wp_theme_json_data_user
Filter HookDescription
Filters the data provided by the user for global styles & settings.Hook Information
File Location |
wp-includes/class-wp-theme-json-resolver.php
View on GitHub
|
Hook Type | Filter |
Line Number | 601 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_Theme_JSON_Data
|
$theme_json
|
Class to access and update the underlying data. $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); /* Backward compatibility for extenders returning a WP_Theme_JSON_Data compatible class that is not a WP_Theme_JSON_Data object. if ( $theme_json instanceof WP_Theme_JSON_Data ) { return $theme_json->get_theme_json(); } else { $config = $theme_json->get_data(); return new WP_Theme_JSON( $config, 'custom' ); } } /* Very important to verify that the flag isGlobalStylesUserThemeJSON is true. If it's not true then the content was not escaped and is not safe. |
Usage Examples
Basic Usage
<?php
// Hook into wp_theme_json_data_user
add_filter('wp_theme_json_data_user', 'my_custom_filter', 10, 1);
function my_custom_filter($theme_json) {
// Your custom filtering logic here
return $theme_json;
}
Source Code Context
wp-includes/class-wp-theme-json-resolver.php:601
- How this hook is used in WordPress core
<?php
596 $config = $decoded_data;
597 }
598 }
599
600 /** This filter is documented in wp-includes/class-wp-theme-json-resolver.php */
601 $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) );
602
603 /*
604 * Backward compatibility for extenders returning a WP_Theme_JSON_Data
605 * compatible class that is not a WP_Theme_JSON_Data object.
606 */
PHP Documentation
<?php
/**
* Filters the data provided by the user for global styles & settings.
*
* @since 6.1.0
*
* @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying data.
*/
$theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) );
/*
* Backward compatibility for extenders returning a WP_Theme_JSON_Data
* compatible class that is not a WP_Theme_JSON_Data object.
*/
if ( $theme_json instanceof WP_Theme_JSON_Data ) {
return $theme_json->get_theme_json();
} else {
$config = $theme_json->get_data();
return new WP_Theme_JSON( $config, 'custom' );
}
}
/*
* Very important to verify that the flag isGlobalStylesUserThemeJSON is true.
* If it's not true then the content was not escaped and is not safe.
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/class-wp-theme-json-resolver.php
Related Hooks
Related hooks will be displayed here in future updates.