Make WordPress Core


Ignore:
Timestamp:
04/11/2022 10:36:02 AM (4 years ago)
Author:
gziolo
Message:

Editor: Add functionality required for theme export in the site editor

This bring across changes to theme export functionality, and related code, and tests. Relates issue in Gutenberg: https://github.com/WordPress/gutenberg/issues/39889.

Props scruffian, timothyblynjacobs, oandregal, ajlende, zieleadam.
See #55505.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json-resolver.php

    r53072 r53129  
    152152         * @since 5.8.0
    153153         * @since 5.9.0 Theme supports have been inlined and the `$theme_support_data` argument removed.
     154         * @since 6.0.0 Adds a second parameter to allow the theme data to be returned without theme supports.
    154155         *
    155156         * @param array $deprecated Deprecated. Not used.
     157         * @param array $options Contains a key called with_supports to determine whether to include theme supports in the data.
    156158         * @return WP_Theme_JSON Entity that holds theme data.
    157159         */
    158         public static function get_theme_data( $deprecated = array() ) {
     160        public static function get_theme_data( $deprecated = array(), $options = array() ) {
    159161                if ( ! empty( $deprecated ) ) {
    160162                        _deprecated_argument( __METHOD__, '5.9.0' );
    161163                }
     164
     165                $options = wp_parse_args( $options, array( 'with_supports' => true ) );
     166
    162167                if ( null === static::$theme ) {
    163168                        $theme_json_data = static::read_json_file( static::get_file_path_from_theme( 'theme.json' ) );
     
    176181                                static::$theme = $parent_theme;
    177182                        }
     183                }
     184
     185                if ( ! $options['with_supports'] ) {
     186                        return static::$theme;
    178187                }
    179188
     
    209218                        }
    210219                        $theme_support_data['settings']['color']['defaultGradients'] = $default_gradients;
     220
     221                        // Classic themes without a theme.json don't support global duotone.
     222                        $theme_support_data['settings']['color']['defaultDuotone'] = false;
    211223                }
    212224                $with_theme_supports = new WP_Theme_JSON( $theme_support_data );
     
    478490                return $variations;
    479491        }
     492
    480493}
Note: See TracChangeset for help on using the changeset viewer.