Ticket #33720: 33720_add_ech_arg_wp_terms_checklist.diff
File 33720_add_ech_arg_wp_terms_checklist.diff, 3.4 KB (added by , 10 years ago) |
---|
-
wp-admin/includes/template.php
169 169 * @param array|string $args { 170 170 * Optional. Array or string of arguments for generating a terms checklist. Default empty array. 171 171 * 172 * @type int $descendants_and_self ID of the category to output along with its descendants. 173 * Default 0. 174 * @type array $selected_cats List of categories to mark as checked. Default false. 175 * @type array $popular_cats List of categories to receive the "popular-category" class. 176 * Default false. 177 * @type object $walker Walker object to use to build the output. 178 * Default is a Walker_Category_Checklist instance. 179 * @type string $taxonomy Taxonomy to generate the checklist for. Default 'category'. 180 * @type bool $checked_ontop Whether to move checked items out of the hierarchy and to 181 * the top of the list. Default true. 172 * @type int $descendants_and_self ID of the category to output along with its descendants. 173 * Default 0. 174 * @type array $selected_cats List of categories to mark as checked. Default false. 175 * @type array $popular_cats List of categories to receive the "popular-category" class. 176 * Default false. 177 * @type object $walker Walker object to use to build the output. 178 * Default is a Walker_Category_Checklist instance. 179 * @type string $taxonomy Taxonomy to generate the checklist for. Default 'category'. 180 * @type bool $checked_ontop Whether to move checked items out of the hierarchy and to 181 * the top of the list. Default true. 182 * @type bool|int $echo Whether to echo or return the generated markup. Accepts 0, 1, or their 183 * bool equivalents. Default 1. 182 184 * } 183 185 */ 184 186 function wp_terms_checklist( $post_id = 0, $args = array() ) { … … 188 190 'popular_cats' => false, 189 191 'walker' => null, 190 192 'taxonomy' => 'category', 191 'checked_ontop' => true 193 'checked_ontop' => true, 194 'echo' => 1 192 195 ); 193 196 194 197 /** … … 251 254 $categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) ); 252 255 } 253 256 257 $output = ''; 258 254 259 if ( $r['checked_ontop'] ) { 255 260 // 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) 256 261 $checked_categories = array(); … … 264 269 } 265 270 266 271 // Put checked cats on top 267 echocall_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) );272 $output .= call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) ); 268 273 } 269 274 // Then the rest of them 270 echo call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) ); 275 $output .= call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) ); 276 277 if( $r['echo'] ){ 278 echo $output; 279 } 280 281 return $output; 271 282 } 272 283 273 284 /**