Changeset 12917
- Timestamp:
- 02/01/2010 04:28:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/general-template.php
r12733 r12917 1257 1257 1258 1258 /** 1259 * Display or Retrieve the date the post was written.1259 * Display or Retrieve the date the current $post was written (once per date) 1260 1260 * 1261 1261 * Will only output the date if the current post's date is different from the 1262 1262 * previous one output. 1263 1264 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the 1265 * function is called several times for each post. 1266 * 1267 * HTML output can be filtered with 'the_date'. 1268 * Date string output can be filtered with 'get_the_date'. 1263 1269 * 1264 1270 * @since 0.71 1265 * 1271 * @uses get_the_date() 1266 1272 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. 1267 1273 * @param string $before Optional. Output before the date. … … 1270 1276 * @return string|null Null if displaying, string if retrieving. 1271 1277 */ 1272 function the_date( $d='', $before='', $after='', $echo = true) {1273 global $ post, $day, $previousday;1278 function the_date( $d = '', $before = '', $after = '', $echo = true ) { 1279 global $day, $previousday; 1274 1280 $the_date = ''; 1275 1281 if ( $day != $previousday ) { 1276 1282 $the_date .= $before; 1277 if ( $d=='' ) 1278 $the_date .= mysql2date(get_option('date_format'), $post->post_date); 1279 else 1280 $the_date .= mysql2date($d, $post->post_date); 1283 $the_date .= get_the_date( $d ); 1281 1284 $the_date .= $after; 1282 1285 $previousday = $day; 1283 1286 1284 $the_date = apply_filters('the_date', $the_date, $d, $before, $after); 1285 if ( $echo ) 1286 echo $the_date; 1287 $the_date = apply_filters('the_date', $the_date, $d, $before, $after); 1288 1289 if ( $echo ) 1290 echo $the_date; 1291 else 1292 return $the_date; 1293 } 1294 1295 return null; 1296 } 1297 1298 /** 1299 * Retrieve the date the current $post was written. 1300 * 1301 * Unlike the_date() this function will always return the date. 1302 * Modify output with 'get_the_date' filter. 1303 * 1304 * @since 3.0.0 1305 * 1306 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. 1307 * @return string|null Null if displaying, string if retrieving. 1308 */ 1309 function get_the_date( $d = '' ) { 1310 global $post, $day; 1311 $the_date = ''; 1312 1313 if ( '' == $d ) 1314 $the_date .= mysql2date(get_option('date_format'), $post->post_date); 1287 1315 else 1288 return $the_date; 1289 } 1316 $the_date .= mysql2date($d, $post->post_date); 1317 1318 return apply_filters('get_the_date', $the_date, $d); 1290 1319 } 1291 1320
Note: See TracChangeset
for help on using the changeset viewer.