Changeset 58801 for trunk/src/wp-includes/blocks.php
- Timestamp:
- 07/24/2024 02:09:58 PM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r58614 r58801 386 386 * @since 6.4.0 Added support for `blockHooks` field. 387 387 * @since 6.5.0 Added support for `allowedBlocks`, `viewScriptModule`, and `viewStyle` fields. 388 * @since 6.7.0 Allow PHP filename as `variations` argument. 388 389 * 389 390 * @param string $file_or_folder Path to the JSON file with metadata definition for … … 523 524 } 524 525 526 // If `variations` is a string, it's the name of a PHP file that 527 // generates the variations. 528 if ( ! empty( $metadata['variations'] ) && is_string( $metadata['variations'] ) ) { 529 $variations_path = wp_normalize_path( 530 realpath( 531 dirname( $metadata['file'] ) . '/' . 532 remove_block_asset_path_prefix( $metadata['variations'] ) 533 ) 534 ); 535 if ( $variations_path ) { 536 /** 537 * Generates the list of block variations. 538 * 539 * @since 6.7.0 540 * 541 * @return string Returns the list of block variations. 542 */ 543 $settings['variation_callback'] = static function () use ( $variations_path ) { 544 $variations = require $variations_path; 545 return $variations; 546 }; 547 // The block instance's `variations` field is only allowed to be an array 548 // (of known block variations). We unset it so that the block instance will 549 // provide a getter that returns the result of the `variation_callback` instead. 550 unset( $settings['variations'] ); 551 } 552 } 553 525 554 $settings = array_merge( $settings, $args ); 526 555
Note: See TracChangeset
for help on using the changeset viewer.