WordPress.org

Make WordPress Core

Ticket #13258: category-template.php.patch

File category-template.php.patch, 949 bytes (added by zaharamh, 11 months ago)

Adds an optional 'value' argument to specify what should be used as for the value of the option (slug or ID). If unspecified reverts to ID for categories and slug otherwise.

  • category-template.php

     
    937937                $pad = str_repeat(' ', $depth * 3); 
    938938 
    939939                $cat_name = apply_filters('list_cats', $category->name, $category); 
    940                 $output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\""; 
    941                 if ( $category->term_id == $args['selected'] ) 
     940                if( !empty($args['value']) ){  
     941              $value = ($args['value']=='slug' ? $category->slug : $category->term_id );  
     942        }else{  
     943               $value = ( $category->taxonomy != 'category' ? $category->slug : $category->term_id );  
     944        }  
     945             
     946       $output .= "\t<option class=\"level-$depth\" value=\"".$value."\"";  
     947       if ( $category->term_id == $args['selected'] ) 
    942948                        $output .= ' selected="selected"'; 
    943949                $output .= '>'; 
    944950                $output .= $pad.$cat_name;