WordPress.org

Make WordPress Core

Changeset 40919


Ignore:
Timestamp:
06/21/2017 04:03:22 AM (2 years ago)
Author:
boonebgorges
Message:

Introduce clean_taxonomy_cache() function.

Previously, taxonomy-wide caches were cleaned only inside of
clean_term_cache(). This made it hard to clean taxonmy caches
in isolation from specific taxonomy terms.

Props spacedmonkey.
See #37189.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r40917 r40919  
    30043004    foreach ( $taxonomies as $taxonomy ) {
    30053005        if ( $clean_taxonomy ) {
    3006             wp_cache_delete('all_ids', $taxonomy);
    3007             wp_cache_delete('get', $taxonomy);
    3008             delete_option("{$taxonomy}_children");
    3009             // Regenerate {$taxonomy}_children
    3010             _get_term_hierarchy($taxonomy);
     3006            clean_taxonomy_cache( $taxonomy );
    30113007        }
    30123008
     
    30253021
    30263022    wp_cache_set( 'last_changed', microtime(), 'terms' );
     3023}
     3024
     3025/**
     3026 * Clean the caches for a taxonomy.
     3027 *
     3028 * @since 4.9.0
     3029 *
     3030 * @param string $taxonomy Taxonomy slug.
     3031 */
     3032function clean_taxonomy_cache( $taxonomy ) {
     3033    wp_cache_delete( 'all_ids', $taxonomy );
     3034    wp_cache_delete( 'get', $taxonomy );
     3035
     3036    // Regenerate cached hierarchy.
     3037    delete_option( "{$taxonomy}_children" );
     3038    _get_term_hierarchy( $taxonomy );
     3039
     3040    /**
     3041     * Fires after a taxonomy's caches have been cleaned.
     3042     *
     3043     * @since 4.9.0
     3044     *
     3045     * @param string $taxonomy Taxonomy slug.
     3046     */
     3047    do_action( 'clean_taxonomy_cache', $taxonomy );
    30273048}
    30283049
Note: See TracChangeset for help on using the changeset viewer.