: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// If we don't have a preset CSS variable, we'll assume it's a regular CSS value.
if ( ! str_contains( $style_value, "var:preset|{$css_property}|" ) ) {
return sprintf( '%s:%s;', $css_property, $style_value );
* We have a preset CSS variable as the style.
* Get the style value from the string and return CSS style.
$index_to_splice = strrpos( $style_value, '|' ) + 1;
$slug = substr( $style_value, $index_to_splice );
// Return the actual CSS inline style e.g. `text-decoration:var(--wp--preset--text-decoration--underline);`.
return sprintf( '%s:var(--wp--preset--%s--%s);', $css_property, $css_property, $slug );
* Determines whether global terms are enabled.
* @since 6.1.0 This function now always returns false.
* @return bool Always returns false.
function global_terms_enabled() {
_deprecated_function( __FUNCTION__, '6.1.0' );
* Filter the SQL clauses of an attachment query to include filenames.
* @param array $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY,
* DISTINCT, fields (SELECT), and LIMITS clauses.
* @return array The unmodified clauses.
function _filter_query_attachment_filenames( $clauses ) {
_deprecated_function( __FUNCTION__, '6.0.3', 'add_filter( "wp_allow_query_attachment_by_filename", "__return_true" )' );
remove_filter( 'posts_clauses', __FUNCTION__ );
* Retrieves a page given its title.
* If more than one post uses the same title, the post with the smallest ID will be returned.
* Be careful: in case of more than one post having the same title, it will check the oldest
* publication date, not the smallest ID.
* Because this function uses the MySQL '=' comparison, $page_title will usually be matched
* as case-insensitive with default collation.
* @since 3.0.0 The `$post_type` parameter was added.
* @deprecated 6.2.0 Use WP_Query.
* @global wpdb $wpdb WordPress database abstraction object.
* @param string $page_title Page title.
* @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
* correspond to a WP_Post object, an associative array, or a numeric array,
* respectively. Default OBJECT.
* @param string|array $post_type Optional. Post type or array of post types. Default 'page'.
* @return WP_Post|array|null WP_Post (or array) on success, or null on failure.
function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) {
_deprecated_function( __FUNCTION__, '6.2.0', 'WP_Query' );
if ( is_array( $post_type ) ) {
$post_type = esc_sql( $post_type );
$post_type_in_string = "'" . implode( "','", $post_type ) . "'";
AND post_type IN ($post_type_in_string)",
$page = $wpdb->get_var( $sql );
return get_post( $page, $output );
* Returns the correct template for the site's home page.
* @deprecated 6.2.0 Site Editor's server-side redirect for missing postType and postId
* query args is removed. Thus, this function is no longer used.
* @return array|null A template object, or null if none could be found.
function _resolve_home_block_template() {
_deprecated_function( __FUNCTION__, '6.2.0' );
$show_on_front = get_option( 'show_on_front' );
$front_page_id = get_option( 'page_on_front' );
if ( 'page' === $show_on_front && $front_page_id ) {
'postId' => $front_page_id,
$hierarchy = array( 'front-page', 'home', 'index' );
$template = resolve_block_template( 'home', $hierarchy, '' );
'postType' => 'wp_template',
'postId' => $template->id,
* Displays the link to the Windows Live Writer manifest file.
* @link https://msdn.microsoft.com/en-us/library/bb463265.aspx
* @deprecated 6.3.0 WLW manifest is no longer in use and no longer included in core,
* so the output from this function is removed.
function wlwmanifest_link() {
_deprecated_function( __FUNCTION__, '6.3.0' );
* Queues comments for metadata lazy-loading.
* @deprecated 6.3.0 Use wp_lazyload_comment_meta() instead.
* @param WP_Comment[] $comments Array of comment objects.
function wp_queue_comments_for_comment_meta_lazyload( $comments ) {
_deprecated_function( __FUNCTION__, '6.3.0', 'wp_lazyload_comment_meta()' );
// Don't use `wp_list_pluck()` to avoid by-reference manipulation.
if ( is_array( $comments ) ) {
foreach ( $comments as $comment ) {
if ( $comment instanceof WP_Comment ) {
$comment_ids[] = $comment->comment_ID;
wp_lazyload_comment_meta( $comment_ids );
* Gets the default value to use for a `loading` attribute on an element.
* This function should only be called for a tag and context if lazy-loading is generally enabled.
* The function usually returns 'lazy', but uses certain heuristics to guess whether the current element is likely to
* appear above the fold, in which case it returns a boolean `false`, which will lead to the `loading` attribute being
* omitted on the element. The purpose of this refinement is to avoid lazy-loading elements that are within the initial
* viewport, which can have a negative performance impact.
* Under the hood, the function uses {@see wp_increase_content_media_count()} every time it is called for an element
* within the main content. If the element is the very first content element, the `loading` attribute will be omitted.
* This default threshold of 3 content elements to omit the `loading` attribute for can be customized using the
* {@see 'wp_omit_loading_attr_threshold'} filter.
* @deprecated 6.3.0 Use wp_get_loading_optimization_attributes() instead.
* @see wp_get_loading_optimization_attributes()
* @global WP_Query $wp_query WordPress Query object.
* @param string $context Context for the element for which the `loading` attribute value is requested.
* @return string|bool The default `loading` attribute value. Either 'lazy', 'eager', or a boolean `false`, to indicate
* that the `loading` attribute should be skipped.
function wp_get_loading_attr_default( $context ) {
_deprecated_function( __FUNCTION__, '6.3.0', 'wp_get_loading_optimization_attributes()' );
// Skip lazy-loading for the overall block template, as it is handled more granularly.
if ( 'template' === $context ) {
* Do not lazy-load images in the header block template part, as they are likely above the fold.
* For classic themes, this is handled in the condition below using the 'get_header' action.
$header_area = WP_TEMPLATE_PART_AREA_HEADER;
if ( "template_part_{$header_area}" === $context ) {
// Special handling for programmatically created image tags.
if ( 'the_post_thumbnail' === $context || 'wp_get_attachment_image' === $context ) {
* Skip programmatically created images within post content as they need to be handled together with the other
* images within the post content.
* Without this clause, they would already be counted below which skews the number and can result in the first
* post content image being lazy-loaded only because there are images elsewhere in the post content.
if ( doing_filter( 'the_content' ) ) {
// Conditionally skip lazy-loading on images before the loop.
// Only apply for main query but before the loop.
$wp_query->before_loop && $wp_query->is_main_query()
* Any image before the loop, but after the header has started should not be lazy-loaded,
* except when the footer has already started which can happen when the current template
* does not include any loop.
&& did_action( 'get_header' ) && ! did_action( 'get_footer' )
* The first elements in 'the_content' or 'the_post_thumbnail' should not be lazy-loaded,
* as they are likely above the fold.
if ( 'the_content' === $context || 'the_post_thumbnail' === $context ) {
// Only elements within the main query loop have special handling.
if ( is_admin() || ! in_the_loop() || ! is_main_query() ) {
// Increase the counter since this is a main query content element.
$content_media_count = wp_increase_content_media_count();
// If the count so far is below the threshold, return `false` so that the `loading` attribute is omitted.
if ( $content_media_count <= wp_omit_loading_attr_threshold() ) {
// For elements after the threshold, lazy-load them as usual.
// Lazy-load by default for any unknown context.
* Adds `loading` attribute to an `img` HTML tag.
* @deprecated 6.3.0 Use wp_img_tag_add_loading_optimization_attrs() instead.
* @see wp_img_tag_add_loading_optimization_attrs()
* @param string $image The HTML `img` tag where the attribute should be added.
* @param string $context Additional context to pass to the filters.
* @return string Converted `img` tag with `loading` attribute added.
function wp_img_tag_add_loading_attr( $image, $context ) {
_deprecated_function( __FUNCTION__, '6.3.0', 'wp_img_tag_add_loading_optimization_attrs()' );
* Get loading attribute value to use. This must occur before the conditional check below so that even images that
* are ineligible for being lazy-loaded are considered.
$value = wp_get_loading_attr_default( $context );
// Images should have source and dimension attributes for the `loading` attribute to be added.
if ( ! str_contains( $image, ' src="' ) || ! str_contains( $image, ' width="' ) || ! str_contains( $image, ' height="' ) ) {
/** This filter is documented in wp-admin/includes/media.php */
$value = apply_filters( 'wp_img_tag_add_loading_attr', $value, $image, $context );
if ( ! in_array( $value, array( 'lazy', 'eager' ), true ) ) {
return str_replace( '<img', '<img loading="' . esc_attr( $value ) . '"', $image );
* Takes input from [0, n] and returns it as [0, 1].
* Direct port of TinyColor's function, lightly simplified to maintain
* consistency with TinyColor.
* @link https://github.com/bgrins/TinyColor
* @param mixed $n Number of unknown type.
* @param int $max Upper value of the range to bound to.
* @return float Value in the range [0, 1].
function wp_tinycolor_bound01( $n, $max ) {
_deprecated_function( __FUNCTION__, '6.3.0' );
if ( 'string' === gettype( $n ) && str_contains( $n, '.' ) && 1 === (float) $n ) {
$n = min( $max, max( 0, (float) $n ) );
// Automatically convert percentage into number.
if ( 'string' === gettype( $n ) && str_contains( $n, '%' ) ) {
$n = (int) ( $n * $max ) / 100;
// Handle floating point rounding errors.
if ( ( abs( $n - $max ) < 0.000001 ) ) {
// Convert into [0, 1] range if it isn't already.
return ( $n % $max ) / (float) $max;
* Direct port of tinycolor's boundAlpha function to maintain consistency with
* @link https://github.com/bgrins/TinyColor
* @param mixed $n Number of unknown type.
* @return float Value in the range [0,1].
function _wp_tinycolor_bound_alpha( $n ) {
_deprecated_function( __FUNCTION__, '6.3.0' );
if ( is_numeric( $n ) ) {
if ( $n >= 0 && $n <= 1 ) {
* Rounds and converts values of an RGB object.
* Direct port of TinyColor's function, lightly simplified to maintain
* consistency with TinyColor.
* @link https://github.com/bgrins/TinyColor
* @param array $rgb_color RGB object.
* @return array Rounded and converted RGB object.
function wp_tinycolor_rgb_to_rgb( $rgb_color ) {
_deprecated_function( __FUNCTION__, '6.3.0' );
'r' => wp_tinycolor_bound01( $rgb_color['r'], 255 ) * 255,
'g' => wp_tinycolor_bound01( $rgb_color['g'], 255 ) * 255,
'b' => wp_tinycolor_bound01( $rgb_color['b'], 255 ) * 255,
* Helper function for hsl to rgb conversion.
* Direct port of TinyColor's function, lightly simplified to maintain
* consistency with TinyColor.
* @link https://github.com/bgrins/TinyColor
* @param float $p first component.
* @param float $q second component.
* @param float $t third component.
* @return float R, G, or B component.
function wp_tinycolor_hue_to_rgb( $p, $q, $t ) {
_deprecated_function( __FUNCTION__, '6.3.0' );
return $p + ( $q - $p ) * 6 * $t;
return $p + ( $q - $p ) * ( 2 / 3 - $t ) * 6;
* Converts an HSL object to an RGB object with converted and rounded values.
* Direct port of TinyColor's function, lightly simplified to maintain
* consistency with TinyColor.
* @link https://github.com/bgrins/TinyColor
* @param array $hsl_color HSL object.
* @return array Rounded and converted RGB object.
function wp_tinycolor_hsl_to_rgb( $hsl_color ) {
_deprecated_function( __FUNCTION__, '6.3.0' );
$h = wp_tinycolor_bound01( $hsl_color['h'], 360 );
$s = wp_tinycolor_bound01( $hsl_color['s'], 100 );
$l = wp_tinycolor_bound01( $hsl_color['l'], 100 );
$q = $l < 0.5 ? $l * ( 1 + $s ) : $l + $s - $l * $s;
$r = wp_tinycolor_hue_to_rgb( $p, $q, $h + 1 / 3 );
$g = wp_tinycolor_hue_to_rgb( $p, $q, $h );
$b = wp_tinycolor_hue_to_rgb( $p, $q, $h - 1 / 3 );
* Parses hex, hsl, and rgb CSS strings using the same regex as TinyColor v1.4.2
* used in the JavaScript. Only colors output from react-color are implemented.
* Direct port of TinyColor's function, lightly simplified to maintain
* consistency with TinyColor.
* @link https://github.com/bgrins/TinyColor
* @link https://github.com/casesandberg/react-color/
* @since 5.9.0 Added alpha processing.