WordPress.org

Make WordPress Core

Ticket #22700: 22700-sw.diff

File 22700-sw.diff, 1.8 KB (added by simonwheatley, 2 years ago)

Set form element value to name if taxonomy is non-hierarchical

  • wp-admin/includes/template.php

    diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
    index 788a4bd..0b50abc 100644
    a b class Walker_Category_Checklist extends Walker { 
    4444                else 
    4545                        $name = 'tax_input['.$taxonomy.']'; 
    4646 
     47                $taxonomy_obj = get_taxonomy( $taxonomy ); 
     48                 
     49                $value = $taxonomy_obj->hierarchical ? esc_attr( $category->term_id ): esc_attr( $category->name ); 
     50                 
    4751                $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; 
    48                 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>'; 
     52                $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $value . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>'; 
    4953        } 
    5054 
    5155        function end_el( &$output, $category, $depth = 0, $args = array() ) { 
    function wp_terms_checklist($post_id = 0, $args = array()) { 
    99103        $args = apply_filters( 'wp_terms_checklist_args', $args, $post_id ); 
    100104 
    101105        extract( wp_parse_args($args, $defaults), EXTR_SKIP ); 
    102  
     106         
    103107        if ( empty($walker) || !is_a($walker, 'Walker') ) 
    104108                $walker = new Walker_Category_Checklist; 
    105109