Index: trunk/src/wp-includes/category-template.php
===================================================================
--- trunk/src/wp-includes/category-template.php (revision 45599)
+++ trunk/src/wp-includes/category-template.php (revision 45667)
@@ -366,12 +366,13 @@
}
- $r = wp_parse_args( $args, $defaults );
- $option_none_value = $r['option_none_value'];
-
- if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
- $r['pad_counts'] = true;
- }
-
- $tab_index = $r['tab_index'];
+ // Parse incoming $args into an array and merge it with $defaults
+ $parsed_args = wp_parse_args( $args, $defaults );
+ $option_none_value = $args['option_none_value'];
+
+ if ( ! isset( $parsed_args['pad_counts'] ) && $parsed_args['show_count'] && $parsed_args['hierarchical'] ) {
+ $parsed_args['pad_counts'] = true;
+ }
+
+ $tab_index = $parsed_args['tab_index'];
$tab_index_attribute = '';
@@ -381,19 +382,19 @@
// Avoid clashes with the 'name' param of get_terms().
- $get_terms_args = $r;
+ $get_terms_args = $parsed_args;
unset( $get_terms_args['name'] );
- $categories = get_terms( $r['taxonomy'], $get_terms_args );
-
- $name = esc_attr( $r['name'] );
- $class = esc_attr( $r['class'] );
- $id = $r['id'] ? esc_attr( $r['id'] ) : $name;
- $required = $r['required'] ? 'required' : '';
-
- if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) {
+ $categories = get_terms( $parsed_args['taxonomy'], $get_terms_args );
+
+ $name = esc_attr( $parsed_args['name'] );
+ $class = esc_attr( $parsed_args['class'] );
+ $id = $parsed_args['id'] ? esc_attr( $parsed_args['id'] ) : $name;
+ $required = $parsed_args['required'] ? 'required' : '';
+
+ if ( ! $parsed_args['hide_if_empty'] || ! empty( $categories ) ) {
$output = "\n";
}
@@ -451,9 +452,9 @@
*
* @param string $output HTML output.
- * @param array $r Arguments used to build the drop-down.
+ * @param array $parsed_args Arguments used to build the drop-down.
*/
- $output = apply_filters( 'wp_dropdown_cats', $output, $r );
-
- if ( $r['echo'] ) {
+ $output = apply_filters( 'wp_dropdown_cats', $output, $parsed_args );
+
+ if ( $parsed_args['echo'] ) {
echo $output;
}
@@ -538,46 +539,46 @@
);
- $r = wp_parse_args( $args, $defaults );
-
- if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
- $r['pad_counts'] = true;
+ $parsed_args = wp_parse_args( $args, $defaults );
+
+ if ( ! isset( $parsed_args['pad_counts'] ) && $parsed_args['show_count'] && $parsed_args['hierarchical'] ) {
+ $parsed_args['pad_counts'] = true;
}
// Descendants of exclusions should be excluded too.
- if ( true == $r['hierarchical'] ) {
+ if ( true == $parsed_args['hierarchical'] ) {
$exclude_tree = array();
- if ( $r['exclude_tree'] ) {
- $exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $r['exclude_tree'] ) );
- }
-
- if ( $r['exclude'] ) {
- $exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $r['exclude'] ) );
- }
-
- $r['exclude_tree'] = $exclude_tree;
- $r['exclude'] = '';
- }
-
- if ( ! isset( $r['class'] ) ) {
- $r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
- }
-
- if ( ! taxonomy_exists( $r['taxonomy'] ) ) {
+ if ( $parsed_args['exclude_tree'] ) {
+ $exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $parsed_args['exclude_tree'] ) );
+ }
+
+ if ( $parsed_args['exclude'] ) {
+ $exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $parsed_args['exclude'] ) );
+ }
+
+ $parsed_args['exclude_tree'] = $exclude_tree;
+ $parsed_args['exclude'] = '';
+ }
+
+ if ( ! isset( $parsed_args['class'] ) ) {
+ $parsed_args['class'] = ( 'category' == $parsed_args['taxonomy'] ) ? 'categories' : $parsed_args['taxonomy'];
+ }
+
+ if ( ! taxonomy_exists( $parsed_args['taxonomy'] ) ) {
return false;
}
- $show_option_all = $r['show_option_all'];
- $show_option_none = $r['show_option_none'];
-
- $categories = get_categories( $r );
+ $show_option_all = $parsed_args['show_option_all'];
+ $show_option_none = $parsed_args['show_option_none'];
+
+ $categories = get_categories( $parsed_args );
$output = '';
- if ( $r['title_li'] && 'list' == $r['style'] && ( ! empty( $categories ) || ! $r['hide_title_if_empty'] ) ) {
- $output = '
' . $r['title_li'] . '';
+ if ( $parsed_args['title_li'] && 'list' == $parsed_args['style'] && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] ) ) {
+ $output = '- ' . $parsed_args['title_li'] . '
';
}
if ( empty( $categories ) ) {
if ( ! empty( $show_option_none ) ) {
- if ( 'list' == $r['style'] ) {
+ if ( 'list' == $parsed_args['style'] ) {
$output .= '- ' . $show_option_none . '
';
} else {
@@ -591,5 +592,5 @@
// For taxonomies that belong only to custom post types, point to a valid archive.
- $taxonomy_object = get_taxonomy( $r['taxonomy'] );
+ $taxonomy_object = get_taxonomy( $parsed_args['taxonomy'] );
if ( ! in_array( 'post', $taxonomy_object->object_type ) && ! in_array( 'page', $taxonomy_object->object_type ) ) {
foreach ( $taxonomy_object->object_type as $object_type ) {
@@ -614,5 +615,5 @@
$posts_page = esc_url( $posts_page );
- if ( 'list' == $r['style'] ) {
+ if ( 'list' == $parsed_args['style'] ) {
$output .= "- $show_option_all
";
} else {
@@ -621,20 +622,20 @@
}
- if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) {
+ if ( empty( $parsed_args['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) {
$current_term_object = get_queried_object();
- if ( $current_term_object && $r['taxonomy'] === $current_term_object->taxonomy ) {
- $r['current_category'] = get_queried_object_id();
+ if ( $current_term_object && $parsed_args['taxonomy'] === $current_term_object->taxonomy ) {
+ $parsed_args['current_category'] = get_queried_object_id();
}
}
- if ( $r['hierarchical'] ) {
- $depth = $r['depth'];
+ if ( $parsed_args['hierarchical'] ) {
+ $depth = $parsed_args['depth'];
} else {
$depth = -1; // Flat.
}
- $output .= walk_category_tree( $categories, $depth, $r );
- }
-
- if ( $r['title_li'] && 'list' == $r['style'] && ( ! empty( $categories ) || ! $r['hide_title_if_empty'] ) ) {
+ $output .= walk_category_tree( $categories, $depth, $parsed_args );
+ }
+
+ if ( $parsed_args['title_li'] && 'list' == $parsed_args['style'] && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] ) ) {
$output .= '
';
}
@@ -650,5 +651,5 @@
$html = apply_filters( 'wp_list_categories', $output, $args );
- if ( $r['echo'] ) {
+ if ( $parsed_args['echo'] ) {
echo $html;
} else {