Making WordPress.org

Ticket #3075: 3075.patch

File 3075.patch, 3.5 KB (added by ketuchetan, 8 years ago)
  • trunk/wordpress.org/public_html/wp-content/plugins/wporg-meeting-posttype/wporg-meeting-posttype.php

     
    6464                                        'relation'=>'AND',
    6565                                        array(
    6666                                                'key'=>'recurring',
    67                                                 'value'=>array('weekly','monthly', '1'),
     67                                                'value'=>array('weekly', 'Biweekly', 'monthly', '1'),
    6868                                                'compare'=>'NOT IN',
    6969                                        ),
    7070                                        array(
     
    7979                                        'relation'=>'AND',
    8080                                        array(
    8181                                                'key'=>'recurring',
    82                                                 'value'=>array('weekly', 'monthly', '1'),
     82                                                'value'=>array('weekly', 'Biweekly',  'monthly', '1'),
    8383                                                'compare'=>'IN',
    8484                                        ),
    8585                                        array(
     
    117117                        if ( $post->recurring == 'weekly' || $post->recurring === '1' ) {
    118118                                try {
    119119                                        // from the start date, advance the week until it's past now
    120                                         $start = new DateTime( $post->start_date.' '.$post->time.' GMT' );
    121                                         $now = new DateTime();
    122                                         $interval = $start->diff($now);
     120                                        $start    = new DateTime( $post->start_date . ' ' . $post->time . ' GMT' );
     121                                        $now      = new DateTime();
     122                                        $interval = $start->diff( $now );
    123123                                        // add one to days to account for events that happened earlier today
    124                                         $weekdiff = ceil( ($interval->days+1) / 7 );
    125                                         $next = strtotime( "{$post->start_date} + {$weekdiff} weeks" );
    126                                         $post->next_date = date('Y-m-d', $next);
    127                                 } catch (Exception $e) {
     124                                        $weekdiff        = ceil( ( $interval->days + 1 ) / 7 );
     125                                        $next            = strtotime( "{$post->start_date} + {$weekdiff} weeks" );
     126                                        $post->next_date = date( 'Y-m-d', $next );
     127                                } catch ( Exception $e ) {
    128128                                        // if the datetime is invalid, then set the post->next_date to the start date instead
    129129                                        $post->next_date = $post->start_date;
    130130                                }
     131                        } else if ( $post->recurring == 'Biweekly' || $post->recurring === '1' ) {
     132                                try {
     133                                        // from the start date, advance the week until it's past now
     134                                        $start    = new DateTime( $post->start_date . ' ' . $post->time . ' GMT' );
     135                                        $now      = new DateTime();
     136                                        $interval = $start->diff( $now );
     137                                        // add one to days to account for events that happened earlier today
     138                                        $weekdiff        = ceil( ( $interval->days + 1 ) / 14 );
     139                                        $next            = strtotime( "{$post->start_date} + {$weekdiff} weeks" );
     140                                        $post->next_date = date( 'Y-m-d', $next );
     141                                } catch ( Exception $e ) {
     142                                        // if the datetime is invalid, then set the post->next_date to the start date instead
     143                                        $post->next_date = $post->start_date;
     144                                }
    131145                        } else if ( $post->recurring == 'monthly' ) {
    132146                                try {
    133147                                        // advance the start date 1 month at a time until it's past now
     
    257271                <label for="recurring"><?php _e( 'Recurring: ', 'wporg' ); ?>
    258272                        <label for="weekly"><?php _e( 'Weekly', 'wporg' ); ?></label>
    259273                        <input type="radio" name="recurring" value="weekly" class="regular-radio" <?php checked( $recurring, 'weekly' ); ?>>
     274            <label for="Biweekly"><?php _e( 'Biweekly', 'wporg' ); ?></label>
     275            <input type="radio" name="recurring" value="Biweekly" class="regular-radio" <?php checked( $recurring, 'Biweekly' ); ?>>
    260276                        <label for="monthly"><?php _e( 'Monthly', 'wporg' ); ?></label>
    261277                        <input type="radio" name="recurring" value="monthly" class="regular-radio" <?php checked( $recurring, 'monthly' ); ?>>
    262278                </label>