Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-inclu...
File: deprecated.php
* @param string $color_str CSS color string.
[5000] Fix | Delete
* @return array RGB object.
[5001] Fix | Delete
*/
[5002] Fix | Delete
function wp_tinycolor_string_to_rgb( $color_str ) {
[5003] Fix | Delete
_deprecated_function( __FUNCTION__, '6.3.0' );
[5004] Fix | Delete
[5005] Fix | Delete
$color_str = strtolower( trim( $color_str ) );
[5006] Fix | Delete
[5007] Fix | Delete
$css_integer = '[-\\+]?\\d+%?';
[5008] Fix | Delete
$css_number = '[-\\+]?\\d*\\.\\d+%?';
[5009] Fix | Delete
[5010] Fix | Delete
$css_unit = '(?:' . $css_number . ')|(?:' . $css_integer . ')';
[5011] Fix | Delete
[5012] Fix | Delete
$permissive_match3 = '[\\s|\\(]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')\\s*\\)?';
[5013] Fix | Delete
$permissive_match4 = '[\\s|\\(]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')\\s*\\)?';
[5014] Fix | Delete
[5015] Fix | Delete
$rgb_regexp = '/^rgb' . $permissive_match3 . '$/';
[5016] Fix | Delete
if ( preg_match( $rgb_regexp, $color_str, $match ) ) {
[5017] Fix | Delete
$rgb = wp_tinycolor_rgb_to_rgb(
[5018] Fix | Delete
array(
[5019] Fix | Delete
'r' => $match[1],
[5020] Fix | Delete
'g' => $match[2],
[5021] Fix | Delete
'b' => $match[3],
[5022] Fix | Delete
)
[5023] Fix | Delete
);
[5024] Fix | Delete
[5025] Fix | Delete
$rgb['a'] = 1;
[5026] Fix | Delete
[5027] Fix | Delete
return $rgb;
[5028] Fix | Delete
}
[5029] Fix | Delete
[5030] Fix | Delete
$rgba_regexp = '/^rgba' . $permissive_match4 . '$/';
[5031] Fix | Delete
if ( preg_match( $rgba_regexp, $color_str, $match ) ) {
[5032] Fix | Delete
$rgb = wp_tinycolor_rgb_to_rgb(
[5033] Fix | Delete
array(
[5034] Fix | Delete
'r' => $match[1],
[5035] Fix | Delete
'g' => $match[2],
[5036] Fix | Delete
'b' => $match[3],
[5037] Fix | Delete
)
[5038] Fix | Delete
);
[5039] Fix | Delete
[5040] Fix | Delete
$rgb['a'] = _wp_tinycolor_bound_alpha( $match[4] );
[5041] Fix | Delete
[5042] Fix | Delete
return $rgb;
[5043] Fix | Delete
}
[5044] Fix | Delete
[5045] Fix | Delete
$hsl_regexp = '/^hsl' . $permissive_match3 . '$/';
[5046] Fix | Delete
if ( preg_match( $hsl_regexp, $color_str, $match ) ) {
[5047] Fix | Delete
$rgb = wp_tinycolor_hsl_to_rgb(
[5048] Fix | Delete
array(
[5049] Fix | Delete
'h' => $match[1],
[5050] Fix | Delete
's' => $match[2],
[5051] Fix | Delete
'l' => $match[3],
[5052] Fix | Delete
)
[5053] Fix | Delete
);
[5054] Fix | Delete
[5055] Fix | Delete
$rgb['a'] = 1;
[5056] Fix | Delete
[5057] Fix | Delete
return $rgb;
[5058] Fix | Delete
}
[5059] Fix | Delete
[5060] Fix | Delete
$hsla_regexp = '/^hsla' . $permissive_match4 . '$/';
[5061] Fix | Delete
if ( preg_match( $hsla_regexp, $color_str, $match ) ) {
[5062] Fix | Delete
$rgb = wp_tinycolor_hsl_to_rgb(
[5063] Fix | Delete
array(
[5064] Fix | Delete
'h' => $match[1],
[5065] Fix | Delete
's' => $match[2],
[5066] Fix | Delete
'l' => $match[3],
[5067] Fix | Delete
)
[5068] Fix | Delete
);
[5069] Fix | Delete
[5070] Fix | Delete
$rgb['a'] = _wp_tinycolor_bound_alpha( $match[4] );
[5071] Fix | Delete
[5072] Fix | Delete
return $rgb;
[5073] Fix | Delete
}
[5074] Fix | Delete
[5075] Fix | Delete
$hex8_regexp = '/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/';
[5076] Fix | Delete
if ( preg_match( $hex8_regexp, $color_str, $match ) ) {
[5077] Fix | Delete
$rgb = wp_tinycolor_rgb_to_rgb(
[5078] Fix | Delete
array(
[5079] Fix | Delete
'r' => base_convert( $match[1], 16, 10 ),
[5080] Fix | Delete
'g' => base_convert( $match[2], 16, 10 ),
[5081] Fix | Delete
'b' => base_convert( $match[3], 16, 10 ),
[5082] Fix | Delete
)
[5083] Fix | Delete
);
[5084] Fix | Delete
[5085] Fix | Delete
$rgb['a'] = _wp_tinycolor_bound_alpha(
[5086] Fix | Delete
base_convert( $match[4], 16, 10 ) / 255
[5087] Fix | Delete
);
[5088] Fix | Delete
[5089] Fix | Delete
return $rgb;
[5090] Fix | Delete
}
[5091] Fix | Delete
[5092] Fix | Delete
$hex6_regexp = '/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/';
[5093] Fix | Delete
if ( preg_match( $hex6_regexp, $color_str, $match ) ) {
[5094] Fix | Delete
$rgb = wp_tinycolor_rgb_to_rgb(
[5095] Fix | Delete
array(
[5096] Fix | Delete
'r' => base_convert( $match[1], 16, 10 ),
[5097] Fix | Delete
'g' => base_convert( $match[2], 16, 10 ),
[5098] Fix | Delete
'b' => base_convert( $match[3], 16, 10 ),
[5099] Fix | Delete
)
[5100] Fix | Delete
);
[5101] Fix | Delete
[5102] Fix | Delete
$rgb['a'] = 1;
[5103] Fix | Delete
[5104] Fix | Delete
return $rgb;
[5105] Fix | Delete
}
[5106] Fix | Delete
[5107] Fix | Delete
$hex4_regexp = '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/';
[5108] Fix | Delete
if ( preg_match( $hex4_regexp, $color_str, $match ) ) {
[5109] Fix | Delete
$rgb = wp_tinycolor_rgb_to_rgb(
[5110] Fix | Delete
array(
[5111] Fix | Delete
'r' => base_convert( $match[1] . $match[1], 16, 10 ),
[5112] Fix | Delete
'g' => base_convert( $match[2] . $match[2], 16, 10 ),
[5113] Fix | Delete
'b' => base_convert( $match[3] . $match[3], 16, 10 ),
[5114] Fix | Delete
)
[5115] Fix | Delete
);
[5116] Fix | Delete
[5117] Fix | Delete
$rgb['a'] = _wp_tinycolor_bound_alpha(
[5118] Fix | Delete
base_convert( $match[4] . $match[4], 16, 10 ) / 255
[5119] Fix | Delete
);
[5120] Fix | Delete
[5121] Fix | Delete
return $rgb;
[5122] Fix | Delete
}
[5123] Fix | Delete
[5124] Fix | Delete
$hex3_regexp = '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/';
[5125] Fix | Delete
if ( preg_match( $hex3_regexp, $color_str, $match ) ) {
[5126] Fix | Delete
$rgb = wp_tinycolor_rgb_to_rgb(
[5127] Fix | Delete
array(
[5128] Fix | Delete
'r' => base_convert( $match[1] . $match[1], 16, 10 ),
[5129] Fix | Delete
'g' => base_convert( $match[2] . $match[2], 16, 10 ),
[5130] Fix | Delete
'b' => base_convert( $match[3] . $match[3], 16, 10 ),
[5131] Fix | Delete
)
[5132] Fix | Delete
);
[5133] Fix | Delete
[5134] Fix | Delete
$rgb['a'] = 1;
[5135] Fix | Delete
[5136] Fix | Delete
return $rgb;
[5137] Fix | Delete
}
[5138] Fix | Delete
[5139] Fix | Delete
/*
[5140] Fix | Delete
* The JS color picker considers the string "transparent" to be a hex value,
[5141] Fix | Delete
* so we need to handle it here as a special case.
[5142] Fix | Delete
*/
[5143] Fix | Delete
if ( 'transparent' === $color_str ) {
[5144] Fix | Delete
return array(
[5145] Fix | Delete
'r' => 0,
[5146] Fix | Delete
'g' => 0,
[5147] Fix | Delete
'b' => 0,
[5148] Fix | Delete
'a' => 0,
[5149] Fix | Delete
);
[5150] Fix | Delete
}
[5151] Fix | Delete
}
[5152] Fix | Delete
[5153] Fix | Delete
/**
[5154] Fix | Delete
* Returns the prefixed id for the duotone filter for use as a CSS id.
[5155] Fix | Delete
*
[5156] Fix | Delete
* @since 5.9.1
[5157] Fix | Delete
* @deprecated 6.3.0
[5158] Fix | Delete
*
[5159] Fix | Delete
* @access private
[5160] Fix | Delete
*
[5161] Fix | Delete
* @param array $preset Duotone preset value as seen in theme.json.
[5162] Fix | Delete
* @return string Duotone filter CSS id.
[5163] Fix | Delete
*/
[5164] Fix | Delete
function wp_get_duotone_filter_id( $preset ) {
[5165] Fix | Delete
_deprecated_function( __FUNCTION__, '6.3.0' );
[5166] Fix | Delete
return WP_Duotone::get_filter_id_from_preset( $preset );
[5167] Fix | Delete
}
[5168] Fix | Delete
[5169] Fix | Delete
/**
[5170] Fix | Delete
* Returns the CSS filter property url to reference the rendered SVG.
[5171] Fix | Delete
*
[5172] Fix | Delete
* @since 5.9.0
[5173] Fix | Delete
* @since 6.1.0 Allow unset for preset colors.
[5174] Fix | Delete
* @deprecated 6.3.0
[5175] Fix | Delete
*
[5176] Fix | Delete
* @access private
[5177] Fix | Delete
*
[5178] Fix | Delete
* @param array $preset Duotone preset value as seen in theme.json.
[5179] Fix | Delete
* @return string Duotone CSS filter property url value.
[5180] Fix | Delete
*/
[5181] Fix | Delete
function wp_get_duotone_filter_property( $preset ) {
[5182] Fix | Delete
_deprecated_function( __FUNCTION__, '6.3.0' );
[5183] Fix | Delete
return WP_Duotone::get_filter_css_property_value_from_preset( $preset );
[5184] Fix | Delete
}
[5185] Fix | Delete
[5186] Fix | Delete
/**
[5187] Fix | Delete
* Returns the duotone filter SVG string for the preset.
[5188] Fix | Delete
*
[5189] Fix | Delete
* @since 5.9.1
[5190] Fix | Delete
* @deprecated 6.3.0
[5191] Fix | Delete
*
[5192] Fix | Delete
* @access private
[5193] Fix | Delete
*
[5194] Fix | Delete
* @param array $preset Duotone preset value as seen in theme.json.
[5195] Fix | Delete
* @return string Duotone SVG filter.
[5196] Fix | Delete
*/
[5197] Fix | Delete
function wp_get_duotone_filter_svg( $preset ) {
[5198] Fix | Delete
_deprecated_function( __FUNCTION__, '6.3.0' );
[5199] Fix | Delete
return WP_Duotone::get_filter_svg_from_preset( $preset );
[5200] Fix | Delete
}
[5201] Fix | Delete
[5202] Fix | Delete
/**
[5203] Fix | Delete
* Registers the style and colors block attributes for block types that support it.
[5204] Fix | Delete
*
[5205] Fix | Delete
* @since 5.8.0
[5206] Fix | Delete
* @deprecated 6.3.0 Use WP_Duotone::register_duotone_support() instead.
[5207] Fix | Delete
*
[5208] Fix | Delete
* @access private
[5209] Fix | Delete
*
[5210] Fix | Delete
* @param WP_Block_Type $block_type Block Type.
[5211] Fix | Delete
*/
[5212] Fix | Delete
function wp_register_duotone_support( $block_type ) {
[5213] Fix | Delete
_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::register_duotone_support()' );
[5214] Fix | Delete
return WP_Duotone::register_duotone_support( $block_type );
[5215] Fix | Delete
}
[5216] Fix | Delete
[5217] Fix | Delete
/**
[5218] Fix | Delete
* Renders out the duotone stylesheet and SVG.
[5219] Fix | Delete
*
[5220] Fix | Delete
* @since 5.8.0
[5221] Fix | Delete
* @since 6.1.0 Allow unset for preset colors.
[5222] Fix | Delete
* @deprecated 6.3.0 Use WP_Duotone::render_duotone_support() instead.
[5223] Fix | Delete
*
[5224] Fix | Delete
* @access private
[5225] Fix | Delete
*
[5226] Fix | Delete
* @param string $block_content Rendered block content.
[5227] Fix | Delete
* @param array $block Block object.
[5228] Fix | Delete
* @return string Filtered block content.
[5229] Fix | Delete
*/
[5230] Fix | Delete
function wp_render_duotone_support( $block_content, $block ) {
[5231] Fix | Delete
_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::render_duotone_support()' );
[5232] Fix | Delete
$wp_block = new WP_Block( $block );
[5233] Fix | Delete
return WP_Duotone::render_duotone_support( $block_content, $block, $wp_block );
[5234] Fix | Delete
}
[5235] Fix | Delete
[5236] Fix | Delete
/**
[5237] Fix | Delete
* Returns a string containing the SVGs to be referenced as filters (duotone).
[5238] Fix | Delete
*
[5239] Fix | Delete
* @since 5.9.1
[5240] Fix | Delete
* @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports.
[5241] Fix | Delete
*
[5242] Fix | Delete
* @return string
[5243] Fix | Delete
*/
[5244] Fix | Delete
function wp_get_global_styles_svg_filters() {
[5245] Fix | Delete
_deprecated_function( __FUNCTION__, '6.3.0' );
[5246] Fix | Delete
[5247] Fix | Delete
/*
[5248] Fix | Delete
* Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme
[5249] Fix | Delete
* developer's workflow.
[5250] Fix | Delete
*/
[5251] Fix | Delete
$can_use_cached = ! wp_is_development_mode( 'theme' );
[5252] Fix | Delete
$cache_group = 'theme_json';
[5253] Fix | Delete
$cache_key = 'wp_get_global_styles_svg_filters';
[5254] Fix | Delete
if ( $can_use_cached ) {
[5255] Fix | Delete
$cached = wp_cache_get( $cache_key, $cache_group );
[5256] Fix | Delete
if ( $cached ) {
[5257] Fix | Delete
return $cached;
[5258] Fix | Delete
}
[5259] Fix | Delete
}
[5260] Fix | Delete
[5261] Fix | Delete
$supports_theme_json = wp_theme_has_theme_json();
[5262] Fix | Delete
[5263] Fix | Delete
$origins = array( 'default', 'theme', 'custom' );
[5264] Fix | Delete
if ( ! $supports_theme_json ) {
[5265] Fix | Delete
$origins = array( 'default' );
[5266] Fix | Delete
}
[5267] Fix | Delete
[5268] Fix | Delete
$tree = WP_Theme_JSON_Resolver::get_merged_data();
[5269] Fix | Delete
$svgs = $tree->get_svg_filters( $origins );
[5270] Fix | Delete
[5271] Fix | Delete
if ( $can_use_cached ) {
[5272] Fix | Delete
wp_cache_set( $cache_key, $svgs, $cache_group );
[5273] Fix | Delete
}
[5274] Fix | Delete
[5275] Fix | Delete
return $svgs;
[5276] Fix | Delete
}
[5277] Fix | Delete
[5278] Fix | Delete
/**
[5279] Fix | Delete
* Renders the SVG filters supplied by theme.json.
[5280] Fix | Delete
*
[5281] Fix | Delete
* Note that this doesn't render the per-block user-defined
[5282] Fix | Delete
* filters which are handled by wp_render_duotone_support,
[5283] Fix | Delete
* but it should be rendered before the filtered content
[5284] Fix | Delete
* in the body to satisfy Safari's rendering quirks.
[5285] Fix | Delete
*
[5286] Fix | Delete
* @since 5.9.1
[5287] Fix | Delete
* @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports.
[5288] Fix | Delete
*/
[5289] Fix | Delete
function wp_global_styles_render_svg_filters() {
[5290] Fix | Delete
_deprecated_function( __FUNCTION__, '6.3.0' );
[5291] Fix | Delete
[5292] Fix | Delete
/*
[5293] Fix | Delete
* When calling via the in_admin_header action, we only want to render the
[5294] Fix | Delete
* SVGs on block editor pages.
[5295] Fix | Delete
*/
[5296] Fix | Delete
if (
[5297] Fix | Delete
is_admin() &&
[5298] Fix | Delete
! get_current_screen()->is_block_editor()
[5299] Fix | Delete
) {
[5300] Fix | Delete
return;
[5301] Fix | Delete
}
[5302] Fix | Delete
[5303] Fix | Delete
$filters = wp_get_global_styles_svg_filters();
[5304] Fix | Delete
if ( ! empty( $filters ) ) {
[5305] Fix | Delete
echo $filters;
[5306] Fix | Delete
}
[5307] Fix | Delete
}
[5308] Fix | Delete
[5309] Fix | Delete
/**
[5310] Fix | Delete
* Build an array with CSS classes and inline styles defining the colors
[5311] Fix | Delete
* which will be applied to the navigation markup in the front-end.
[5312] Fix | Delete
*
[5313] Fix | Delete
* @since 5.9.0
[5314] Fix | Delete
* @deprecated 6.3.0 This was removed from the Navigation Submenu block in favour of `wp_apply_colors_support()`.
[5315] Fix | Delete
* `wp_apply_colors_support()` returns an array with similar class and style values,
[5316] Fix | Delete
* but with different keys: `class` and `style`.
[5317] Fix | Delete
*
[5318] Fix | Delete
* @param array $context Navigation block context.
[5319] Fix | Delete
* @param array $attributes Block attributes.
[5320] Fix | Delete
* @param bool $is_sub_menu Whether the block is a sub-menu.
[5321] Fix | Delete
* @return array Colors CSS classes and inline styles.
[5322] Fix | Delete
*/
[5323] Fix | Delete
function block_core_navigation_submenu_build_css_colors( $context, $attributes, $is_sub_menu = false ) {
[5324] Fix | Delete
_deprecated_function( __FUNCTION__, '6.3.0' );
[5325] Fix | Delete
$colors = array(
[5326] Fix | Delete
'css_classes' => array(),
[5327] Fix | Delete
'inline_styles' => '',
[5328] Fix | Delete
);
[5329] Fix | Delete
[5330] Fix | Delete
// Text color.
[5331] Fix | Delete
$named_text_color = null;
[5332] Fix | Delete
$custom_text_color = null;
[5333] Fix | Delete
[5334] Fix | Delete
if ( $is_sub_menu && array_key_exists( 'customOverlayTextColor', $context ) ) {
[5335] Fix | Delete
$custom_text_color = $context['customOverlayTextColor'];
[5336] Fix | Delete
} elseif ( $is_sub_menu && array_key_exists( 'overlayTextColor', $context ) ) {
[5337] Fix | Delete
$named_text_color = $context['overlayTextColor'];
[5338] Fix | Delete
} elseif ( array_key_exists( 'customTextColor', $context ) ) {
[5339] Fix | Delete
$custom_text_color = $context['customTextColor'];
[5340] Fix | Delete
} elseif ( array_key_exists( 'textColor', $context ) ) {
[5341] Fix | Delete
$named_text_color = $context['textColor'];
[5342] Fix | Delete
} elseif ( isset( $context['style']['color']['text'] ) ) {
[5343] Fix | Delete
$custom_text_color = $context['style']['color']['text'];
[5344] Fix | Delete
}
[5345] Fix | Delete
[5346] Fix | Delete
// If has text color.
[5347] Fix | Delete
if ( ! is_null( $named_text_color ) ) {
[5348] Fix | Delete
// Add the color class.
[5349] Fix | Delete
array_push( $colors['css_classes'], 'has-text-color', sprintf( 'has-%s-color', $named_text_color ) );
[5350] Fix | Delete
} elseif ( ! is_null( $custom_text_color ) ) {
[5351] Fix | Delete
// Add the custom color inline style.
[5352] Fix | Delete
$colors['css_classes'][] = 'has-text-color';
[5353] Fix | Delete
$colors['inline_styles'] .= sprintf( 'color: %s;', $custom_text_color );
[5354] Fix | Delete
}
[5355] Fix | Delete
[5356] Fix | Delete
// Background color.
[5357] Fix | Delete
$named_background_color = null;
[5358] Fix | Delete
$custom_background_color = null;
[5359] Fix | Delete
[5360] Fix | Delete
if ( $is_sub_menu && array_key_exists( 'customOverlayBackgroundColor', $context ) ) {
[5361] Fix | Delete
$custom_background_color = $context['customOverlayBackgroundColor'];
[5362] Fix | Delete
} elseif ( $is_sub_menu && array_key_exists( 'overlayBackgroundColor', $context ) ) {
[5363] Fix | Delete
$named_background_color = $context['overlayBackgroundColor'];
[5364] Fix | Delete
} elseif ( array_key_exists( 'customBackgroundColor', $context ) ) {
[5365] Fix | Delete
$custom_background_color = $context['customBackgroundColor'];
[5366] Fix | Delete
} elseif ( array_key_exists( 'backgroundColor', $context ) ) {
[5367] Fix | Delete
$named_background_color = $context['backgroundColor'];
[5368] Fix | Delete
} elseif ( isset( $context['style']['color']['background'] ) ) {
[5369] Fix | Delete
$custom_background_color = $context['style']['color']['background'];
[5370] Fix | Delete
}
[5371] Fix | Delete
[5372] Fix | Delete
// If has background color.
[5373] Fix | Delete
if ( ! is_null( $named_background_color ) ) {
[5374] Fix | Delete
// Add the background-color class.
[5375] Fix | Delete
array_push( $colors['css_classes'], 'has-background', sprintf( 'has-%s-background-color', $named_background_color ) );
[5376] Fix | Delete
} elseif ( ! is_null( $custom_background_color ) ) {
[5377] Fix | Delete
// Add the custom background-color inline style.
[5378] Fix | Delete
$colors['css_classes'][] = 'has-background';
[5379] Fix | Delete
$colors['inline_styles'] .= sprintf( 'background-color: %s;', $custom_background_color );
[5380] Fix | Delete
}
[5381] Fix | Delete
[5382] Fix | Delete
return $colors;
[5383] Fix | Delete
}
[5384] Fix | Delete
[5385] Fix | Delete
/**
[5386] Fix | Delete
* Runs the theme.json webfonts handler.
[5387] Fix | Delete
*
[5388] Fix | Delete
* Using `WP_Theme_JSON_Resolver`, it gets the fonts defined
[5389] Fix | Delete
* in the `theme.json` for the current selection and style
[5390] Fix | Delete
* variations, validates the font-face properties, generates
[5391] Fix | Delete
* the '@font-face' style declarations, and then enqueues the
[5392] Fix | Delete
* styles for both the editor and front-end.
[5393] Fix | Delete
*
[5394] Fix | Delete
* Design Notes:
[5395] Fix | Delete
* This is not a public API, but rather an internal handler.
[5396] Fix | Delete
* A future public Webfonts API will replace this stopgap code.
[5397] Fix | Delete
*
[5398] Fix | Delete
* This code design is intentional.
[5399] Fix | Delete
* a. It hides the inner-workings.
[5400] Fix | Delete
* b. It does not expose API ins or outs for consumption.
[5401] Fix | Delete
* c. It only works with a theme's `theme.json`.
[5402] Fix | Delete
*
[5403] Fix | Delete
* Why?
[5404] Fix | Delete
* a. To avoid backwards-compatibility issues when
[5405] Fix | Delete
* the Webfonts API is introduced in Core.
[5406] Fix | Delete
* b. To make `fontFace` declarations in `theme.json` work.
[5407] Fix | Delete
*
[5408] Fix | Delete
* @link https://github.com/WordPress/gutenberg/issues/40472
[5409] Fix | Delete
*
[5410] Fix | Delete
* @since 6.0.0
[5411] Fix | Delete
* @deprecated 6.4.0 Use wp_print_font_faces() instead.
[5412] Fix | Delete
* @access private
[5413] Fix | Delete
*/
[5414] Fix | Delete
function _wp_theme_json_webfonts_handler() {
[5415] Fix | Delete
_deprecated_function( __FUNCTION__, '6.4.0', 'wp_print_font_faces' );
[5416] Fix | Delete
[5417] Fix | Delete
// Block themes are unavailable during installation.
[5418] Fix | Delete
if ( wp_installing() ) {
[5419] Fix | Delete
return;
[5420] Fix | Delete
}
[5421] Fix | Delete
[5422] Fix | Delete
if ( ! wp_theme_has_theme_json() ) {
[5423] Fix | Delete
return;
[5424] Fix | Delete
}
[5425] Fix | Delete
[5426] Fix | Delete
// Webfonts to be processed.
[5427] Fix | Delete
$registered_webfonts = array();
[5428] Fix | Delete
[5429] Fix | Delete
/**
[5430] Fix | Delete
* Gets the webfonts from theme.json.
[5431] Fix | Delete
*
[5432] Fix | Delete
* @since 6.0.0
[5433] Fix | Delete
*
[5434] Fix | Delete
* @return array Array of defined webfonts.
[5435] Fix | Delete
*/
[5436] Fix | Delete
$fn_get_webfonts_from_theme_json = static function() {
[5437] Fix | Delete
// Get settings from theme.json.
[5438] Fix | Delete
$settings = WP_Theme_JSON_Resolver::get_merged_data()->get_settings();
[5439] Fix | Delete
[5440] Fix | Delete
// If in the editor, add webfonts defined in variations.
[5441] Fix | Delete
if ( is_admin() || wp_is_rest_endpoint() ) {
[5442] Fix | Delete
$variations = WP_Theme_JSON_Resolver::get_style_variations();
[5443] Fix | Delete
foreach ( $variations as $variation ) {
[5444] Fix | Delete
// Skip if fontFamilies are not defined in the variation.
[5445] Fix | Delete
if ( empty( $variation['settings']['typography']['fontFamilies'] ) ) {
[5446] Fix | Delete
continue;
[5447] Fix | Delete
}
[5448] Fix | Delete
[5449] Fix | Delete
// Initialize the array structure.
[5450] Fix | Delete
if ( empty( $settings['typography'] ) ) {
[5451] Fix | Delete
$settings['typography'] = array();
[5452] Fix | Delete
}
[5453] Fix | Delete
if ( empty( $settings['typography']['fontFamilies'] ) ) {
[5454] Fix | Delete
$settings['typography']['fontFamilies'] = array();
[5455] Fix | Delete
}
[5456] Fix | Delete
if ( empty( $settings['typography']['fontFamilies']['theme'] ) ) {
[5457] Fix | Delete
$settings['typography']['fontFamilies']['theme'] = array();
[5458] Fix | Delete
}
[5459] Fix | Delete
[5460] Fix | Delete
// Combine variations with settings. Remove duplicates.
[5461] Fix | Delete
$settings['typography']['fontFamilies']['theme'] = array_merge( $settings['typography']['fontFamilies']['theme'], $variation['settings']['typography']['fontFamilies']['theme'] );
[5462] Fix | Delete
$settings['typography']['fontFamilies'] = array_unique( $settings['typography']['fontFamilies'] );
[5463] Fix | Delete
}
[5464] Fix | Delete
}
[5465] Fix | Delete
[5466] Fix | Delete
// Bail out early if there are no settings for webfonts.
[5467] Fix | Delete
if ( empty( $settings['typography']['fontFamilies'] ) ) {
[5468] Fix | Delete
return array();
[5469] Fix | Delete
}
[5470] Fix | Delete
[5471] Fix | Delete
$webfonts = array();
[5472] Fix | Delete
[5473] Fix | Delete
// Look for fontFamilies.
[5474] Fix | Delete
foreach ( $settings['typography']['fontFamilies'] as $font_families ) {
[5475] Fix | Delete
foreach ( $font_families as $font_family ) {
[5476] Fix | Delete
[5477] Fix | Delete
// Skip if fontFace is not defined.
[5478] Fix | Delete
if ( empty( $font_family['fontFace'] ) ) {
[5479] Fix | Delete
continue;
[5480] Fix | Delete
}
[5481] Fix | Delete
[5482] Fix | Delete
// Skip if fontFace is not an array of webfonts.
[5483] Fix | Delete
if ( ! is_array( $font_family['fontFace'] ) ) {
[5484] Fix | Delete
continue;
[5485] Fix | Delete
}
[5486] Fix | Delete
[5487] Fix | Delete
$webfonts = array_merge( $webfonts, $font_family['fontFace'] );
[5488] Fix | Delete
}
[5489] Fix | Delete
}
[5490] Fix | Delete
[5491] Fix | Delete
return $webfonts;
[5492] Fix | Delete
};
[5493] Fix | Delete
[5494] Fix | Delete
/**
[5495] Fix | Delete
* Transforms each 'src' into an URI by replacing 'file:./'
[5496] Fix | Delete
* placeholder from theme.json.
[5497] Fix | Delete
*
[5498] Fix | Delete
* The absolute path to the webfont file(s) cannot be defined in
[5499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function