CoreFiles by mySites.guru
block.php43 lines, 859 bytes, from wordpress-5.2.zip
Raw History Compare with 5.1.28
md5
738914db33e13d02689a3ba40674ab4b
sha1
c3e8a3b90110e87c01b1132cda5ff0c89b70550f
sha256
b678a883ba31a2ddefd80cafa67b0738ad2ec5ebe52e4b578b8a2935376276f0
<?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',
	)
);

The same content is in 108 releases, WordPress 5.0.2-RC1 to 5.2.30. See them all, or every version of this file.