| 1 |
<?php |
| 2 |
/** |
| 3 |
* Block support utility functions. |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Checks whether serialization of the current block's supported properties |
| 10 |
* should occur. |
| 11 |
* |
| 12 |
* @param WP_Block_type $block_type Block type. |
| 13 |
* @param string $feature_set Name of block support feature set.. |
| 14 |
* @param string $feature Optional name of individual feature to check. |
| 15 |
* |
| 16 |
* @return boolean Whether to serialize block support styles & classes. |
| 17 |
*/ |
| 18 |
function gutenberg_should_skip_block_supports_serialization( $block_type, $feature_set, $feature = null ) { |
| 19 |
if ( ! is_object( $block_type ) || ! $feature_set ) { |
| 20 |
return false; |
| 21 |
} |
| 22 |
|
| 23 |
$path = array( $feature_set, '__experimentalSkipSerialization' ); |
| 24 |
$skip_serialization = _wp_array_get( $block_type->supports, $path, false ); |
| 25 |
|
| 26 |
if ( is_array( $skip_serialization ) ) { |
| 27 |
return in_array( $feature, $skip_serialization, true ); |
| 28 |
} |
| 29 |
|
| 30 |
return $skip_serialization; |
| 31 |
} |
| 32 |
|