Make WordPress Core

Ticket #9547: #9547-sw2.diff

File #9547-sw2.diff, 2.9 KB (added by simonwheatley, 13 years ago)

Add ordering to term template tags through $args array type param (removed error_log call)

  • wp-includes/category-template.php

     
    10541054 *
    10551055 * @since 2.5.0
    10561056 *
     1057 * @see wp_get_object_terms() for reference on the $args param
     1058 *
    10571059 * @param int $id Post ID.
    10581060 * @param string $taxonomy Taxonomy name.
     1061 * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms.
    10591062 * @return array|bool False on failure. Array of term objects on success.
    10601063 */
    1061 function get_the_terms( $id, $taxonomy ) {
     1064function get_the_terms( $id, $taxonomy, $args = array() ) {
    10621065        global $post;
    10631066
    10641067        $id = (int) $id;
     
    10701073                        $id = (int) $post->ID;
    10711074        }
    10721075
    1073         $terms = get_object_term_cache( $id, $taxonomy );
     1076        $cache_key = "{$taxonomy}_relationships_" . md5( serialize( $args ) );
     1077        var_dump( $cache_key );
     1078        $terms = wp_cache_get($id, $cache_key);
     1079
    10741080        if ( false === $terms ) {
    1075                 $terms = wp_get_object_terms( $id, $taxonomy );
    1076                 wp_cache_add($id, $terms, $taxonomy . '_relationships');
     1081                $terms = wp_get_object_terms( $id, $taxonomy, $args );
     1082                wp_cache_add($id, $terms, $cache_key);
    10771083        }
    10781084
    10791085        $terms = apply_filters( 'get_the_terms', $terms, $id, $taxonomy );
     
    10891095 *
    10901096 * @since 2.5.0
    10911097 *
     1098 * @see wp_get_object_terms() for reference on the $args param
     1099 *
    10921100 * @param int $id Post ID.
    10931101 * @param string $taxonomy Taxonomy name.
    10941102 * @param string $before Optional. Before list.
    10951103 * @param string $sep Optional. Separate items using this.
    10961104 * @param string $after Optional. After list.
     1105 * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms.
    10971106 * @return string
    10981107 */
    1099 function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {
    1100         $terms = get_the_terms( $id, $taxonomy );
     1108function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '', $args = array() ) {
     1109        $terms = get_the_terms( $id, $taxonomy, $args );
    11011110
    11021111        if ( is_wp_error( $terms ) )
    11031112                return $terms;
     
    11271136 * @param string $before Optional. Before list.
    11281137 * @param string $sep Optional. Separate items using this.
    11291138 * @param string $after Optional. After list.
     1139 * @param string $order Either 'ASC' or 'DESC', defaults to 'ASC'.
     1140 * @param string $orderby Either 'name' (default), 'slug', 'count', 'term_order', 'term_group' (as per wp_get_object_terms).
    11301141 * @return null|bool False on WordPress error. Returns null when displaying.
    11311142 */
    1132 function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
    1133         $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
     1143function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '', $order = null, $orderby = null ) {
     1144        $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after, $order, $orderby );
    11341145
    11351146        if ( is_wp_error( $term_list ) )
    11361147                return false;