-
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.
- Loading branch information
1 parent
bff71f6
commit bff7af0
Showing
4 changed files
with
50 additions
and
41 deletions.
There are no files selected for viewing
File renamed without changes.
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
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,47 @@ | ||
<?php | ||
/** | ||
* Temporary compatibility shims for block APIs present in Gutenberg. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Filters the block type arguments during registration to stabilize experimental block supports. | ||
* | ||
* This is a temporary compatibility shim as the approach in core is for this to be handled | ||
* within the WP_Block_Type class rather than requiring a filter. | ||
* | ||
* @param array $args Array of arguments for registering a block type. | ||
* @return array Array of arguments for registering a block type. | ||
*/ | ||
function gutenberg_stabilize_experimental_block_supports( $args ) { | ||
if ( empty( $args['supports']['typography'] ) ) { | ||
return $args; | ||
} | ||
|
||
$experimental_typography_supports_to_stable = array( | ||
'__experimentalFontFamily' => 'fontFamily', | ||
'__experimentalFontStyle' => 'fontStyle', | ||
'__experimentalFontWeight' => 'fontWeight', | ||
'__experimentalLetterSpacing' => 'letterSpacing', | ||
'__experimentalTextDecoration' => 'textDecoration', | ||
'__experimentalTextTransform' => 'textTransform', | ||
); | ||
|
||
$current_typography_supports = $args['supports']['typography']; | ||
$stable_typography_supports = array(); | ||
|
||
foreach ( $current_typography_supports as $key => $value ) { | ||
if ( array_key_exists( $key, $experimental_typography_supports_to_stable ) ) { | ||
$stable_typography_supports[ $experimental_typography_supports_to_stable[ $key ] ] = $value; | ||
} else { | ||
$stable_typography_supports[ $key ] = $value; | ||
} | ||
} | ||
|
||
$args['supports']['typography'] = $stable_typography_supports; | ||
|
||
return $args; | ||
} | ||
|
||
add_filter( 'register_block_type_args', 'gutenberg_stabilize_experimental_block_supports', PHP_INT_MAX, 1 ); |
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