WP_Theme::is_block_theme() WordPress Method

The WP_Theme::is_block_theme() method is used to determine if a theme is a block-based theme. This method will return true if the theme is a block-based theme, false otherwise.

WP_Theme::is_block_theme() #

Returns whether this theme is a block-based theme or not.


Return

(bool)


Top ↑

Source

File: wp-includes/class-wp-theme.php

	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' ),
		);

		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 ) ) {
				return true;
			}
		}

		return false;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.