WordPress.org

Make WordPress Core

Ticket #9285: 9285-5.diff

File 9285-5.diff, 4.5 KB (added by technosailor, 4 years ago)

9285-3 with the addition of the deprecation of get_date_from_gmt() in favor of get_gmt_from_date() and eating our own dogfood.

  • wp-includes/post.php

     
    41124112 */ 
    41134113function _future_post_hook( $deprecated = '', $post ) { 
    41144114        wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) ); 
    4115         wp_schedule_single_event( strtotime( $post->post_date_gmt. ' GMT' ), 'publish_future_post', array( $post->ID ) ); 
     4115        wp_schedule_single_event( get_gmt_from_date( $post->post_date ) . ' GMT', 'publish_future_post', array( $post->ID ) ); 
    41164116} 
    41174117 
    41184118/** 
  • wp-includes/formatting.php

     
    15551555 * 
    15561556 * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the 
    15571557 * value of the 'gmt_offset' option. Return format can be overridden using the 
    1558  * $format parameter 
     1558 * $format parameter. If PHP5 is supported, the function uses the DateTime and 
     1559 * DateTimeZone objects to respect time zone differences in DST. 
    15591560 * 
    15601561 * @since 1.2.0 
    15611562 * 
     
    15661567 */ 
    15671568function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') { 
    15681569        preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches); 
    1569         $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); 
    1570         $string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * 3600); 
     1570        $tz = get_option('timezone_string'); 
     1571        if( class_exists('DateTime') && $tz ) { 
     1572                //PHP5 
     1573                date_default_timezone_set( $tz ); 
     1574                $datetime = new DateTime( $string ); 
     1575                $datetime->setTimezone( new DateTimeZone('UTC') ); 
     1576                $offset = $datetime->getOffset(); 
     1577                $datetime->modify( '+' . $offset / 3600 . ' hours'); 
     1578                $string_gmt = gmdate($format, $datetime->format('U')); 
     1579 
     1580                date_default_timezone_set('UTC'); 
     1581        } 
     1582        else { 
     1583                //PHP4 
     1584                $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); 
     1585                $string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * 3600); 
     1586        } 
    15711587        return $string_gmt; 
    15721588} 
    15731589 
    15741590/** 
    1575  * Converts a GMT date into the correct format for the blog. 
    1576  * 
    1577  * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of 
    1578  * gmt_offset.Return format can be overridden using the $format parameter 
    1579  * 
    1580  * @since 1.2.0 
    1581  * 
    1582  * @param string $string The date to be converted. 
    1583  * @param string $format The format string for the returned date (default is Y-m-d H:i:s) 
    1584  * @return string Formatted date relative to the GMT offset. 
    1585  */ 
    1586 function get_date_from_gmt($string, $format = 'Y-m-d H:i:s') { 
    1587         preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches); 
    1588         $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); 
    1589         $string_localtime = gmdate($format, $string_time + get_option('gmt_offset')*3600); 
    1590         return $string_localtime; 
    1591 } 
    1592  
    1593 /** 
    15941591 * Computes an offset in seconds from an iso8601 timezone. 
    15951592 * 
    15961593 * @since 1.5.0 
  • wp-includes/deprecated.php

     
    25132513        _deprecated_function( __FUNCTION__, '3.0' ); 
    25142514        return ''; 
    25152515} 
     2516 
     2517/** 
     2518 * Converts a GMT date into the correct format for the blog. 
     2519 * 
     2520 * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of 
     2521 * gmt_offset.Return format can be overridden using the $format parameter 
     2522 * 
     2523 * @since 1.2.0 
     2524 * 
     2525 * @param string $string The date to be converted. 
     2526 * @param string $format The format string for the returned date (default is Y-m-d H:i:s) 
     2527 * @deprecated 3.0.0 
     2528 * @see get_gmt_from_date() 
     2529 * @return string Formatted date relative to the GMT offset. 
     2530 */ 
     2531function get_date_from_gmt($string, $format = 'Y-m-d H:i:s') { 
     2532        _deprecated_function( __FUNCTION__, '3.0', 'get_gmt_from_date()' ); 
     2533        return get_gmt_from_date( $string, $format ); 
     2534} 
  • wp-admin/import/rss.php

     
    6969                        } 
    7070 
    7171                        $post_date_gmt = gmdate('Y-m-d H:i:s', $post_date_gmt); 
    72                         $post_date = get_date_from_gmt( $post_date_gmt ); 
     72                        $post_date = get_gmt_from_date( $post_date_gmt ); 
    7373 
    7474                        preg_match_all('|<category>(.*?)</category>|is', $post, $categories); 
    7575                        $categories = $categories[1];