Make WordPress Core


Ignore:
Timestamp:
06/27/2023 12:43:42 AM (3 years ago)
Author:
peterwilsoncc
Message:

Editor: Update block-serialization-default-parser package for WP 6.3 Beta 1.

Update the @wordpress/block-serialization-default-parser to 4.35.1 for WordPress 6.3 Beta 1. These changes split the following classes in to their own files in order to match the WordPress PHP coding standards:

  • WP_Block_Parser_Block
  • WP_Block_Parser_Frame
  • WP_Block_Parser

These classes were previously all included in the src/wp-includes/class-wp-block-parser.php file. In order to maintain backward compatibly for developers requiring the file directly, the relocated classes are replaced with require_once calls in the original file.

In order to retain the commit history of the new files, they have been created using the svn copy command.

Props aristath, rajanpanchal2028, jrf, SergeyBiryukov, costdev, manfcarlo, spacedmonkey, mukesh27, isabel_brison, dd32.
Fixes #57832.
See #58623.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-parser.php

    r55246 r56048  
    55 * @package WordPress
    66 */
    7 
    8 /**
    9  * Class WP_Block_Parser_Block
    10  *
    11  * Holds the block structure in memory
    12  *
    13  * @since 5.0.0
    14  */
    15 class WP_Block_Parser_Block {
    16         /**
    17          * Name of block
    18          *
    19          * @example "core/paragraph"
    20          *
    21          * @since 5.0.0
    22          * @var string
    23          */
    24         public $blockName;
    25 
    26         /**
    27          * Optional set of attributes from block comment delimiters
    28          *
    29          * @example null
    30          * @example array( 'columns' => 3 )
    31          *
    32          * @since 5.0.0
    33          * @var array|null
    34          */
    35         public $attrs;
    36 
    37         /**
    38          * List of inner blocks (of this same class)
    39          *
    40          * @since 5.0.0
    41          * @var WP_Block_Parser_Block[]
    42          */
    43         public $innerBlocks;
    44 
    45         /**
    46          * Resultant HTML from inside block comment delimiters
    47          * after removing inner blocks
    48          *
    49          * @example "...Just <!-- wp:test /--> testing..." -> "Just testing..."
    50          *
    51          * @since 5.0.0
    52          * @var string
    53          */
    54         public $innerHTML;
    55 
    56         /**
    57          * List of string fragments and null markers where inner blocks were found
    58          *
    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.0
    66          * @var array
    67          */
    68         public $innerContent;
    69 
    70         /**
    71          * Constructor.
    72          *
    73          * Will populate object properties from the provided arguments.
    74          *
    75          * @since 5.0.0
    76          *
    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_Frame
    94  *
    95  * Holds partial blocks in memory while parsing
    96  *
    97  * @internal
    98  * @since 5.0.0
    99  */
    100 class WP_Block_Parser_Frame {
    101         /**
    102          * Full or partial block
    103          *
    104          * @since 5.0.0
    105          * @var WP_Block_Parser_Block
    106          */
    107         public $block;
    108 
    109         /**
    110          * Byte offset into document for start of parse token
    111          *
    112          * @since 5.0.0
    113          * @var int
    114          */
    115         public $token_start;
    116 
    117         /**
    118          * Byte length of entire parse token string
    119          *
    120          * @since 5.0.0
    121          * @var int
    122          */
    123         public $token_length;
    124 
    125         /**
    126          * Byte offset into document for after parse token ends
    127          * (used during reconstruction of stack into parse production)
    128          *
    129          * @since 5.0.0
    130          * @var int
    131          */
    132         public $prev_offset;
    133 
    134         /**
    135          * Byte offset into document where leading HTML before token starts
    136          *
    137          * @since 5.0.0
    138          * @var int
    139          */
    140         public $leading_html_start;
    141 
    142         /**
    143          * Constructor
    144          *
    145          * Will populate object properties from the provided arguments.
    146          *
    147          * @since 5.0.0
    148          *
    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 }
    1637
    1648/**
     
    471315         * @since 3.9.0
    472316         *
    473          * @param string $innerHTML HTML content of block.
     317         * @param string $inner_html HTML content of block.
    474318         * @return WP_Block_Parser_Block freeform block object.
    475319         */
    476         public function freeform( $innerHTML ) {
    477                 return new WP_Block_Parser_Block( null, $this->empty_attrs, array(), $innerHTML, 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 ) );
    478322        }
    479323
     
    554398        }
    555399}
     400
     401/**
     402 * WP_Block_Parser_Block class.
     403 *
     404 * Required for backward compatibility in WordPress Core.
     405 */
     406require_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 */
     413require_once __DIR__ . '/class-wp-block-parser-frame.php';
Note: See TracChangeset for help on using the changeset viewer.