Make WordPress Core


Ignore:
Timestamp:
03/11/2010 04:34:27 PM (15 years ago)
Author:
nacin
Message:

Introduce the disabled() form helper. Move selected() and checked() out of wp-admin and into full scope. see #12581

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r13624 r13658  
    171171
    172172    return $output;
    173 }
    174 
    175 /**
    176  * Outputs the html checked attribute.
    177  *
    178  * Compares the first two arguments and if identical marks as checked
    179  *
    180  * @since 1.0
    181  *
    182  * @param any $checked One of the values to compare
    183  * @param any $current (true) The other value to compare if not just true
    184  * @param bool $echo Whether to echo or just return the string
    185  */
    186 function checked( $checked, $current = true, $echo = true) {
    187     return __checked_selected_helper( $checked, $current, $echo, 'checked' );
    188 }
    189 
    190 /**
    191  * Outputs the html selected attribute.
    192  *
    193  * Compares the first two arguments and if identical marks as selected
    194  *
    195  * @since 1.0
    196  *
    197  * @param any selected One of the values to compare
    198  * @param any $current (true) The other value to compare if not just true
    199  * @param bool $echo Whether to echo or just return the string
    200  */
    201 function selected( $selected, $current = true, $echo = true) {
    202     return __checked_selected_helper( $selected, $current, $echo, 'selected' );
    203 }
    204 
    205 /**
    206  * Private helper function for checked and selected.
    207  *
    208  * Compares the first two arguments and if identical marks as $type
    209  *
    210  * @since 2.8
    211  * @access private
    212  *
    213  * @param any $helper One of the values to compare
    214  * @param any $current (true) The other value to compare if not just true
    215  * @param bool $echo Whether to echo or just return the string
    216  * @param string $type The type of checked|selected we are doing.
    217  */
    218 function __checked_selected_helper( $helper, $current, $echo, $type) {
    219     if ( (string) $helper === (string) $current)
    220         $result = " $type='$type'";
    221     else
    222         $result = '';
    223 
    224     if ($echo)
    225         echo $result;
    226 
    227     return $result;
    228173}
    229174
Note: See TracChangeset for help on using the changeset viewer.