@@ -5229,3 +5229,76 @@ function wp_render_duotone_support( $block_content, $block ) {
52295229 _deprecated_function ( __FUNCTION__ , '6.3.0 ' , 'WP_Duotone::render_duotone_support ' );
52305230 return WP_Duotone::render_duotone_support ( $ block_content , $ block );
52315231}
5232+
5233+ /**
5234+ * Returns a string containing the SVGs to be referenced as filters (duotone).
5235+ *
5236+ * @since 5.9.1
5237+ * @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports.
5238+ *
5239+ * @return string
5240+ */
5241+ function wp_get_global_styles_svg_filters () {
5242+ _deprecated_function ( __FUNCTION__ , '6.3.0 ' );
5243+
5244+ /*
5245+ * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme
5246+ * developer's workflow.
5247+ */
5248+ $ can_use_cached = wp_get_development_mode () !== 'theme ' ;
5249+ $ cache_group = 'theme_json ' ;
5250+ $ cache_key = 'wp_get_global_styles_svg_filters ' ;
5251+ if ( $ can_use_cached ) {
5252+ $ cached = wp_cache_get ( $ cache_key , $ cache_group );
5253+ if ( $ cached ) {
5254+ return $ cached ;
5255+ }
5256+ }
5257+
5258+ $ supports_theme_json = wp_theme_has_theme_json ();
5259+
5260+ $ origins = array ( 'default ' , 'theme ' , 'custom ' );
5261+ if ( ! $ supports_theme_json ) {
5262+ $ origins = array ( 'default ' );
5263+ }
5264+
5265+ $ tree = WP_Theme_JSON_Resolver::get_merged_data ();
5266+ $ svgs = $ tree ->get_svg_filters ( $ origins );
5267+
5268+ if ( $ can_use_cached ) {
5269+ wp_cache_set ( $ cache_key , $ svgs , $ cache_group );
5270+ }
5271+
5272+ return $ svgs ;
5273+ }
5274+
5275+ /**
5276+ * Renders the SVG filters supplied by theme.json.
5277+ *
5278+ * Note that this doesn't render the per-block user-defined
5279+ * filters which are handled by wp_render_duotone_support,
5280+ * but it should be rendered before the filtered content
5281+ * in the body to satisfy Safari's rendering quirks.
5282+ *
5283+ * @since 5.9.1
5284+ * @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports.
5285+ */
5286+ function wp_global_styles_render_svg_filters () {
5287+ _deprecated_function ( __FUNCTION__ , '6.3.0 ' );
5288+
5289+ /*
5290+ * When calling via the in_admin_header action, we only want to render the
5291+ * SVGs on block editor pages.
5292+ */
5293+ if (
5294+ is_admin () &&
5295+ ! get_current_screen ()->is_block_editor ()
5296+ ) {
5297+ return ;
5298+ }
5299+
5300+ $ filters = wp_get_global_styles_svg_filters ();
5301+ if ( ! empty ( $ filters ) ) {
5302+ echo $ filters ;
5303+ }
5304+ }
0 commit comments