<!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>[13854] trunk/wp-includes: Update wp_list_categories()
to be custom taxonomy aware.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13854">13854</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-03-28 02:07:31 +0000 (Sun, 28 Mar 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update wp_list_categories() to be custom taxonomy aware. Props jfarthing84. See <a href="http://trac.wordpress.org/ticket/11838">#11838</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludescategorytemplatephp">trunk/wp-includes/category-template.php</a></li>
<li><a href="#trunkwpincludesclassesphp">trunk/wp-includes/classes.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludescategorytemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/category-template.php (13853 => 13854)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/category-template.php        2010-03-28 01:57:45 UTC (rev 13853)
+++ trunk/wp-includes/category-template.php        2010-03-28 02:07:31 UTC (rev 13854)
</span><span class="lines">@@ -448,44 +448,53 @@
</span><span class="cx"> */
</span><span class="cx"> function wp_list_categories( $args = '' ) {
</span><span class="cx">         $defaults = array(
</span><del>-                'show_option_all' => '', 'orderby' => 'name',
-                'order' => 'ASC', 'show_last_update' => 0,
-                'style' => 'list', 'show_count' => 0,
-                'hide_empty' => 1, 'use_desc_for_title' => 1,
-                'child_of' => 0, 'feed' => '', 'feed_type' => '',
-                'feed_image' => '', 'exclude' => '', 'exclude_tree' => '', 'current_category' => 0,
</del><ins>+                'show_option_all' => '', 'show_option_none' => __('No categories'),
+                'orderby' => 'name', 'order' => 'ASC',
+                'show_last_update' => 0, 'style' => 'list',
+                'show_count' => 0, 'hide_empty' => 1,
+                'use_desc_for_title' => 1, 'child_of' => 0,
+                'feed' => '', 'feed_type' => '',
+                'feed_image' => '', 'exclude' => '',
+                'exclude_tree' => '', 'current_category' => 0,
</ins><span class="cx">                 'hierarchical' => true, 'title_li' => __( 'Categories' ),
</span><del>-                'echo' => 1, 'depth' => 0
</del><ins>+                'echo' => 1, 'depth' => 0,
+                'taxonomy' => 'category'
</ins><span class="cx">         );
</span><span class="cx">
</span><span class="cx">         $r = wp_parse_args( $args, $defaults );
</span><span class="cx">
</span><del>-        if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
</del><ins>+        if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] )
</ins><span class="cx">                 $r['pad_counts'] = true;
</span><del>-        }
</del><span class="cx">
</span><del>-        if ( isset( $r['show_date'] ) ) {
</del><ins>+        if ( isset( $r['show_date'] ) )
</ins><span class="cx">                 $r['include_last_update_time'] = $r['show_date'];
</span><del>-        }
</del><span class="cx">
</span><span class="cx">         if ( true == $r['hierarchical'] ) {
</span><span class="cx">                 $r['exclude_tree'] = $r['exclude'];
</span><span class="cx">                 $r['exclude'] = '';
</span><span class="cx">         }
</span><ins>+        
+        if ( !isset( $r['class'] ) )
+                $r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
</ins><span class="cx">
</span><span class="cx">         extract( $r );
</span><span class="cx">
</span><ins>+        if ( !is_taxonomy($taxonomy) )
+                return false;
+
</ins><span class="cx">         $categories = get_categories( $r );
</span><span class="cx">
</span><span class="cx">         $output = '';
</span><span class="cx">         if ( $title_li && 'list' == $style )
</span><del>-                        $output = '<li class="categories">' . $r['title_li'] . '<ul>';
</del><ins>+                        $output = '<li class="' . $class . '">' . $title_li . '<ul>';
</ins><span class="cx">
</span><span class="cx">         if ( empty( $categories ) ) {
</span><del>-                if ( 'list' == $style )
-                        $output .= '<li>' . __( "No categories" ) . '</li>';
-                else
-                        $output .= __( "No categories" );
</del><ins>+                if ( ! empty( $show_option_none ) ) {
+                        if ( 'list' == $style )
+                                $output .= '<li>' . $show_option_none . '</li>';
+                        else
+                                $output .= $show_option_none;
+                }
</ins><span class="cx">         } else {
</span><span class="cx">                 global $wp_query;
</span><span class="cx">
</span><span class="lines">@@ -495,7 +504,7 @@
</span><span class="cx">                         else
</span><span class="cx">                                 $output .= '<a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a>';
</span><span class="cx">
</span><del>-                if ( empty( $r['current_category'] ) && is_category() )
</del><ins>+                if ( empty( $r['current_category'] ) && ( is_category() || is_tax() ) )
</ins><span class="cx">                         $r['current_category'] = $wp_query->get_queried_object_id();
</span><span class="cx">
</span><span class="cx">                 if ( $hierarchical )
</span><span class="lines">@@ -994,4 +1003,4 @@
</span><span class="cx">         return $r;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-?>
</del><ins>+?>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/classes.php (13853 => 13854)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/classes.php        2010-03-28 01:57:45 UTC (rev 13853)
+++ trunk/wp-includes/classes.php        2010-03-28 02:07:31 UTC (rev 13854)
</span><span class="lines">@@ -1438,7 +1438,7 @@
</span><span class="cx">
</span><span class="cx">                 $cat_name = esc_attr( $category->name);
</span><span class="cx">                 $cat_name = apply_filters( 'list_cats', $cat_name, $category );
</span><del>-                $link = '<a href="' . get_category_link( $category->term_id ) . '" ';
</del><ins>+                $link = '<a href="' . get_term_link( $category, $category->taxonomy ) . '" ';
</ins><span class="cx">                 if ( $use_desc_for_title == 0 || empty($category->description) )
</span><span class="cx">                         $link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"';
</span><span class="cx">                 else
</span></span></pre>
</div>
</div>
</body>
</html>