bp_esc_like( string $text )

Escape special characters in a SQL LIKE clause.


Description 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 See also


Top ↑

Parameters Parameters

$text

(Required) The raw text to be escaped.


Top ↑

Return Return

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


Top ↑

Source 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, '_%\\' );
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.