From aed5679ace1bf8def4393b40275094e52984a37a Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sun, 16 Sep 2007 02:36:23 +0000 Subject: [PATCH] Don't lose tags when saving a post with attachments. Props filosofo. fixes #4532 git-svn-id: https://develop.svn.wordpress.org/trunk@6121 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 4 +++- wp-includes/taxonomy.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 076e6133aa..080eb6bf22 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -581,12 +581,14 @@ function wp_get_single_post($postid = 0, $mode = OBJECT) { $post = get_post($postid, $mode); - // Set categories + // Set categories and tags if($mode == OBJECT) { $post->post_category = wp_get_post_categories($postid); + $post->tags_input = wp_get_post_tags($postid, array('fields' => 'names')); } else { $post['post_category'] = wp_get_post_categories($postid); + $post['tags_input'] = wp_get_post_tags($postid, array('fields' => 'names')); } return $post; diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index a739746725..2d4ac9317f 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -868,6 +868,8 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) { $select_this = 't.*, tt.*'; else if ( 'ids' == $fields ) $select_this = 't.term_id'; + else if ( 'names' == $fields ) + $select_this = 't.name'; else if ( 'all_with_object_id' == $fields ) $select_this = 't.*, tt.*, tr.object_id'; @@ -876,7 +878,7 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) { if ( 'all' == $fields || 'all_with_object_id' == $fields ) { $terms = $wpdb->get_results($query); update_term_cache($terms); - } else if ( 'ids' == $fields ) { + } else if ( 'ids' == $fields || 'names' == $fields ) { $terms = $wpdb->get_col($query); } else if ( 'tt_ids' == $fields ) { $terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) ORDER BY tr.term_taxonomy_id $order");