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