Ticket #11264: 12277-add-get_the_date.diff

File 12277-add-get_the_date.diff, 2.6 KB (added by jeremyclarke, 3 years ago)

add get_the_date() function to /wp-includes/general-template.php and use it in the_date()

  • general-template.php

    # This patch file was generated by NetBeans IDE
    # Following Index: paths are relative to: /Users/ungratefulbiped/Sites/wp-svn/wp-includes
    # This patch can be applied using context Tools: Patch action on respective folder.
    # It uses platform neutral UTF-8 encoding and \n newlines.
    # Above lines and this line are ignored by the patching process.
     
    12071207} 
    12081208 
    12091209/** 
    1210  * Display or Retrieve the date the post was written. 
     1210 * Display or Retrieve the date the current $post was written (once per date) 
    12111211 * 
    12121212 * Will only output the date if the current post's date is different from the 
    12131213 * previous one output. 
     1214 
     1215 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the 
     1216 * function is called several times for each post. 
    12141217 * 
    1215  * @since 0.71 
     1218 * HTML output can be filtered with 'the_date'. 
     1219 * Date string output can be filtered with 'get_the_date'. 
    12161220 * 
     1221 * @since 0.71 
     1222 * @uses get_the_date() 
    12171223 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. 
    12181224 * @param string $before Optional. Output before the date. 
    12191225 * @param string $after Optional. Output after the date. 
     
    12211227 * @return string|null Null if displaying, string if retrieving. 
    12221228 */ 
    12231229function the_date($d='', $before='', $after='', $echo = true) { 
    1224         global $post, $day, $previousday; 
     1230        global $day, $previousday; 
    12251231        $the_date = ''; 
    12261232        if ( $day != $previousday ) { 
    12271233                $the_date .= $before; 
    1228                 if ( $d=='' ) 
    1229                         $the_date .= mysql2date(get_option('date_format'), $post->post_date); 
    1230                 else 
    1231                         $the_date .= mysql2date($d, $post->post_date); 
     1234                $the_date .= get_the_date( $d ); 
    12321235                $the_date .= $after; 
    12331236                $previousday = $day; 
    12341237 
     
    12411244} 
    12421245 
    12431246/** 
     1247 * Retrieve the date the current $post was written. 
     1248 * 
     1249 * Unlike the_date() this function will always return the date. 
     1250 * Modify output with 'get_the_date' filter. 
     1251 * 
     1252 * @since 2.9 
     1253 * 
     1254 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. 
     1255 * @return string|null Null if displaying, string if retrieving. 
     1256 */ 
     1257function get_the_date($d='') { 
     1258        global $post, $day; 
     1259        $the_date = ''; 
     1260 
     1261        if ( '' == $d ) 
     1262                $the_date .= mysql2date(get_option('date_format'), $post->post_date); 
     1263        else 
     1264                $the_date .= mysql2date($d, $post->post_date); 
     1265 
     1266        return apply_filters('get_the_date', $the_date, $d); 
     1267} 
     1268 
     1269/** 
     1270 No newline at end of file 
    12441271 * Display the date on which the post was last modified. 
    12451272 * 
    12461273 * @since 2.1.0