wpdb::placeholder_escape
Generates and returns a placeholder escape string for use in queries returned by ::prepare().
Method of the class: wpdb{}
No Hooks.
Returns
String
. String to escape placeholders.
Usage
global $wpdb; $wpdb->placeholder_escape();
Changelog
Since 4.8.3 | Introduced. |
wpdb::placeholder_escape() wpdb::placeholder escape code WP 6.8.1
public function placeholder_escape() { static $placeholder; if ( ! $placeholder ) { // Old WP installs may not have AUTH_SALT defined. $salt = defined( 'AUTH_SALT' ) && AUTH_SALT ? AUTH_SALT : (string) rand(); $placeholder = '{' . hash_hmac( 'sha256', uniqid( $salt, true ), $salt ) . '}'; } /* * Add the filter to remove the placeholder escaper. Uses priority 0, so that anything * else attached to this filter will receive the query with the placeholder string removed. */ if ( false === has_filter( 'query', array( $this, 'remove_placeholder_escape' ) ) ) { add_filter( 'query', array( $this, 'remove_placeholder_escape' ), 0 ); } return $placeholder; }