WordPress.org

Make WordPress Core

Ticket #8481: checked-selected-helper-upgrade.patch

File checked-selected-helper-upgrade.patch, 2.4 KB (added by chmac, 5 years ago)

New patch against the new checked_selected_helper() function

  • wp-admin/includes/template.php

     
    374374/** 
    375375 * Outputs the html checked attribute. 
    376376 * 
    377  * Compares the first two arguments and if identical marks as checked 
     377 * Compares the first two arguments and if identical, or $current is an array  
     378 * and $checked is in the array, marks as checked 
    378379 * 
    379380 * @since 2.8 
    380381 * 
    381382 * @param any $checked One of the values to compare 
    382  * @param any $current (true) The other value to compare if not just true 
     383 * @param any $current (true) The other value (or array of values) to compare if not just true 
    383384 * @param bool $echo Whether or not to echo or just return the string 
    384385 */ 
    385386function checked( $checked, $current = true, $echo = true) { 
     
    389390/** 
    390391 * Outputs the html selected attribute. 
    391392 * 
    392  * Compares the first two arguments and if identical marks as selected 
     393 * Compares the first two arguments and if identical, or $current is an array  
     394 * and $checked is in the array, marks as selected 
    393395 * 
    394396 * @since 2.8 
    395397 * 
    396398 * @param any selected One of the values to compare 
    397  * @param any $current (true) The other value to compare if not just true 
     399 * @param any $current (true) The other value (or array of values) to compare if not just true 
    398400 * @param bool $echo Whether or not to echo or just return the string 
    399401 */ 
    400402function selected( $selected, $current = true, $echo = true) { 
     
    404406/** 
    405407 * Private helper function for checked and selected. 
    406408 * 
    407  * Compares the first two arguments and if identical marks as $type 
     409 * Compares the first two arguments and if identical, or $current is an array  
     410 * and $checked is in the array, marks as $type 
    408411 * 
    409412 * @since 2.8 
    410413 * @access private 
    411414 * 
    412415 * @param any $helper One of the values to compare 
    413  * @param any $current (true) The other value to compare if not just true 
     416 * @param any $current (true) The other value (or array of values) to compare if not just true 
    414417 * @param bool $echo Whether or not to echo or just return the string 
    415418 * @param string $type The type of checked|selected we are doing. 
    416419 */ 
    417420function __checked_selected_helper( $helper, $current, $echo, $type) { 
    418         if ( $helper == $current) 
     421        if ( ( is_array($selected) && in_array($helper, $selected) ) || $helper == $current ) 
    419422                $result = " $type='$type'"; 
    420423        else 
    421424                $result = '';