handbook/references/internal-api/wp-cli-utils-esc-like.md
Pascal Birchler 264cb131bf
Fix handbook information architecture
- Organize files in folders according to the desired structure
- Use directory iterator to loop through all files and folders (makes generation more robust)
2025-06-25 15:38:39 +02: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.