Make WordPress Core

Ticket #9547: 9547.2.diff

File 9547.2.diff, 3.4 KB (added by wonderboymusic, 12 years ago)
  • wp-includes/category-template.php

    diff --git wp-includes/category-template.php wp-includes/category-template.php
    index 96a61cf..87ea722 100644
    function term_description( $term = 0, $taxonomy = 'post_tag' ) { 
    10531053 *
    10541054 * @since 2.5.0
    10551055 *
     1056 * @see wp_get_object_terms() for reference on the $args param
     1057 *
    10561058 * @param int|object $post Post ID or object.
    10571059 * @param string $taxonomy Taxonomy name.
     1060 * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms.
    10581061 * @return array|bool|WP_Error Array of term objects on success, false or WP_Error on failure.
    10591062 */
    1060 function get_the_terms( $post, $taxonomy ) {
     1063function get_the_terms( $post, $taxonomy, $args = array() ) {
    10611064        if ( ! $post = get_post( $post ) )
    10621065                return false;
    10631066
    1064         $terms = get_object_term_cache( $post->ID, $taxonomy );
     1067        $key = "{$post->ID}:$taxonomy:" . md5( serialize( $args ) );
     1068        $group = "{$taxonomy}_relationships";
     1069        $terms = wp_cache_get( $key, $group );
     1070
    10651071        if ( false === $terms ) {
    1066                 $terms = wp_get_object_terms( $post->ID, $taxonomy );
    1067                 wp_cache_add($post->ID, $terms, $taxonomy . '_relationships');
     1072                $terms = wp_get_object_terms( $post->ID, $taxonomy, $args );
     1073                wp_cache_add( $key, $terms, $group );
    10681074        }
    10691075
    10701076        $terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
    function get_the_terms( $post, $taxonomy ) { 
    10801086 *
    10811087 * @since 2.5.0
    10821088 *
     1089 * @see wp_get_object_terms() for reference on the $args param
     1090 *
    10831091 * @param int $id Post ID.
    10841092 * @param string $taxonomy Taxonomy name.
    10851093 * @param string $before Optional. Before list.
    10861094 * @param string $sep Optional. Separate items using this.
    10871095 * @param string $after Optional. After list.
     1096 * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms.
    10881097 * @return string|bool|WP_Error A list of terms on success, false or WP_Error on failure.
    10891098 */
    1090 function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {
    1091         $terms = get_the_terms( $id, $taxonomy );
     1099function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '', $args = array() ) {
     1100        $terms = get_the_terms( $id, $taxonomy, $args );
    10921101
    10931102        if ( is_wp_error( $terms ) )
    10941103                return $terms;
    function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' 
    11131122 *
    11141123 * @since 2.5.0
    11151124 *
     1125 * @see wp_get_object_terms() for reference on the $args param
     1126 *
    11161127 * @param int $id Post ID.
    11171128 * @param string $taxonomy Taxonomy name.
    11181129 * @param string $before Optional. Before list.
    11191130 * @param string $sep Optional. Separate items using this.
    11201131 * @param string $after Optional. After list.
     1132 * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms.
    11211133 * @return null|bool False on WordPress error. Returns null when displaying.
    11221134 */
    1123 function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
    1124         $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
     1135function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '', $args = array() ) {
     1136        $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after, $args );
    11251137
    11261138        if ( is_wp_error( $term_list ) )
    11271139                return false;
    11281140
    1129         echo apply_filters('the_terms', $term_list, $taxonomy, $before, $sep, $after);
     1141        echo apply_filters( 'the_terms', $term_list, $taxonomy, $before, $sep, $after );
    11301142}
    11311143
    11321144/**