mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Themes: Fix caching issue in get_post_templates method in WP_Theme.
Fix an edge case caching issue, where if a developer use the `wp_cache_themes_persistently` filter and is running the site in multisite configuration, it meant block template are incorrectly cached. Block templates are stored in the posts table. But in a multisite configuration, different sites on the multisite could have different block templates stored in there post table. As themes cache group is a global group, it resulted in incorrect values being cached. Props maniu, spacedmonkey, hellofromTonya, oglekler, mukesh27, joemcgill. Fixes #57886. git-svn-id: https://develop.svn.wordpress.org/trunk@55939 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
7cfc7a46f9
commit
ea0a4881ae
@ -1283,24 +1283,24 @@ final class WP_Theme implements ArrayAccess {
|
||||
}
|
||||
}
|
||||
|
||||
if ( current_theme_supports( 'block-templates' ) ) {
|
||||
$block_templates = get_block_templates( array(), 'wp_template' );
|
||||
foreach ( get_post_types( array( 'public' => true ) ) as $type ) {
|
||||
foreach ( $block_templates as $block_template ) {
|
||||
if ( ! $block_template->is_custom ) {
|
||||
continue;
|
||||
}
|
||||
$this->cache_add( 'post_templates', $post_templates );
|
||||
}
|
||||
|
||||
if ( isset( $block_template->post_types ) && ! in_array( $type, $block_template->post_types, true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$post_templates[ $type ][ $block_template->slug ] = $block_template->title;
|
||||
if ( current_theme_supports( 'block-templates' ) ) {
|
||||
$block_templates = get_block_templates( array(), 'wp_template' );
|
||||
foreach ( get_post_types( array( 'public' => true ) ) as $type ) {
|
||||
foreach ( $block_templates as $block_template ) {
|
||||
if ( ! $block_template->is_custom ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $block_template->post_types ) && ! in_array( $type, $block_template->post_types, true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$post_templates[ $type ][ $block_template->slug ] = $block_template->title;
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache_add( 'post_templates', $post_templates );
|
||||
}
|
||||
|
||||
if ( $this->load_textdomain() ) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user