Make WordPress Core


Ignore:
Timestamp:
09/17/2009 02:03:57 PM (15 years ago)
Author:
ryan
Message:

Actions for taxonomy updates. Props Demitrious Kelly. fixes #10750

File:
1 edited

Legend:

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

    r11476 r11941  
    10791079        $tt_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
    10801080        $in_tt_ids = "'" . implode("', '", $tt_ids) . "'";
     1081        do_action( 'delete_term_relationships', $object_id, $tt_ids );
    10811082        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id) );
     1083        do_action( 'deleted_term_relationships', $object_id, $tt_ids );
    10821084        wp_update_term_count($tt_ids, $taxonomy);
    10831085    }
     
    11381140        $parent = $term_obj->parent;
    11391141
     1142        $edit_tt_ids = $wpdb->get_col( "SELECT `term_taxonomy_id` FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id );
     1143        do_action( 'edit_term_taxonomies', $edit_tt_ids );
    11401144        $wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) );
     1145        do_action( 'edited_term_taxonomies', $edit_tt_ids );
    11411146    }
    11421147
     
    11561161    }
    11571162
     1163    do_action( 'delete_term_taxonomy', $tt_id );
    11581164    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $tt_id ) );
     1165    do_action( 'deleted_term_taxonomy', $tt_id );
    11591166
    11601167    // Delete the term if no taxonomies use it.
     
    13781385            // The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
    13791386            $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
     1387            do_action( 'edit_terms', $alias->term_id );
    13801388            $wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) );
     1389            do_action( 'edited_terms', $alias->term_id );
    13811390        }
    13821391    }
     
    13971406    if ( empty($slug) ) {
    13981407        $slug = sanitize_title($slug, $term_id);
     1408        do_action( 'edit_terms', $term_id );
    13991409        $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
     1410        do_action( 'edited_terms', $term_id );
    14001411    }
    14011412
     
    14751486        if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) )
    14761487            continue;
     1488        do_action( 'add_term_relationship', $object_id, $tt_id );
    14771489        $wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $tt_id ) );
     1490        do_action( 'added_term_relationship', $object_id, $tt_id );
    14781491    }
    14791492
     
    14841497        if ( $delete_terms ) {
    14851498            $in_delete_terms = "'" . implode("', '", $delete_terms) . "'";
     1499            do_action( 'delete_term_relationships', $object_id, $delete_terms );
    14861500            $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_delete_terms)", $object_id) );
     1501            do_action( 'deleted_term_relationships', $object_id, $delete_terms );
    14871502            wp_update_term_count($delete_terms, $taxonomy);
    14881503        }
     
    16471662            // The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
    16481663            $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
     1664            do_action( 'edit_terms', $alias->term_id );
    16491665            $wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) );
     1666            do_action( 'edited_terms', $alias->term_id );
    16501667        }
    16511668    }
     
    16611678            return new WP_Error('duplicate_term_slug', sprintf(__('The slug “%s” is already in use by another term'), $slug));
    16621679    }
    1663 
     1680    do_action( 'edit_terms', $alias->term_id );
    16641681    $wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) );
    1665 
    16661682    if ( empty($slug) ) {
    16671683        $slug = sanitize_title($name, $term_id);
    16681684        $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
    16691685    }
     1686    do_action( 'edited_terms', $alias->term_id );
    16701687
    16711688    $tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id) );
    1672 
     1689    do_action( 'edit_term_taxonomy', $tt_id );
    16731690    $wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) );
    1674 
     1691    do_action( 'edited_term_taxonomy', $tt_id );
     1692   
    16751693    do_action("edit_term", $term_id, $tt_id);
    16761694    do_action("edit_$taxonomy", $term_id, $tt_id);
     
    17721790        foreach ( (array) $terms as $term) {
    17731791            $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) );
     1792            do_action( 'edit_term_taxonomy', $term );
    17741793            $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
     1794            do_action( 'edited_term_taxonomy', $term );
    17751795        }
    17761796
     
    21542174    foreach ( (array) $terms as $term ) {
    21552175        $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term ) );
     2176        do_action( 'edit_term_taxonomy', $term );
    21562177        $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
     2178        do_action( 'edited_term_taxonomy', $term );
    21572179    }
    21582180}
Note: See TracChangeset for help on using the changeset viewer.