WP_Term_Query::generate_cache_key( array $args, string $sql )
Generate cache key.
Parameters
- $args
-
(Required) WP_Term_Query arguments.
- $sql
-
(Required) SQL statement.
Return
(string) Cache key.
Source
File: wp-includes/class-wp-term-query.php
protected function generate_cache_key( array $args, $sql ) {
global $wpdb;
// $args can be anything. Only use the args defined in defaults to compute the key.
$cache_args = wp_array_slice_assoc( $args, array_keys( $this->query_var_defaults ) );
unset( $cache_args['update_term_meta_cache'] );
if ( 'count' !== $args['fields'] && 'all_with_object_id' !== $args['fields'] ) {
$cache_args['fields'] = 'all';
}
$taxonomies = (array) $args['taxonomy'];
// Replace wpdb placeholder in the SQL statement used by the cache key.
$sql = $wpdb->remove_placeholder_escape( $sql );
$key = md5( serialize( $cache_args ) . serialize( $taxonomies ) . $sql );
$last_changed = wp_cache_get_last_changed( 'terms' );
return "get_terms:$key:$last_changed";
}
Changelog
Version | Description |
---|---|
6.2.0 | Introduced. |