Skip to content

Commit

Permalink
Add filter ensuring selectors metadata is available
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Mar 13, 2023
1 parent c7e307d commit 1a3e557
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/compat/wordpress-6.3/blocks.php
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 );
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function gutenberg_is_experiment_enabled( $name ) {

// WordPress 6.3 compat.
require __DIR__ . '/compat/wordpress-6.3/html-api/class-gutenberg-html-tag-processor-6-3.php';
require __DIR__ . '/compat/wordpress-6.3/blocks.php';

// Experimental features.
remove_action( 'plugins_loaded', '_wp_theme_json_webfonts_handler' ); // Turns off WP 6.0's stopgap handler for Webfonts API.
Expand Down

0 comments on commit 1a3e557

Please sign in to comment.