Changeset 28410 for trunk/src/wp-admin/includes/template.php
- Timestamp:
- 05/15/2014 03:08:46 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/template.php
r28409 r28410 137 137 * @param array $args 138 138 */ 139 function wp_terms_checklist( $post_id = 0, $args = array()) {139 function wp_terms_checklist( $post_id = 0, $args = array() ) { 140 140 $defaults = array( 141 141 'descendants_and_self' => 0, … … 157 157 * @param int $post_id The post ID. 158 158 */ 159 $ args = apply_filters( 'wp_terms_checklist_args', $args, $post_id );160 161 extract( wp_parse_args($args, $defaults), EXTR_SKIP);162 163 if ( empty( $walker) || !is_a($walker, 'Walker') )159 $params = apply_filters( 'wp_terms_checklist_args', $args, $post_id ); 160 161 $r = wp_parse_args( $params, $defaults ); 162 163 if ( empty( $r['walker'] ) || ! is_a( $r['walker'], 'Walker' ) ) { 164 164 $walker = new Walker_Category_Checklist; 165 166 $descendants_and_self = (int) $descendants_and_self; 167 168 $args = array('taxonomy' => $taxonomy); 169 170 $tax = get_taxonomy($taxonomy); 171 $args['disabled'] = !current_user_can($tax->cap->assign_terms); 172 173 if ( is_array( $selected_cats ) ) 174 $args['selected_cats'] = $selected_cats; 175 elseif ( $post_id ) 176 $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); 177 else 165 } else { 166 $walker = $r['walker']; 167 } 168 169 $taxonomy = $r['taxonomy']; 170 $descendants_and_self = (int) $r['descendants_and_self']; 171 172 $args = array( 'taxonomy' => $taxonomy ); 173 174 $tax = get_taxonomy( $taxonomy ); 175 $args['disabled'] = ! current_user_can( $tax->cap->assign_terms ); 176 177 if ( is_array( $r['selected_cats'] ) ) { 178 $args['selected_cats'] = $r['selected_cats']; 179 } elseif ( $post_id ) { 180 $args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) ); 181 } else { 178 182 $args['selected_cats'] = array(); 179 180 if ( is_array( $popular_cats ) ) 181 $args['popular_cats'] = $popular_cats; 182 else 183 $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); 184 183 } 184 if ( is_array( $r['popular_cats'] ) ) { 185 $args['popular_cats'] = $r['popular_cats']; 186 } else { 187 $args['popular_cats'] = get_terms( $taxonomy, array( 188 'fields' => 'ids', 189 'orderby' => 'count', 190 'order' => 'DESC', 191 'number' => 10, 192 'hierarchical' => false 193 ) ); 194 } 185 195 if ( $descendants_and_self ) { 186 $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) ); 196 $categories = (array) get_terms( $taxonomy, array( 197 'child_of' => $descendants_and_self, 198 'hierarchical' => 0, 199 'hide_empty' => 0 200 ) ); 187 201 $self = get_term( $descendants_and_self, $taxonomy ); 188 202 array_unshift( $categories, $self ); 189 203 } else { 190 $categories = (array) get_terms( $taxonomy, array('get' => 'all'));191 } 192 193 if ( $ checked_ontop) {204 $categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) ); 205 } 206 207 if ( $r['checked_ontop'] ) { 194 208 // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) 195 209 $checked_categories = array(); … … 204 218 205 219 // Put checked cats on top 206 echo call_user_func_array( array(&$walker, 'walk'), array($checked_categories, 0, $args));220 echo call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) ); 207 221 } 208 222 // Then the rest of them 209 echo call_user_func_array( array(&$walker, 'walk'), array($categories, 0, $args));223 echo call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) ); 210 224 } 211 225
Note: See TracChangeset
for help on using the changeset viewer.