Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: pattern.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/pattern` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Registers the `core/pattern` block on the server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 5.9.0
[10] Fix | Delete
*/
[11] Fix | Delete
function register_block_core_pattern() {
[12] Fix | Delete
register_block_type_from_metadata(
[13] Fix | Delete
__DIR__ . '/pattern',
[14] Fix | Delete
array(
[15] Fix | Delete
'render_callback' => 'render_block_core_pattern',
[16] Fix | Delete
)
[17] Fix | Delete
);
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Renders the `core/pattern` block on the server.
[22] Fix | Delete
*
[23] Fix | Delete
* @since 6.3.0 Backwards compatibility: blocks with no `syncStatus` attribute do not receive block wrapper.
[24] Fix | Delete
*
[25] Fix | Delete
* @global WP_Embed $wp_embed Used to process embedded content within patterns
[26] Fix | Delete
*
[27] Fix | Delete
* @param array $attributes Block attributes.
[28] Fix | Delete
*
[29] Fix | Delete
* @return string Returns the output of the pattern.
[30] Fix | Delete
*/
[31] Fix | Delete
function render_block_core_pattern( $attributes ) {
[32] Fix | Delete
static $seen_refs = array();
[33] Fix | Delete
[34] Fix | Delete
if ( empty( $attributes['slug'] ) ) {
[35] Fix | Delete
return '';
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
$slug = $attributes['slug'];
[39] Fix | Delete
$registry = WP_Block_Patterns_Registry::get_instance();
[40] Fix | Delete
[41] Fix | Delete
if ( ! $registry->is_registered( $slug ) ) {
[42] Fix | Delete
return '';
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
if ( isset( $seen_refs[ $attributes['slug'] ] ) ) {
[46] Fix | Delete
// WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent
[47] Fix | Delete
// is set in `wp_debug_mode()`.
[48] Fix | Delete
$is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;
[49] Fix | Delete
[50] Fix | Delete
return $is_debug ?
[51] Fix | Delete
// translators: Visible only in the front end, this warning takes the place of a faulty block. %s represents a pattern's slug.
[52] Fix | Delete
sprintf( __( '[block rendering halted for pattern "%s"]' ), $slug ) :
[53] Fix | Delete
'';
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
$pattern = $registry->get_registered( $slug );
[57] Fix | Delete
$content = $pattern['content'];
[58] Fix | Delete
[59] Fix | Delete
// Backward compatibility for handling Block Hooks and injecting the theme attribute in the Gutenberg plugin.
[60] Fix | Delete
// This can be removed when the minimum supported WordPress is >= 6.4.
[61] Fix | Delete
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && ! function_exists( 'traverse_and_serialize_blocks' ) ) {
[62] Fix | Delete
$blocks = parse_blocks( $content );
[63] Fix | Delete
$content = gutenberg_serialize_blocks( $blocks );
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
$seen_refs[ $attributes['slug'] ] = true;
[67] Fix | Delete
[68] Fix | Delete
$content = do_blocks( $content );
[69] Fix | Delete
[70] Fix | Delete
global $wp_embed;
[71] Fix | Delete
$content = $wp_embed->autoembed( $content );
[72] Fix | Delete
[73] Fix | Delete
unset( $seen_refs[ $attributes['slug'] ] );
[74] Fix | Delete
return $content;
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
add_action( 'init', 'register_block_core_pattern' );
[78] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function