From 139766122f235f498e0d7d7158fdbe30db4c7b9f Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 13 Feb 2025 10:13:06 +0800 Subject: [PATCH 1/3] Editor: Set new default rendering mode for Pages --- src/wp-includes/post.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 58504e140a139..d8ea919192f82 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -69,6 +69,11 @@ function create_initial_post_types() { ) ); + // Enhance page editor for block themes by rendering template and content blocks. + if ( wp_is_block_theme() ) { + add_post_type_support( 'page', 'editor', array( 'default-mode' => 'template-locked' ) ); + } + register_post_type( 'attachment', array( From e0a29d5b9dd857f695b448f0e0b8fe906665a6b7 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 17 Feb 2025 15:04:01 +0800 Subject: [PATCH 2/3] Add an extra check before enabling the new default rendering mode for Pages --- src/wp-includes/post.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index d8ea919192f82..a9992071f0167 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -70,7 +70,7 @@ function create_initial_post_types() { ); // Enhance page editor for block themes by rendering template and content blocks. - if ( wp_is_block_theme() ) { + if ( wp_is_block_theme() && current_theme_supports( 'block-templates' ) ) { add_post_type_support( 'page', 'editor', array( 'default-mode' => 'template-locked' ) ); } From 4ea7c097ed9aaf3f3ba60aaff2e0cc5cd92845c0 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 28 Feb 2025 09:22:32 +1100 Subject: [PATCH 3/3] Fix tests by comparing cache contents before and affter. --- tests/phpunit/tests/option/networkOption.php | 28 +++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/tests/option/networkOption.php b/tests/phpunit/tests/option/networkOption.php index a4247d4926cec..7771154ef86ca 100644 --- a/tests/phpunit/tests/option/networkOption.php +++ b/tests/phpunit/tests/option/networkOption.php @@ -381,14 +381,18 @@ public function test_delete_network_option_does_not_use_network_notoptions_cache * @covers ::get_network_option */ public function test_get_network_option_does_not_use_single_site_notoptions_cache_for_networks() { + $network_notoptions_cache_before = wp_cache_get( '1:notoptions', 'site-options' ); + $single_site_notoptions_cache_before = wp_cache_get( 'notoptions', 'options' ); + get_network_option( 1, 'ticket_61730_notoption' ); - $network_notoptions_cache = wp_cache_get( '1:notoptions', 'site-options' ); - $single_site_notoptions_cache = wp_cache_get( 'notoptions', 'options' ); + $network_notoptions_cache_after = wp_cache_get( '1:notoptions', 'site-options' ); + $single_site_notoptions_cache_after = wp_cache_get( 'notoptions', 'options' ); - $this->assertEmpty( $single_site_notoptions_cache, 'Single site notoptions cache should not be set for multisite installs.' ); - $this->assertIsArray( $network_notoptions_cache, 'Multisite notoptions cache should be set.' ); - $this->assertArrayHasKey( 'ticket_61730_notoption', $network_notoptions_cache, 'The option should be in the notoptions cache.' ); + $this->assertSame( $single_site_notoptions_cache_before, $single_site_notoptions_cache_after, 'Single site notoptions cache should not change for multisite installs.' ); + $this->assertNotSame( $network_notoptions_cache_before, $network_notoptions_cache_after, 'Multisite notoptions cache should change.' ); + $this->assertIsArray( $network_notoptions_cache_after, 'Multisite notoptions cache should be set.' ); + $this->assertArrayHasKey( 'ticket_61730_notoption', $network_notoptions_cache_after, 'The option should be in the notoptions cache.' ); } /** @@ -402,14 +406,18 @@ public function test_get_network_option_does_not_use_single_site_notoptions_cach * @covers ::delete_network_option */ public function test_delete_network_option_does_not_use_single_site_notoptions_cache_for_networks() { + $network_notoptions_cache_before = wp_cache_get( '1:notoptions', 'site-options' ); + $single_site_notoptions_cache_before = wp_cache_get( 'notoptions', 'options' ); + add_network_option( 1, 'ticket_61730_notoption', 'value' ); delete_network_option( 1, 'ticket_61730_notoption' ); - $network_notoptions_cache = wp_cache_get( '1:notoptions', 'site-options' ); - $single_site_notoptions_cache = wp_cache_get( 'notoptions', 'options' ); + $network_notoptions_cache_after = wp_cache_get( '1:notoptions', 'site-options' ); + $single_site_notoptions_cache_after = wp_cache_get( 'notoptions', 'options' ); - $this->assertEmpty( $single_site_notoptions_cache, 'Single site notoptions cache should not be set for multisite installs.' ); - $this->assertIsArray( $network_notoptions_cache, 'Multisite notoptions cache should be set.' ); - $this->assertArrayHasKey( 'ticket_61730_notoption', $network_notoptions_cache, 'The option should be in the notoptions cache.' ); + $this->assertSame( $single_site_notoptions_cache_before, $single_site_notoptions_cache_after, 'Single site notoptions cache should not change for multisite installs.' ); + $this->assertNotSame( $network_notoptions_cache_before, $network_notoptions_cache_after, 'Multisite notoptions cache should change.' ); + $this->assertIsArray( $network_notoptions_cache_after, 'Multisite notoptions cache should be set.' ); + $this->assertArrayHasKey( 'ticket_61730_notoption', $network_notoptions_cache_after, 'The option should be in the notoptions cache.' ); } }