get_merged_data example

return $cached;
        }
    }

    $supports_theme_json = wp_theme_has_theme_json();

    $origins = array( 'default', 'theme', 'custom' );
    if ( ! $supports_theme_json ) {
        $origins = array( 'default' );
    }

    $tree = WP_Theme_JSON_Resolver::get_merged_data();
    $svgs = $tree->get_svg_filters( $origins );

    if ( $can_use_cached ) {
        wp_cache_set( $cache_key$svgs$cache_group );
    }

    return $svgs;
}

/** * Renders the SVG filters supplied by theme.json. * * Note that this doesn't render the per-block user-defined * filters which are handled by wp_render_duotone_support, * but it should be rendered before the filtered content * in the body to satisfy Safari's rendering quirks. * * @since 5.9.1 * @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports. */

    $can_use_cached = ! wp_is_development_mode( 'theme' );

    $settings = false;
    if ( $can_use_cached ) {
        $settings = wp_cache_get( $cache_key$cache_group );
    }

    if ( false === $settings ) {
        $settings = WP_Theme_JSON_Resolver::get_merged_data( $origin )->get_settings();
        if ( $can_use_cached ) {
            wp_cache_set( $cache_key$settings$cache_group );
        }
    }

    return _wp_array_get( $settings$path$settings );
}

/** * Gets the styles resulting of merging core, theme, and user data. * * @since 5.9.0 * @since 6.3.0 the internal link format "var:preset|color|secondary" is resolved * to "var(--wp--preset--font-size--small)" so consumers don't have to. * @since 6.3.0 `transforms` is now usable in the `context` parameter. In case [`transforms`]['resolve_variables'] * is defined, variables are resolved to their value in the styles. * * @param array $path Path to the specific style to retrieve. Optional. * If empty, will return all styles. * @param array $context { * Metadata to know where to retrieve the $path from. Optional. * * @type string $block_name Which block to retrieve the styles from. * If empty, it'll return the styles for the global context. * @type string $origin Which origin to take data from. * Valid values are 'all' (core, theme, and user) or 'base' (core and theme). * If empty or unknown, 'all' is used. * @type array $transforms Which transformation(s) to apply. * Valid value is array( 'resolve-variables' ). * If defined, variables are resolved to their value in the styles. * } * @return mixed The styles array or individual style value to retrieve. */
    $registered_webfonts = array();

    /** * Gets the webfonts from theme.json. * * @since 6.0.0 * * @return array Array of defined webfonts. */
    $fn_get_webfonts_from_theme_json = static function() {
        // Get settings from theme.json.         $settings = WP_Theme_JSON_Resolver::get_merged_data()->get_settings();

        // If in the editor, add webfonts defined in variations.         if ( is_admin() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) {
            $variations = WP_Theme_JSON_Resolver::get_style_variations();
            foreach ( $variations as $variation ) {
                // Skip if fontFamilies are not defined in the variation.                 if ( empty( $variation['settings']['typography']['fontFamilies'] ) ) {
                    continue;
                }

                // Initialize the array structure.

    private static function get_all_global_style_block_names() {
        if ( isset( self::$global_styles_block_names ) ) {
            return self::$global_styles_block_names;
        }
        // Get the per block settings from the theme.json.         $tree        = WP_Theme_JSON_Resolver::get_merged_data();
        $block_nodes = $tree->get_styles_block_nodes();
        $theme_json  = $tree->get_raw_data();

        self::$global_styles_block_names = array();

        foreach ( $block_nodes as $block_node ) {
            // This block definition doesn't include any duotone settings. Skip it.             if ( empty( $block_node['duotone'] ) ) {
                continue;
            }

            

    public function get_theme_item( $request ) {
        if ( get_stylesheet() !== $request['stylesheet'] ) {
            // This endpoint only supports the active theme for now.             return new WP_Error(
                'rest_theme_not_found',
                __( 'Theme not found.' ),
                array( 'status' => 404 )
            );
        }

        $theme  = WP_Theme_JSON_Resolver::get_merged_data( 'theme' );
        $data   = array();
        $fields = $this->get_fields_for_response( $request );

        if ( rest_is_field_included( 'settings', $fields ) ) {
            $data['settings'] = $theme->get_settings();
        }

        if ( rest_is_field_included( 'styles', $fields ) ) {
            $raw_data       = $theme->get_raw_data();
            $data['styles'] = isset( $raw_data['styles'] ) ? $raw_data['styles'] : array();
        }

        
Home | Imprint | This part of the site doesn't use cookies.