-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add filter ensuring selectors metadata is available
- Loading branch information
1 parent
c7e307d
commit 1a3e557
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Temporary compatibility shims for block APIs present in Gutenberg. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Ensure the selectors property, set via block.json metadata, is included | ||
* within the block type's settings. | ||
* | ||
* Note: This should be removed when the minimum required WP version is >= 6.2. | ||
* | ||
* @see https://github.com/WordPress/gutenberg/pull/46496 | ||
* | ||
* @param array $settings Current block type settings. | ||
* @param array $metadata Block metadata as read in via block.json. | ||
* | ||
* @return array Filtered block type settings. | ||
*/ | ||
function gutenberg_add_selectors_to_block_type_settings( $settings, $metadata ) { | ||
if ( ! isset( $settings['selectors'] ) && isset( $metadata['selectors'] ) ) { | ||
$settings['selectors'] = $metadata['selectors']; | ||
} | ||
|
||
return $settings; | ||
} | ||
add_filter( 'block_type_metadata_settings', 'gutenberg_add_selectors_to_block_type_settings', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters