Making WordPress.org

Ticket #3075: 3075.2.patch

File 3075.2.patch, 3.5 KB (added by SergeyBiryukov, 8 years ago)
  • 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(
     
    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' ) {
     132                                try {
     133                                        // advance the start date 2 weeks at a time until it's past now
     134                                        $start = new DateTime( $post->start_date.' '.$post->time.' GMT' );
     135                                        $next = $start;
     136                                        $now = new DateTime();
     137                                        while ( $now > $next ) {
     138                                                $next->modify('+2 weeks');
     139                                        }
     140                                        $post->next_date = $next->format('Y-m-d');
     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
     
    255269                        <input type="text" name="time" class="time" value="<?php echo esc_attr($time); ?>">
    256270                </label>
    257271                <label for="recurring"><?php _e( 'Recurring: ', 'wporg' ); ?>
     272                        <input type="radio" name="recurring" value="weekly" id="weekly" class="regular-radio" <?php checked( $recurring, 'weekly' ); ?>>
    258273                        <label for="weekly"><?php _e( 'Weekly', 'wporg' ); ?></label>
    259                         <input type="radio" name="recurring" value="weekly" class="regular-radio" <?php checked( $recurring, 'weekly' ); ?>>
     274                        <input type="radio" name="recurring" value="biweekly" id="biweekly" class="regular-radio" <?php checked( $recurring, 'biweekly' ); ?>>
     275                        <label for="biweekly"><?php _e( 'Biweekly', 'wporg' ); ?></label>
     276                        <input type="radio" name="recurring" value="monthly" id="monthly" class="regular-radio" <?php checked( $recurring, 'monthly' ); ?>>
    260277                        <label for="monthly"><?php _e( 'Monthly', 'wporg' ); ?></label>
    261                         <input type="radio" name="recurring" value="monthly" class="regular-radio" <?php checked( $recurring, 'monthly' ); ?>>
    262278                </label>
    263279                </p>
    264280                <p>
     
    328344                $meta['start_date'] = ( isset( $_POST['start_date'] ) ? esc_textarea( $_POST['start_date'] ) : '' );
    329345                $meta['end_date'] = ( isset( $_POST['end_date'] ) ? esc_textarea( $_POST['end_date'] ) : '' );
    330346                $meta['time'] = ( isset( $_POST['time'] ) ? esc_textarea( $_POST['time'] ) : '' );
    331                 $meta['recurring'] = ( isset ( $_POST['recurring'] ) && ( in_array( $_POST['recurring'], array('weekly', 'monthly') ) ) ? ( $_POST['recurring'] ) : '' );
     347                $meta['recurring'] = ( isset ( $_POST['recurring'] ) && ( in_array( $_POST['recurring'], array( 'weekly', 'biweekly', 'monthly' ) ) ) ? ( $_POST['recurring'] ) : '' );
    332348                $meta['link'] = ( isset( $_POST['link'] ) ? esc_url( $_POST['link'] ) : '' );
    333349                $meta['location'] = ( isset( $_POST['location'] ) ? esc_textarea( $_POST['location'] ) : '' );
    334350