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/deprecated.php

    r48798 r49188  
    41024102    return remove_allowed_options( $del_options, $options );
    41034103}
     4104
     4105/**
     4106 * Adds slashes to only string values in an array of values.
     4107 *
     4108 * This should be used when preparing data for core APIs that expect slashed data.
     4109 * This should not be used to escape data going directly into an SQL query.
     4110 *
     4111 * @since 5.3.0
     4112 * @deprecated 5.6.0 Use wp_slash()
     4113 *
     4114 * @see wp_slash()
     4115 *
     4116 * @param mixed $value Scalar or array of scalars.
     4117 * @return mixed Slashes $value
     4118 */
     4119function wp_slash_strings_only( $value ) {
     4120    return map_deep( $value, 'addslashes_strings_only' );
     4121}
     4122
     4123/**
     4124 * Adds slashes only if the provided value is a string.
     4125 *
     4126 * @since 5.3.0
     4127 * @deprecated 5.6.0
     4128 *
     4129 * @see wp_slash()
     4130 *
     4131 * @param mixed $value
     4132 * @return mixed
     4133 */
     4134function addslashes_strings_only( $value ) {
     4135    return is_string( $value ) ? addslashes( $value ) : $value;
     4136}
Note: See TracChangeset for help on using the changeset viewer.