Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_theme_json_data_user

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
471                if ( JSON_ERROR_NONE !== $json_decoding_error ) {
472                     trigger_error( 'Error when decoding a theme.json schema for user data. ' . json_last_error_msg() );
473                     /**
474                      * Filters the data provided by the user for global styles & settings.
475                      *
476                      * @since 6.1.0
477                      *
478                      * @param WP_Theme_JSON_Data Class to access and update the underlying data.
479                      */
480                     $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) );
481                     $config     = $theme_json->get_data();
482                     return new WP_Theme_JSON( $config, 'custom' );
483                }
484
485                // Very important to verify that the flag isGlobalStylesUserThemeJSON is true.
486                // If it's not true then the content was not escaped and is not safe.
487                if (
488                     is_array( $decoded_data ) &&
489                     isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) &&
490                     $decoded_data['isGlobalStylesUserThemeJSON']
491                ) {
492                     unset( $decoded_data['isGlobalStylesUserThemeJSON'] );
493                     $config = $decoded_data;
494                }
495           }
496
497           /** This filter is documented in wp-includes/class-wp-theme-json-resolver.php */
498           $theme_json   = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) );
499           $config       = $theme_json->get_data();
500           static::$user = new WP_Theme_JSON( $config, 'custom' );
501
502           return static::$user;
503      }
504
505      /**
506       * Returns the data merged from multiple origins.
507       *