bp_esc_like( string $text )

Escape special characters in a SQL LIKE clause.

Description

In WordPress 4.0, like_escape() was deprecated, due to incorrect documentation and improper sanitization leading to a history of misuse. To maintain compatibility with versions of WP before 4.0, we duplicate the logic of the replacement, wpdb::esc_like().

See also

Parameters

$text

(string) (Required) The raw text to be escaped.

Return

(string) Text in the form of a LIKE phrase. Not SQL safe. Run through wpdb::prepare() before use.

Source

File: bp-core/bp-core-functions.php

function bp_esc_like( $text ) {
	global $wpdb;

	if ( method_exists( $wpdb, 'esc_like' ) ) {
		return $wpdb->esc_like( $text );
	} else {
		return addcslashes( $text, '_%\\' );
	}
}

Changelog

Changelog
Version Description
BuddyPress 2.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.