WP_Theme::is_block_theme
Returns whether this theme is a block-based theme or not.
Method of the class: WP_Theme{}
No Hooks.
Returns
true|false.
Usage
$WP_Theme = new WP_Theme(); $WP_Theme->is_block_theme();
Changelog
| Since 5.9.0 | Introduced. |
WP_Theme::is_block_theme() WP Theme::is block theme code WP 6.9
public function is_block_theme() {
if ( isset( $this->block_theme ) ) {
return $this->block_theme;
}
$paths_to_index_block_template = array(
$this->get_file_path( '/templates/index.html' ),
$this->get_file_path( '/block-templates/index.html' ),
);
$this->block_theme = false;
foreach ( $paths_to_index_block_template as $path_to_index_block_template ) {
if ( is_file( $path_to_index_block_template ) && is_readable( $path_to_index_block_template ) ) {
$this->block_theme = true;
break;
}
}
return $this->block_theme;
}