wp_is_block_theme(): bool
- Since
- 5.9.0
- Source
wp-includes/theme.php:4368
Return value
bool- Whether the active theme is a block-based theme or not.
Performance profile
How much work a call to wp_is_block_theme() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 7–11
- Plugin surface
- None
- Called by
- 23
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.4, depending on the branch taken. The body compiles to 16.
Nothing here hands control to plugin code.
23 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
do_action()one call below wp_is_block_theme()
Further down the call graph this can also reach option, cache, serialize, transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_is_block_theme() can have, taken from its control-flow graph on PHP 8.4.
| When | Instructions | Calls it makes |
|---|---|---|
!empty($value) | 7 | wp_get_theme(), ->is_block_theme() |
empty($value) | 11 | __(), _doing_it_wrong() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.4 | 16 | 7–11 | 1 | |
| 8.3 | 16 | 7–11 | 1 | |
| 8.2 | 16 | 7–11 | 1 | |
| 8.1 | 16 | 7–11 | 1 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 17 | 8–12 | 1 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 4
- _doing_it_wrong()Marks something as being incorrectly called.
- __()Retrieves the translation of $text.
- wp_get_theme()Gets a WP_Theme object for a theme.
- wp_get_theme()::is_block_theme()
Used by · 23
- WP_Customize_Manager::__construct()Constructor.
- WP_Customize_Manager::customize_preview_settings()Prints JavaScript settings for preview frame.
- WP_Duotone::output_footer_assets()Outputs all necessary SVG for duotone filters, CSS for classic themes.
- WP_REST_Sidebars_Controller::prepare_item_for_response()Prepares a single sidebar output for response.
- WP_Script_Modules::add_hooks()Adds the hooks to print the import map, enqueued script modules and script module preloads.
- _add_default_theme_supports()Adds default theme supports for block themes when the 'after_setup_theme' action fires.
- _add_plugin_file_editor_to_tools()Adds the 'Plugin File Editor' menu item after the 'Themes File Editor' in Tools for block themes.
- _add_themes_utility_last()Adds the 'Theme File Editor' menu item to the bottom of the Appearance (non-block themes) or Tools (block themes) menu.
- _wp_block_theme_register_classic_sidebars()Registers the previous theme's sidebars for the block themes.
- comments_block_form_defaults()Use the button block classes for the form-submit button.
- get_block_editor_settings()Returns the contextualized block editor settings for a selected editor context.
- post_comments_form_block_form_defaults()Use the button block classes for the form-submit button.
Show all 23
- wp_admin_bar_customize_menu()Adds the "Customize" link to the Toolbar.
- wp_admin_bar_edit_site_menu()Adds the "Edit Site" link to the Toolbar.
- wp_enable_block_templates()Enables the block templates (editor mode) for themes with theme.json by default.
- wp_enqueue_block_support_styles()Hooks inline styles in the proper place, depending on the active theme.
- wp_enqueue_global_styles()Enqueues the global styles defined via theme.json.
- wp_enqueue_global_styles_custom_css()Enqueues the global styles custom css defined via theme.json.
- wp_enqueue_stored_styles()Fetches, processes and compiles stored core styles, then combines and renders them to the page.
- wp_get_post_content_block_attributes()Retrieves Post Content block attributes from the current post template.
- wp_load_classic_theme_block_styles_on_demand()Adds hooks to load block styles on demand in classic themes.
- wp_welcome_panel()Displays a welcome panel to introduce users to WordPress.
- wp_widgets_add_menu()Appends the Widgets menu to the themes main menu.
Source code
function wp_is_block_theme() { if ( empty( $GLOBALS['wp_theme_directories'] ) ) { _doing_it_wrong( __FUNCTION__, __( 'This function should not be called before the theme directory is registered.' ), '6.8.0' ); return false; } return wp_get_theme()->is_block_theme();}Changelog
Introduced in 5.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/theme.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.