utils.php 1014 B

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