Better variable naming. See #7358.

git-svn-id: http://svn.automattic.com/wordpress/trunk@9349 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2008-10-25 22:56:02 +00:00
parent e393417401
commit 1f079aa071
2 changed files with 17 additions and 17 deletions

View File

@ -1593,8 +1593,8 @@ function wp_publish_post($post_id) {
// Update counts for the post's terms. // Update counts for the post's terms.
foreach ( (array) get_object_taxonomies('post') as $taxonomy ) { foreach ( (array) get_object_taxonomies('post') as $taxonomy ) {
$terms = wp_get_object_terms($post_id, $taxonomy, 'fields=tt_ids'); $tt_ids = wp_get_object_terms($post_id, $taxonomy, 'fields=tt_ids');
wp_update_term_count($terms, $taxonomy); wp_update_term_count($tt_ids, $taxonomy);
} }
do_action('edit_post', $post_id, $post); do_action('edit_post', $post_id, $post);

View File

@ -970,10 +970,10 @@ function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
$taxonomies = array($taxonomies); $taxonomies = array($taxonomies);
foreach ( (array) $taxonomies as $taxonomy ) { foreach ( (array) $taxonomies as $taxonomy ) {
$terms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids'); $tt_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
$in_terms = "'" . implode("', '", $terms) . "'"; $in_tt_ids = "'" . implode("', '", $tt_ids) . "'";
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_terms)", $object_id) ); $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id) );
wp_update_term_count($terms, $taxonomy); wp_update_term_count($tt_ids, $taxonomy);
} }
} }
@ -1332,7 +1332,7 @@ function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) {
$terms = array($terms); $terms = array($terms);
if ( ! $append ) if ( ! $append )
$old_terms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids'); $old_tt_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
$tt_ids = array(); $tt_ids = array();
$term_ids = array(); $term_ids = array();
@ -1341,23 +1341,23 @@ function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) {
if ( !strlen(trim($term)) ) if ( !strlen(trim($term)) )
continue; continue;
if ( !$id = is_term($term, $taxonomy) ) if ( !$term_info = is_term($term, $taxonomy) )
$id = wp_insert_term($term, $taxonomy); $term_info = wp_insert_term($term, $taxonomy);
if ( is_wp_error($id) ) if ( is_wp_error($term_info) )
return $id; return $term_info;
$term_ids[] = $id['term_id']; $term_ids[] = $term_info['term_id'];
$id = $id['term_taxonomy_id']; $tt_id = $term_info['term_taxonomy_id'];
$tt_ids[] = $id; $tt_ids[] = $tt_id;
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, $id ) ) ) 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 ) ) )
continue; continue;
$wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $id ) ); $wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $tt_id ) );
} }
wp_update_term_count($tt_ids, $taxonomy); wp_update_term_count($tt_ids, $taxonomy);
if ( ! $append ) { if ( ! $append ) {
$delete_terms = array_diff($old_terms, $tt_ids); $delete_terms = array_diff($old_tt_ids, $tt_ids);
if ( $delete_terms ) { if ( $delete_terms ) {
$in_delete_terms = "'" . implode("', '", $delete_terms) . "'"; $in_delete_terms = "'" . implode("', '", $delete_terms) . "'";
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_delete_terms)", $object_id) ); $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_delete_terms)", $object_id) );