mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-29 12:37:57 +01:00
00401e16b3
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
46 lines
922 B
PHP
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' );
|