mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-26 10:11:29 +01:00
36158d7909
Update packages include: - block-library - components - edit-post - editor - format-library - list-reusable-blocks - nux Other changes: - Fix a translator comment in `edit-form-blocks.php`. - Rename the `gutenberg_` functions in `blocks/latest-comments.php`. Props noisy socks, youknowriad, pinto, swissspidy. Merges [43935] and [43949-43951] into trunk. See #45145. Built from https://develop.svn.wordpress.org/trunk@44273 git-svn-id: http://core.svn.wordpress.org/trunk@44103 1a063a9b-81f0-0310-95a4-ce76da25c4cd
40 lines
744 B
PHP
40 lines
744 B
PHP
<?php
|
|
/**
|
|
* Server-side rendering of the `core/block` block.
|
|
*
|
|
* @package WordPress
|
|
*/
|
|
|
|
/**
|
|
* Renders the `core/block` block on server.
|
|
*
|
|
* @param array $attributes The block attributes.
|
|
*
|
|
* @return string Rendered HTML of the referenced block.
|
|
*/
|
|
function render_block_core_block( $attributes ) {
|
|
if ( empty( $attributes['ref'] ) ) {
|
|
return '';
|
|
}
|
|
|
|
$reusable_block = get_post( $attributes['ref'] );
|
|
if ( ! $reusable_block || 'wp_block' !== $reusable_block->post_type ) {
|
|
return '';
|
|
}
|
|
|
|
return do_blocks( $reusable_block->post_content );
|
|
}
|
|
|
|
register_block_type(
|
|
'core/block',
|
|
array(
|
|
'attributes' => array(
|
|
'ref' => array(
|
|
'type' => 'number',
|
|
),
|
|
),
|
|
|
|
'render_callback' => 'render_block_core_block',
|
|
)
|
|
);
|