: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @param string $color_str CSS color string.
* @return array RGB object.
function wp_tinycolor_string_to_rgb( $color_str ) {
_deprecated_function( __FUNCTION__, '6.3.0' );
$color_str = strtolower( trim( $color_str ) );
$css_integer = '[-\\+]?\\d+%?';
$css_number = '[-\\+]?\\d*\\.\\d+%?';
$css_unit = '(?:' . $css_number . ')|(?:' . $css_integer . ')';
$permissive_match3 = '[\\s|\\(]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')\\s*\\)?';
$permissive_match4 = '[\\s|\\(]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')\\s*\\)?';
$rgb_regexp = '/^rgb' . $permissive_match3 . '$/';
if ( preg_match( $rgb_regexp, $color_str, $match ) ) {
$rgb = wp_tinycolor_rgb_to_rgb(
$rgba_regexp = '/^rgba' . $permissive_match4 . '$/';
if ( preg_match( $rgba_regexp, $color_str, $match ) ) {
$rgb = wp_tinycolor_rgb_to_rgb(
$rgb['a'] = _wp_tinycolor_bound_alpha( $match[4] );
$hsl_regexp = '/^hsl' . $permissive_match3 . '$/';
if ( preg_match( $hsl_regexp, $color_str, $match ) ) {
$rgb = wp_tinycolor_hsl_to_rgb(
$hsla_regexp = '/^hsla' . $permissive_match4 . '$/';
if ( preg_match( $hsla_regexp, $color_str, $match ) ) {
$rgb = wp_tinycolor_hsl_to_rgb(
$rgb['a'] = _wp_tinycolor_bound_alpha( $match[4] );
$hex8_regexp = '/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/';
if ( preg_match( $hex8_regexp, $color_str, $match ) ) {
$rgb = wp_tinycolor_rgb_to_rgb(
'r' => base_convert( $match[1], 16, 10 ),
'g' => base_convert( $match[2], 16, 10 ),
'b' => base_convert( $match[3], 16, 10 ),
$rgb['a'] = _wp_tinycolor_bound_alpha(
base_convert( $match[4], 16, 10 ) / 255
$hex6_regexp = '/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/';
if ( preg_match( $hex6_regexp, $color_str, $match ) ) {
$rgb = wp_tinycolor_rgb_to_rgb(
'r' => base_convert( $match[1], 16, 10 ),
'g' => base_convert( $match[2], 16, 10 ),
'b' => base_convert( $match[3], 16, 10 ),
$hex4_regexp = '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/';
if ( preg_match( $hex4_regexp, $color_str, $match ) ) {
$rgb = wp_tinycolor_rgb_to_rgb(
'r' => base_convert( $match[1] . $match[1], 16, 10 ),
'g' => base_convert( $match[2] . $match[2], 16, 10 ),
'b' => base_convert( $match[3] . $match[3], 16, 10 ),
$rgb['a'] = _wp_tinycolor_bound_alpha(
base_convert( $match[4] . $match[4], 16, 10 ) / 255
$hex3_regexp = '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/';
if ( preg_match( $hex3_regexp, $color_str, $match ) ) {
$rgb = wp_tinycolor_rgb_to_rgb(
'r' => base_convert( $match[1] . $match[1], 16, 10 ),
'g' => base_convert( $match[2] . $match[2], 16, 10 ),
'b' => base_convert( $match[3] . $match[3], 16, 10 ),
* The JS color picker considers the string "transparent" to be a hex value,
* so we need to handle it here as a special case.
if ( 'transparent' === $color_str ) {
* Returns the prefixed id for the duotone filter for use as a CSS id.
* @param array $preset Duotone preset value as seen in theme.json.
* @return string Duotone filter CSS id.
function wp_get_duotone_filter_id( $preset ) {
_deprecated_function( __FUNCTION__, '6.3.0' );
return WP_Duotone::get_filter_id_from_preset( $preset );
* Returns the CSS filter property url to reference the rendered SVG.
* @since 6.1.0 Allow unset for preset colors.
* @param array $preset Duotone preset value as seen in theme.json.
* @return string Duotone CSS filter property url value.
function wp_get_duotone_filter_property( $preset ) {
_deprecated_function( __FUNCTION__, '6.3.0' );
return WP_Duotone::get_filter_css_property_value_from_preset( $preset );
* Returns the duotone filter SVG string for the preset.
* @param array $preset Duotone preset value as seen in theme.json.
* @return string Duotone SVG filter.
function wp_get_duotone_filter_svg( $preset ) {
_deprecated_function( __FUNCTION__, '6.3.0' );
return WP_Duotone::get_filter_svg_from_preset( $preset );
* Registers the style and colors block attributes for block types that support it.
* @deprecated 6.3.0 Use WP_Duotone::register_duotone_support() instead.
* @param WP_Block_Type $block_type Block Type.
function wp_register_duotone_support( $block_type ) {
_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::register_duotone_support()' );
return WP_Duotone::register_duotone_support( $block_type );
* Renders out the duotone stylesheet and SVG.
* @since 6.1.0 Allow unset for preset colors.
* @deprecated 6.3.0 Use WP_Duotone::render_duotone_support() instead.
* @param string $block_content Rendered block content.
* @param array $block Block object.
* @return string Filtered block content.
function wp_render_duotone_support( $block_content, $block ) {
_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::render_duotone_support()' );
$wp_block = new WP_Block( $block );
return WP_Duotone::render_duotone_support( $block_content, $block, $wp_block );
* Returns a string containing the SVGs to be referenced as filters (duotone).
* @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports.
function wp_get_global_styles_svg_filters() {
_deprecated_function( __FUNCTION__, '6.3.0' );
* Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme
$can_use_cached = ! wp_is_development_mode( 'theme' );
$cache_group = 'theme_json';
$cache_key = 'wp_get_global_styles_svg_filters';
$cached = wp_cache_get( $cache_key, $cache_group );
$supports_theme_json = wp_theme_has_theme_json();
$origins = array( 'default', 'theme', 'custom' );
if ( ! $supports_theme_json ) {
$origins = array( 'default' );
$tree = WP_Theme_JSON_Resolver::get_merged_data();
$svgs = $tree->get_svg_filters( $origins );
wp_cache_set( $cache_key, $svgs, $cache_group );
* Renders the SVG filters supplied by theme.json.
* Note that this doesn't render the per-block user-defined
* filters which are handled by wp_render_duotone_support,
* but it should be rendered before the filtered content
* in the body to satisfy Safari's rendering quirks.
* @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports.
function wp_global_styles_render_svg_filters() {
_deprecated_function( __FUNCTION__, '6.3.0' );
* When calling via the in_admin_header action, we only want to render the
* SVGs on block editor pages.
! get_current_screen()->is_block_editor()
$filters = wp_get_global_styles_svg_filters();
if ( ! empty( $filters ) ) {
* Build an array with CSS classes and inline styles defining the colors
* which will be applied to the navigation markup in the front-end.
* @deprecated 6.3.0 This was removed from the Navigation Submenu block in favour of `wp_apply_colors_support()`.
* `wp_apply_colors_support()` returns an array with similar class and style values,
* but with different keys: `class` and `style`.
* @param array $context Navigation block context.
* @param array $attributes Block attributes.
* @param bool $is_sub_menu Whether the block is a sub-menu.
* @return array Colors CSS classes and inline styles.
function block_core_navigation_submenu_build_css_colors( $context, $attributes, $is_sub_menu = false ) {
_deprecated_function( __FUNCTION__, '6.3.0' );
'css_classes' => array(),
$named_text_color = null;
$custom_text_color = null;
if ( $is_sub_menu && array_key_exists( 'customOverlayTextColor', $context ) ) {
$custom_text_color = $context['customOverlayTextColor'];
} elseif ( $is_sub_menu && array_key_exists( 'overlayTextColor', $context ) ) {
$named_text_color = $context['overlayTextColor'];
} elseif ( array_key_exists( 'customTextColor', $context ) ) {
$custom_text_color = $context['customTextColor'];
} elseif ( array_key_exists( 'textColor', $context ) ) {
$named_text_color = $context['textColor'];
} elseif ( isset( $context['style']['color']['text'] ) ) {
$custom_text_color = $context['style']['color']['text'];
if ( ! is_null( $named_text_color ) ) {
array_push( $colors['css_classes'], 'has-text-color', sprintf( 'has-%s-color', $named_text_color ) );
} elseif ( ! is_null( $custom_text_color ) ) {
// Add the custom color inline style.
$colors['css_classes'][] = 'has-text-color';
$colors['inline_styles'] .= sprintf( 'color: %s;', $custom_text_color );
$named_background_color = null;
$custom_background_color = null;
if ( $is_sub_menu && array_key_exists( 'customOverlayBackgroundColor', $context ) ) {
$custom_background_color = $context['customOverlayBackgroundColor'];
} elseif ( $is_sub_menu && array_key_exists( 'overlayBackgroundColor', $context ) ) {
$named_background_color = $context['overlayBackgroundColor'];
} elseif ( array_key_exists( 'customBackgroundColor', $context ) ) {
$custom_background_color = $context['customBackgroundColor'];
} elseif ( array_key_exists( 'backgroundColor', $context ) ) {
$named_background_color = $context['backgroundColor'];
} elseif ( isset( $context['style']['color']['background'] ) ) {
$custom_background_color = $context['style']['color']['background'];
// If has background color.
if ( ! is_null( $named_background_color ) ) {
// Add the background-color class.
array_push( $colors['css_classes'], 'has-background', sprintf( 'has-%s-background-color', $named_background_color ) );
} elseif ( ! is_null( $custom_background_color ) ) {
// Add the custom background-color inline style.
$colors['css_classes'][] = 'has-background';
$colors['inline_styles'] .= sprintf( 'background-color: %s;', $custom_background_color );
* Runs the theme.json webfonts handler.
* Using `WP_Theme_JSON_Resolver`, it gets the fonts defined
* in the `theme.json` for the current selection and style
* variations, validates the font-face properties, generates
* the '@font-face' style declarations, and then enqueues the
* styles for both the editor and front-end.
* This is not a public API, but rather an internal handler.
* A future public Webfonts API will replace this stopgap code.
* This code design is intentional.
* a. It hides the inner-workings.
* b. It does not expose API ins or outs for consumption.
* c. It only works with a theme's `theme.json`.
* a. To avoid backwards-compatibility issues when
* the Webfonts API is introduced in Core.
* b. To make `fontFace` declarations in `theme.json` work.
* @link https://github.com/WordPress/gutenberg/issues/40472
* @deprecated 6.4.0 Use wp_print_font_faces() instead.
function _wp_theme_json_webfonts_handler() {
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_print_font_faces' );
// Block themes are unavailable during installation.
if ( ! wp_theme_has_theme_json() ) {
// Webfonts to be processed.
$registered_webfonts = array();
* Gets the webfonts from theme.json.
* @return array Array of defined webfonts.
$fn_get_webfonts_from_theme_json = static function() {
// Get settings from theme.json.
$settings = WP_Theme_JSON_Resolver::get_merged_data()->get_settings();
// If in the editor, add webfonts defined in variations.
if ( is_admin() || wp_is_rest_endpoint() ) {
$variations = WP_Theme_JSON_Resolver::get_style_variations();
foreach ( $variations as $variation ) {
// Skip if fontFamilies are not defined in the variation.
if ( empty( $variation['settings']['typography']['fontFamilies'] ) ) {
// Initialize the array structure.
if ( empty( $settings['typography'] ) ) {
$settings['typography'] = array();
if ( empty( $settings['typography']['fontFamilies'] ) ) {
$settings['typography']['fontFamilies'] = array();
if ( empty( $settings['typography']['fontFamilies']['theme'] ) ) {
$settings['typography']['fontFamilies']['theme'] = array();
// Combine variations with settings. Remove duplicates.
$settings['typography']['fontFamilies']['theme'] = array_merge( $settings['typography']['fontFamilies']['theme'], $variation['settings']['typography']['fontFamilies']['theme'] );
$settings['typography']['fontFamilies'] = array_unique( $settings['typography']['fontFamilies'] );
// Bail out early if there are no settings for webfonts.
if ( empty( $settings['typography']['fontFamilies'] ) ) {
// Look for fontFamilies.
foreach ( $settings['typography']['fontFamilies'] as $font_families ) {
foreach ( $font_families as $font_family ) {
// Skip if fontFace is not defined.
if ( empty( $font_family['fontFace'] ) ) {
// Skip if fontFace is not an array of webfonts.
if ( ! is_array( $font_family['fontFace'] ) ) {
$webfonts = array_merge( $webfonts, $font_family['fontFace'] );
* Transforms each 'src' into an URI by replacing 'file:./'
* placeholder from theme.json.
* The absolute path to the webfont file(s) cannot be defined in