50 * @param array $args Uses 'selected', 'show_count', and 'value_field' keys, if they exist. |
53 * @param array $args Uses 'selected', 'show_count', and 'value_field' keys, if they exist. |
51 * See wp_dropdown_categories(). |
54 * See wp_dropdown_categories(). |
52 * @param int $id Optional. ID of the current category. Default 0 (unused). |
55 * @param int $id Optional. ID of the current category. Default 0 (unused). |
53 */ |
56 */ |
54 public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
57 public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
55 $pad = str_repeat(' ', $depth * 3); |
58 $pad = str_repeat( ' ', $depth * 3 ); |
56 |
59 |
57 /** This filter is documented in wp-includes/category-template.php */ |
60 /** This filter is documented in wp-includes/category-template.php */ |
58 $cat_name = apply_filters( 'list_cats', $category->name, $category ); |
61 $cat_name = apply_filters( 'list_cats', $category->name, $category ); |
59 |
62 |
60 if ( isset( $args['value_field'] ) && isset( $category->{$args['value_field']} ) ) { |
63 if ( isset( $args['value_field'] ) && isset( $category->{$args['value_field']} ) ) { |
61 $value_field = $args['value_field']; |
64 $value_field = $args['value_field']; |
62 } else { |
65 } else { |
63 $value_field = 'term_id'; |
66 $value_field = 'term_id'; |
64 } |
67 } |
65 |
68 |
66 $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$value_field} ) . "\""; |
69 $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$value_field} ) . '"'; |
67 |
70 |
68 // Type-juggling causes false matches, so we force everything to a string. |
71 // Type-juggling causes false matches, so we force everything to a string. |
69 if ( (string) $category->{$value_field} === (string) $args['selected'] ) |
72 if ( (string) $category->{$value_field} === (string) $args['selected'] ) { |
70 $output .= ' selected="selected"'; |
73 $output .= ' selected="selected"'; |
|
74 } |
71 $output .= '>'; |
75 $output .= '>'; |
72 $output .= $pad.$cat_name; |
76 $output .= $pad . $cat_name; |
73 if ( $args['show_count'] ) |
77 if ( $args['show_count'] ) { |
74 $output .= ' ('. number_format_i18n( $category->count ) .')'; |
78 $output .= ' (' . number_format_i18n( $category->count ) . ')'; |
|
79 } |
75 $output .= "</option>\n"; |
80 $output .= "</option>\n"; |
76 } |
81 } |
77 } |
82 } |