Edit File by line
/home/barbar84/www/wp-inclu...
File: class-wp-theme.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WP_Theme Class
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Theme
[5] Fix | Delete
* @since 3.4.0
[6] Fix | Delete
*/
[7] Fix | Delete
final class WP_Theme implements ArrayAccess {
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Whether the theme has been marked as updateable.
[11] Fix | Delete
*
[12] Fix | Delete
* @since 4.4.0
[13] Fix | Delete
* @var bool
[14] Fix | Delete
*
[15] Fix | Delete
* @see WP_MS_Themes_List_Table
[16] Fix | Delete
*/
[17] Fix | Delete
public $update = false;
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Headers for style.css files.
[21] Fix | Delete
*
[22] Fix | Delete
* @since 3.4.0
[23] Fix | Delete
* @since 5.4.0 Added `Requires at least` and `Requires PHP` headers.
[24] Fix | Delete
* @var array
[25] Fix | Delete
*/
[26] Fix | Delete
private static $file_headers = array(
[27] Fix | Delete
'Name' => 'Theme Name',
[28] Fix | Delete
'ThemeURI' => 'Theme URI',
[29] Fix | Delete
'Description' => 'Description',
[30] Fix | Delete
'Author' => 'Author',
[31] Fix | Delete
'AuthorURI' => 'Author URI',
[32] Fix | Delete
'Version' => 'Version',
[33] Fix | Delete
'Template' => 'Template',
[34] Fix | Delete
'Status' => 'Status',
[35] Fix | Delete
'Tags' => 'Tags',
[36] Fix | Delete
'TextDomain' => 'Text Domain',
[37] Fix | Delete
'DomainPath' => 'Domain Path',
[38] Fix | Delete
'RequiresWP' => 'Requires at least',
[39] Fix | Delete
'RequiresPHP' => 'Requires PHP',
[40] Fix | Delete
);
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Default themes.
[44] Fix | Delete
*
[45] Fix | Delete
* @var array
[46] Fix | Delete
*/
[47] Fix | Delete
private static $default_themes = array(
[48] Fix | Delete
'classic' => 'WordPress Classic',
[49] Fix | Delete
'default' => 'WordPress Default',
[50] Fix | Delete
'twentyten' => 'Twenty Ten',
[51] Fix | Delete
'twentyeleven' => 'Twenty Eleven',
[52] Fix | Delete
'twentytwelve' => 'Twenty Twelve',
[53] Fix | Delete
'twentythirteen' => 'Twenty Thirteen',
[54] Fix | Delete
'twentyfourteen' => 'Twenty Fourteen',
[55] Fix | Delete
'twentyfifteen' => 'Twenty Fifteen',
[56] Fix | Delete
'twentysixteen' => 'Twenty Sixteen',
[57] Fix | Delete
'twentyseventeen' => 'Twenty Seventeen',
[58] Fix | Delete
'twentynineteen' => 'Twenty Nineteen',
[59] Fix | Delete
'twentytwenty' => 'Twenty Twenty',
[60] Fix | Delete
'twentytwentyone' => 'Twenty Twenty-One',
[61] Fix | Delete
);
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Renamed theme tags.
[65] Fix | Delete
*
[66] Fix | Delete
* @var array
[67] Fix | Delete
*/
[68] Fix | Delete
private static $tag_map = array(
[69] Fix | Delete
'fixed-width' => 'fixed-layout',
[70] Fix | Delete
'flexible-width' => 'fluid-layout',
[71] Fix | Delete
);
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Absolute path to the theme root, usually wp-content/themes
[75] Fix | Delete
*
[76] Fix | Delete
* @var string
[77] Fix | Delete
*/
[78] Fix | Delete
private $theme_root;
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Header data from the theme's style.css file.
[82] Fix | Delete
*
[83] Fix | Delete
* @var array
[84] Fix | Delete
*/
[85] Fix | Delete
private $headers = array();
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Header data from the theme's style.css file after being sanitized.
[89] Fix | Delete
*
[90] Fix | Delete
* @var array
[91] Fix | Delete
*/
[92] Fix | Delete
private $headers_sanitized;
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Header name from the theme's style.css after being translated.
[96] Fix | Delete
*
[97] Fix | Delete
* Cached due to sorting functions running over the translated name.
[98] Fix | Delete
*
[99] Fix | Delete
* @var string
[100] Fix | Delete
*/
[101] Fix | Delete
private $name_translated;
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Errors encountered when initializing the theme.
[105] Fix | Delete
*
[106] Fix | Delete
* @var WP_Error
[107] Fix | Delete
*/
[108] Fix | Delete
private $errors;
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* The directory name of the theme's files, inside the theme root.
[112] Fix | Delete
*
[113] Fix | Delete
* In the case of a child theme, this is directory name of the child theme.
[114] Fix | Delete
* Otherwise, 'stylesheet' is the same as 'template'.
[115] Fix | Delete
*
[116] Fix | Delete
* @var string
[117] Fix | Delete
*/
[118] Fix | Delete
private $stylesheet;
[119] Fix | Delete
[120] Fix | Delete
/**
[121] Fix | Delete
* The directory name of the theme's files, inside the theme root.
[122] Fix | Delete
*
[123] Fix | Delete
* In the case of a child theme, this is the directory name of the parent theme.
[124] Fix | Delete
* Otherwise, 'template' is the same as 'stylesheet'.
[125] Fix | Delete
*
[126] Fix | Delete
* @var string
[127] Fix | Delete
*/
[128] Fix | Delete
private $template;
[129] Fix | Delete
[130] Fix | Delete
/**
[131] Fix | Delete
* A reference to the parent theme, in the case of a child theme.
[132] Fix | Delete
*
[133] Fix | Delete
* @var WP_Theme
[134] Fix | Delete
*/
[135] Fix | Delete
private $parent;
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* URL to the theme root, usually an absolute URL to wp-content/themes
[139] Fix | Delete
*
[140] Fix | Delete
* @var string
[141] Fix | Delete
*/
[142] Fix | Delete
private $theme_root_uri;
[143] Fix | Delete
[144] Fix | Delete
/**
[145] Fix | Delete
* Flag for whether the theme's textdomain is loaded.
[146] Fix | Delete
*
[147] Fix | Delete
* @var bool
[148] Fix | Delete
*/
[149] Fix | Delete
private $textdomain_loaded;
[150] Fix | Delete
[151] Fix | Delete
/**
[152] Fix | Delete
* Stores an md5 hash of the theme root, to function as the cache key.
[153] Fix | Delete
*
[154] Fix | Delete
* @var string
[155] Fix | Delete
*/
[156] Fix | Delete
private $cache_hash;
[157] Fix | Delete
[158] Fix | Delete
/**
[159] Fix | Delete
* Flag for whether the themes cache bucket should be persistently cached.
[160] Fix | Delete
*
[161] Fix | Delete
* Default is false. Can be set with the {@see 'wp_cache_themes_persistently'} filter.
[162] Fix | Delete
*
[163] Fix | Delete
* @var bool
[164] Fix | Delete
*/
[165] Fix | Delete
private static $persistently_cache;
[166] Fix | Delete
[167] Fix | Delete
/**
[168] Fix | Delete
* Expiration time for the themes cache bucket.
[169] Fix | Delete
*
[170] Fix | Delete
* By default the bucket is not cached, so this value is useless.
[171] Fix | Delete
*
[172] Fix | Delete
* @var bool
[173] Fix | Delete
*/
[174] Fix | Delete
private static $cache_expiration = 1800;
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* Constructor for WP_Theme.
[178] Fix | Delete
*
[179] Fix | Delete
* @since 3.4.0
[180] Fix | Delete
*
[181] Fix | Delete
* @global array $wp_theme_directories
[182] Fix | Delete
*
[183] Fix | Delete
* @param string $theme_dir Directory of the theme within the theme_root.
[184] Fix | Delete
* @param string $theme_root Theme root.
[185] Fix | Delete
* @param WP_Theme|null $_child If this theme is a parent theme, the child may be passed for validation purposes.
[186] Fix | Delete
*/
[187] Fix | Delete
public function __construct( $theme_dir, $theme_root, $_child = null ) {
[188] Fix | Delete
global $wp_theme_directories;
[189] Fix | Delete
[190] Fix | Delete
// Initialize caching on first run.
[191] Fix | Delete
if ( ! isset( self::$persistently_cache ) ) {
[192] Fix | Delete
/** This action is documented in wp-includes/theme.php */
[193] Fix | Delete
self::$persistently_cache = apply_filters( 'wp_cache_themes_persistently', false, 'WP_Theme' );
[194] Fix | Delete
if ( self::$persistently_cache ) {
[195] Fix | Delete
wp_cache_add_global_groups( 'themes' );
[196] Fix | Delete
if ( is_int( self::$persistently_cache ) ) {
[197] Fix | Delete
self::$cache_expiration = self::$persistently_cache;
[198] Fix | Delete
}
[199] Fix | Delete
} else {
[200] Fix | Delete
wp_cache_add_non_persistent_groups( 'themes' );
[201] Fix | Delete
}
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
$this->theme_root = $theme_root;
[205] Fix | Delete
$this->stylesheet = $theme_dir;
[206] Fix | Delete
[207] Fix | Delete
// Correct a situation where the theme is 'some-directory/some-theme' but 'some-directory' was passed in as part of the theme root instead.
[208] Fix | Delete
if ( ! in_array( $theme_root, (array) $wp_theme_directories, true )
[209] Fix | Delete
&& in_array( dirname( $theme_root ), (array) $wp_theme_directories, true )
[210] Fix | Delete
) {
[211] Fix | Delete
$this->stylesheet = basename( $this->theme_root ) . '/' . $this->stylesheet;
[212] Fix | Delete
$this->theme_root = dirname( $theme_root );
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
$this->cache_hash = md5( $this->theme_root . '/' . $this->stylesheet );
[216] Fix | Delete
$theme_file = $this->stylesheet . '/style.css';
[217] Fix | Delete
[218] Fix | Delete
$cache = $this->cache_get( 'theme' );
[219] Fix | Delete
[220] Fix | Delete
if ( is_array( $cache ) ) {
[221] Fix | Delete
foreach ( array( 'errors', 'headers', 'template' ) as $key ) {
[222] Fix | Delete
if ( isset( $cache[ $key ] ) ) {
[223] Fix | Delete
$this->$key = $cache[ $key ];
[224] Fix | Delete
}
[225] Fix | Delete
}
[226] Fix | Delete
if ( $this->errors ) {
[227] Fix | Delete
return;
[228] Fix | Delete
}
[229] Fix | Delete
if ( isset( $cache['theme_root_template'] ) ) {
[230] Fix | Delete
$theme_root_template = $cache['theme_root_template'];
[231] Fix | Delete
}
[232] Fix | Delete
} elseif ( ! file_exists( $this->theme_root . '/' . $theme_file ) ) {
[233] Fix | Delete
$this->headers['Name'] = $this->stylesheet;
[234] Fix | Delete
if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet ) ) {
[235] Fix | Delete
$this->errors = new WP_Error(
[236] Fix | Delete
'theme_not_found',
[237] Fix | Delete
sprintf(
[238] Fix | Delete
/* translators: %s: Theme directory name. */
[239] Fix | Delete
__( 'The theme directory "%s" does not exist.' ),
[240] Fix | Delete
esc_html( $this->stylesheet )
[241] Fix | Delete
)
[242] Fix | Delete
);
[243] Fix | Delete
} else {
[244] Fix | Delete
$this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) );
[245] Fix | Delete
}
[246] Fix | Delete
$this->template = $this->stylesheet;
[247] Fix | Delete
$this->cache_add(
[248] Fix | Delete
'theme',
[249] Fix | Delete
array(
[250] Fix | Delete
'headers' => $this->headers,
[251] Fix | Delete
'errors' => $this->errors,
[252] Fix | Delete
'stylesheet' => $this->stylesheet,
[253] Fix | Delete
'template' => $this->template,
[254] Fix | Delete
)
[255] Fix | Delete
);
[256] Fix | Delete
if ( ! file_exists( $this->theme_root ) ) { // Don't cache this one.
[257] Fix | Delete
$this->errors->add( 'theme_root_missing', __( 'Error: The themes directory is either empty or doesn&#8217;t exist. Please check your installation.' ) );
[258] Fix | Delete
}
[259] Fix | Delete
return;
[260] Fix | Delete
} elseif ( ! is_readable( $this->theme_root . '/' . $theme_file ) ) {
[261] Fix | Delete
$this->headers['Name'] = $this->stylesheet;
[262] Fix | Delete
$this->errors = new WP_Error( 'theme_stylesheet_not_readable', __( 'Stylesheet is not readable.' ) );
[263] Fix | Delete
$this->template = $this->stylesheet;
[264] Fix | Delete
$this->cache_add(
[265] Fix | Delete
'theme',
[266] Fix | Delete
array(
[267] Fix | Delete
'headers' => $this->headers,
[268] Fix | Delete
'errors' => $this->errors,
[269] Fix | Delete
'stylesheet' => $this->stylesheet,
[270] Fix | Delete
'template' => $this->template,
[271] Fix | Delete
)
[272] Fix | Delete
);
[273] Fix | Delete
return;
[274] Fix | Delete
} else {
[275] Fix | Delete
$this->headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' );
[276] Fix | Delete
// Default themes always trump their pretenders.
[277] Fix | Delete
// Properly identify default themes that are inside a directory within wp-content/themes.
[278] Fix | Delete
$default_theme_slug = array_search( $this->headers['Name'], self::$default_themes, true );
[279] Fix | Delete
if ( $default_theme_slug ) {
[280] Fix | Delete
if ( basename( $this->stylesheet ) != $default_theme_slug ) {
[281] Fix | Delete
$this->headers['Name'] .= '/' . $this->stylesheet;
[282] Fix | Delete
}
[283] Fix | Delete
}
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
if ( ! $this->template && $this->stylesheet === $this->headers['Template'] ) {
[287] Fix | Delete
$this->errors = new WP_Error(
[288] Fix | Delete
'theme_child_invalid',
[289] Fix | Delete
sprintf(
[290] Fix | Delete
/* translators: %s: Template. */
[291] Fix | Delete
__( 'The theme defines itself as its parent theme. Please check the %s header.' ),
[292] Fix | Delete
'<code>Template</code>'
[293] Fix | Delete
)
[294] Fix | Delete
);
[295] Fix | Delete
$this->cache_add(
[296] Fix | Delete
'theme',
[297] Fix | Delete
array(
[298] Fix | Delete
'headers' => $this->headers,
[299] Fix | Delete
'errors' => $this->errors,
[300] Fix | Delete
'stylesheet' => $this->stylesheet,
[301] Fix | Delete
)
[302] Fix | Delete
);
[303] Fix | Delete
[304] Fix | Delete
return;
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
// (If template is set from cache [and there are no errors], we know it's good.)
[308] Fix | Delete
if ( ! $this->template ) {
[309] Fix | Delete
$this->template = $this->headers['Template'];
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
if ( ! $this->template ) {
[313] Fix | Delete
$this->template = $this->stylesheet;
[314] Fix | Delete
if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet . '/index.php' ) ) {
[315] Fix | Delete
$error_message = sprintf(
[316] Fix | Delete
/* translators: 1: index.php, 2: Documentation URL, 3: style.css */
[317] Fix | Delete
__( 'Template is missing. Standalone themes need to have a %1$s template file. <a href="%2$s">Child themes</a> need to have a Template header in the %3$s stylesheet.' ),
[318] Fix | Delete
'<code>index.php</code>',
[319] Fix | Delete
__( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ),
[320] Fix | Delete
'<code>style.css</code>'
[321] Fix | Delete
);
[322] Fix | Delete
$this->errors = new WP_Error( 'theme_no_index', $error_message );
[323] Fix | Delete
$this->cache_add(
[324] Fix | Delete
'theme',
[325] Fix | Delete
array(
[326] Fix | Delete
'headers' => $this->headers,
[327] Fix | Delete
'errors' => $this->errors,
[328] Fix | Delete
'stylesheet' => $this->stylesheet,
[329] Fix | Delete
'template' => $this->template,
[330] Fix | Delete
)
[331] Fix | Delete
);
[332] Fix | Delete
return;
[333] Fix | Delete
}
[334] Fix | Delete
}
[335] Fix | Delete
[336] Fix | Delete
// If we got our data from cache, we can assume that 'template' is pointing to the right place.
[337] Fix | Delete
if ( ! is_array( $cache ) && $this->template != $this->stylesheet && ! file_exists( $this->theme_root . '/' . $this->template . '/index.php' ) ) {
[338] Fix | Delete
// If we're in a directory of themes inside /themes, look for the parent nearby.
[339] Fix | Delete
// wp-content/themes/directory-of-themes/*
[340] Fix | Delete
$parent_dir = dirname( $this->stylesheet );
[341] Fix | Delete
$directories = search_theme_directories();
[342] Fix | Delete
[343] Fix | Delete
if ( '.' !== $parent_dir && file_exists( $this->theme_root . '/' . $parent_dir . '/' . $this->template . '/index.php' ) ) {
[344] Fix | Delete
$this->template = $parent_dir . '/' . $this->template;
[345] Fix | Delete
} elseif ( $directories && isset( $directories[ $this->template ] ) ) {
[346] Fix | Delete
// Look for the template in the search_theme_directories() results, in case it is in another theme root.
[347] Fix | Delete
// We don't look into directories of themes, just the theme root.
[348] Fix | Delete
$theme_root_template = $directories[ $this->template ]['theme_root'];
[349] Fix | Delete
} else {
[350] Fix | Delete
// Parent theme is missing.
[351] Fix | Delete
$this->errors = new WP_Error(
[352] Fix | Delete
'theme_no_parent',
[353] Fix | Delete
sprintf(
[354] Fix | Delete
/* translators: %s: Theme directory name. */
[355] Fix | Delete
__( 'The parent theme is missing. Please install the "%s" parent theme.' ),
[356] Fix | Delete
esc_html( $this->template )
[357] Fix | Delete
)
[358] Fix | Delete
);
[359] Fix | Delete
$this->cache_add(
[360] Fix | Delete
'theme',
[361] Fix | Delete
array(
[362] Fix | Delete
'headers' => $this->headers,
[363] Fix | Delete
'errors' => $this->errors,
[364] Fix | Delete
'stylesheet' => $this->stylesheet,
[365] Fix | Delete
'template' => $this->template,
[366] Fix | Delete
)
[367] Fix | Delete
);
[368] Fix | Delete
$this->parent = new WP_Theme( $this->template, $this->theme_root, $this );
[369] Fix | Delete
return;
[370] Fix | Delete
}
[371] Fix | Delete
}
[372] Fix | Delete
[373] Fix | Delete
// Set the parent, if we're a child theme.
[374] Fix | Delete
if ( $this->template != $this->stylesheet ) {
[375] Fix | Delete
// If we are a parent, then there is a problem. Only two generations allowed! Cancel things out.
[376] Fix | Delete
if ( $_child instanceof WP_Theme && $_child->template == $this->stylesheet ) {
[377] Fix | Delete
$_child->parent = null;
[378] Fix | Delete
$_child->errors = new WP_Error(
[379] Fix | Delete
'theme_parent_invalid',
[380] Fix | Delete
sprintf(
[381] Fix | Delete
/* translators: %s: Theme directory name. */
[382] Fix | Delete
__( 'The "%s" theme is not a valid parent theme.' ),
[383] Fix | Delete
esc_html( $_child->template )
[384] Fix | Delete
)
[385] Fix | Delete
);
[386] Fix | Delete
$_child->cache_add(
[387] Fix | Delete
'theme',
[388] Fix | Delete
array(
[389] Fix | Delete
'headers' => $_child->headers,
[390] Fix | Delete
'errors' => $_child->errors,
[391] Fix | Delete
'stylesheet' => $_child->stylesheet,
[392] Fix | Delete
'template' => $_child->template,
[393] Fix | Delete
)
[394] Fix | Delete
);
[395] Fix | Delete
// The two themes actually reference each other with the Template header.
[396] Fix | Delete
if ( $_child->stylesheet == $this->template ) {
[397] Fix | Delete
$this->errors = new WP_Error(
[398] Fix | Delete
'theme_parent_invalid',
[399] Fix | Delete
sprintf(
[400] Fix | Delete
/* translators: %s: Theme directory name. */
[401] Fix | Delete
__( 'The "%s" theme is not a valid parent theme.' ),
[402] Fix | Delete
esc_html( $this->template )
[403] Fix | Delete
)
[404] Fix | Delete
);
[405] Fix | Delete
$this->cache_add(
[406] Fix | Delete
'theme',
[407] Fix | Delete
array(
[408] Fix | Delete
'headers' => $this->headers,
[409] Fix | Delete
'errors' => $this->errors,
[410] Fix | Delete
'stylesheet' => $this->stylesheet,
[411] Fix | Delete
'template' => $this->template,
[412] Fix | Delete
)
[413] Fix | Delete
);
[414] Fix | Delete
}
[415] Fix | Delete
return;
[416] Fix | Delete
}
[417] Fix | Delete
// Set the parent. Pass the current instance so we can do the crazy checks above and assess errors.
[418] Fix | Delete
$this->parent = new WP_Theme( $this->template, isset( $theme_root_template ) ? $theme_root_template : $this->theme_root, $this );
[419] Fix | Delete
}
[420] Fix | Delete
[421] Fix | Delete
if ( wp_paused_themes()->get( $this->stylesheet ) && ( ! is_wp_error( $this->errors ) || ! isset( $this->errors->errors['theme_paused'] ) ) ) {
[422] Fix | Delete
$this->errors = new WP_Error( 'theme_paused', __( 'This theme failed to load properly and was paused within the admin backend.' ) );
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
// We're good. If we didn't retrieve from cache, set it.
[426] Fix | Delete
if ( ! is_array( $cache ) ) {
[427] Fix | Delete
$cache = array(
[428] Fix | Delete
'headers' => $this->headers,
[429] Fix | Delete
'errors' => $this->errors,
[430] Fix | Delete
'stylesheet' => $this->stylesheet,
[431] Fix | Delete
'template' => $this->template,
[432] Fix | Delete
);
[433] Fix | Delete
// If the parent theme is in another root, we'll want to cache this. Avoids an entire branch of filesystem calls above.
[434] Fix | Delete
if ( isset( $theme_root_template ) ) {
[435] Fix | Delete
$cache['theme_root_template'] = $theme_root_template;
[436] Fix | Delete
}
[437] Fix | Delete
$this->cache_add( 'theme', $cache );
[438] Fix | Delete
}
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
/**
[442] Fix | Delete
* When converting the object to a string, the theme name is returned.
[443] Fix | Delete
*
[444] Fix | Delete
* @since 3.4.0
[445] Fix | Delete
*
[446] Fix | Delete
* @return string Theme name, ready for display (translated)
[447] Fix | Delete
*/
[448] Fix | Delete
public function __toString() {
[449] Fix | Delete
return (string) $this->display( 'Name' );
[450] Fix | Delete
}
[451] Fix | Delete
[452] Fix | Delete
/**
[453] Fix | Delete
* __isset() magic method for properties formerly returned by current_theme_info()
[454] Fix | Delete
*
[455] Fix | Delete
* @since 3.4.0
[456] Fix | Delete
*
[457] Fix | Delete
* @param string $offset Property to check if set.
[458] Fix | Delete
* @return bool Whether the given property is set.
[459] Fix | Delete
*/
[460] Fix | Delete
public function __isset( $offset ) {
[461] Fix | Delete
static $properties = array(
[462] Fix | Delete
'name',
[463] Fix | Delete
'title',
[464] Fix | Delete
'version',
[465] Fix | Delete
'parent_theme',
[466] Fix | Delete
'template_dir',
[467] Fix | Delete
'stylesheet_dir',
[468] Fix | Delete
'template',
[469] Fix | Delete
'stylesheet',
[470] Fix | Delete
'screenshot',
[471] Fix | Delete
'description',
[472] Fix | Delete
'author',
[473] Fix | Delete
'tags',
[474] Fix | Delete
'theme_root',
[475] Fix | Delete
'theme_root_uri',
[476] Fix | Delete
);
[477] Fix | Delete
[478] Fix | Delete
return in_array( $offset, $properties, true );
[479] Fix | Delete
}
[480] Fix | Delete
[481] Fix | Delete
/**
[482] Fix | Delete
* __get() magic method for properties formerly returned by current_theme_info()
[483] Fix | Delete
*
[484] Fix | Delete
* @since 3.4.0
[485] Fix | Delete
*
[486] Fix | Delete
* @param string $offset Property to get.
[487] Fix | Delete
* @return mixed Property value.
[488] Fix | Delete
*/
[489] Fix | Delete
public function __get( $offset ) {
[490] Fix | Delete
switch ( $offset ) {
[491] Fix | Delete
case 'name':
[492] Fix | Delete
case 'title':
[493] Fix | Delete
return $this->get( 'Name' );
[494] Fix | Delete
case 'version':
[495] Fix | Delete
return $this->get( 'Version' );
[496] Fix | Delete
case 'parent_theme':
[497] Fix | Delete
return $this->parent() ? $this->parent()->get( 'Name' ) : '';
[498] Fix | Delete
case 'template_dir':
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function