[wp-trac] [WordPress Trac] #54552: Consider consolidating wp_is_block_template_theme() and WP_Theme::is_block_based()

WordPress Trac noreply at wordpress.org
Thu Dec 2 17:20:34 UTC 2021

#54552: Consider consolidating wp_is_block_template_theme() and
 Reporter:  noisysocks      |       Owner:  (none)
     Type:  task (blessed)  |      Status:  new
 Priority:  normal          |   Milestone:  5.9
Component:  Themes          |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  needs-patch     |     Focuses:

Comment (by antonvlasenko):

 When replacing `wp_is_block_template_theme` with
 `wp_get_theme()→is_block_based()`, we must take into account that
 `get_stylesheet_directory` and `get_template_directory` functions use
 filters (`get_stylesheet_directory` and `template_directory` filters
 These functions are used by `wp_is_block_template_theme` function
 While `WP_Theme::get_stylesheet_directory` and
 `WP_Theme::get_template_directory` methods don't use any filters (used by
 So, there could be some inconsistency in how these methods behave.
 Should we add these filters to `WP_Theme::get_stylesheet_directory` and
 `WP_Theme::get_template_directory` methods as well?

 My vote:
 1. We can have both `wp_is_block_template_theme ` and
 It's handy to call just 1 function (`wp_is_block_template_theme`) instead
 of using `wp_get_theme()→is_block_based()`. It's kind of syntactic sugar.

 But I don't mind removing `wp_is_block_template_theme`.
 2. If we decide to keep `wp_is_block_template_theme ` we should rename it
 to`wp_is_block_theme` .

 3. If we decided to rename `WP_Theme::is_block_based()` method, it should
 not have `theme` in it.
 Check this code snippet out:
 $theme = new WP_Theme();
 $theme->is_block_theme(); // <- this

 We are repeating the name of the class (`theme`) in the method's name. It
 looks redundant to me.

 IMO the current name is better (no tautology).
 $theme = new WP_Theme();
 $theme->is_block_based(); // <- this

Ticket URL: <https://core.trac.wordpress.org/ticket/54552#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list