Returns whether the active theme is a block-based theme or not.
Return
bool Whether the active theme is a block-based theme or not.Source
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(); }
Related
Uses | Description |
---|---|
WP_Theme::is_block_theme()wp-includes/class-wp-theme.php | Returns whether this theme is a block-based theme or not. |
wp_get_theme()wp-includes/theme.php | Gets a WP_Theme object for a theme. |
_doing_it_wrong()wp-includes/functions.php | Marks something as being incorrectly called. |
Used by | Description |
---|---|
WP_Script_Modules::add_hooks()wp-includes/class-wp-script-modules.php | Adds the hooks to print the import map, enqueued script modules and script module preloads. |
wp_get_post_content_block_attributes()wp-includes/block-editor.php | Retrieves Post Content block attributes from the current post template. |
WP_Duotone::output_footer_assets()wp-includes/class-wp-duotone.php | Outputs all necessary SVG for duotone filters, CSS for classic themes. |
_wp_block_theme_register_classic_sidebars()wp-includes/widgets.php | Registers the previous theme’s sidebars for the block themes. |
wp_enqueue_global_styles_custom_css()wp-includes/deprecated.php | Enqueues the global styles custom css defined via theme.json. |
wp_enqueue_stored_styles()wp-includes/script-loader.php | Fetches, processes and compiles stored core styles, then combines and renders them to the page. |
wp_enqueue_block_support_styles()wp-includes/script-loader.php | Hooks inline styles in the proper place, depending on the active theme. |
_add_default_theme_supports()wp-includes/theme.php | Adds default theme supports for block themes when the ‘after_setup_theme’ action fires. |
wp_admin_bar_edit_site_menu()wp-includes/admin-bar.php | Adds the “Edit Site” link to the Toolbar. |
_add_plugin_file_editor_to_tools()wp-admin/menu.php | Adds the ‘Plugin File Editor’ menu item after the ‘Themes File Editor’ in Tools for block themes. |
WP_REST_Sidebars_Controller::prepare_item_for_response()wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php | Prepares a single sidebar output for response. |
wp_enable_block_templates()wp-includes/theme-templates.php | Enables the block templates (editor mode) for themes with theme.json by default. |
get_block_editor_settings()wp-includes/block-editor.php | Returns the contextualized block editor settings for a selected editor context. |
wp_enqueue_global_styles()wp-includes/script-loader.php | Enqueues the global styles defined via theme.json. |
wp_admin_bar_customize_menu()wp-includes/admin-bar.php | Adds the “Customize” link to the Toolbar. |
wp_welcome_panel()wp-admin/includes/dashboard.php | Displays a welcome panel to introduce users to WordPress. |
_add_themes_utility_last()wp-admin/menu.php | Adds the ‘Theme File Editor’ menu item to the bottom of the Appearance (non-block themes) or Tools (block themes) menu. |
WP_Customize_Manager::__construct()wp-includes/class-wp-customize-manager.php | Constructor. |
wp_widgets_add_menu()wp-includes/functions.php | Appends the Widgets menu to the themes main menu. |
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |
Note that this specifically checks if an
index.html
block template is defined, so it actually checks for an FSE theme. The name might be slightly confusing.Function wp_is_block_theme was called incorrectly. This function should not be called before the theme directory is registered. This message was added in version 6.8.0.
It would appear that this function is only useful after the after_theme_setup hook is triggered.