CoreFiles by mySites.guru
block.php39 lines, 744 bytes, from wordpress-5.0.zip
Raw History Compare with 4.9.35
md5
e8b304c87988422dbd2c7c5dc18cc3d1
sha1
77d0b92ecafb066716294472e05c6b693d94a263
sha256
ac10950b4655e5e49a1bc66efcd9da61e65bcc28100f138320c08c5672dc4677
<?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',
	)
);

The same content is in 4 releases, WordPress 5.0-RC2 to 5.0.1. See them all, or every version of this file.