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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52330 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork
2021-12-07 00:00:45 +00:00
parent f322c1ef3f
commit 9cc20468ef
10 changed files with 27 additions and 34 deletions
+2 -2
View File
@@ -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;
}
+1 -1
View File
@@ -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' ),
+3 -3
View File
@@ -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,
+2 -3
View File
@@ -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();
}