Make WordPress Core

Ticket #47463: trim-events.patch

File trim-events.patch, 1.2 KB (added by Rarst, 6 years ago)
  • src/wp-admin/includes/class-wp-community-events.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    402402         */
    403403        protected function trim_events( $response_body ) {
    404404                if ( isset( $response_body['events'] ) ) {
    405                         $wordcamps         = array();
    406                         $current_timestamp = current_time( 'timestamp' );
     405                        $wordcamps = array();
     406                        $today     = current_time( 'Y-m-d' );
    407407
    408408                        foreach ( $response_body['events'] as $key => $event ) {
    409409                                /*
     
    415415                                        continue;
    416416                                }
    417417
    418                                 $event_timestamp = strtotime( $event['date'] );
     418                                // We don’t get accurate time with timezone from API, so we only take date part (Y-m-d).
     419                                $event_date = substr( $event['date'], 0, 10 );
    419420
    420                                 if ( $current_timestamp > $event_timestamp && ( $current_timestamp - $event_timestamp ) > DAY_IN_SECONDS ) {
     421                                if ( $today > $event_date ) {
    421422                                        unset( $response_body['events'][ $key ] );
    422423                                }
    423424                        }