mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-14 14:45:45 +01:00
d6e8d93412
Updated packages: - `@wordpress/annotations - `@wordpress/api-fetch - `@wordpress/block-library@2.2.10 - `@wordpress/block-serialization-default-parser@2.0.2` - `@wordpress/block-serialization-spec-parser@2.0.2` - `@wordpress/blocks@6.0.4` - `@wordpress/components@7.0.4` - `@wordpress/core-data@2.0.15` - `@wordpress/data@4.1.0` - `@wordpress/date@3.0.1` - `@wordpress/edit-post@3.1.5` - `@wordpress/editor@9.0.5` - `@wordpress/eslint-plugin@1.0.0` - `@wordpress/format-library@1.2.8` - `@wordpress/html-entities@2.0.4` - `@wordpress/list-reusable-blocks@1.1.17` - `@wordpress/notices@1.1.1` - `@wordpress/nux@3.0.5` - `@wordpress/rich-text@3.0.3` - `@wordpress/url@2.3.2` - `@wordpress/viewport@2.0.13` This also includes the updates the Core blocks. The script loader is updated to match the Gutenberg repository as well. Props atimmer, gziolo, joen, youknowriad. Merges [44183] to trunk. Fixes #45442, #45637. Built from https://develop.svn.wordpress.org/trunk@44296 git-svn-id: http://core.svn.wordpress.org/trunk@44126 1a063a9b-81f0-0310-95a4-ce76da25c4cd
44 lines
859 B
PHP
44 lines
859 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 '';
|
|
}
|
|
|
|
if ( 'publish' !== $reusable_block->post_status || ! empty( $reusable_block->post_password ) ) {
|
|
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',
|
|
)
|
|
);
|