Make WordPress Core

Ticket #18968: 18968.diff

File 18968.diff, 2.7 KB (added by wonderboymusic, 12 years ago)
  • src/wp-admin/includes/taxonomy.php

     
    234234        if ( !$post_id )
    235235                return false;
    236236
    237         $tags = wp_get_post_terms($post_id, $taxonomy, array());
     237        $terms = get_object_term_cache( $post_id, $taxonomy );
     238        if ( false === $terms ) {
     239                $terms = wp_get_object_terms( $post_id, $taxonomy );
     240                wp_cache_add( $post_id, $terms, $taxonomy . '_relationships' );
     241        }
    238242
    239         if ( !$tags ) {
     243        if ( ! $terms ) {
    240244                return false;
    241245        }
    242         if ( is_wp_error($tags) ) {
    243                 return $tags;
     246        if ( is_wp_error( $terms ) ) {
     247                return $terms;
    244248        }
    245         $tag_names = array();
    246         foreach ( $tags as $tag ) {
    247                 $tag_names[] = $tag->name;
     249        $term_names = array();
     250        foreach ( $terms as $term ) {
     251                $term_names[] = $term->name;
    248252        }
    249253
    250         $tags_to_edit = esc_attr( join( ',', $tag_names ) );
     254        $terms_to_edit = esc_attr( join( ',', $term_names ) );
    251255
    252256        /**
    253257         * Filter the comma-separated list of terms available to edit.
     
    256260         *
    257261         * @see get_terms_to_edit()
    258262         *
    259          * @param array  $tags_to_edit An array of terms.
     263         * @param array  $terms_to_edit An array of terms.
    260264         * @param string $taxonomy     The taxonomy for which to retrieve terms. Default 'post_tag'.
    261265         */
    262         $tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy );
     266        $terms_to_edit = apply_filters( 'terms_to_edit', $terms_to_edit, $taxonomy );
    263267
    264         return $tags_to_edit;
     268        return $terms_to_edit;
    265269}
    266270
    267271/**
  • src/wp-admin/includes/template.php

     
    364364                $taxonomy = get_taxonomy( $taxonomy_name );
    365365
    366366                if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
    367                                 echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">'
    368                                         . implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array( 'fields' => 'ids' ) ) ) . '</div>';
     367
     368                        $terms = get_object_term_cache( $post->ID, $taxonomy_name );
     369                        if ( false === $terms ) {
     370                                $terms = wp_get_object_terms( $post->ID, $taxonomy_name );
     371                                wp_cache_add( $post->ID, $terms, $taxonomy_name . '_relationships' );
     372                        }
     373                        $term_ids = empty( $terms ) ? array() : wp_list_pluck( $terms, 'term_id' );
     374
     375                        echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">' . implode( ',', $term_ids ) . '</div>';
     376
    369377                } elseif ( $taxonomy->show_ui ) {
     378
    370379                        echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
    371380                                . esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>';
     381
    372382                }
    373383        }
    374384