PHP
6 days ago
LICENSE.md
6 days ago
README.md
6 days ago
class-wp-html-active-formatting-elements.php
6 days ago
class-wp-html-attribute-token.php
6 days ago
class-wp-html-decoder.php
6 days ago
class-wp-html-doctype-info.php
6 days ago
class-wp-html-native-processor-wrapper.php
6 days ago
class-wp-html-native-tag-processor-wrapper.php
6 days ago
class-wp-html-open-elements.php
6 days ago
class-wp-html-processor-state.php
6 days ago
class-wp-html-processor.php
6 days ago
class-wp-html-span.php
6 days ago
class-wp-html-stack-event.php
6 days ago
class-wp-html-tag-processor.php
6 days ago
class-wp-html-text-replacement.php
6 days ago
class-wp-html-token.php
6 days ago
class-wp-html-unsupported-exception.php
6 days ago
class-wp-token-map.php
6 days ago
composer.json
6 days ago
html5-named-character-references.php
6 days ago
class-wp-html-attribute-token.php
117 lines
| 1 | <?php |
| 2 | /** |
| 3 | * HTML API: WP_HTML_Attribute_Token class |
| 4 | * |
| 5 | * @package WordPress |
| 6 | * @subpackage HTML-API |
| 7 | * @since 6.2.0 |
| 8 | */ |
| 9 | |
| 10 | /** |
| 11 | * Core class used by the HTML tag processor as a data structure for the attribute token, |
| 12 | * allowing to drastically improve performance. |
| 13 | * |
| 14 | * This class is for internal usage of the WP_HTML_Tag_Processor class. |
| 15 | * |
| 16 | * @access private |
| 17 | * @since 6.2.0 |
| 18 | * @since 6.5.0 Replaced `end` with `length` to more closely match `substr()`. |
| 19 | * |
| 20 | * @see WP_HTML_Tag_Processor |
| 21 | */ |
| 22 | class WP_HTML_Attribute_Token { |
| 23 | /** |
| 24 | * Attribute name. |
| 25 | * |
| 26 | * @since 6.2.0 |
| 27 | * |
| 28 | * @var string |
| 29 | */ |
| 30 | public $name; |
| 31 | |
| 32 | /** |
| 33 | * Attribute value. |
| 34 | * |
| 35 | * @since 6.2.0 |
| 36 | * |
| 37 | * @var int |
| 38 | */ |
| 39 | public $value_starts_at; |
| 40 | |
| 41 | /** |
| 42 | * How many bytes the value occupies in the input HTML. |
| 43 | * |
| 44 | * @since 6.2.0 |
| 45 | * |
| 46 | * @var int |
| 47 | */ |
| 48 | public $value_length; |
| 49 | |
| 50 | /** |
| 51 | * The string offset where the attribute name starts. |
| 52 | * |
| 53 | * @since 6.2.0 |
| 54 | * |
| 55 | * @var int |
| 56 | */ |
| 57 | public $start; |
| 58 | |
| 59 | /** |
| 60 | * Byte length of text spanning the attribute inside a tag. |
| 61 | * |
| 62 | * This span starts at the first character of the attribute name |
| 63 | * and it ends after one of three cases: |
| 64 | * |
| 65 | * - at the end of the attribute name for boolean attributes. |
| 66 | * - at the end of the value for unquoted attributes. |
| 67 | * - at the final single or double quote for quoted attributes. |
| 68 | * |
| 69 | * Example: |
| 70 | * |
| 71 | * <div class="post"> |
| 72 | * ------------ length is 12, including quotes |
| 73 | * |
| 74 | * <input type="checked" checked id="selector"> |
| 75 | * ------- length is 6 |
| 76 | * |
| 77 | * <a rel=noopener> |
| 78 | * ------------ length is 11 |
| 79 | * |
| 80 | * @since 6.5.0 Replaced `end` with `length` to more closely match `substr()`. |
| 81 | * |
| 82 | * @var int |
| 83 | */ |
| 84 | public $length; |
| 85 | |
| 86 | /** |
| 87 | * Whether the attribute is a boolean attribute with value `true`. |
| 88 | * |
| 89 | * @since 6.2.0 |
| 90 | * |
| 91 | * @var bool |
| 92 | */ |
| 93 | public $is_true; |
| 94 | |
| 95 | /** |
| 96 | * Constructor. |
| 97 | * |
| 98 | * @param string $name Attribute name. |
| 99 | * @param int $value_start Attribute value. |
| 100 | * @param int $value_length Number of bytes attribute value spans. |
| 101 | * @param int $start The string offset where the attribute name starts. |
| 102 | * @param int $length Byte length of the entire attribute name or name and value pair expression. |
| 103 | * @param bool $is_true Whether the attribute is a boolean attribute with true value. |
| 104 | * |
| 105 | * @since 6.2.0 |
| 106 | * @since 6.5.0 Replaced `end` with `length` to more closely match `substr()`. |
| 107 | */ |
| 108 | public function __construct( $name, $value_start, $value_length, $start, $length, $is_true ) { |
| 109 | $this->name = $name; |
| 110 | $this->value_starts_at = $value_start; |
| 111 | $this->value_length = $value_length; |
| 112 | $this->start = $start; |
| 113 | $this->length = $length; |
| 114 | $this->is_true = $is_true; |
| 115 | } |
| 116 | } |
| 117 |