CoreFiles by mySites.guru
block.php48 lines, 1,006 bytes, from wordpress-5.3.21.zip
Raw History Compare with 5.3.20
md5
e337c377e9fbd5a5a0b46d8a60e30a77
sha1
62d31a933542a46af143d3b8c2d6f6016c47999f
sha256
d702bf664496cf3d3eea9f0da89f1527d174ca057a705004d81cf03f86bd5164
<?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 );
}

/**
 * Registers the `core/block` block.
 */
function register_block_core_block() {
	register_block_type(
		'core/block',
		array(
			'attributes'      => array(
				'ref' => array(
					'type' => 'number',
				),
			),
			'render_callback' => 'render_block_core_block',
		)
	);
}
add_action( 'init', 'register_block_core_block' );

The same content is in 76 releases, WordPress 5.3-beta1 to 5.4.25. See them all, or every version of this file.