remove_json_comments example

public static function get_block_data() {
        $registry = WP_Block_Type_Registry::get_instance();
        $blocks   = $registry->get_all_registered();

        if ( null !== static::$blocks && static::has_same_registered_blocks( 'blocks' ) ) {
            return static::$blocks;
        }

        $config = array( 'version' => 2 );
        foreach ( $blocks as $block_name => $block_type ) {
            if ( isset( $block_type->supports['__experimentalStyle'] ) ) {
                $config['styles']['blocks'][ $block_name ] = static::remove_json_comments( $block_type->supports['__experimentalStyle'] );
            }

            if (
                isset( $block_type->supports['spacing']['blockGap']['__experimentalDefault'] ) &&
                null === _wp_array_get( $config, array( 'styles', 'blocks', $block_name, 'spacing', 'blockGap' ), null )
            ) {
                /* * Ensure an empty placeholder value exists for the block, if it provides a default blockGap value. * The real blockGap value to be used will be determined when the styles are rendered for output. */
                $config['styles']['blocks'][ $block_name ]['spacing']['blockGap'] = null;
            }
Home | Imprint | This part of the site doesn't use cookies.