Changeset 31006 for trunk/src/wp-includes/category-template.php
- Timestamp:
- 12/30/2014 09:30:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/category-template.php
r31005 r31006 294 294 * 295 295 * @since 2.1.0 296 * @since 4.2.0 Introduced the 'value_field' parameter. 296 297 * 297 298 * @param string|array $args { … … 328 329 * Defaults to the value of $name. 329 330 * @type string $class Optional. Value for the 'class' attribute of the select element. 330 * @type int $selected Optional. ID of the category to be selected. 331 * @type int|string $selected Optional. Value of the option that should be selected. 332 * @type string $value_field Optional. Term field that should be used to populate the 'value' attribute 333 * of the option elements. Accepts any valid term field: 'term_id', 'name', 334 * 'slug', 'term_group', 'term_taxonomy_id', 'taxonomy', 'description', 335 * 'parent', 'count'. Default 'term_id'. 331 336 * @type string $taxonomy Optional. Name of the category to retrieve. Default 'category'. 332 337 * @type bool $hide_if_empty Optional. True to skip generating markup if no categories are found. … … 347 352 'class' => 'postform', 'depth' => 0, 348 353 'tab_index' => 0, 'taxonomy' => 'category', 349 'hide_if_empty' => false, 'option_none_value' => -1 354 'hide_if_empty' => false, 'option_none_value' => -1, 355 'value_field' => 'term_id', 350 356 ); 351 357 … … 1107 1113 * @param object $category Category data object. 1108 1114 * @param int $depth Depth of category. Used for padding. 1109 * @param array $args Uses 'selected' and 'show_count' keys, if they exist. @see wp_dropdown_categories() 1115 * @param array $args Uses 'selected', 'show_count', and 'value_field' keys, if they exist. 1116 * See {@see wp_dropdown_categories()}. 1110 1117 */ 1111 1118 public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { … … 1115 1122 $cat_name = apply_filters( 'list_cats', $category->name, $category ); 1116 1123 1117 $output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\""; 1124 if ( ! isset( $args['value_field'] ) || ! isset( $category->{$args['value_field']} ) ) { 1125 $args['value_field'] = 'term_id'; 1126 } 1127 1128 $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$args['value_field']} ) . "\""; 1129 1118 1130 if ( $category->term_id == $args['selected'] ) 1119 1131 $output .= ' selected="selected"';
Note: See TracChangeset
for help on using the changeset viewer.