deslash

The timeline below displays how wordpress function deslash has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.1

/**
 * Filters for content to remove unnecessary slashes.
 *
 * @since 1.5.0
 *
 * @param string $content The content to modify.
 * @return string The de-slashed content.
 */
function deslash($content)
{
    // Note: \\\ inside a regex denotes a single backslash.
    /*
     * Replace one or more backslashes followed by a single quote with
     * a single quote.
     */
    $content = preg_replace("/\\\\+'/", "'", $content);
    /*
     * Replace one or more backslashes followed by a double quote with
     * a double quote.
     */
    $content = preg_replace('/\\\\+"/', '"', $content);
    // Replace one or more backslashes with one backslash.
    $content = preg_replace('/\\\\+/', '\\', $content);
    return $content;
}

WordPress Version: 4.2

/**
 * Filters for content to remove unnecessary slashes.
 *
 * @since 1.5.0
 *
 * @param string $content The content to modify.
 * @return string The de-slashed content.
 */
function deslash($content)
{
    // Note: \\\ inside a regex denotes a single backslash.
    /*
     * Replace one or more backslashes followed by a single quote with
     * a single quote.
     */
    $content = preg_replace("/\\\\+'/", "'", $content);
    /*
     * Replace one or more backslashes followed by a double quote with
     * a double quote.
     */
    $content = preg_replace('/\\\\+"/', '"', $content);
    // Replace one or more backslashes with one backslash.
    $content = preg_replace("/\\\\+/", "\\", $content);
    return $content;
}

WordPress Version: 4.0

/**
 * {@internal Missing Short Description}}
 *
 * {@internal Missing Long Description}}
 *
 * @since 1.5.0
 *
 * @param string $content
 * @return string
 */
function deslash($content)
{
    // Note: \\\ inside a regex denotes a single backslash.
    /*
     * Replace one or more backslashes followed by a single quote with
     * a single quote.
     */
    $content = preg_replace("/\\\\+'/", "'", $content);
    /*
     * Replace one or more backslashes followed by a double quote with
     * a double quote.
     */
    $content = preg_replace('/\\\\+"/', '"', $content);
    // Replace one or more backslashes with one backslash.
    $content = preg_replace("/\\\\+/", "\\", $content);
    return $content;
}

WordPress Version: 3.7

/**
 * {@internal Missing Short Description}}
 *
 * {@internal Missing Long Description}}
 *
 * @since 1.5.0
 *
 * @param string $content
 * @return string
 */
function deslash($content)
{
    // Note: \\\ inside a regex denotes a single backslash.
    // Replace one or more backslashes followed by a single quote with
    // a single quote.
    $content = preg_replace("/\\\\+'/", "'", $content);
    // Replace one or more backslashes followed by a double quote with
    // a double quote.
    $content = preg_replace('/\\\\+"/', '"', $content);
    // Replace one or more backslashes with one backslash.
    $content = preg_replace("/\\\\+/", "\\", $content);
    return $content;
}