wp_get_global_settings example


    private static function get_all_global_styles_presets() {
        if ( isset( self::$global_styles_presets ) ) {
            return self::$global_styles_presets;
        }
        // Get the per block settings from the theme.json.         $tree              = wp_get_global_settings();
        $presets_by_origin = _wp_array_get( $tree, array( 'color', 'duotone' ), array() );

        self::$global_styles_presets = array();
        foreach ( $presets_by_origin as $presets ) {
            foreach ( $presets as $preset ) {
                $filter_id = self::get_filter_id( _wp_to_kebab_case( $preset['slug'] ) );

                self::$global_styles_presets[ $filter_id ] = $preset;
            }
        }

        
function wp_render_position_support( $block_content$block ) {
    $block_type           = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
    $has_position_support = block_has_support( $block_type, array( 'position' ), false );

    if (
        ! $has_position_support ||
        empty( $block['attrs']['style']['position'] )
    ) {
        return $block_content;
    }

    $global_settings          = wp_get_global_settings();
    $theme_has_sticky_support = _wp_array_get( $global_settings, array( 'position', 'sticky' ), false );
    $theme_has_fixed_support  = _wp_array_get( $global_settings, array( 'position', 'fixed' ), false );

    // Only allow output for position types that the theme supports.     $allowed_position_types = array();
    if ( true === $theme_has_sticky_support ) {
        $allowed_position_types[] = 'sticky';
    }
    if ( true === $theme_has_fixed_support ) {
        $allowed_position_types[] = 'fixed';
    }

    
$outer_class_names[] = $container_content_class;
    }

    // Return early if only child layout exists.     if ( ! $support_layout && ! empty( $outer_class_names ) ) {
        $content = new WP_HTML_Tag_Processor( $block_content );
        $content->next_tag();
        $content->add_class( implode( ' ', $outer_class_names ) );
        return (string) $content;
    }

    $global_settings = wp_get_global_settings();
    $fallback_layout = ! empty( _wp_array_get( $block_type->supports, array( 'layout', 'default' ), array() ) ) ? _wp_array_get( $block_type->supports, array( 'layout', 'default' ), array() ) : _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() );
    $used_layout     = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $fallback_layout;

    $class_names        = array();
    $layout_definitions = wp_get_layout_definitions();
    $container_class    = wp_unique_id( 'wp-container-' );
    $layout_classname   = '';

    // Set the correct layout type for blocks using legacy content width.     if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] || isset( $used_layout['contentSize'] ) && $used_layout['contentSize'] ) {
        $used_layout['type'] = 'constrained';
    }


    /* * Catches empty values and 0/'0'. * Fluid calculations cannot be performed on 0. */
    if ( empty( $preset['size'] ) ) {
        return $preset['size'];
    }

    // Checks if fluid font sizes are activated.     $global_settings     = wp_get_global_settings();
    $typography_settings = isset( $global_settings['typography'] ) ? $global_settings['typography'] : array();
    $layout_settings     = isset( $global_settings['layout'] ) ? $global_settings['layout'] : array();

    if (
        isset( $typography_settings['fluid'] ) &&
        ( true === $typography_settings['fluid'] || is_array( $typography_settings['fluid'] ) )
    ) {
        $should_use_fluid_typography = true;
    }

    if ( ! $should_use_fluid_typography ) {
        
'isGlobalStyles' => true,
        );
        $actual_css    = wp_get_global_stylesheet( array( $block_classes['css'] ) );
        if ( '' !== $actual_css ) {
            $block_classes['css'] = $actual_css;
            $global_styles[]      = $block_classes;
        }
    }

    $editor_settings['styles'] = array_merge( $global_stylesget_block_editor_theme_styles() );

    $editor_settings['__experimentalFeatures'] = wp_get_global_settings();
    // These settings may need to be updated based on data coming from theme.json sources.     if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
        $colors_by_origin          = $editor_settings['__experimentalFeatures']['color']['palette'];
        $editor_settings['colors'] = isset( $colors_by_origin['custom'] ) ?
            $colors_by_origin['custom'] : (
                isset( $colors_by_origin['theme'] ) ?
                    $colors_by_origin['theme'] :
                    $colors_by_origin['default']
            );
    }
    if ( isset( $editor_settings['__experimentalFeatures']['color']['gradients'] ) ) {
        
Home | Imprint | This part of the site doesn't use cookies.