<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12694] trunk: Show custom hierarchical taxonomies in the menus.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12694">12694</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-01-11 19:27:44 +0000 (Mon, 11 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Show custom hierarchical taxonomies in the menus. Props dd32. see <a href="http://trac.wordpress.org/ticket/11838">#11838</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincategoriesphp">trunk/wp-admin/categories.php</a></li>
<li><a href="#trunkwpadminincludestaxonomyphp">trunk/wp-admin/includes/taxonomy.php</a></li>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
<li><a href="#trunkwpadminmenuphp">trunk/wp-admin/menu.php</a></li>
<li><a href="#trunkwpincludescategorytemplatephp">trunk/wp-includes/category-template.php</a></li>
<li><a href="#trunkwpincludescategoryphp">trunk/wp-includes/category.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincategoriesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/categories.php (12693 => 12694)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/categories.php        2010-01-11 18:53:52 UTC (rev 12693)
+++ trunk/wp-admin/categories.php        2010-01-11 19:27:44 UTC (rev 12694)
</span><span class="lines">@@ -11,8 +11,26 @@
</span><span class="cx">
</span><span class="cx"> $title = __('Categories');
</span><span class="cx">
</span><del>-wp_reset_vars( array('action') );
</del><ins>+wp_reset_vars( array('action', 'taxonomy', 'post_type') );
</ins><span class="cx">
</span><ins>+if ( empty($taxonomy) )
+        $taxonomy = 'category';
+
+if ( !is_taxonomy($taxonomy) )
+        wp_die(__('Invalid taxonomy'));
+
+if ( empty($post_type) || !in_array( $post_type, get_post_types( array('_show' => true) ) ) )
+        $post_type = 'post';
+
+if ( 'post' != $post_type ) {
+        $parent_file = "edit.php?post_type=$post_type";
+        $submenu_file = "categories.php?taxonomy=$taxonomy&amp;post_type=$post_type";
+} else {
+        $parent_file = 'edit.php';
+        $submenu_file = "categories.php?taxonomy=$taxonomy";        
+}
+
+
</ins><span class="cx"> if ( isset( $_GET['action'] ) && isset($_GET['delete']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) )
</span><span class="cx">         $action = 'bulk-delete';
</span><span class="cx">
</span><span class="lines">@@ -135,7 +153,7 @@
</span><span class="cx"> <div class="wrap nosubsub">
</span><span class="cx"> <?php screen_icon(); ?>
</span><span class="cx"> <h2><?php echo esc_html( $title );
</span><del>-if ( isset($_GET['s']) && $_GET['s'] )
</del><ins>+if ( !empty($_GET['s']) )
</ins><span class="cx">         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( stripslashes($_GET['s']) ) ); ?>
</span><span class="cx"> </h2>
</span><span class="cx">
</span><span class="lines">@@ -146,6 +164,8 @@
</span><span class="cx"> endif; ?>
</span><span class="cx">
</span><span class="cx"> <form class="search-form topmargin" action="" method="get">
</span><ins>+<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
+<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
</ins><span class="cx"> <p class="search-box">
</span><span class="cx">         <label class="screen-reader-text" for="category-search-input"><?php _e('Search Categories'); ?>:</label>
</span><span class="cx">         <input type="text" id="category-search-input" name="s" value="<?php _admin_search_query(); ?>" />
</span><span class="lines">@@ -159,6 +179,8 @@
</span><span class="cx"> <div id="col-right">
</span><span class="cx"> <div class="col-wrap">
</span><span class="cx"> <form id="posts-filter" action="" method="get">
</span><ins>+<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
+<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
</ins><span class="cx"> <div class="tablenav">
</span><span class="cx">
</span><span class="cx"> <?php
</span><span class="lines">@@ -172,9 +194,9 @@
</span><span class="cx"> $cats_per_page = apply_filters( 'edit_categories_per_page', $cats_per_page );
</span><span class="cx">
</span><span class="cx"> if ( !empty($_GET['s']) )
</span><del>-        $num_cats = count(get_categories(array('hide_empty' => 0, 'search' => $_GET['s'])));
</del><ins>+        $num_cats = count(get_categories(array('taxonomy' => $taxonomy, 'hide_empty' => 0, 'search' => $_GET['s'])));
</ins><span class="cx"> else
</span><del>-        $num_cats = wp_count_terms('category');
</del><ins>+        $num_cats = wp_count_terms($taxonomy);
</ins><span class="cx">
</span><span class="cx"> $page_links = paginate_links( array(
</span><span class="cx">         'base' => add_query_arg( 'pagenum', '%#%' ),
</span><span class="lines">@@ -218,7 +240,7 @@
</span><span class="cx">
</span><span class="cx">         <tbody id="the-list" class="list:cat">
</span><span class="cx"> <?php
</span><del>-cat_rows(0, 0, 0, $pagenum, $cats_per_page);
</del><ins>+cat_rows(0, 0, 0, $pagenum, $cats_per_page, $taxonomy);
</ins><span class="cx"> ?>
</span><span class="cx">         </tbody>
</span><span class="cx"> </table>
</span><span class="lines">@@ -244,8 +266,12 @@
</span><span class="cx"> </form>
</span><span class="cx">
</span><span class="cx"> <div class="form-wrap">
</span><del>-<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>
</del><ins>+<?php if ( get_option('default_' . $taxonomy) ) : ?>
+<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>
+<?php endif; ?>
+<?php if ( 'category' == $taxonomy ) : ?>
</ins><span class="cx"> <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>
</span><ins>+<?php endif; ?>
</ins><span class="cx"> </div>
</span><span class="cx">
</span><span class="cx"> </div>
</span><span class="lines">@@ -261,6 +287,8 @@
</span><span class="cx"> <h3><?php _e('Add Category'); ?></h3>
</span><span class="cx"> <div id="ajax-response"></div>
</span><span class="cx"> <form name="addcat" id="addcat" method="post" action="categories.php" class="add:the-list: validate">
</span><ins>+<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
+<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
</ins><span class="cx"> <input type="hidden" name="action" value="addcat" />
</span><span class="cx"> <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-category'); ?>
</span><span class="cx">
</span><span class="lines">@@ -278,7 +306,7 @@
</span><span class="cx">
</span><span class="cx"> <div class="form-field">
</span><span class="cx">         <label for="category_parent"><?php _e('Category Parent') ?></label>
</span><del>-        <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'category_parent', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
</del><ins>+        <?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'))); ?>
</ins><span class="cx"> <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>
</span><span class="cx"> </div>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminincludestaxonomyphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/taxonomy.php (12693 => 12694)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/taxonomy.php        2010-01-11 18:53:52 UTC (rev 12693)
+++ trunk/wp-admin/includes/taxonomy.php        2010-01-11 19:27:44 UTC (rev 12694)
</span><span class="lines">@@ -108,7 +108,7 @@
</span><span class="cx"> * @return unknown
</span><span class="cx"> */
</span><span class="cx"> function wp_insert_category($catarr, $wp_error = false) {
</span><del>-        $cat_defaults = array('cat_ID' => 0, 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '');
</del><ins>+        $cat_defaults = array('cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '');
</ins><span class="cx">         $catarr = wp_parse_args($catarr, $cat_defaults);
</span><span class="cx">         extract($catarr, EXTR_SKIP);
</span><span class="cx">
</span><span class="lines">@@ -142,9 +142,9 @@
</span><span class="cx">         $args = compact('name', 'slug', 'parent', 'description');
</span><span class="cx">
</span><span class="cx">         if ( $update )
</span><del>-                $cat_ID = wp_update_term($cat_ID, 'category', $args);
</del><ins>+                $cat_ID = wp_update_term($cat_ID, $taxonomy, $args);
</ins><span class="cx">         else
</span><del>-                $cat_ID = wp_insert_term($cat_name, 'category', $args);
</del><ins>+                $cat_ID = wp_insert_term($cat_name, $taxonomy, $args);
</ins><span class="cx">
</span><span class="cx">         if ( is_wp_error($cat_ID) ) {
</span><span class="cx">                 if ( $wp_error )
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (12693 => 12694)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2010-01-11 18:53:52 UTC (rev 12693)
+++ trunk/wp-admin/includes/template.php        2010-01-11 19:27:44 UTC (rev 12694)
</span><span class="lines">@@ -20,13 +20,13 @@
</span><span class="cx"> * @param unknown_type $page
</span><span class="cx"> * @param unknown_type $per_page
</span><span class="cx"> */
</span><del>-function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) {
</del><ins>+function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20, $taxonomy = 'category' ) {
</ins><span class="cx">
</span><span class="cx">         $count = 0;
</span><span class="cx">
</span><span class="cx">         if ( empty($categories) ) {
</span><span class="cx">
</span><del>-                $args = array('hide_empty' => 0);
</del><ins>+                $args = array('hide_empty' => 0, 'taxonomy' => $taxonomy);
</ins><span class="cx">                 if ( !empty($_GET['s']) )
</span><span class="cx">                         $args['search'] = $_GET['s'];
</span><span class="cx">
</span><span class="lines">@@ -36,9 +36,9 @@
</span><span class="cx">                         return false;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        $children = _get_term_hierarchy('category');
</del><ins>+        $children = _get_term_hierarchy($taxonomy);
</ins><span class="cx">
</span><del>-        _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count );
</del><ins>+        echo _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count );
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -53,14 +53,14 @@
</span><span class="cx"> * @param unknown_type $level
</span><span class="cx"> * @param unknown_type $page
</span><span class="cx"> * @param unknown_type $per_page
</span><del>- * @return unknown
</del><ins>+ * @return string the output of the table.
</ins><span class="cx"> */
</span><span class="cx"> function _cat_rows( $parent = 0, $level = 0, $categories, &$children, $page = 1, $per_page = 20, &$count ) {
</span><span class="cx">
</span><span class="cx">         $start = ($page - 1) * $per_page;
</span><span class="cx">         $end = $start + $per_page;
</span><del>-        ob_start();
</del><span class="cx">
</span><ins>+        $output = '';
</ins><span class="cx">         foreach ( $categories as $key => $category ) {
</span><span class="cx">                 if ( $count >= $end )
</span><span class="cx">                         break;
</span><span class="lines">@@ -83,26 +83,23 @@
</span><span class="cx">
</span><span class="cx">                         $num_parents = count($my_parents);
</span><span class="cx">                         while( $my_parent = array_pop($my_parents) ) {
</span><del>-                                echo "\t" . _cat_row( $my_parent, $level - $num_parents );
</del><ins>+                                $output = "\t" . _cat_row( $my_parent, $level - $num_parents );
</ins><span class="cx">                                 $num_parents--;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if ( $count >= $start )
</span><del>-                        echo "\t" . _cat_row( $category, $level );
</del><ins>+                        $output .= "\t" . _cat_row( $category, $level );
</ins><span class="cx">
</span><span class="cx">                 unset( $categories[ $key ] );
</span><span class="cx">
</span><span class="cx">                 $count++;
</span><span class="cx">
</span><span class="cx">                 if ( isset($children[$category->term_id]) )
</span><del>-                        _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count );
</del><ins>+                        $output .= _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count );
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        $output = ob_get_contents();
-        ob_end_clean();
-
-        echo $output;
</del><ins>+        return $output;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -2568,7 +2565,7 @@
</span><span class="cx"> ?>
</span><span class="cx"> </select>
</span><span class="cx"> <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
</span><del>-<a href="#postcustomstuff" class="hide-if-no-js" onClick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
</del><ins>+<a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
</ins><span class="cx"> <span id="enternew"><?php _e('Enter new'); ?></span>
</span><span class="cx"> <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
</span><span class="cx"> <?php } else { ?>
</span><span class="lines">@@ -3239,7 +3236,7 @@
</span><span class="cx">                                 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
</span><span class="cx">                                 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
</span><span class="cx">                                 <input type="text" id="find-posts-input" name="ps" value="" />
</span><del>-                                <input type="button" onClick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
</del><ins>+                                <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
</ins><span class="cx">
</span><span class="cx">                                 <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" />
</span><span class="cx">                                 <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label>
</span><span class="lines">@@ -3249,7 +3246,7 @@
</span><span class="cx">                         <div id="find-posts-response"></div>
</span><span class="cx">                 </div>
</span><span class="cx">                 <div class="find-box-buttons">
</span><del>-                        <input type="button" class="button alignleft" onClick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
</del><ins>+                        <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
</ins><span class="cx">                         <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />
</span><span class="cx">                 </div>
</span><span class="cx">         </div>
</span></span></pre></div>
<a id="trunkwpadminmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/menu.php (12693 => 12694)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/menu.php        2010-01-11 18:53:52 UTC (rev 12693)
+++ trunk/wp-admin/menu.php        2010-01-11 19:27:44 UTC (rev 12694)
</span><span class="lines">@@ -47,15 +47,16 @@
</span><span class="cx">
</span><span class="cx">         $i = 15;
</span><span class="cx">         foreach ( $wp_taxonomies as $tax ) {
</span><del>-                if ( $tax->hierarchical || ! in_array('post', (array) $tax->object_type, true) )
</del><ins>+                if ( ! in_array('post', (array) $tax->object_type, true) )
</ins><span class="cx">                         continue;
</span><span class="cx">
</span><del>-                $submenu['edit.php'][$i] = array( esc_attr($tax->label), 'manage_categories', 'edit-tags.php?taxonomy=' . $tax->name );
</del><ins>+                if ( $tax->hierarchical )
+                        $submenu['edit.php'][$i] = array( esc_attr($tax->label), 'manage_categories', 'categories.php?taxonomy=' . $tax->name );
+                else
+                        $submenu['edit.php'][$i] = array( esc_attr($tax->label), 'manage_categories', 'edit-tags.php?taxonomy=' . $tax->name );
</ins><span class="cx">                 ++$i;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        $submenu['edit.php'][50] = array( __('Categories'), 'manage_categories', 'categories.php' );
-
</del><span class="cx"> $menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top', 'menu-media', 'div' );
</span><span class="cx">         $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
</span><span class="cx">         /* translators: add new file */
</span><span class="lines">@@ -86,10 +87,13 @@
</span><span class="cx">
</span><span class="cx">         $i = 15;
</span><span class="cx">         foreach ( $wp_taxonomies as $tax ) {
</span><del>-                if ( $tax->hierarchical || ! in_array($ptype, (array) $tax->object_type, true) )
</del><ins>+                if ( ! in_array($ptype, (array) $tax->object_type, true) )
</ins><span class="cx">                         continue;
</span><span class="cx">
</span><del>-                $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&amp;post_type=$ptype" );
</del><ins>+                if ( $tax->hierarchical )
+                        $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "categories.php?taxonomy=$tax->name&amp;post_type=$ptype" );
+                else
+                        $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&amp;post_type=$ptype" );
</ins><span class="cx">                 ++$i;
</span><span class="cx">         }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpincludescategorytemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/category-template.php (12693 => 12694)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/category-template.php        2010-01-11 18:53:52 UTC (rev 12693)
+++ trunk/wp-includes/category-template.php        2010-01-11 19:27:44 UTC (rev 12694)
</span><span class="lines">@@ -337,7 +337,8 @@
</span><span class="cx">                 'exclude' => '', 'echo' => 1,
</span><span class="cx">                 'selected' => 0, 'hierarchical' => 0,
</span><span class="cx">                 'name' => 'cat', 'class' => 'postform',
</span><del>-                'depth' => 0, 'tab_index' => 0
</del><ins>+                'depth' => 0, 'tab_index' => 0,
+                'taxonomy' => 'category', 'hide_if_empty' => false
</ins><span class="cx">         );
</span><span class="cx">
</span><span class="cx">         $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;
</span><span class="lines">@@ -359,9 +360,11 @@
</span><span class="cx">         $name = esc_attr($name);
</span><span class="cx">         $class = esc_attr($class);
</span><span class="cx">
</span><del>-        $output = '';
</del><ins>+        if ( ! $r['hide_if_empty'] || ! empty($categories) )
+                $output = "<select name='$name' id='$name' class='$class' $tab_index_attribute>\n";
+        else
+                $output = '';
</ins><span class="cx">         if ( ! empty( $categories ) ) {
</span><del>-                $output = "<select name='$name' id='$name' class='$class' $tab_index_attribute>\n";
</del><span class="cx">
</span><span class="cx">                 if ( $show_option_all ) {
</span><span class="cx">                         $show_option_all = apply_filters( 'list_cats', $show_option_all );
</span><span class="lines">@@ -381,9 +384,11 @@
</span><span class="cx">                         $depth = -1; // Flat.
</span><span class="cx">
</span><span class="cx">                 $output .= walk_category_dropdown_tree( $categories, $depth, $r );
</span><ins>+        }
+        if ( ! $r['hide_if_empty'] || ! empty($categories) )
</ins><span class="cx">                 $output .= "</select>\n";
</span><del>-        }
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         $output = apply_filters( 'wp_dropdown_cats', $output );
</span><span class="cx">
</span><span class="cx">         if ( $echo )
</span></span></pre></div>
<a id="trunkwpincludescategoryphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/category.php (12693 => 12694)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/category.php        2010-01-11 18:53:52 UTC (rev 12693)
+++ trunk/wp-includes/category.php        2010-01-11 19:27:44 UTC (rev 12694)
</span><span class="lines">@@ -37,12 +37,14 @@
</span><span class="cx"> * @return array List of categories.
</span><span class="cx"> */
</span><span class="cx"> function &get_categories( $args = '' ) {
</span><del>-        $defaults = array( 'type' => 'category' );
</del><ins>+        $defaults = array( 'taxonomy' => 'category' );
</ins><span class="cx">         $args = wp_parse_args( $args, $defaults );
</span><span class="cx">
</span><del>-        $taxonomy = apply_filters( 'get_categories_taxonomy', 'category', $args );
-        if ( 'link' == $args['type'] )
-                $taxonomy = 'link_category';
</del><ins>+        $taxonomy = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args );
+
+        if ( isset($args['type']) && 'link' == $args['type'] ) //Back compat
+                $taxonomy = $args['taxonomy'] = 'link_category';
+
</ins><span class="cx">         $categories = (array) get_terms( $taxonomy, $args );
</span><span class="cx">
</span><span class="cx">         foreach ( array_keys( $categories ) as $k )
</span></span></pre>
</div>
</div>
</body>
</html>