handbook/internal-api/wp-cli-utils-esc-like.md
2021-05-14 13:24:24 +01:00

2.3 KiB

WP_CLI\Utils\esc_like()

First half of escaping for LIKE special characters % and _ before preparing for MySQL.


Usage

WP_CLI\Utils\esc_like( $text )
$text (string) The raw text to be escaped. The input typed by the user should have no
@return (string) in the form of a LIKE phrase. The output is not SQL safe. Call $wpdb::prepare()

Notes

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. extra or deleted slashes. or real_escape next.

Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request.