Edit File by line
/home/zeestwma/ceyloniy.../wp-inclu...
File: class-wp-block.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Blocks API: WP_Block class
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @since 5.5.0
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Class representing a parsed instance of a block.
[9] Fix | Delete
*
[10] Fix | Delete
* @since 5.5.0
[11] Fix | Delete
* @property array $attributes
[12] Fix | Delete
*/
[13] Fix | Delete
#[AllowDynamicProperties]
[14] Fix | Delete
class WP_Block {
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Original parsed array representation of block.
[18] Fix | Delete
*
[19] Fix | Delete
* @since 5.5.0
[20] Fix | Delete
* @var array
[21] Fix | Delete
*/
[22] Fix | Delete
public $parsed_block;
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Name of block.
[26] Fix | Delete
*
[27] Fix | Delete
* @example "core/paragraph"
[28] Fix | Delete
*
[29] Fix | Delete
* @since 5.5.0
[30] Fix | Delete
* @var string|null
[31] Fix | Delete
*/
[32] Fix | Delete
public $name;
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Block type associated with the instance.
[36] Fix | Delete
*
[37] Fix | Delete
* @since 5.5.0
[38] Fix | Delete
* @var WP_Block_Type
[39] Fix | Delete
*/
[40] Fix | Delete
public $block_type;
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Block context values.
[44] Fix | Delete
*
[45] Fix | Delete
* @since 5.5.0
[46] Fix | Delete
* @var array
[47] Fix | Delete
*/
[48] Fix | Delete
public $context = array();
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* All available context of the current hierarchy.
[52] Fix | Delete
*
[53] Fix | Delete
* @since 5.5.0
[54] Fix | Delete
* @var array
[55] Fix | Delete
*/
[56] Fix | Delete
protected $available_context = array();
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Block type registry.
[60] Fix | Delete
*
[61] Fix | Delete
* @since 5.9.0
[62] Fix | Delete
* @var WP_Block_Type_Registry
[63] Fix | Delete
*/
[64] Fix | Delete
protected $registry;
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* List of inner blocks (of this same class)
[68] Fix | Delete
*
[69] Fix | Delete
* @since 5.5.0
[70] Fix | Delete
* @var WP_Block_List
[71] Fix | Delete
*/
[72] Fix | Delete
public $inner_blocks = array();
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* Resultant HTML from inside block comment delimiters after removing inner
[76] Fix | Delete
* blocks.
[77] Fix | Delete
*
[78] Fix | Delete
* @example "...Just <!-- wp:test /--> testing..." -> "Just testing..."
[79] Fix | Delete
*
[80] Fix | Delete
* @since 5.5.0
[81] Fix | Delete
* @var string
[82] Fix | Delete
*/
[83] Fix | Delete
public $inner_html = '';
[84] Fix | Delete
[85] Fix | Delete
/**
[86] Fix | Delete
* List of string fragments and null markers where inner blocks were found
[87] Fix | Delete
*
[88] Fix | Delete
* @example array(
[89] Fix | Delete
* 'inner_html' => 'BeforeInnerAfter',
[90] Fix | Delete
* 'inner_blocks' => array( block, block ),
[91] Fix | Delete
* 'inner_content' => array( 'Before', null, 'Inner', null, 'After' ),
[92] Fix | Delete
* )
[93] Fix | Delete
*
[94] Fix | Delete
* @since 5.5.0
[95] Fix | Delete
* @var array
[96] Fix | Delete
*/
[97] Fix | Delete
public $inner_content = array();
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Constructor.
[101] Fix | Delete
*
[102] Fix | Delete
* Populates object properties from the provided block instance argument.
[103] Fix | Delete
*
[104] Fix | Delete
* The given array of context values will not necessarily be available on
[105] Fix | Delete
* the instance itself, but is treated as the full set of values provided by
[106] Fix | Delete
* the block's ancestry. This is assigned to the private `available_context`
[107] Fix | Delete
* property. Only values which are configured to consumed by the block via
[108] Fix | Delete
* its registered type will be assigned to the block's `context` property.
[109] Fix | Delete
*
[110] Fix | Delete
* @since 5.5.0
[111] Fix | Delete
*
[112] Fix | Delete
* @param array $block {
[113] Fix | Delete
* An associative array of a single parsed block object. See WP_Block_Parser_Block.
[114] Fix | Delete
*
[115] Fix | Delete
* @type string|null $blockName Name of block.
[116] Fix | Delete
* @type array $attrs Attributes from block comment delimiters.
[117] Fix | Delete
* @type array $innerBlocks List of inner blocks. An array of arrays that
[118] Fix | Delete
* have the same structure as this one.
[119] Fix | Delete
* @type string $innerHTML HTML from inside block comment delimiters.
[120] Fix | Delete
* @type array $innerContent List of string fragments and null markers where inner blocks were found.
[121] Fix | Delete
* }
[122] Fix | Delete
* @param array $available_context Optional array of ancestry context values.
[123] Fix | Delete
* @param WP_Block_Type_Registry $registry Optional block type registry.
[124] Fix | Delete
*/
[125] Fix | Delete
public function __construct( $block, $available_context = array(), $registry = null ) {
[126] Fix | Delete
$this->parsed_block = $block;
[127] Fix | Delete
$this->name = $block['blockName'];
[128] Fix | Delete
[129] Fix | Delete
if ( is_null( $registry ) ) {
[130] Fix | Delete
$registry = WP_Block_Type_Registry::get_instance();
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
$this->registry = $registry;
[134] Fix | Delete
[135] Fix | Delete
$this->block_type = $registry->get_registered( $this->name );
[136] Fix | Delete
[137] Fix | Delete
$this->available_context = $available_context;
[138] Fix | Delete
[139] Fix | Delete
$this->refresh_context_dependents();
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
/**
[143] Fix | Delete
* Updates the context for the current block and its inner blocks.
[144] Fix | Delete
*
[145] Fix | Delete
* The method updates the context of inner blocks, if any, by passing down
[146] Fix | Delete
* any context values the block provides (`provides_context`).
[147] Fix | Delete
*
[148] Fix | Delete
* If the block has inner blocks, the method recursively processes them by creating new instances of `WP_Block`
[149] Fix | Delete
* for each inner block and updating their context based on the block's `provides_context` property.
[150] Fix | Delete
*
[151] Fix | Delete
* @since 6.8.0
[152] Fix | Delete
*/
[153] Fix | Delete
public function refresh_context_dependents() {
[154] Fix | Delete
/*
[155] Fix | Delete
* Merging the `$context` property here is not ideal, but for now needs to happen because of backward compatibility.
[156] Fix | Delete
* Ideally, the `$context` property itself would not be filterable directly and only the `$available_context` would be filterable.
[157] Fix | Delete
* However, this needs to be separately explored whether it's possible without breakage.
[158] Fix | Delete
*/
[159] Fix | Delete
$this->available_context = array_merge( $this->available_context, $this->context );
[160] Fix | Delete
[161] Fix | Delete
if ( ! empty( $this->block_type->uses_context ) ) {
[162] Fix | Delete
foreach ( $this->block_type->uses_context as $context_name ) {
[163] Fix | Delete
if ( array_key_exists( $context_name, $this->available_context ) ) {
[164] Fix | Delete
$this->context[ $context_name ] = $this->available_context[ $context_name ];
[165] Fix | Delete
}
[166] Fix | Delete
}
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
$this->refresh_parsed_block_dependents();
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
/**
[173] Fix | Delete
* Updates the parsed block content for the current block and its inner blocks.
[174] Fix | Delete
*
[175] Fix | Delete
* This method sets the `inner_html` and `inner_content` properties of the block based on the parsed
[176] Fix | Delete
* block content provided during initialization. It ensures that the block instance reflects the
[177] Fix | Delete
* most up-to-date content for both the inner HTML and any string fragments around inner blocks.
[178] Fix | Delete
*
[179] Fix | Delete
* If the block has inner blocks, this method initializes a new `WP_Block_List` for them, ensuring the
[180] Fix | Delete
* correct content and context are updated for each nested block.
[181] Fix | Delete
*
[182] Fix | Delete
* @since 6.8.0
[183] Fix | Delete
*/
[184] Fix | Delete
public function refresh_parsed_block_dependents() {
[185] Fix | Delete
if ( ! empty( $this->parsed_block['innerBlocks'] ) ) {
[186] Fix | Delete
$child_context = $this->available_context;
[187] Fix | Delete
[188] Fix | Delete
if ( ! empty( $this->block_type->provides_context ) ) {
[189] Fix | Delete
foreach ( $this->block_type->provides_context as $context_name => $attribute_name ) {
[190] Fix | Delete
if ( array_key_exists( $attribute_name, $this->attributes ) ) {
[191] Fix | Delete
$child_context[ $context_name ] = $this->attributes[ $attribute_name ];
[192] Fix | Delete
}
[193] Fix | Delete
}
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
$this->inner_blocks = new WP_Block_List( $this->parsed_block['innerBlocks'], $child_context, $this->registry );
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
if ( ! empty( $this->parsed_block['innerHTML'] ) ) {
[200] Fix | Delete
$this->inner_html = $this->parsed_block['innerHTML'];
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
if ( ! empty( $this->parsed_block['innerContent'] ) ) {
[204] Fix | Delete
$this->inner_content = $this->parsed_block['innerContent'];
[205] Fix | Delete
}
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
/**
[209] Fix | Delete
* Returns a value from an inaccessible property.
[210] Fix | Delete
*
[211] Fix | Delete
* This is used to lazily initialize the `attributes` property of a block,
[212] Fix | Delete
* such that it is only prepared with default attributes at the time that
[213] Fix | Delete
* the property is accessed. For all other inaccessible properties, a `null`
[214] Fix | Delete
* value is returned.
[215] Fix | Delete
*
[216] Fix | Delete
* @since 5.5.0
[217] Fix | Delete
*
[218] Fix | Delete
* @param string $name Property name.
[219] Fix | Delete
* @return array|null Prepared attributes, or null.
[220] Fix | Delete
*/
[221] Fix | Delete
public function __get( $name ) {
[222] Fix | Delete
if ( 'attributes' === $name ) {
[223] Fix | Delete
$this->attributes = isset( $this->parsed_block['attrs'] ) ?
[224] Fix | Delete
$this->parsed_block['attrs'] :
[225] Fix | Delete
array();
[226] Fix | Delete
[227] Fix | Delete
if ( ! is_null( $this->block_type ) ) {
[228] Fix | Delete
$this->attributes = $this->block_type->prepare_attributes_for_render( $this->attributes );
[229] Fix | Delete
}
[230] Fix | Delete
[231] Fix | Delete
return $this->attributes;
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
return null;
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
/**
[238] Fix | Delete
* Processes the block bindings and updates the block attributes with the values from the sources.
[239] Fix | Delete
*
[240] Fix | Delete
* A block might contain bindings in its attributes. Bindings are mappings
[241] Fix | Delete
* between an attribute of the block and a source. A "source" is a function
[242] Fix | Delete
* registered with `register_block_bindings_source()` that defines how to
[243] Fix | Delete
* retrieve a value from outside the block, e.g. from post meta.
[244] Fix | Delete
*
[245] Fix | Delete
* This function will process those bindings and update the block's attributes
[246] Fix | Delete
* with the values coming from the bindings.
[247] Fix | Delete
*
[248] Fix | Delete
* ### Example
[249] Fix | Delete
*
[250] Fix | Delete
* The "bindings" property for an Image block might look like this:
[251] Fix | Delete
*
[252] Fix | Delete
* ```json
[253] Fix | Delete
* {
[254] Fix | Delete
* "metadata": {
[255] Fix | Delete
* "bindings": {
[256] Fix | Delete
* "title": {
[257] Fix | Delete
* "source": "core/post-meta",
[258] Fix | Delete
* "args": { "key": "text_custom_field" }
[259] Fix | Delete
* },
[260] Fix | Delete
* "url": {
[261] Fix | Delete
* "source": "core/post-meta",
[262] Fix | Delete
* "args": { "key": "url_custom_field" }
[263] Fix | Delete
* }
[264] Fix | Delete
* }
[265] Fix | Delete
* }
[266] Fix | Delete
* }
[267] Fix | Delete
* ```
[268] Fix | Delete
*
[269] Fix | Delete
* The above example will replace the `title` and `url` attributes of the Image
[270] Fix | Delete
* block with the values of the `text_custom_field` and `url_custom_field` post meta.
[271] Fix | Delete
*
[272] Fix | Delete
* @since 6.5.0
[273] Fix | Delete
* @since 6.6.0 Handle the `__default` attribute for pattern overrides.
[274] Fix | Delete
* @since 6.7.0 Return any updated bindings metadata in the computed attributes.
[275] Fix | Delete
*
[276] Fix | Delete
* @return array The computed block attributes for the provided block bindings.
[277] Fix | Delete
*/
[278] Fix | Delete
private function process_block_bindings() {
[279] Fix | Delete
$block_type = $this->name;
[280] Fix | Delete
$parsed_block = $this->parsed_block;
[281] Fix | Delete
$computed_attributes = array();
[282] Fix | Delete
$supported_block_attributes = get_block_bindings_supported_attributes( $block_type );
[283] Fix | Delete
[284] Fix | Delete
// If the block doesn't have the bindings property, isn't one of the supported
[285] Fix | Delete
// block types, or the bindings property is not an array, return the block content.
[286] Fix | Delete
if (
[287] Fix | Delete
empty( $supported_block_attributes ) ||
[288] Fix | Delete
empty( $parsed_block['attrs']['metadata']['bindings'] ) ||
[289] Fix | Delete
! is_array( $parsed_block['attrs']['metadata']['bindings'] )
[290] Fix | Delete
) {
[291] Fix | Delete
return $computed_attributes;
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
$bindings = $parsed_block['attrs']['metadata']['bindings'];
[295] Fix | Delete
[296] Fix | Delete
/*
[297] Fix | Delete
* If the default binding is set for pattern overrides, replace it
[298] Fix | Delete
* with a pattern override binding for all supported attributes.
[299] Fix | Delete
*/
[300] Fix | Delete
if (
[301] Fix | Delete
isset( $bindings['__default']['source'] ) &&
[302] Fix | Delete
'core/pattern-overrides' === $bindings['__default']['source']
[303] Fix | Delete
) {
[304] Fix | Delete
$updated_bindings = array();
[305] Fix | Delete
[306] Fix | Delete
/*
[307] Fix | Delete
* Build a binding array of all supported attributes.
[308] Fix | Delete
* Note that this also omits the `__default` attribute from the
[309] Fix | Delete
* resulting array.
[310] Fix | Delete
*/
[311] Fix | Delete
foreach ( $supported_block_attributes as $attribute_name ) {
[312] Fix | Delete
// Retain any non-pattern override bindings that might be present.
[313] Fix | Delete
$updated_bindings[ $attribute_name ] = isset( $bindings[ $attribute_name ] )
[314] Fix | Delete
? $bindings[ $attribute_name ]
[315] Fix | Delete
: array( 'source' => 'core/pattern-overrides' );
[316] Fix | Delete
}
[317] Fix | Delete
$bindings = $updated_bindings;
[318] Fix | Delete
/*
[319] Fix | Delete
* Update the bindings metadata of the computed attributes.
[320] Fix | Delete
* This ensures the block receives the expanded __default binding metadata when it renders.
[321] Fix | Delete
*/
[322] Fix | Delete
$computed_attributes['metadata'] = array_merge(
[323] Fix | Delete
$parsed_block['attrs']['metadata'],
[324] Fix | Delete
array( 'bindings' => $bindings )
[325] Fix | Delete
);
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
foreach ( $bindings as $attribute_name => $block_binding ) {
[329] Fix | Delete
// If the attribute is not in the supported list, process next attribute.
[330] Fix | Delete
if ( ! in_array( $attribute_name, $supported_block_attributes, true ) ) {
[331] Fix | Delete
continue;
[332] Fix | Delete
}
[333] Fix | Delete
// If no source is provided, or that source is not registered, process next attribute.
[334] Fix | Delete
if ( ! isset( $block_binding['source'] ) || ! is_string( $block_binding['source'] ) ) {
[335] Fix | Delete
continue;
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
$block_binding_source = get_block_bindings_source( $block_binding['source'] );
[339] Fix | Delete
if ( null === $block_binding_source ) {
[340] Fix | Delete
continue;
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
// Adds the necessary context defined by the source.
[344] Fix | Delete
if ( ! empty( $block_binding_source->uses_context ) ) {
[345] Fix | Delete
foreach ( $block_binding_source->uses_context as $context_name ) {
[346] Fix | Delete
if ( array_key_exists( $context_name, $this->available_context ) ) {
[347] Fix | Delete
$this->context[ $context_name ] = $this->available_context[ $context_name ];
[348] Fix | Delete
}
[349] Fix | Delete
}
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
$source_args = ! empty( $block_binding['args'] ) && is_array( $block_binding['args'] ) ? $block_binding['args'] : array();
[353] Fix | Delete
$source_value = $block_binding_source->get_value( $source_args, $this, $attribute_name );
[354] Fix | Delete
[355] Fix | Delete
// If the value is not null, process the HTML based on the block and the attribute.
[356] Fix | Delete
if ( ! is_null( $source_value ) ) {
[357] Fix | Delete
$computed_attributes[ $attribute_name ] = $source_value;
[358] Fix | Delete
}
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
return $computed_attributes;
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
/**
[365] Fix | Delete
* Depending on the block attribute name, replace its value in the HTML based on the value provided.
[366] Fix | Delete
*
[367] Fix | Delete
* @since 6.5.0
[368] Fix | Delete
*
[369] Fix | Delete
* @param string $block_content Block content.
[370] Fix | Delete
* @param string $attribute_name The attribute name to replace.
[371] Fix | Delete
* @param mixed $source_value The value used to replace in the HTML.
[372] Fix | Delete
* @return string The modified block content.
[373] Fix | Delete
*/
[374] Fix | Delete
private function replace_html( string $block_content, string $attribute_name, $source_value ) {
[375] Fix | Delete
$block_type = $this->block_type;
[376] Fix | Delete
if ( ! isset( $block_type->attributes[ $attribute_name ]['source'] ) ) {
[377] Fix | Delete
return $block_content;
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
// Depending on the attribute source, the processing will be different.
[381] Fix | Delete
switch ( $block_type->attributes[ $attribute_name ]['source'] ) {
[382] Fix | Delete
case 'html':
[383] Fix | Delete
case 'rich-text':
[384] Fix | Delete
$block_reader = self::get_block_bindings_processor( $block_content );
[385] Fix | Delete
[386] Fix | Delete
// TODO: Support for CSS selectors whenever they are ready in the HTML API.
[387] Fix | Delete
// In the meantime, support comma-separated selectors by exploding them into an array.
[388] Fix | Delete
$selectors = explode( ',', $block_type->attributes[ $attribute_name ]['selector'] );
[389] Fix | Delete
// Add a bookmark to the first tag to be able to iterate over the selectors.
[390] Fix | Delete
$block_reader->next_tag();
[391] Fix | Delete
$block_reader->set_bookmark( 'iterate-selectors' );
[392] Fix | Delete
[393] Fix | Delete
foreach ( $selectors as $selector ) {
[394] Fix | Delete
// If the parent tag, or any of its children, matches the selector, replace the HTML.
[395] Fix | Delete
if ( strcasecmp( $block_reader->get_tag(), $selector ) === 0 || $block_reader->next_tag(
[396] Fix | Delete
array(
[397] Fix | Delete
'tag_name' => $selector,
[398] Fix | Delete
)
[399] Fix | Delete
) ) {
[400] Fix | Delete
// TODO: Use `WP_HTML_Processor::set_inner_html` method once it's available.
[401] Fix | Delete
$block_reader->release_bookmark( 'iterate-selectors' );
[402] Fix | Delete
$block_reader->replace_rich_text( wp_kses_post( $source_value ) );
[403] Fix | Delete
return $block_reader->get_updated_html();
[404] Fix | Delete
} else {
[405] Fix | Delete
$block_reader->seek( 'iterate-selectors' );
[406] Fix | Delete
}
[407] Fix | Delete
}
[408] Fix | Delete
$block_reader->release_bookmark( 'iterate-selectors' );
[409] Fix | Delete
return $block_content;
[410] Fix | Delete
[411] Fix | Delete
case 'attribute':
[412] Fix | Delete
$amended_content = new WP_HTML_Tag_Processor( $block_content );
[413] Fix | Delete
if ( ! $amended_content->next_tag(
[414] Fix | Delete
array(
[415] Fix | Delete
// TODO: build the query from CSS selector.
[416] Fix | Delete
'tag_name' => $block_type->attributes[ $attribute_name ]['selector'],
[417] Fix | Delete
)
[418] Fix | Delete
) ) {
[419] Fix | Delete
return $block_content;
[420] Fix | Delete
}
[421] Fix | Delete
$amended_content->set_attribute( $block_type->attributes[ $attribute_name ]['attribute'], $source_value );
[422] Fix | Delete
return $amended_content->get_updated_html();
[423] Fix | Delete
[424] Fix | Delete
default:
[425] Fix | Delete
return $block_content;
[426] Fix | Delete
}
[427] Fix | Delete
}
[428] Fix | Delete
[429] Fix | Delete
private static function get_block_bindings_processor( string $block_content ) {
[430] Fix | Delete
$internal_processor_class = new class('', WP_HTML_Processor::CONSTRUCTOR_UNLOCK_CODE) extends WP_HTML_Processor {
[431] Fix | Delete
/**
[432] Fix | Delete
* Replace the rich text content between a tag opener and matching closer.
[433] Fix | Delete
*
[434] Fix | Delete
* When stopped on a tag opener, replace the content enclosed by it and its
[435] Fix | Delete
* matching closer with the provided rich text.
[436] Fix | Delete
*
[437] Fix | Delete
* @param string $rich_text The rich text to replace the original content with.
[438] Fix | Delete
* @return bool True on success.
[439] Fix | Delete
*/
[440] Fix | Delete
public function replace_rich_text( $rich_text ) {
[441] Fix | Delete
if ( $this->is_tag_closer() || ! $this->expects_closer() ) {
[442] Fix | Delete
return false;
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
$depth = $this->get_current_depth();
[446] Fix | Delete
$tag_name = $this->get_tag();
[447] Fix | Delete
[448] Fix | Delete
$this->set_bookmark( '_wp_block_bindings' );
[449] Fix | Delete
// The bookmark names are prefixed with `_` so the key below has an extra `_`.
[450] Fix | Delete
$tag_opener = $this->bookmarks['__wp_block_bindings'];
[451] Fix | Delete
$start = $tag_opener->start + $tag_opener->length;
[452] Fix | Delete
[453] Fix | Delete
// Find matching tag closer.
[454] Fix | Delete
while ( $this->next_token() && $this->get_current_depth() >= $depth ) {
[455] Fix | Delete
}
[456] Fix | Delete
[457] Fix | Delete
if ( ! $this->is_tag_closer() || $tag_name !== $this->get_tag() ) {
[458] Fix | Delete
return false;
[459] Fix | Delete
}
[460] Fix | Delete
[461] Fix | Delete
$this->set_bookmark( '_wp_block_bindings' );
[462] Fix | Delete
$tag_closer = $this->bookmarks['__wp_block_bindings'];
[463] Fix | Delete
$end = $tag_closer->start;
[464] Fix | Delete
[465] Fix | Delete
$this->lexical_updates[] = new WP_HTML_Text_Replacement(
[466] Fix | Delete
$start,
[467] Fix | Delete
$end - $start,
[468] Fix | Delete
$rich_text
[469] Fix | Delete
);
[470] Fix | Delete
[471] Fix | Delete
return true;
[472] Fix | Delete
}
[473] Fix | Delete
};
[474] Fix | Delete
[475] Fix | Delete
return $internal_processor_class::create_fragment( $block_content );
[476] Fix | Delete
}
[477] Fix | Delete
[478] Fix | Delete
/**
[479] Fix | Delete
* Generates the render output for the block.
[480] Fix | Delete
*
[481] Fix | Delete
* @since 5.5.0
[482] Fix | Delete
* @since 6.5.0 Added block bindings processing.
[483] Fix | Delete
*
[484] Fix | Delete
* @global WP_Post $post Global post object.
[485] Fix | Delete
*
[486] Fix | Delete
* @param array $options {
[487] Fix | Delete
* Optional options object.
[488] Fix | Delete
*
[489] Fix | Delete
* @type bool $dynamic Defaults to 'true'. Optionally set to false to avoid using the block's render_callback.
[490] Fix | Delete
* }
[491] Fix | Delete
* @return string Rendered block output.
[492] Fix | Delete
*/
[493] Fix | Delete
public function render( $options = array() ) {
[494] Fix | Delete
global $post;
[495] Fix | Delete
[496] Fix | Delete
$before_wp_enqueue_scripts_count = did_action( 'wp_enqueue_scripts' );
[497] Fix | Delete
[498] Fix | Delete
// Capture the current assets queues.
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function