_wp_array_get example

    if ( isset( $attributes['style']['border']['style'] ) ) {
        $border_styles['style'] = $attributes['style']['border']['style'];
    }

    // Border width.     if ( isset( $attributes['style']['border']['width'] ) ) {
        $border_styles['width'] = $attributes['style']['border']['width'];
    }

    // Border color.     $preset_color           = array_key_exists( 'borderColor', $attributes ) ? "var:preset|color|{$attributes['borderColor']}" : null;
    $custom_color           = _wp_array_get( $attributes, array( 'style', 'border', 'color' ), null );
    $border_styles['color'] = $preset_color ? $preset_color : $custom_color;

    // Individual border styles e.g. top, left etc.     foreach ( $sides as $side ) {
        $border                 = _wp_array_get( $attributes, array( 'style', 'border', $side ), null );
        $border_styles[ $side ] = array(
            'color' => isset( $border['color'] ) ? $border['color'] : null,
            'style' => isset( $border['style'] ) ? $border['style'] : null,
            'width' => isset( $border['width'] ) ? $border['width'] : null,
        );
    }

    

        if ( empty( $block_styles ) || ! is_array( $block_styles ) ) {
            return $parsed_styles;
        }

        // Collect CSS and classnames.         foreach ( static::BLOCK_STYLE_DEFINITIONS_METADATA as $definition_group_key => $definition_group_style ) {
            if ( empty( $block_styles[ $definition_group_key ] ) ) {
                continue;
            }
            foreach ( $definition_group_style as $style_definition ) {
                $style_value = _wp_array_get( $block_styles$style_definition['path'], null );

                if ( ! static::is_valid_style_value( $style_value ) ) {
                    continue;
                }

                $parsed_styles['classnames']   = array_merge( $parsed_styles['classnames']static::get_classnames( $style_value$style_definition ) );
                $parsed_styles['declarations'] = array_merge( $parsed_styles['declarations']static::get_css_declarations( $style_value$style_definition$options ) );
            }
        }

        return $parsed_styles;
    }
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;
            }
        }

        /** * Filters the data provided by the blocks for global styles & settings. * * @since 6.1.0 * * @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying data. */

        $duotone_support = block_has_support( $block_type, array( 'filter', 'duotone' ) );
        if ( ! $duotone_support ) {
            return null;
        }

        /* * If the experimental duotone support was set, that value is to be * treated as a selector and requires scoping. */
        $experimental_duotone = _wp_array_get( $block_type->supports, array( 'color', '__experimentalDuotone' ), false );
        if ( $experimental_duotone ) {
            $root_selector = wp_get_block_css_selector( $block_type );
            return is_string( $experimental_duotone )
                ? WP_Theme_JSON::scope_selector( $root_selector$experimental_duotone )
                : $root_selector;
        }

        // Regular filter.duotone support uses filter.duotone selectors with fallbacks.         return wp_get_block_css_selector( $block_type, array( 'filter', 'duotone' ), true );
    }

    
$layout_class .= $layout_justification[ $attributes['layout']['justifyContent'] ];
    }
    if ( isset( $attributes['layout']['orientation'] ) && 'vertical' === $attributes['layout']['orientation'] ) {
        $layout_class .= ' is-vertical';
    }

    if ( isset( $attributes['layout']['flexWrap'] ) && 'nowrap' === $attributes['layout']['flexWrap'] ) {
        $layout_class .= ' no-wrap';
    }

    // Manually add block support text decoration as CSS class.     $text_decoration       = _wp_array_get( $attributes, array( 'style', 'typography', 'textDecoration' ), null );
    $text_decoration_class = sprintf( 'has-text-decoration-%s', $text_decoration );

    $colors     = block_core_navigation_build_css_colors( $attributes );
    $font_sizes = block_core_navigation_build_css_font_sizes( $attributes );
    $classes    = array_merge(
        $colors['css_classes'],
        $font_sizes['css_classes'],
        $is_responsive_menu ? array( 'is-responsive' ) : array(),
        $layout_class ? array( $layout_class ) : array(),
        $is_fallback ? array( 'is-fallback' ) : array(),
        $text_decoration ? array( $text_decoration_class ) : array()
    );
$layout_styles[] = array(
                'selector'     => $selector,
                'declarations' => array( 'flex-wrap' => 'nowrap' ),
            );
        }

        if ( $has_block_gap_support && isset( $gap_value ) ) {
            $combined_gap_value = '';
            $gap_sides          = is_array( $gap_value ) ? array( 'top', 'left' ) : array( 'top' );

            foreach ( $gap_sides as $gap_side ) {
                $process_value = is_string( $gap_value ) ? $gap_value : _wp_array_get( $gap_value, array( $gap_side )$fallback_gap_value );
                // Get spacing CSS variable from preset value if provided.                 if ( is_string( $process_value ) && str_contains( $process_value, 'var:preset|spacing|' ) ) {
                    $index_to_splice = strrpos( $process_value, '|' ) + 1;
                    $slug            = _wp_to_kebab_case( substr( $process_value$index_to_splice ) );
                    $process_value   = "var(--wp--preset--spacing--$slug)";
                }
                $combined_gap_value .= "$process_value ";
            }
            $gap_value = trim( $combined_gap_value );

            if ( null !== $gap_value && ! $should_skip_gap_serialization ) {
                
    if ( isset( $attributes['style']['border']['style'] ) ) {
        $border_styles['style'] = $attributes['style']['border']['style'];
    }

    // Border width.     if ( isset( $attributes['style']['border']['width'] ) ) {
        $border_styles['width'] = $attributes['style']['border']['width'];
    }

    // Border color.     $preset_color           = array_key_exists( 'borderColor', $attributes ) ? "var:preset|color|{$attributes['borderColor']}" : null;
    $custom_color           = _wp_array_get( $attributes, array( 'style', 'border', 'color' ), null );
    $border_styles['color'] = $preset_color ? $preset_color : $custom_color;

    // Individual border styles e.g. top, left etc.     foreach ( $sides as $side ) {
        $border                 = _wp_array_get( $attributes, array( 'style', 'border', $side ), null );
        $border_styles[ $side ] = array(
            'color' => isset( $border['color'] ) ? $border['color'] : null,
            'style' => isset( $border['style'] ) ? $border['style'] : null,
            'width' => isset( $border['width'] ) ? $border['width'] : null,
        );
    }

    

function block_has_support( $block_type$feature$default_value = false ) {
    $block_support = $default_value;
    if ( $block_type && property_exists( $block_type, 'supports' ) ) {
        $block_support = _wp_array_get( $block_type->supports, $feature$default_value );
    }

    return true === $block_support || is_array( $block_support );
}

/** * Converts typography keys declared under `supports.*` to `supports.typography.*`. * * Displays a `_doing_it_wrong()` notice when a block using the older format is detected. * * @since 5.8.0 * * @param array $metadata Metadata for registering a block type. * @return array Filtered metadata for registering a block type. */

function block_core_gallery_render( $attributes$content ) {
    $gap = _wp_array_get( $attributes, array( 'style', 'spacing', 'blockGap' ) );
    // Skip if gap value contains unsupported characters.     // Regex for CSS value borrowed from `safecss_filter_attr`, and used here     // because we only want to match against the value, not the CSS attribute.     if ( is_array( $gap ) ) {
        foreach ( $gap as $key => $value ) {
            // Make sure $value is a string to avoid PHP 8.1 deprecation error in preg_match() when the value is null.             $value = is_string( $value ) ? $value : '';
            $value = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value;

            // Get spacing CSS variable from preset value if provided.             if ( is_string( $value ) && str_contains( $value, 'var:preset|spacing|' ) ) {
                

function wp_skip_border_serialization( $block_type ) {
    _deprecated_function( __FUNCTION__, '6.0.0', 'wp_should_skip_block_supports_serialization()' );

    $border_support = _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), false );

    return is_array( $border_support ) &&
        array_key_exists( '__experimentalSkipSerialization', $border_support ) &&
        $border_support['__experimentalSkipSerialization'];
}

/** * Checks whether serialization of the current block's dimensions properties should occur. * * @since 5.9.0 * @access private * @deprecated 6.0.0 Use wp_should_skip_block_supports_serialization() introduced in 6.0.0. * * @see wp_should_skip_block_supports_serialization() * * @param WP_Block_type $block_type Block type. * @return bool Whether to serialize spacing support styles & classes. */


    $block_type                    = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
    $skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' );

    if ( $skip_link_color_serialization ) {
        return $block_content;
    }

    $link_color = null;
    if ( ! empty( $block['attrs'] ) ) {
        $link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null );
    }

    $hover_link_color = null;
    if ( ! empty( $block['attrs'] ) ) {
        $hover_link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', ':hover', 'color', 'text' ), null );
    }

    /* * For now we only care about link colors. * This code in the future when we have a public API * should take advantage of WP_Theme_JSON::compute_style_properties * and work for any element and style. */
/** * Registers the style and colors block attributes for block types that support it. * * @since 5.6.0 * @since 6.1.0 Improved $color_support assignment optimization. * @access private * * @param WP_Block_Type $block_type Block Type. */
function wp_register_colors_support( $block_type ) {
    $color_support                 = property_exists( $block_type, 'supports' ) ? _wp_array_get( $block_type->supports, array( 'color' ), false ) : false;
    $has_text_colors_support       = true === $color_support || ( is_array( $color_support ) && _wp_array_get( $color_support, array( 'text' ), true ) );
    $has_background_colors_support = true === $color_support || ( is_array( $color_support ) && _wp_array_get( $color_support, array( 'background' ), true ) );
    $has_gradients_support         = _wp_array_get( $color_support, array( 'gradients' ), false );
    $has_link_colors_support       = _wp_array_get( $color_support, array( 'link' ), false );
    $has_color_support             = $has_text_colors_support ||
        $has_background_colors_support ||
        $has_gradients_support ||
        $has_link_colors_support;

    if ( ! $block_type->attributes ) {
        $block_type->attributes = array();
    }
$theme_json       = static::sanitize( $this->theme_json, $valid_block_names$valid_element_names$valid_variations );
        $this->theme_json = static::maybe_opt_in_into_settings( $theme_json );

        // Internally, presets are keyed by origin.         $nodes = static::get_setting_nodes( $this->theme_json );
        foreach ( $nodes as $node ) {
            foreach ( static::PRESETS_METADATA as $preset_metadata ) {
                $path = $node['path'];
                foreach ( $preset_metadata['path'] as $subpath ) {
                    $path[] = $subpath;
                }
                $preset = _wp_array_get( $this->theme_json, $path, null );
                if ( null !== $preset ) {
                    // If the preset is not already keyed by origin.                     if ( isset( $preset[0] ) || empty( $preset ) ) {
                        _wp_array_set( $this->theme_json, $path, array( $origin => $preset ) );
                    }
                }
            }
        }
    }

    /** * Enables some opt-in settings if theme declared support. * * @since 5.9.0 * * @param array $theme_json A theme.json structure to modify. * @return array The modified theme.json structure. */
// Width support to be added in near future.
    $has_min_height_support = block_has_support( $block_type, array( 'dimensions', 'minHeight' ), false );
    $block_styles           = isset( $block_attributes['style'] ) ? $block_attributes['style'] : null;

    if ( ! $block_styles ) {
        return $attributes;
    }

    $skip_min_height                      = wp_should_skip_block_supports_serialization( $block_type, 'dimensions', 'minHeight' );
    $dimensions_block_styles              = array();
    $dimensions_block_styles['minHeight'] = $has_min_height_support && ! $skip_min_height ? _wp_array_get( $block_styles, array( 'dimensions', 'minHeight' ), null ) : null;
    $styles                               = wp_style_engine_get_styles( array( 'dimensions' => $dimensions_block_styles ) );

    if ( ! empty( $styles['css'] ) ) {
        $attributes['style'] = $styles['css'];
    }

    return $attributes;
}

// Register the block support. WP_Block_Supports::get_instance()->register(
    

function wp_should_skip_block_supports_serialization( $block_type$feature_set$feature = null ) {
    if ( ! is_object( $block_type ) || ! $feature_set ) {
        return false;
    }

    $path               = array( $feature_set, '__experimentalSkipSerialization' );
    $skip_serialization = _wp_array_get( $block_type->supports, $path, false );

    if ( is_array( $skip_serialization ) ) {
        return in_array( $feature$skip_serialization, true );
    }

    return $skip_serialization;
}
Home | Imprint | This part of the site doesn't use cookies.