WP_CLI\Utils
esc_like()
First half of escaping for LIKE special characters % and _ before preparing for MySQL.
Use this only before wpdb::prepare() or esc_sql(). Reversing the order is very bad for security.
Copied from core "wp-includes/wp-db.php". Avoids dependency on WP 4.4 wpdb.
Хуков нет.
Возвращает
Строку. Text in the form of a LIKE phrase. The output is not SQL safe. Call $wpdb::prepare() or real_escape next.
Использование
esc_like( $text );
- $text(строка) (обязательный)
- The raw text to be escaped. The input typed by the user should have no extra or deleted slashes.
Код esc_like() esc like WP-CLI 2.13.0-alpha
function esc_like( $text ) {
global $wpdb;
// Check if the esc_like() method exists on the global $wpdb object.
// We need to do this because to ensure compatibilty layers like the
// SQLite integration plugin still work.
if ( null !== $wpdb && method_exists( $wpdb, 'esc_like' ) ) {
return $wpdb->esc_like( $text );
}
return addcslashes( $text, '_%\\' );
}