Make WordPress Core

Ticket #20110: 20110.2.diff

File 20110.2.diff, 1.0 KB (added by jeremyfelt, 12 years ago)

Updated function

  • general-template.php

     
    22122212}
    22132213
    22142214/**
     2215 * Outputs the html value and placeholder attributes.
     2216 *
     2217 * Accepts the value of the input field and an optional placeholder for
     2218 * use when the value is empty.
     2219 *
     2220 * @param string $value The value of the input field
     2221 * @param bool $echo (true) Whether to echo or just return the string
     2222 * @param string $placeholder (NULL) The placeholder of the input field
     2223 * @return string html attribute or empty string 
     2224 */
     2225function valued( $value, $echo = true, $placeholder = NULL ){
     2226        $data = '';
     2227        if ( isset( $value ) )
     2228                $data = ' value="' . esc_attr( $value ) . '"';
     2229
     2230        if ( isset( $placeholder ) )
     2231                $data .= ' placeholder="' . esc_attr( $placeholder ) . '"';
     2232
     2233        if ( $echo )
     2234                echo $data;
     2235        else
     2236                return $data;
     2237}
     2238
     2239/**
    22152240 * Outputs the html checked attribute.
    22162241 *
    22172242 * Compares the first two arguments and if identical marks as checked