| 1 |
<?php |
| 2 |
/** |
| 3 |
* Block Serialization Parser |
| 4 |
* |
| 5 |
* @package WordPress |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Class WP_Block_Parser_Frame |
| 10 |
* |
| 11 |
* Holds partial blocks in memory while parsing |
| 12 |
* |
| 13 |
* @internal |
| 14 |
* @since 5.0.0 |
| 15 |
*/ |
| 16 |
class WP_Block_Parser_Frame { |
| 17 |
/** |
| 18 |
* Full or partial block |
| 19 |
* |
| 20 |
* @since 5.0.0 |
| 21 |
* @var WP_Block_Parser_Block |
| 22 |
*/ |
| 23 |
public $block; |
| 24 |
|
| 25 |
/** |
| 26 |
* Byte offset into document for start of parse token |
| 27 |
* |
| 28 |
* @since 5.0.0 |
| 29 |
* @var int |
| 30 |
*/ |
| 31 |
public $token_start; |
| 32 |
|
| 33 |
/** |
| 34 |
* Byte length of entire parse token string |
| 35 |
* |
| 36 |
* @since 5.0.0 |
| 37 |
* @var int |
| 38 |
*/ |
| 39 |
public $token_length; |
| 40 |
|
| 41 |
/** |
| 42 |
* Byte offset into document for after parse token ends |
| 43 |
* (used during reconstruction of stack into parse production) |
| 44 |
* |
| 45 |
* @since 5.0.0 |
| 46 |
* @var int |
| 47 |
*/ |
| 48 |
public $prev_offset; |
| 49 |
|
| 50 |
/** |
| 51 |
* Byte offset into document where leading HTML before token starts |
| 52 |
* |
| 53 |
* @since 5.0.0 |
| 54 |
* @var int |
| 55 |
*/ |
| 56 |
public $leading_html_start; |
| 57 |
|
| 58 |
/** |
| 59 |
* Constructor |
| 60 |
* |
| 61 |
* Will populate object properties from the provided arguments. |
| 62 |
* |
| 63 |
* @since 5.0.0 |
| 64 |
* |
| 65 |
* @param WP_Block_Parser_Block $block Full or partial block. |
| 66 |
* @param int $token_start Byte offset into document for start of parse token. |
| 67 |
* @param int $token_length Byte length of entire parse token string. |
| 68 |
* @param int|null $prev_offset Optional. Byte offset into document for after parse token ends. Default null. |
| 69 |
* @param int|null $leading_html_start Optional. Byte offset into document where leading HTML before token starts. |
| 70 |
* Default null. |
| 71 |
*/ |
| 72 |
public function __construct( $block, $token_start, $token_length, $prev_offset = null, $leading_html_start = null ) { |
| 73 |
$this->block = $block; |
| 74 |
$this->token_start = $token_start; |
| 75 |
$this->token_length = $token_length; |
| 76 |
$this->prev_offset = $prev_offset ?? $token_start + $token_length; |
| 77 |
$this->leading_html_start = $leading_html_start; |
| 78 |
} |
| 79 |
} |
| 80 |
|