Generate cache key.
Parameters
$args
arrayrequired- WP_Term_Query arguments.
$sql
stringrequired- SQL statement.
Source
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['cache_results'], $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. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.