- Timestamp:
- 09/30/2024 05:05:24 PM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api.php
r59130 r59131 97 97 98 98 /** 99 * Representation in array format of the element currently being processed. 100 * 101 * This is only available during directive processing, otherwise it is `null`. 102 * 103 * @since 6.7.0 104 * @var array<mixed>|null 105 */ 106 private $current_element = null; 107 /** 99 108 * Gets and/or sets the initial state of an Interactivity API store for a 100 109 * given namespace. … … 297 306 ? $context[ $store_namespace ] 298 307 : array(); 308 } 309 /** 310 * Returns an array representation of the current element being processed. 311 * 312 * The returned array contains a copy of the element attributes. 313 * 314 * @since 6.7.0 315 * 316 * @return array|null Current element. 317 */ 318 public function get_element(): ?array { 319 if ( null === $this->current_element ) { 320 _doing_it_wrong( 321 __METHOD__, 322 __( 'The element can only be read during directive processing.' ), 323 '6.7.0' 324 ); 325 } 326 327 return $this->current_element; 299 328 } 300 329 … … 448 477 'enter' => ! $p->is_tag_closer(), 449 478 'exit' => $p->is_tag_closer() || ! $p->has_and_visits_its_closer_tag(), 479 ); 480 481 // Get the element attributes to include them in the element representation. 482 $element_attrs = array(); 483 $attr_names = $p->get_attribute_names_with_prefix( '' ) ?? array(); 484 485 foreach ( $attr_names as $name ) { 486 $element_attrs[ $name ] = $p->get_attribute( $name ); 487 } 488 489 // Assign the current element right before running its directive processors. 490 $this->current_element = array( 491 'attributes' => $element_attrs, 450 492 ); 451 493 … … 471 513 } 472 514 } 515 516 // Clear the current element. 517 $this->current_element = null; 473 518 } 474 519
Note: See TracChangeset
for help on using the changeset viewer.