Skip to content

Commit

Permalink
Add a "global_styles" filter
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Feb 3, 2021
1 parent 92baa9b commit a866186
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,18 @@ function gutenberg_experimental_global_styles_get_stylesheet( $tree, $type = 'al

if ( $can_use_cached ) {
// Check if we have the styles already cached.
$cached = get_transient( 'global_styles' );
if ( $cached ) {
return $cached;
$stylesheet = get_transient( 'global_styles' );
if ( $stylesheet ) {
/**
* Filters global styles.
*
* @param string $stylesheet The styles.
* @param WP_Theme_JSON $tree Input tree.
* @param string $type Type of stylesheet we want accepts 'all', 'block_styles', and 'css_variables'.
*
* @return string Stylesheet.
*/
return apply_filters( 'global_styles', $stylesheet, $type, $tree );
}
}

Expand All @@ -164,7 +173,16 @@ function gutenberg_experimental_global_styles_get_stylesheet( $tree, $type = 'al
set_transient( 'global_styles', $stylesheet, MINUTE_IN_SECONDS );
}

return $stylesheet;
/**
* Filters global styles.
*
* @param string $stylesheet The styles.
* @param WP_Theme_JSON $tree Input tree.
* @param string $type Type of stylesheet we want accepts 'all', 'block_styles', and 'css_variables'.
*
* @return string Stylesheet.
*/
return apply_filters( 'global_styles', $stylesheet, $type, $tree );
}

/**
Expand Down

0 comments on commit a866186

Please sign in to comment.