Make WordPress Core

Ticket #20110: 20110.diff

File 20110.diff, 1.0 KB (added by jeremyfelt, 13 years ago)
  • 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 (false) The placeholder of the input field
     2223 * @return string html attribute or empty string 
     2224 */
     2225function valued( $value, $echo = true, $placeholder = false ){
     2226        $data = '';
     2227        if ( (string) $value )
     2228                $data = ' value="' . esc_attr( $value ) . '"';
     2229
     2230        if ( (string) $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