From 897c35502c5d15c5479b9a733112d59af4dc834a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Thu, 22 Dec 2022 15:33:03 +0100 Subject: [PATCH] 6.2: remove get_user_data Same code as core. There's a check for detecting whether the class is an instance of WP_Theme_JSON_Gutenberg that was not ported. This check was introduced to make sure the cache of the core class didn't interfere with the cache of the Gutenberg class, so it's no longer necessary. See https://github.com/WordPress/gutenberg/pull/42756 --- .../class-wp-theme-json-resolver-6-2.php | 58 ------------------- 1 file changed, 58 deletions(-) diff --git a/lib/compat/wordpress-6.2/class-wp-theme-json-resolver-6-2.php b/lib/compat/wordpress-6.2/class-wp-theme-json-resolver-6-2.php index a66983dfad9b0c..60aca8e7c75256 100644 --- a/lib/compat/wordpress-6.2/class-wp-theme-json-resolver-6-2.php +++ b/lib/compat/wordpress-6.2/class-wp-theme-json-resolver-6-2.php @@ -17,62 +17,4 @@ */ class WP_Theme_JSON_Resolver_6_2 extends WP_Theme_JSON_Resolver_Base { - /** - * Returns the user's origin config. - * - * @since 6.2 Added check for the WP_Theme_JSON_Gutenberg class to prevent $user - * values set in core fron overriding the new custom css values added to VALID_STYLES. - * This does not need to be backported to core as the new VALID_STYLES[css] value will - * be added to core with 6.2. - * - * @return WP_Theme_JSON_Gutenberg Entity that holds styles for user data. - */ - public static function get_user_data() { - if ( null !== static::$user && static::$user instanceof WP_Theme_JSON_Gutenberg ) { - return static::$user; - } - - $config = array(); - $user_cpt = static::get_user_data_from_wp_global_styles( wp_get_theme() ); - - if ( array_key_exists( 'post_content', $user_cpt ) ) { - $decoded_data = json_decode( $user_cpt['post_content'], true ); - - $json_decoding_error = json_last_error(); - if ( JSON_ERROR_NONE !== $json_decoding_error ) { - trigger_error( 'Error when decoding a theme.json schema for user data. ' . json_last_error_msg() ); - /** - * Filters the data provided by the user for global styles & settings. - * - * @param WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data. - */ - $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data_Gutenberg( $config, 'custom' ) ); - $config = $theme_json->get_data(); - return new WP_Theme_JSON_Gutenberg( $config, 'custom' ); - } - - // Very important to verify if the flag isGlobalStylesUserThemeJSON is true. - // If is not true the content was not escaped and is not safe. - if ( - is_array( $decoded_data ) && - isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) && - $decoded_data['isGlobalStylesUserThemeJSON'] - ) { - unset( $decoded_data['isGlobalStylesUserThemeJSON'] ); - $config = $decoded_data; - } - } - - /** - * Filters the data provided by the user for global styles & settings. - * - * @param WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data. - */ - $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data_Gutenberg( $config, 'custom' ) ); - $config = $theme_json->get_data(); - - static::$user = new WP_Theme_JSON_Gutenberg( $config, 'custom' ); - - return static::$user; - } }