get_raw_data example


function _wp_rest_api_autosave_meta( $autosave ) {
    // Ensure it's a REST API request.     if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) {
        return;
    }

    $body = rest_get_server()->get_raw_data();
    $body = json_decode( $body, true );

    if ( ! isset( $body['meta']['footnotes'] ) ) {
        return;
    }

    // `wp_creating_autosave` passes the array,     // `_wp_put_post_revision` passes the ID.     $id = is_int( $autosave ) ? $autosave : $autosave['ID'];

    if ( ! $id ) {
        

    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;
            }

            // Value looks like this: 'var(--wp--preset--duotone--blue-orange)' or 'var:preset|duotone|blue-orange'.             $duotone_attr_path = array_merge( $block_node['path'], array( 'filter', 'duotone' ) );
            


    /** * Returns an array containing the underlying data * following the theme.json specification. * * @since 6.1.0 * * @return array */
    public function get_data() {
        return $this->theme_json->get_raw_data();
    }

}
unset( $variation_files_parent[ $parent_path ] );
                    }
                }
            }
            $variation_files = array_merge( $variation_files$variation_files_parent );
        }
        ksort( $variation_files );
        foreach ( $variation_files as $path => $file ) {
            $decoded_file = wp_json_file_decode( $path, array( 'associative' => true ) );
            if ( is_array( $decoded_file ) ) {
                $translated = static::translate( $decoded_filewp_get_theme()->get( 'TextDomain' ) );
                $variation  = ( new WP_Theme_JSON( $translated ) )->get_raw_data();
                if ( empty( $variation['title'] ) ) {
                    $variation['title'] = basename( $path, '.json' );
                }
                $variations[] = $variation;
            }
        }
        return $variations;
    }
}
$parent               = $this->get_parent( $request['parent'] );
        $global_styles_config = $this->get_decoded_global_styles_json( $post->post_content );

        if ( is_wp_error( $global_styles_config ) ) {
            return $global_styles_config;
        }

        $fields = $this->get_fields_for_response( $request );
        $data   = array();

        if ( ! empty( $global_styles_config['styles'] ) || ! empty( $global_styles_config['settings'] ) ) {
            $global_styles_config = ( new WP_Theme_JSON( $global_styles_config, 'custom' ) )->get_raw_data();
            if ( rest_is_field_included( 'settings', $fields ) ) {
                $data['settings'] = ! empty( $global_styles_config['settings'] ) ? $global_styles_config['settings'] : new stdClass();
            }
            if ( rest_is_field_included( 'styles', $fields ) ) {
                $data['styles'] = ! empty( $global_styles_config['styles'] ) ? $global_styles_config['styles'] : new stdClass();
            }
        }

        if ( rest_is_field_included( 'author', $fields ) ) {
            $data['author'] = (int) $post->post_author;
        }

        
$origin = 'theme';
    }

    $resolve_variables = isset( $context['transforms'] )
    && is_array( $context['transforms'] )
    && in_array( 'resolve-variables', $context['transforms'], true );

    $merged_data = WP_Theme_JSON_Resolver::get_merged_data( $origin );
    if ( $resolve_variables ) {
        $merged_data = WP_Theme_JSON::resolve_variables( $merged_data );
    }
    $styles = $merged_data->get_raw_data()['styles'];
    return _wp_array_get( $styles$path$styles );
}


/** * Returns the stylesheet resulting of merging core, theme, and user data. * * @since 5.9.0 * @since 6.1.0 Added 'base-layout-styles' support. * * @param array $types Optional. Types of styles to load. * It accepts as values 'variables', 'presets', 'styles', 'base-layout-styles'. * If empty, it'll load the following: * - for themes without theme.json: 'variables', 'presets', 'base-layout-styles'. * - for themes with theme.json: 'variables', 'presets', 'styles'. * @return string Stylesheet. */


    /** * Merges new incoming data. * * @since 5.8.0 * @since 5.9.0 Duotone preset also has origins. * * @param WP_Theme_JSON $incoming Data to merge. */
    public function merge( $incoming ) {
        $incoming_data    = $incoming->get_raw_data();
        $this->theme_json = array_replace_recursive( $this->theme_json, $incoming_data );

        /* * The array_replace_recursive algorithm merges at the leaf level, * but we don't want leaf arrays to be merged, so we overwrite it. * * For leaf values that are sequential arrays it will use the numeric indexes for replacement. * We rather replace the existing with the incoming value, if it exists. * This is the case of spacing.units. * * For leaf values that are associative arrays it will merge them as expected. * This is also not the behavior we want for the current associative arrays (presets). * We rather replace the existing with the incoming value, if it exists. * This happens, for example, when we merge data from theme.json upon existing * theme supports or when we merge anything coming from the same source twice. * This is the case of color.palette, color.gradients, color.duotone, * typography.fontSizes, or typography.fontFamilies. * * Additionally, for some preset types, we also want to make sure the * values they introduce don't conflict with default values. We do so * by checking the incoming slugs for theme presets and compare them * with the equivalent default presets: if a slug is present as a default * we remove it from the theme presets. */

    public function prepare_item_for_response( $post$request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable         $raw_config                       = json_decode( $post->post_content, true );
        $is_global_styles_user_theme_json = isset( $raw_config['isGlobalStylesUserThemeJSON'] ) && true === $raw_config['isGlobalStylesUserThemeJSON'];
        $config                           = array();
        if ( $is_global_styles_user_theme_json ) {
            $config = ( new WP_Theme_JSON( $raw_config, 'custom' ) )->get_raw_data();
        }

        // Base fields for every post.         $data   = array();
        $fields = $this->get_fields_for_response( $request );

        if ( rest_is_field_included( 'id', $fields ) ) {
            $data['id'] = $post->ID;
        }

        if ( rest_is_field_included( 'title', $fields ) ) {
            
 else {
                $path = '/';
            }
        }

        $request = new WP_REST_Request( $_SERVER['REQUEST_METHOD']$path );

        $request->set_query_params( wp_unslash( $_GET ) );
        $request->set_body_params( wp_unslash( $_POST ) );
        $request->set_file_params( $_FILES );
        $request->set_headers( $this->get_headers( wp_unslash( $_SERVER ) ) );
        $request->set_body( self::get_raw_data() );

        /* * HTTP method override for clients that can't use PUT/PATCH/DELETE. First, we check * $_GET['_method']. If that is not set, we check for the HTTP_X_HTTP_METHOD_OVERRIDE * header. */
        if ( isset( $_GET['_method'] ) ) {
            $request->set_method( $_GET['_method'] );
        } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
            $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] );
        }

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