Changeset 12694
- Timestamp:
- 01/11/2010 07:27:44 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
wp-admin/categories.php (modified) (9 diffs)
-
wp-admin/includes/taxonomy.php (modified) (2 diffs)
-
wp-admin/includes/template.php (modified) (11 diffs)
-
wp-admin/menu.php (modified) (2 diffs)
-
wp-includes/category-template.php (modified) (3 diffs)
-
wp-includes/category.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/categories.php
r12616 r12694 12 12 $title = __('Categories'); 13 13 14 wp_reset_vars( array('action') ); 14 wp_reset_vars( array('action', 'taxonomy', 'post_type') ); 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 15 33 16 34 if ( isset( $_GET['action'] ) && isset($_GET['delete']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) ) … … 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> … … 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> … … 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 … … 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( … … 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> … … 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 … … 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'); ?> … … 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> -
trunk/wp-admin/includes/taxonomy.php
r12662 r12694 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); … … 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) ) { -
trunk/wp-admin/includes/template.php
r12652 r12694 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; … … 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']; … … 37 37 } 38 38 39 $children = _get_term_hierarchy( 'category');40 41 _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count );39 $children = _get_term_hierarchy($taxonomy); 40 41 echo _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count ); 42 42 43 43 } … … 54 54 * @param unknown_type $page 55 55 * @param unknown_type $per_page 56 * @return unknown56 * @return string the output of the table. 57 57 */ 58 58 function _cat_rows( $parent = 0, $level = 0, $categories, &$children, $page = 1, $per_page = 20, &$count ) { … … 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 ) … … 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 } … … 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 ] ); … … 97 97 98 98 if ( isset($children[$category->term_id]) ) 99 _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count ); 100 } 101 102 $output = ob_get_contents(); 103 ob_end_clean(); 104 105 echo $output; 99 $output .= _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count ); 100 } 101 102 return $output; 106 103 } 107 104 … … 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> … … 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" /> … … 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> -
trunk/wp-admin/menu.php
r12673 r12694 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 57 $submenu['edit.php'][50] = array( __('Categories'), 'manage_categories', 'categories.php' );58 59 59 60 $menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top', 'menu-media', 'div' ); … … 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 } -
trunk/wp-includes/category-template.php
r12598 r12694 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 … … 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 ) { … … 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 } 390 386 391 387 392 $output = apply_filters( 'wp_dropdown_cats', $output ); -
trunk/wp-includes/category.php
r12515 r12694 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 $taxonomy = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args ); 44 45 if ( isset($args['type']) && 'link' == $args['type'] ) //Back compat 46 $taxonomy = $args['taxonomy'] = 'link_category'; 47 46 48 $categories = (array) get_terms( $taxonomy, $args ); 47 49
Note: See TracChangeset
for help on using the changeset viewer.