Making WordPress.org

Changeset 5849


Ignore:
Timestamp:
08/31/2017 12:26:46 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Make/Meetings: Add "Biweekly" option for recurrent meetings.

Props ketuchetan for initial patch.
Fixes #3075. See #2218.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-meeting-posttype/wporg-meeting-posttype.php

    r5848 r5849  
    6565                    array(
    6666                        'key'=>'recurring',
    67                         'value'=>array('weekly','monthly', '1'),
     67                        'value'=>array( 'weekly', 'biweekly', 'monthly', '1' ),
    6868                        'compare'=>'NOT IN',
    6969                    ),
     
    8080                    array(
    8181                        'key'=>'recurring',
    82                         'value'=>array('weekly', 'monthly', '1'),
     82                        'value'=>array( 'weekly', 'biweekly', 'monthly', '1' ),
    8383                        'compare'=>'IN',
    8484                    ),
     
    128128                    }
    129129                    $post->next_date = $next->format( 'Y-m-d' );
     130                } catch (Exception $e) {
     131                    // if the datetime is invalid, then set the post->next_date to the start date instead
     132                    $post->next_date = $post->start_date;
     133                }
     134            } else if ( $post->recurring == 'biweekly' ) {
     135                try {
     136                    // advance the start date 2 weeks at a time until it's past now
     137                    $start = new DateTime( $post->start_date.' '.$post->time.' GMT' );
     138                    $next = $start;
     139                    $now = new DateTime();
     140                    while ( $now > $next ) {
     141                        $next->modify('+2 weeks');
     142                    }
     143                    $post->next_date = $next->format('Y-m-d');
    130144                } catch (Exception $e) {
    131145                    // if the datetime is invalid, then set the post->next_date to the start date instead
     
    259273        </label>
    260274        <label for="recurring"><?php _e( 'Recurring: ', 'wporg' ); ?>
     275            <input type="radio" name="recurring" value="weekly" id="weekly" class="regular-radio" <?php checked( $recurring, 'weekly' ); ?>>
    261276            <label for="weekly"><?php _e( 'Weekly', 'wporg' ); ?></label>
    262             <input type="radio" name="recurring" value="weekly" class="regular-radio" <?php checked( $recurring, 'weekly' ); ?>>
     277            <input type="radio" name="recurring" value="biweekly" id="biweekly" class="regular-radio" <?php checked( $recurring, 'biweekly' ); ?>>
     278            <label for="biweekly"><?php _e( 'Biweekly', 'wporg' ); ?></label>
     279            <input type="radio" name="recurring" value="monthly" id="monthly" class="regular-radio" <?php checked( $recurring, 'monthly' ); ?>>
    263280            <label for="monthly"><?php _e( 'Monthly', 'wporg' ); ?></label>
    264             <input type="radio" name="recurring" value="monthly" class="regular-radio" <?php checked( $recurring, 'monthly' ); ?>>
    265281        </label>
    266282        </p>
     
    332348        $meta['end_date'] = ( isset( $_POST['end_date'] ) ? esc_textarea( $_POST['end_date'] ) : '' );
    333349        $meta['time'] = ( isset( $_POST['time'] ) ? esc_textarea( $_POST['time'] ) : '' );
    334         $meta['recurring'] = ( isset ( $_POST['recurring'] ) && ( in_array( $_POST['recurring'], array('weekly', 'monthly') ) ) ? ( $_POST['recurring'] ) : '' );
     350        $meta['recurring'] = ( isset ( $_POST['recurring'] ) && ( in_array( $_POST['recurring'], array( 'weekly', 'biweekly', 'monthly' ) ) ) ? ( $_POST['recurring'] ) : '' );
    335351        $meta['link'] = ( isset( $_POST['link'] ) ? esc_url( $_POST['link'] ) : '' );
    336352        $meta['location'] = ( isset( $_POST['location'] ) ? esc_textarea( $_POST['location'] ) : '' );
Note: See TracChangeset for help on using the changeset viewer.