diff --git a/lib/class-wp-theme-json-resolver.php b/lib/class-wp-theme-json-resolver.php index 31ecb553a2ccd0..afeee40d754b7f 100644 --- a/lib/class-wp-theme-json-resolver.php +++ b/lib/class-wp-theme-json-resolver.php @@ -402,7 +402,17 @@ public static function get_merged_data( $theme_support_data = array(), $origin = $result->merge( self::get_user_data() ); } - return $result; + /** + * Return merged data. + * + * @param array $theme_support_data Existing block editor settings. + * @param string $origin The source of data the consumer wants. + * Valid values are 'core', 'theme', 'user'. + * Default is 'user'. + * + * @return WP_Theme_JSON + */ + return apply_filters( 'global_styles_get_data', $result, $theme_support_data, $origin ); } /** diff --git a/lib/global-styles.php b/lib/global-styles.php index 4bef8e7b93751c..38b514660c565c 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -10,7 +10,7 @@ * the corresponding stylesheet. * * @param WP_Theme_JSON $tree Input tree. - * @param string $type Type of stylesheet we want accepts 'all', 'block_styles', and 'css_variables'. + * @param string $type Type of stylesheet we want. Accepts 'all', 'block_styles', and 'css_variables'. * * @return string Stylesheet. */ @@ -28,7 +28,8 @@ function gutenberg_experimental_global_styles_get_stylesheet( $tree, $type = 'al // Check if we have the styles already cached. $cached = get_transient( 'global_styles' ); if ( $cached ) { - return $cached; + /* This filter is documented in lib/global-styles.php */ + return apply_filters( 'global_styles_get_stylesheet', $cached, $type, $tree ); } } @@ -49,7 +50,16 @@ function gutenberg_experimental_global_styles_get_stylesheet( $tree, $type = 'al set_transient( 'global_styles', $stylesheet, MINUTE_IN_SECONDS ); } - return $stylesheet; + /** + * Filter generated styles. + * + * @param string $stylesheet The generated styles. + * @param string $type Type of stylesheet we want. Accepts 'all', 'block_styles', and 'css_variables'. + * @param WP_Theme_JSON $tree Input tree. + * + * @return string + */ + return apply_filters( 'global_styles_get_stylesheet', $stylesheet, $type, $tree ); } /**