Changeset 57315 for trunk/src/wp-includes/class-wp-block-type.php
- Timestamp:
- 01/19/2024 08:52:06 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-block-type.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block-type.php
r57140 r57315 114 114 * 115 115 * @since 5.8.0 116 * @var array[] 117 */ 118 public $variations = array(); 116 * @since 6.5.0 Only accessible through magic getter. null by default. 117 * @var array[]|null 118 */ 119 private $variations = null; 120 121 /** 122 * Block variations callback. 123 * 124 * @since 6.5.0 125 * @var callable|null 126 */ 127 public $variation_callback = null; 119 128 120 129 /** … … 297 306 * @type array|null $example Structured data for the block preview. 298 307 * @type callable|null $render_callback Block type render callback. 308 * @type callable|null $variation_callback Block type variations callback. 299 309 * @type array|null $attributes Block type attributes property schemas. 300 310 * @type string[] $uses_context Context values inherited by blocks of this type. … … 326 336 */ 327 337 public function __get( $name ) { 338 if ( 'variations' === $name ) { 339 return $this->get_variations(); 340 } 341 328 342 if ( ! in_array( $name, $this->deprecated_properties, true ) ) { 329 343 return; … … 354 368 */ 355 369 public function __isset( $name ) { 370 if ( 'variations' === $name ) { 371 return true; 372 } 373 356 374 if ( ! in_array( $name, $this->deprecated_properties, true ) ) { 357 375 return false; … … 373 391 */ 374 392 public function __set( $name, $value ) { 393 if ( 'variations' === $name ) { 394 $this->variations = $value; 395 return; 396 } 397 375 398 if ( ! in_array( $name, $this->deprecated_properties, true ) ) { 376 399 $this->{$name} = $value; … … 541 564 array(); 542 565 } 566 567 /** 568 * Get block variations. 569 * 570 * @since 6.5.0 571 * 572 * @return array[] 573 */ 574 public function get_variations() { 575 if ( ! isset( $this->variations ) ) { 576 $this->variations = array(); 577 if ( is_callable( $this->variation_callback ) ) { 578 $this->variations = call_user_func( $this->variation_callback ); 579 } 580 } 581 582 /** 583 * Filters the registered variations for a block type. 584 * 585 * @since 6.5.0 586 * 587 * @param array $variations Array of registered variations for a block type. 588 * @param WP_Block_Type $block_type The full block type object. 589 */ 590 return apply_filters( 'get_block_type_variations', $this->variations, $this ); 591 } 543 592 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)