WordPress.org

Make WordPress Core

Ticket #9285: 9285-3.diff

File 9285-3.diff, 2.2 KB (added by technosailor, 4 years ago)

Adheres to the WP curly brace style.

  • wp-includes/post.php

     
    41104110 */ 
    41114111function _future_post_hook( $deprecated = '', $post ) { 
    41124112        wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) ); 
    4113         wp_schedule_single_event( strtotime( $post->post_date_gmt. ' GMT' ), 'publish_future_post', array( $post->ID ) ); 
     4113        wp_schedule_single_event( get_gmt_from_date( $post->post_date ) . ' GMT', 'publish_future_post', array( $post->ID ) ); 
    41144114} 
    41154115 
    41164116/** 
  • 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