Ticket #9547: #9547-sw1.diff
File #9547-sw1.diff, 2.9 KB (added by , 13 years ago) |
---|
-
wp-includes/category-template.php
1056 1056 * 1057 1057 * @param int $id Post ID. 1058 1058 * @param string $taxonomy Taxonomy name. 1059 * @param string $order Either 'ASC' or 'DESC', defaults to 'ASC'. 1060 * @param string $orderby Either 'name' (default), 'slug', 'count', 'term_order', 'term_group' (as per wp_get_object_terms). 1059 1061 * @return array|bool False on failure. Array of term objects on success. 1060 1062 */ 1061 function get_the_terms( $id, $taxonomy ) {1063 function get_the_terms( $id, $taxonomy, $order = null, $orderby = null ) { 1062 1064 global $post; 1063 1065 1064 1066 $id = (int) $id; … … 1070 1072 $id = (int) $post->ID; 1071 1073 } 1072 1074 1073 $terms = get_object_term_cache( $id, $taxonomy ); 1075 $cache_key = "{$taxonomy}_relationships_order_{$orderby}_{$order}"; 1076 $terms = wp_cache_get($id, $cache_key); 1077 1074 1078 if ( false === $terms ) { 1075 $terms = wp_get_object_terms( $id, $taxonomy );1076 wp_cache_add($id, $terms, $ taxonomy . '_relationships');1079 $terms = wp_get_object_terms( $id, $taxonomy, array( 'order' => $order, 'orderby' => $orderby ) ); 1080 wp_cache_add($id, $terms, $cache_key); 1077 1081 } 1078 1082 1079 1083 $terms = apply_filters( 'get_the_terms', $terms, $id, $taxonomy ); … … 1094 1098 * @param string $before Optional. Before list. 1095 1099 * @param string $sep Optional. Separate items using this. 1096 1100 * @param string $after Optional. After list. 1101 * @param string $order Either 'ASC' or 'DESC', defaults to 'ASC'. 1102 * @param string $orderby Either 'name' (default), 'slug', 'count', 'term_order', 'term_group' (as per wp_get_object_terms). 1097 1103 * @return string 1098 1104 */ 1099 function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {1100 $terms = get_the_terms( $id, $taxonomy );1105 function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '', $order = null, $orderby = null ) { 1106 $terms = get_the_terms( $id, $taxonomy, $order, $orderby ); 1101 1107 1102 1108 if ( is_wp_error( $terms ) ) 1103 1109 return $terms; … … 1127 1133 * @param string $before Optional. Before list. 1128 1134 * @param string $sep Optional. Separate items using this. 1129 1135 * @param string $after Optional. After list. 1136 * @param string $order Either 'ASC' or 'DESC', defaults to 'ASC'. 1137 * @param string $orderby Either 'name' (default), 'slug', 'count', 'term_order', 'term_group' (as per wp_get_object_terms). 1130 1138 * @return null|bool False on WordPress error. Returns null when displaying. 1131 1139 */ 1132 function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {1133 $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );1140 function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '', $order = null, $orderby = null ) { 1141 $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after, $order, $orderby ); 1134 1142 1135 1143 if ( is_wp_error( $term_list ) ) 1136 1144 return false;