<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[5850] sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-meeting-posttype/wporg-meeting-posttype.php: Make/Meetings: Add "Occurrence in a month" option for recurrent meetings, allowing for a more flexible schedule like the first and third Thursday of every month.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/5850">5850</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/5850","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-08-31 12:34:12 +0000 (Thu, 31 Aug 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Make/Meetings: Add "Occurrence in a month" option for recurrent meetings, allowing for a more flexible schedule like the first and third Thursday of every month.

The occurrence day is based on the day of week that the Start Date falls on.

Fixes <a href="http://meta.trac.wordpress.org/ticket/2218">#2218</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginswporgmeetingposttypewporgmeetingposttypephp">sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-meeting-posttype/wporg-meeting-posttype.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginswporgmeetingposttypewporgmeetingposttypephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-meeting-posttype/wporg-meeting-posttype.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-meeting-posttype/wporg-meeting-posttype.php        2017-08-31 12:26:46 UTC (rev 5849)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-meeting-posttype/wporg-meeting-posttype.php  2017-08-31 12:34:12 UTC (rev 5850)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -29,8 +29,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'admin_head', array( $mpt, 'meeting_column_width' ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function meeting_column_width() {
-               echo '<style type="text/css">.column-team { width:10em !important; overflow:hidden }</style>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function meeting_column_width() { ?>
+               <style type="text/css">
+                       .column-team { width: 10em !important; overflow: hidden; }
+                       #meeting-info .recurring label { padding-right: 10px; }
+               </style>
+               <?php
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function meeting_add_custom_columns( $columns ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -64,7 +68,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'relation'=>'AND',
</span><span class="cx" style="display: block; padding: 0 10px">                                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                                'key'=>'recurring',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                'value'=>array( 'weekly', 'biweekly', 'monthly', '1' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                         'value'=>array( 'weekly', 'biweekly', 'occurrence', 'monthly', '1' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                                 'compare'=>'NOT IN',
</span><span class="cx" style="display: block; padding: 0 10px">                                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                                        array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -79,7 +83,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'relation'=>'AND',
</span><span class="cx" style="display: block; padding: 0 10px">                                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                                'key'=>'recurring',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                'value'=>array( 'weekly', 'biweekly', 'monthly', '1' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                         'value'=>array( 'weekly', 'biweekly', 'occurrence', 'monthly', '1' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                                 'compare'=>'IN',
</span><span class="cx" style="display: block; padding: 0 10px">                                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                                        array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,53 +118,84 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // for each entry, set a fake meta value to show the next date for recurring meetings
</span><span class="cx" style="display: block; padding: 0 10px">                array_walk( $posts, function ( &$post ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( $post->recurring == 'weekly' || $post->recurring === '1' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( 'weekly' === $post->recurring || '1' === $post->recurring ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 try {
</span><span class="cx" style="display: block; padding: 0 10px">                                        // from the start date, advance the week until it's past now
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        $start = new DateTime( $post->start_date.' '.$post->time.' GMT' );
-                                       $next = $start;
-                                       $now = new DateTime();
-                                       if ( $now > $next ) {
-                                               $interval = $start->diff($now);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 $start = new DateTime( $post->start_date . ' ' . $post->time . ' GMT' );
+                                       $next  = $start;
+                                       $now   = new DateTime();
+
+                                       if ( $next < $now ) {
+                                               $interval = $start->diff( $now );
</ins><span class="cx" style="display: block; padding: 0 10px">                                                 // add one to days to account for events that happened earlier today
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                $weekdiff = ceil( ($interval->days+1) / 7 );
-                                               $next->modify('+ '.$weekdiff.' weeks');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                         $weekdiff = ceil( ( $interval->days + 1 ) / 7 );
+                                               $next->modify( '+ ' . $weekdiff . ' weeks' );
</ins><span class="cx" style="display: block; padding: 0 10px">                                         }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">                                         $post->next_date = $next->format( 'Y-m-d' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                } catch (Exception $e) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         } catch ( Exception $e ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         // if the datetime is invalid, then set the post->next_date to the start date instead
</span><span class="cx" style="display: block; padding: 0 10px">                                        $post->next_date = $post->start_date;
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        } else if ( $post->recurring == 'biweekly' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 } else if ( 'biweekly' === $post->recurring ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 try {
</span><span class="cx" style="display: block; padding: 0 10px">                                        // advance the start date 2 weeks at a time until it's past now
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        $start = new DateTime( $post->start_date.' '.$post->time.' GMT' );
-                                       $next = $start;
-                                       $now = new DateTime();
-                                       while ( $now > $next ) {
-                                               $next->modify('+2 weeks');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 $start = new DateTime( $post->start_date . ' ' . $post->time . ' GMT' );
+                                       $next  = $start;
+                                       $now   = new DateTime();
+
+                                       while ( $next < $now ) {
+                                               $next->modify( '+2 weeks' );
</ins><span class="cx" style="display: block; padding: 0 10px">                                         }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        $post->next_date = $next->format('Y-m-d');
-                               } catch (Exception $e) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                                       $post->next_date = $next->format( 'Y-m-d' );
+                               } catch ( Exception $e ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         // if the datetime is invalid, then set the post->next_date to the start date instead
</span><span class="cx" style="display: block; padding: 0 10px">                                        $post->next_date = $post->start_date;
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        } else if ( $post->recurring == 'monthly' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 } else if ( 'occurrence' === $post->recurring ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 try {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                        // advance the start date in the current month until it's past now
+                                       $start = new DateTime( $post->start_date . ' ' . $post->time . ' GMT' );
+                                       $next  = $start;
+                                       $now   = new DateTime();
+
+                                       $day_index = date( 'w', strtotime( $post->start_date . ' ' . $post->time . ' GMT' ) );
+                                       $day_name  = $GLOBALS['wp_locale']->get_weekday( $day_index );
+                                       $numerals  = array( 'first', 'second', 'third', 'fourth' );
+                                       $months    = array( 'this month', 'next month' );
+
+                                       foreach ( $post->occurrence as $index ) {
+                                               foreach ( $months as $month ) {
+                                                       $next->modify( $numerals[ $index - 1 ] . ' ' . $day_name . ' of ' . $month );
+                                                       if ( $next > $now ) {
+                                                               break 2;
+                                                       }
+                                               }
+                                       }
+
+                                       $post->next_date = $next->format( 'Y-m-d' );
+                               } catch ( Exception $e ) {
+                                       // if the datetime is invalid, then set the post->next_date to the start date instead
+                                       $post->next_date = $post->start_date;
+                               }
+                       } else if ( 'monthly' === $post->recurring ) {
+                               try {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         // advance the start date 1 month at a time until it's past now
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        $start = new DateTime( $post->start_date.' '.$post->time.' GMT' );
-                                       $next = $start;
-                                       $now = new DateTime();
-                                       while ( $now > $next ) {
-                                               $next->modify('+1 month');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 $start = new DateTime( $post->start_date . ' ' . $post->time . ' GMT' );
+                                       $next  = $start;
+                                       $now   = new DateTime();
+
+                                       while ( $next < $now ) {
+                                               $next->modify( '+1 month' );
</ins><span class="cx" style="display: block; padding: 0 10px">                                         }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        $post->next_date = $next->format('Y-m-d');
-                               } catch (Exception $e) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                                       $post->next_date = $next->format( 'Y-m-d' );
+                               } catch ( Exception $e ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         // if the datetime is invalid, then set the post->next_date to the start date instead
</span><span class="cx" style="display: block; padding: 0 10px">                                        $post->next_date = $post->start_date;
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        }
-                       else {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 } else {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $post->next_date = $post->start_date;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                });
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -227,7 +262,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function add_meta_boxes() {
</span><span class="cx" style="display: block; padding: 0 10px">                add_meta_box(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'meeting_info',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'meeting-info',
</ins><span class="cx" style="display: block; padding: 0 10px">                         'Meeting Info',
</span><span class="cx" style="display: block; padding: 0 10px">                        array( $this, 'render_meta_boxes' ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'meeting',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -240,73 +275,105 @@
</span><span class="cx" style="display: block; padding: 0 10px">                wp_enqueue_script( 'jquery-ui-datepicker' );
</span><span class="cx" style="display: block; padding: 0 10px">                wp_enqueue_style( 'jquery-ui-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css', true);
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $meta = get_post_custom( $post->ID );
-               $team = ! isset( $meta['team'][0] ) ? '' : $meta['team'][0];
-               $start = ! isset( $meta['start_date'][0] ) ? '' : $meta['start_date'][0];
-               $end = ! isset( $meta['end_date'][0] ) ? '' : $meta['end_date'][0];
-               $time = ! isset( $meta['time'][0] ) ? '' : $meta['time'][0];
-               $recurring = ! isset( $meta['recurring'][0] ) ? '' : $meta['recurring'][0];
-               if ( $recurring === '1' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $meta       = get_post_custom( $post->ID );
+               $team       = isset( $meta['team'][0] ) ? $meta['team'][0] : '';
+               $start      = isset( $meta['start_date'][0] ) ? $meta['start_date'][0] : '';
+               $end        = isset( $meta['end_date'][0] ) ? $meta['end_date'][0] : '';
+               $time       = isset( $meta['time'][0] ) ? $meta['time'][0] : '';
+               $recurring  = isset( $meta['recurring'][0] ) ? $meta['recurring'][0] : '';
+               if ( '1' === $recurring ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $recurring = 'weekly';
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $link = ! isset( $meta['link'][0] ) ? '' : $meta['link'][0];
-               $location = ! isset( $meta['location'][0] ) ? '' : $meta['location'][0];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $occurrence = isset( $meta['occurrence'][0] ) ? unserialize( $meta['occurrence'][0] ) : array();
+               $link       = isset( $meta['link'][0] ) ? $meta['link'][0] : '';
+               $location   = isset( $meta['location'][0] ) ? $meta['location'][0] : '';
</ins><span class="cx" style="display: block; padding: 0 10px">                 wp_nonce_field( 'save_meeting_meta_'.$post->ID , 'meeting_nonce' );
</span><span class="cx" style="display: block; padding: 0 10px">                ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                <p>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                <label for="team"><?php _e( 'Team: ', 'wporg' ); ?>
-                       <input type="text" id="team" name="team" class="regular-text wide" value="<?php echo esc_attr($team); ?>">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         <label for="team">
+                       <?php _e( 'Team: ', 'wporg' ); ?>
+                       <input type="text" id="team" name="team" class="regular-text wide" value="<?php echo esc_attr( $team ); ?>">
</ins><span class="cx" style="display: block; padding: 0 10px">                 </label>
</span><span class="cx" style="display: block; padding: 0 10px">                </p>
</span><span class="cx" style="display: block; padding: 0 10px">                <p>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                <label for="start_date"><?php _e( 'Start Date', 'wporg' ); ?>
-                       <input type="text" name="start_date" class="date" value="<?php echo esc_attr($start); ?>">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         <label for="start_date">
+                       <?php _e( 'Start Date', 'wporg' ); ?>
+                       <input type="text" name="start_date" id="start_date" class="date" value="<?php echo esc_attr( $start ); ?>">
</ins><span class="cx" style="display: block; padding: 0 10px">                 </label>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                <label for="end_date"><?php _e( 'End Date', 'wporg' ); ?>
-                       <input type="text" name="end_date" class="date" value="<?php echo esc_attr($end); ?>">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         <label for="end_date">
+                       <?php _e( 'End Date', 'wporg' ); ?>
+                       <input type="text" name="end_date" id="end_date" class="date" value="<?php echo esc_attr( $end ); ?>">
</ins><span class="cx" style="display: block; padding: 0 10px">                 </label>
</span><span class="cx" style="display: block; padding: 0 10px">                </p>
</span><span class="cx" style="display: block; padding: 0 10px">                <p>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                <label for="time"><?php _e( 'Time (UTC)', 'wporg' ); ?>
-                       <input type="text" name="time" class="time" value="<?php echo esc_attr($time); ?>">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         <label for="time">
+                       <?php _e( 'Time (UTC)', 'wporg' ); ?>
+                       <input type="text" name="time" id="time" class="time" value="<?php echo esc_attr( $time ); ?>">
</ins><span class="cx" style="display: block; padding: 0 10px">                 </label>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                <label for="recurring"><?php _e( 'Recurring: ', 'wporg' ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         </p>
+               <p class="recurring">
+               <?php _e( 'Recurring: ', 'wporg' ); ?><br />
+               <label for="weekly">
</ins><span class="cx" style="display: block; padding: 0 10px">                         <input type="radio" name="recurring" value="weekly" id="weekly" class="regular-radio" <?php checked( $recurring, 'weekly' ); ?>>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <label for="weekly"><?php _e( 'Weekly', 'wporg' ); ?></label>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <?php _e( 'Weekly', 'wporg' ); ?>
+               </label><br />
+
+               <label for="biweekly">
</ins><span class="cx" style="display: block; padding: 0 10px">                         <input type="radio" name="recurring" value="biweekly" id="biweekly" class="regular-radio" <?php checked( $recurring, 'biweekly' ); ?>>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <label for="biweekly"><?php _e( 'Biweekly', 'wporg' ); ?></label>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <?php _e( 'Biweekly', 'wporg' ); ?>
+               </label><br />
+
+               <label for="occurrence">
+                       <input type="radio" name="recurring" value="occurrence" id="occurrence" class="regular-radio" <?php checked( $recurring, 'occurrence' ); ?>>
+                       <?php _e( 'Occurrence in a month:', 'wporg' ); ?>
+               </label>
+               <label for="week-1">
+                       <input type="checkbox" name="occurrence[]" value="1" id="week-1" <?php checked( in_array( 1, $occurrence ) ); ?>>
+                       <?php _e( '1st', 'wporg' ); ?>
+               </label>
+               <label for="week-2">
+                       <input type="checkbox" name="occurrence[]" value="2" id="week-2" <?php checked( in_array( 2, $occurrence ) ); ?>>
+                       <?php _e( '2nd', 'wporg' ); ?>
+               </label>
+               <label for="week-3">
+                       <input type="checkbox" name="occurrence[]" value="3" id="week-3" <?php checked( in_array( 3, $occurrence ) ); ?>>
+                       <?php _e( '3rd', 'wporg' ); ?>
+               </label>
+               <label for="week-4">
+                       <input type="checkbox" name="occurrence[]" value="4" id="week-4" <?php checked( in_array( 4, $occurrence ) ); ?>>
+                       <?php _e( '4th', 'wporg' ); ?>
+               </label><br />
+
+               <label for="monthly">
</ins><span class="cx" style="display: block; padding: 0 10px">                         <input type="radio" name="recurring" value="monthly" id="monthly" class="regular-radio" <?php checked( $recurring, 'monthly' ); ?>>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <label for="monthly"><?php _e( 'Monthly', 'wporg' ); ?></label>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <?php _e( 'Monthly', 'wporg' ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px">                 </label>
</span><span class="cx" style="display: block; padding: 0 10px">                </p>
</span><span class="cx" style="display: block; padding: 0 10px">                <p>
</span><span class="cx" style="display: block; padding: 0 10px">                <label for="link"><?php _e( 'Link: ', 'wporg' ); ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <input type="text" name="link" class="regular-text wide" value="<?php echo esc_url($link); ?>">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <input type="text" name="link" id="link" class="regular-text wide" value="<?php echo esc_url( $link ); ?>">
</ins><span class="cx" style="display: block; padding: 0 10px">                 </label>
</span><span class="cx" style="display: block; padding: 0 10px">                </p>
</span><span class="cx" style="display: block; padding: 0 10px">                <p>
</span><span class="cx" style="display: block; padding: 0 10px">                <label for="location"><?php _e( 'Location: ', 'wporg' ); ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <input type="text" id="location" name="location" class="regular-text wide" value="<?php echo esc_attr($location); ?>">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <input type="text" name="location" id="location" class="regular-text wide" value="<?php echo esc_attr( $location ); ?>">
</ins><span class="cx" style="display: block; padding: 0 10px">                 </label>
</span><span class="cx" style="display: block; padding: 0 10px">                </p>
</span><span class="cx" style="display: block; padding: 0 10px">                <script>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                jQuery(document).ready(function($){
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         jQuery(document).ready( function($) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $('.date').datepicker({
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                dateFormat: "yy-mm-dd"
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         dateFormat: 'yy-mm-dd'
</ins><span class="cx" style="display: block; padding: 0 10px">                         });
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $(document).on( 'keydown', '#title, #location', function( e ) {
-                               var keyCode = e.keyCode || e.which;
-                               if ( 9 == keyCode){
-                                       e.preventDefault();
-                                       var target = $(this).attr('id') == 'title' ? '#team' : 'textarea#content';
-                                       if ( (target === '#team') || $('#wp-content-wrap').hasClass('html-active') ) {
-                                               $(target).focus();
-                                       } else {
-                                               tinymce.execCommand('mceFocus',false,'content');
-                                       }
-                               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       $('input[name="recurring"]').change( function() {
+                               var disabled = ( 'occurrence' !== $(this).val() );
+                               $('#meeting-info').find('[name^="occurrence"]').prop('disabled', disabled);
</ins><span class="cx" style="display: block; padding: 0 10px">                         });
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       if ( 'occurrence' !== $('input[name="recurring"]:checked').val() ) {
+                               $('#meeting-info').find('[name^="occurrence"]').prop('disabled', true);
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px">                 });
</span><span class="cx" style="display: block; padding: 0 10px">                </script>
</span><span class="cx" style="display: block; padding: 0 10px">        <?php
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -327,7 +394,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Don't save for revisions
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( isset( $post->post_type ) && $post->post_type == 'revision' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( isset( $post->post_type ) && 'revision' === $post->post_type ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         return $post_id;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -336,21 +403,19 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return $post_id;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $team = ! isset( $meta['team'][0] ) ? '' : $meta['team'][0];
-               $start = ! isset( $meta['start_date'][0] ) ? '' : $meta['start_date'][0];
-               $end = ! isset( $meta['end_date'][0] ) ? '' : $meta['end_date'][0];
-               $recurring = ! isset( $meta['recurring'][0] ) ? '' : $meta['recurring'][0];
-               $link = ! isset( $meta['link'][0] ) ? '' : $meta['link'][0];
-               $location = ! isset( $meta['location'][0] ) ? '' : $meta['location'][0];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $meta['team']        = ( isset( $_POST['team'] ) ? esc_textarea( $_POST['team'] ) : '' );
+               $meta['start_date']  = ( isset( $_POST['start_date'] ) ? esc_textarea( $_POST['start_date'] ) : '' );
+               $meta['end_date']    = ( isset( $_POST['end_date'] ) ? esc_textarea( $_POST['end_date'] ) : '' );
+               $meta['time']        = ( isset( $_POST['time'] ) ? esc_textarea( $_POST['time'] ) : '' );
+               $meta['recurring']   = ( isset( $_POST['recurring'] )
+                                        && in_array( $_POST['recurring'], array( 'weekly', 'biweekly', 'occurrence', 'monthly' ) )
+                                        ? ( $_POST['recurring'] ) : '' );
+               $meta['occurrence']  = ( isset( $_POST['occurrence'] ) && 'occurrence' === $meta['recurring']
+                                        && is_array( $_POST['occurrence'] )
+                                        ? array_map( 'intval', $_POST['occurrence'] ) : array() );
+               $meta['link']        = ( isset( $_POST['link'] ) ? esc_url( $_POST['link'] ) : '' );
+               $meta['location']    = ( isset( $_POST['location'] ) ? esc_textarea( $_POST['location'] ) : '' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $meta['team'] = ( isset( $_POST['team'] ) ? esc_textarea( $_POST['team'] ) : '' );
-               $meta['start_date'] = ( isset( $_POST['start_date'] ) ? esc_textarea( $_POST['start_date'] ) : '' );
-               $meta['end_date'] = ( isset( $_POST['end_date'] ) ? esc_textarea( $_POST['end_date'] ) : '' );
-               $meta['time'] = ( isset( $_POST['time'] ) ? esc_textarea( $_POST['time'] ) : '' );
-               $meta['recurring'] = ( isset ( $_POST['recurring'] ) && ( in_array( $_POST['recurring'], array( 'weekly', 'biweekly', 'monthly' ) ) ) ? ( $_POST['recurring'] ) : '' );
-               $meta['link'] = ( isset( $_POST['link'] ) ? esc_url( $_POST['link'] ) : '' );
-               $meta['location'] = ( isset( $_POST['location'] ) ? esc_textarea( $_POST['location'] ) : '' );
-
</del><span class="cx" style="display: block; padding: 0 10px">                 foreach ( $meta as $key => $value ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        update_post_meta( $post->ID, $key, $value );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span></span></pre>
</div>
</div>

</body>
</html>