Changeset 56587 for trunk/src/wp-includes/blocks.php
- Timestamp:
- 09/14/2023 01:23:13 PM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r56560 r56587 343 343 * @since 6.1.0 Added support for `render` field. 344 344 * @since 6.3.0 Added `selectors` field. 345 * @since 6.4.0 Added support for `blockHooks` field. 345 346 * 346 347 * @param string $file_or_folder Path to the JSON file with metadata definition for … … 514 515 } 515 516 517 if ( ! empty( $metadata['blockHooks'] ) ) { 518 /** 519 * Map camelCased position string (from block.json) to snake_cased block type position. 520 * 521 * @var array 522 */ 523 $position_mappings = array( 524 'before' => 'before', 525 'after' => 'after', 526 'firstChild' => 'first_child', 527 'lastChild' => 'last_child', 528 ); 529 530 $settings['block_hooks'] = array(); 531 foreach ( $metadata['blockHooks'] as $anchor_block_name => $position ) { 532 // Avoid infinite recursion (hooking to itself). 533 if ( $metadata['name'] === $anchor_block_name ) { 534 _doing_it_wrong( 535 __METHOD__, 536 __( 'Cannot hook block to itself.', 'gutenberg' ), 537 '6.4.0' 538 ); 539 continue; 540 } 541 542 if ( ! isset( $position_mappings[ $position ] ) ) { 543 continue; 544 } 545 546 $settings['block_hooks'][ $anchor_block_name ] = $position_mappings[ $position ]; 547 } 548 } 549 516 550 if ( ! empty( $metadata['render'] ) ) { 517 551 $template_path = wp_normalize_path(
Note: See TracChangeset
for help on using the changeset viewer.