Ticket #11838: 11838.diff
File 11838.diff, 14.0 KB (added by , 14 years ago) |
---|
-
wp-admin/categories.php
11 11 12 12 $title = __('Categories'); 13 13 14 wp_reset_vars( array('action' ) );14 wp_reset_vars( array('action', 'taxonomy', 'post_type') ); 15 15 16 if ( empty($taxonomy) ) 17 $taxonomy = 'category'; 18 19 if ( !is_taxonomy($taxonomy) ) 20 wp_die(__('Invalid taxonomy')); 21 22 if ( empty($post_type) || !in_array( $post_type, get_post_types( array('_show' => true) ) ) ) 23 $post_type = 'post'; 24 25 if ( 'post' != $post_type ) { 26 $parent_file = "edit.php?post_type=$post_type"; 27 $submenu_file = "categories.php?taxonomy=$taxonomy&post_type=$post_type"; 28 } else { 29 $parent_file = 'edit.php'; 30 $submenu_file = "categories.php?taxonomy=$taxonomy"; 31 } 32 33 16 34 if ( isset( $_GET['action'] ) && isset($_GET['delete']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) ) 17 35 $action = 'bulk-delete'; 18 36 … … 135 153 <div class="wrap nosubsub"> 136 154 <?php screen_icon(); ?> 137 155 <h2><?php echo esc_html( $title ); 138 if ( isset($_GET['s']) && $_GET['s'])156 if ( !empty($_GET['s']) ) 139 157 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_GET['s']) ) ); ?> 140 158 </h2> 141 159 … … 146 164 endif; ?> 147 165 148 166 <form class="search-form topmargin" action="" method="get"> 167 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> 168 <input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> 149 169 <p class="search-box"> 150 170 <label class="screen-reader-text" for="category-search-input"><?php _e('Search Categories'); ?>:</label> 151 171 <input type="text" id="category-search-input" name="s" value="<?php _admin_search_query(); ?>" /> … … 159 179 <div id="col-right"> 160 180 <div class="col-wrap"> 161 181 <form id="posts-filter" action="" method="get"> 182 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> 183 <input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> 162 184 <div class="tablenav"> 163 185 164 186 <?php … … 172 194 $cats_per_page = apply_filters( 'edit_categories_per_page', $cats_per_page ); 173 195 174 196 if ( !empty($_GET['s']) ) 175 $num_cats = count(get_categories(array(' hide_empty' => 0, 'search' => $_GET['s'])));197 $num_cats = count(get_categories(array('taxonomy' => $taxonomy, 'hide_empty' => 0, 'search' => $_GET['s']))); 176 198 else 177 $num_cats = wp_count_terms( 'category');199 $num_cats = wp_count_terms($taxonomy); 178 200 179 201 $page_links = paginate_links( array( 180 202 'base' => add_query_arg( 'pagenum', '%#%' ), … … 218 240 219 241 <tbody id="the-list" class="list:cat"> 220 242 <?php 221 cat_rows(0, 0, 0, $pagenum, $cats_per_page );243 cat_rows(0, 0, 0, $pagenum, $cats_per_page, $taxonomy); 222 244 ?> 223 245 </tbody> 224 246 </table> … … 244 266 </form> 245 267 246 268 <div class="form-wrap"> 247 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), apply_filters('the_category', get_cat_name(get_option('default_category')))) ?></p> 269 <?php if ( get_option('default_' . $taxonomy) ) : ?> 270 <p><?php printf(__('<strong>Note:</strong><br />Deleting a %1$s does not delete the objects in that %1$s. Instead, objects that were only assigned to the deleted %1$s are set to the %1$s <strong>%2$s</strong>.'), $tax->label, apply_filters('the_category', get_cat_name(get_option('default_' . $taxonomy)))) ?></p> 271 <?php endif; ?> 272 <?php if ( 'category' == $taxonomy ) : ?> 248 273 <p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), 'admin.php?import=wp-cat2tag') ?></p> 274 <?php endif; ?> 249 275 </div> 250 276 251 277 </div> … … 261 287 <h3><?php _e('Add Category'); ?></h3> 262 288 <div id="ajax-response"></div> 263 289 <form name="addcat" id="addcat" method="post" action="categories.php" class="add:the-list: validate"> 290 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> 291 <input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> 264 292 <input type="hidden" name="action" value="addcat" /> 265 293 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-category'); ?> 266 294 … … 278 306 279 307 <div class="form-field"> 280 308 <label for="category_parent"><?php _e('Category Parent') ?></label> 281 <?php wp_dropdown_categories(array('hide_empty' => 0, ' name' => 'category_parent', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None'))); ?>309 <?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'taxonomy' => $taxonomy, 'name' => 'category_parent', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None'))); ?> 282 310 <p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p> 283 311 </div> 284 312 -
wp-admin/includes/taxonomy.php
108 108 * @return unknown 109 109 */ 110 110 function wp_insert_category($catarr, $wp_error = false) { 111 $cat_defaults = array('cat_ID' => 0, ' cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '');111 $cat_defaults = array('cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => ''); 112 112 $catarr = wp_parse_args($catarr, $cat_defaults); 113 113 extract($catarr, EXTR_SKIP); 114 114 … … 142 142 $args = compact('name', 'slug', 'parent', 'description'); 143 143 144 144 if ( $update ) 145 $cat_ID = wp_update_term($cat_ID, 'category', $args);145 $cat_ID = wp_update_term($cat_ID, $taxonomy, $args); 146 146 else 147 $cat_ID = wp_insert_term($cat_name, 'category', $args);147 $cat_ID = wp_insert_term($cat_name, $taxonomy, $args); 148 148 149 149 if ( is_wp_error($cat_ID) ) { 150 150 if ( $wp_error ) -
wp-admin/includes/template.php
20 20 * @param unknown_type $page 21 21 * @param unknown_type $per_page 22 22 */ 23 function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) {23 function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20, $taxonomy = 'category' ) { 24 24 25 25 $count = 0; 26 26 27 27 if ( empty($categories) ) { 28 28 29 $args = array('hide_empty' => 0 );29 $args = array('hide_empty' => 0, 'taxonomy' => $taxonomy); 30 30 if ( !empty($_GET['s']) ) 31 31 $args['search'] = $_GET['s']; 32 32 … … 36 36 return false; 37 37 } 38 38 39 $children = _get_term_hierarchy( 'category');39 $children = _get_term_hierarchy($taxonomy); 40 40 41 41 _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count ); 42 42 … … 59 59 60 60 $start = ($page - 1) * $per_page; 61 61 $end = $start + $per_page; 62 ob_start();63 62 63 $output = ''; 64 64 foreach ( $categories as $key => $category ) { 65 65 if ( $count >= $end ) 66 66 break; … … 83 83 84 84 $num_parents = count($my_parents); 85 85 while( $my_parent = array_pop($my_parents) ) { 86 echo"\t" . _cat_row( $my_parent, $level - $num_parents );86 $output .= "\t" . _cat_row( $my_parent, $level - $num_parents ); 87 87 $num_parents--; 88 88 } 89 89 } 90 90 91 91 if ( $count >= $start ) 92 echo"\t" . _cat_row( $category, $level );92 $output .= "\t" . _cat_row( $category, $level ); 93 93 94 94 unset( $categories[ $key ] ); 95 95 96 96 $count++; 97 97 98 98 if ( isset($children[$category->term_id]) ) 99 _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count );99 $output .= _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count ); 100 100 } 101 101 102 $output = ob_get_contents();103 ob_end_clean();104 105 102 echo $output; 106 103 } 107 104 … … 2568 2565 ?> 2569 2566 </select> 2570 2567 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" /> 2571 <a href="#postcustomstuff" class="hide-if-no-js" on Click="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">2568 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;"> 2572 2569 <span id="enternew"><?php _e('Enter new'); ?></span> 2573 2570 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a> 2574 2571 <?php } else { ?> … … 3239 3236 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> 3240 3237 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> 3241 3238 <input type="text" id="find-posts-input" name="ps" value="" /> 3242 <input type="button" on Click="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />3239 <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> 3243 3240 3244 3241 <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" /> 3245 3242 <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label> … … 3249 3246 <div id="find-posts-response"></div> 3250 3247 </div> 3251 3248 <div class="find-box-buttons"> 3252 <input type="button" class="button alignleft" on Click="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />3249 <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" /> 3253 3250 <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" /> 3254 3251 </div> 3255 3252 </div> -
wp-admin/menu.php
47 47 48 48 $i = 15; 49 49 foreach ( $wp_taxonomies as $tax ) { 50 if ( $tax->hierarchical ||! in_array('post', (array) $tax->object_type, true) )50 if ( ! in_array('post', (array) $tax->object_type, true) ) 51 51 continue; 52 52 53 $submenu['edit.php'][$i] = array( esc_attr($tax->label), 'manage_categories', 'edit-tags.php?taxonomy=' . $tax->name ); 53 if ( $tax->hierarchical ) 54 $submenu['edit.php'][$i] = array( esc_attr($tax->label), 'manage_categories', 'categories.php?taxonomy=' . $tax->name ); 55 else 56 $submenu['edit.php'][$i] = array( esc_attr($tax->label), 'manage_categories', 'edit-tags.php?taxonomy=' . $tax->name ); 54 57 ++$i; 55 58 } 56 59 57 $submenu['edit.php'][50] = array( __('Categories'), 'manage_categories', 'categories.php' );58 59 60 $menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top', 'menu-media', 'div' ); 60 61 $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php'); 61 62 /* translators: add new file */ … … 86 87 87 88 $i = 15; 88 89 foreach ( $wp_taxonomies as $tax ) { 89 if ( $tax->hierarchical ||! in_array($ptype, (array) $tax->object_type, true) )90 if ( ! in_array($ptype, (array) $tax->object_type, true) ) 90 91 continue; 91 92 92 $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" ); 93 if ( $tax->hierarchical ) 94 $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "categories.php?taxonomy=$tax->name&post_type=$ptype" ); 95 else 96 $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" ); 93 97 ++$i; 94 98 } 95 99 } -
wp-includes/category-template.php
337 337 'exclude' => '', 'echo' => 1, 338 338 'selected' => 0, 'hierarchical' => 0, 339 339 'name' => 'cat', 'class' => 'postform', 340 'depth' => 0, 'tab_index' => 0 340 'depth' => 0, 'tab_index' => 0, 341 'taxonomy' => 'category', 'hide_if_empty' => false 341 342 ); 342 343 343 344 $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0; … … 359 360 $name = esc_attr($name); 360 361 $class = esc_attr($class); 361 362 362 $output = ''; 363 if ( ! $r['hide_if_empty'] || ! empty($categories) ) 364 $output = "<select name='$name' id='$name' class='$class' $tab_index_attribute>\n"; 365 else 366 $output = ''; 363 367 if ( ! empty( $categories ) ) { 364 $output = "<select name='$name' id='$name' class='$class' $tab_index_attribute>\n";365 368 366 369 if ( $show_option_all ) { 367 370 $show_option_all = apply_filters( 'list_cats', $show_option_all ); … … 381 384 $depth = -1; // Flat. 382 385 383 386 $output .= walk_category_dropdown_tree( $categories, $depth, $r ); 387 } 388 if ( ! $r['hide_if_empty'] || ! empty($categories) ) 384 389 $output .= "</select>\n"; 385 }386 390 391 387 392 $output = apply_filters( 'wp_dropdown_cats', $output ); 388 393 389 394 if ( $echo ) -
wp-includes/category.php
37 37 * @return array List of categories. 38 38 */ 39 39 function &get_categories( $args = '' ) { 40 $defaults = array( 't ype' => 'category' );40 $defaults = array( 'taxonomy' => 'category' ); 41 41 $args = wp_parse_args( $args, $defaults ); 42 42 43 $taxonomy = apply_filters( 'get_categories_taxonomy', 'category', $args ); 44 if ( 'link' == $args['type'] ) 45 $taxonomy = 'link_category'; 43 if ( isset($args['type']) && 'link' == $args['type'] ) //Back compat 44 $args['taxonomy'] = 'link_category'; 45 46 $taxonomy = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args ); 46 47 $categories = (array) get_terms( $taxonomy, $args ); 47 48 48 49 foreach ( array_keys( $categories ) as $k )