WordPress/wp-includes/blocks/pattern.php
Bernhard Reiter 00401e16b3 Editor: update Wordpress npm packages.
Updates the wordpress npm packages and their dependencies to the latest versions, as well as auto-updates to relevant core PHP files.

Props youknowriad, joemcgill, spacedmonkey, ramonopoly, peterwilsoncc, bernhard-reiter, tyxla, dmsnell.
Fixes #58623.
Built from https://develop.svn.wordpress.org/trunk@56065


git-svn-id: http://core.svn.wordpress.org/trunk@55577 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-27 14:24:19 +00:00

46 lines
922 B
PHP

<?php
/**
* Server-side rendering of the `core/pattern` block.
*
* @package WordPress
*/
/**
* Registers the `core/pattern` block on the server.
*
* @return void
*/
function register_block_core_pattern() {
register_block_type_from_metadata(
__DIR__ . '/pattern',
array(
'render_callback' => 'render_block_core_pattern',
)
);
}
/**
* Renders the `core/pattern` block on the server.
*
* @param array $attributes Block attributes.
*
* @return string Returns the output of the pattern.
*/
function render_block_core_pattern( $attributes ) {
if ( empty( $attributes['slug'] ) ) {
return '';
}
$slug = $attributes['slug'];
$registry = WP_Block_Patterns_Registry::get_instance();
if ( ! $registry->is_registered( $slug ) ) {
return '';
}
$pattern = $registry->get_registered( $slug );
return do_blocks( $pattern['content'] );
}
add_action( 'init', 'register_block_core_pattern' );