Make WordPress Core


Ignore:
Timestamp:
10/18/2020 06:55:16 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Formatting: Deprecate wp_slash_strings_only() in favor of wp_slash().

The reason for introducing wp_slash_strings_only() in [46454] was to keep non-string values untouched.

Later, wp_slash() itself was updated in [48433] to prevent changing non-string values.

To avoid confusion, wp_slash_strings_only() is now deprecated.

Props ayeshrajans, ocean90.
Fixes #50635.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r49108 r49188  
    55475547
    55485548/**
    5549  * Adds slashes to only string values in an array of values.
    5550  *
    5551  * This should be used when preparing data for core APIs that expect slashed data.
    5552  * This should not be used to escape data going directly into an SQL query.
    5553  *
    5554  * @since 5.3.0
    5555  *
    5556  * @param mixed $value Scalar or array of scalars.
    5557  * @return mixed Slashes $value
    5558  */
    5559 function wp_slash_strings_only( $value ) {
    5560     return map_deep( $value, 'addslashes_strings_only' );
    5561 }
    5562 
    5563 /**
    5564  * Adds slashes only if the provided value is a string.
    5565  *
    5566  * @since 5.3.0
    5567  *
    5568  * @param mixed $value
    5569  * @return mixed
    5570  */
    5571 function addslashes_strings_only( $value ) {
    5572     return is_string( $value ) ? addslashes( $value ) : $value;
    5573 }
    5574 
    5575 /**
    55765549 * Extract and return the first URL from passed content.
    55775550 *
Note: See TracChangeset for help on using the changeset viewer.