On this page
WP_Theme_JSON_Resolver::has_same_registered_blocks( string $origin ): bool
Checks whether the registered blocks were already processed for this origin.
Parameters
$originstring Required-
Data source for which to cache the blocks.
Valid values are'core','blocks','theme', and'user'.
Return
bool True on success, false otherwise.
Source
File: wp-includes/class-wp-theme-json-resolver.php. View all references
protected static function has_same_registered_blocks( $origin ) {
// Bail out if the origin is invalid.
if ( ! isset( static::$blocks_cache[ $origin ] ) ) {
return false;
}
$registry = WP_Block_Type_Registry::get_instance();
$blocks = $registry->get_all_registered();
// Is there metadata for all currently registered blocks?
$block_diff = array_diff_key( $blocks, static::$blocks_cache[ $origin ] );
if ( empty( $block_diff ) ) {
return true;
}
foreach ( $blocks as $block_name => $block_type ) {
static::$blocks_cache[ $origin ][ $block_name ] = true;
}
return false;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Block_Type_Registry::get_instance() wp-includes/class-wp-block-type-registry.php | Utility method to retrieve the main instance of the class. |
Changelog
| Version | Description |
|---|---|
| 6.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/has_same_registered_blocks