Ticket #9547: #9547-sw2.2.diff
File #9547-sw2.2.diff, 2.7 KB (added by , 13 years ago) |
---|
-
wp-includes/category-template.php
1054 1054 * 1055 1055 * @since 2.5.0 1056 1056 * 1057 * @see wp_get_object_terms() for reference on the $args param 1058 * 1057 1059 * @param int $id Post ID. 1058 1060 * @param string $taxonomy Taxonomy name. 1061 * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms. 1059 1062 * @return array|bool False on failure. Array of term objects on success. 1060 1063 */ 1061 function get_the_terms( $id, $taxonomy ) {1064 function get_the_terms( $id, $taxonomy, $args = array() ) { 1062 1065 global $post; 1063 1066 1064 1067 $id = (int) $id; … … 1070 1073 $id = (int) $post->ID; 1071 1074 } 1072 1075 1073 $terms = get_object_term_cache( $id, $taxonomy ); 1076 $cache_key = "{$taxonomy}_relationships_" . md5( serialize( $args ) ); 1077 $terms = wp_cache_get($id, $cache_key); 1078 1074 1079 if ( false === $terms ) { 1075 $terms = wp_get_object_terms( $id, $taxonomy );1076 wp_cache_add($id, $terms, $ taxonomy . '_relationships');1080 $terms = wp_get_object_terms( $id, $taxonomy, $args ); 1081 wp_cache_add($id, $terms, $cache_key); 1077 1082 } 1078 1083 1079 1084 $terms = apply_filters( 'get_the_terms', $terms, $id, $taxonomy ); … … 1089 1094 * 1090 1095 * @since 2.5.0 1091 1096 * 1097 * @see wp_get_object_terms() for reference on the $args param 1098 * 1092 1099 * @param int $id Post ID. 1093 1100 * @param string $taxonomy Taxonomy name. 1094 1101 * @param string $before Optional. Before list. 1095 1102 * @param string $sep Optional. Separate items using this. 1096 1103 * @param string $after Optional. After list. 1104 * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms. 1097 1105 * @return string 1098 1106 */ 1099 function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {1100 $terms = get_the_terms( $id, $taxonomy );1107 function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '', $args = array() ) { 1108 $terms = get_the_terms( $id, $taxonomy, $args ); 1101 1109 1102 1110 if ( is_wp_error( $terms ) ) 1103 1111 return $terms; … … 1127 1135 * @param string $before Optional. Before list. 1128 1136 * @param string $sep Optional. Separate items using this. 1129 1137 * @param string $after Optional. After list. 1138 * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms. 1130 1139 * @return null|bool False on WordPress error. Returns null when displaying. 1131 1140 */ 1132 function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {1133 $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );1141 function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '', $args = array() ) { 1142 $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after, $args ); 1134 1143 1135 1144 if ( is_wp_error( $term_list ) ) 1136 1145 return false;