like_escape

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

WordPress Version: 4.6

/**
 * Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described.
 *
 * @since 2.5.0
 * @deprecated 4.0.0 Use wpdb::esc_like()
 * @see wpdb::esc_like()
 *
 * @param string $text The text to be escaped.
 * @return string text, safe for inclusion in LIKE query.
 */
function like_escape($text)
{
    _deprecated_function(__FUNCTION__, '4.0.0', 'wpdb::esc_like()');
    return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
}

WordPress Version: 4.4

/**
 * Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described.
 *
 * @since 2.5.0
 * @deprecated 4.0.0 Use wpdb::esc_like()
 * @see wpdb::esc_like()
 *
 * @param string $text The text to be escaped.
 * @return string text, safe for inclusion in LIKE query.
 */
function like_escape($text)
{
    _deprecated_function(__FUNCTION__, '4.0', 'wpdb::esc_like()');
    return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
}

WordPress Version: 4.0

/**
 * Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described.
 *
 * @since 2.5.0
 * @deprecated 4.0.0
 * @deprecated Use wpdb::esc_like()
 *
 * @param string $text The text to be escaped.
 * @return string text, safe for inclusion in LIKE query.
 */
function like_escape($text)
{
    _deprecated_function(__FUNCTION__, '4.0', 'wpdb::esc_like()');
    return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
}

WordPress Version: 3.7

/**
 * Escapes text for SQL LIKE special characters % and _.
 *
 * @since 2.5.0
 *
 * @param string $text The text to be escaped.
 * @return string text, safe for inclusion in LIKE query.
 */
function like_escape($text)
{
    return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
}