Skip to content

Commit 897c355

Browse files
committed
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 #42756
1 parent a5bdc76 commit 897c355

File tree

1 file changed

+0
-58
lines changed

1 file changed

+0
-58
lines changed

lib/compat/wordpress-6.2/class-wp-theme-json-resolver-6-2.php

-58
Original file line numberDiff line numberDiff line change
@@ -17,62 +17,4 @@
1717
*/
1818
class WP_Theme_JSON_Resolver_6_2 extends WP_Theme_JSON_Resolver_Base {
1919

20-
/**
21-
* Returns the user's origin config.
22-
*
23-
* @since 6.2 Added check for the WP_Theme_JSON_Gutenberg class to prevent $user
24-
* values set in core fron overriding the new custom css values added to VALID_STYLES.
25-
* This does not need to be backported to core as the new VALID_STYLES[css] value will
26-
* be added to core with 6.2.
27-
*
28-
* @return WP_Theme_JSON_Gutenberg Entity that holds styles for user data.
29-
*/
30-
public static function get_user_data() {
31-
if ( null !== static::$user && static::$user instanceof WP_Theme_JSON_Gutenberg ) {
32-
return static::$user;
33-
}
34-
35-
$config = array();
36-
$user_cpt = static::get_user_data_from_wp_global_styles( wp_get_theme() );
37-
38-
if ( array_key_exists( 'post_content', $user_cpt ) ) {
39-
$decoded_data = json_decode( $user_cpt['post_content'], true );
40-
41-
$json_decoding_error = json_last_error();
42-
if ( JSON_ERROR_NONE !== $json_decoding_error ) {
43-
trigger_error( 'Error when decoding a theme.json schema for user data. ' . json_last_error_msg() );
44-
/**
45-
* Filters the data provided by the user for global styles & settings.
46-
*
47-
* @param WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data.
48-
*/
49-
$theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data_Gutenberg( $config, 'custom' ) );
50-
$config = $theme_json->get_data();
51-
return new WP_Theme_JSON_Gutenberg( $config, 'custom' );
52-
}
53-
54-
// Very important to verify if the flag isGlobalStylesUserThemeJSON is true.
55-
// If is not true the content was not escaped and is not safe.
56-
if (
57-
is_array( $decoded_data ) &&
58-
isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) &&
59-
$decoded_data['isGlobalStylesUserThemeJSON']
60-
) {
61-
unset( $decoded_data['isGlobalStylesUserThemeJSON'] );
62-
$config = $decoded_data;
63-
}
64-
}
65-
66-
/**
67-
* Filters the data provided by the user for global styles & settings.
68-
*
69-
* @param WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data.
70-
*/
71-
$theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data_Gutenberg( $config, 'custom' ) );
72-
$config = $theme_json->get_data();
73-
74-
static::$user = new WP_Theme_JSON_Gutenberg( $config, 'custom' );
75-
76-
return static::$user;
77-
}
7820
}

0 commit comments

Comments
 (0)