mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-19 09:05:22 +01:00
6137ee183b
Updated packages: - @wordpress/annotations@1.0.4 - @wordpress/api-fetch@2.2.6 - @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 too. Props atimmer, gziolo, joen. Fixes #45442, #45637. Built from https://develop.svn.wordpress.org/branches/5.0@44183 git-svn-id: http://core.svn.wordpress.org/branches/5.0@44013 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',
|
|
)
|
|
);
|