Changeset 13658
- Timestamp:
- 03/11/2010 04:34:27 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r13624 r13658 171 171 172 172 return $output; 173 }174 175 /**176 * Outputs the html checked attribute.177 *178 * Compares the first two arguments and if identical marks as checked179 *180 * @since 1.0181 *182 * @param any $checked One of the values to compare183 * @param any $current (true) The other value to compare if not just true184 * @param bool $echo Whether to echo or just return the string185 */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 selected194 *195 * @since 1.0196 *197 * @param any selected One of the values to compare198 * @param any $current (true) The other value to compare if not just true199 * @param bool $echo Whether to echo or just return the string200 */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 $type209 *210 * @since 2.8211 * @access private212 *213 * @param any $helper One of the values to compare214 * @param any $current (true) The other value to compare if not just true215 * @param bool $echo Whether to echo or just return the string216 * @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 else222 $result = '';223 224 if ($echo)225 echo $result;226 227 return $result;228 173 } 229 174 -
trunk/wp-includes/general-template.php
r13502 r13658 2204 2204 } 2205 2205 2206 /** 2207 * Outputs the html checked attribute. 2208 * 2209 * Compares the first two arguments and if identical marks as checked 2210 * 2211 * @since 1.0 2212 * 2213 * @param mixed $checked One of the values to compare 2214 * @param mixed $current (true) The other value to compare if not just true 2215 * @param bool $echo Whether to echo or just return the string 2216 * @return string html attribute or empty string 2217 */ 2218 function checked( $checked, $current = true, $echo = true ) { 2219 return __checked_selected_helper( $checked, $current, $echo, 'checked' ); 2220 } 2221 2222 /** 2223 * Outputs the html selected attribute. 2224 * 2225 * Compares the first two arguments and if identical marks as selected 2226 * 2227 * @since 1.0 2228 * 2229 * @param mixed selected One of the values to compare 2230 * @param mixed $current (true) The other value to compare if not just true 2231 * @param bool $echo Whether to echo or just return the string 2232 * @return string html attribute or empty string 2233 */ 2234 function selected( $selected, $current = true, $echo = true ) { 2235 return __checked_selected_helper( $selected, $current, $echo, 'selected' ); 2236 } 2237 2238 /** 2239 * Outputs the html disabled attribute. 2240 * 2241 * Compares the first two arguments and if identical marks as disabled 2242 * 2243 * @since 3.0.0 2244 * 2245 * @param mixed $disabled One of the values to compare 2246 * @param mixed $current (true) The other value to compare if not just true 2247 * @param bool $echo Whether to echo or just return the string 2248 * @return string html attribute or empty string 2249 */ 2250 function disabled( $disabled, $current = true, $echo = true ) { 2251 return __checked_selected_helper( $disabled, $current, $echo, 'disabled' ); 2252 } 2253 2254 /** 2255 * Private helper function for checked, selected, and disabled. 2256 * 2257 * Compares the first two arguments and if identical marks as $type 2258 * 2259 * @since 2.8 2260 * @access private 2261 * 2262 * @param any $helper One of the values to compare 2263 * @param any $current (true) The other value to compare if not just true 2264 * @param bool $echo Whether to echo or just return the string 2265 * @param string $type The type of checked|selected|disabled we are doing 2266 * @return string html attribute or empty string 2267 */ 2268 function __checked_selected_helper( $helper, $current, $echo, $type ) { 2269 if ( (string) $helper === (string) $current ) 2270 $result = " $type='$type'"; 2271 else 2272 $result = ''; 2273 2274 if ( $echo ) 2275 echo $result; 2276 2277 return $result; 2278 } 2279 2206 2280 ?>
Note: See TracChangeset
for help on using the changeset viewer.