Add: Public functions for interacting with global styles & settings.

This commit ports the public functions to interact with the global styles & settings.

See #54336.
Props oandregal.

git-svn-id: https://develop.svn.wordpress.org/trunk@52054 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jorge Costa
2021-11-08 21:44:12 +00:00
parent a2015573eb
commit 8e30713cd5
5 changed files with 160 additions and 37 deletions

View File

@@ -2303,31 +2303,7 @@ function wp_enqueue_global_styles() {
return;
}
$can_use_cache = (
( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) &&
( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) &&
( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) &&
! is_admin()
);
$stylesheet = null;
$transient_name = 'global_styles_' . get_stylesheet();
if ( $can_use_cache ) {
$cache = get_transient( $transient_name );
if ( $cache ) {
$stylesheet = $cache;
}
}
if ( null === $stylesheet ) {
$theme_json = WP_Theme_JSON_Resolver::get_merged_data();
$stylesheet = $theme_json->get_stylesheet();
if ( $can_use_cache ) {
set_transient( $transient_name, $stylesheet, MINUTE_IN_SECONDS );
}
}
$stylesheet = wp_get_global_stylesheet();
if ( empty( $stylesheet ) ) {
return;