[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/html-api/ -> class-wp-html-attribute-token.php (source)

   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   * @ignore
  18   *
  19   * @since 6.2.0
  20   * @since 6.5.0 Replaced `end` with `length` to more closely match `substr()`.
  21   *
  22   * @see WP_HTML_Tag_Processor
  23   */
  24  class WP_HTML_Attribute_Token {
  25      /**
  26       * Attribute name.
  27       *
  28       * @since 6.2.0
  29       *
  30       * @var string
  31       */
  32      public $name;
  33  
  34      /**
  35       * Byte offset in the input HTML where the attribute value starts.
  36       *
  37       * @since 6.2.0
  38       *
  39       * @var int
  40       */
  41      public $value_starts_at;
  42  
  43      /**
  44       * How many bytes the value occupies in the input HTML.
  45       *
  46       * @since 6.2.0
  47       *
  48       * @var int
  49       */
  50      public $value_length;
  51  
  52      /**
  53       * The string offset where the attribute name starts.
  54       *
  55       * @since 6.2.0
  56       *
  57       * @var int
  58       */
  59      public $start;
  60  
  61      /**
  62       * Byte length of text spanning the attribute inside a tag.
  63       *
  64       * This span starts at the first character of the attribute name
  65       * and it ends after one of three cases:
  66       *
  67       *  - at the end of the attribute name for boolean attributes.
  68       *  - at the end of the value for unquoted attributes.
  69       *  - at the final single or double quote for quoted attributes.
  70       *
  71       * Example:
  72       *
  73       *     <div class="post">
  74       *          ------------ length is 12, including quotes
  75       *
  76       *     <input type="checked" checked id="selector">
  77       *                           ------- length is 6
  78       *
  79       *     <a rel=noopener>
  80       *        ------------ length is 11
  81       *
  82       * @since 6.5.0 Replaced `end` with `length` to more closely match `substr()`.
  83       *
  84       * @var int
  85       */
  86      public $length;
  87  
  88      /**
  89       * Whether the attribute is a boolean attribute with value `true`.
  90       *
  91       * @since 6.2.0
  92       *
  93       * @var bool
  94       */
  95      public $is_true;
  96  
  97      /**
  98       * Constructor.
  99       *
 100       * @since 6.2.0
 101       * @since 6.5.0 Replaced `end` with `length` to more closely match `substr()`.
 102       *
 103       * @param string $name         Attribute name.
 104       * @param int    $value_start  Byte offset where the attribute value starts.
 105       * @param int    $value_length Number of bytes attribute value spans.
 106       * @param int    $start        The string offset where the attribute name starts.
 107       * @param int    $length       Byte length of the entire attribute name or name and value pair expression.
 108       * @param bool   $is_true      Whether the attribute is a boolean attribute with true value.
 109       */
 110  	public function __construct( $name, $value_start, $value_length, $start, $length, $is_true ) {
 111          $this->name            = $name;
 112          $this->value_starts_at = $value_start;
 113          $this->value_length    = $value_length;
 114          $this->start           = $start;
 115          $this->length          = $length;
 116          $this->is_true         = $is_true;
 117      }
 118  }


Generated : Tue Jun 30 08:20:12 2026 Cross-referenced by PHPXref