Changeset 56048 for trunk/src/wp-includes/class-wp-block-parser.php
- Timestamp:
- 06/27/2023 12:43:42 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-block-parser.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block-parser.php
r55246 r56048 5 5 * @package WordPress 6 6 */ 7 8 /**9 * Class WP_Block_Parser_Block10 *11 * Holds the block structure in memory12 *13 * @since 5.0.014 */15 class WP_Block_Parser_Block {16 /**17 * Name of block18 *19 * @example "core/paragraph"20 *21 * @since 5.0.022 * @var string23 */24 public $blockName;25 26 /**27 * Optional set of attributes from block comment delimiters28 *29 * @example null30 * @example array( 'columns' => 3 )31 *32 * @since 5.0.033 * @var array|null34 */35 public $attrs;36 37 /**38 * List of inner blocks (of this same class)39 *40 * @since 5.0.041 * @var WP_Block_Parser_Block[]42 */43 public $innerBlocks;44 45 /**46 * Resultant HTML from inside block comment delimiters47 * after removing inner blocks48 *49 * @example "...Just <!-- wp:test /--> testing..." -> "Just testing..."50 *51 * @since 5.0.052 * @var string53 */54 public $innerHTML;55 56 /**57 * List of string fragments and null markers where inner blocks were found58 *59 * @example array(60 * 'innerHTML' => 'BeforeInnerAfter',61 * 'innerBlocks' => array( block, block ),62 * 'innerContent' => array( 'Before', null, 'Inner', null, 'After' ),63 * )64 *65 * @since 4.2.066 * @var array67 */68 public $innerContent;69 70 /**71 * Constructor.72 *73 * Will populate object properties from the provided arguments.74 *75 * @since 5.0.076 *77 * @param string $name Name of block.78 * @param array $attrs Optional set of attributes from block comment delimiters.79 * @param array $innerBlocks List of inner blocks (of this same class).80 * @param string $innerHTML Resultant HTML from inside block comment delimiters after removing inner blocks.81 * @param array $innerContent List of string fragments and null markers where inner blocks were found.82 */83 public function __construct( $name, $attrs, $innerBlocks, $innerHTML, $innerContent ) {84 $this->blockName = $name;85 $this->attrs = $attrs;86 $this->innerBlocks = $innerBlocks;87 $this->innerHTML = $innerHTML;88 $this->innerContent = $innerContent;89 }90 }91 92 /**93 * Class WP_Block_Parser_Frame94 *95 * Holds partial blocks in memory while parsing96 *97 * @internal98 * @since 5.0.099 */100 class WP_Block_Parser_Frame {101 /**102 * Full or partial block103 *104 * @since 5.0.0105 * @var WP_Block_Parser_Block106 */107 public $block;108 109 /**110 * Byte offset into document for start of parse token111 *112 * @since 5.0.0113 * @var int114 */115 public $token_start;116 117 /**118 * Byte length of entire parse token string119 *120 * @since 5.0.0121 * @var int122 */123 public $token_length;124 125 /**126 * Byte offset into document for after parse token ends127 * (used during reconstruction of stack into parse production)128 *129 * @since 5.0.0130 * @var int131 */132 public $prev_offset;133 134 /**135 * Byte offset into document where leading HTML before token starts136 *137 * @since 5.0.0138 * @var int139 */140 public $leading_html_start;141 142 /**143 * Constructor144 *145 * Will populate object properties from the provided arguments.146 *147 * @since 5.0.0148 *149 * @param WP_Block_Parser_Block $block Full or partial block.150 * @param int $token_start Byte offset into document for start of parse token.151 * @param int $token_length Byte length of entire parse token string.152 * @param int $prev_offset Byte offset into document for after parse token ends.153 * @param int $leading_html_start Byte offset into document where leading HTML before token starts.154 */155 public function __construct( $block, $token_start, $token_length, $prev_offset = null, $leading_html_start = null ) {156 $this->block = $block;157 $this->token_start = $token_start;158 $this->token_length = $token_length;159 $this->prev_offset = isset( $prev_offset ) ? $prev_offset : $token_start + $token_length;160 $this->leading_html_start = $leading_html_start;161 }162 }163 7 164 8 /** … … 471 315 * @since 3.9.0 472 316 * 473 * @param string $inner HTMLHTML content of block.317 * @param string $inner_html HTML content of block. 474 318 * @return WP_Block_Parser_Block freeform block object. 475 319 */ 476 public function freeform( $inner HTML) {477 return new WP_Block_Parser_Block( null, $this->empty_attrs, array(), $inner HTML, array( $innerHTML) );320 public function freeform( $inner_html ) { 321 return new WP_Block_Parser_Block( null, $this->empty_attrs, array(), $inner_html, array( $inner_html ) ); 478 322 } 479 323 … … 554 398 } 555 399 } 400 401 /** 402 * WP_Block_Parser_Block class. 403 * 404 * Required for backward compatibility in WordPress Core. 405 */ 406 require_once __DIR__ . '/class-wp-block-parser-block.php'; 407 408 /** 409 * WP_Block_Parser_Frame class. 410 * 411 * Required for backward compatibility in WordPress Core. 412 */ 413 require_once __DIR__ . '/class-wp-block-parser-frame.php';
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)