In `wp_delete_term()`, the `$deleted_term` object passed to filters should be generated before term relationships are deleted.

This allows the `count` property to reflect the pre-delete state of affairs,
rather than always being 0.

Props nicholas_io.
Fixes #33485.
Built from https://develop.svn.wordpress.org/trunk@33711


git-svn-id: http://core.svn.wordpress.org/trunk@33678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2015-08-22 19:43:26 +00:00
parent 6ab7493b27
commit dc0e7671b0
2 changed files with 4 additions and 4 deletions

View File

@ -2551,6 +2551,9 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) {
do_action( 'edited_term_taxonomies', $edit_tt_ids );
}
// Get the term before deleting it or its term relationships so we can pass to actions below.
$deleted_term = get_term( $term, $taxonomy );
$objects = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );
foreach ( (array) $objects as $object ) {
@ -2571,9 +2574,6 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) {
foreach ( $tax_object->object_type as $object_type )
clean_object_term_cache( $objects, $object_type );
// Get the object before deletion so we can pass to actions below
$deleted_term = get_term( $term, $taxonomy );
/**
* Fires immediately before a term taxonomy ID is deleted.
*

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-33710';
$wp_version = '4.4-alpha-33711';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.