wp/wp-includes/class-wp-block-parser-block.php
changeset 21 48c4eec2b7e6
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
       
     1 <?php
       
     2 /**
       
     3  * Block Serialization Parser
       
     4  *
       
     5  * @package WordPress
       
     6  */
       
     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; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
       
    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; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
       
    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; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
       
    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; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
       
    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  $inner_blocks  List of inner blocks (of this same class).
       
    80 	 * @param string $inner_html    Resultant HTML from inside block comment delimiters after removing inner blocks.
       
    81 	 * @param array  $inner_content List of string fragments and null markers where inner blocks were found.
       
    82 	 */
       
    83 	public function __construct( $name, $attrs, $inner_blocks, $inner_html, $inner_content ) {
       
    84 		$this->blockName    = $name;          // phpcs:ignore WordPress.NamingConventions.ValidVariableName
       
    85 		$this->attrs        = $attrs;
       
    86 		$this->innerBlocks  = $inner_blocks;  // phpcs:ignore WordPress.NamingConventions.ValidVariableName
       
    87 		$this->innerHTML    = $inner_html;    // phpcs:ignore WordPress.NamingConventions.ValidVariableName
       
    88 		$this->innerContent = $inner_content; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
       
    89 	}
       
    90 }