Commit f70fb51f99 for wordpress.org

commit f70fb51f99973274809caa80135d87f78b66b86a
Author: hellofromTonya <hellofromTonya@git.wordpress.org>
Date:   Tue Dec 7 00:02:02 2021 +0000

    Themes: Better names for `WP_Theme::is_block_theme()` and `wp_is_block_theme()` and make `wp_is_block_theme()` a wrapper.

    This commit renames the following method and function to better represent block theme terminology:

    * `WP_Theme::is_block_based()` to `WP_Theme::is_block_theme()`
    * `wp_is_block_template_theme()` to `wp_is_block_theme()`

    It also changes `wp_is_block_theme()` to be a helper wrapper (sugar syntax) for `wp_get_theme()->is_block_theme();`. Why? To ensure both the method and function behave the same, to help Gutenberg maintain WordPress cross-version compatibility, and to make it less cumbersome to port changes from Gutenberg to Core.

    Follow-up to [52069], [52247], [52279].

    Props antonvlasenko, costdev, hellofromTonya, noisysocks.
    Fixes #54550.
    Built from https://develop.svn.wordpress.org/trunk@52330


    git-svn-id: http://core.svn.wordpress.org/trunk@51922 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php
index 833a617bc7..3bcc14efc1 100644
--- a/wp-admin/includes/dashboard.php
+++ b/wp-admin/includes/dashboard.php
@@ -1993,11 +1993,11 @@ function wp_welcome_panel() {
 	$customize_url          = null;
 	$can_edit_theme_options = current_user_can( 'edit_theme_options' );
 	$can_customize          = current_user_can( 'customize' );
-	$is_block_based_theme   = wp_is_block_template_theme();
+	$is_block_theme         = wp_is_block_theme();

-	if ( $is_block_based_theme && $can_edit_theme_options ) {
+	if ( $is_block_theme && $can_edit_theme_options ) {
 		$customize_url = esc_url( admin_url( 'site-editor.php' ) );
-	} elseif ( ! $is_block_based_theme && $can_customize ) {
+	} elseif ( ! $is_block_theme && $can_customize ) {
 		$customize_url = wp_customize_url();
 	}
 	?>
@@ -2012,7 +2012,7 @@ function wp_welcome_panel() {
 		<?php endif; ?>
 		<a class="button button-primary button-hero hide-if-customize" href="<?php echo esc_url( admin_url( 'themes.php' ) ); ?>"><?php _e( 'Customize Your Site' ); ?></a>
 		<?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?>
-			<?php $themes_link = $can_customize && ! $is_block_based_theme ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?>
+			<?php $themes_link = $can_customize && ! $is_block_theme ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?>
 			<p class="hide-if-no-customize">
 				<?php
 					/* translators: %s: URL to Themes panel in Customizer or Themes screen. */
diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php
index 3d1b8d74b9..ab751689f0 100644
--- a/wp-admin/includes/theme.php
+++ b/wp-admin/includes/theme.php
@@ -704,11 +704,11 @@ function wp_prepare_themes_for_js( $themes = null ) {

 		$can_edit_theme_options = current_user_can( 'edit_theme_options' );
 		$can_customize          = current_user_can( 'customize' );
-		$is_block_based_theme   = $theme->is_block_based();
+		$is_block_theme         = $theme->is_block_theme();

-		if ( $is_block_based_theme && $can_edit_theme_options ) {
+		if ( $is_block_theme && $can_edit_theme_options ) {
 			$customize_action = esc_url( admin_url( 'site-editor.php' ) );
-		} elseif ( ! $is_block_based_theme && $can_customize && $can_edit_theme_options ) {
+		} elseif ( ! $is_block_theme && $can_customize && $can_edit_theme_options ) {
 			$customize_action = esc_url(
 				add_query_arg(
 					array(
diff --git a/wp-admin/menu.php b/wp-admin/menu.php
index 232b18025e..928a65db3f 100644
--- a/wp-admin/menu.php
+++ b/wp-admin/menu.php
@@ -202,7 +202,7 @@ if ( ! is_multisite() && current_user_can( 'update_themes' ) ) {
 	/* translators: %s: Number of available theme updates. */
 	$submenu['themes.php'][5] = array( sprintf( __( 'Themes %s' ), $count ), $appearance_cap, 'themes.php' );

-if ( wp_is_block_template_theme() ) {
+if ( wp_is_block_theme() ) {
 	$submenu['themes.php'][6] = array(
 		sprintf(
 			/* translators: %s: "beta" label */
@@ -216,9 +216,9 @@ if ( wp_is_block_template_theme() ) {

 // Hide Customize link on block themes unless a plugin or theme is using
 // customize_register to add a setting.
-if ( ! wp_is_block_template_theme() || has_action( 'customize_register' ) ) {
+if ( ! wp_is_block_theme() || has_action( 'customize_register' ) ) {
 	$customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );
-	$position      = wp_is_block_template_theme() ? 7 : 6;
+	$position      = wp_is_block_theme() ? 7 : 6;

 	$submenu['themes.php'][ $position ] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' );
 }
@@ -255,7 +255,7 @@ if ( ! is_multisite() ) {
  */
 function _add_themes_utility_last() {
 	add_submenu_page(
-		wp_is_block_template_theme() ? 'tools.php' : 'themes.php',
+		wp_is_block_theme() ? 'tools.php' : 'themes.php',
 		__( 'Theme Editor' ),
 		__( 'Theme Editor' ),
 		'edit_themes',
diff --git a/wp-admin/site-editor.php b/wp-admin/site-editor.php
index f8a3375765..d135a0ebf2 100644
--- a/wp-admin/site-editor.php
+++ b/wp-admin/site-editor.php
@@ -19,7 +19,7 @@ if ( ! current_user_can( 'edit_theme_options' ) ) {
 	);
 }

-if ( ! wp_is_block_template_theme() ) {
+if ( ! wp_is_block_theme() ) {
 	wp_die( __( 'The theme you are currently using is not compatible with Full Site Editing.' ) );
 }

diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php
index 7db3e84a8e..e8affbfbd2 100644
--- a/wp-admin/theme-editor.php
+++ b/wp-admin/theme-editor.php
@@ -196,7 +196,7 @@ if ( $file_description !== $file_show ) {
 	</div>
 <?php endif; ?>

-<?php if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_template_theme() && current_user_can( 'customize' ) ) : ?>
+<?php if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_can( 'customize' ) ) : ?>
 	<div id="message" class="notice-info notice">
 		<p><strong><?php _e( 'Did you know?' ); ?></strong></p>
 		<p>
diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php
index 611c4e570b..fa2017a501 100644
--- a/wp-includes/admin-bar.php
+++ b/wp-includes/admin-bar.php
@@ -417,7 +417,7 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
  */
 function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
 	// Don't show if a block theme is not activated.
-	if ( ! wp_is_block_template_theme() ) {
+	if ( ! wp_is_block_theme() ) {
 		return;
 	}

@@ -447,7 +447,7 @@ function wp_admin_bar_customize_menu( $wp_admin_bar ) {
 	global $wp_customize;

 	// Don't show if a block theme is activated.
-	if ( wp_is_block_template_theme() ) {
+	if ( wp_is_block_theme() ) {
 		return;
 	}

diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php
index 37b524fdc9..b5ac408278 100644
--- a/wp-includes/class-wp-theme.php
+++ b/wp-includes/class-wp-theme.php
@@ -1467,7 +1467,7 @@ final class WP_Theme implements ArrayAccess {
 	 *
 	 * @return bool
 	 */
-	public function is_block_based() {
+	public function is_block_theme() {
 		$paths_to_index_block_template = array(
 			$this->get_file_path( '/block-templates/index.html' ),
 			$this->get_file_path( '/templates/index.html' ),
diff --git a/wp-includes/post.php b/wp-includes/post.php
index f7fe8d7451..3091eeb9b8 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -356,7 +356,7 @@ function create_initial_post_types() {
 			'public'                => false,
 			'_builtin'              => true, /* internal use only. don't use this when registering your own post type. */
 			'has_archive'           => false,
-			'show_ui'               => wp_is_block_template_theme(),
+			'show_ui'               => wp_is_block_theme(),
 			'show_in_menu'          => false,
 			'show_in_rest'          => true,
 			'rewrite'               => false,
@@ -416,7 +416,7 @@ function create_initial_post_types() {
 			'public'                => false,
 			'_builtin'              => true, /* internal use only. don't use this when registering your own post type. */
 			'has_archive'           => false,
-			'show_ui'               => wp_is_block_template_theme(),
+			'show_ui'               => wp_is_block_theme(),
 			'show_in_menu'          => false,
 			'show_in_rest'          => true,
 			'rewrite'               => false,
@@ -503,7 +503,7 @@ function create_initial_post_types() {
 			'public'                => false,
 			'_builtin'              => true, /* internal use only. don't use this when registering your own post type. */
 			'has_archive'           => false,
-			'show_ui'               => wp_is_block_template_theme(),
+			'show_ui'               => wp_is_block_theme(),
 			'show_in_menu'          => 'themes.php',
 			'show_in_admin_bar'     => false,
 			'show_in_rest'          => true,
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index 9737fb3cb5..c1f94428fe 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -4090,7 +4090,6 @@ function create_initial_theme_features() {
  *
  * @return boolean Whether the current theme is a block-based theme or not.
  */
-function wp_is_block_template_theme() {
-	return is_readable( get_theme_file_path( '/block-templates/index.html' ) ) ||
-		is_readable( get_theme_file_path( '/templates/index.html' ) );
+function wp_is_block_theme() {
+	return wp_get_theme()->is_block_theme();
 }
diff --git a/wp-includes/version.php b/wp-includes/version.php
index db79323ae4..c405692118 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '5.9-beta1-52329';
+$wp_version = '5.9-beta1-52330';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.