WordPress.org

Making WordPress.org

Changeset 9705


Ignore:
Timestamp:
04/06/2020 10:23:19 PM (8 months ago)
Author:
iandunn
Message:

Official WordPress Events: Only use session time when dates match.

See https://wordpress.slack.com/archives/C08M59V3P/p1586194798100800

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/official-wordpress-events.php

    r9704 r9705  
    164164        }
    165165
    166         $this->log( 'finished job' );
     166        $this->log( "finished job\n\n" );
    167167    }
    168168
     
    335335                                continue 3;
    336336                            }
    337                             if ( ! $wordcamp->session_start_time ) {
    338                                 $event['start_timestamp'] = $value;
    339                             } else {
    340                                 $event['start_timestamp'] = absint( $wordcamp->session_start_time );
    341                             }
     337
     338                            $event['start_timestamp'] = $this->get_wordcamp_start_time( $value, absint( $wordcamp->session_start_time ) );
    342339                            break;
    343340
     
    394391
    395392        return $events;
     393    }
     394
     395    /**
     396     * Determine the best start time for a WordCamp.
     397     *
     398     * The timestamp from the WordCamp post type only tell us the date that the camp is on, not when it starts.
     399     * The earliest session can be used to get the time that the camp starts, but it's likely to be inaccurate
     400     * if it doesn't match the date from the WordCamp post. One common cause of that is when an event is
     401     * postponed, but the organizers haven't gone through and updated all of the sessions yet.
     402     *
     403     * @param string $start_date
     404     * @param string $first_session_start_time
     405     *
     406     * @return string
     407     */
     408    protected function get_wordcamp_start_time( $start_date, $first_session_start_time ) {
     409        $session_time_is_same_day = date( 'Ymd', $start_date ) === date( 'Ymd', $first_session_start_time );
     410
     411        return $session_time_is_same_day ? $first_session_start_time : $start_date;
    396412    }
    397413
Note: See TracChangeset for help on using the changeset viewer.