Edit File by line
/home/barbar84/www/wp-inclu...
File: theme.php
[500] Fix | Delete
// Start with directories in the root of the current theme directory.
[501] Fix | Delete
$dirs = @ scandir( $theme_root );
[502] Fix | Delete
if ( ! $dirs ) {
[503] Fix | Delete
trigger_error( "$theme_root is not readable", E_USER_NOTICE );
[504] Fix | Delete
continue;
[505] Fix | Delete
}
[506] Fix | Delete
foreach ( $dirs as $dir ) {
[507] Fix | Delete
if ( ! is_dir( $theme_root . '/' . $dir ) || '.' === $dir[0] || 'CVS' === $dir ) {
[508] Fix | Delete
continue;
[509] Fix | Delete
}
[510] Fix | Delete
if ( file_exists( $theme_root . '/' . $dir . '/style.css' ) ) {
[511] Fix | Delete
// wp-content/themes/a-single-theme
[512] Fix | Delete
// wp-content/themes is $theme_root, a-single-theme is $dir.
[513] Fix | Delete
$found_themes[ $dir ] = array(
[514] Fix | Delete
'theme_file' => $dir . '/style.css',
[515] Fix | Delete
'theme_root' => $theme_root,
[516] Fix | Delete
);
[517] Fix | Delete
} else {
[518] Fix | Delete
$found_theme = false;
[519] Fix | Delete
// wp-content/themes/a-folder-of-themes/*
[520] Fix | Delete
// wp-content/themes is $theme_root, a-folder-of-themes is $dir, then themes are $sub_dirs.
[521] Fix | Delete
$sub_dirs = @ scandir( $theme_root . '/' . $dir );
[522] Fix | Delete
if ( ! $sub_dirs ) {
[523] Fix | Delete
trigger_error( "$theme_root/$dir is not readable", E_USER_NOTICE );
[524] Fix | Delete
continue;
[525] Fix | Delete
}
[526] Fix | Delete
foreach ( $sub_dirs as $sub_dir ) {
[527] Fix | Delete
if ( ! is_dir( $theme_root . '/' . $dir . '/' . $sub_dir ) || '.' === $dir[0] || 'CVS' === $dir ) {
[528] Fix | Delete
continue;
[529] Fix | Delete
}
[530] Fix | Delete
if ( ! file_exists( $theme_root . '/' . $dir . '/' . $sub_dir . '/style.css' ) ) {
[531] Fix | Delete
continue;
[532] Fix | Delete
}
[533] Fix | Delete
$found_themes[ $dir . '/' . $sub_dir ] = array(
[534] Fix | Delete
'theme_file' => $dir . '/' . $sub_dir . '/style.css',
[535] Fix | Delete
'theme_root' => $theme_root,
[536] Fix | Delete
);
[537] Fix | Delete
$found_theme = true;
[538] Fix | Delete
}
[539] Fix | Delete
// Never mind the above, it's just a theme missing a style.css.
[540] Fix | Delete
// Return it; WP_Theme will catch the error.
[541] Fix | Delete
if ( ! $found_theme ) {
[542] Fix | Delete
$found_themes[ $dir ] = array(
[543] Fix | Delete
'theme_file' => $dir . '/style.css',
[544] Fix | Delete
'theme_root' => $theme_root,
[545] Fix | Delete
);
[546] Fix | Delete
}
[547] Fix | Delete
}
[548] Fix | Delete
}
[549] Fix | Delete
}
[550] Fix | Delete
[551] Fix | Delete
asort( $found_themes );
[552] Fix | Delete
[553] Fix | Delete
$theme_roots = array();
[554] Fix | Delete
$relative_theme_roots = array_flip( $relative_theme_roots );
[555] Fix | Delete
[556] Fix | Delete
foreach ( $found_themes as $theme_dir => $theme_data ) {
[557] Fix | Delete
$theme_roots[ $theme_dir ] = $relative_theme_roots[ $theme_data['theme_root'] ]; // Convert absolute to relative.
[558] Fix | Delete
}
[559] Fix | Delete
[560] Fix | Delete
if ( get_site_transient( 'theme_roots' ) != $theme_roots ) {
[561] Fix | Delete
set_site_transient( 'theme_roots', $theme_roots, $cache_expiration );
[562] Fix | Delete
}
[563] Fix | Delete
[564] Fix | Delete
return $found_themes;
[565] Fix | Delete
}
[566] Fix | Delete
[567] Fix | Delete
/**
[568] Fix | Delete
* Retrieves path to themes directory.
[569] Fix | Delete
*
[570] Fix | Delete
* Does not have trailing slash.
[571] Fix | Delete
*
[572] Fix | Delete
* @since 1.5.0
[573] Fix | Delete
*
[574] Fix | Delete
* @global array $wp_theme_directories
[575] Fix | Delete
*
[576] Fix | Delete
* @param string $stylesheet_or_template Optional. The stylesheet or template name of the theme.
[577] Fix | Delete
* Default is to leverage the main theme root.
[578] Fix | Delete
* @return string Themes directory path.
[579] Fix | Delete
*/
[580] Fix | Delete
function get_theme_root( $stylesheet_or_template = '' ) {
[581] Fix | Delete
global $wp_theme_directories;
[582] Fix | Delete
[583] Fix | Delete
$theme_root = '';
[584] Fix | Delete
[585] Fix | Delete
if ( $stylesheet_or_template ) {
[586] Fix | Delete
$theme_root = get_raw_theme_root( $stylesheet_or_template );
[587] Fix | Delete
if ( $theme_root ) {
[588] Fix | Delete
// Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.
[589] Fix | Delete
// This gives relative theme roots the benefit of the doubt when things go haywire.
[590] Fix | Delete
if ( ! in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
[591] Fix | Delete
$theme_root = WP_CONTENT_DIR . $theme_root;
[592] Fix | Delete
}
[593] Fix | Delete
}
[594] Fix | Delete
}
[595] Fix | Delete
[596] Fix | Delete
if ( ! $theme_root ) {
[597] Fix | Delete
$theme_root = WP_CONTENT_DIR . '/themes';
[598] Fix | Delete
}
[599] Fix | Delete
[600] Fix | Delete
/**
[601] Fix | Delete
* Filters the absolute path to the themes directory.
[602] Fix | Delete
*
[603] Fix | Delete
* @since 1.5.0
[604] Fix | Delete
*
[605] Fix | Delete
* @param string $theme_root Absolute path to themes directory.
[606] Fix | Delete
*/
[607] Fix | Delete
return apply_filters( 'theme_root', $theme_root );
[608] Fix | Delete
}
[609] Fix | Delete
[610] Fix | Delete
/**
[611] Fix | Delete
* Retrieves URI for themes directory.
[612] Fix | Delete
*
[613] Fix | Delete
* Does not have trailing slash.
[614] Fix | Delete
*
[615] Fix | Delete
* @since 1.5.0
[616] Fix | Delete
*
[617] Fix | Delete
* @global array $wp_theme_directories
[618] Fix | Delete
*
[619] Fix | Delete
* @param string $stylesheet_or_template Optional. The stylesheet or template name of the theme.
[620] Fix | Delete
* Default is to leverage the main theme root.
[621] Fix | Delete
* @param string $theme_root Optional. The theme root for which calculations will be based,
[622] Fix | Delete
* preventing the need for a get_raw_theme_root() call. Default empty.
[623] Fix | Delete
* @return string Themes directory URI.
[624] Fix | Delete
*/
[625] Fix | Delete
function get_theme_root_uri( $stylesheet_or_template = '', $theme_root = '' ) {
[626] Fix | Delete
global $wp_theme_directories;
[627] Fix | Delete
[628] Fix | Delete
if ( $stylesheet_or_template && ! $theme_root ) {
[629] Fix | Delete
$theme_root = get_raw_theme_root( $stylesheet_or_template );
[630] Fix | Delete
}
[631] Fix | Delete
[632] Fix | Delete
if ( $stylesheet_or_template && $theme_root ) {
[633] Fix | Delete
if ( in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
[634] Fix | Delete
// Absolute path. Make an educated guess. YMMV -- but note the filter below.
[635] Fix | Delete
if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) ) {
[636] Fix | Delete
$theme_root_uri = content_url( str_replace( WP_CONTENT_DIR, '', $theme_root ) );
[637] Fix | Delete
} elseif ( 0 === strpos( $theme_root, ABSPATH ) ) {
[638] Fix | Delete
$theme_root_uri = site_url( str_replace( ABSPATH, '', $theme_root ) );
[639] Fix | Delete
} elseif ( 0 === strpos( $theme_root, WP_PLUGIN_DIR ) || 0 === strpos( $theme_root, WPMU_PLUGIN_DIR ) ) {
[640] Fix | Delete
$theme_root_uri = plugins_url( basename( $theme_root ), $theme_root );
[641] Fix | Delete
} else {
[642] Fix | Delete
$theme_root_uri = $theme_root;
[643] Fix | Delete
}
[644] Fix | Delete
} else {
[645] Fix | Delete
$theme_root_uri = content_url( $theme_root );
[646] Fix | Delete
}
[647] Fix | Delete
} else {
[648] Fix | Delete
$theme_root_uri = content_url( 'themes' );
[649] Fix | Delete
}
[650] Fix | Delete
[651] Fix | Delete
/**
[652] Fix | Delete
* Filters the URI for themes directory.
[653] Fix | Delete
*
[654] Fix | Delete
* @since 1.5.0
[655] Fix | Delete
*
[656] Fix | Delete
* @param string $theme_root_uri The URI for themes directory.
[657] Fix | Delete
* @param string $siteurl WordPress web address which is set in General Options.
[658] Fix | Delete
* @param string $stylesheet_or_template The stylesheet or template name of the theme.
[659] Fix | Delete
*/
[660] Fix | Delete
return apply_filters( 'theme_root_uri', $theme_root_uri, get_option( 'siteurl' ), $stylesheet_or_template );
[661] Fix | Delete
}
[662] Fix | Delete
[663] Fix | Delete
/**
[664] Fix | Delete
* Gets the raw theme root relative to the content directory with no filters applied.
[665] Fix | Delete
*
[666] Fix | Delete
* @since 3.1.0
[667] Fix | Delete
*
[668] Fix | Delete
* @global array $wp_theme_directories
[669] Fix | Delete
*
[670] Fix | Delete
* @param string $stylesheet_or_template The stylesheet or template name of the theme.
[671] Fix | Delete
* @param bool $skip_cache Optional. Whether to skip the cache.
[672] Fix | Delete
* Defaults to false, meaning the cache is used.
[673] Fix | Delete
* @return string Theme root.
[674] Fix | Delete
*/
[675] Fix | Delete
function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) {
[676] Fix | Delete
global $wp_theme_directories;
[677] Fix | Delete
[678] Fix | Delete
if ( ! is_array( $wp_theme_directories ) || count( $wp_theme_directories ) <= 1 ) {
[679] Fix | Delete
return '/themes';
[680] Fix | Delete
}
[681] Fix | Delete
[682] Fix | Delete
$theme_root = false;
[683] Fix | Delete
[684] Fix | Delete
// If requesting the root for the current theme, consult options to avoid calling get_theme_roots().
[685] Fix | Delete
if ( ! $skip_cache ) {
[686] Fix | Delete
if ( get_option( 'stylesheet' ) == $stylesheet_or_template ) {
[687] Fix | Delete
$theme_root = get_option( 'stylesheet_root' );
[688] Fix | Delete
} elseif ( get_option( 'template' ) == $stylesheet_or_template ) {
[689] Fix | Delete
$theme_root = get_option( 'template_root' );
[690] Fix | Delete
}
[691] Fix | Delete
}
[692] Fix | Delete
[693] Fix | Delete
if ( empty( $theme_root ) ) {
[694] Fix | Delete
$theme_roots = get_theme_roots();
[695] Fix | Delete
if ( ! empty( $theme_roots[ $stylesheet_or_template ] ) ) {
[696] Fix | Delete
$theme_root = $theme_roots[ $stylesheet_or_template ];
[697] Fix | Delete
}
[698] Fix | Delete
}
[699] Fix | Delete
[700] Fix | Delete
return $theme_root;
[701] Fix | Delete
}
[702] Fix | Delete
[703] Fix | Delete
/**
[704] Fix | Delete
* Displays localized stylesheet link element.
[705] Fix | Delete
*
[706] Fix | Delete
* @since 2.1.0
[707] Fix | Delete
*/
[708] Fix | Delete
function locale_stylesheet() {
[709] Fix | Delete
$stylesheet = get_locale_stylesheet_uri();
[710] Fix | Delete
if ( empty( $stylesheet ) ) {
[711] Fix | Delete
return;
[712] Fix | Delete
}
[713] Fix | Delete
[714] Fix | Delete
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
[715] Fix | Delete
[716] Fix | Delete
printf(
[717] Fix | Delete
'<link rel="stylesheet" href="%s"%s media="screen" />',
[718] Fix | Delete
$stylesheet,
[719] Fix | Delete
$type_attr
[720] Fix | Delete
);
[721] Fix | Delete
}
[722] Fix | Delete
[723] Fix | Delete
/**
[724] Fix | Delete
* Switches the theme.
[725] Fix | Delete
*
[726] Fix | Delete
* Accepts one argument: $stylesheet of the theme. It also accepts an additional function signature
[727] Fix | Delete
* of two arguments: $template then $stylesheet. This is for backward compatibility.
[728] Fix | Delete
*
[729] Fix | Delete
* @since 2.5.0
[730] Fix | Delete
*
[731] Fix | Delete
* @global array $wp_theme_directories
[732] Fix | Delete
* @global WP_Customize_Manager $wp_customize
[733] Fix | Delete
* @global array $sidebars_widgets
[734] Fix | Delete
*
[735] Fix | Delete
* @param string $stylesheet Stylesheet name.
[736] Fix | Delete
*/
[737] Fix | Delete
function switch_theme( $stylesheet ) {
[738] Fix | Delete
global $wp_theme_directories, $wp_customize, $sidebars_widgets;
[739] Fix | Delete
[740] Fix | Delete
$requirements = validate_theme_requirements( $stylesheet );
[741] Fix | Delete
if ( is_wp_error( $requirements ) ) {
[742] Fix | Delete
wp_die( $requirements );
[743] Fix | Delete
}
[744] Fix | Delete
[745] Fix | Delete
$_sidebars_widgets = null;
[746] Fix | Delete
if ( 'wp_ajax_customize_save' === current_action() ) {
[747] Fix | Delete
$old_sidebars_widgets_data_setting = $wp_customize->get_setting( 'old_sidebars_widgets_data' );
[748] Fix | Delete
if ( $old_sidebars_widgets_data_setting ) {
[749] Fix | Delete
$_sidebars_widgets = $wp_customize->post_value( $old_sidebars_widgets_data_setting );
[750] Fix | Delete
}
[751] Fix | Delete
} elseif ( is_array( $sidebars_widgets ) ) {
[752] Fix | Delete
$_sidebars_widgets = $sidebars_widgets;
[753] Fix | Delete
}
[754] Fix | Delete
[755] Fix | Delete
if ( is_array( $_sidebars_widgets ) ) {
[756] Fix | Delete
set_theme_mod(
[757] Fix | Delete
'sidebars_widgets',
[758] Fix | Delete
array(
[759] Fix | Delete
'time' => time(),
[760] Fix | Delete
'data' => $_sidebars_widgets,
[761] Fix | Delete
)
[762] Fix | Delete
);
[763] Fix | Delete
}
[764] Fix | Delete
[765] Fix | Delete
$nav_menu_locations = get_theme_mod( 'nav_menu_locations' );
[766] Fix | Delete
update_option( 'theme_switch_menu_locations', $nav_menu_locations );
[767] Fix | Delete
[768] Fix | Delete
if ( func_num_args() > 1 ) {
[769] Fix | Delete
$stylesheet = func_get_arg( 1 );
[770] Fix | Delete
}
[771] Fix | Delete
[772] Fix | Delete
$old_theme = wp_get_theme();
[773] Fix | Delete
$new_theme = wp_get_theme( $stylesheet );
[774] Fix | Delete
$template = $new_theme->get_template();
[775] Fix | Delete
[776] Fix | Delete
if ( wp_is_recovery_mode() ) {
[777] Fix | Delete
$paused_themes = wp_paused_themes();
[778] Fix | Delete
$paused_themes->delete( $old_theme->get_stylesheet() );
[779] Fix | Delete
$paused_themes->delete( $old_theme->get_template() );
[780] Fix | Delete
}
[781] Fix | Delete
[782] Fix | Delete
update_option( 'template', $template );
[783] Fix | Delete
update_option( 'stylesheet', $stylesheet );
[784] Fix | Delete
[785] Fix | Delete
if ( count( $wp_theme_directories ) > 1 ) {
[786] Fix | Delete
update_option( 'template_root', get_raw_theme_root( $template, true ) );
[787] Fix | Delete
update_option( 'stylesheet_root', get_raw_theme_root( $stylesheet, true ) );
[788] Fix | Delete
} else {
[789] Fix | Delete
delete_option( 'template_root' );
[790] Fix | Delete
delete_option( 'stylesheet_root' );
[791] Fix | Delete
}
[792] Fix | Delete
[793] Fix | Delete
$new_name = $new_theme->get( 'Name' );
[794] Fix | Delete
[795] Fix | Delete
update_option( 'current_theme', $new_name );
[796] Fix | Delete
[797] Fix | Delete
// Migrate from the old mods_{name} option to theme_mods_{slug}.
[798] Fix | Delete
if ( is_admin() && false === get_option( 'theme_mods_' . $stylesheet ) ) {
[799] Fix | Delete
$default_theme_mods = (array) get_option( 'mods_' . $new_name );
[800] Fix | Delete
if ( ! empty( $nav_menu_locations ) && empty( $default_theme_mods['nav_menu_locations'] ) ) {
[801] Fix | Delete
$default_theme_mods['nav_menu_locations'] = $nav_menu_locations;
[802] Fix | Delete
}
[803] Fix | Delete
add_option( "theme_mods_$stylesheet", $default_theme_mods );
[804] Fix | Delete
} else {
[805] Fix | Delete
/*
[806] Fix | Delete
* Since retrieve_widgets() is called when initializing a theme in the Customizer,
[807] Fix | Delete
* we need to remove the theme mods to avoid overwriting changes made via
[808] Fix | Delete
* the Customizer when accessing wp-admin/widgets.php.
[809] Fix | Delete
*/
[810] Fix | Delete
if ( 'wp_ajax_customize_save' === current_action() ) {
[811] Fix | Delete
remove_theme_mod( 'sidebars_widgets' );
[812] Fix | Delete
}
[813] Fix | Delete
}
[814] Fix | Delete
[815] Fix | Delete
update_option( 'theme_switched', $old_theme->get_stylesheet() );
[816] Fix | Delete
[817] Fix | Delete
/**
[818] Fix | Delete
* Fires after the theme is switched.
[819] Fix | Delete
*
[820] Fix | Delete
* @since 1.5.0
[821] Fix | Delete
* @since 4.5.0 Introduced the `$old_theme` parameter.
[822] Fix | Delete
*
[823] Fix | Delete
* @param string $new_name Name of the new theme.
[824] Fix | Delete
* @param WP_Theme $new_theme WP_Theme instance of the new theme.
[825] Fix | Delete
* @param WP_Theme $old_theme WP_Theme instance of the old theme.
[826] Fix | Delete
*/
[827] Fix | Delete
do_action( 'switch_theme', $new_name, $new_theme, $old_theme );
[828] Fix | Delete
}
[829] Fix | Delete
[830] Fix | Delete
/**
[831] Fix | Delete
* Checks that the current theme has 'index.php' and 'style.css' files.
[832] Fix | Delete
*
[833] Fix | Delete
* Does not initially check the default theme, which is the fallback and should always exist.
[834] Fix | Delete
* But if it doesn't exist, it'll fall back to the latest core default theme that does exist.
[835] Fix | Delete
* Will switch theme to the fallback theme if current theme does not validate.
[836] Fix | Delete
*
[837] Fix | Delete
* You can use the {@see 'validate_current_theme'} filter to return false to disable
[838] Fix | Delete
* this functionality.
[839] Fix | Delete
*
[840] Fix | Delete
* @since 1.5.0
[841] Fix | Delete
*
[842] Fix | Delete
* @see WP_DEFAULT_THEME
[843] Fix | Delete
*
[844] Fix | Delete
* @return bool
[845] Fix | Delete
*/
[846] Fix | Delete
function validate_current_theme() {
[847] Fix | Delete
/**
[848] Fix | Delete
* Filters whether to validate the current theme.
[849] Fix | Delete
*
[850] Fix | Delete
* @since 2.7.0
[851] Fix | Delete
*
[852] Fix | Delete
* @param bool $validate Whether to validate the current theme. Default true.
[853] Fix | Delete
*/
[854] Fix | Delete
if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) ) {
[855] Fix | Delete
return true;
[856] Fix | Delete
}
[857] Fix | Delete
[858] Fix | Delete
if ( ! file_exists( get_template_directory() . '/index.php' ) ) {
[859] Fix | Delete
// Invalid.
[860] Fix | Delete
} elseif ( ! file_exists( get_template_directory() . '/style.css' ) ) {
[861] Fix | Delete
// Invalid.
[862] Fix | Delete
} elseif ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
[863] Fix | Delete
// Invalid.
[864] Fix | Delete
} else {
[865] Fix | Delete
// Valid.
[866] Fix | Delete
return true;
[867] Fix | Delete
}
[868] Fix | Delete
[869] Fix | Delete
$default = wp_get_theme( WP_DEFAULT_THEME );
[870] Fix | Delete
if ( $default->exists() ) {
[871] Fix | Delete
switch_theme( WP_DEFAULT_THEME );
[872] Fix | Delete
return false;
[873] Fix | Delete
}
[874] Fix | Delete
[875] Fix | Delete
/**
[876] Fix | Delete
* If we're in an invalid state but WP_DEFAULT_THEME doesn't exist,
[877] Fix | Delete
* switch to the latest core default theme that's installed.
[878] Fix | Delete
*
[879] Fix | Delete
* If it turns out that this latest core default theme is our current
[880] Fix | Delete
* theme, then there's nothing we can do about that, so we have to bail,
[881] Fix | Delete
* rather than going into an infinite loop. (This is why there are
[882] Fix | Delete
* checks against WP_DEFAULT_THEME above, also.) We also can't do anything
[883] Fix | Delete
* if it turns out there is no default theme installed. (That's `false`.)
[884] Fix | Delete
*/
[885] Fix | Delete
$default = WP_Theme::get_core_default_theme();
[886] Fix | Delete
if ( false === $default || get_stylesheet() == $default->get_stylesheet() ) {
[887] Fix | Delete
return true;
[888] Fix | Delete
}
[889] Fix | Delete
[890] Fix | Delete
switch_theme( $default->get_stylesheet() );
[891] Fix | Delete
return false;
[892] Fix | Delete
}
[893] Fix | Delete
[894] Fix | Delete
/**
[895] Fix | Delete
* Validates the theme requirements for WordPress version and PHP version.
[896] Fix | Delete
*
[897] Fix | Delete
* Uses the information from `Requires at least` and `Requires PHP` headers
[898] Fix | Delete
* defined in the theme's `style.css` file.
[899] Fix | Delete
*
[900] Fix | Delete
* If the headers are not present in the theme's stylesheet file,
[901] Fix | Delete
* `readme.txt` is also checked as a fallback.
[902] Fix | Delete
*
[903] Fix | Delete
* @since 5.5.0
[904] Fix | Delete
*
[905] Fix | Delete
* @param string $stylesheet Directory name for the theme.
[906] Fix | Delete
* @return true|WP_Error True if requirements are met, WP_Error on failure.
[907] Fix | Delete
*/
[908] Fix | Delete
function validate_theme_requirements( $stylesheet ) {
[909] Fix | Delete
$theme = wp_get_theme( $stylesheet );
[910] Fix | Delete
[911] Fix | Delete
$requirements = array(
[912] Fix | Delete
'requires' => ! empty( $theme->get( 'RequiresWP' ) ) ? $theme->get( 'RequiresWP' ) : '',
[913] Fix | Delete
'requires_php' => ! empty( $theme->get( 'RequiresPHP' ) ) ? $theme->get( 'RequiresPHP' ) : '',
[914] Fix | Delete
);
[915] Fix | Delete
[916] Fix | Delete
$readme_file = $theme->theme_root . '/' . $stylesheet . '/readme.txt';
[917] Fix | Delete
[918] Fix | Delete
if ( file_exists( $readme_file ) ) {
[919] Fix | Delete
$readme_headers = get_file_data(
[920] Fix | Delete
$readme_file,
[921] Fix | Delete
array(
[922] Fix | Delete
'requires' => 'Requires at least',
[923] Fix | Delete
'requires_php' => 'Requires PHP',
[924] Fix | Delete
),
[925] Fix | Delete
'theme'
[926] Fix | Delete
);
[927] Fix | Delete
[928] Fix | Delete
$requirements = array_merge( $readme_headers, $requirements );
[929] Fix | Delete
}
[930] Fix | Delete
[931] Fix | Delete
$compatible_wp = is_wp_version_compatible( $requirements['requires'] );
[932] Fix | Delete
$compatible_php = is_php_version_compatible( $requirements['requires_php'] );
[933] Fix | Delete
[934] Fix | Delete
if ( ! $compatible_wp && ! $compatible_php ) {
[935] Fix | Delete
return new WP_Error(
[936] Fix | Delete
'theme_wp_php_incompatible',
[937] Fix | Delete
sprintf(
[938] Fix | Delete
/* translators: %s: Theme name. */
[939] Fix | Delete
_x( '<strong>Error:</strong> Current WordPress and PHP versions do not meet minimum requirements for %s.', 'theme' ),
[940] Fix | Delete
$theme->display( 'Name' )
[941] Fix | Delete
)
[942] Fix | Delete
);
[943] Fix | Delete
} elseif ( ! $compatible_php ) {
[944] Fix | Delete
return new WP_Error(
[945] Fix | Delete
'theme_php_incompatible',
[946] Fix | Delete
sprintf(
[947] Fix | Delete
/* translators: %s: Theme name. */
[948] Fix | Delete
_x( '<strong>Error:</strong> Current PHP version does not meet minimum requirements for %s.', 'theme' ),
[949] Fix | Delete
$theme->display( 'Name' )
[950] Fix | Delete
)
[951] Fix | Delete
);
[952] Fix | Delete
} elseif ( ! $compatible_wp ) {
[953] Fix | Delete
return new WP_Error(
[954] Fix | Delete
'theme_wp_incompatible',
[955] Fix | Delete
sprintf(
[956] Fix | Delete
/* translators: %s: Theme name. */
[957] Fix | Delete
_x( '<strong>Error:</strong> Current WordPress version does not meet minimum requirements for %s.', 'theme' ),
[958] Fix | Delete
$theme->display( 'Name' )
[959] Fix | Delete
)
[960] Fix | Delete
);
[961] Fix | Delete
}
[962] Fix | Delete
[963] Fix | Delete
return true;
[964] Fix | Delete
}
[965] Fix | Delete
[966] Fix | Delete
/**
[967] Fix | Delete
* Retrieves all theme modifications.
[968] Fix | Delete
*
[969] Fix | Delete
* @since 3.1.0
[970] Fix | Delete
*
[971] Fix | Delete
* @return array|void Theme modifications.
[972] Fix | Delete
*/
[973] Fix | Delete
function get_theme_mods() {
[974] Fix | Delete
$theme_slug = get_option( 'stylesheet' );
[975] Fix | Delete
$mods = get_option( "theme_mods_$theme_slug" );
[976] Fix | Delete
if ( false === $mods ) {
[977] Fix | Delete
$theme_name = get_option( 'current_theme' );
[978] Fix | Delete
if ( false === $theme_name ) {
[979] Fix | Delete
$theme_name = wp_get_theme()->get( 'Name' );
[980] Fix | Delete
}
[981] Fix | Delete
$mods = get_option( "mods_$theme_name" ); // Deprecated location.
[982] Fix | Delete
if ( is_admin() && false !== $mods ) {
[983] Fix | Delete
update_option( "theme_mods_$theme_slug", $mods );
[984] Fix | Delete
delete_option( "mods_$theme_name" );
[985] Fix | Delete
}
[986] Fix | Delete
}
[987] Fix | Delete
return $mods;
[988] Fix | Delete
}
[989] Fix | Delete
[990] Fix | Delete
/**
[991] Fix | Delete
* Retrieves theme modification value for the current theme.
[992] Fix | Delete
*
[993] Fix | Delete
* If the modification name does not exist, then the $default will be passed
[994] Fix | Delete
* through {@link https://www.php.net/sprintf sprintf()} PHP function with
[995] Fix | Delete
* the template directory URI as the first string and the stylesheet directory URI
[996] Fix | Delete
* as the second string.
[997] Fix | Delete
*
[998] Fix | Delete
* @since 2.1.0
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function