diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index dadfad2e38..484d26ebbc 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -3003,11 +3003,7 @@ function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) { foreach ( $taxonomies as $taxonomy ) { if ( $clean_taxonomy ) { - wp_cache_delete('all_ids', $taxonomy); - wp_cache_delete('get', $taxonomy); - delete_option("{$taxonomy}_children"); - // Regenerate {$taxonomy}_children - _get_term_hierarchy($taxonomy); + clean_taxonomy_cache( $taxonomy ); } /** @@ -3026,6 +3022,31 @@ function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) { wp_cache_set( 'last_changed', microtime(), 'terms' ); } +/** + * Clean the caches for a taxonomy. + * + * @since 4.9.0 + * + * @param string $taxonomy Taxonomy slug. + */ +function clean_taxonomy_cache( $taxonomy ) { + wp_cache_delete( 'all_ids', $taxonomy ); + wp_cache_delete( 'get', $taxonomy ); + + // Regenerate cached hierarchy. + delete_option( "{$taxonomy}_children" ); + _get_term_hierarchy( $taxonomy ); + + /** + * Fires after a taxonomy's caches have been cleaned. + * + * @since 4.9.0 + * + * @param string $taxonomy Taxonomy slug. + */ + do_action( 'clean_taxonomy_cache', $taxonomy ); +} + /** * Retrieves the taxonomy relationship to the term object id. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 96de16a2a5..53969d5b73 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-40918'; +$wp_version = '4.9-alpha-40919'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.