My Calendar - Version 3.1.16

Version Description

  • Bug fix: restricting styles & JS to specific pages broken by strict type checks.
  • New filter: mc_list_title_title
Download this release

Release Info

Developer joedolson
Plugin Icon 128x128 My Calendar
Version 3.1.16
Comparing to
See all releases

Code changes from version 3.1.13 to 3.1.16

css/reset.css CHANGED
@@ -84,6 +84,7 @@ div.site-content {
84
  position: absolute !important;
85
  width: 1px;
86
  word-wrap: normal !important;
 
87
  }
88
 
89
  button.mc-toggle {
84
  position: absolute !important;
85
  width: 1px;
86
  word-wrap: normal !important;
87
+ color: inherit;
88
  }
89
 
90
  button.mc-toggle {
includes/general-utilities.php CHANGED
@@ -383,7 +383,7 @@ function mc_newline_replace( $string ) {
383
  * @return array
384
  */
385
  function reverse_array( $array, $boolean, $order ) {
386
- if ( 'desc' == $order ) {
387
 
388
  return array_reverse( $array, $boolean );
389
  } else {
@@ -400,11 +400,11 @@ function reverse_array( $array, $boolean, $order ) {
400
  * @param string $email target email (if sending via email).
401
  */
402
  function mc_debug( $subject, $body, $email = false ) {
403
- if ( defined( 'MC_DEBUG' ) && true == MC_DEBUG ) {
404
  if ( ! $email ) {
405
  $email = get_option( 'admin_email' );
406
  }
407
- if ( defined( 'MC_DEBUG_METHOD' ) && 'email' == MC_DEBUG_METHOD ) {
408
  wp_mail( get_option( 'admin_email' ), $subject, print_r( $body ) );
409
  } else {
410
  do_action( 'mc_debug', $subject, $body );
383
  * @return array
384
  */
385
  function reverse_array( $array, $boolean, $order ) {
386
+ if ( 'desc' === $order ) {
387
 
388
  return array_reverse( $array, $boolean );
389
  } else {
400
  * @param string $email target email (if sending via email).
401
  */
402
  function mc_debug( $subject, $body, $email = false ) {
403
+ if ( defined( 'MC_DEBUG' ) && true === MC_DEBUG ) {
404
  if ( ! $email ) {
405
  $email = get_option( 'admin_email' );
406
  }
407
+ if ( defined( 'MC_DEBUG_METHOD' ) && 'email' === MC_DEBUG_METHOD ) {
408
  wp_mail( get_option( 'admin_email' ), $subject, print_r( $body ) );
409
  } else {
410
  do_action( 'mc_debug', $subject, $body );
includes/kses.php CHANGED
@@ -39,7 +39,7 @@ add_filter( 'wp_kses_allowed_html', 'mc_allowed_tags', 10, 2 );
39
  * @return return array tags
40
  */
41
  function mc_allowed_tags( $tags, $context ) {
42
- if ( 'mycalendar' == $context ) {
43
  global $allowedposttags;
44
  $tags = $allowedposttags;
45
 
39
  * @return return array tags
40
  */
41
  function mc_allowed_tags( $tags, $context ) {
42
+ if ( 'mycalendar' === $context ) {
43
  global $allowedposttags;
44
  $tags = $allowedposttags;
45
 
includes/screen-options.php CHANGED
@@ -37,7 +37,7 @@ add_filter( 'screen_settings', 'mc_show_event_editing', 10, 2 );
37
  */
38
  function mc_show_event_editing( $status, $args ) {
39
  $return = $status;
40
- if ( 'toplevel_page_my-calendar' == $args->base ) {
41
  $input_options = get_user_meta( get_current_user_id(), 'mc_show_on_page', true );
42
  $settings_options = get_option( 'mc_input_options' );
43
  if ( ! is_array( $input_options ) ) {
@@ -62,9 +62,9 @@ function mc_show_event_editing( $status, $args ) {
62
 
63
  $output = '';
64
  foreach ( $input_options as $key => $value ) {
65
- $checked = ( 'on' == $value ) ? "checked='checked'" : '';
66
- $allowed = ( isset( $settings_options[ $key ] ) && 'on' == $settings_options[ $key ] ) ? true : false;
67
- if ( ! ( current_user_can( 'manage_options' ) && 'true' == get_option( 'mc_input_options_administrators' ) ) && ! $allowed ) {
68
  // don't display options if this user can't use them.
69
  $output .= "<input type='hidden' name='mc_show_on_page[$key]' value='off' />";
70
  } else {
@@ -102,7 +102,7 @@ add_filter( 'set-screen-option', 'mc_set_event_editing', 11, 3 );
102
  * @return value
103
  */
104
  function mc_set_event_editing( $status, $option, $value ) {
105
- if ( 'mc_show_on_page' == $option ) {
106
  $orig = get_option( 'mc_input_options' );
107
  $value = array();
108
  foreach ( $orig as $k => $v ) {
37
  */
38
  function mc_show_event_editing( $status, $args ) {
39
  $return = $status;
40
+ if ( 'toplevel_page_my-calendar' === $args->base ) {
41
  $input_options = get_user_meta( get_current_user_id(), 'mc_show_on_page', true );
42
  $settings_options = get_option( 'mc_input_options' );
43
  if ( ! is_array( $input_options ) ) {
62
 
63
  $output = '';
64
  foreach ( $input_options as $key => $value ) {
65
+ $checked = ( 'on' === $value ) ? "checked='checked'" : '';
66
+ $allowed = ( isset( $settings_options[ $key ] ) && 'on' === $settings_options[ $key ] ) ? true : false;
67
+ if ( ! ( current_user_can( 'manage_options' ) && 'true' === get_option( 'mc_input_options_administrators' ) ) && ! $allowed ) {
68
  // don't display options if this user can't use them.
69
  $output .= "<input type='hidden' name='mc_show_on_page[$key]' value='off' />";
70
  } else {
102
  * @return value
103
  */
104
  function mc_set_event_editing( $status, $option, $value ) {
105
+ if ( 'mc_show_on_page' === $option ) {
106
  $orig = get_option( 'mc_input_options' );
107
  $value = array();
108
  foreach ( $orig as $k => $v ) {
includes/widgets/class-my-calendar-mini-widget.php CHANGED
@@ -198,11 +198,11 @@ class My_Calendar_Mini_Widget extends WP_Widget {
198
  for="<?php echo $this->get_field_id( 'my_calendar_mini_time' ); ?>"><?php _e( 'Mini-Calendar Timespan:', 'my-calendar' ); ?></label>
199
  <select id="<?php echo $this->get_field_id( 'my_calendar_mini_time' ); ?>" name="<?php echo $this->get_field_name( 'my_calendar_mini_time' ); ?>">
200
  <option
201
- value="month"<?php echo ( 'month' == $widget_time ) ? ' selected="selected"' : ''; ?>><?php _e( 'Month', 'my-calendar' ); ?></option>
202
  <option
203
- value="month+1"<?php echo ( 'month+1' == $widget_time ) ? ' selected="selected"' : ''; ?>><?php _e( 'Next Month', 'my-calendar' ); ?></option>
204
  <option
205
- value="week"<?php echo ( 'week' == $widget_time ) ? ' selected="selected"' : ''; ?>><?php _e( 'Week', 'my-calendar' ); ?></option>
206
  </select>
207
  </p>
208
  <p>
198
  for="<?php echo $this->get_field_id( 'my_calendar_mini_time' ); ?>"><?php _e( 'Mini-Calendar Timespan:', 'my-calendar' ); ?></label>
199
  <select id="<?php echo $this->get_field_id( 'my_calendar_mini_time' ); ?>" name="<?php echo $this->get_field_name( 'my_calendar_mini_time' ); ?>">
200
  <option
201
+ value="month"<?php echo ( 'month' === $widget_time ) ? ' selected="selected"' : ''; ?>><?php _e( 'Month', 'my-calendar' ); ?></option>
202
  <option
203
+ value="month+1"<?php echo ( 'month+1' === $widget_time ) ? ' selected="selected"' : ''; ?>><?php _e( 'Next Month', 'my-calendar' ); ?></option>
204
  <option
205
+ value="week"<?php echo ( 'week' === $widget_time ) ? ' selected="selected"' : ''; ?>><?php _e( 'Week', 'my-calendar' ); ?></option>
206
  </select>
207
  </p>
208
  <p>
includes/widgets/class-my-calendar-today-widget.php CHANGED
@@ -62,7 +62,7 @@ class My_Calendar_Today_Widget extends WP_Widget {
62
  $author = ( ! isset( $instance['my_calendar_today_author'] ) || '' == $instance['my_calendar_today_author'] ) ? 'all' : esc_attr( $instance['my_calendar_today_author'] );
63
  $host = ( ! isset( $instance['mc_host'] ) || '' == $instance['mc_host'] ) ? 'all' : esc_attr( $instance['mc_host'] );
64
  $default_link = mc_get_uri( false, $args );
65
- $widget_link = ( ! empty( $instance['my_calendar_today_linked'] ) && 'yes' == $instance['my_calendar_today_linked'] ) ? $default_link : '';
66
  $widget_link = ( ! empty( $instance['mc_link'] ) ) ? esc_url( $instance['mc_link'] ) : $widget_link;
67
  $widget_title = empty( $the_title ) ? '' : $the_title;
68
  $date = ( ! empty( $instance['mc_date'] ) ) ? $instance['mc_date'] : false;
@@ -109,7 +109,7 @@ class My_Calendar_Today_Widget extends WP_Widget {
109
  $widget_category = ( isset( $instance['my_calendar_today_category'] ) ) ? esc_attr( $instance['my_calendar_today_category'] ) : '';
110
  $widget_linked = ( isset( $instance['my_calendar_today_linked'] ) ) ? esc_attr( $instance['my_calendar_today_linked'] ) : '';
111
  $date = ( isset( $instance['mc_date'] ) ) ? esc_attr( $instance['mc_date'] ) : '';
112
- if ( 'yes' == $widget_linked ) {
113
  $default_link = mc_get_uri( false, $instance );
114
  } else {
115
  $default_link = '';
62
  $author = ( ! isset( $instance['my_calendar_today_author'] ) || '' == $instance['my_calendar_today_author'] ) ? 'all' : esc_attr( $instance['my_calendar_today_author'] );
63
  $host = ( ! isset( $instance['mc_host'] ) || '' == $instance['mc_host'] ) ? 'all' : esc_attr( $instance['mc_host'] );
64
  $default_link = mc_get_uri( false, $args );
65
+ $widget_link = ( ! empty( $instance['my_calendar_today_linked'] ) && 'yes' === $instance['my_calendar_today_linked'] ) ? $default_link : '';
66
  $widget_link = ( ! empty( $instance['mc_link'] ) ) ? esc_url( $instance['mc_link'] ) : $widget_link;
67
  $widget_title = empty( $the_title ) ? '' : $the_title;
68
  $date = ( ! empty( $instance['mc_date'] ) ) ? $instance['mc_date'] : false;
109
  $widget_category = ( isset( $instance['my_calendar_today_category'] ) ) ? esc_attr( $instance['my_calendar_today_category'] ) : '';
110
  $widget_linked = ( isset( $instance['my_calendar_today_linked'] ) ) ? esc_attr( $instance['my_calendar_today_linked'] ) : '';
111
  $date = ( isset( $instance['mc_date'] ) ) ? esc_attr( $instance['mc_date'] ) : '';
112
+ if ( 'yes' === $widget_linked ) {
113
  $default_link = mc_get_uri( false, $instance );
114
  } else {
115
  $default_link = '';
includes/widgets/class-my-calendar-upcoming-widget.php CHANGED
@@ -66,7 +66,7 @@ class My_Calendar_Upcoming_Widget extends WP_Widget {
66
  $before = ( '' != $before ) ? esc_attr( $instance['my_calendar_upcoming_before'] ) : 3;
67
  $after = ( '' != $after ) ? esc_attr( $instance['my_calendar_upcoming_after'] ) : 3;
68
  $skip = ( '' != $skip ) ? esc_attr( $instance['my_calendar_upcoming_skip'] ) : 0;
69
- $show_today = ( 'no' == $show ) ? 'no' : 'yes';
70
  $type = esc_attr( $type );
71
  $order = esc_attr( $order );
72
  $the_category = ( '' == $cat ) ? 'default' : esc_attr( $instance['my_calendar_upcoming_category'] );
@@ -74,7 +74,7 @@ class My_Calendar_Upcoming_Widget extends WP_Widget {
74
  $host = ( ! isset( $instance['mc_host'] ) || '' == $instance['mc_host'] ) ? 'default' : esc_attr( $instance['mc_host'] );
75
  $ltype = ( ! isset( $instance['ltype'] ) || '' == $instance['ltype'] ) ? '' : esc_attr( $instance['ltype'] );
76
  $lvalue = ( ! isset( $instance['lvalue'] ) || '' == $instance['lvalue'] ) ? '' : esc_attr( $instance['lvalue'] );
77
- $widget_link = ( isset( $instance['my_calendar_upcoming_linked'] ) && 'yes' == $instance['my_calendar_upcoming_linked'] ) ? mc_get_uri( false, $instance ) : '';
78
  $widget_link = ( ! empty( $instance['mc_link'] ) ) ? esc_url( $instance['mc_link'] ) : $widget_link;
79
  $widget_title = empty( $the_title ) ? '' : $the_title;
80
  $widget_title = ( '' == $widget_link ) ? $widget_title : "<a href='$widget_link'>$widget_title</a>";
@@ -141,7 +141,7 @@ class My_Calendar_Upcoming_Widget extends WP_Widget {
141
  $to = ( isset( $instance['mc_to'] ) ) ? esc_attr( $instance['mc_to'] ) : '';
142
  $site = ( isset( $instance['mc_site'] ) ) ? esc_attr( $instance['mc_site'] ) : false;
143
 
144
- if ( 'yes' == $linked ) {
145
  $default_link = mc_get_uri( false, $instance );
146
  } else {
147
  $default_link = '';
@@ -174,27 +174,27 @@ class My_Calendar_Upcoming_Widget extends WP_Widget {
174
  <p>
175
  <label for="<?php echo $this->get_field_id( 'my_calendar_upcoming_type' ); ?>"><?php _e( 'Display upcoming events by:', 'my-calendar' ); ?></label>
176
  <select id="<?php echo $this->get_field_id( 'my_calendar_upcoming_type' ); ?>" name="<?php echo $this->get_field_name( 'my_calendar_upcoming_type' ); ?>">
177
- <option value="events" <?php echo ( 'events' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Events (e.g. 2 past, 3 future)', 'my-calendar' ); ?></option>
178
- <option value="days" <?php echo ( 'days' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Dates (e.g. 4 days past, 5 forward)', 'my-calendar' ); ?></option>
179
- <option value="month" <?php echo ( 'month' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show current month', 'my-calendar' ); ?></option>
180
- <option value="month+1" <?php echo ( 'month+1' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show next month', 'my-calendar' ); ?></option>
181
- <option value="month+2" <?php echo ( 'month+2' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 2nd month out', 'my-calendar' ); ?></option>
182
- <option value="month+3" <?php echo ( 'month+3' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 3rd month out', 'my-calendar' ); ?></option>
183
- <option value="month+4" <?php echo ( 'month+4' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 4th month out', 'my-calendar' ); ?></option>
184
- <option value="month+5" <?php echo ( 'month+5' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 5th month out', 'my-calendar' ); ?></option>
185
- <option value="month+6" <?php echo ( 'month+6' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 6th month out', 'my-calendar' ); ?></option>
186
- <option value="month+7" <?php echo ( 'month+7' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 7th month out', 'my-calendar' ); ?></option>
187
- <option value="month+8" <?php echo ( 'month+8' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 8th month out', 'my-calendar' ); ?></option>
188
- <option value="month+9" <?php echo ( 'month+9' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 9th month out', 'my-calendar' ); ?></option>
189
- <option value="month+10" <?php echo ( 'month+10' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 10th month out', 'my-calendar' ); ?></option>
190
- <option value="month+11" <?php echo ( 'month+11' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 11th month out', 'my-calendar' ); ?></option>
191
- <option value="month+12" <?php echo ( 'month+12' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 12th month out', 'my-calendar' ); ?></option>
192
- <option value="year" <?php echo ( 'year' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show current year', 'my-calendar' ); ?></option>
193
- <option value="custom" <?php echo ( 'custom' == $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Custom Dates', 'my-calendar' ); ?></option>
194
  </select>
195
  </p>
196
  <?php
197
- if ( 'custom' == $type ) {
198
  ?>
199
  <p>
200
  <label for="<?php echo $this->get_field_id( 'mc_from' ); ?>"><?php _e( 'Start date', 'my-calendar' ); ?>:</label>
@@ -214,12 +214,12 @@ class My_Calendar_Upcoming_Widget extends WP_Widget {
214
  <p>
215
  <label for="<?php echo $this->get_field_id( 'my_calendar_upcoming_order' ); ?>"><?php _e( 'Events sort order:', 'my-calendar' ); ?></label>
216
  <select id="<?php echo $this->get_field_id( 'my_calendar_upcoming_order' ); ?>" name="<?php echo $this->get_field_name( 'my_calendar_upcoming_order' ); ?>">
217
- <option value="asc" <?php echo ( 'asc' == $order ) ? 'selected="selected"' : ''; ?>><?php _e( 'Ascending (near to far)', 'my-calendar' ); ?></option>
218
- <option value="desc" <?php echo ( 'desc' == $order ) ? 'selected="selected"' : ''; ?>><?php _e( 'Descending (far to near)', 'my-calendar' ); ?></option>
219
  </select>
220
  </p>
221
  <?php
222
- if ( ! ( 'month' == $type || 'month+1' == $type || 'year' == $type ) ) {
223
  ?>
224
  <p>
225
  <input type="text" id="<?php echo $this->get_field_id( 'my_calendar_upcoming_after' ); ?>" name="<?php echo $this->get_field_name( 'my_calendar_upcoming_after' ); ?>" value="<?php echo $after; ?>" size="1" maxlength="3"/>
@@ -240,7 +240,7 @@ class My_Calendar_Upcoming_Widget extends WP_Widget {
240
  }
241
  ?>
242
  <p>
243
- <input type="checkbox" id="<?php echo $this->get_field_id( 'my_calendar_upcoming_show_today' ); ?>" name="<?php echo $this->get_field_name( 'my_calendar_upcoming_show_today' ); ?>" value="yes"<?php echo ( 'yes' == $show_today ) ? ' checked="checked"' : ''; ?> />
244
  <label for="<?php echo $this->get_field_id( 'my_calendar_upcoming_show_today' ); ?>"><?php _e( "Include today's events", 'my-calendar' ); ?></label>
245
  </p>
246
  <p>
66
  $before = ( '' != $before ) ? esc_attr( $instance['my_calendar_upcoming_before'] ) : 3;
67
  $after = ( '' != $after ) ? esc_attr( $instance['my_calendar_upcoming_after'] ) : 3;
68
  $skip = ( '' != $skip ) ? esc_attr( $instance['my_calendar_upcoming_skip'] ) : 0;
69
+ $show_today = ( 'no' === $show ) ? 'no' : 'yes';
70
  $type = esc_attr( $type );
71
  $order = esc_attr( $order );
72
  $the_category = ( '' == $cat ) ? 'default' : esc_attr( $instance['my_calendar_upcoming_category'] );
74
  $host = ( ! isset( $instance['mc_host'] ) || '' == $instance['mc_host'] ) ? 'default' : esc_attr( $instance['mc_host'] );
75
  $ltype = ( ! isset( $instance['ltype'] ) || '' == $instance['ltype'] ) ? '' : esc_attr( $instance['ltype'] );
76
  $lvalue = ( ! isset( $instance['lvalue'] ) || '' == $instance['lvalue'] ) ? '' : esc_attr( $instance['lvalue'] );
77
+ $widget_link = ( isset( $instance['my_calendar_upcoming_linked'] ) && 'yes' === $instance['my_calendar_upcoming_linked'] ) ? mc_get_uri( false, $instance ) : '';
78
  $widget_link = ( ! empty( $instance['mc_link'] ) ) ? esc_url( $instance['mc_link'] ) : $widget_link;
79
  $widget_title = empty( $the_title ) ? '' : $the_title;
80
  $widget_title = ( '' == $widget_link ) ? $widget_title : "<a href='$widget_link'>$widget_title</a>";
141
  $to = ( isset( $instance['mc_to'] ) ) ? esc_attr( $instance['mc_to'] ) : '';
142
  $site = ( isset( $instance['mc_site'] ) ) ? esc_attr( $instance['mc_site'] ) : false;
143
 
144
+ if ( 'yes' === $linked ) {
145
  $default_link = mc_get_uri( false, $instance );
146
  } else {
147
  $default_link = '';
174
  <p>
175
  <label for="<?php echo $this->get_field_id( 'my_calendar_upcoming_type' ); ?>"><?php _e( 'Display upcoming events by:', 'my-calendar' ); ?></label>
176
  <select id="<?php echo $this->get_field_id( 'my_calendar_upcoming_type' ); ?>" name="<?php echo $this->get_field_name( 'my_calendar_upcoming_type' ); ?>">
177
+ <option value="events" <?php echo ( 'events' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Events (e.g. 2 past, 3 future)', 'my-calendar' ); ?></option>
178
+ <option value="days" <?php echo ( 'days' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Dates (e.g. 4 days past, 5 forward)', 'my-calendar' ); ?></option>
179
+ <option value="month" <?php echo ( 'month' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show current month', 'my-calendar' ); ?></option>
180
+ <option value="month+1" <?php echo ( 'month+1' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show next month', 'my-calendar' ); ?></option>
181
+ <option value="month+2" <?php echo ( 'month+2' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 2nd month out', 'my-calendar' ); ?></option>
182
+ <option value="month+3" <?php echo ( 'month+3' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 3rd month out', 'my-calendar' ); ?></option>
183
+ <option value="month+4" <?php echo ( 'month+4' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 4th month out', 'my-calendar' ); ?></option>
184
+ <option value="month+5" <?php echo ( 'month+5' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 5th month out', 'my-calendar' ); ?></option>
185
+ <option value="month+6" <?php echo ( 'month+6' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 6th month out', 'my-calendar' ); ?></option>
186
+ <option value="month+7" <?php echo ( 'month+7' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 7th month out', 'my-calendar' ); ?></option>
187
+ <option value="month+8" <?php echo ( 'month+8' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 8th month out', 'my-calendar' ); ?></option>
188
+ <option value="month+9" <?php echo ( 'month+9' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 9th month out', 'my-calendar' ); ?></option>
189
+ <option value="month+10" <?php echo ( 'month+10' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 10th month out', 'my-calendar' ); ?></option>
190
+ <option value="month+11" <?php echo ( 'month+11' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 11th month out', 'my-calendar' ); ?></option>
191
+ <option value="month+12" <?php echo ( 'month+12' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show 12th month out', 'my-calendar' ); ?></option>
192
+ <option value="year" <?php echo ( 'year' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Show current year', 'my-calendar' ); ?></option>
193
+ <option value="custom" <?php echo ( 'custom' === $type ) ? 'selected="selected"' : ''; ?>><?php _e( 'Custom Dates', 'my-calendar' ); ?></option>
194
  </select>
195
  </p>
196
  <?php
197
+ if ( 'custom' === $type ) {
198
  ?>
199
  <p>
200
  <label for="<?php echo $this->get_field_id( 'mc_from' ); ?>"><?php _e( 'Start date', 'my-calendar' ); ?>:</label>
214
  <p>
215
  <label for="<?php echo $this->get_field_id( 'my_calendar_upcoming_order' ); ?>"><?php _e( 'Events sort order:', 'my-calendar' ); ?></label>
216
  <select id="<?php echo $this->get_field_id( 'my_calendar_upcoming_order' ); ?>" name="<?php echo $this->get_field_name( 'my_calendar_upcoming_order' ); ?>">
217
+ <option value="asc" <?php echo ( 'asc' === $order ) ? 'selected="selected"' : ''; ?>><?php _e( 'Ascending (near to far)', 'my-calendar' ); ?></option>
218
+ <option value="desc" <?php echo ( 'desc' === $order ) ? 'selected="selected"' : ''; ?>><?php _e( 'Descending (far to near)', 'my-calendar' ); ?></option>
219
  </select>
220
  </p>
221
  <?php
222
+ if ( ! ( 'month' === $type || 'month+1' === $type || 'year' === $type ) ) {
223
  ?>
224
  <p>
225
  <input type="text" id="<?php echo $this->get_field_id( 'my_calendar_upcoming_after' ); ?>" name="<?php echo $this->get_field_name( 'my_calendar_upcoming_after' ); ?>" value="<?php echo $after; ?>" size="1" maxlength="3"/>
240
  }
241
  ?>
242
  <p>
243
+ <input type="checkbox" id="<?php echo $this->get_field_id( 'my_calendar_upcoming_show_today' ); ?>" name="<?php echo $this->get_field_name( 'my_calendar_upcoming_show_today' ); ?>" value="yes"<?php echo ( 'yes' === $show_today ) ? ' checked="checked"' : ''; ?> />
244
  <label for="<?php echo $this->get_field_id( 'my_calendar_upcoming_show_today' ); ?>"><?php _e( "Include today's events", 'my-calendar' ); ?></label>
245
  </p>
246
  <p>
my-calendar-api.php CHANGED
@@ -331,7 +331,7 @@ function mc_strip_to_xml( $value ) {
331
  $length = strlen( $value );
332
  for ( $i = 0; $i < $length; $i ++ ) {
333
  $current = ord( $value{$i} );
334
- if ( ( 0x9 == $current ) || ( 0xA == $current ) || ( 0xD == $current ) || ( ( $current >= 0x20 ) && ( $current <= 0xD7FF ) ) || ( ( $current >= 0xE000 ) && ( $current <= 0xFFFD ) ) || ( ( $current >= 0x10000 ) && ( $current <= 0x10FFFF ) ) ) {
335
  $ret .= chr( $current );
336
  } else {
337
  $ret .= ' ';
331
  $length = strlen( $value );
332
  for ( $i = 0; $i < $length; $i ++ ) {
333
  $current = ord( $value{$i} );
334
+ if ( ( 0x9 === $current ) || ( 0xA === $current ) || ( 0xD === $current ) || ( ( $current >= 0x20 ) && ( $current <= 0xD7FF ) ) || ( ( $current >= 0xE000 ) && ( $current <= 0xFFFD ) ) || ( ( $current >= 0x10000 ) && ( $current <= 0x10FFFF ) ) ) {
335
  $ret .= chr( $current );
336
  } else {
337
  $ret .= ' ';
my-calendar-categories.php CHANGED
@@ -90,7 +90,7 @@ function mc_private_categories() {
90
  function mc_get_private_categories() {
91
  global $wpdb;
92
  $mcdb = $wpdb;
93
- if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
94
  $mcdb = mc_remote_db();
95
  }
96
  $table = my_calendar_categories_table();
@@ -142,7 +142,7 @@ function my_calendar_manage_categories() {
142
  }
143
  }
144
 
145
- if ( isset( $_POST['mode'] ) && 'add' == $_POST['mode'] ) {
146
  $cat_id = mc_create_category( $_POST );
147
 
148
  if ( isset( $_POST['mc_default_category'] ) ) {
@@ -160,7 +160,7 @@ function my_calendar_manage_categories() {
160
  } else {
161
  mc_show_error( __( 'Category addition failed.', 'my-calendar' ) );
162
  }
163
- } elseif ( isset( $_GET['mode'] ) && isset( $_GET['category_id'] ) && 'delete' == $_GET['mode'] ) {
164
  $cat_id = (int) $_GET['category_id'];
165
  $results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . my_calendar_categories_table() . ' WHERE category_id=%d', $cat_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
166
 
@@ -184,10 +184,10 @@ function my_calendar_manage_categories() {
184
  } elseif ( ! $results && $cal_results ) {
185
  mc_show_error( __( 'Category not deleted. Categories in calendar updated.', 'my-calendar' ) );
186
  }
187
- } elseif ( isset( $_GET['mode'] ) && isset( $_GET['category_id'] ) && 'edit' == $_GET['mode'] && ! isset( $_POST['mode'] ) ) {
188
  $cur_cat = (int) $_GET['category_id'];
189
  mc_edit_category_form( 'edit', $cur_cat );
190
- } elseif ( isset( $_POST['mode'] ) && isset( $_POST['category_id'] ) && isset( $_POST['category_name'] ) && isset( $_POST['category_color'] ) && 'edit' == $_POST['mode'] ) {
191
  $append = '';
192
  if ( isset( $_POST['mc_default_category'] ) ) {
193
  update_option( 'mc_default_category', (int) $_POST['category_id'] );
@@ -291,7 +291,7 @@ function mc_create_category( $category ) {
291
  'category_name' => $category['category_name'],
292
  'category_color' => $category['category_color'],
293
  'category_icon' => $category['category_icon'],
294
- 'category_private' => ( ( isset( $category['category_private'] ) && ( 'on' == $category['category_private'] || 1 == $category['category_private'] ) ) ? 1 : 0 ),
295
  'category_term' => $term,
296
  );
297
 
@@ -328,7 +328,7 @@ function mc_edit_category_form( $view = 'edit', $cat_id = '' ) {
328
  $path = '/' . dirname( plugin_basename( __FILE__ ) ) . '/images/icons';
329
  $iconlist = mc_directory_list( $directory );
330
  }
331
- if ( 'add' == $view ) {
332
  ?>
333
  <h1><?php _e( 'Add Category', 'my-calendar' ); ?></h1>
334
  <?php
@@ -351,7 +351,7 @@ function mc_edit_category_form( $view = 'edit', $cat_id = '' ) {
351
  <form id="my-calendar" method="post" action="<?php echo admin_url( 'admin.php?page=my-calendar-categories' ); ?>">
352
  <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'my-calendar-nonce' ); ?>"/></div>
353
  <?php
354
- if ( 'add' == $view ) {
355
  ?>
356
  <div>
357
  <input type="hidden" name="mode" value="add"/>
@@ -387,7 +387,7 @@ function mc_edit_category_form( $view = 'edit', $cat_id = '' ) {
387
  <input type="text" id="cat_color" name="category_color" class="mc-color-input" size="10" maxlength="7" value="<?php echo ( '#' != $color ) ? esc_attr( $color ) : ''; ?>"/>
388
  </li>
389
  <?php
390
- if ( 'true' == get_option( 'mc_hide_icons' ) ) {
391
  echo "<input type='hidden' name='category_icon' value='' />";
392
  } else {
393
  ?>
@@ -408,7 +408,7 @@ function mc_edit_category_form( $view = 'edit', $cat_id = '' ) {
408
  ?>
409
  <li>
410
  <?php
411
- if ( 'add' == $view ) {
412
  $private_checked = '';
413
  } else {
414
  if ( ! empty( $cur_cat ) && is_object( $cur_cat ) && 1 == $cur_cat->category_private ) {
@@ -417,8 +417,8 @@ function mc_edit_category_form( $view = 'edit', $cat_id = '' ) {
417
  $private_checked = '';
418
  }
419
  }
420
- $checked = ( 'add' == $view ) ? '' : mc_is_checked( 'mc_default_category', $cur_cat->category_id, '', true );
421
- $holiday_checked = ( 'add' == $view ) ? '' : mc_is_checked( 'mc_skip_holidays_category', $cur_cat->category_id, '', true );
422
  ?>
423
  <ul class='checkboxes'>
424
  <li>
@@ -435,7 +435,7 @@ function mc_edit_category_form( $view = 'edit', $cat_id = '' ) {
435
  <?php echo apply_filters( 'mc_category_fields', '', $cur_cat ); ?>
436
  </ul>
437
  <?php
438
- if ( 'add' == $view ) {
439
  $save_text = __( 'Add Category', 'my-calendar' );
440
  } else {
441
  $save_text = __( 'Save Changes', 'my-calendar' );
@@ -449,7 +449,7 @@ function mc_edit_category_form( $view = 'edit', $cat_id = '' ) {
449
  </div>
450
  </div>
451
  </div>
452
- <?php if ( 'edit' == $view ) { ?>
453
  <p>
454
  <a href="<?php echo admin_url( 'admin.php?page=my-calendar-categories' ); ?>"><?php _e( 'Add a New Category', 'my-calendar' ); ?> &raquo;</a>
455
  </p>
@@ -479,9 +479,9 @@ function mc_category_settings_update() {
479
  $message = '';
480
  $nonce = ( isset( $_POST['_wpnonce'] ) ) ? $_POST['_wpnonce'] : false;
481
  if ( isset( $_POST['mc_category_settings'] ) && wp_verify_nonce( $nonce, 'my-calendar-nonce' ) ) {
482
- update_option( 'mc_hide_icons', ( ! empty( $_POST['mc_hide_icons'] ) && 'on' == $_POST['mc_hide_icons'] ) ? 'true' : 'false' );
483
  update_option( 'mc_apply_color', $_POST['mc_apply_color'] );
484
- update_option( 'mc_multiple_categories', ( ! empty( $_POST['mc_multiple_categories'] ) && 'on' == $_POST['mc_multiple_categories'] ) ? 'true' : 'false' );
485
 
486
  $message = mc_show_notice( __( 'My Calendar Category Configuration Updated', 'my-calendar' ), false );
487
  }
@@ -545,7 +545,7 @@ function mc_category_settings() {
545
  function mc_get_category_detail( $cat_id, $field = 'category_name' ) {
546
  global $wpdb;
547
  $mcdb = $wpdb;
548
- if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
549
  $mcdb = mc_remote_db();
550
  }
551
 
@@ -570,7 +570,7 @@ function mc_get_category_detail( $cat_id, $field = 'category_name' ) {
570
  function mc_category_by_name( $string ) {
571
  global $wpdb;
572
  $mcdb = $wpdb;
573
- if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
574
  $mcdb = mc_remote_db();
575
  }
576
  $cat_id = false;
@@ -637,7 +637,7 @@ function mc_manage_categories() {
637
  <?php
638
  $class = '';
639
  foreach ( $categories as $cat ) {
640
- $class = ( 'alternate' == $class ) ? '' : 'alternate';
641
  if ( '' != $cat->category_icon && 'true' != get_option( 'mc_hide_icons' ) ) {
642
  $icon_src = ( mc_file_exists( $cat->category_icon ) ) ? mc_get_file( $cat->category_icon, 'url' ) : plugins_url( 'my-calendar/images/icons/' . $cat->category_icon );
643
  } else {
@@ -721,7 +721,7 @@ function mc_profile() {
721
  </th>
722
  <td>
723
  <ul class='checkboxes'>
724
- <li><input type="checkbox" name="mc_user_permisions[]" value="all" id="mc_edit_all" <?php echo $selected; ?>> <label for="mc_edit_all"><?php _e( 'Edit All Categories', 'my-calendar' ); ?></li>
725
  <?php echo mc_category_select( $permissions, true, true, 'mc_user_permissions[]' ); ?>
726
  </ul>
727
  </td>
@@ -769,7 +769,7 @@ function mc_save_profile() {
769
  function mc_category_select( $data = false, $option = true, $multiple = false, $name = false ) {
770
  global $wpdb;
771
  $mcdb = $wpdb;
772
- if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
773
  $mcdb = mc_remote_db();
774
  }
775
  if ( ! $name ) {
@@ -802,7 +802,7 @@ function mc_category_select( $data = false, $option = true, $multiple = false, $
802
  if ( ! empty( $data ) ) {
803
  if ( ! is_object( $data ) ) {
804
  $category = $data;
805
- } elseif ( is_array( $data ) && $multiple && 'mc_user_permissions[]' == $name ) {
806
  $category = $data;
807
  } else {
808
  if ( $multiple ) {
@@ -828,7 +828,7 @@ function mc_category_select( $data = false, $option = true, $multiple = false, $
828
  $category_name = strip_tags( stripslashes( trim( $cat->category_name ) ) );
829
  $category_name = ( '' === $category_name ) ? '(' . __( 'Untitled category', 'my-calendar' ) . ')' : $category_name;
830
  if ( $multiple ) {
831
- $c = '<li><input type="checkbox" name="' . esc_attr( $name ) . '" id="mc_cat_' . $cat->category_id . '" value="' . $cat->category_id . '" ' . $selected . ' /><label for="mc_cat_' . $cat->category_id . '">' . $category_name . '</label></li>';
832
  } else {
833
  $c = '<option value="' . $cat->category_id . '" ' . $selected . '>' . $category_name . '</option>';
834
  }
@@ -863,7 +863,7 @@ function mc_category_select( $data = false, $option = true, $multiple = false, $
863
  function mc_get_categories( $event, $ids = true ) {
864
  global $wpdb;
865
  $mcdb = $wpdb;
866
- if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
867
  $mcdb = mc_remote_db();
868
  }
869
 
@@ -880,7 +880,7 @@ function mc_get_categories( $event, $ids = true ) {
880
  $primary = mc_get_data( 'event_category', $event_id );
881
  } else {
882
 
883
- return ( 'html' == $ids ) ? '' : array();
884
  }
885
 
886
  if ( ! $results ) {
@@ -896,9 +896,9 @@ function mc_get_categories( $event, $ids = true ) {
896
  } else {
897
  $return[] = $primary;
898
  }
899
- } elseif ( 'html' == $ids ) {
900
  $return = mc_categories_html( $results, $primary );
901
- } elseif ( 'testing' == $ids ) {
902
  if ( $results ) {
903
  foreach ( $results as $result ) {
904
  $return[] = $result->category_id;
90
  function mc_get_private_categories() {
91
  global $wpdb;
92
  $mcdb = $wpdb;
93
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
94
  $mcdb = mc_remote_db();
95
  }
96
  $table = my_calendar_categories_table();
142
  }
143
  }
144
 
145
+ if ( isset( $_POST['mode'] ) && 'add' === $_POST['mode'] ) {
146
  $cat_id = mc_create_category( $_POST );
147
 
148
  if ( isset( $_POST['mc_default_category'] ) ) {
160
  } else {
161
  mc_show_error( __( 'Category addition failed.', 'my-calendar' ) );
162
  }
163
+ } elseif ( isset( $_GET['mode'] ) && isset( $_GET['category_id'] ) && 'delete' === $_GET['mode'] ) {
164
  $cat_id = (int) $_GET['category_id'];
165
  $results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . my_calendar_categories_table() . ' WHERE category_id=%d', $cat_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
166
 
184
  } elseif ( ! $results && $cal_results ) {
185
  mc_show_error( __( 'Category not deleted. Categories in calendar updated.', 'my-calendar' ) );
186
  }
187
+ } elseif ( isset( $_GET['mode'] ) && isset( $_GET['category_id'] ) && 'edit' === $_GET['mode'] && ! isset( $_POST['mode'] ) ) {
188
  $cur_cat = (int) $_GET['category_id'];
189
  mc_edit_category_form( 'edit', $cur_cat );
190
+ } elseif ( isset( $_POST['mode'] ) && isset( $_POST['category_id'] ) && isset( $_POST['category_name'] ) && isset( $_POST['category_color'] ) && 'edit' === $_POST['mode'] ) {
191
  $append = '';
192
  if ( isset( $_POST['mc_default_category'] ) ) {
193
  update_option( 'mc_default_category', (int) $_POST['category_id'] );
291
  'category_name' => $category['category_name'],
292
  'category_color' => $category['category_color'],
293
  'category_icon' => $category['category_icon'],
294
+ 'category_private' => ( ( isset( $category['category_private'] ) && ( 'on' === $category['category_private'] || 1 == $category['category_private'] ) ) ? 1 : 0 ),
295
  'category_term' => $term,
296
  );
297
 
328
  $path = '/' . dirname( plugin_basename( __FILE__ ) ) . '/images/icons';
329
  $iconlist = mc_directory_list( $directory );
330
  }
331
+ if ( 'add' === $view ) {
332
  ?>
333
  <h1><?php _e( 'Add Category', 'my-calendar' ); ?></h1>
334
  <?php
351
  <form id="my-calendar" method="post" action="<?php echo admin_url( 'admin.php?page=my-calendar-categories' ); ?>">
352
  <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'my-calendar-nonce' ); ?>"/></div>
353
  <?php
354
+ if ( 'add' === $view ) {
355
  ?>
356
  <div>
357
  <input type="hidden" name="mode" value="add"/>
387
  <input type="text" id="cat_color" name="category_color" class="mc-color-input" size="10" maxlength="7" value="<?php echo ( '#' != $color ) ? esc_attr( $color ) : ''; ?>"/>
388
  </li>
389
  <?php
390
+ if ( 'true' === get_option( 'mc_hide_icons' ) ) {
391
  echo "<input type='hidden' name='category_icon' value='' />";
392
  } else {
393
  ?>
408
  ?>
409
  <li>
410
  <?php
411
+ if ( 'add' === $view ) {
412
  $private_checked = '';
413
  } else {
414
  if ( ! empty( $cur_cat ) && is_object( $cur_cat ) && 1 == $cur_cat->category_private ) {
417
  $private_checked = '';
418
  }
419
  }
420
+ $checked = ( 'add' === $view ) ? '' : mc_is_checked( 'mc_default_category', $cur_cat->category_id, '', true );
421
+ $holiday_checked = ( 'add' === $view ) ? '' : mc_is_checked( 'mc_skip_holidays_category', $cur_cat->category_id, '', true );
422
  ?>
423
  <ul class='checkboxes'>
424
  <li>
435
  <?php echo apply_filters( 'mc_category_fields', '', $cur_cat ); ?>
436
  </ul>
437
  <?php
438
+ if ( 'add' === $view ) {
439
  $save_text = __( 'Add Category', 'my-calendar' );
440
  } else {
441
  $save_text = __( 'Save Changes', 'my-calendar' );
449
  </div>
450
  </div>
451
  </div>
452
+ <?php if ( 'edit' === $view ) { ?>
453
  <p>
454
  <a href="<?php echo admin_url( 'admin.php?page=my-calendar-categories' ); ?>"><?php _e( 'Add a New Category', 'my-calendar' ); ?> &raquo;</a>
455
  </p>
479
  $message = '';
480
  $nonce = ( isset( $_POST['_wpnonce'] ) ) ? $_POST['_wpnonce'] : false;
481
  if ( isset( $_POST['mc_category_settings'] ) && wp_verify_nonce( $nonce, 'my-calendar-nonce' ) ) {
482
+ update_option( 'mc_hide_icons', ( ! empty( $_POST['mc_hide_icons'] ) && 'on' === $_POST['mc_hide_icons'] ) ? 'true' : 'false' );
483
  update_option( 'mc_apply_color', $_POST['mc_apply_color'] );
484
+ update_option( 'mc_multiple_categories', ( ! empty( $_POST['mc_multiple_categories'] ) && 'on' === $_POST['mc_multiple_categories'] ) ? 'true' : 'false' );
485
 
486
  $message = mc_show_notice( __( 'My Calendar Category Configuration Updated', 'my-calendar' ), false );
487
  }
545
  function mc_get_category_detail( $cat_id, $field = 'category_name' ) {
546
  global $wpdb;
547
  $mcdb = $wpdb;
548
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
549
  $mcdb = mc_remote_db();
550
  }
551
 
570
  function mc_category_by_name( $string ) {
571
  global $wpdb;
572
  $mcdb = $wpdb;
573
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
574
  $mcdb = mc_remote_db();
575
  }
576
  $cat_id = false;
637
  <?php
638
  $class = '';
639
  foreach ( $categories as $cat ) {
640
+ $class = ( 'alternate' === $class ) ? '' : 'alternate';
641
  if ( '' != $cat->category_icon && 'true' != get_option( 'mc_hide_icons' ) ) {
642
  $icon_src = ( mc_file_exists( $cat->category_icon ) ) ? mc_get_file( $cat->category_icon, 'url' ) : plugins_url( 'my-calendar/images/icons/' . $cat->category_icon );
643
  } else {
721
  </th>
722
  <td>
723
  <ul class='checkboxes'>
724
+ <li><input type="checkbox" name="mc_user_permissions[]" value="all" id="mc_edit_all" <?php echo $selected; ?>> <label for="mc_edit_all"><?php _e( 'Edit All Categories', 'my-calendar' ); ?></li>
725
  <?php echo mc_category_select( $permissions, true, true, 'mc_user_permissions[]' ); ?>
726
  </ul>
727
  </td>
769
  function mc_category_select( $data = false, $option = true, $multiple = false, $name = false ) {
770
  global $wpdb;
771
  $mcdb = $wpdb;
772
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
773
  $mcdb = mc_remote_db();
774
  }
775
  if ( ! $name ) {
802
  if ( ! empty( $data ) ) {
803
  if ( ! is_object( $data ) ) {
804
  $category = $data;
805
+ } elseif ( is_array( $data ) && $multiple && 'mc_user_permissions[]' === $name ) {
806
  $category = $data;
807
  } else {
808
  if ( $multiple ) {
828
  $category_name = strip_tags( stripslashes( trim( $cat->category_name ) ) );
829
  $category_name = ( '' === $category_name ) ? '(' . __( 'Untitled category', 'my-calendar' ) . ')' : $category_name;
830
  if ( $multiple ) {
831
+ $c = '<li class="mc_cat_' . $cat->category_id . '"><input type="checkbox" name="' . esc_attr( $name ) . '" id="mc_cat_' . $cat->category_id . '" value="' . $cat->category_id . '" ' . $selected . ' /> <label for="mc_cat_' . $cat->category_id . '">' . $category_name . '</label></li>';
832
  } else {
833
  $c = '<option value="' . $cat->category_id . '" ' . $selected . '>' . $category_name . '</option>';
834
  }
863
  function mc_get_categories( $event, $ids = true ) {
864
  global $wpdb;
865
  $mcdb = $wpdb;
866
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
867
  $mcdb = mc_remote_db();
868
  }
869
 
880
  $primary = mc_get_data( 'event_category', $event_id );
881
  } else {
882
 
883
+ return ( 'html' === $ids ) ? '' : array();
884
  }
885
 
886
  if ( ! $results ) {
896
  } else {
897
  $return[] = $primary;
898
  }
899
+ } elseif ( 'html' === $ids ) {
900
  $return = mc_categories_html( $results, $primary );
901
+ } elseif ( 'testing' === $ids ) {
902
  if ( $results ) {
903
  foreach ( $results as $result ) {
904
  $return[] = $result->category_id;
my-calendar-core.php CHANGED
@@ -67,8 +67,8 @@ function mc_plugin_action( $links, $file ) {
67
  function mc_custom_dirs( $type = 'path' ) {
68
  $dirs = array();
69
 
70
- $dirs[] = ( 'path' === $type ) ? plugin_dir_path( __FILE__ ) . 'my-calendar-custom/styles/' : plugin_dir_url( __FILE__ ) . 'my-calendar-custom/styles/';
71
- $dirs[] = ( 'path' === $type ) ? plugin_dir_path( __FILE__ ) . 'my-calendar-custom/' : plugin_dir_url( __FILE__ ) . 'my-calendar-custom/';
72
  $dirs[] = ( 'path' === $type ) ? get_stylesheet_directory() . '/css/' : get_stylesheet_directory_uri() . '/css/';
73
  $dirs[] = ( 'path' === $type ) ? get_stylesheet_directory() . '/' : get_stylesheet_directory_uri() . '/';
74
 
@@ -148,14 +148,17 @@ function mc_register_styles() {
148
  wp_enqueue_style( 'my-calendar-admin-style' );
149
  }
150
 
151
- $default = apply_filters( 'mc_display_css_on_archives', true, $wp_query );
152
- $id = ( is_object( $this_post ) && isset( $this_post->ID ) ) ? $this_post->ID : false;
153
- $js_array = ( '' !== get_option( 'mc_show_js', '' ) ) ? explode( ',', get_option( 'mc_show_js' ) ) : array();
154
- $css_array = ( '' !== get_option( 'mc_show_css', '' ) ) ? explode( ',', get_option( 'mc_show_css' ) ) : array();
 
 
 
155
 
156
  // check whether any scripts are actually enabled.
157
- if ( get_option( 'mc_calendar_javascript' ) != 1 || get_option( 'mc_list_javascript' ) != 1 || get_option( 'mc_mini_javascript' ) != 1 || get_option( 'mc_ajax_javascript' ) != 1 ) {
158
- if ( is_array( $js_array ) && in_array( $id, $js_array ) || '' == get_option( 'mc_show_js' ) || is_singular( 'mc-events' ) ) {
159
  wp_enqueue_script( 'jquery' );
160
  if ( 'true' === get_option( 'mc_gmap' ) ) {
161
  $api_key = get_option( 'mc_gmap_api_key' );
@@ -168,7 +171,7 @@ function mc_register_styles() {
168
  }
169
  // True means styles are disabled.
170
  if ( 'true' !== get_option( 'mc_use_styles' ) ) {
171
- if ( ( $default && ! $id ) || ( is_array( $css_array ) && in_array( $id, $css_array ) || get_option( 'mc_show_css', '' ) === '' ) ) {
172
  wp_enqueue_style( 'my-calendar-style' );
173
  }
174
  }
@@ -199,9 +202,9 @@ function my_calendar_head() {
199
 
200
  if ( get_option( 'mc_use_styles' ) !== 'true' ) {
201
  $this_post = $wp_query->get_queried_object();
202
- $id = ( is_object( $this_post ) && isset( $this_post->ID ) ) ? $this_post->ID : false;
203
  $array = ( '' !== get_option( 'mc_show_css', '' ) ) ? explode( ',', get_option( 'mc_show_css' ) ) : $array;
204
- if ( is_array( $array ) && in_array( $id, $array ) || get_option( 'mc_show_css', '' ) === '' ) {
205
  // generate category colors.
206
  $category_styles = '';
207
  $inv = '';
@@ -348,12 +351,13 @@ function mc_footer_js() {
348
 
349
  return;
350
  } else {
351
- $pages = array();
352
- if ( get_option( 'mc_show_js', '' ) !== '' ) {
353
- $pages = explode( ',', get_option( 'mc_show_js' ) );
 
354
  }
355
  if ( is_object( $wp_query ) && isset( $wp_query->post ) ) {
356
- $id = $wp_query->post->ID;
357
  } else {
358
  $id = false;
359
  }
@@ -378,17 +382,18 @@ function mc_footer_js() {
378
  }
379
  $ajax_js = stripcslashes( get_option( 'mc_ajaxjs' ) );
380
  $inner = '';
381
- if ( ( is_array( $pages ) && in_array( $id, $pages ) ) || '' === get_option( 'mc_show_js', '' ) ) {
382
- if ( get_option( 'mc_calendar_javascript' ) != 1 ) {
 
383
  $inner .= "\n" . $cal_js;
384
  }
385
- if ( get_option( 'mc_list_javascript' ) != 1 ) {
386
  $inner .= "\n" . $list_js;
387
  }
388
- if ( get_option( 'mc_mini_javascript' ) != 1 ) {
389
  $inner .= "\n" . $mini_js;
390
  }
391
- if ( get_option( 'mc_ajax_javascript' ) != 1 ) {
392
  $inner .= "\n" . $ajax_js;
393
  }
394
  $script = '
@@ -400,26 +405,26 @@ function mc_footer_js() {
400
  echo ( '' !== $inner ) ? $script . $mcjs : '';
401
  } else {
402
  $enqueue_mcjs = false;
403
- if ( ( is_array( $pages ) && in_array( $id, $pages ) ) || '' === get_option( 'mc_show_js', '' ) ) {
404
- if ( 1 != get_option( 'mc_calendar_javascript' ) && 'true' !== get_option( 'mc_open_uri' ) ) {
405
  $url = apply_filters( 'mc_grid_js', plugins_url( 'js/mc-grid.js', __FILE__ ) );
406
  $enqueue_mcjs = true;
407
  wp_enqueue_script( 'mc.grid', $url, array( 'jquery' ) );
408
  wp_localize_script( 'mc.grid', 'mcgrid', 'true' );
409
  }
410
- if ( 1 != get_option( 'mc_list_javascript' ) ) {
411
  $url = apply_filters( 'mc_list_js', plugins_url( 'js/mc-list.js', __FILE__ ) );
412
  $enqueue_mcjs = true;
413
  wp_enqueue_script( 'mc.list', $url, array( 'jquery' ) );
414
  wp_localize_script( 'mc.list', 'mclist', 'true' );
415
  }
416
- if ( 1 != get_option( 'mc_mini_javascript' ) && 'true' !== get_option( 'mc_open_day_uri' ) ) {
417
  $url = apply_filters( 'mc_mini_js', plugins_url( 'js/mc-mini.js', __FILE__ ) );
418
  $enqueue_mcjs = true;
419
  wp_enqueue_script( 'mc.mini', $url, array( 'jquery' ) );
420
  wp_localize_script( 'mc.mini', 'mcmini', 'true' );
421
  }
422
- if ( 1 != get_option( 'mc_ajax_javascript' ) ) {
423
  $url = apply_filters( 'mc_ajax_js', plugins_url( 'js/mc-ajax.js', __FILE__ ) );
424
  $enqueue_mcjs = true;
425
  wp_enqueue_script( 'mc.ajax', $url, array( 'jquery' ) );
@@ -917,7 +922,7 @@ function mc_spam( $event_url = '', $description = '', $post = array() ) {
917
  $ignore = array( 'HTTP_COOKIE' );
918
 
919
  foreach ( $_SERVER as $key => $value ) {
920
- if ( ! in_array( $key, (array) $ignore ) ) {
921
  $c[ "$key" ] = $value;
922
  }
923
  }
@@ -1439,7 +1444,7 @@ $plugins_string
1439
  $sitename = substr( $sitename, 4 );
1440
  }
1441
  $from_email = 'wordpress@' . $sitename;
1442
- $from = "From: \"$current_user->username\" <$from_email>\r\nReply-to: \"$current_user->username\" <$current_user->user_email>\r\n";
1443
 
1444
  if ( ! $has_read_faq ) {
1445
  echo '<div class="message error"><p>' . __( 'Please read the FAQ and other Help documents before making a support request.', 'my-calendar' ) . '</p></div>';
@@ -1589,7 +1594,7 @@ function mc_posttypes() {
1589
  'exclude_from_search' => $raw['exclude_from_search'],
1590
  'show_ui' => $raw['show_ui'],
1591
  'show_in_menu' => $raw['show_in_menu'],
1592
- 'menu_icon' => ( null == $raw['menu_icon'] ) ? plugins_url( 'images', __FILE__ ) . '/icon.png' : $raw['menu_icon'],
1593
  'query_var' => true,
1594
  'rewrite' => array(
1595
  'with_front' => false,
@@ -1728,7 +1733,7 @@ add_action( 'admin_notices', 'mc_update_notice' );
1728
  */
1729
  function mc_update_notice() {
1730
  // Deprecate this notice when 2.3 no longer in upgrade cycles.
1731
- if ( current_user_can( 'activate_plugins' ) && 0 == get_option( 'mc_update_notice' ) || ! get_option( 'mc_update_notice' ) ) {
1732
  $dismiss = admin_url( 'admin.php?page=my-calendar-behaviors&dismiss=update' );
1733
  // Translators: URL to scripts manager.
1734
  echo "<div class='updated'><p>" . sprintf( __( "<strong>Update notice:</strong> if you use custom JS with My Calendar, you need to activate your custom scripts following this update. <a href='%s'>Dismiss Notice</a>", 'my-calendar' ), $dismiss ) . '</p></div>';
67
  function mc_custom_dirs( $type = 'path' ) {
68
  $dirs = array();
69
 
70
+ $dirs[] = ( 'path' === $type ) ? plugin_dir_path( __DIR__ ) . 'my-calendar-custom/styles/' : plugin_dir_url( __DIR__ ) . 'my-calendar-custom/styles/';
71
+ $dirs[] = ( 'path' === $type ) ? plugin_dir_path( __DIR__ ) . 'my-calendar-custom/' : plugin_dir_url( __DIR__ ) . 'my-calendar-custom/';
72
  $dirs[] = ( 'path' === $type ) ? get_stylesheet_directory() . '/css/' : get_stylesheet_directory_uri() . '/css/';
73
  $dirs[] = ( 'path' === $type ) ? get_stylesheet_directory() . '/' : get_stylesheet_directory_uri() . '/';
74
 
148
  wp_enqueue_style( 'my-calendar-admin-style' );
149
  }
150
 
151
+ $default = apply_filters( 'mc_display_css_on_archives', true, $wp_query );
152
+ $id = ( is_object( $this_post ) && isset( $this_post->ID ) ) ? $this_post->ID : false;
153
+ $js_array = ( '' !== trim( get_option( 'mc_show_js', '' ) ) ) ? explode( ',', get_option( 'mc_show_js' ) ) : array();
154
+ $css_array = ( '' !== trim( get_option( 'mc_show_css', '' ) ) ) ? explode( ',', get_option( 'mc_show_css' ) ) : array();
155
+ $use_default = ( $default && ! $id ) ? true : false;
156
+ $js_usage = ( ( empty( $js_array ) ) || ( $id && in_array( $id, $js_array ) ) ) ? true : false;
157
+ $css_usage = ( ( empty( $css_array ) ) || ( $id && in_array( $id, $css_array ) ) ) ? true : false;
158
 
159
  // check whether any scripts are actually enabled.
160
+ if ( get_option( 'mc_calendar_javascript' ) !== '1' || get_option( 'mc_list_javascript' ) !== '1' || get_option( 'mc_mini_javascript' ) !== '1' || get_option( 'mc_ajax_javascript' ) !== '1' ) {
161
+ if ( $use_default || $js_usage || is_singular( 'mc-events' ) ) {
162
  wp_enqueue_script( 'jquery' );
163
  if ( 'true' === get_option( 'mc_gmap' ) ) {
164
  $api_key = get_option( 'mc_gmap_api_key' );
171
  }
172
  // True means styles are disabled.
173
  if ( 'true' !== get_option( 'mc_use_styles' ) ) {
174
+ if ( $use_default || $css_usage ) {
175
  wp_enqueue_style( 'my-calendar-style' );
176
  }
177
  }
202
 
203
  if ( get_option( 'mc_use_styles' ) !== 'true' ) {
204
  $this_post = $wp_query->get_queried_object();
205
+ $id = (string) ( is_object( $this_post ) && isset( $this_post->ID ) ) ? $this_post->ID : false;
206
  $array = ( '' !== get_option( 'mc_show_css', '' ) ) ? explode( ',', get_option( 'mc_show_css' ) ) : $array;
207
+ if ( ( is_array( $array ) && ! empty( $array ) ) || in_array( $id, $array, true ) || get_option( 'mc_show_css', '' ) === '' ) {
208
  // generate category colors.
209
  $category_styles = '';
210
  $inv = '';
351
 
352
  return;
353
  } else {
354
+ $pages = array();
355
+ $show_js = get_option( 'mc_show_js', '' );
356
+ if ( '' !== $show_js ) {
357
+ $pages = explode( ',', $show_js );
358
  }
359
  if ( is_object( $wp_query ) && isset( $wp_query->post ) ) {
360
+ $id = (string) $wp_query->post->ID;
361
  } else {
362
  $id = false;
363
  }
382
  }
383
  $ajax_js = stripcslashes( get_option( 'mc_ajaxjs' ) );
384
  $inner = '';
385
+
386
+ if ( ! $id || ( ( is_array( $pages ) && in_array( $id, $pages, true ) ) ) || '' === $show_js ) {
387
+ if ( get_option( 'mc_calendar_javascript' ) !== '1' ) {
388
  $inner .= "\n" . $cal_js;
389
  }
390
+ if ( get_option( 'mc_list_javascript' ) !== '1' ) {
391
  $inner .= "\n" . $list_js;
392
  }
393
+ if ( get_option( 'mc_mini_javascript' ) !== '1' ) {
394
  $inner .= "\n" . $mini_js;
395
  }
396
+ if ( get_option( 'mc_ajax_javascript' ) !== '1' ) {
397
  $inner .= "\n" . $ajax_js;
398
  }
399
  $script = '
405
  echo ( '' !== $inner ) ? $script . $mcjs : '';
406
  } else {
407
  $enqueue_mcjs = false;
408
+ if ( ! $id || ( is_array( $pages ) && in_array( $id, $pages, true ) ) || '' === $show_js ) {
409
+ if ( '1' !== get_option( 'mc_calendar_javascript' ) && 'true' !== get_option( 'mc_open_uri' ) ) {
410
  $url = apply_filters( 'mc_grid_js', plugins_url( 'js/mc-grid.js', __FILE__ ) );
411
  $enqueue_mcjs = true;
412
  wp_enqueue_script( 'mc.grid', $url, array( 'jquery' ) );
413
  wp_localize_script( 'mc.grid', 'mcgrid', 'true' );
414
  }
415
+ if ( '1' !== get_option( 'mc_list_javascript' ) ) {
416
  $url = apply_filters( 'mc_list_js', plugins_url( 'js/mc-list.js', __FILE__ ) );
417
  $enqueue_mcjs = true;
418
  wp_enqueue_script( 'mc.list', $url, array( 'jquery' ) );
419
  wp_localize_script( 'mc.list', 'mclist', 'true' );
420
  }
421
+ if ( '1' !== get_option( 'mc_mini_javascript' ) && 'true' !== get_option( 'mc_open_day_uri' ) ) {
422
  $url = apply_filters( 'mc_mini_js', plugins_url( 'js/mc-mini.js', __FILE__ ) );
423
  $enqueue_mcjs = true;
424
  wp_enqueue_script( 'mc.mini', $url, array( 'jquery' ) );
425
  wp_localize_script( 'mc.mini', 'mcmini', 'true' );
426
  }
427
+ if ( '1' !== get_option( 'mc_ajax_javascript' ) ) {
428
  $url = apply_filters( 'mc_ajax_js', plugins_url( 'js/mc-ajax.js', __FILE__ ) );
429
  $enqueue_mcjs = true;
430
  wp_enqueue_script( 'mc.ajax', $url, array( 'jquery' ) );
922
  $ignore = array( 'HTTP_COOKIE' );
923
 
924
  foreach ( $_SERVER as $key => $value ) {
925
+ if ( ! in_array( $key, (array) $ignore, true ) ) {
926
  $c[ "$key" ] = $value;
927
  }
928
  }
1444
  $sitename = substr( $sitename, 4 );
1445
  }
1446
  $from_email = 'wordpress@' . $sitename;
1447
+ $from = "From: $current_user->username <$from_email>\r\nReply-to: $current_user->username <$current_user->user_email>\r\n";
1448
 
1449
  if ( ! $has_read_faq ) {
1450
  echo '<div class="message error"><p>' . __( 'Please read the FAQ and other Help documents before making a support request.', 'my-calendar' ) . '</p></div>';
1594
  'exclude_from_search' => $raw['exclude_from_search'],
1595
  'show_ui' => $raw['show_ui'],
1596
  'show_in_menu' => $raw['show_in_menu'],
1597
+ 'menu_icon' => ( null === $raw['menu_icon'] ) ? plugins_url( 'images', __FILE__ ) . '/icon.png' : $raw['menu_icon'],
1598
  'query_var' => true,
1599
  'rewrite' => array(
1600
  'with_front' => false,
1733
  */
1734
  function mc_update_notice() {
1735
  // Deprecate this notice when 2.3 no longer in upgrade cycles.
1736
+ if ( current_user_can( 'activate_plugins' ) && '0' === get_option( 'mc_update_notice' ) || ! get_option( 'mc_update_notice' ) ) {
1737
  $dismiss = admin_url( 'admin.php?page=my-calendar-behaviors&dismiss=update' );
1738
  // Translators: URL to scripts manager.
1739
  echo "<div class='updated'><p>" . sprintf( __( "<strong>Update notice:</strong> if you use custom JS with My Calendar, you need to activate your custom scripts following this update. <a href='%s'>Dismiss Notice</a>", 'my-calendar' ), $dismiss ) . '</p></div>';
my-calendar-event-manager.php CHANGED
@@ -24,9 +24,9 @@ if ( ! defined( 'ABSPATH' ) ) {
24
  */
25
  function mc_event_post( $action, $data, $event_id ) {
26
  // if the event save was successful.
27
- if ( 'add' == $action || 'copy' == $action ) {
28
  $post_id = mc_create_event_post( $data, $event_id );
29
- } elseif ( 'edit' == $action ) {
30
  if ( isset( $_POST['event_post'] ) && ( 0 == $_POST['event_post'] || '' == $_POST['event_post'] ) ) {
31
  $post_id = mc_create_event_post( $data, $event_id );
32
  } else {
@@ -227,9 +227,9 @@ function mc_event_delete_posts( $deleted ) {
227
  function mc_update_event( $field, $data, $event, $type = '%d' ) {
228
  global $wpdb;
229
  $field = sanitize_key( $field );
230
- if ( '%d' == $type ) {
231
  $sql = 'UPDATE ' . my_calendar_table() . " SET $field = %d WHERE event_id=%d";
232
- } elseif ( '%s' == $type ) {
233
  $sql = 'UPDATE ' . my_calendar_table() . " SET $field = %s WHERE event_id=%d";
234
  } else {
235
  $sql = 'UPDATE ' . my_calendar_table() . " SET $field = %f WHERE event_id=%d";
@@ -437,7 +437,7 @@ function mc_show_notice( $message, $echo = true ) {
437
  function my_calendar_manage() {
438
  my_calendar_check();
439
  global $wpdb;
440
- if ( isset( $_GET['mode'] ) && 'delete' == $_GET['mode'] ) {
441
  $event_id = ( isset( $_GET['event_id'] ) ) ? absint( $_GET['event_id'] ) : false;
442
  $result = $wpdb->get_results( $wpdb->prepare( 'SELECT event_title, event_author FROM ' . my_calendar_table() . ' WHERE event_id=%d', $event_id ), ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
443
  if ( mc_can_edit_event( $event_id ) ) {
@@ -481,7 +481,7 @@ function my_calendar_manage() {
481
  }
482
 
483
  // Approve and show an Event ...originally by Roland.
484
- if ( isset( $_GET['mode'] ) && 'publish' == $_GET['mode'] ) {
485
  if ( current_user_can( 'mc_approve_events' ) ) {
486
  $event_id = absint( $_GET['event_id'] );
487
  $wpdb->get_results( $wpdb->prepare( 'UPDATE ' . my_calendar_table() . ' SET event_approved = 1 WHERE event_id=%d', $event_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
@@ -492,7 +492,7 @@ function my_calendar_manage() {
492
  }
493
 
494
  // Reject and hide an Event ...by Roland.
495
- if ( isset( $_GET['mode'] ) && 'reject' == $_GET['mode'] ) {
496
  if ( current_user_can( 'mc_approve_events' ) ) {
497
  $event_id = absint( $_GET['event_id'] );
498
  $wpdb->get_results( $wpdb->prepare( 'UPDATE ' . my_calendar_table() . ' SET event_approved = 2 WHERE event_id=%d', $event_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
@@ -576,7 +576,7 @@ function my_calendar_edit() {
576
 
577
  if ( isset( $_GET['mode'] ) ) {
578
  $action = $_GET['mode'];
579
- if ( 'edit' == $action || 'copy' == $action ) {
580
  $event_id = (int) $_GET['event_id'];
581
  }
582
  }
@@ -598,7 +598,7 @@ function my_calendar_edit() {
598
  }
599
  for ( $i = 0; $i < $count; $i ++ ) {
600
  $mc_output = mc_check_data( $action, $_POST, $i );
601
- if ( 'add' == $action || 'copy' == $action ) {
602
  $response = my_calendar_save( $action, $mc_output );
603
  } else {
604
  $response = my_calendar_save( $action, $mc_output, (int) $_POST['event_id'] );
@@ -623,7 +623,7 @@ function my_calendar_edit() {
623
  }
624
  mc_show_notice( $message );
625
  }
626
- if ( 'edit' == $action ) {
627
  ?>
628
  <h1><?php _e( 'Edit Event', 'my-calendar' ); ?></h1>
629
  <?php
@@ -632,7 +632,7 @@ function my_calendar_edit() {
632
  } else {
633
  mc_edit_event_form( 'edit', $event_id );
634
  }
635
- } elseif ( 'copy' == $action ) {
636
  ?>
637
  <h1><?php _e( 'Copy Event', 'my-calendar' ); ?></h1>
638
  <?php
@@ -668,7 +668,7 @@ function my_calendar_save( $action, $output, $event_id = false ) {
668
  $message = '';
669
  $formats = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%f', '%f' );
670
 
671
- if ( ( 'add' == $action || 'copy' == $action ) && true == $proceed ) {
672
  $add = $output[2]; // add format here.
673
  $cats = $add['event_categories'];
674
 
@@ -686,7 +686,7 @@ function my_calendar_save( $action, $output, $event_id = false ) {
686
  $event_error = '';
687
  do_action( 'mc_save_event', $action, $data, $event_id, $result );
688
 
689
- if ( 'true' == get_option( 'mc_event_mail' ) ) {
690
  // insert_id is last occurrence inserted in the db.
691
  $event = mc_get_first_event( $event_id );
692
  my_calendar_send_email( $event );
@@ -719,7 +719,7 @@ function my_calendar_save( $action, $output, $event_id = false ) {
719
  }
720
  }
721
 
722
- if ( 'edit' == $action && true == $proceed ) {
723
  $result = true;
724
  // Translators: URL to view calendar.
725
  $url = sprintf( __( 'View <a href="%s">your calendar</a>.', 'my-calendar' ), mc_get_uri() );
@@ -751,7 +751,7 @@ function my_calendar_save( $action, $output, $event_id = false ) {
751
  mc_update_data( $event_id, 'event_group_id', $event_id );
752
  }
753
  // retain saved location unless actively changed.
754
- if ( isset( $_POST['preset_location'] ) && 'none' == $_POST['location_preset'] ) {
755
  $location = absint( $_POST['preset_location'] );
756
  $update['event_location'] = $location;
757
  }
@@ -992,7 +992,7 @@ function mc_edit_event_form( $mode = 'add', $event_id = false ) {
992
 
993
  apply_filters( 'mc_event_notices', '', $data, $event_id );
994
 
995
- if ( is_object( $data ) && 1 != $data->event_approved && 'edit' == $mode ) {
996
  if ( 0 == $data->event_approved ) {
997
  mc_show_error( __( '<strong>Draft</strong>: Publish this event to show it on the calendar.', 'my-calendar' ) );
998
  } else {
@@ -1013,7 +1013,7 @@ function mc_edit_event_form( $mode = 'add', $event_id = false ) {
1013
  function mc_get_instance_data( $instance_id ) {
1014
  global $wpdb;
1015
  $mcdb = $wpdb;
1016
- if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
1017
  $mcdb = mc_remote_db();
1018
  }
1019
  $result = $mcdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . my_calendar_event_table() . ' WHERE occur_id = %d', $instance_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
@@ -1043,15 +1043,15 @@ function mc_show_edit_block( $field ) {
1043
  return true;
1044
  }
1045
  if ( $admin ) {
1046
- if ( isset( $show[ $field ] ) && 'on' == $show[ $field ] ) {
1047
  return true;
1048
  } else {
1049
  return false;
1050
  }
1051
  } else {
1052
- if ( 'off' == $input[ $field ] || '' == $input[ $field ] ) {
1053
  return false;
1054
- } elseif ( 'off' == $show[ $field ] ) {
1055
  return false;
1056
  } else {
1057
  return true;
@@ -1117,7 +1117,7 @@ function mc_show_block( $field, $has_data, $data, $echo = true, $default = '' )
1117
  if ( false !== $custom_editor ) {
1118
  $return = $custom_editor;
1119
  } else {
1120
- if ( 'post' == $current_screen->base ) {
1121
  $return = '<div class="event_description">
1122
  <label for="content" class="screen-reader-text">' . __( 'Event Description', 'my-calendar' ) . '</label>
1123
  <textarea id="content" name="content" class="event_desc" rows="8" cols="80">' . stripslashes( esc_attr( $value ) ) . '</textarea>
@@ -1203,7 +1203,7 @@ function mc_show_block( $field, $has_data, $data, $echo = true, $default = '' )
1203
  $checked = ' checked="checked"';
1204
  } elseif ( $has_data && '0' == $data->event_link_expires ) {
1205
  $checked = '';
1206
- } elseif ( 'true' == get_option( 'mc_event_link_expires' ) ) {
1207
  $checked = ' checked="checked"';
1208
  }
1209
  $return = '
@@ -1218,7 +1218,7 @@ function mc_show_block( $field, $has_data, $data, $echo = true, $default = '' )
1218
  $recurs = str_split( $event_recur, 1 );
1219
  $recur = $recurs[0];
1220
  $every = ( isset( $recurs[1] ) ) ? str_replace( $recurs[0], '', $event_recur ) : 1;
1221
- if ( 1 == $every && 'B' == $recur ) {
1222
  $every = 2;
1223
  }
1224
  $prev = '<input type="hidden" name="prev_event_repeats" value="' . $data->event_repeats . '" /><input type="hidden" name="prev_event_recur" value="' . $data->event_recur . '" />';
@@ -1323,7 +1323,7 @@ function mc_show_block( $field, $has_data, $data, $echo = true, $default = '' )
1323
  function mc_test_occurrence_overlap( $data, $return = false ) {
1324
  $warning = '';
1325
  // If this event is single, skip query.
1326
- $single_recur = ( 'S' == $data->event_recur || 'S1' == $data->event_recur ) ? true : false;
1327
  // If event starts and ends on same day, skip query.
1328
  $start_end = ( $data->event_begin == $data->event_end ) ? true : false;
1329
  // Only run test when an event is set up to recur & starts/ends on different days.
@@ -1374,7 +1374,7 @@ function mc_form_fields( $data, $mode, $event_id ) {
1374
  <div class="postbox-container jcd-wide">
1375
  <div class="metabox-holder">
1376
  <?php
1377
- if ( 'add' == $mode || 'copy' == $mode ) {
1378
  $query_args = array();
1379
  } else {
1380
  $query_args = array(
@@ -1407,7 +1407,7 @@ function mc_form_fields( $data, $mode, $event_id ) {
1407
  ?>
1408
  <input type="hidden" name="event_id" value="<?php echo (int) $event_id; ?>"/>
1409
  <?php
1410
- if ( 'edit' == $mode ) {
1411
  if ( $has_data && ( ! property_exists( $data, 'event_post' ) || ! $data->event_post ) ) {
1412
  $array_data = (array) $data;
1413
  $post_id = mc_event_post( 'add', $array_data, $event_id );
@@ -1425,7 +1425,7 @@ function mc_form_fields( $data, $mode, $event_id ) {
1425
  <div class="ui-sortable meta-box-sortables">
1426
  <div class="postbox">
1427
  <?php
1428
- $text = ( 'edit' == $mode ) ? __( 'Edit Event', 'my-calendar' ) : __( 'Add Event', 'my-calendar' );
1429
  ?>
1430
  <h2><?php esc_html( $text ); ?></h2>
1431
  <div class="inside">
@@ -1477,7 +1477,7 @@ function mc_form_fields( $data, $mode, $event_id ) {
1477
  apply_filters( 'mc_insert_custom_fields', '', $has_data, $data );
1478
 
1479
  if ( function_exists( 'wpt_post_to_twitter' ) && current_user_can( 'wpt_can_tweet' ) ) {
1480
- if ( ! ( 'edit' == $mode && 1 == $data->event_approved ) ) {
1481
  $mc_allowed = absint( ( get_option( 'wpt_tweet_length' ) ) ? get_option( 'wpt_tweet_length' ) : 140 );
1482
  ?>
1483
  <p class='mc-twitter'>
@@ -1689,7 +1689,7 @@ function mc_form_fields( $data, $mode, $event_id ) {
1689
  <?php
1690
  }
1691
  if ( mc_show_edit_block( 'event_specials' ) ) {
1692
- $hol_checked = ( 'true' == get_option( 'mc_skip_holidays' ) ) ? ' checked="checked"' : '';
1693
  $fifth_checked = ( 'true' === get_option( 'mc_no_fifth_week' ) ) ? ' checked="checked"' : '';
1694
  if ( $has_data ) {
1695
  $hol_checked = ( '1' == $data->event_holiday ) ? ' checked="checked"' : '';
@@ -1831,10 +1831,10 @@ function mc_event_access() {
1831
  function mc_event_accessibility( $form, $data, $label ) {
1832
  $note_value = '';
1833
  $events_access = array();
1834
- $class = ( is_admin() ) ? ' class="screen-reader-text"' : '';
1835
  $form .= "
1836
  <fieldset>
1837
- <legend$class>$label</legend>
1838
  <ul class='accessibility-features checkboxes'>";
1839
  $access = apply_filters( 'mc_event_accessibility', mc_event_access() );
1840
  if ( ! empty( $data ) ) {
@@ -1873,20 +1873,20 @@ function mc_list_events() {
1873
 
1874
  $action = ! empty( $_POST['event_action'] ) ? $_POST['event_action'] : '';
1875
  $event_id = ! empty( $_POST['event_id'] ) ? $_POST['event_id'] : '';
1876
- if ( 'delete' == $action ) {
1877
  $message = mc_delete_event( $event_id );
1878
  echo $message;
1879
  }
1880
 
1881
  if ( isset( $_GET['order'] ) ) {
1882
- $sortdir = ( isset( $_GET['order'] ) && 'ASC' == $_GET['order'] ) ? 'ASC' : 'default';
1883
- $sortdir = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? 'DESC' : $sortdir;
1884
  } else {
1885
  $sortdir = 'default';
1886
  }
1887
 
1888
  $default_direction = ( '' == get_option( 'mc_default_direction' ) ) ? 'ASC' : get_option( 'mc_default_direction' );
1889
- $sortbydirection = ( 'default' == $sortdir ) ? $default_direction : $sortdir;
1890
 
1891
  $sortby = ( isset( $_GET['sort'] ) ) ? $_GET['sort'] : get_option( 'mc_default_sort' );
1892
  if ( empty( $sortby ) ) {
@@ -1918,7 +1918,7 @@ function mc_list_events() {
1918
  $sortbyvalue = "event_begin $sortbydirection, event_time";
1919
  }
1920
  }
1921
- $sorting = ( 'DESC' == $sortbydirection ) ? '&amp;order=ASC' : '&amp;order=DESC';
1922
  $allow_filters = true;
1923
  $status = ( isset( $_GET['limit'] ) ) ? $_GET['limit'] : 'all';
1924
  $restrict = ( isset( $_GET['restrict'] ) ) ? $_GET['restrict'] : 'all';
@@ -1967,7 +1967,7 @@ function mc_list_events() {
1967
  $allow_filters = false;
1968
  }
1969
  $filter = esc_sql( urldecode( $filter ) );
1970
- if ( 'event_label' == $restrict ) {
1971
  $filter = "'$filter'";
1972
  }
1973
  if ( '' == $limit && '' != $filter ) {
@@ -2017,7 +2017,7 @@ function mc_list_events() {
2017
  ?>
2018
  <ul class="links">
2019
  <li>
2020
- <a <?php echo ( isset( $_GET['limit'] ) && 'published' == $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2021
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=published' ); ?>">
2022
  <?php
2023
  // Translators: Number of published events.
@@ -2026,7 +2026,7 @@ function mc_list_events() {
2026
  </a>
2027
  </li>
2028
  <li>
2029
- <a <?php echo ( isset( $_GET['limit'] ) && 'draft' == $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2030
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=draft' ); ?>">
2031
  <?php
2032
  // Translators: Number of draft events.
@@ -2035,7 +2035,7 @@ function mc_list_events() {
2035
  </a>
2036
  </li>
2037
  <li>
2038
- <a <?php echo ( isset( $_GET['limit'] ) && 'trashed' == $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2039
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=trashed' ); ?>">
2040
  <?php
2041
  // Translators: Number of trashed events.
@@ -2044,7 +2044,7 @@ function mc_list_events() {
2044
  </a>
2045
  </li>
2046
  <li>
2047
- <a <?php echo ( isset( $_GET['restrict'] ) && 'archived' == $_GET['restrict'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2048
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=archived' ); ?>">
2049
  <?php
2050
  // Translators: Number of archived events.
@@ -2056,7 +2056,7 @@ function mc_list_events() {
2056
  if ( function_exists( 'akismet_http_post' ) && $allow_filters ) {
2057
  ?>
2058
  <li>
2059
- <a <?php echo ( isset( $_GET['restrict'] ) && 'flagged' == $_GET['restrict'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2060
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=flagged&amp;filter=1' ); ?>">
2061
  <?php
2062
  // Translators: Number of events marked as spam.
@@ -2068,7 +2068,7 @@ function mc_list_events() {
2068
  }
2069
  ?>
2070
  <li>
2071
- <a <?php echo ( isset( $_GET['limit'] ) && 'all' == $_GET['limit'] || ( ! isset( $_GET['limit'] ) && ! isset( $_GET['restrict'] ) ) ) ? 'class="active-link" aria-current="true"' : ''; ?>
2072
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=all' ); ?>"><?php _e( 'All', 'my-calendar' ); ?></a>
2073
  </li>
2074
  </ul>
@@ -2114,12 +2114,12 @@ function mc_list_events() {
2114
  if ( current_user_can( 'mc_approve_events' ) ) {
2115
  echo '<input type="submit" class="button-secondary mc-approve" name="mass_approve" value="' . __( 'Publish events', 'my-calendar' ) . '" /> ';
2116
  }
2117
- if ( ! ( isset( $_GET['restrict'] ) && 'archived' == $_GET['restrict'] ) ) {
2118
  echo '<input type="submit" class="button-secondary mc-archive" name="mass_archive" value="' . __( 'Archive events', 'my-calendar' ) . '" /> ';
2119
  } else {
2120
  echo '<input type="submit" class="button-secondary mc-archive" name="mass_undo_archive" value="' . __( 'Remove from archive', 'my-calendar' ) . '" /> ';
2121
  }
2122
- if ( isset( $_GET['restrict'] ) && 'flagged' == $_GET['restrict'] ) {
2123
  echo '<input type="submit" class="button-secondary mc-archive" name="mass_not_spam" value="' . __( 'Not spam', 'my-calendar' ) . '" /> ';
2124
  }
2125
  ?>
@@ -2159,12 +2159,12 @@ function mc_list_events() {
2159
  if ( ! is_object( $event ) ) {
2160
  continue;
2161
  }
2162
- $class = ( 'alternate' == $class ) ? 'even' : 'alternate';
2163
  $pending = ( 0 == $event->event_approved ) ? 'pending' : '';
2164
  $trashed = ( 2 == $event->event_approved ) ? 'trashed' : '';
2165
  $author = ( 0 != $event->event_author ) ? get_userdata( $event->event_author ) : 'Public Submitter';
2166
 
2167
- if ( 1 == $event->event_flagged && ( isset( $_GET['restrict'] ) && 'flagged' == $_GET['restrict'] ) ) {
2168
  $spam = 'spam';
2169
  $pending = '';
2170
  $spam_label = '<strong>' . __( 'Possible spam', 'my-calendar' ) . ':</strong> ';
@@ -2343,7 +2343,7 @@ function mc_list_events() {
2343
  </table>
2344
  <ul class="links">
2345
  <li>
2346
- <a <?php echo ( isset( $_GET['limit'] ) && 'published' == $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2347
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=published' ); ?>">
2348
  <?php
2349
  // Translators: Number of published events.
@@ -2352,7 +2352,7 @@ function mc_list_events() {
2352
  </a>
2353
  </li>
2354
  <li>
2355
- <a <?php echo ( isset( $_GET['limit'] ) && 'draft' == $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2356
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=draft' ); ?>">
2357
  <?php
2358
  // Translators: Number of draft events.
@@ -2361,7 +2361,7 @@ function mc_list_events() {
2361
  </a>
2362
  </li>
2363
  <li>
2364
- <a <?php echo ( isset( $_GET['limit'] ) && 'trashed' == $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2365
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=trashed' ); ?>">
2366
  <?php
2367
  // Translators: Number of trashed events.
@@ -2370,7 +2370,7 @@ function mc_list_events() {
2370
  </a>
2371
  </li>
2372
  <li>
2373
- <a <?php echo ( isset( $_GET['restrict'] ) && 'archived' == $_GET['restrict'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2374
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=archived' ); ?>">
2375
  <?php
2376
  // Translators: Number of archived events.
@@ -2382,7 +2382,7 @@ function mc_list_events() {
2382
  if ( function_exists( 'akismet_http_post' ) && $allow_filters ) {
2383
  ?>
2384
  <li>
2385
- <a <?php echo ( isset( $_GET['restrict'] ) && 'flagged' == $_GET['restrict'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2386
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=flagged&amp;filter=1' ); ?>">
2387
  <?php
2388
  // Translators: Number of events marked as spam.
@@ -2394,7 +2394,7 @@ function mc_list_events() {
2394
  }
2395
  ?>
2396
  <li>
2397
- <a <?php echo ( isset( $_GET['limit'] ) && 'all' == $_GET['limit'] || ( ! isset( $_GET['limit'] ) && ! isset( $_GET['restrict'] ) ) ) ? 'class="active-link" aria-current="true"' : ''; ?>
2398
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=all' ); ?>"><?php _e( 'All', 'my-calendar' ); ?></a>
2399
  </li>
2400
  </ul>
@@ -2426,7 +2426,7 @@ function mc_list_events() {
2426
  <input type="submit" class="button-secondary mc-approve" name="mass_approve" value="<?php _e( 'Publish events', 'my-calendar' ); ?>"/>
2427
  <?php
2428
  }
2429
- if ( ! ( isset( $_GET['restrict'] ) && 'archived' == $_GET['restrict'] ) ) {
2430
  ?>
2431
  <input type="submit" class="button-secondary mc-archive" name="mass_archive" value="<?php _e( 'Archive events', 'my-calendar' ); ?>"/>
2432
  <?php
@@ -2436,7 +2436,7 @@ function mc_list_events() {
2436
 
2437
  <p>
2438
  <?php
2439
- if ( ! ( isset( $_GET['restrict'] ) && 'archived' == $_GET['restrict'] ) ) {
2440
  ?>
2441
  <a class='mc_filter' href='<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=archived' ); ?>'><?php _e( 'View Archived Events', 'my-calendar' ); ?></a>
2442
  <?php
@@ -2528,7 +2528,7 @@ function mc_check_data( $action, $post, $i ) {
2528
  return array();
2529
  }
2530
 
2531
- if ( 'add' == $action || 'edit' == $action || 'copy' == $action ) {
2532
  $title = ! empty( $post['event_title'] ) ? trim( $post['event_title'] ) : '';
2533
  $desc = ! empty( $post['content'] ) ? trim( $post['content'] ) : '';
2534
  $short = ! empty( $post['event_short'] ) ? trim( $post['event_short'] ) : '';
@@ -2538,7 +2538,7 @@ function mc_check_data( $action, $post, $i ) {
2538
  // ...AND there's no reason to allow it, since weekday events will NEVER happen on the weekend.
2539
  $begin = trim( $post['event_begin'][ $i ] );
2540
  $end = ( ! empty( $post['event_end'] ) ) ? trim( $post['event_end'][ $i ] ) : $post['event_begin'][ $i ];
2541
- if ( 'E' == $recur && 0 == ( date( 'w', mc_strtotime( $begin ) ) || 6 == date( 'w', mc_strtotime( $begin ) ) ) ) {
2542
  if ( 0 == date( 'w', mc_strtotime( $begin ) ) ) {
2543
  $newbegin = my_calendar_add_date( $begin, 1 );
2544
  if ( ! empty( $post['event_end'][ $i ] ) ) {
@@ -2573,11 +2573,11 @@ function mc_check_data( $action, $post, $i ) {
2573
  } else {
2574
  $endtime = ! empty( $post['event_endtime'][ $i ] ) ? trim( $post['event_endtime'][ $i ] ) : '';
2575
  }
2576
- $time = ( '' == $time || '00:00:00' == $time ) ? '00:00:00' : $time; // Set at midnight if not provided.
2577
- $endtime = ( '' == $endtime && '00:00:00' == $time ) ? '23:59:59' : $endtime; // Set at end of night if np.
2578
 
2579
  // Prevent setting enddate to incorrect value on copy.
2580
- if ( mc_strtotime( $end ) < mc_strtotime( $begin ) && 'copy' == $action ) {
2581
  $end = date( 'Y-m-d', ( mc_strtotime( $begin ) + ( mc_strtotime( $post['prev_event_end'] ) - mc_strtotime( $post['prev_event_begin'] ) ) ) );
2582
  }
2583
  if ( isset( $post['event_allday'] ) && 0 !== (int) $post['event_allday'] ) {
@@ -2630,7 +2630,7 @@ function mc_check_data( $action, $post, $i ) {
2630
  $event_group_id = ( ( is_array( $post['event_begin'] ) && count( $post['event_begin'] ) > 1 ) || mc_event_is_grouped( $group_id ) ) ? $group_id : 0;
2631
  $event_span = ( ! empty( $post['event_span'] ) && 0 != $event_group_id ) ? 1 : 0;
2632
  $event_hide_end = ( ! empty( $post['event_hide_end'] ) ) ? (int) $post['event_hide_end'] : 0;
2633
- $event_hide_end = ( '' == $time || '23:59:59' == $time ) ? 1 : $event_hide_end; // Hide end time on all day events.
2634
  // Set location.
2635
  if ( 'none' != $location_preset && is_numeric( $location_preset ) ) {
2636
  $location = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . my_calendar_locations_table() . ' WHERE location_id = %d', $location_preset ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
@@ -2666,7 +2666,7 @@ function mc_check_data( $action, $post, $i ) {
2666
  $event_phone2 = ! empty( $post['event_phone2'] ) ? $post['event_phone2'] : '';
2667
  $event_access = ! empty( $post['event_access'] ) ? $post['event_access'] : '';
2668
  $event_access = ! empty( $post['event_access_hidden'] ) ? unserialize( $post['event_access_hidden'] ) : $event_access;
2669
- if ( isset( $post['mc_copy_location'] ) && 'on' == $post['mc_copy_location'] && 0 == $i ) {
2670
  // Only the first event, if adding multiples.
2671
  $add_loc = array(
2672
  'location_label' => $event_label,
@@ -2726,7 +2726,7 @@ function mc_check_data( $action, $post, $i ) {
2726
  }
2727
  // Run checks on recurrence profile.
2728
  $valid_recur = array( 'W', 'B', 'M', 'U', 'Y', 'D', 'E' );
2729
- if ( ( 0 == $repeats && 'S' == $recur ) || ( ( $repeats >= 0 ) && in_array( $recur, $valid_recur ) ) ) {
2730
  $recur = $recur . $every;
2731
  } else {
2732
  // if it's not valid, assign a default value.
@@ -2747,7 +2747,7 @@ function mc_check_data( $action, $post, $i ) {
2747
  $spam_content = ( '' != $desc ) ? $desc : $short;
2748
  $spam = mc_spam( $event_link, $spam_content, $post );
2749
  // Likelihood that event will be flagged as spam, have a zero start time and be legit is minimal. Just kill it.
2750
- if ( 1 == $spam && '1970-01-01' == $begin ) {
2751
  die;
2752
  }
2753
 
@@ -3123,7 +3123,7 @@ function mc_event_is_grouped( $group_id ) {
3123
  */
3124
  function mc_is_all_day( $event ) {
3125
 
3126
- return ( '00:00:00' == $event->event_time && '23:59:59' == $event->event_endtime ) ? true : false;
3127
  }
3128
 
3129
  /**
@@ -3334,7 +3334,7 @@ function mc_controls( $mode, $has_data, $event, $position = 'header' ) {
3334
  $text_link = '';
3335
  $controls = array();
3336
 
3337
- if ( 'edit' == $mode ) {
3338
  $publish_text = __( 'Save', 'my-calendar' );
3339
  $event_id = $event->event_id;
3340
  $args = '';
@@ -3345,7 +3345,7 @@ function mc_controls( $mode, $has_data, $event, $position = 'header' ) {
3345
  }
3346
  }
3347
  $controls['delete'] = "<span class='dashicons dashicons-no' aria-hidden='true'></span><a href='" . admin_url( "admin.php?page=my-calendar-manage&amp;mode=delete&amp;event_id=$event_id$args" ) . "' class='delete'>" . __( 'Delete', 'my-calendar' ) . '</a>';
3348
- if ( 'true' == apply_filters( 'mc_use_permalinks', get_option( 'mc_use_permalinks' ) ) ) {
3349
  $post_id = $event->event_post;
3350
  $post_link = ( $post_id ) ? get_edit_post_link( $post_id ) : false;
3351
  $controls['post'] = ( $post_link ) ? sprintf( "<span class='dashicons dashicons-admin-post' aria-hidden='true'></span><a href='%s'>" . __( 'Edit Event Post', 'my-calendar' ) . '</a>', $post_link ) : '';
@@ -3369,8 +3369,8 @@ function mc_controls( $mode, $has_data, $event, $position = 'header' ) {
3369
  $controls['publish'] = '<input type="submit" name="save" class="button-primary" value="' . esc_attr( $publish_text ) . '" />';
3370
  // Event Status settings: draft, published, trash, (custom).
3371
  // Switch to select status.
3372
- if ( 'header' == $position ) {
3373
- if ( 'edit' == $mode ) {
3374
  $controls['prev_status'] = "<input type='hidden' name='prev_event_status' value='" . absint( $event->event_approved ) . "' />";
3375
  if ( current_user_can( 'mc_approve_events' ) || current_user_can( 'mc_publish_events' ) ) { // Added by Roland P.
3376
  if ( $has_data && '1' == $event->event_approved ) {
@@ -3584,13 +3584,13 @@ function mc_recur_string( $event ) {
3584
  * @return string form options
3585
  */
3586
  function mc_recur_options( $value ) {
3587
- $s = ( 'S' == $value ) ? ' selected="selected"' : '';
3588
- $d = ( 'D' == $value ) ? ' selected="selected"' : '';
3589
- $e = ( 'E' == $value ) ? ' selected="selected"' : '';
3590
- $w = ( 'W' == $value || 'B' == $value ) ? ' selected="selected"' : '';
3591
- $m = ( 'M' == $value ) ? ' selected="selected"' : '';
3592
- $u = ( 'U' == $value ) ? ' selected="selected"' : '';
3593
- $y = ( 'Y' == $value ) ? ' selected="selected"' : '';
3594
 
3595
  $return = "
3596
  <option class='input' value='S' $s>" . __( 'Does not recur', 'my-calendar' ) . "</option>
@@ -3763,7 +3763,7 @@ function mc_increment_event( $id, $post = array(), $test = false, $instances = a
3763
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3764
  'occur_group_id' => $group_id,
3765
  );
3766
- if ( 'test' == $test && $i > 0 ) {
3767
  return $data;
3768
  }
3769
  $return[] = $data;
@@ -3793,7 +3793,7 @@ function mc_increment_event( $id, $post = array(), $test = false, $instances = a
3793
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3794
  'occur_group_id' => $group_id,
3795
  );
3796
- if ( 'test' == $test && $i > 0 ) {
3797
  return $data;
3798
  }
3799
  $return[] = $data;
@@ -3820,7 +3820,7 @@ function mc_increment_event( $id, $post = array(), $test = false, $instances = a
3820
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3821
  'occur_group_id' => $group_id,
3822
  );
3823
- if ( 'test' == $test && $i > 0 ) {
3824
  return $data;
3825
  }
3826
  $return[] = $data;
@@ -3845,7 +3845,7 @@ function mc_increment_event( $id, $post = array(), $test = false, $instances = a
3845
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3846
  'occur_group_id' => $group_id,
3847
  );
3848
- if ( 'test' == $test && $i > 0 ) {
3849
  return $data;
3850
  }
3851
  $return[] = $data;
@@ -3869,7 +3869,7 @@ function mc_increment_event( $id, $post = array(), $test = false, $instances = a
3869
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3870
  'occur_group_id' => $group_id,
3871
  );
3872
- if ( 'test' == $test && $i > 0 ) {
3873
  return $data;
3874
  }
3875
  $return[] = $data;
@@ -3893,7 +3893,7 @@ function mc_increment_event( $id, $post = array(), $test = false, $instances = a
3893
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3894
  'occur_group_id' => $group_id,
3895
  );
3896
- if ( 'test' == $test && $i > 0 ) {
3897
  return $data;
3898
  }
3899
  $return[] = $data;
@@ -3975,7 +3975,7 @@ function mc_increment_event( $id, $post = array(), $test = false, $instances = a
3975
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3976
  'occur_group_id' => $group_id,
3977
  );
3978
- if ( 'test' == $test && $i > 0 ) {
3979
  return $data;
3980
  }
3981
  $return[] = $data;
24
  */
25
  function mc_event_post( $action, $data, $event_id ) {
26
  // if the event save was successful.
27
+ if ( 'add' === $action || 'copy' === $action ) {
28
  $post_id = mc_create_event_post( $data, $event_id );
29
+ } elseif ( 'edit' === $action ) {
30
  if ( isset( $_POST['event_post'] ) && ( 0 == $_POST['event_post'] || '' == $_POST['event_post'] ) ) {
31
  $post_id = mc_create_event_post( $data, $event_id );
32
  } else {
227
  function mc_update_event( $field, $data, $event, $type = '%d' ) {
228
  global $wpdb;
229
  $field = sanitize_key( $field );
230
+ if ( '%d' === $type ) {
231
  $sql = 'UPDATE ' . my_calendar_table() . " SET $field = %d WHERE event_id=%d";
232
+ } elseif ( '%s' === $type ) {
233
  $sql = 'UPDATE ' . my_calendar_table() . " SET $field = %s WHERE event_id=%d";
234
  } else {
235
  $sql = 'UPDATE ' . my_calendar_table() . " SET $field = %f WHERE event_id=%d";
437
  function my_calendar_manage() {
438
  my_calendar_check();
439
  global $wpdb;
440
+ if ( isset( $_GET['mode'] ) && 'delete' === $_GET['mode'] ) {
441
  $event_id = ( isset( $_GET['event_id'] ) ) ? absint( $_GET['event_id'] ) : false;
442
  $result = $wpdb->get_results( $wpdb->prepare( 'SELECT event_title, event_author FROM ' . my_calendar_table() . ' WHERE event_id=%d', $event_id ), ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
443
  if ( mc_can_edit_event( $event_id ) ) {
481
  }
482
 
483
  // Approve and show an Event ...originally by Roland.
484
+ if ( isset( $_GET['mode'] ) && 'publish' === $_GET['mode'] ) {
485
  if ( current_user_can( 'mc_approve_events' ) ) {
486
  $event_id = absint( $_GET['event_id'] );
487
  $wpdb->get_results( $wpdb->prepare( 'UPDATE ' . my_calendar_table() . ' SET event_approved = 1 WHERE event_id=%d', $event_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
492
  }
493
 
494
  // Reject and hide an Event ...by Roland.
495
+ if ( isset( $_GET['mode'] ) && 'reject' === $_GET['mode'] ) {
496
  if ( current_user_can( 'mc_approve_events' ) ) {
497
  $event_id = absint( $_GET['event_id'] );
498
  $wpdb->get_results( $wpdb->prepare( 'UPDATE ' . my_calendar_table() . ' SET event_approved = 2 WHERE event_id=%d', $event_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
576
 
577
  if ( isset( $_GET['mode'] ) ) {
578
  $action = $_GET['mode'];
579
+ if ( 'edit' === $action || 'copy' === $action ) {
580
  $event_id = (int) $_GET['event_id'];
581
  }
582
  }
598
  }
599
  for ( $i = 0; $i < $count; $i ++ ) {
600
  $mc_output = mc_check_data( $action, $_POST, $i );
601
+ if ( 'add' === $action || 'copy' === $action ) {
602
  $response = my_calendar_save( $action, $mc_output );
603
  } else {
604
  $response = my_calendar_save( $action, $mc_output, (int) $_POST['event_id'] );
623
  }
624
  mc_show_notice( $message );
625
  }
626
+ if ( 'edit' === $action ) {
627
  ?>
628
  <h1><?php _e( 'Edit Event', 'my-calendar' ); ?></h1>
629
  <?php
632
  } else {
633
  mc_edit_event_form( 'edit', $event_id );
634
  }
635
+ } elseif ( 'copy' === $action ) {
636
  ?>
637
  <h1><?php _e( 'Copy Event', 'my-calendar' ); ?></h1>
638
  <?php
668
  $message = '';
669
  $formats = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%f', '%f' );
670
 
671
+ if ( ( 'add' === $action || 'copy' === $action ) && true === $proceed ) {
672
  $add = $output[2]; // add format here.
673
  $cats = $add['event_categories'];
674
 
686
  $event_error = '';
687
  do_action( 'mc_save_event', $action, $data, $event_id, $result );
688
 
689
+ if ( 'true' === get_option( 'mc_event_mail' ) ) {
690
  // insert_id is last occurrence inserted in the db.
691
  $event = mc_get_first_event( $event_id );
692
  my_calendar_send_email( $event );
719
  }
720
  }
721
 
722
+ if ( 'edit' === $action && true == $proceed ) {
723
  $result = true;
724
  // Translators: URL to view calendar.
725
  $url = sprintf( __( 'View <a href="%s">your calendar</a>.', 'my-calendar' ), mc_get_uri() );
751
  mc_update_data( $event_id, 'event_group_id', $event_id );
752
  }
753
  // retain saved location unless actively changed.
754
+ if ( isset( $_POST['preset_location'] ) && 'none' === $_POST['location_preset'] ) {
755
  $location = absint( $_POST['preset_location'] );
756
  $update['event_location'] = $location;
757
  }
992
 
993
  apply_filters( 'mc_event_notices', '', $data, $event_id );
994
 
995
+ if ( is_object( $data ) && 1 != $data->event_approved && 'edit' === $mode ) {
996
  if ( 0 == $data->event_approved ) {
997
  mc_show_error( __( '<strong>Draft</strong>: Publish this event to show it on the calendar.', 'my-calendar' ) );
998
  } else {
1013
  function mc_get_instance_data( $instance_id ) {
1014
  global $wpdb;
1015
  $mcdb = $wpdb;
1016
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
1017
  $mcdb = mc_remote_db();
1018
  }
1019
  $result = $mcdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . my_calendar_event_table() . ' WHERE occur_id = %d', $instance_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
1043
  return true;
1044
  }
1045
  if ( $admin ) {
1046
+ if ( isset( $show[ $field ] ) && 'on' === $show[ $field ] ) {
1047
  return true;
1048
  } else {
1049
  return false;
1050
  }
1051
  } else {
1052
+ if ( 'off' === $input[ $field ] || '' == $input[ $field ] ) {
1053
  return false;
1054
+ } elseif ( 'off' === $show[ $field ] ) {
1055
  return false;
1056
  } else {
1057
  return true;
1117
  if ( false !== $custom_editor ) {
1118
  $return = $custom_editor;
1119
  } else {
1120
+ if ( 'post' === $current_screen->base ) {
1121
  $return = '<div class="event_description">
1122
  <label for="content" class="screen-reader-text">' . __( 'Event Description', 'my-calendar' ) . '</label>
1123
  <textarea id="content" name="content" class="event_desc" rows="8" cols="80">' . stripslashes( esc_attr( $value ) ) . '</textarea>
1203
  $checked = ' checked="checked"';
1204
  } elseif ( $has_data && '0' == $data->event_link_expires ) {
1205
  $checked = '';
1206
+ } elseif ( 'true' === get_option( 'mc_event_link_expires' ) ) {
1207
  $checked = ' checked="checked"';
1208
  }
1209
  $return = '
1218
  $recurs = str_split( $event_recur, 1 );
1219
  $recur = $recurs[0];
1220
  $every = ( isset( $recurs[1] ) ) ? str_replace( $recurs[0], '', $event_recur ) : 1;
1221
+ if ( 1 == $every && 'B' === $recur ) {
1222
  $every = 2;
1223
  }
1224
  $prev = '<input type="hidden" name="prev_event_repeats" value="' . $data->event_repeats . '" /><input type="hidden" name="prev_event_recur" value="' . $data->event_recur . '" />';
1323
  function mc_test_occurrence_overlap( $data, $return = false ) {
1324
  $warning = '';
1325
  // If this event is single, skip query.
1326
+ $single_recur = ( 'S' === $data->event_recur || 'S1' === $data->event_recur ) ? true : false;
1327
  // If event starts and ends on same day, skip query.
1328
  $start_end = ( $data->event_begin == $data->event_end ) ? true : false;
1329
  // Only run test when an event is set up to recur & starts/ends on different days.
1374
  <div class="postbox-container jcd-wide">
1375
  <div class="metabox-holder">
1376
  <?php
1377
+ if ( 'add' === $mode || 'copy' === $mode ) {
1378
  $query_args = array();
1379
  } else {
1380
  $query_args = array(
1407
  ?>
1408
  <input type="hidden" name="event_id" value="<?php echo (int) $event_id; ?>"/>
1409
  <?php
1410
+ if ( 'edit' === $mode ) {
1411
  if ( $has_data && ( ! property_exists( $data, 'event_post' ) || ! $data->event_post ) ) {
1412
  $array_data = (array) $data;
1413
  $post_id = mc_event_post( 'add', $array_data, $event_id );
1425
  <div class="ui-sortable meta-box-sortables">
1426
  <div class="postbox">
1427
  <?php
1428
+ $text = ( 'edit' === $mode ) ? __( 'Edit Event', 'my-calendar' ) : __( 'Add Event', 'my-calendar' );
1429
  ?>
1430
  <h2><?php esc_html( $text ); ?></h2>
1431
  <div class="inside">
1477
  apply_filters( 'mc_insert_custom_fields', '', $has_data, $data );
1478
 
1479
  if ( function_exists( 'wpt_post_to_twitter' ) && current_user_can( 'wpt_can_tweet' ) ) {
1480
+ if ( ! ( 'edit' === $mode && 1 == $data->event_approved ) ) {
1481
  $mc_allowed = absint( ( get_option( 'wpt_tweet_length' ) ) ? get_option( 'wpt_tweet_length' ) : 140 );
1482
  ?>
1483
  <p class='mc-twitter'>
1689
  <?php
1690
  }
1691
  if ( mc_show_edit_block( 'event_specials' ) ) {
1692
+ $hol_checked = ( 'true' === get_option( 'mc_skip_holidays' ) ) ? ' checked="checked"' : '';
1693
  $fifth_checked = ( 'true' === get_option( 'mc_no_fifth_week' ) ) ? ' checked="checked"' : '';
1694
  if ( $has_data ) {
1695
  $hol_checked = ( '1' == $data->event_holiday ) ? ' checked="checked"' : '';
1831
  function mc_event_accessibility( $form, $data, $label ) {
1832
  $note_value = '';
1833
  $events_access = array();
1834
+ $class = ( is_admin() ) ? 'screen-reader-text' : 'mc-event-access';
1835
  $form .= "
1836
  <fieldset>
1837
+ <legend class='$class'>$label</legend>
1838
  <ul class='accessibility-features checkboxes'>";
1839
  $access = apply_filters( 'mc_event_accessibility', mc_event_access() );
1840
  if ( ! empty( $data ) ) {
1873
 
1874
  $action = ! empty( $_POST['event_action'] ) ? $_POST['event_action'] : '';
1875
  $event_id = ! empty( $_POST['event_id'] ) ? $_POST['event_id'] : '';
1876
+ if ( 'delete' === $action ) {
1877
  $message = mc_delete_event( $event_id );
1878
  echo $message;
1879
  }
1880
 
1881
  if ( isset( $_GET['order'] ) ) {
1882
+ $sortdir = ( isset( $_GET['order'] ) && 'ASC' === $_GET['order'] ) ? 'ASC' : 'default';
1883
+ $sortdir = ( isset( $_GET['order'] ) && 'DESC' === $_GET['order'] ) ? 'DESC' : $sortdir;
1884
  } else {
1885
  $sortdir = 'default';
1886
  }
1887
 
1888
  $default_direction = ( '' == get_option( 'mc_default_direction' ) ) ? 'ASC' : get_option( 'mc_default_direction' );
1889
+ $sortbydirection = ( 'default' === $sortdir ) ? $default_direction : $sortdir;
1890
 
1891
  $sortby = ( isset( $_GET['sort'] ) ) ? $_GET['sort'] : get_option( 'mc_default_sort' );
1892
  if ( empty( $sortby ) ) {
1918
  $sortbyvalue = "event_begin $sortbydirection, event_time";
1919
  }
1920
  }
1921
+ $sorting = ( 'DESC' === $sortbydirection ) ? '&amp;order=ASC' : '&amp;order=DESC';
1922
  $allow_filters = true;
1923
  $status = ( isset( $_GET['limit'] ) ) ? $_GET['limit'] : 'all';
1924
  $restrict = ( isset( $_GET['restrict'] ) ) ? $_GET['restrict'] : 'all';
1967
  $allow_filters = false;
1968
  }
1969
  $filter = esc_sql( urldecode( $filter ) );
1970
+ if ( 'event_label' === $restrict ) {
1971
  $filter = "'$filter'";
1972
  }
1973
  if ( '' == $limit && '' != $filter ) {
2017
  ?>
2018
  <ul class="links">
2019
  <li>
2020
+ <a <?php echo ( isset( $_GET['limit'] ) && 'published' === $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2021
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=published' ); ?>">
2022
  <?php
2023
  // Translators: Number of published events.
2026
  </a>
2027
  </li>
2028
  <li>
2029
+ <a <?php echo ( isset( $_GET['limit'] ) && 'draft' === $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2030
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=draft' ); ?>">
2031
  <?php
2032
  // Translators: Number of draft events.
2035
  </a>
2036
  </li>
2037
  <li>
2038
+ <a <?php echo ( isset( $_GET['limit'] ) && 'trashed' === $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2039
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=trashed' ); ?>">
2040
  <?php
2041
  // Translators: Number of trashed events.
2044
  </a>
2045
  </li>
2046
  <li>
2047
+ <a <?php echo ( isset( $_GET['restrict'] ) && 'archived' === $_GET['restrict'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2048
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=archived' ); ?>">
2049
  <?php
2050
  // Translators: Number of archived events.
2056
  if ( function_exists( 'akismet_http_post' ) && $allow_filters ) {
2057
  ?>
2058
  <li>
2059
+ <a <?php echo ( isset( $_GET['restrict'] ) && 'flagged' === $_GET['restrict'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2060
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=flagged&amp;filter=1' ); ?>">
2061
  <?php
2062
  // Translators: Number of events marked as spam.
2068
  }
2069
  ?>
2070
  <li>
2071
+ <a <?php echo ( isset( $_GET['limit'] ) && 'all' === $_GET['limit'] || ( ! isset( $_GET['limit'] ) && ! isset( $_GET['restrict'] ) ) ) ? 'class="active-link" aria-current="true"' : ''; ?>
2072
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=all' ); ?>"><?php _e( 'All', 'my-calendar' ); ?></a>
2073
  </li>
2074
  </ul>
2114
  if ( current_user_can( 'mc_approve_events' ) ) {
2115
  echo '<input type="submit" class="button-secondary mc-approve" name="mass_approve" value="' . __( 'Publish events', 'my-calendar' ) . '" /> ';
2116
  }
2117
+ if ( ! ( isset( $_GET['restrict'] ) && 'archived' === $_GET['restrict'] ) ) {
2118
  echo '<input type="submit" class="button-secondary mc-archive" name="mass_archive" value="' . __( 'Archive events', 'my-calendar' ) . '" /> ';
2119
  } else {
2120
  echo '<input type="submit" class="button-secondary mc-archive" name="mass_undo_archive" value="' . __( 'Remove from archive', 'my-calendar' ) . '" /> ';
2121
  }
2122
+ if ( isset( $_GET['restrict'] ) && 'flagged' === $_GET['restrict'] ) {
2123
  echo '<input type="submit" class="button-secondary mc-archive" name="mass_not_spam" value="' . __( 'Not spam', 'my-calendar' ) . '" /> ';
2124
  }
2125
  ?>
2159
  if ( ! is_object( $event ) ) {
2160
  continue;
2161
  }
2162
+ $class = ( 'alternate' === $class ) ? 'even' : 'alternate';
2163
  $pending = ( 0 == $event->event_approved ) ? 'pending' : '';
2164
  $trashed = ( 2 == $event->event_approved ) ? 'trashed' : '';
2165
  $author = ( 0 != $event->event_author ) ? get_userdata( $event->event_author ) : 'Public Submitter';
2166
 
2167
+ if ( 1 == $event->event_flagged && ( isset( $_GET['restrict'] ) && 'flagged' === $_GET['restrict'] ) ) {
2168
  $spam = 'spam';
2169
  $pending = '';
2170
  $spam_label = '<strong>' . __( 'Possible spam', 'my-calendar' ) . ':</strong> ';
2343
  </table>
2344
  <ul class="links">
2345
  <li>
2346
+ <a <?php echo ( isset( $_GET['limit'] ) && 'published' === $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2347
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=published' ); ?>">
2348
  <?php
2349
  // Translators: Number of published events.
2352
  </a>
2353
  </li>
2354
  <li>
2355
+ <a <?php echo ( isset( $_GET['limit'] ) && 'draft' === $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2356
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=draft' ); ?>">
2357
  <?php
2358
  // Translators: Number of draft events.
2361
  </a>
2362
  </li>
2363
  <li>
2364
+ <a <?php echo ( isset( $_GET['limit'] ) && 'trashed' === $_GET['limit'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2365
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=trashed' ); ?>">
2366
  <?php
2367
  // Translators: Number of trashed events.
2370
  </a>
2371
  </li>
2372
  <li>
2373
+ <a <?php echo ( isset( $_GET['restrict'] ) && 'archived' === $_GET['restrict'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2374
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=archived' ); ?>">
2375
  <?php
2376
  // Translators: Number of archived events.
2382
  if ( function_exists( 'akismet_http_post' ) && $allow_filters ) {
2383
  ?>
2384
  <li>
2385
+ <a <?php echo ( isset( $_GET['restrict'] ) && 'flagged' === $_GET['restrict'] ) ? 'class="active-link" aria-current="true"' : ''; ?>
2386
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=flagged&amp;filter=1' ); ?>">
2387
  <?php
2388
  // Translators: Number of events marked as spam.
2394
  }
2395
  ?>
2396
  <li>
2397
+ <a <?php echo ( isset( $_GET['limit'] ) && 'all' === $_GET['limit'] || ( ! isset( $_GET['limit'] ) && ! isset( $_GET['restrict'] ) ) ) ? 'class="active-link" aria-current="true"' : ''; ?>
2398
  href="<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;limit=all' ); ?>"><?php _e( 'All', 'my-calendar' ); ?></a>
2399
  </li>
2400
  </ul>
2426
  <input type="submit" class="button-secondary mc-approve" name="mass_approve" value="<?php _e( 'Publish events', 'my-calendar' ); ?>"/>
2427
  <?php
2428
  }
2429
+ if ( ! ( isset( $_GET['restrict'] ) && 'archived' === $_GET['restrict'] ) ) {
2430
  ?>
2431
  <input type="submit" class="button-secondary mc-archive" name="mass_archive" value="<?php _e( 'Archive events', 'my-calendar' ); ?>"/>
2432
  <?php
2436
 
2437
  <p>
2438
  <?php
2439
+ if ( ! ( isset( $_GET['restrict'] ) && 'archived' === $_GET['restrict'] ) ) {
2440
  ?>
2441
  <a class='mc_filter' href='<?php echo admin_url( 'admin.php?page=my-calendar-manage&amp;restrict=archived' ); ?>'><?php _e( 'View Archived Events', 'my-calendar' ); ?></a>
2442
  <?php
2528
  return array();
2529
  }
2530
 
2531
+ if ( 'add' === $action || 'edit' === $action || 'copy' === $action ) {
2532
  $title = ! empty( $post['event_title'] ) ? trim( $post['event_title'] ) : '';
2533
  $desc = ! empty( $post['content'] ) ? trim( $post['content'] ) : '';
2534
  $short = ! empty( $post['event_short'] ) ? trim( $post['event_short'] ) : '';
2538
  // ...AND there's no reason to allow it, since weekday events will NEVER happen on the weekend.
2539
  $begin = trim( $post['event_begin'][ $i ] );
2540
  $end = ( ! empty( $post['event_end'] ) ) ? trim( $post['event_end'][ $i ] ) : $post['event_begin'][ $i ];
2541
+ if ( 'E' === $recur && 0 == ( date( 'w', mc_strtotime( $begin ) ) || 6 == date( 'w', mc_strtotime( $begin ) ) ) ) {
2542
  if ( 0 == date( 'w', mc_strtotime( $begin ) ) ) {
2543
  $newbegin = my_calendar_add_date( $begin, 1 );
2544
  if ( ! empty( $post['event_end'][ $i ] ) ) {
2573
  } else {
2574
  $endtime = ! empty( $post['event_endtime'][ $i ] ) ? trim( $post['event_endtime'][ $i ] ) : '';
2575
  }
2576
+ $time = ( '' == $time || '00:00:00' === $time ) ? '00:00:00' : $time; // Set at midnight if not provided.
2577
+ $endtime = ( '' == $endtime && '00:00:00' === $time ) ? '23:59:59' : $endtime; // Set at end of night if np.
2578
 
2579
  // Prevent setting enddate to incorrect value on copy.
2580
+ if ( mc_strtotime( $end ) < mc_strtotime( $begin ) && 'copy' === $action ) {
2581
  $end = date( 'Y-m-d', ( mc_strtotime( $begin ) + ( mc_strtotime( $post['prev_event_end'] ) - mc_strtotime( $post['prev_event_begin'] ) ) ) );
2582
  }
2583
  if ( isset( $post['event_allday'] ) && 0 !== (int) $post['event_allday'] ) {
2630
  $event_group_id = ( ( is_array( $post['event_begin'] ) && count( $post['event_begin'] ) > 1 ) || mc_event_is_grouped( $group_id ) ) ? $group_id : 0;
2631
  $event_span = ( ! empty( $post['event_span'] ) && 0 != $event_group_id ) ? 1 : 0;
2632
  $event_hide_end = ( ! empty( $post['event_hide_end'] ) ) ? (int) $post['event_hide_end'] : 0;
2633
+ $event_hide_end = ( '' == $time || '23:59:59' === $time ) ? 1 : $event_hide_end; // Hide end time on all day events.
2634
  // Set location.
2635
  if ( 'none' != $location_preset && is_numeric( $location_preset ) ) {
2636
  $location = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . my_calendar_locations_table() . ' WHERE location_id = %d', $location_preset ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
2666
  $event_phone2 = ! empty( $post['event_phone2'] ) ? $post['event_phone2'] : '';
2667
  $event_access = ! empty( $post['event_access'] ) ? $post['event_access'] : '';
2668
  $event_access = ! empty( $post['event_access_hidden'] ) ? unserialize( $post['event_access_hidden'] ) : $event_access;
2669
+ if ( isset( $post['mc_copy_location'] ) && 'on' === $post['mc_copy_location'] && 0 == $i ) {
2670
  // Only the first event, if adding multiples.
2671
  $add_loc = array(
2672
  'location_label' => $event_label,
2726
  }
2727
  // Run checks on recurrence profile.
2728
  $valid_recur = array( 'W', 'B', 'M', 'U', 'Y', 'D', 'E' );
2729
+ if ( ( 0 == $repeats && 'S' === $recur ) || ( ( $repeats >= 0 ) && in_array( $recur, $valid_recur ) ) ) {
2730
  $recur = $recur . $every;
2731
  } else {
2732
  // if it's not valid, assign a default value.
2747
  $spam_content = ( '' != $desc ) ? $desc : $short;
2748
  $spam = mc_spam( $event_link, $spam_content, $post );
2749
  // Likelihood that event will be flagged as spam, have a zero start time and be legit is minimal. Just kill it.
2750
+ if ( 1 == $spam && '1970-01-01' === $begin ) {
2751
  die;
2752
  }
2753
 
3123
  */
3124
  function mc_is_all_day( $event ) {
3125
 
3126
+ return ( '00:00:00' === $event->event_time && '23:59:59' === $event->event_endtime ) ? true : false;
3127
  }
3128
 
3129
  /**
3334
  $text_link = '';
3335
  $controls = array();
3336
 
3337
+ if ( 'edit' === $mode ) {
3338
  $publish_text = __( 'Save', 'my-calendar' );
3339
  $event_id = $event->event_id;
3340
  $args = '';
3345
  }
3346
  }
3347
  $controls['delete'] = "<span class='dashicons dashicons-no' aria-hidden='true'></span><a href='" . admin_url( "admin.php?page=my-calendar-manage&amp;mode=delete&amp;event_id=$event_id$args" ) . "' class='delete'>" . __( 'Delete', 'my-calendar' ) . '</a>';
3348
+ if ( 'true' === apply_filters( 'mc_use_permalinks', get_option( 'mc_use_permalinks' ) ) ) {
3349
  $post_id = $event->event_post;
3350
  $post_link = ( $post_id ) ? get_edit_post_link( $post_id ) : false;
3351
  $controls['post'] = ( $post_link ) ? sprintf( "<span class='dashicons dashicons-admin-post' aria-hidden='true'></span><a href='%s'>" . __( 'Edit Event Post', 'my-calendar' ) . '</a>', $post_link ) : '';
3369
  $controls['publish'] = '<input type="submit" name="save" class="button-primary" value="' . esc_attr( $publish_text ) . '" />';
3370
  // Event Status settings: draft, published, trash, (custom).
3371
  // Switch to select status.
3372
+ if ( 'header' === $position ) {
3373
+ if ( 'edit' === $mode ) {
3374
  $controls['prev_status'] = "<input type='hidden' name='prev_event_status' value='" . absint( $event->event_approved ) . "' />";
3375
  if ( current_user_can( 'mc_approve_events' ) || current_user_can( 'mc_publish_events' ) ) { // Added by Roland P.
3376
  if ( $has_data && '1' == $event->event_approved ) {
3584
  * @return string form options
3585
  */
3586
  function mc_recur_options( $value ) {
3587
+ $s = ( 'S' === $value ) ? ' selected="selected"' : '';
3588
+ $d = ( 'D' === $value ) ? ' selected="selected"' : '';
3589
+ $e = ( 'E' === $value ) ? ' selected="selected"' : '';
3590
+ $w = ( 'W' === $value || 'B' == $value ) ? ' selected="selected"' : '';
3591
+ $m = ( 'M' === $value ) ? ' selected="selected"' : '';
3592
+ $u = ( 'U' === $value ) ? ' selected="selected"' : '';
3593
+ $y = ( 'Y' === $value ) ? ' selected="selected"' : '';
3594
 
3595
  $return = "
3596
  <option class='input' value='S' $s>" . __( 'Does not recur', 'my-calendar' ) . "</option>
3763
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3764
  'occur_group_id' => $group_id,
3765
  );
3766
+ if ( 'test' === $test && $i > 0 ) {
3767
  return $data;
3768
  }
3769
  $return[] = $data;
3793
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3794
  'occur_group_id' => $group_id,
3795
  );
3796
+ if ( 'test' === $test && $i > 0 ) {
3797
  return $data;
3798
  }
3799
  $return[] = $data;
3820
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3821
  'occur_group_id' => $group_id,
3822
  );
3823
+ if ( 'test' === $test && $i > 0 ) {
3824
  return $data;
3825
  }
3826
  $return[] = $data;
3845
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3846
  'occur_group_id' => $group_id,
3847
  );
3848
+ if ( 'test' === $test && $i > 0 ) {
3849
  return $data;
3850
  }
3851
  $return[] = $data;
3869
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3870
  'occur_group_id' => $group_id,
3871
  );
3872
+ if ( 'test' === $test && $i > 0 ) {
3873
  return $data;
3874
  }
3875
  $return[] = $data;
3893
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3894
  'occur_group_id' => $group_id,
3895
  );
3896
+ if ( 'test' === $test && $i > 0 ) {
3897
  return $data;
3898
  }
3899
  $return[] = $data;
3975
  'occur_end' => date( 'Y-m-d H:i:s', $end ),
3976
  'occur_group_id' => $group_id,
3977
  );
3978
+ if ( 'test' === $test && $i > 0 ) {
3979
  return $data;
3980
  }
3981
  $return[] = $data;
my-calendar-events.php CHANGED
@@ -25,12 +25,12 @@ function mc_event_object( $object ) {
25
  if ( ! property_exists( $object, 'categories' ) ) {
26
  $object->categories = mc_get_categories( $object, false );
27
  }
28
- if ( ! property_exists( $object, 'location' ) && is_numeric( $object->event_location ) && 0 != $object->event_location ) {
29
  $object->location = mc_get_location( $object->event_location );
30
  }
31
  if ( ! property_exists( $object, 'uid' ) ) {
32
- $guid = get_post_meta( $object->event_post, '_mc_guid', true );
33
- if ( '' == $guid ) {
34
  $guid = mc_create_guid( $object );
35
  }
36
  $object->uid = $guid;
@@ -118,49 +118,100 @@ function my_calendar_get_events( $args ) {
118
  $exclude_categories = mc_private_categories();
119
  $arr_events = array();
120
 
121
- $event_query = '
122
- SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end
123
- FROM ' . my_calendar_event_table( $site ) . '
124
- JOIN ' . my_calendar_table( $site ) . ' AS e
125
- ON (event_id=occur_event_id)
126
- JOIN ' . my_calendar_categories_table( $site ) . " AS c
127
- ON (event_category=category_id)
128
- $join
129
- WHERE $select_published $select_category $select_location $select_author $select_host $select_access $search
130
- AND ( DATE(occur_begin) BETWEEN '$from 00:00:00' AND '$to 23:59:59'
131
- OR DATE(occur_end) BETWEEN '$from 00:00:00' AND '$to 23:59:59'
132
- OR ( DATE('$from') BETWEEN DATE(occur_begin) AND DATE(occur_end) )
133
- OR ( DATE('$to') BETWEEN DATE(occur_begin) AND DATE(occur_end) ) )
134
- $exclude_categories
135
- ORDER BY " . apply_filters( 'mc_primary_sort', 'occur_begin' ) . ', ' . apply_filters( 'mc_secondary_sort', 'event_title ASC' );
136
-
137
- $events = $mcdb->get_results( $event_query );
138
-
139
- if ( ! empty( $events ) ) {
140
- $cats = array();
141
- $locs = array();
142
- foreach ( array_keys( $events ) as $key ) {
143
- $event =& $events[ $key ];
144
- $event->site_id = $site;
145
- $object_id = $event->event_id;
146
- $location_id = $event->event_location;
147
- if ( ! isset( $cats[ $object_id ] ) ) {
148
- $categories = mc_get_categories( $event, false );
149
- $event->categories = $categories;
150
- $cats[ $object_id ] = $categories;
151
- } else {
152
- $event->categories = $cats[ $object_id ];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  }
154
- if ( 0 != $location_id ) {
155
- if ( ! isset( $locs[ $object_id ] ) ) {
156
- $location = mc_get_location( $location_id );
157
- $event->location = $location;
158
- $locs[ $object_id ] = $location;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  } else {
160
- $event->location = $locs[ $object_id ];
 
 
 
 
 
 
 
 
 
161
  }
 
162
  }
163
- $arr_events[] = mc_event_object( $event );
164
  }
165
  }
166
 
@@ -350,10 +401,10 @@ function mc_get_rss_events( $cat_id = false ) {
350
  $output = array();
351
  foreach ( array_keys( $events ) as $key ) {
352
  $event =& $events[ $key ];
353
- if ( ! in_array( $event->occur_group_id, $groups ) ) {
354
  $output[ $event->event_begin ][] = $event;
355
  }
356
- if ( 1 == $event->event_span ) {
357
  $groups[] = $event->occur_group_id;
358
  }
359
  }
@@ -649,6 +700,80 @@ function my_calendar_events_now( $category = 'default', $template = '<strong>{li
649
  return $return;
650
  }
651
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
652
  /**
653
  * Get all occurrences associated with an event.
654
  *
@@ -710,7 +835,7 @@ function mc_holiday_limit( $events, $holidays ) {
710
  foreach ( array_keys( $events ) as $key ) {
711
  if ( ! empty( $holidays[ $key ] ) ) {
712
  foreach ( $events[ $key ] as $k => $event ) {
713
- if ( get_option( 'mc_skip_holidays_category' ) != $event->event_category && 1 == $event->event_holiday ) {
714
  unset( $events[ $key ][ $k ] );
715
  }
716
  }
25
  if ( ! property_exists( $object, 'categories' ) ) {
26
  $object->categories = mc_get_categories( $object, false );
27
  }
28
+ if ( ! property_exists( $object, 'location' ) && is_numeric( $object->event_location ) && 0 !== (int) $object->event_location ) {
29
  $object->location = mc_get_location( $object->event_location );
30
  }
31
  if ( ! property_exists( $object, 'uid' ) ) {
32
+ $guid = (string) get_post_meta( $object->event_post, '_mc_guid', true );
33
+ if ( '' === $guid ) {
34
  $guid = mc_create_guid( $object );
35
  }
36
  $object->uid = $guid;
118
  $exclude_categories = mc_private_categories();
119
  $arr_events = array();
120
 
121
+ $site = apply_filters( 'mc_get_events_sites', $site, $args );
122
+ if ( is_array( $site ) ) {
123
+ foreach ( $site as $s ) {
124
+ $event_query = '
125
+ SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end
126
+ FROM ' . my_calendar_event_table( $s ) . '
127
+ JOIN ' . my_calendar_table( $s ) . ' AS e
128
+ ON (event_id=occur_event_id)
129
+ JOIN ' . my_calendar_categories_table( $s ) . " AS c
130
+ ON (event_category=category_id)
131
+ $join
132
+ WHERE $select_published $select_category $select_location $select_author $select_host $select_access $search
133
+ AND ( DATE(occur_begin) BETWEEN '$from 00:00:00' AND '$to 23:59:59'
134
+ OR DATE(occur_end) BETWEEN '$from 00:00:00' AND '$to 23:59:59'
135
+ OR ( DATE('$from') BETWEEN DATE(occur_begin) AND DATE(occur_end) )
136
+ OR ( DATE('$to') BETWEEN DATE(occur_begin) AND DATE(occur_end) ) )
137
+ $exclude_categories
138
+ ORDER BY " . apply_filters( 'mc_primary_sort', 'occur_begin' ) . ', ' . apply_filters( 'mc_secondary_sort', 'event_title ASC' );
139
+
140
+ $events = $mcdb->get_results( $event_query );
141
+
142
+ if ( ! empty( $events ) ) {
143
+ $cats = array();
144
+ $locs = array();
145
+ foreach ( array_keys( $events ) as $key ) {
146
+ $event =& $events[ $key ];
147
+ $event->site_id = $s;
148
+ $object_id = $event->event_id;
149
+ $location_id = $event->event_location;
150
+ if ( ! isset( $cats[ $object_id ] ) ) {
151
+ $categories = mc_get_categories( $event, false );
152
+ $event->categories = $categories;
153
+ $cats[ $object_id ] = $categories;
154
+ } else {
155
+ $event->categories = $cats[ $object_id ];
156
+ }
157
+ if ( 0 !== (int) $location_id ) {
158
+ if ( ! isset( $locs[ $object_id ] ) ) {
159
+ $location = mc_get_location( $location_id );
160
+ $event->location = $location;
161
+ $locs[ $object_id ] = $location;
162
+ } else {
163
+ $event->location = $locs[ $object_id ];
164
+ }
165
+ }
166
+ $arr_events[] = mc_event_object( $event );
167
+ }
168
  }
169
+ }
170
+ } else {
171
+ $event_query = '
172
+ SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end
173
+ FROM ' . my_calendar_event_table( $site ) . '
174
+ JOIN ' . my_calendar_table( $site ) . ' AS e
175
+ ON (event_id=occur_event_id)
176
+ JOIN ' . my_calendar_categories_table( $site ) . " AS c
177
+ ON (event_category=category_id)
178
+ $join
179
+ WHERE $select_published $select_category $select_location $select_author $select_host $select_access $search
180
+ AND ( DATE(occur_begin) BETWEEN '$from 00:00:00' AND '$to 23:59:59'
181
+ OR DATE(occur_end) BETWEEN '$from 00:00:00' AND '$to 23:59:59'
182
+ OR ( DATE('$from') BETWEEN DATE(occur_begin) AND DATE(occur_end) )
183
+ OR ( DATE('$to') BETWEEN DATE(occur_begin) AND DATE(occur_end) ) )
184
+ $exclude_categories
185
+ ORDER BY " . apply_filters( 'mc_primary_sort', 'occur_begin' ) . ', ' . apply_filters( 'mc_secondary_sort', 'event_title ASC' );
186
+
187
+ $events = $mcdb->get_results( $event_query );
188
+
189
+ if ( ! empty( $events ) ) {
190
+ $cats = array();
191
+ $locs = array();
192
+ foreach ( array_keys( $events ) as $key ) {
193
+ $event =& $events[ $key ];
194
+ $event->site_id = $site;
195
+ $object_id = $event->event_id;
196
+ $location_id = $event->event_location;
197
+ if ( ! isset( $cats[ $object_id ] ) ) {
198
+ $categories = mc_get_categories( $event, false );
199
+ $event->categories = $categories;
200
+ $cats[ $object_id ] = $categories;
201
  } else {
202
+ $event->categories = $cats[ $object_id ];
203
+ }
204
+ if ( 0 !== (int) $location_id ) {
205
+ if ( ! isset( $locs[ $object_id ] ) ) {
206
+ $location = mc_get_location( $location_id );
207
+ $event->location = $location;
208
+ $locs[ $object_id ] = $location;
209
+ } else {
210
+ $event->location = $locs[ $object_id ];
211
+ }
212
  }
213
+ $arr_events[] = mc_event_object( $event );
214
  }
 
215
  }
216
  }
217
 
401
  $output = array();
402
  foreach ( array_keys( $events ) as $key ) {
403
  $event =& $events[ $key ];
404
+ if ( ! in_array( $event->occur_group_id, $groups, true ) ) {
405
  $output[ $event->event_begin ][] = $event;
406
  }
407
+ if ( 1 === (int) $event->event_span ) {
408
  $groups[] = $event->occur_group_id;
409
  }
410
  }
700
  return $return;
701
  }
702
 
703
+
704
+ /**
705
+ * Get the next scheduled event, not currently happening.
706
+ *
707
+ * @param mixed $category string/integer category ID or 'default'.
708
+ * @param string $template display Template.
709
+ * @param integer $skip Number of events to skip.
710
+ * @param integer $site Site ID if fetching events from a different multisite instance.
711
+ *
712
+ * @return string output HTML
713
+ */
714
+ function my_calendar_events_next( $category = 'default', $template = '<strong>{link_title}</strong> {timerange}', $skip = 0, $site = false ) {
715
+ if ( $site ) {
716
+ $site = ( 'global' === $site ) ? BLOG_ID_CURRENT_SITE : $site;
717
+ switch_to_blog( $site );
718
+ }
719
+
720
+ global $wpdb;
721
+ $mcdb = $wpdb;
722
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
723
+ $mcdb = mc_remote_db();
724
+ }
725
+
726
+ $arr_events = array();
727
+ $select_published = mc_select_published();
728
+ $cat_limit = ( 'default' !== $category ) ? mc_select_category( $category ) : array();
729
+ $join = ( isset( $cat_limit[0] ) ) ? $cat_limit[0] : '';
730
+ $select_category = ( isset( $cat_limit[1] ) ) ? $cat_limit[1] : '';
731
+ $exclude_categories = mc_private_categories();
732
+
733
+ // May add support for location/author/host later.
734
+ $select_location = '';
735
+ $select_author = '';
736
+ $select_host = '';
737
+ $now = date( 'Y-m-d H:i:s', current_time( 'timestamp' ) );
738
+ $event_query = 'SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end
739
+ FROM ' . my_calendar_event_table( $site ) . '
740
+ JOIN ' . my_calendar_table( $site ) . " AS e
741
+ ON (event_id=occur_event_id)
742
+ $join
743
+ JOIN " . my_calendar_categories_table( $site ) . " as c
744
+ ON (e.event_category=c.category_id)
745
+ WHERE $select_published $select_category $select_location $select_author $select_host
746
+ $exclude_categories
747
+ AND DATE(occur_begin) > CAST('$now' as DATETIME) ORDER BY occur_begin LIMIT $skip,1";
748
+
749
+ $events = $mcdb->get_results( $event_query );
750
+ if ( ! empty( $events ) ) {
751
+ foreach ( array_keys( $events ) as $key ) {
752
+ $event =& $events[ $key ];
753
+ $arr_events[] = $event;
754
+ }
755
+ }
756
+ if ( ! empty( $arr_events ) ) {
757
+ $event = mc_create_tags( $arr_events[0] );
758
+
759
+ if ( mc_key_exists( $template ) ) {
760
+ $template = mc_get_custom_template( $template );
761
+ }
762
+
763
+ $output = mc_draw_template( $event, apply_filters( 'mc_happening_next_template', $template, $event ) );
764
+ $return = mc_run_shortcodes( $output );
765
+ } else {
766
+ $return = '';
767
+ }
768
+
769
+ if ( $site ) {
770
+ restore_current_blog();
771
+ }
772
+
773
+ return $return;
774
+ }
775
+
776
+
777
  /**
778
  * Get all occurrences associated with an event.
779
  *
835
  foreach ( array_keys( $events ) as $key ) {
836
  if ( ! empty( $holidays[ $key ] ) ) {
837
  foreach ( $events[ $key ] as $k => $event ) {
838
+ if ( (int) get_option( 'mc_skip_holidays_category' ) !== (int) $event->event_category && 1 === (int) $event->event_holiday ) {
839
  unset( $events[ $key ][ $k ] );
840
  }
841
  }
my-calendar-generator.php CHANGED
@@ -44,7 +44,7 @@ function mc_generate() {
44
  }
45
  foreach ( $_POST as $key => $value ) {
46
  if ( 'generator' != $key && 'shortcode' != $key && '_wpnonce' != $key ) {
47
- if ( 'template' == $key ) {
48
  $template = mc_create_template( $value, array( 'mc_template_key' => $templatekey ) );
49
  $v = $template;
50
  $append = "<a href='" . add_query_arg( 'mc_template', $template, admin_url( 'admin.php?page=my-calendar-templates' ) ) . "'>" . __( 'Edit this Template', 'my-calendar' ) . ' &rarr;</a>';
@@ -142,7 +142,7 @@ function mc_generator( $type ) {
142
  </p>
143
  <?php
144
  // Main shortcode only.
145
- if ( 'main' == $type ) {
146
  ?>
147
  <p>
148
  <label for="format"><?php _e( 'Format', 'my-calendar' ); ?></label>
@@ -168,7 +168,7 @@ function mc_generator( $type ) {
168
  <?php
169
  global $wpdb;
170
  $mcdb = $wpdb;
171
- if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
172
  $mcdb = mc_remote_db();
173
  }
174
  $query = 'SELECT event_begin FROM ' . my_calendar_table() . ' WHERE event_approved = 1 AND event_flagged <> 1 ORDER BY event_begin ASC LIMIT 0 , 1';
@@ -247,7 +247,7 @@ function mc_generator( $type ) {
247
  </p>
248
  <?php
249
  }
250
- if ( 'upcoming' == $type || 'today' == $type ) {
251
  // Upcoming Events & Today's Events shortcodes.
252
  ?>
253
  <p>
@@ -260,7 +260,7 @@ function mc_generator( $type ) {
260
  </p>
261
  <?php
262
  }
263
- if ( 'upcoming' == $type ) {
264
  // Upcoming events only.
265
  ?>
266
  <p>
44
  }
45
  foreach ( $_POST as $key => $value ) {
46
  if ( 'generator' != $key && 'shortcode' != $key && '_wpnonce' != $key ) {
47
+ if ( 'template' === $key ) {
48
  $template = mc_create_template( $value, array( 'mc_template_key' => $templatekey ) );
49
  $v = $template;
50
  $append = "<a href='" . add_query_arg( 'mc_template', $template, admin_url( 'admin.php?page=my-calendar-templates' ) ) . "'>" . __( 'Edit this Template', 'my-calendar' ) . ' &rarr;</a>';
142
  </p>
143
  <?php
144
  // Main shortcode only.
145
+ if ( 'main' === $type ) {
146
  ?>
147
  <p>
148
  <label for="format"><?php _e( 'Format', 'my-calendar' ); ?></label>
168
  <?php
169
  global $wpdb;
170
  $mcdb = $wpdb;
171
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
172
  $mcdb = mc_remote_db();
173
  }
174
  $query = 'SELECT event_begin FROM ' . my_calendar_table() . ' WHERE event_approved = 1 AND event_flagged <> 1 ORDER BY event_begin ASC LIMIT 0 , 1';
247
  </p>
248
  <?php
249
  }
250
+ if ( 'upcoming' === $type || 'today' === $type ) {
251
  // Upcoming Events & Today's Events shortcodes.
252
  ?>
253
  <p>
260
  </p>
261
  <?php
262
  }
263
+ if ( 'upcoming' === $type ) {
264
  // Upcoming events only.
265
  ?>
266
  <p>
my-calendar-group-manager.php CHANGED
@@ -146,7 +146,7 @@ function my_calendar_save_group( $action, $output, $event_id = false ) {
146
  $proceed = $output[0];
147
  $message = '';
148
 
149
- if ( 'edit' === $action && true == $proceed ) {
150
  $event_author = (int) ( $_POST['event_author'] );
151
  if ( mc_can_edit_event( $event_id ) ) {
152
  $update = $output[2];
@@ -287,14 +287,16 @@ function mc_group_form( $group_id, $type = 'break' ) {
287
  */
288
  function mc_edit_groups( $mode = 'edit', $event_id = false, $group_id = false ) {
289
  global $submission;
290
- $message = '';
291
- $group = '';
292
- if ( false != $event_id ) {
 
 
293
  $data = mc_group_data( $event_id );
294
  } else {
295
  $data = $submission;
296
  }
297
- if ( false != $group_id ) {
298
  $group = mc_group_form( $group_id, 'break' );
299
  } else {
300
  $message .= __( 'You must provide a group ID to edit groups', 'my-calendar' );
@@ -368,11 +370,11 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
368
  <?php
369
  $apply = mc_group_form( $group_id, 'apply' );
370
  echo $apply;
371
- if ( 0 == $data->event_repeats && ( 'S1' === $data->event_recur || 'S' === $data->event_recur ) ) {
372
  $span_checked = '';
373
- if ( ! empty( $data ) && 1 == $data->event_span ) {
374
  $span_checked = ' checked="checked"';
375
- } elseif ( ! empty( $data ) && 0 == $data->event_span ) {
376
  $span_checked = '';
377
  }
378
  ?>
@@ -473,9 +475,9 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
473
  $user_list = mc_get_users( 'hosts' );
474
  foreach ( $user_list as $u ) {
475
  echo '<option value="' . $u->ID . '"';
476
- if ( is_object( $data ) && $data->event_host == $u->ID ) {
477
  echo ' selected="selected"';
478
- } elseif ( is_object( $u ) && $u->ID == $user->ID && empty( $data->event_host ) ) {
479
  echo ' selected="selected"';
480
  }
481
  $display_name = ( '' === $u->display_name ) ? $u->user_nicename : $u->display_name;
@@ -507,9 +509,9 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
507
  <?php
508
  }
509
  if ( 'on' === $mc_input['event_link'] || $input_all ) {
510
- if ( ! empty( $data ) && 1 == $data->event_link_expires ) {
511
  $exp_checked = ' checked="checked"';
512
- } elseif ( ! empty( $data ) && 0 == $data->event_link_expires ) {
513
  $exp_checked = '';
514
  } elseif ( 'true' === get_option( 'mc_event_link_expires' ) ) {
515
  $exp_checked = ' checked="checked"';
@@ -758,7 +760,7 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
758
  $label = $a;
759
  $checked = '';
760
  if ( is_array( $location_access ) ) {
761
- $checked = ( in_array( $k, $location_access ) ) ? " checked='checked'" : '';
762
  }
763
  $item = sprintf( '<li><input type="checkbox" id="%1$s" name="event_access[]" value="%4$s" class="checkbox" %2$s /> <label for="%1$s">%3$s</label></li>', esc_attr( $id ), $checked, esc_html( $label ), esc_attr( $k ) );
764
  $access_list .= $item;
@@ -819,7 +821,7 @@ function mc_check_group_data( $action, $post ) {
819
  foreach ( $cats as $cat ) {
820
  $private = mc_get_category_detail( $cat, 'category_private' );
821
  // If a selected category is private, set that category as primary instead.
822
- if ( 1 == $private ) {
823
  $primary = $cat;
824
  }
825
  }
@@ -871,7 +873,7 @@ function mc_check_group_data( $action, $post ) {
871
  $event_access = ! empty( $post['event_access_hidden'] ) ? unserialize( $post['event_access_hidden'] ) : $event_access;
872
  }
873
  // We check to make sure the URL is acceptable (blank or starting with http://).
874
- if ( ! ( '' == $event_link || preg_match( '/^(http)(s?)(:)\/\//', $event_link ) ) ) {
875
  $event_link = 'http://' . $event_link;
876
  }
877
  }
@@ -1070,11 +1072,11 @@ function mc_list_groups() {
1070
  $categories = $wpdb->get_results( 'SELECT * FROM ' . my_calendar_categories_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
1071
  foreach ( $events as $event ) {
1072
  $class = ( 'alternate' === $class ) ? '' : 'alternate';
1073
- $spam = ( 1 == $event->event_flagged ) ? ' spam' : '';
1074
- $spam_label = ( 1 == $event->event_flagged ) ? '<strong>Possible spam:</strong> ' : '';
1075
- $author = ( 0 != $event->event_author ) ? get_userdata( $event->event_author ) : 'Public Submitter';
1076
  $can_edit = mc_can_edit_event( $event );
1077
- if ( '' != $event->event_link ) {
1078
  $title = "<a href='" . esc_attr( $event->event_link ) . "'>" . strip_tags( $event->event_title, mc_strip_tags() ) . '</a>';
1079
  } else {
1080
  $title = $event->event_title;
@@ -1086,7 +1088,7 @@ function mc_list_groups() {
1086
  <label for="mc<?php echo $event->event_id; ?>"><?php echo $event->event_id; ?></label>
1087
  </th>
1088
  <th scope="row">
1089
- <?php echo ( 0 == $event->event_group_id ) ? '-' : $event->event_group_id; ?>
1090
  </th>
1091
  <td>
1092
  <strong>
@@ -1149,7 +1151,7 @@ function mc_list_groups() {
1149
  <?php
1150
  $this_category = $event->event_category;
1151
  foreach ( $categories as $key => $value ) {
1152
- if ( $value->category_id == $this_category ) {
1153
  $this_cat = $categories[ $key ];
1154
  }
1155
  }
146
  $proceed = $output[0];
147
  $message = '';
148
 
149
+ if ( 'edit' === $action && true === $proceed ) {
150
  $event_author = (int) ( $_POST['event_author'] );
151
  if ( mc_can_edit_event( $event_id ) ) {
152
  $update = $output[2];
287
  */
288
  function mc_edit_groups( $mode = 'edit', $event_id = false, $group_id = false ) {
289
  global $submission;
290
+ $event_id = ( 0 === $event_id ) ? false : $event_id;
291
+ $group_id = ( 0 === $group_id ) ? false : $group_id;
292
+ $message = '';
293
+ $group = '';
294
+ if ( false !== $event_id ) {
295
  $data = mc_group_data( $event_id );
296
  } else {
297
  $data = $submission;
298
  }
299
+ if ( false !== $group_id ) {
300
  $group = mc_group_form( $group_id, 'break' );
301
  } else {
302
  $message .= __( 'You must provide a group ID to edit groups', 'my-calendar' );
370
  <?php
371
  $apply = mc_group_form( $group_id, 'apply' );
372
  echo $apply;
373
+ if ( '0' === $data->event_repeats && ( 'S1' === $data->event_recur || 'S' === $data->event_recur ) ) {
374
  $span_checked = '';
375
+ if ( ! empty( $data ) && '1' === $data->event_span ) {
376
  $span_checked = ' checked="checked"';
377
+ } elseif ( ! empty( $data ) && '0' === $data->event_span ) {
378
  $span_checked = '';
379
  }
380
  ?>
475
  $user_list = mc_get_users( 'hosts' );
476
  foreach ( $user_list as $u ) {
477
  echo '<option value="' . $u->ID . '"';
478
+ if ( is_object( $data ) && absint( $data->event_host ) === absint( $u->ID ) ) {
479
  echo ' selected="selected"';
480
+ } elseif ( is_object( $u ) && $u->ID === $user->ID && empty( $data->event_host ) ) {
481
  echo ' selected="selected"';
482
  }
483
  $display_name = ( '' === $u->display_name ) ? $u->user_nicename : $u->display_name;
509
  <?php
510
  }
511
  if ( 'on' === $mc_input['event_link'] || $input_all ) {
512
+ if ( ! empty( $data ) && '1' === $data->event_link_expires ) {
513
  $exp_checked = ' checked="checked"';
514
+ } elseif ( ! empty( $data ) && '0' === $data->event_link_expires ) {
515
  $exp_checked = '';
516
  } elseif ( 'true' === get_option( 'mc_event_link_expires' ) ) {
517
  $exp_checked = ' checked="checked"';
760
  $label = $a;
761
  $checked = '';
762
  if ( is_array( $location_access ) ) {
763
+ $checked = ( in_array( $k, $location_access, true ) ) ? " checked='checked'" : '';
764
  }
765
  $item = sprintf( '<li><input type="checkbox" id="%1$s" name="event_access[]" value="%4$s" class="checkbox" %2$s /> <label for="%1$s">%3$s</label></li>', esc_attr( $id ), $checked, esc_html( $label ), esc_attr( $k ) );
766
  $access_list .= $item;
821
  foreach ( $cats as $cat ) {
822
  $private = mc_get_category_detail( $cat, 'category_private' );
823
  // If a selected category is private, set that category as primary instead.
824
+ if ( 1 === (int) $private ) {
825
  $primary = $cat;
826
  }
827
  }
873
  $event_access = ! empty( $post['event_access_hidden'] ) ? unserialize( $post['event_access_hidden'] ) : $event_access;
874
  }
875
  // We check to make sure the URL is acceptable (blank or starting with http://).
876
+ if ( ! ( '' === $event_link || preg_match( '/^(http)(s?)(:)\/\//', $event_link ) ) ) {
877
  $event_link = 'http://' . $event_link;
878
  }
879
  }
1072
  $categories = $wpdb->get_results( 'SELECT * FROM ' . my_calendar_categories_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
1073
  foreach ( $events as $event ) {
1074
  $class = ( 'alternate' === $class ) ? '' : 'alternate';
1075
+ $spam = ( '1' === $event->event_flagged ) ? ' spam' : '';
1076
+ $spam_label = ( '1' === $event->event_flagged ) ? '<strong>Possible spam:</strong> ' : '';
1077
+ $author = ( '0' !== $event->event_author ) ? get_userdata( $event->event_author ) : 'Public Submitter';
1078
  $can_edit = mc_can_edit_event( $event );
1079
+ if ( '' !== trim( $event->event_link ) ) {
1080
  $title = "<a href='" . esc_attr( $event->event_link ) . "'>" . strip_tags( $event->event_title, mc_strip_tags() ) . '</a>';
1081
  } else {
1082
  $title = $event->event_title;
1088
  <label for="mc<?php echo $event->event_id; ?>"><?php echo $event->event_id; ?></label>
1089
  </th>
1090
  <th scope="row">
1091
+ <?php echo ( '0' === $event->event_group_id ) ? '-' : $event->event_group_id; ?>
1092
  </th>
1093
  <td>
1094
  <strong>
1151
  <?php
1152
  $this_category = $event->event_category;
1153
  foreach ( $categories as $key => $value ) {
1154
+ if ( $value->category_id === $this_category ) {
1155
  $this_cat = $categories[ $key ];
1156
  }
1157
  }
my-calendar-install.php CHANGED
@@ -24,8 +24,8 @@ function mc_widget_defaults() {
24
  $defaults = array(
25
  'upcoming' => array(
26
  'type' => 'event',
27
- 'before' => 3,
28
- 'after' => 3,
29
  'template' => $default_template,
30
  'category' => '',
31
  'text' => '',
@@ -390,14 +390,19 @@ function mc_migrate_db() {
390
  return; // No events, migration unnecessary.
391
  }
392
  // Step 2) migrate events.
393
- $events = $wpdb->get_results( 'SELECT event_id, event_begin, event_time, event_end, event_endtime FROM ' . my_calendar_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
394
  foreach ( $events as $event ) {
395
  // assign endtimes to all events.
396
  if ( '00:00:00' === $event->event_endtime && '00:00:00' !== $event->event_time ) {
397
  $event->event_endtime = date( 'H:i:s', strtotime( "$event->event_time +1 hour" ) );
398
  mc_flag_event( $event->event_id, $event->event_endtime );
399
  }
400
-
 
 
 
 
 
401
  $dates = array(
402
  'event_begin' => $event->event_begin,
403
  'event_end' => $event->event_end,
24
  $defaults = array(
25
  'upcoming' => array(
26
  'type' => 'event',
27
+ 'before' => 0,
28
+ 'after' => 5,
29
  'template' => $default_template,
30
  'category' => '',
31
  'text' => '',
390
  return; // No events, migration unnecessary.
391
  }
392
  // Step 2) migrate events.
393
+ $events = $wpdb->get_results( 'SELECT event_id, event_begin, event_time, event_end, event_endtime, event_category FROM ' . my_calendar_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
394
  foreach ( $events as $event ) {
395
  // assign endtimes to all events.
396
  if ( '00:00:00' === $event->event_endtime && '00:00:00' !== $event->event_time ) {
397
  $event->event_endtime = date( 'H:i:s', strtotime( "$event->event_time +1 hour" ) );
398
  mc_flag_event( $event->event_id, $event->event_endtime );
399
  }
400
+ // Set up category relationships if missing.
401
+ $cats = $wpdb->get_results( $wpdb->prepare( 'SELECT category_id FROM ' . my_calendar_category_relationships_table() . ' WHERE event_id = %d', $event->event_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
402
+ if ( ! $cats ) {
403
+ $cats = array( $event->event_category );
404
+ mc_set_category_relationships( $cats, $event->event_id );
405
+ }
406
  $dates = array(
407
  'event_begin' => $event->event_begin,
408
  'event_end' => $event->event_end,
my-calendar-limits.php CHANGED
@@ -24,8 +24,8 @@ function mc_prepare_search_query( $query ) {
24
  global $wpdb;
25
  $db_type = mc_get_db_type();
26
  $search = '';
27
- if ( '' != $query ) {
28
- if ( 'MyISAM' == $db_type ) {
29
  $query = esc_sql( $query );
30
  $search = ' AND MATCH(' . apply_filters( 'mc_search_fields', 'event_title,event_desc,event_short,event_label,event_city,event_postcode,event_registration' ) . ") AGAINST ( '$query' IN BOOLEAN MODE ) ";
31
  } else {
@@ -48,12 +48,12 @@ function mc_prepare_search_query( $query ) {
48
  * @return string SQL modifiers.
49
  */
50
  function mc_select_category( $category, $type = 'event', $group = 'events' ) {
51
- if ( '' == $category ) {
52
  return '';
53
  }
54
  $category = urldecode( $category );
55
  $select_clause = '';
56
- $data = ( 'category' == $group ) ? 'category_id' : 'r.category_id';
57
  if ( preg_match( '/^all$|^all,|,all$|,all,/i', $category ) > 0 ) {
58
 
59
  return '';
@@ -66,7 +66,7 @@ function mc_select_category( $category, $type = 'event', $group = 'events' ) {
66
  }
67
 
68
  $join = '';
69
- if ( '' != $select_clause ) {
70
  $join = ' JOIN ' . my_calendar_category_relationships_table() . ' AS r ON r.event_id = e.event_id ';
71
  }
72
 
@@ -86,7 +86,7 @@ function mc_category_select_ids( $category ) {
86
  $mcdb = $wpdb;
87
  $select = array();
88
 
89
- if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
90
  $mcdb = mc_remote_db();
91
  }
92
 
@@ -135,15 +135,15 @@ function mc_category_select_ids( $category ) {
135
  * @return string WHERE limits
136
  */
137
  function mc_select_author( $author, $type = 'event', $context = 'author' ) {
138
- if ( '' == $author ) {
139
  return '';
140
  }
141
  $author = urldecode( $author );
142
- if ( '' == $author || 'all' == $author || 'default' == $author || null == $author ) {
143
  return '';
144
  }
145
  $select_author = '';
146
- $data = ( 'author' == $context ) ? 'event_author' : 'event_host';
147
 
148
  if ( preg_match( '/^all$|^all,|,all$|,all,/i', $author ) > 0 ) {
149
  return '';
@@ -229,11 +229,9 @@ function mc_select_location( $ltype = '', $lvalue = '' ) {
229
  $limit_string = '';
230
  $location = '';
231
  $current_location = '';
232
- if ( '' != $ltype && '' != $lvalue ) {
233
- if ( '' != $ltype && '' != $lvalue ) {
234
- $location = $ltype;
235
- $current_location = $lvalue;
236
- }
237
  switch ( $location ) {
238
  case 'name':
239
  $location_type = 'event_label';
@@ -256,8 +254,8 @@ function mc_select_location( $ltype = '', $lvalue = '' ) {
256
  default:
257
  $location_type = $location;
258
  }
259
- if ( in_array( $location_type, array( 'event_label', 'event_city', 'event_state', 'event_postcode', 'event_country', 'event_region', 'event_location', 'event_street', 'event_street2', 'event_url', 'event_longitude', 'event_latitude', 'event_zoom', 'event_phone', 'event_phone2' ) ) ) {
260
- if ( 'all' != $current_location && '' != $current_location ) {
261
  $current_location = trim( $current_location );
262
  if ( is_numeric( $current_location ) ) {
263
  $limit_string = 'AND ' . $location_type . ' = ' . absint( $current_location );
@@ -267,7 +265,7 @@ function mc_select_location( $ltype = '', $lvalue = '' ) {
267
  }
268
  }
269
  }
270
- if ( '' != $limit_string ) {
271
  if ( isset( $_GET['loc2'] ) && isset( $_GET['ltype2'] ) ) {
272
  $limit_string .= mc_secondary_limit( $_GET['ltype2'], $_GET['loc2'] );
273
  }
@@ -341,7 +339,7 @@ function mc_secondary_limit( $ltype = '', $lvalue = '' ) {
341
  default:
342
  $location_type = 'event_label';
343
  }
344
- if ( 'all' != $current_location && 'all' != $current_location ) {
345
  $limit_string = "OR $location_type='$current_location'";
346
  }
347
 
24
  global $wpdb;
25
  $db_type = mc_get_db_type();
26
  $search = '';
27
+ if ( '' !== trim( $query ) ) {
28
+ if ( 'MyISAM' === $db_type ) {
29
  $query = esc_sql( $query );
30
  $search = ' AND MATCH(' . apply_filters( 'mc_search_fields', 'event_title,event_desc,event_short,event_label,event_city,event_postcode,event_registration' ) . ") AGAINST ( '$query' IN BOOLEAN MODE ) ";
31
  } else {
48
  * @return string SQL modifiers.
49
  */
50
  function mc_select_category( $category, $type = 'event', $group = 'events' ) {
51
+ if ( '' === trim( $category ) ) {
52
  return '';
53
  }
54
  $category = urldecode( $category );
55
  $select_clause = '';
56
+ $data = ( 'category' === $group ) ? 'category_id' : 'r.category_id';
57
  if ( preg_match( '/^all$|^all,|,all$|,all,/i', $category ) > 0 ) {
58
 
59
  return '';
66
  }
67
 
68
  $join = '';
69
+ if ( '' !== $select_clause ) {
70
  $join = ' JOIN ' . my_calendar_category_relationships_table() . ' AS r ON r.event_id = e.event_id ';
71
  }
72
 
86
  $mcdb = $wpdb;
87
  $select = array();
88
 
89
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
90
  $mcdb = mc_remote_db();
91
  }
92
 
135
  * @return string WHERE limits
136
  */
137
  function mc_select_author( $author, $type = 'event', $context = 'author' ) {
138
+ if ( '' === trim( (string) $author ) ) {
139
  return '';
140
  }
141
  $author = urldecode( $author );
142
+ if ( '' === $author || 'all' === $author || 'default' === $author || null === $author ) {
143
  return '';
144
  }
145
  $select_author = '';
146
+ $data = ( 'author' === $context ) ? 'event_author' : 'event_host';
147
 
148
  if ( preg_match( '/^all$|^all,|,all$|,all,/i', $author ) > 0 ) {
149
  return '';
229
  $limit_string = '';
230
  $location = '';
231
  $current_location = '';
232
+ if ( '' !== $ltype && '' !== $lvalue ) {
233
+ $location = $ltype;
234
+ $current_location = $lvalue;
 
 
235
  switch ( $location ) {
236
  case 'name':
237
  $location_type = 'event_label';
254
  default:
255
  $location_type = $location;
256
  }
257
+ if ( in_array( $location_type, array( 'event_label', 'event_city', 'event_state', 'event_postcode', 'event_country', 'event_region', 'event_location', 'event_street', 'event_street2', 'event_url', 'event_longitude', 'event_latitude', 'event_zoom', 'event_phone', 'event_phone2' ), true ) ) {
258
+ if ( 'all' !== $current_location && '' !== $current_location ) {
259
  $current_location = trim( $current_location );
260
  if ( is_numeric( $current_location ) ) {
261
  $limit_string = 'AND ' . $location_type . ' = ' . absint( $current_location );
265
  }
266
  }
267
  }
268
+ if ( '' !== $limit_string ) {
269
  if ( isset( $_GET['loc2'] ) && isset( $_GET['ltype2'] ) ) {
270
  $limit_string .= mc_secondary_limit( $_GET['ltype2'], $_GET['loc2'] );
271
  }
339
  default:
340
  $location_type = 'event_label';
341
  }
342
+ if ( 'all' !== $current_location && '' !== $current_location ) {
343
  $limit_string = "OR $location_type='$current_location'";
344
  }
345
 
my-calendar-locations.php CHANGED
@@ -161,7 +161,7 @@ function my_calendar_add_locations() {
161
  do_action( 'mc_modify_location', $where, $update );
162
  if ( false === $results ) {
163
  mc_show_error( __( 'Location could not be edited.', 'my-calendar' ) );
164
- } elseif ( 0 == $results ) {
165
  mc_show_error( __( 'Location was not changed.', 'my-calendar' ) );
166
  } else {
167
  mc_show_notice( __( 'Location edited successfully', 'my-calendar' ) );
161
  do_action( 'mc_modify_location', $where, $update );
162
  if ( false === $results ) {
163
  mc_show_error( __( 'Location could not be edited.', 'my-calendar' ) );
164
+ } elseif ( 0 === $results ) {
165
  mc_show_error( __( 'Location was not changed.', 'my-calendar' ) );
166
  } else {
167
  mc_show_notice( __( 'Location edited successfully', 'my-calendar' ) );
my-calendar-output.php CHANGED
@@ -174,10 +174,11 @@ function mc_category_icon_title( $title, $post_id = null ) {
174
  * @param array $params calendar parameters.
175
  * @param string $process_date String formatted date being displayed.
176
  * @param string $template Template to use for drawing individual events.
 
177
  *
178
  * @return string Generated HTML.
179
  */
180
- function my_calendar_draw_events( $events, $params, $process_date, $template = '' ) {
181
  $type = $params['format'];
182
  $time = $params['time'];
183
 
@@ -205,7 +206,7 @@ function my_calendar_draw_events( $events, $params, $process_date, $template = '
205
  $check = '';
206
  }
207
  if ( '' === $check ) {
208
- $output_array[] = my_calendar_draw_event( $event, $type, $process_date, $time, $template );
209
  }
210
  }
211
  if ( is_array( $output_array ) ) {
@@ -236,13 +237,14 @@ function my_calendar_draw_events( $events, $params, $process_date, $template = '
236
  * @param string $process_date Current date being displayed.
237
  * @param string $time Time view being drawn.
238
  * @param string $template Template to use to draw event.
 
239
  *
240
  * @return string Generated HTML.
241
  */
242
- function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $time, $template = '' ) {
243
  $exit_early = mc_exit_early( $event, $process_date );
244
  if ( $exit_early ) {
245
- return;
246
  }
247
 
248
  // assign empty values to template sections.
@@ -293,7 +295,7 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
293
  $img = '';
294
  $has_image = ( '' !== $image ) ? ' has-image' : '';
295
  $event_classes = mc_event_classes( $event, $day_id, $type );
296
- $header .= "<div id='$uid-$type' class='$event_classes'>\n";
297
 
298
  switch ( $type ) {
299
  case 'calendar':
@@ -334,7 +336,7 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
334
  $group_class = ( 1 == $event->event_span ) ? ' multidate group' . $event->event_group_id : '';
335
  $hlevel = apply_filters( 'mc_heading_level_table', 'h3', $type, $time, $template );
336
  $inner_heading = apply_filters( 'mc_heading_inner_title', $wrap . $image . trim( $event_title ) . $balance, $event_title, $event );
337
- $header .= ( 'single' !== $type && 'list' !== $type ) ? "<$hlevel class='event-title summary$group_class' id='mc_$event->occur_id-title'>$inner_heading</$hlevel>\n" : '';
338
  $event_title = ( 'single' === $type ) ? apply_filters( 'mc_single_event_title', $event_title, $event ) : $event_title;
339
  $title = ( 'single' === $type && ! is_singular( 'mc-events' ) ) ? "<h2 class='event-title summary'>$image $event_title</h2>\n" : '<span class="summary screen-reader-text">' . $event_title . '</span>';
340
  $title = apply_filters( 'mc_event_title', $title, $event, $event_title, $image );
@@ -353,7 +355,7 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
353
  $time_html = mc_time_html( $event, $type );
354
  if ( 'list' === $type ) {
355
  $hlevel = apply_filters( 'mc_heading_level_list', 'h3', $type, $time, $template );
356
- $list_title = "<$hlevel class='event-title summary' id='mc_$event->occur_id-title'>$image" . $event_title . "</$hlevel>\n";
357
  }
358
  if ( 'true' === $display_author ) {
359
  if ( 0 != $event->event_author ) {
@@ -464,8 +466,8 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
464
  }
465
 
466
  $img_class = ( '' !== $img ) ? ' has-image' : ' no-image';
467
- $container = "<div id='$uid-$type-details' class='details$img_class' role='alert' aria-labelledby='mc_$event->occur_id-title' itemscope itemtype='http://schema.org/Event'>\n";
468
- $container .= "<meta itemprop='name' content='" . strip_tags( $event->event_title ) . "' />";
469
  $container = apply_filters( 'mc_before_event', $container, $event, $type, $time );
470
  $details = $header . $container . apply_filters( 'mc_inner_content', $details, $event, $type, $time );
471
  $details .= apply_filters( 'mc_after_event', '', $event, $type, $time );
@@ -499,26 +501,26 @@ function mc_get_details( $data, $template, $type ) {
499
  switch ( $type ) {
500
  case 'mini':
501
  $template = mc_get_template( 'mini' );
502
- if ( 1 == get_option( 'mc_use_mini_template' ) ) {
503
  $details = mc_draw_template( $data, $template );
504
  }
505
  break;
506
  case 'list':
507
  $template = mc_get_template( 'list' );
508
- if ( 1 == get_option( 'mc_use_list_template' ) ) {
509
  $details = mc_draw_template( $data, $template );
510
  }
511
  break;
512
  case 'single':
513
  $template = mc_get_template( 'details' );
514
- if ( 1 == get_option( 'mc_use_details_template' ) ) {
515
  $details = mc_draw_template( $data, $template );
516
  }
517
  break;
518
  case 'calendar':
519
  default:
520
  $template = mc_get_template( 'grid' );
521
- if ( 1 == get_option( 'mc_use_grid_template' ) ) {
522
  $details = mc_draw_template( $data, $template );
523
  }
524
  }
@@ -972,9 +974,9 @@ function mc_date_array( $timestamp, $period ) {
972
 
973
  // This allows multiple months displayed. Will figure out splitting tables...
974
  // To handle: $endtime = strtotime( "+$months months",$endtime ); JCD TODO.
975
- $last = date( 'N', $endtime );
976
- $n = ( 1 == get_option( 'start_of_week' ) ) ? 7 - $last : 6 - $last;
977
- if ( '-1' == $n && '7' == date( 'N', $endtime ) ) {
978
  $n = 6;
979
  }
980
  $to = date( 'Y-m-d', strtotime( "+$n days", $endtime ) );
@@ -1051,7 +1053,7 @@ function mc_list_title( $events ) {
1051
  usort( $events, 'mc_time_cmp' );
1052
  $now = $events[0];
1053
  $count = count( $events ) - 1;
1054
- $event_title = strip_tags( stripcslashes( $now->event_title ), mc_strip_tags() );
1055
  if ( 0 === $count ) {
1056
  $cstate = $event_title;
1057
  } elseif ( 1 == $count ) {
@@ -1396,7 +1398,7 @@ function mc_show_event_template( $content ) {
1396
 
1397
  return $content;
1398
  }
1399
- if ( 1 == get_option( 'mc_use_details_template' ) ) {
1400
  $new_content = apply_filters( 'mc_before_event', '', $event, 'single', $time );
1401
  if ( isset( $_GET['mc_id'] ) ) {
1402
  $shortcode = str_replace( "event='$event_id'", "event='$mc_id' instance='1'", get_post_meta( $post->ID, '_mc_event_shortcode', true ) );
@@ -1495,7 +1497,7 @@ function mc_event_is_hidden( $event ) {
1495
  $category = $event->event_category;
1496
  $private = mc_get_private_categories();
1497
  $can_see = apply_filters( 'mc_user_can_see_private_events', is_user_logged_in(), $event );
1498
- if ( in_array( $category, $private ) && ! $can_see ) {
1499
 
1500
  return true;
1501
  }
@@ -1532,33 +1534,33 @@ function mc_calendar_params( $args ) {
1532
  $site = ( isset( $args['site'] ) && '' != trim( $args['site'] ) ) ? $args['site'] : false;
1533
  $months = isset( $args['months'] ) ? $args['months'] : false;
1534
 
1535
- if ( ! in_array( $format, array( 'list', 'calendar', 'mini' ) ) ) {
1536
  $format = 'calendar';
1537
  }
1538
 
1539
- if ( ! in_array( $time, array( 'day', 'week', 'month', 'month+1' ) ) ) {
1540
  $time = 'month';
1541
  }
1542
 
1543
  $category = ( isset( $_GET['mcat'] ) ) ? (int) $_GET['mcat'] : $category;
1544
  // This relates to default value inconsistencies, I think.
1545
- if ( '' == $category ) {
1546
  $category = 'all';
1547
  }
1548
 
1549
- if ( isset( $_GET['format'] ) && in_array( $_GET['format'], array( 'list', 'mini' ) ) && 'mini' != $format ) {
1550
  $format = esc_attr( $_GET['format'] );
1551
  } else {
1552
  $format = esc_attr( $format );
1553
  }
1554
 
1555
- if ( isset( $_GET['time'] ) && in_array( $_GET['time'], array( 'day', 'week', 'month', 'month+1' ) ) && 'mini' != $format ) {
1556
  $time = esc_attr( $_GET['time'] );
1557
  } else {
1558
  $time = esc_attr( $time );
1559
  }
1560
 
1561
- if ( 'day' == $time ) {
1562
  $format = 'list';
1563
  }
1564
 
@@ -1605,24 +1607,24 @@ function my_calendar( $args ) {
1605
  $template = isset( $args['template'] ) ? $args['template'] : '';
1606
  $content = isset( $args['content'] ) ? $args['content'] : '';
1607
  $source = isset( $args['source'] ) ? $args['source'] : 'shortcode';
1608
- $site = ( isset( $args['site'] ) && '' != trim( $args['site'] ) ) ? $args['site'] : false;
1609
  $months = isset( $args['months'] ) ? $args['months'] : false;
1610
 
1611
  // Get options before switching sites in multisite environments.
1612
- $list_js_class = ( 0 == get_option( 'mc_list_javascript' ) ) ? 'listjs' : '';
1613
- $grid_js_class = ( 0 == get_option( 'mc_calendar_javascript' ) ) ? 'gridjs' : '';
1614
- $mini_js_class = ( 0 == get_option( 'mc_mini_javascript' ) ) ? 'minijs' : '';
1615
- $ajax_js_class = ( 0 == get_option( 'mc_ajax_javascript' ) ) ? 'ajaxjs' : '';
1616
  $date_format = mc_date_format();
1617
- $start_of_week = ( get_option( 'start_of_week' ) == 1 ) ? 1 : 7; // convert start of week to ISO 8601 (Monday/Sunday).
1618
- $show_weekends = ( get_option( 'mc_show_weekends' ) == 'true' ) ? true : false;
1619
  $skip_holidays = get_option( 'mc_skip_holidays_category' );
1620
- $month_format = ( get_option( 'mc_month_format' ) == '' ) ? 'F Y' : get_option( 'mc_month_format' );
1621
  $show_months = absint( apply_filters( 'mc_show_months', get_option( 'mc_show_months' ), $args ) );
1622
- $show_months = ( 0 === $show_months ) ? 1 : $show_months;
1623
  $caption_text = ' ' . stripslashes( trim( get_option( 'mc_caption' ) ) );
1624
  $week_format = ( ! get_option( 'mc_week_format' ) ) ? 'M j, \'y' : get_option( 'mc_week_format' );
1625
- $week_template = ( get_option( 'mc_week_caption' ) != '' ) ? get_option( 'mc_week_caption' ) : 'Week of {date format="M jS"}';
1626
  $day_uri = ( ! get_option( 'mc_open_day_uri' ) ) ? 'false' : get_option( 'mc_open_day_uri' ); // This is not a URL. It's a behavior reference.
1627
  $list_info = get_option( 'mc_show_list_info' );
1628
  $list_events = get_option( 'mc_show_list_events' );
@@ -1637,7 +1639,7 @@ function my_calendar( $args ) {
1637
  $body = apply_filters( 'mc_before_calendar', '', $params );
1638
 
1639
  $id = $params['id'];
1640
- $main_class = ( '' != $id ) ? sanitize_title( $id ) : 'all';
1641
  $cid = ( isset( $_GET['cid'] ) ) ? esc_attr( strip_tags( $_GET['cid'] ) ) : $main_class;
1642
  $mc_wrapper = "
1643
  <div id=\"$id\" class=\"mc-main mcjs $list_js_class $grid_js_class $mini_js_class $ajax_js_class $params[format] $params[time] $main_class\" aria-live='assertive' aria-atomic='true' aria-relevant='additions'>";
@@ -1646,7 +1648,7 @@ function my_calendar( $args ) {
1646
 
1647
  $date_format = apply_filters( 'mc_date_format', $date_format, $params['format'], $params['time'] );
1648
 
1649
- if ( isset( $_GET['mc_id'] ) && 'widget' != $source ) {
1650
  // single event, main calendar only.
1651
  $mc_id = ( is_numeric( $_GET['mc_id'] ) ) ? $_GET['mc_id'] : false;
1652
  if ( $mc_id ) {
@@ -1689,7 +1691,7 @@ function my_calendar( $args ) {
1689
  'site' => $site,
1690
  );
1691
  $query = apply_filters( 'mc_calendar_attributes', $query, $params );
1692
- if ( 'mc-print-view' == $id && isset( $_GET['searched'] ) && $_GET['searched'] ) {
1693
  $event_array = mc_get_searched_events();
1694
  if ( ! empty( $event_array ) ) {
1695
  reset( $event_array );
@@ -1706,7 +1708,7 @@ function my_calendar( $args ) {
1706
  $top = $nav['top'];
1707
  $bottom = $nav['bottom'];
1708
 
1709
- if ( 'day' == $params['time'] ) {
1710
  $body .= "<div class='mcjs " . esc_attr( $params['format'] . ' ' . $params['time'] ) . "'>" . $top;
1711
  $from = date( 'Y-m-d', $current );
1712
  $to = date( 'Y-m-d', $current );
@@ -1739,9 +1741,9 @@ function my_calendar( $args ) {
1739
 
1740
  if ( is_array( $events ) && count( $events ) > 0 ) {
1741
  if ( is_array( $holidays ) && count( $holidays ) > 0 ) {
1742
- $mc_events .= my_calendar_draw_events( $holidays, $params, $from, $template );
1743
  } else {
1744
- $mc_events .= my_calendar_draw_events( $events, $params, $from, $template );
1745
  }
1746
  } else {
1747
  $mc_events .= __( 'No events scheduled for today!', 'my-calendar' );
@@ -1755,29 +1757,29 @@ function my_calendar( $args ) {
1755
  </div>";
1756
  } else {
1757
  // If showing multiple months, figure out how far we're going.
1758
- $months = ( 'week' == $params['time'] ) ? 1 : $show_months;
1759
  $through_date = mktime( 0, 0, 0, $date['month'] + ( $months - 1 ), $date['day'], $date['year'] );
1760
- if ( 'month+1' == $params['time'] ) {
1761
  $current_header = date_i18n( $month_format, strtotime( '+1 month', $current ) );
1762
  } else {
1763
  $current_header = date_i18n( $month_format, $current );
1764
  }
1765
- $current_month_header = ( date( 'Y', $current ) == date( 'Y', $through_date ) ) ? date_i18n( 'F', $current ) : date_i18n( 'F Y', $current );
1766
  $through_month_header = date_i18n( $month_format, $through_date );
1767
  $values = array( 'date' => date( 'Y-m-d', $current ) );
1768
 
1769
  // Add the calendar table and heading.
1770
  $body .= $top;
1771
- if ( 'calendar' == $params['format'] || 'mini' == $params['format'] ) {
1772
  $table = apply_filters( 'mc_grid_wrapper', 'table', $params['format'] );
1773
  $body .= "\n<$table class=\"my-calendar-table\">\n";
1774
  $week_caption = mc_draw_template( $values, stripslashes( $week_template ) );
1775
- $caption_heading = ( 'week' != $params['time'] ) ? $current_header . $caption_text : $week_caption . $caption_text;
1776
  $caption = apply_filters( 'mc_grid_caption', 'caption', $params['format'] );
1777
  $body .= "<$caption class=\"heading my-calendar-$params[time]\">" . $caption_heading . "</$caption>\n";
1778
  } else {
1779
  // Determine which header text to show depending on number of months displayed.
1780
- if ( 'week' != $params['time'] && 'day' != $params['time'] ) {
1781
  $list_heading = ( $months <= 1 ) ? $current_header . $caption_text . "\n" : $current_month_header . '&ndash;' . $through_month_header . $caption_text;
1782
  // Translators: time period displayed.
1783
  $list_heading = sprintf( __( 'Events in %s', 'my-calendar' ), $list_heading );
@@ -1794,14 +1796,14 @@ function my_calendar( $args ) {
1794
 
1795
  $tr = apply_filters( 'mc_grid_week_wrapper', 'tr', $params['format'] );
1796
  $th = apply_filters( 'mc_grid_header_wrapper', 'th', $params['format'] );
1797
- $close_th = ( 'th' == $th ) ? 'th' : $th;
1798
- $th .= ( 'th' == $th ) ? ' scope="col"' : '';
1799
 
1800
  // If in a calendar format, print the headings of the days of the week.
1801
- if ( 'list' == $params['format'] ) {
1802
  $body .= "<ul id='list-$id' class='mc-list'>";
1803
  } else {
1804
- $body .= ( 'tr' == $tr ) ? "<thead>\n" : '<div class="mc-table-body">';
1805
  $body .= "<$tr class='mc-row'>\n";
1806
  if ( apply_filters( 'mc_show_week_number', false, $args ) ) {
1807
  $body .= "<th class='mc-week-number'>" . __( 'Week', 'my-calendar' ) . '</th>';
@@ -1813,17 +1815,17 @@ function my_calendar( $args ) {
1813
  $class = ( $i < 5 ) ? 'day-heading' : 'weekend-heading';
1814
  }
1815
  $dayclass = sanitize_html_class( $abbrevs[ $i ] );
1816
- if ( ( 'weekend-heading' == $class && $show_weekends ) || 'weekend-heading' != $class ) {
1817
  $body .= "<$th class='$class $dayclass'>" . $name_days[ $i ] . "</$close_th>\n";
1818
  }
1819
  }
1820
  $body .= "\n</$tr>\n";
1821
- $body .= ( 'tr' == $tr ) ? "</thead>\n<tbody>" : '';
1822
  }
1823
  $odd = 'odd';
1824
 
1825
  $show_all = apply_filters( 'mc_all_list_dates', false, $args );
1826
- if ( $no_events && 'list' == $params['format'] && false == $show_all ) {
1827
  // If there are no events in list format, just display that info.
1828
  $no_events = ( '' == $content ) ? __( 'There are no events scheduled during this period.', 'my-calendar' ) : $content;
1829
  $body .= "<li class='mc-events no-events'>$no_events</li>";
@@ -1835,12 +1837,12 @@ function my_calendar( $args ) {
1835
  $date_is = date( 'Y-m-d', $start );
1836
  $is_weekend = ( date( 'N', $start ) < 6 ) ? false : true;
1837
  if ( $show_weekends || ( ! $show_weekends && ! $is_weekend ) ) {
1838
- if ( date( 'N', $start ) == $start_of_week && 'list' != $params['format'] ) {
1839
  $body .= "<$tr class='mc-row'>";
1840
  }
1841
  $events = ( isset( $event_array[ $date_is ] ) ) ? $event_array[ $date_is ] : array();
1842
  $week_header = date_i18n( $week_format, $start );
1843
- $thisday_heading = ( 'week' == $params['time'] ) ? "<small>$week_header</small>" : date( 'j', $start );
1844
 
1845
  // Generate event classes & attributes.
1846
  $events_class = mc_events_class( $events, $date_is );
@@ -1859,19 +1861,19 @@ function my_calendar( $args ) {
1859
 
1860
  if ( ! empty( $events ) ) {
1861
  $hide_nextmonth = apply_filters( 'mc_hide_nextmonth', false );
1862
- if ( true == $hide_nextmonth && 'nextmonth' == $monthclass ) {
1863
  $event_output = ' ';
1864
  } else {
1865
- if ( 'mini' == $params['format'] && 'false' != $day_uri ) {
1866
  $event_output = ' ';
1867
  } else {
1868
- $event_output = my_calendar_draw_events( $events, $params, $date_is, $template );
1869
  }
1870
  }
1871
  if ( true === $event_output ) {
1872
  $event_output = ' ';
1873
  }
1874
- if ( 'mini' == $params['format'] && '' != $event_output ) {
1875
  $link = mc_build_mini_url( $start, $params['category'], $events, $args, $date );
1876
  $element = "a href='$link'";
1877
  $close = 'a';
@@ -1884,17 +1886,17 @@ function my_calendar( $args ) {
1884
  // set up events.
1885
  if ( ( $is_weekend && $show_weekends ) || ! $is_weekend ) {
1886
  $weekend_class = ( $is_weekend ) ? 'weekend' : '';
1887
- if ( 'list' == $params['format'] ) {
1888
- if ( 'true' == $list_info ) {
1889
  $title = ' - ' . mc_wrap_title( "<span class='mc-list-details select-event'>" . mc_list_title( $events ) . '</span>' );
1890
- } elseif ( 'true' == $list_events ) {
1891
  $title = ' - ' . mc_wrap_title( "<span class='mc-list-details all-events'>" . mc_list_titles( $events ) . '</span>' );
1892
  } else {
1893
  $title = '';
1894
  }
1895
- if ( '' != $event_output ) {
1896
  $body .= "<li id='$params[format]-$date_is' $ariacurrent class='mc-events $dateclass $events_class $odd'><strong class=\"event-date\">" . mc_wrap_title( date_i18n( $date_format, $start ) ) . "$title</strong>" . $event_output . '</li>';
1897
- $odd = ( 'odd' == $odd ) ? 'even' : 'odd';
1898
  }
1899
  } else {
1900
  $body .= "<$td id='$params[format]-$date_is' $ariacurrent class='$dateclass $weekend_class $monthclass $events_class day-with-date'>" . "<$element class='mc-date $trigger'><span aria-hidden='true'>$thisday_heading</span><span class='screen-reader-text'>" . date_i18n( $date_format, strtotime( $date_is ) ) . "</span></$close>" . $event_output . "</$td>\n";
@@ -1902,19 +1904,19 @@ function my_calendar( $args ) {
1902
  }
1903
  } else {
1904
  // If there are no events on this date within current params.
1905
- if ( 'list' != $params['format'] ) {
1906
  $weekend_class = ( $is_weekend ) ? 'weekend' : '';
1907
  $body .= "<$td $ariacurrent class='no-events $dateclass $weekend_class $monthclass $events_class day-with-date'><span class='mc-date no-events'><span aria-hidden='true'>$thisday_heading</span><span class='screen-reader-text'>" . date_i18n( $date_format, strtotime( $date_is ) ) . "</span></span></$td>\n";
1908
  } else {
1909
- if ( true == $show_all ) {
1910
  $body .= "<li id='$params[format]-$date_is' $ariacurrent class='no-events $dateclass $events_class $odd'><strong class=\"event-date\">" . mc_wrap_title( date_i18n( $date_format, $start ) ) . '</strong></li>';
1911
- $odd = ( 'odd' == $odd ) ? 'even' : 'odd';
1912
  }
1913
  }
1914
  }
1915
 
1916
  if ( date( 'N', $start ) == $end_of_week || ( date( 'N', $start ) == 5 && ! $show_weekends ) ) {
1917
- if ( 'list' != $params['format'] ) {
1918
  $body .= "\n</$tr>\n"; // End of 'is beginning of week'.
1919
  }
1920
  $week_number_shown = false;
@@ -1926,8 +1928,8 @@ function my_calendar( $args ) {
1926
  }
1927
 
1928
  $table = apply_filters( 'mc_grid_wrapper', 'table', $params['format'] );
1929
- $end = ( 'table' == $table ) ? "\n</tbody>\n</table>" : "</div></$table>";
1930
- $body .= ( 'list' == $params['format'] ) ? "\n</ul>" : $end;
1931
  }
1932
  $body .= $bottom;
1933
  }
@@ -1960,9 +1962,9 @@ function mc_get_from_to( $show_months, $params, $date ) {
1960
  $c_year = $date['year'];
1961
 
1962
  // Grid calendar can't show multiple months.
1963
- if ( 'list' == $format && 'week' != $time ) {
1964
  if ( $num > 0 && 'day' != $time && 'week' != $time ) {
1965
- if ( 'month+1' == $time ) {
1966
  $from = date( 'Y-m-d', strtotime( '+1 month', mktime( 0, 0, 0, $c_month, 1, $c_year ) ) );
1967
  $next = strtotime( "+$num months", strtotime( '+1 month', mktime( 0, 0, 0, $c_month, 1, $c_year ) ) );
1968
  } else {
@@ -2009,7 +2011,7 @@ function mc_generate_calendar_nav( $params, $cat, $start_of_week, $show_months,
2009
  $ltype = $params['ltype'];
2010
  $lvalue = $params['lvalue'];
2011
 
2012
- if ( 'none' == $above && 'none' == $below ) {
2013
  return array(
2014
  'bottom' => '',
2015
  'top' => '',
@@ -2021,27 +2023,27 @@ function mc_generate_calendar_nav( $params, $cat, $start_of_week, $show_months,
2021
  $mc_bottomorder = array( 'key', 'feeds' );
2022
  $available = array( 'nav', 'toggle', 'jump', 'print', 'timeframe', 'key', 'feeds', 'exports' );
2023
 
2024
- if ( 'none' == $above ) {
2025
  $mc_toporder = array();
2026
  } else {
2027
  // Set up above-calendar order of fields.
2028
- if ( '' != get_option( 'mc_topnav' ) ) {
2029
  $mc_toporder = array_map( 'trim', explode( ',', get_option( 'mc_topnav' ) ) );
2030
  }
2031
 
2032
- if ( '' != $above ) {
2033
  $mc_toporder = array_map( 'trim', explode( ',', $above ) );
2034
  }
2035
  }
2036
 
2037
- if ( 'none' == $below ) {
2038
  $mc_bottomorder = array();
2039
  } else {
2040
- if ( '' != get_option( 'mc_bottomnav' ) ) {
2041
  $mc_bottomorder = array_map( 'trim', explode( ',', get_option( 'mc_bottomnav' ) ) );
2042
  }
2043
 
2044
- if ( '' != $below ) {
2045
  $mc_bottomorder = array_map( 'trim', explode( ',', $below ) );
2046
  }
2047
  }
@@ -2073,28 +2075,28 @@ function mc_generate_calendar_nav( $params, $cat, $start_of_week, $show_months,
2073
  'href' => urlencode( mc_get_current_url() ),
2074
  );
2075
 
2076
- if ( 'list' == $format ) {
2077
  $add['format'] = 'list';
2078
  }
2079
 
2080
  $subtract = array();
2081
- if ( '' == $ltype ) {
2082
  $subtract[] = 'ltype';
2083
  unset( $add['ltype'] );
2084
  }
2085
 
2086
- if ( '' == $lvalue ) {
2087
  $subtract[] = 'lvalue';
2088
  unset( $add['lvalue'] );
2089
  }
2090
 
2091
- if ( 'all' == $category ) {
2092
  $subtract[] = 'mcat';
2093
  unset( $add['mcat'] );
2094
  }
2095
 
2096
  // Set up print link.
2097
- if ( in_array( 'print', $used ) ) {
2098
  $print_add = array_merge( $add, array( 'cid' => 'mc-print-view' ) );
2099
  $mc_print_url = mc_build_url( $print_add, $subtract, home_url() );
2100
  $print = "<div class='mc-print'><a href='$mc_print_url'>" . __( 'Print<span class="maybe-hide"> View</span>', 'my-calendar' ) . '</a></div>';
@@ -2104,25 +2106,25 @@ function mc_generate_calendar_nav( $params, $cat, $start_of_week, $show_months,
2104
  $toggle = ( in_array( 'toggle', $used ) ) ? mc_format_toggle( $format, 'yes', $time ) : '';
2105
 
2106
  // Set up time toggle.
2107
- if ( in_array( 'timeframe', $used ) ) {
2108
  $timeframe = mc_time_toggle( $format, $time, $date['month'], $date['year'], $date['current_date'], $start_of_week, $from );
2109
  }
2110
 
2111
  // Set up category key.
2112
- $key = ( in_array( 'key', $used ) ) ? mc_category_key( $cat ) : '';
2113
 
2114
  // Set up navigation links.
2115
- if ( in_array( 'nav', $used ) ) {
2116
  $nav = mc_nav( $date, $format, $time, $show_months, $main_class );
2117
  }
2118
 
2119
  // Set up rss feeds.
2120
- if ( in_array( 'feeds', $used ) ) {
2121
  $feeds = mc_sub_links( $subtract );
2122
  }
2123
 
2124
  // Set up exports.
2125
- if ( in_array( 'exports', $used ) ) {
2126
  $ical_m = ( isset( $_GET['month'] ) ) ? (int) $_GET['month'] : date( 'n' );
2127
  $ical_y = ( isset( $_GET['yr'] ) ) ? (int) $_GET['yr'] : date( 'Y' );
2128
  $next_link = my_calendar_next_link( $date, $format, $time, $show_months );
@@ -2130,29 +2132,29 @@ function mc_generate_calendar_nav( $params, $cat, $start_of_week, $show_months,
2130
  }
2131
 
2132
  // Set up date switcher.
2133
- if ( in_array( 'jump', $used ) ) {
2134
  $jump = mc_date_switcher( $format, $main_class, $time, $date );
2135
  }
2136
 
2137
  foreach ( $mc_toporder as $value ) {
2138
- if ( 'none' != $value && in_array( $value, $used ) && in_array( $value, $available ) ) {
2139
  $value = trim( $value );
2140
  $mc_topnav .= ${$value};
2141
  }
2142
  }
2143
 
2144
  foreach ( $mc_bottomorder as $value ) {
2145
- if ( 'none' != $value && 'stop' != $value && in_array( $value, $used ) && in_array( $value, $available ) ) {
2146
  $value = trim( $value );
2147
  $mc_bottomnav .= ${$value};
2148
  }
2149
  }
2150
 
2151
- if ( '' != $mc_topnav ) {
2152
  $mc_topnav = '<div class="my-calendar-header">' . $mc_topnav . '</div>';
2153
  }
2154
 
2155
- if ( '' != $mc_bottomnav ) {
2156
  $mc_bottomnav = "<div class='mc_bottomnav my-calendar-footer'>$mc_bottomnav</div>";
2157
  }
2158
 
@@ -2180,7 +2182,7 @@ function mc_show_week_number( $events, $args, $format, $td, $start ) {
2180
  if ( 'list' != $format ) {
2181
  $body = "<$td class='week_number'>$weeknumber</$td>";
2182
  }
2183
- if ( 'list' == $format && ! empty( $events ) ) {
2184
  $body = "<li class='mc-week-number'><span class='week-number-text'>" . __( 'Week', 'my-calendar' ) . "</span> <span class='week-number-number'>$weeknumber</span></li>";
2185
  }
2186
  }
@@ -2201,7 +2203,7 @@ function mc_show_week_number( $events, $args, $format, $td, $start ) {
2201
  */
2202
  function mc_build_mini_url( $start, $category, $events, $args, $date ) {
2203
  $open_day_uri = get_option( 'mc_open_day_uri' );
2204
- if ( 'true' == $open_day_uri || 'false' == $open_day_uri ) {
2205
  // Yes, this is weird. it's from some old settings...
2206
  $target = array(
2207
  'yr' => date( 'Y', $start ),
@@ -2244,9 +2246,9 @@ add_filter( 'mc_display_format', 'mc_convert_format', 10, 2 );
2244
  * @return string new format.
2245
  */
2246
  function mc_convert_format( $format, $params ) {
2247
- if ( 'true' == get_option( 'mc_convert' ) ) {
2248
- $format = ( mc_is_mobile() && 'calendar' == $format ) ? 'list' : $format;
2249
- } elseif ( 'mini' == get_option( 'mc_convert' ) ) {
2250
  $format = ( mc_is_mobile() ) ? 'mini' : $format;
2251
  }
2252
 
@@ -2315,14 +2317,14 @@ function mc_get_current_date( $main_class, $cid, $params ) {
2315
  $syear = $params['syear'];
2316
  $sday = $params['sday'];
2317
  $c_m = 0;
2318
- if ( isset( $_GET['dy'] ) && $main_class == $cid && ( 'day' == $time || 'week' == $time ) ) {
2319
  $c_day = (int) $_GET['dy'];
2320
  } else {
2321
- if ( 'week' == $time ) {
2322
  $dm = mc_first_day_of_week();
2323
  $c_day = $dm[0];
2324
  $c_m = $dm[1];
2325
- } elseif ( 'day' == $time ) {
2326
  $c_day = date( 'd', $timestamp );
2327
  } else {
2328
  $c_day = 1;
@@ -2338,11 +2340,11 @@ function mc_get_current_date( $main_class, $cid, $params ) {
2338
  $c_month = ( 0 == $c_m ) ? date( 'm', $timestamp ) : date( 'm', strtotime( $xnow . ' -1 month' ) );
2339
  }
2340
 
2341
- $is_start_of_week = ( get_option( 'start_of_week' ) == date( 'N', $timestamp ) ) ? true : false;
2342
  if ( isset( $_GET['yr'] ) && $main_class == $cid ) {
2343
  $c_year = (int) $_GET['yr'];
2344
  } else {
2345
- if ( 'week' == $time && ! isset( $_GET['dy'] ) ) {
2346
  if ( $is_start_of_week ) {
2347
  $c_year = ( date( 'Y', current_time( 'timestamp' ) ) );
2348
  } else {
@@ -2395,7 +2397,7 @@ add_filter( 'my_calendar_body', 'mc_run_shortcodes', 10, 1 );
2395
  * @return string Calendar body with shortcodes processed
2396
  */
2397
  function mc_run_shortcodes( $content ) {
2398
- $content = ( 'true' == get_option( 'mc_process_shortcodes' ) ) ? do_shortcode( $content ) : $content;
2399
 
2400
  return $content;
2401
  }
@@ -2408,7 +2410,7 @@ function mc_run_shortcodes( $content ) {
2408
  * @return string title with wrapper if appropriate
2409
  */
2410
  function mc_wrap_title( $title ) {
2411
- if ( 1 != get_option( 'mc_list_javascript' ) ) {
2412
  $is_anchor = '<button type="button" class="mc-text-button">';
2413
  $is_close_anchor = '</button>';
2414
  } else {
@@ -2430,7 +2432,7 @@ function mc_category_key( $category ) {
2430
  global $wpdb;
2431
  $url = plugin_dir_url( __FILE__ );
2432
  $mcdb = $wpdb;
2433
- if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
2434
  $mcdb = mc_remote_db();
2435
  }
2436
  $key = '';
@@ -2453,7 +2455,7 @@ function mc_category_key( $category ) {
2453
 
2454
  $selected_categories = ( empty( $_GET['mcat'] ) ) ? array() : explode( ',', $_GET['mcat'] );
2455
 
2456
- if ( in_array( $cat->category_id, $selected_categories ) || $category == $cat->category_id ) {
2457
  $selected_categories = array_diff( $selected_categories, array( $cat->category_id ) );
2458
  $class .= ' current';
2459
  $aria_current = 'aria-current="true"';
@@ -2462,7 +2464,7 @@ function mc_category_key( $category ) {
2462
  $aria_current = '';
2463
  }
2464
  $selectable_categories = implode( ',', $selected_categories );
2465
- if ( '' == $selectable_categories ) {
2466
  $url = remove_query_arg( 'mcat', mc_get_current_url() );
2467
  } else {
2468
  $url = mc_build_url( array( 'mcat' => $selectable_categories ), array( 'mcat' ) );
@@ -2471,10 +2473,11 @@ function mc_category_key( $category ) {
2471
  $class .= ' private';
2472
  }
2473
  $cat_name = mc_kses_post( stripcslashes( $cat->category_name ) );
 
2474
  $cat_key = '';
2475
- if ( '' != $cat->category_icon && 'true' != get_option( 'mc_hide_icons' ) ) {
2476
  $cat_key .= '<span class="category-color-sample"><img src="' . $path . $cat->category_icon . '" alt="" style="background:' . $hex . $cat->category_color . ';" /></span>' . $cat_name;
2477
- } elseif ( 'default' != get_option( 'mc_apply_color' ) ) {
2478
  $cat_key .= '<span class="category-color-sample no-icon" style="background:' . $hex . $cat->category_color . ';"> &nbsp; </span>' . $cat_name;
2479
  } else {
2480
  // If category colors are ignored, don't render HTML for them.
@@ -2566,9 +2569,9 @@ function my_calendar_next_link( $date, $format, $time = 'month', $months = 1 ) {
2566
  $cur_day = $date['day'];
2567
 
2568
  $next_year = $cur_year + 1;
2569
- $mc_next = get_option( 'mc_next_events' );
2570
- $next_events = ( '' == $mc_next ) ? '<span class="maybe-hide">' . __( 'Next', 'my-calendar' ) . '</span>' : stripslashes( $mc_next );
2571
- if ( $months <= 1 || 'list' != $format ) {
2572
  if ( 12 == $cur_month ) {
2573
  $month = 1;
2574
  $yr = $next_year;
@@ -2594,7 +2597,7 @@ function my_calendar_next_link( $date, $format, $time = 'month', $months = 1 ) {
2594
  $format = 'F';
2595
  }
2596
  $date = date_i18n( $format, mktime( 0, 0, 0, $month, 1, $yr ) );
2597
- if ( 'week' == $time ) {
2598
  $nextdate = strtotime( "$cur_year-$cur_month-$cur_day" . '+ 7 days' );
2599
  $day = date( 'd', $nextdate );
2600
  $yr = date( 'Y', $nextdate );
@@ -2607,7 +2610,7 @@ function my_calendar_next_link( $date, $format, $time = 'month', $months = 1 ) {
2607
  // Translators: Current formatted date.
2608
  $date = sprintf( __( 'Week of %s', 'my-calendar' ), date_i18n( $format, mktime( 0, 0, 0, $month, $day, $yr ) ) );
2609
  }
2610
- if ( 'day' == $time ) {
2611
  $nextdate = strtotime( "$cur_year-$cur_month-$cur_day" . '+ 1 days' );
2612
  $day = date( 'd', $nextdate );
2613
  $yr = date( 'Y', $nextdate );
@@ -2674,7 +2677,7 @@ function my_calendar_prev_link( $date, $format, $time = 'month', $months = 1 ) {
2674
  }
2675
  $date = date_i18n( $format, mktime( 0, 0, 0, $month, 1, $yr ) );
2676
  $day = '';
2677
- if ( 'week' == $time ) {
2678
  $prevdate = strtotime( "$cur_year-$cur_month-$cur_day" . '- 7 days' );
2679
  $day = date( 'd', $prevdate );
2680
  $yr = date( 'Y', $prevdate );
@@ -2686,7 +2689,7 @@ function my_calendar_prev_link( $date, $format, $time = 'month', $months = 1 ) {
2686
  }
2687
  $date = __( 'Week of ', 'my-calendar' ) . date_i18n( $format, mktime( 0, 0, 0, $month, $day, $yr ) );
2688
  }
2689
- if ( 'day' == $time ) {
2690
  $prevdate = strtotime( "$cur_year-$cur_month-$cur_day" . '- 1 days' );
2691
  $day = date( 'd', $prevdate );
2692
  $yr = date( 'Y', $prevdate );
@@ -2730,7 +2733,7 @@ function mc_filters( $args, $target_url, $ltype ) {
2730
  $return = false;
2731
 
2732
  $current_url = mc_get_uri();
2733
- $current_url = ( '' != $target_url && _mc_is_url( $target_url ) ) ? $target_url : $current_url;
2734
  $form = "
2735
  <div id='mc_filters'>
2736
  <form action='" . $current_url . "' method='get'>\n";
@@ -2744,7 +2747,7 @@ function mc_filters( $args, $target_url, $ltype ) {
2744
  foreach ( $qsa as $name => $argument ) {
2745
  $name = esc_attr( strip_tags( $name ) );
2746
  $argument = esc_attr( strip_tags( $argument ) );
2747
- if ( ! ( 'access' == $name || 'mcat' == $name || 'loc' == $name || 'ltype' == $name || 'mc_id' == $name ) ) {
2748
  $form .= '<input type="hidden" name="' . $name . '" value="' . $argument . '" />' . "\n";
2749
  }
2750
  }
@@ -2788,20 +2791,20 @@ function my_calendar_categories_list( $show = 'list', $context = 'public', $grou
2788
  global $wpdb;
2789
  $mcdb = $wpdb;
2790
 
2791
- if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
2792
  $mcdb = mc_remote_db();
2793
  }
2794
 
2795
  $output = '';
2796
  $current_url = mc_get_uri();
2797
- $current_url = ( '' != $target_url && _mc_is_url( $target_url ) ) ? $target_url : $current_url;
2798
 
2799
- $name = ( 'public' == $context ) ? 'mcat' : 'category';
2800
- $admin_fields = ( 'public' == $context ) ? ' name="' . $name . '"' : ' multiple="multiple" size="5" name="' . $name . '[]" ';
2801
- $admin_label = ( 'public' == $context ) ? '' : __( '(select to include)', 'my-calendar' );
2802
- $form = ( 'single' == $group ) ? '<form action="' . $current_url . '" method="get">
2803
  <div>' : '';
2804
- if ( 'single' == $group ) {
2805
  $qsa = array();
2806
  if ( isset( $_SERVER['QUERY_STRING'] ) ) {
2807
  parse_str( $_SERVER['QUERY_STRING'], $qsa );
@@ -2812,14 +2815,14 @@ function my_calendar_categories_list( $show = 'list', $context = 'public', $grou
2812
  foreach ( $qsa as $name => $argument ) {
2813
  $name = esc_attr( strip_tags( $name ) );
2814
  $argument = esc_attr( strip_tags( $argument ) );
2815
- if ( 'mcat' != $name || 'mc_id' != $name ) {
2816
  $form .= ' <input type="hidden" name="' . $name . '" value="' . $argument . '" />' . "\n";
2817
  }
2818
  }
2819
  }
2820
- $form .= ( 'list' == $show || 'group' == $group ) ? '' : '
2821
  </div><p>';
2822
- $public_form = ( 'public' == $context ) ? $form : '';
2823
  if ( ! is_user_logged_in() ) {
2824
  $categories = $mcdb->get_results( 'SELECT * FROM ' . my_calendar_categories_table() . ' WHERE category_private = 0 ORDER BY category_name ASC' );
2825
  } else {
@@ -2828,7 +2831,7 @@ function my_calendar_categories_list( $show = 'list', $context = 'public', $grou
2828
  if ( ! empty( $categories ) && count( $categories ) >= 1 ) {
2829
  $output = "<div id='mc_categories'>\n";
2830
  $url = mc_build_url( array( 'mcat' => 'all' ), array() );
2831
- $output .= ( 'list' == $show ) ? "
2832
  <ul>
2833
  <li><a href='$url'>" . __( 'All Categories', 'my-calendar' ) . '</a></li>' : $public_form . '
2834
  <label for="category">' . __( 'Categories', 'my-calendar' ) . ' ' . $admin_label . '</label>
@@ -2838,18 +2841,19 @@ function my_calendar_categories_list( $show = 'list', $context = 'public', $grou
2838
  foreach ( $categories as $category ) {
2839
  $category_name = strip_tags( stripcslashes( $category->category_name ), mc_strip_tags() );
2840
  $mcat = ( empty( $_GET['mcat'] ) ) ? '' : (int) $_GET['mcat'];
2841
- if ( 'list' == $show ) {
 
2842
  $this_url = mc_build_url( array( 'mcat' => $category->category_id ), array() );
2843
- $selected = ( $category->category_id == $mcat ) ? ' class="selected"' : '';
2844
  $output .= " <li$selected><a rel='nofollow' href='$this_url'>$category_name</a></li>";
2845
  } else {
2846
- $selected = ( $category->category_id == $mcat ) ? ' selected="selected"' : '';
2847
- $output .= " <option$selected value='$category->category_id'>$category_name</option>\n";
2848
  }
2849
  }
2850
- $output .= ( 'list' == $show ) ? '</ul>' : '</select>';
2851
- if ( 'admin' != $context && 'list' != $show ) {
2852
- if ( 'single' == $group ) {
2853
  $output .= '<input type="submit" value="' . __( 'Submit', 'my-calendar' ) . '" /></p></form>';
2854
  }
2855
  }
@@ -2872,9 +2876,9 @@ function my_calendar_categories_list( $show = 'list', $context = 'public', $grou
2872
  function mc_access_list( $show = 'list', $group = 'single', $target_url = '' ) {
2873
  $output = '';
2874
  $current_url = mc_get_uri();
2875
- $current_url = ( '' != $target_url && _mc_is_url( $target_url ) ) ? $target_url : $current_url;
2876
- $form = ( 'single' == $group ) ? "<form action='" . $current_url . "' method='get'><div>" : '';
2877
- if ( 'single' == $group ) {
2878
  $qsa = array();
2879
  if ( isset( $_SERVER['QUERY_STRING'] ) ) {
2880
  parse_str( $_SERVER['QUERY_STRING'], $qsa );
@@ -2885,19 +2889,19 @@ function mc_access_list( $show = 'list', $group = 'single', $target_url = '' ) {
2885
  foreach ( $qsa as $name => $argument ) {
2886
  $name = esc_attr( strip_tags( $name ) );
2887
  $argument = esc_attr( strip_tags( $argument ) );
2888
- if ( 'access' != $name || 'mc_id' != $name ) {
2889
  $form .= '<input type="hidden" name="' . $name . '" value="' . $argument . '" />' . "\n";
2890
  }
2891
  }
2892
  }
2893
- $form .= ( 'list' == $show || 'group' == $group ) ? '' : '</div><p>';
2894
 
2895
  $access_options = mc_event_access();
2896
  if ( ! empty( $access_options ) && count( $access_options ) >= 1 ) {
2897
  $output = "<div id='mc_access'>\n";
2898
  $url = mc_build_url( array( 'access' => 'all' ), array() );
2899
  $not_selected = ( ! isset( $_GET['access'] ) ) ? 'selected="selected"' : '';
2900
- $output .= ( 'list' == $show ) ? "
2901
  <ul>
2902
  <li><a href='$url'>" . __( 'Accessibility Services', 'my-calendar' ) . '</a></li>' : $form . '
2903
  <label for="access">' . __( 'Accessibility Services', 'my-calendar' ) . '</label>
@@ -2907,17 +2911,17 @@ function mc_access_list( $show = 'list', $group = 'single', $target_url = '' ) {
2907
  foreach ( $access_options as $key => $access ) {
2908
  $access_name = $access;
2909
  $this_access = ( empty( $_GET['access'] ) ) ? '' : (int) $_GET['access'];
2910
- if ( 'list' == $show ) {
2911
  $this_url = mc_build_url( array( 'access' => $key ), array() );
2912
- $selected = ( $key == $this_access ) ? ' class="selected"' : '';
2913
  $output .= " <li$selected><a rel='nofollow' href='$this_url'>$access_name</a></li>";
2914
  } else {
2915
- $selected = ( $this_access == $key ) ? ' selected="selected"' : '';
2916
  $output .= " <option$selected value='" . esc_attr( $key ) . "'>" . esc_html( $access_name ) . "</option>\n";
2917
  }
2918
  }
2919
- $output .= ( 'list' == $show ) ? '</ul>' : '</select>';
2920
- $output .= ( 'list' != $show && 'single' == $group ) ? '<p><input type="submit" value="' . __( 'Limit by Access', 'my-calendar' ) . '" /></p></form>' : '';
2921
  $output .= "\n</div>";
2922
  }
2923
  $output = apply_filters( 'mc_access_selector', $output, $access_options );
@@ -2937,7 +2941,7 @@ function mc_access_list( $show = 'list', $group = 'single', $target_url = '' ) {
2937
  function mc_build_url( $add, $subtract, $root = '' ) {
2938
  $home = '';
2939
 
2940
- if ( '' != $root ) {
2941
  $home = $root;
2942
  }
2943
 
@@ -2945,7 +2949,7 @@ function mc_build_url( $add, $subtract, $root = '' ) {
2945
  $home = get_permalink( $root );
2946
  }
2947
 
2948
- if ( '' == $home ) {
2949
  if ( is_front_page() ) {
2950
  $home = home_url( '/' );
2951
  } elseif ( is_home() ) {
@@ -2988,8 +2992,8 @@ function mc_build_url( $add, $subtract, $root = '' ) {
2988
  */
2989
  function my_calendar_searchform( $type, $url ) {
2990
  $query = ( isset( $_GET['mcs'] ) ) ? $_GET['mcs'] : '';
2991
- if ( 'simple' == $type ) {
2992
- if ( ! $url || '' == $url ) {
2993
  $url = mc_get_uri( false, array( 'type' => $type ) );
2994
  }
2995
  return '
@@ -3019,7 +3023,7 @@ function my_calendar_searchform( $type, $url ) {
3019
  function mc_get_list_locations( $datatype, $full = true, $return_type = OBJECT ) {
3020
  global $wpdb;
3021
  $mcdb = $wpdb;
3022
- if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
3023
  $mcdb = mc_remote_db();
3024
  }
3025
 
@@ -3075,14 +3079,14 @@ function my_calendar_show_locations( $datatype = 'name', $template = '' ) {
3075
  if ( $locations ) {
3076
  $output = '<ul class="mc-locations">';
3077
  foreach ( $locations as $key => $value ) {
3078
- if ( 'hcard' != $datatype && '' != $template ) {
3079
  $label = stripslashes( $value->{$datatype} );
3080
  $url = mc_maplink( $value, 'url', 'location' );
3081
  $output .= ( $url ) ? "<li><a href='" . esc_url( $url ) . "'>$label</a></li>" : "<li>$label</li>";
3082
- } elseif ( 'hcard' == $datatype ) {
3083
  $label = mc_hcard( $value, true, true, 'location' );
3084
  $output .= "<li>$label</li>";
3085
- } elseif ( '' != $template ) {
3086
  if ( mc_key_exists( $template ) ) {
3087
  $template = mc_get_custom_template( $template );
3088
  }
@@ -3130,10 +3134,10 @@ function my_calendar_locations_list( $show = 'list', $datatype = 'name', $group
3130
  $output = '';
3131
  $locations = mc_get_list_locations( $datatype, $datatype, ARRAY_A );
3132
  $current_url = mc_get_uri();
3133
- $current_url = ( '' != $target_url && _mc_is_url( $target_url ) ) ? $target_url : $current_url;
3134
 
3135
  if ( count( $locations ) > 1 ) {
3136
- if ( 'list' == $show ) {
3137
  $url = mc_build_url(
3138
  array(
3139
  'loc' => 'all',
@@ -3146,9 +3150,9 @@ function my_calendar_locations_list( $show = 'list', $datatype = 'name', $group
3146
  } else {
3147
  $ltype = ( ! isset( $_GET['ltype'] ) ) ? $datatype : $_GET['ltype'];
3148
  $output .= '<div id="mc_locations">';
3149
- $output .= ( 'single' == $group ) ? "<form action='" . $current_url . "' method='get'><div>" : '';
3150
  $output .= "<input type='hidden' name='ltype' value='" . esc_attr( $ltype ) . "' />";
3151
- if ( 'single' == $group ) {
3152
  $qsa = array();
3153
  if ( isset( $_SERVER['QUERY_STRING'] ) ) {
3154
  parse_str( $_SERVER['QUERY_STRING'], $qsa );
@@ -3159,7 +3163,7 @@ function my_calendar_locations_list( $show = 'list', $datatype = 'name', $group
3159
  foreach ( $qsa as $name => $argument ) {
3160
  $name = esc_attr( strip_tags( $name ) );
3161
  $argument = esc_attr( strip_tags( $argument ) );
3162
- if ( 'loc' != $name && 'ltype' != $name ) {
3163
  $output .= "\n" . '<input type="hidden" name="' . $name . '" value="' . $argument . '" />';
3164
  }
3165
  }
@@ -3173,12 +3177,12 @@ function my_calendar_locations_list( $show = 'list', $datatype = 'name', $group
3173
  foreach ( $location as $k => $value ) {
3174
  $vt = urlencode( trim( $value ) );
3175
  $value = strip_tags( stripcslashes( $value ), mc_strip_tags() );
3176
- if ( '' == $value ) {
3177
  continue;
3178
  }
3179
  $loc = ( empty( $_GET['loc'] ) ) ? '' : $_GET['loc'];
3180
- if ( 'list' == $show ) {
3181
- $selected = ( $vt == $loc ) ? ' class="selected"' : '';
3182
  $this_url = esc_url(
3183
  mc_build_url(
3184
  array(
@@ -3190,18 +3194,16 @@ function my_calendar_locations_list( $show = 'list', $datatype = 'name', $group
3190
  );
3191
  $output .= " <li$selected><a rel='nofollow' href='$this_url'>$value</a></li>\n";
3192
  } else {
3193
- $selected = ( $vt == $loc ) ? ' class="selected"' : '';
3194
- if ( '' != $value ) {
3195
- $output .= " <option value='" . esc_attr( $vt ) . "'$selected>$value</option>\n";
3196
- }
3197
  }
3198
  }
3199
  }
3200
- if ( 'list' == $show ) {
3201
  $output .= '</ul>';
3202
  } else {
3203
  $output .= '</select>';
3204
- $output .= ( 'single' == $group ) ? '<input type="submit" value="' . __( 'Submit', 'my-calendar' ) . '" />
3205
  </div>
3206
  </form>' : '';
3207
  $output .= '</div>';
174
  * @param array $params calendar parameters.
175
  * @param string $process_date String formatted date being displayed.
176
  * @param string $template Template to use for drawing individual events.
177
+ * @param string $id ID for the calendar calling this function.
178
  *
179
  * @return string Generated HTML.
180
  */
181
+ function my_calendar_draw_events( $events, $params, $process_date, $template = '', $id = '' ) {
182
  $type = $params['format'];
183
  $time = $params['time'];
184
 
206
  $check = '';
207
  }
208
  if ( '' === $check ) {
209
+ $output_array[] = my_calendar_draw_event( $event, $type, $process_date, $time, $template, $id );
210
  }
211
  }
212
  if ( is_array( $output_array ) ) {
237
  * @param string $process_date Current date being displayed.
238
  * @param string $time Time view being drawn.
239
  * @param string $template Template to use to draw event.
240
+ * @param string $id ID for the calendar calling this function.
241
  *
242
  * @return string Generated HTML.
243
  */
244
+ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $time, $template = '', $id = '' ) {
245
  $exit_early = mc_exit_early( $event, $process_date );
246
  if ( $exit_early ) {
247
+ return '';
248
  }
249
 
250
  // assign empty values to template sections.
295
  $img = '';
296
  $has_image = ( '' !== $image ) ? ' has-image' : '';
297
  $event_classes = mc_event_classes( $event, $day_id, $type );
298
+ $header .= "<div id='$uid-$type-$id' class='$event_classes'>\n";
299
 
300
  switch ( $type ) {
301
  case 'calendar':
336
  $group_class = ( 1 == $event->event_span ) ? ' multidate group' . $event->event_group_id : '';
337
  $hlevel = apply_filters( 'mc_heading_level_table', 'h3', $type, $time, $template );
338
  $inner_heading = apply_filters( 'mc_heading_inner_title', $wrap . $image . trim( $event_title ) . $balance, $event_title, $event );
339
+ $header .= ( 'single' !== $type && 'list' !== $type ) ? "<$hlevel class='event-title summary$group_class' id='mc_$event->occur_id-title-$id'>$inner_heading</$hlevel>\n" : '';
340
  $event_title = ( 'single' === $type ) ? apply_filters( 'mc_single_event_title', $event_title, $event ) : $event_title;
341
  $title = ( 'single' === $type && ! is_singular( 'mc-events' ) ) ? "<h2 class='event-title summary'>$image $event_title</h2>\n" : '<span class="summary screen-reader-text">' . $event_title . '</span>';
342
  $title = apply_filters( 'mc_event_title', $title, $event, $event_title, $image );
355
  $time_html = mc_time_html( $event, $type );
356
  if ( 'list' === $type ) {
357
  $hlevel = apply_filters( 'mc_heading_level_list', 'h3', $type, $time, $template );
358
+ $list_title = "<$hlevel class='event-title summary' id='mc_$event->occur_id-title-$id'>$image" . $event_title . "</$hlevel>\n";
359
  }
360
  if ( 'true' === $display_author ) {
361
  if ( 0 != $event->event_author ) {
466
  }
467
 
468
  $img_class = ( '' !== $img ) ? ' has-image' : ' no-image';
469
+ $container = "<div id='$uid-$type-details-$id' class='details$img_class' role='alert' aria-labelledby='mc_$event->occur_id-title" . '-' . $id . "' itemscope itemtype='http://schema.org/Event'>\n";
470
+ $container .= "<meta itemprop='name' content='" . esc_attr( strip_tags( $event->event_title ) ) . "' />";
471
  $container = apply_filters( 'mc_before_event', $container, $event, $type, $time );
472
  $details = $header . $container . apply_filters( 'mc_inner_content', $details, $event, $type, $time );
473
  $details .= apply_filters( 'mc_after_event', '', $event, $type, $time );
501
  switch ( $type ) {
502
  case 'mini':
503
  $template = mc_get_template( 'mini' );
504
+ if ( '1' === get_option( 'mc_use_mini_template' ) ) {
505
  $details = mc_draw_template( $data, $template );
506
  }
507
  break;
508
  case 'list':
509
  $template = mc_get_template( 'list' );
510
+ if ( '1' === get_option( 'mc_use_list_template' ) ) {
511
  $details = mc_draw_template( $data, $template );
512
  }
513
  break;
514
  case 'single':
515
  $template = mc_get_template( 'details' );
516
+ if ( '1' === get_option( 'mc_use_details_template' ) ) {
517
  $details = mc_draw_template( $data, $template );
518
  }
519
  break;
520
  case 'calendar':
521
  default:
522
  $template = mc_get_template( 'grid' );
523
+ if ( '1' === get_option( 'mc_use_grid_template' ) ) {
524
  $details = mc_draw_template( $data, $template );
525
  }
526
  }
974
 
975
  // This allows multiple months displayed. Will figure out splitting tables...
976
  // To handle: $endtime = strtotime( "+$months months",$endtime ); JCD TODO.
977
+ $last = (int) date( 'N', $endtime );
978
+ $n = ( '1' === get_option( 'start_of_week' ) ) ? 7 - $last : 6 - $last;
979
+ if ( -1 === $n && '7' === date( 'N', $endtime ) ) {
980
  $n = 6;
981
  }
982
  $to = date( 'Y-m-d', strtotime( "+$n days", $endtime ) );
1053
  usort( $events, 'mc_time_cmp' );
1054
  $now = $events[0];
1055
  $count = count( $events ) - 1;
1056
+ $event_title = apply_filters( 'mc_list_title_title', strip_tags( stripcslashes( $now->event_title ), mc_strip_tags(), $now ) );
1057
  if ( 0 === $count ) {
1058
  $cstate = $event_title;
1059
  } elseif ( 1 == $count ) {
1398
 
1399
  return $content;
1400
  }
1401
+ if ( '1' === get_option( 'mc_use_details_template' ) ) {
1402
  $new_content = apply_filters( 'mc_before_event', '', $event, 'single', $time );
1403
  if ( isset( $_GET['mc_id'] ) ) {
1404
  $shortcode = str_replace( "event='$event_id'", "event='$mc_id' instance='1'", get_post_meta( $post->ID, '_mc_event_shortcode', true ) );
1497
  $category = $event->event_category;
1498
  $private = mc_get_private_categories();
1499
  $can_see = apply_filters( 'mc_user_can_see_private_events', is_user_logged_in(), $event );
1500
+ if ( in_array( $category, $private, true ) && ! $can_see ) {
1501
 
1502
  return true;
1503
  }
1534
  $site = ( isset( $args['site'] ) && '' != trim( $args['site'] ) ) ? $args['site'] : false;
1535
  $months = isset( $args['months'] ) ? $args['months'] : false;
1536
 
1537
+ if ( ! in_array( $format, array( 'list', 'calendar', 'mini' ), true ) ) {
1538
  $format = 'calendar';
1539
  }
1540
 
1541
+ if ( ! in_array( $time, array( 'day', 'week', 'month', 'month+1' ), true ) ) {
1542
  $time = 'month';
1543
  }
1544
 
1545
  $category = ( isset( $_GET['mcat'] ) ) ? (int) $_GET['mcat'] : $category;
1546
  // This relates to default value inconsistencies, I think.
1547
+ if ( '' === $category ) {
1548
  $category = 'all';
1549
  }
1550
 
1551
+ if ( isset( $_GET['format'] ) && in_array( $_GET['format'], array( 'list', 'mini' ), true ) && 'mini' !== $format ) {
1552
  $format = esc_attr( $_GET['format'] );
1553
  } else {
1554
  $format = esc_attr( $format );
1555
  }
1556
 
1557
+ if ( isset( $_GET['time'] ) && in_array( $_GET['time'], array( 'day', 'week', 'month', 'month+1' ), true ) && 'mini' !== $format ) {
1558
  $time = esc_attr( $_GET['time'] );
1559
  } else {
1560
  $time = esc_attr( $time );
1561
  }
1562
 
1563
+ if ( 'day' === $time ) {
1564
  $format = 'list';
1565
  }
1566
 
1607
  $template = isset( $args['template'] ) ? $args['template'] : '';
1608
  $content = isset( $args['content'] ) ? $args['content'] : '';
1609
  $source = isset( $args['source'] ) ? $args['source'] : 'shortcode';
1610
+ $site = ( isset( $args['site'] ) && '' !== trim( $args['site'] ) ) ? $args['site'] : false;
1611
  $months = isset( $args['months'] ) ? $args['months'] : false;
1612
 
1613
  // Get options before switching sites in multisite environments.
1614
+ $list_js_class = ( '0' === get_option( 'mc_list_javascript' ) ) ? 'listjs' : '';
1615
+ $grid_js_class = ( '0' === get_option( 'mc_calendar_javascript' ) ) ? 'gridjs' : '';
1616
+ $mini_js_class = ( '0' === get_option( 'mc_mini_javascript' ) ) ? 'minijs' : '';
1617
+ $ajax_js_class = ( '0' === get_option( 'mc_ajax_javascript' ) ) ? 'ajaxjs' : '';
1618
  $date_format = mc_date_format();
1619
+ $start_of_week = ( get_option( 'start_of_week' ) === '1' ) ? 1 : 7; // convert start of week to ISO 8601 (Monday/Sunday).
1620
+ $show_weekends = ( get_option( 'mc_show_weekends' ) === 'true' ) ? true : false;
1621
  $skip_holidays = get_option( 'mc_skip_holidays_category' );
1622
+ $month_format = ( get_option( 'mc_month_format', '' ) === '' ) ? 'F Y' : get_option( 'mc_month_format' );
1623
  $show_months = absint( apply_filters( 'mc_show_months', get_option( 'mc_show_months' ), $args ) );
1624
+ $show_months = ( '0' === $show_months ) ? 1 : $show_months;
1625
  $caption_text = ' ' . stripslashes( trim( get_option( 'mc_caption' ) ) );
1626
  $week_format = ( ! get_option( 'mc_week_format' ) ) ? 'M j, \'y' : get_option( 'mc_week_format' );
1627
+ $week_template = ( get_option( 'mc_week_caption', '' ) !== '' ) ? get_option( 'mc_week_caption' ) : 'Week of {date format="M jS"}';
1628
  $day_uri = ( ! get_option( 'mc_open_day_uri' ) ) ? 'false' : get_option( 'mc_open_day_uri' ); // This is not a URL. It's a behavior reference.
1629
  $list_info = get_option( 'mc_show_list_info' );
1630
  $list_events = get_option( 'mc_show_list_events' );
1639
  $body = apply_filters( 'mc_before_calendar', '', $params );
1640
 
1641
  $id = $params['id'];
1642
+ $main_class = ( '' !== $id ) ? sanitize_title( $id ) : 'all';
1643
  $cid = ( isset( $_GET['cid'] ) ) ? esc_attr( strip_tags( $_GET['cid'] ) ) : $main_class;
1644
  $mc_wrapper = "
1645
  <div id=\"$id\" class=\"mc-main mcjs $list_js_class $grid_js_class $mini_js_class $ajax_js_class $params[format] $params[time] $main_class\" aria-live='assertive' aria-atomic='true' aria-relevant='additions'>";
1648
 
1649
  $date_format = apply_filters( 'mc_date_format', $date_format, $params['format'], $params['time'] );
1650
 
1651
+ if ( isset( $_GET['mc_id'] ) && 'widget' !== $source ) {
1652
  // single event, main calendar only.
1653
  $mc_id = ( is_numeric( $_GET['mc_id'] ) ) ? $_GET['mc_id'] : false;
1654
  if ( $mc_id ) {
1691
  'site' => $site,
1692
  );
1693
  $query = apply_filters( 'mc_calendar_attributes', $query, $params );
1694
+ if ( 'mc-print-view' === $id && isset( $_GET['searched'] ) && $_GET['searched'] ) {
1695
  $event_array = mc_get_searched_events();
1696
  if ( ! empty( $event_array ) ) {
1697
  reset( $event_array );
1708
  $top = $nav['top'];
1709
  $bottom = $nav['bottom'];
1710
 
1711
+ if ( 'day' === $params['time'] ) {
1712
  $body .= "<div class='mcjs " . esc_attr( $params['format'] . ' ' . $params['time'] ) . "'>" . $top;
1713
  $from = date( 'Y-m-d', $current );
1714
  $to = date( 'Y-m-d', $current );
1741
 
1742
  if ( is_array( $events ) && count( $events ) > 0 ) {
1743
  if ( is_array( $holidays ) && count( $holidays ) > 0 ) {
1744
+ $mc_events .= my_calendar_draw_events( $holidays, $params, $from, $template, $id );
1745
  } else {
1746
+ $mc_events .= my_calendar_draw_events( $events, $params, $from, $template, $id );
1747
  }
1748
  } else {
1749
  $mc_events .= __( 'No events scheduled for today!', 'my-calendar' );
1757
  </div>";
1758
  } else {
1759
  // If showing multiple months, figure out how far we're going.
1760
+ $months = ( 'week' === $params['time'] ) ? 1 : $show_months;
1761
  $through_date = mktime( 0, 0, 0, $date['month'] + ( $months - 1 ), $date['day'], $date['year'] );
1762
+ if ( 'month+1' === $params['time'] ) {
1763
  $current_header = date_i18n( $month_format, strtotime( '+1 month', $current ) );
1764
  } else {
1765
  $current_header = date_i18n( $month_format, $current );
1766
  }
1767
+ $current_month_header = ( date( 'Y', $current ) === date( 'Y', $through_date ) ) ? date_i18n( 'F', $current ) : date_i18n( 'F Y', $current );
1768
  $through_month_header = date_i18n( $month_format, $through_date );
1769
  $values = array( 'date' => date( 'Y-m-d', $current ) );
1770
 
1771
  // Add the calendar table and heading.
1772
  $body .= $top;
1773
+ if ( 'calendar' === $params['format'] || 'mini' === $params['format'] ) {
1774
  $table = apply_filters( 'mc_grid_wrapper', 'table', $params['format'] );
1775
  $body .= "\n<$table class=\"my-calendar-table\">\n";
1776
  $week_caption = mc_draw_template( $values, stripslashes( $week_template ) );
1777
+ $caption_heading = ( 'week' !== $params['time'] ) ? $current_header . $caption_text : $week_caption . $caption_text;
1778
  $caption = apply_filters( 'mc_grid_caption', 'caption', $params['format'] );
1779
  $body .= "<$caption class=\"heading my-calendar-$params[time]\">" . $caption_heading . "</$caption>\n";
1780
  } else {
1781
  // Determine which header text to show depending on number of months displayed.
1782
+ if ( 'week' !== $params['time'] && 'day' !== $params['time'] ) {
1783
  $list_heading = ( $months <= 1 ) ? $current_header . $caption_text . "\n" : $current_month_header . '&ndash;' . $through_month_header . $caption_text;
1784
  // Translators: time period displayed.
1785
  $list_heading = sprintf( __( 'Events in %s', 'my-calendar' ), $list_heading );
1796
 
1797
  $tr = apply_filters( 'mc_grid_week_wrapper', 'tr', $params['format'] );
1798
  $th = apply_filters( 'mc_grid_header_wrapper', 'th', $params['format'] );
1799
+ $close_th = ( 'th' === $th ) ? 'th' : $th;
1800
+ $th .= ( 'th' === $th ) ? ' scope="col"' : '';
1801
 
1802
  // If in a calendar format, print the headings of the days of the week.
1803
+ if ( 'list' === $params['format'] ) {
1804
  $body .= "<ul id='list-$id' class='mc-list'>";
1805
  } else {
1806
+ $body .= ( 'tr' === $tr ) ? "<thead>\n" : '<div class="mc-table-body">';
1807
  $body .= "<$tr class='mc-row'>\n";
1808
  if ( apply_filters( 'mc_show_week_number', false, $args ) ) {
1809
  $body .= "<th class='mc-week-number'>" . __( 'Week', 'my-calendar' ) . '</th>';
1815
  $class = ( $i < 5 ) ? 'day-heading' : 'weekend-heading';
1816
  }
1817
  $dayclass = sanitize_html_class( $abbrevs[ $i ] );
1818
+ if ( ( 'weekend-heading' === $class && $show_weekends ) || 'weekend-heading' !== $class ) {
1819
  $body .= "<$th class='$class $dayclass'>" . $name_days[ $i ] . "</$close_th>\n";
1820
  }
1821
  }
1822
  $body .= "\n</$tr>\n";
1823
+ $body .= ( 'tr' === $tr ) ? "</thead>\n<tbody>" : '';
1824
  }
1825
  $odd = 'odd';
1826
 
1827
  $show_all = apply_filters( 'mc_all_list_dates', false, $args );
1828
+ if ( $no_events && 'list' === $params['format'] && false === $show_all ) {
1829
  // If there are no events in list format, just display that info.
1830
  $no_events = ( '' == $content ) ? __( 'There are no events scheduled during this period.', 'my-calendar' ) : $content;
1831
  $body .= "<li class='mc-events no-events'>$no_events</li>";
1837
  $date_is = date( 'Y-m-d', $start );
1838
  $is_weekend = ( date( 'N', $start ) < 6 ) ? false : true;
1839
  if ( $show_weekends || ( ! $show_weekends && ! $is_weekend ) ) {
1840
+ if ( date( 'N', $start ) == $start_of_week && 'list' !== $params['format'] ) {
1841
  $body .= "<$tr class='mc-row'>";
1842
  }
1843
  $events = ( isset( $event_array[ $date_is ] ) ) ? $event_array[ $date_is ] : array();
1844
  $week_header = date_i18n( $week_format, $start );
1845
+ $thisday_heading = ( 'week' === $params['time'] ) ? "<small>$week_header</small>" : date( 'j', $start );
1846
 
1847
  // Generate event classes & attributes.
1848
  $events_class = mc_events_class( $events, $date_is );
1861
 
1862
  if ( ! empty( $events ) ) {
1863
  $hide_nextmonth = apply_filters( 'mc_hide_nextmonth', false );
1864
+ if ( true === $hide_nextmonth && 'nextmonth' === $monthclass ) {
1865
  $event_output = ' ';
1866
  } else {
1867
+ if ( 'mini' === $params['format'] && 'false' !== $day_uri ) {
1868
  $event_output = ' ';
1869
  } else {
1870
+ $event_output = my_calendar_draw_events( $events, $params, $date_is, $template, $id );
1871
  }
1872
  }
1873
  if ( true === $event_output ) {
1874
  $event_output = ' ';
1875
  }
1876
+ if ( 'mini' === $params['format'] && '' !== $event_output ) {
1877
  $link = mc_build_mini_url( $start, $params['category'], $events, $args, $date );
1878
  $element = "a href='$link'";
1879
  $close = 'a';
1886
  // set up events.
1887
  if ( ( $is_weekend && $show_weekends ) || ! $is_weekend ) {
1888
  $weekend_class = ( $is_weekend ) ? 'weekend' : '';
1889
+ if ( 'list' === $params['format'] ) {
1890
+ if ( 'true' === $list_info ) {
1891
  $title = ' - ' . mc_wrap_title( "<span class='mc-list-details select-event'>" . mc_list_title( $events ) . '</span>' );
1892
+ } elseif ( 'true' === $list_events ) {
1893
  $title = ' - ' . mc_wrap_title( "<span class='mc-list-details all-events'>" . mc_list_titles( $events ) . '</span>' );
1894
  } else {
1895
  $title = '';
1896
  }
1897
+ if ( '' !== $event_output ) {
1898
  $body .= "<li id='$params[format]-$date_is' $ariacurrent class='mc-events $dateclass $events_class $odd'><strong class=\"event-date\">" . mc_wrap_title( date_i18n( $date_format, $start ) ) . "$title</strong>" . $event_output . '</li>';
1899
+ $odd = ( 'odd' === $odd ) ? 'even' : 'odd';
1900
  }
1901
  } else {
1902
  $body .= "<$td id='$params[format]-$date_is' $ariacurrent class='$dateclass $weekend_class $monthclass $events_class day-with-date'>" . "<$element class='mc-date $trigger'><span aria-hidden='true'>$thisday_heading</span><span class='screen-reader-text'>" . date_i18n( $date_format, strtotime( $date_is ) ) . "</span></$close>" . $event_output . "</$td>\n";
1904
  }
1905
  } else {
1906
  // If there are no events on this date within current params.
1907
+ if ( 'list' !== $params['format'] ) {
1908
  $weekend_class = ( $is_weekend ) ? 'weekend' : '';
1909
  $body .= "<$td $ariacurrent class='no-events $dateclass $weekend_class $monthclass $events_class day-with-date'><span class='mc-date no-events'><span aria-hidden='true'>$thisday_heading</span><span class='screen-reader-text'>" . date_i18n( $date_format, strtotime( $date_is ) ) . "</span></span></$td>\n";
1910
  } else {
1911
+ if ( true === $show_all ) {
1912
  $body .= "<li id='$params[format]-$date_is' $ariacurrent class='no-events $dateclass $events_class $odd'><strong class=\"event-date\">" . mc_wrap_title( date_i18n( $date_format, $start ) ) . '</strong></li>';
1913
+ $odd = ( 'odd' === $odd ) ? 'even' : 'odd';
1914
  }
1915
  }
1916
  }
1917
 
1918
  if ( date( 'N', $start ) == $end_of_week || ( date( 'N', $start ) == 5 && ! $show_weekends ) ) {
1919
+ if ( 'list' !== $params['format'] ) {
1920
  $body .= "\n</$tr>\n"; // End of 'is beginning of week'.
1921
  }
1922
  $week_number_shown = false;
1928
  }
1929
 
1930
  $table = apply_filters( 'mc_grid_wrapper', 'table', $params['format'] );
1931
+ $end = ( 'table' === $table ) ? "\n</tbody>\n</table>" : "</div></$table>";
1932
+ $body .= ( 'list' === $params['format'] ) ? "\n</ul>" : $end;
1933
  }
1934
  $body .= $bottom;
1935
  }
1962
  $c_year = $date['year'];
1963
 
1964
  // Grid calendar can't show multiple months.
1965
+ if ( 'list' === $format && 'week' !== $time ) {
1966
  if ( $num > 0 && 'day' != $time && 'week' != $time ) {
1967
+ if ( 'month+1' === $time ) {
1968
  $from = date( 'Y-m-d', strtotime( '+1 month', mktime( 0, 0, 0, $c_month, 1, $c_year ) ) );
1969
  $next = strtotime( "+$num months", strtotime( '+1 month', mktime( 0, 0, 0, $c_month, 1, $c_year ) ) );
1970
  } else {
2011
  $ltype = $params['ltype'];
2012
  $lvalue = $params['lvalue'];
2013
 
2014
+ if ( 'none' === $above && 'none' === $below ) {
2015
  return array(
2016
  'bottom' => '',
2017
  'top' => '',
2023
  $mc_bottomorder = array( 'key', 'feeds' );
2024
  $available = array( 'nav', 'toggle', 'jump', 'print', 'timeframe', 'key', 'feeds', 'exports' );
2025
 
2026
+ if ( 'none' === $above ) {
2027
  $mc_toporder = array();
2028
  } else {
2029
  // Set up above-calendar order of fields.
2030
+ if ( '' !== get_option( 'mc_topnav', '' ) ) {
2031
  $mc_toporder = array_map( 'trim', explode( ',', get_option( 'mc_topnav' ) ) );
2032
  }
2033
 
2034
+ if ( '' !== $above ) {
2035
  $mc_toporder = array_map( 'trim', explode( ',', $above ) );
2036
  }
2037
  }
2038
 
2039
+ if ( 'none' === $below ) {
2040
  $mc_bottomorder = array();
2041
  } else {
2042
+ if ( '' !== get_option( 'mc_bottomnav', '' ) ) {
2043
  $mc_bottomorder = array_map( 'trim', explode( ',', get_option( 'mc_bottomnav' ) ) );
2044
  }
2045
 
2046
+ if ( '' !== $below ) {
2047
  $mc_bottomorder = array_map( 'trim', explode( ',', $below ) );
2048
  }
2049
  }
2075
  'href' => urlencode( mc_get_current_url() ),
2076
  );
2077
 
2078
+ if ( 'list' === $format ) {
2079
  $add['format'] = 'list';
2080
  }
2081
 
2082
  $subtract = array();
2083
+ if ( '' === $ltype ) {
2084
  $subtract[] = 'ltype';
2085
  unset( $add['ltype'] );
2086
  }
2087
 
2088
+ if ( '' === $lvalue ) {
2089
  $subtract[] = 'lvalue';
2090
  unset( $add['lvalue'] );
2091
  }
2092
 
2093
+ if ( 'all' === $category ) {
2094
  $subtract[] = 'mcat';
2095
  unset( $add['mcat'] );
2096
  }
2097
 
2098
  // Set up print link.
2099
+ if ( in_array( 'print', $used, true ) ) {
2100
  $print_add = array_merge( $add, array( 'cid' => 'mc-print-view' ) );
2101
  $mc_print_url = mc_build_url( $print_add, $subtract, home_url() );
2102
  $print = "<div class='mc-print'><a href='$mc_print_url'>" . __( 'Print<span class="maybe-hide"> View</span>', 'my-calendar' ) . '</a></div>';
2106
  $toggle = ( in_array( 'toggle', $used ) ) ? mc_format_toggle( $format, 'yes', $time ) : '';
2107
 
2108
  // Set up time toggle.
2109
+ if ( in_array( 'timeframe', $used, true ) ) {
2110
  $timeframe = mc_time_toggle( $format, $time, $date['month'], $date['year'], $date['current_date'], $start_of_week, $from );
2111
  }
2112
 
2113
  // Set up category key.
2114
+ $key = ( in_array( 'key', $used, true ) ) ? mc_category_key( $cat ) : '';
2115
 
2116
  // Set up navigation links.
2117
+ if ( in_array( 'nav', $used, true ) ) {
2118
  $nav = mc_nav( $date, $format, $time, $show_months, $main_class );
2119
  }
2120
 
2121
  // Set up rss feeds.
2122
+ if ( in_array( 'feeds', $used, true ) ) {
2123
  $feeds = mc_sub_links( $subtract );
2124
  }
2125
 
2126
  // Set up exports.
2127
+ if ( in_array( 'exports', $used, true ) ) {
2128
  $ical_m = ( isset( $_GET['month'] ) ) ? (int) $_GET['month'] : date( 'n' );
2129
  $ical_y = ( isset( $_GET['yr'] ) ) ? (int) $_GET['yr'] : date( 'Y' );
2130
  $next_link = my_calendar_next_link( $date, $format, $time, $show_months );
2132
  }
2133
 
2134
  // Set up date switcher.
2135
+ if ( in_array( 'jump', $used, true ) ) {
2136
  $jump = mc_date_switcher( $format, $main_class, $time, $date );
2137
  }
2138
 
2139
  foreach ( $mc_toporder as $value ) {
2140
+ if ( 'none' !== $value && in_array( $value, $used, true ) && in_array( $value, $available, true ) ) {
2141
  $value = trim( $value );
2142
  $mc_topnav .= ${$value};
2143
  }
2144
  }
2145
 
2146
  foreach ( $mc_bottomorder as $value ) {
2147
+ if ( 'none' !== $value && 'stop' !== $value && in_array( $value, $used, true ) && in_array( $value, $available, true ) ) {
2148
  $value = trim( $value );
2149
  $mc_bottomnav .= ${$value};
2150
  }
2151
  }
2152
 
2153
+ if ( '' !== $mc_topnav ) {
2154
  $mc_topnav = '<div class="my-calendar-header">' . $mc_topnav . '</div>';
2155
  }
2156
 
2157
+ if ( '' !== $mc_bottomnav ) {
2158
  $mc_bottomnav = "<div class='mc_bottomnav my-calendar-footer'>$mc_bottomnav</div>";
2159
  }
2160
 
2182
  if ( 'list' != $format ) {
2183
  $body = "<$td class='week_number'>$weeknumber</$td>";
2184
  }
2185
+ if ( 'list' === $format && ! empty( $events ) ) {
2186
  $body = "<li class='mc-week-number'><span class='week-number-text'>" . __( 'Week', 'my-calendar' ) . "</span> <span class='week-number-number'>$weeknumber</span></li>";
2187
  }
2188
  }
2203
  */
2204
  function mc_build_mini_url( $start, $category, $events, $args, $date ) {
2205
  $open_day_uri = get_option( 'mc_open_day_uri' );
2206
+ if ( 'true' === $open_day_uri || 'false' === $open_day_uri ) {
2207
  // Yes, this is weird. it's from some old settings...
2208
  $target = array(
2209
  'yr' => date( 'Y', $start ),
2246
  * @return string new format.
2247
  */
2248
  function mc_convert_format( $format, $params ) {
2249
+ if ( 'true' === get_option( 'mc_convert' ) ) {
2250
+ $format = ( mc_is_mobile() && 'calendar' === $format ) ? 'list' : $format;
2251
+ } elseif ( 'mini' === get_option( 'mc_convert' ) ) {
2252
  $format = ( mc_is_mobile() ) ? 'mini' : $format;
2253
  }
2254
 
2317
  $syear = $params['syear'];
2318
  $sday = $params['sday'];
2319
  $c_m = 0;
2320
+ if ( isset( $_GET['dy'] ) && $main_class === $cid && ( 'day' === $time || 'week' === $time ) ) {
2321
  $c_day = (int) $_GET['dy'];
2322
  } else {
2323
+ if ( 'week' === $time ) {
2324
  $dm = mc_first_day_of_week();
2325
  $c_day = $dm[0];
2326
  $c_m = $dm[1];
2327
+ } elseif ( 'day' === $time ) {
2328
  $c_day = date( 'd', $timestamp );
2329
  } else {
2330
  $c_day = 1;
2340
  $c_month = ( 0 == $c_m ) ? date( 'm', $timestamp ) : date( 'm', strtotime( $xnow . ' -1 month' ) );
2341
  }
2342
 
2343
+ $is_start_of_week = ( get_option( 'start_of_week' ) === date( 'N', $timestamp ) ) ? true : false;
2344
  if ( isset( $_GET['yr'] ) && $main_class == $cid ) {
2345
  $c_year = (int) $_GET['yr'];
2346
  } else {
2347
+ if ( 'week' === $time && ! isset( $_GET['dy'] ) ) {
2348
  if ( $is_start_of_week ) {
2349
  $c_year = ( date( 'Y', current_time( 'timestamp' ) ) );
2350
  } else {
2397
  * @return string Calendar body with shortcodes processed
2398
  */
2399
  function mc_run_shortcodes( $content ) {
2400
+ $content = ( 'true' === get_option( 'mc_process_shortcodes' ) ) ? do_shortcode( $content ) : $content;
2401
 
2402
  return $content;
2403
  }
2410
  * @return string title with wrapper if appropriate
2411
  */
2412
  function mc_wrap_title( $title ) {
2413
+ if ( '1' !== get_option( 'mc_list_javascript' ) ) {
2414
  $is_anchor = '<button type="button" class="mc-text-button">';
2415
  $is_close_anchor = '</button>';
2416
  } else {
2432
  global $wpdb;
2433
  $url = plugin_dir_url( __FILE__ );
2434
  $mcdb = $wpdb;
2435
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
2436
  $mcdb = mc_remote_db();
2437
  }
2438
  $key = '';
2455
 
2456
  $selected_categories = ( empty( $_GET['mcat'] ) ) ? array() : explode( ',', $_GET['mcat'] );
2457
 
2458
+ if ( in_array( $cat->category_id, $selected_categories, true ) || $category === $cat->category_id ) {
2459
  $selected_categories = array_diff( $selected_categories, array( $cat->category_id ) );
2460
  $class .= ' current';
2461
  $aria_current = 'aria-current="true"';
2464
  $aria_current = '';
2465
  }
2466
  $selectable_categories = implode( ',', $selected_categories );
2467
+ if ( '' === $selectable_categories ) {
2468
  $url = remove_query_arg( 'mcat', mc_get_current_url() );
2469
  } else {
2470
  $url = mc_build_url( array( 'mcat' => $selectable_categories ), array( 'mcat' ) );
2473
  $class .= ' private';
2474
  }
2475
  $cat_name = mc_kses_post( stripcslashes( $cat->category_name ) );
2476
+ $cat_name = ( '' === $cat_name ) ? '<span class="screen-reader-text">' . __( 'Untitled Category', 'my-calendar' ) . '</span>' : $cat_name;
2477
  $cat_key = '';
2478
+ if ( '' !== $cat->category_icon && 'true' !== get_option( 'mc_hide_icons' ) ) {
2479
  $cat_key .= '<span class="category-color-sample"><img src="' . $path . $cat->category_icon . '" alt="" style="background:' . $hex . $cat->category_color . ';" /></span>' . $cat_name;
2480
+ } elseif ( 'default' !== get_option( 'mc_apply_color' ) ) {
2481
  $cat_key .= '<span class="category-color-sample no-icon" style="background:' . $hex . $cat->category_color . ';"> &nbsp; </span>' . $cat_name;
2482
  } else {
2483
  // If category colors are ignored, don't render HTML for them.
2569
  $cur_day = $date['day'];
2570
 
2571
  $next_year = $cur_year + 1;
2572
+ $mc_next = get_option( 'mc_next_events', '' );
2573
+ $next_events = ( '' === $mc_next ) ? '<span class="maybe-hide">' . __( 'Next', 'my-calendar' ) . '</span>' : stripslashes( $mc_next );
2574
+ if ( $months <= 1 || 'list' !== $format ) {
2575
  if ( 12 == $cur_month ) {
2576
  $month = 1;
2577
  $yr = $next_year;
2597
  $format = 'F';
2598
  }
2599
  $date = date_i18n( $format, mktime( 0, 0, 0, $month, 1, $yr ) );
2600
+ if ( 'week' === $time ) {
2601
  $nextdate = strtotime( "$cur_year-$cur_month-$cur_day" . '+ 7 days' );
2602
  $day = date( 'd', $nextdate );
2603
  $yr = date( 'Y', $nextdate );
2610
  // Translators: Current formatted date.
2611
  $date = sprintf( __( 'Week of %s', 'my-calendar' ), date_i18n( $format, mktime( 0, 0, 0, $month, $day, $yr ) ) );
2612
  }
2613
+ if ( 'day' === $time ) {
2614
  $nextdate = strtotime( "$cur_year-$cur_month-$cur_day" . '+ 1 days' );
2615
  $day = date( 'd', $nextdate );
2616
  $yr = date( 'Y', $nextdate );
2677
  }
2678
  $date = date_i18n( $format, mktime( 0, 0, 0, $month, 1, $yr ) );
2679
  $day = '';
2680
+ if ( 'week' === $time ) {
2681
  $prevdate = strtotime( "$cur_year-$cur_month-$cur_day" . '- 7 days' );
2682
  $day = date( 'd', $prevdate );
2683
  $yr = date( 'Y', $prevdate );
2689
  }
2690
  $date = __( 'Week of ', 'my-calendar' ) . date_i18n( $format, mktime( 0, 0, 0, $month, $day, $yr ) );
2691
  }
2692
+ if ( 'day' === $time ) {
2693
  $prevdate = strtotime( "$cur_year-$cur_month-$cur_day" . '- 1 days' );
2694
  $day = date( 'd', $prevdate );
2695
  $yr = date( 'Y', $prevdate );
2733
  $return = false;
2734
 
2735
  $current_url = mc_get_uri();
2736
+ $current_url = ( '' !== $target_url && _mc_is_url( $target_url ) ) ? $target_url : $current_url;
2737
  $form = "
2738
  <div id='mc_filters'>
2739
  <form action='" . $current_url . "' method='get'>\n";
2747
  foreach ( $qsa as $name => $argument ) {
2748
  $name = esc_attr( strip_tags( $name ) );
2749
  $argument = esc_attr( strip_tags( $argument ) );
2750
+ if ( ! ( 'access' === $name || 'mcat' === $name || 'loc' === $name || 'ltype' === $name || 'mc_id' === $name ) ) {
2751
  $form .= '<input type="hidden" name="' . $name . '" value="' . $argument . '" />' . "\n";
2752
  }
2753
  }
2791
  global $wpdb;
2792
  $mcdb = $wpdb;
2793
 
2794
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
2795
  $mcdb = mc_remote_db();
2796
  }
2797
 
2798
  $output = '';
2799
  $current_url = mc_get_uri();
2800
+ $current_url = ( '' !== $target_url && _mc_is_url( $target_url ) ) ? $target_url : $current_url;
2801
 
2802
+ $name = ( 'public' === $context ) ? 'mcat' : 'category';
2803
+ $admin_fields = ( 'public' === $context ) ? ' name="' . $name . '"' : ' multiple="multiple" size="5" name="' . $name . '[]" ';
2804
+ $admin_label = ( 'public' === $context ) ? '' : __( '(select to include)', 'my-calendar' );
2805
+ $form = ( 'single' === $group ) ? '<form action="' . $current_url . '" method="get">
2806
  <div>' : '';
2807
+ if ( 'single' === $group ) {
2808
  $qsa = array();
2809
  if ( isset( $_SERVER['QUERY_STRING'] ) ) {
2810
  parse_str( $_SERVER['QUERY_STRING'], $qsa );
2815
  foreach ( $qsa as $name => $argument ) {
2816
  $name = esc_attr( strip_tags( $name ) );
2817
  $argument = esc_attr( strip_tags( $argument ) );
2818
+ if ( 'mcat' !== $name || 'mc_id' !== $name ) {
2819
  $form .= ' <input type="hidden" name="' . $name . '" value="' . $argument . '" />' . "\n";
2820
  }
2821
  }
2822
  }
2823
+ $form .= ( 'list' === $show || 'group' === $group ) ? '' : '
2824
  </div><p>';
2825
+ $public_form = ( 'public' === $context ) ? $form : '';
2826
  if ( ! is_user_logged_in() ) {
2827
  $categories = $mcdb->get_results( 'SELECT * FROM ' . my_calendar_categories_table() . ' WHERE category_private = 0 ORDER BY category_name ASC' );
2828
  } else {
2831
  if ( ! empty( $categories ) && count( $categories ) >= 1 ) {
2832
  $output = "<div id='mc_categories'>\n";
2833
  $url = mc_build_url( array( 'mcat' => 'all' ), array() );
2834
+ $output .= ( 'list' === $show ) ? "
2835
  <ul>
2836
  <li><a href='$url'>" . __( 'All Categories', 'my-calendar' ) . '</a></li>' : $public_form . '
2837
  <label for="category">' . __( 'Categories', 'my-calendar' ) . ' ' . $admin_label . '</label>
2841
  foreach ( $categories as $category ) {
2842
  $category_name = strip_tags( stripcslashes( $category->category_name ), mc_strip_tags() );
2843
  $mcat = ( empty( $_GET['mcat'] ) ) ? '' : (int) $_GET['mcat'];
2844
+ $category_id = (int) $category->category_id;
2845
+ if ( 'list' === $show ) {
2846
  $this_url = mc_build_url( array( 'mcat' => $category->category_id ), array() );
2847
+ $selected = ( $category_id === $mcat ) ? ' class="selected"' : '';
2848
  $output .= " <li$selected><a rel='nofollow' href='$this_url'>$category_name</a></li>";
2849
  } else {
2850
+ $selected = ( $category_id === $mcat ) ? ' selected="selected"' : '';
2851
+ $output .= " <option$selected value='$category_id'>$category_name</option>\n";
2852
  }
2853
  }
2854
+ $output .= ( 'list' === $show ) ? '</ul>' : '</select>';
2855
+ if ( 'admin' !== $context && 'list' !== $show ) {
2856
+ if ( 'single' === $group ) {
2857
  $output .= '<input type="submit" value="' . __( 'Submit', 'my-calendar' ) . '" /></p></form>';
2858
  }
2859
  }
2876
  function mc_access_list( $show = 'list', $group = 'single', $target_url = '' ) {
2877
  $output = '';
2878
  $current_url = mc_get_uri();
2879
+ $current_url = ( '' !== $target_url && _mc_is_url( $target_url ) ) ? $target_url : $current_url;
2880
+ $form = ( 'single' === $group ) ? "<form action='" . $current_url . "' method='get'><div>" : '';
2881
+ if ( 'single' === $group ) {
2882
  $qsa = array();
2883
  if ( isset( $_SERVER['QUERY_STRING'] ) ) {
2884
  parse_str( $_SERVER['QUERY_STRING'], $qsa );
2889
  foreach ( $qsa as $name => $argument ) {
2890
  $name = esc_attr( strip_tags( $name ) );
2891
  $argument = esc_attr( strip_tags( $argument ) );
2892
+ if ( 'access' !== $name || 'mc_id' !== $name ) {
2893
  $form .= '<input type="hidden" name="' . $name . '" value="' . $argument . '" />' . "\n";
2894
  }
2895
  }
2896
  }
2897
+ $form .= ( 'list' === $show || 'group' === $group ) ? '' : '</div><p>';
2898
 
2899
  $access_options = mc_event_access();
2900
  if ( ! empty( $access_options ) && count( $access_options ) >= 1 ) {
2901
  $output = "<div id='mc_access'>\n";
2902
  $url = mc_build_url( array( 'access' => 'all' ), array() );
2903
  $not_selected = ( ! isset( $_GET['access'] ) ) ? 'selected="selected"' : '';
2904
+ $output .= ( 'list' === $show ) ? "
2905
  <ul>
2906
  <li><a href='$url'>" . __( 'Accessibility Services', 'my-calendar' ) . '</a></li>' : $form . '
2907
  <label for="access">' . __( 'Accessibility Services', 'my-calendar' ) . '</label>
2911
  foreach ( $access_options as $key => $access ) {
2912
  $access_name = $access;
2913
  $this_access = ( empty( $_GET['access'] ) ) ? '' : (int) $_GET['access'];
2914
+ if ( 'list' === $show ) {
2915
  $this_url = mc_build_url( array( 'access' => $key ), array() );
2916
+ $selected = ( $key === $this_access ) ? ' class="selected"' : '';
2917
  $output .= " <li$selected><a rel='nofollow' href='$this_url'>$access_name</a></li>";
2918
  } else {
2919
+ $selected = ( $this_access === $key ) ? ' selected="selected"' : '';
2920
  $output .= " <option$selected value='" . esc_attr( $key ) . "'>" . esc_html( $access_name ) . "</option>\n";
2921
  }
2922
  }
2923
+ $output .= ( 'list' === $show ) ? '</ul>' : '</select>';
2924
+ $output .= ( 'list' !== $show && 'single' === $group ) ? '<p><input type="submit" value="' . __( 'Limit by Access', 'my-calendar' ) . '" /></p></form>' : '';
2925
  $output .= "\n</div>";
2926
  }
2927
  $output = apply_filters( 'mc_access_selector', $output, $access_options );
2941
  function mc_build_url( $add, $subtract, $root = '' ) {
2942
  $home = '';
2943
 
2944
+ if ( '' !== $root ) {
2945
  $home = $root;
2946
  }
2947
 
2949
  $home = get_permalink( $root );
2950
  }
2951
 
2952
+ if ( '' === $home ) {
2953
  if ( is_front_page() ) {
2954
  $home = home_url( '/' );
2955
  } elseif ( is_home() ) {
2992
  */
2993
  function my_calendar_searchform( $type, $url ) {
2994
  $query = ( isset( $_GET['mcs'] ) ) ? $_GET['mcs'] : '';
2995
+ if ( 'simple' === $type ) {
2996
+ if ( ! $url || '' === $url ) {
2997
  $url = mc_get_uri( false, array( 'type' => $type ) );
2998
  }
2999
  return '
3023
  function mc_get_list_locations( $datatype, $full = true, $return_type = OBJECT ) {
3024
  global $wpdb;
3025
  $mcdb = $wpdb;
3026
+ if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
3027
  $mcdb = mc_remote_db();
3028
  }
3029
 
3079
  if ( $locations ) {
3080
  $output = '<ul class="mc-locations">';
3081
  foreach ( $locations as $key => $value ) {
3082
+ if ( 'hcard' !== $datatype && '' !== $template ) {
3083
  $label = stripslashes( $value->{$datatype} );
3084
  $url = mc_maplink( $value, 'url', 'location' );
3085
  $output .= ( $url ) ? "<li><a href='" . esc_url( $url ) . "'>$label</a></li>" : "<li>$label</li>";
3086
+ } elseif ( 'hcard' === $datatype ) {
3087
  $label = mc_hcard( $value, true, true, 'location' );
3088
  $output .= "<li>$label</li>";
3089
+ } elseif ( '' !== $template ) {
3090
  if ( mc_key_exists( $template ) ) {
3091
  $template = mc_get_custom_template( $template );
3092
  }
3134
  $output = '';
3135
  $locations = mc_get_list_locations( $datatype, $datatype, ARRAY_A );
3136
  $current_url = mc_get_uri();
3137
+ $current_url = ( '' !== $target_url && _mc_is_url( $target_url ) ) ? $target_url : $current_url;
3138
 
3139
  if ( count( $locations ) > 1 ) {
3140
+ if ( 'list' === $show ) {
3141
  $url = mc_build_url(
3142
  array(
3143
  'loc' => 'all',
3150
  } else {
3151
  $ltype = ( ! isset( $_GET['ltype'] ) ) ? $datatype : $_GET['ltype'];
3152
  $output .= '<div id="mc_locations">';
3153
+ $output .= ( 'single' === $group ) ? "<form action='" . $current_url . "' method='get'><div>" : '';
3154
  $output .= "<input type='hidden' name='ltype' value='" . esc_attr( $ltype ) . "' />";
3155
+ if ( 'single' === $group ) {
3156
  $qsa = array();
3157
  if ( isset( $_SERVER['QUERY_STRING'] ) ) {
3158
  parse_str( $_SERVER['QUERY_STRING'], $qsa );
3163
  foreach ( $qsa as $name => $argument ) {
3164
  $name = esc_attr( strip_tags( $name ) );
3165
  $argument = esc_attr( strip_tags( $argument ) );
3166
+ if ( 'loc' !== $name && 'ltype' !== $name ) {
3167
  $output .= "\n" . '<input type="hidden" name="' . $name . '" value="' . $argument . '" />';
3168
  }
3169
  }
3177
  foreach ( $location as $k => $value ) {
3178
  $vt = urlencode( trim( $value ) );
3179
  $value = strip_tags( stripcslashes( $value ), mc_strip_tags() );
3180
+ if ( '' === trim( $value ) ) {
3181
  continue;
3182
  }
3183
  $loc = ( empty( $_GET['loc'] ) ) ? '' : $_GET['loc'];
3184
+ if ( 'list' === $show ) {
3185
+ $selected = ( $vt === $loc ) ? ' class="selected"' : '';
3186
  $this_url = esc_url(
3187
  mc_build_url(
3188
  array(
3194
  );
3195
  $output .= " <li$selected><a rel='nofollow' href='$this_url'>$value</a></li>\n";
3196
  } else {
3197
+ $selected = ( $vt === $loc ) ? ' class="selected"' : '';
3198
+ $output .= " <option value='" . esc_attr( $vt ) . "'$selected>$value</option>\n";
 
 
3199
  }
3200
  }
3201
  }
3202
+ if ( 'list' === $show ) {
3203
  $output .= '</ul>';
3204
  } else {
3205
  $output .= '</select>';
3206
+ $output .= ( 'single' === $group ) ? '<input type="submit" value="' . __( 'Submit', 'my-calendar' ) . '" />
3207
  </div>
3208
  </form>' : '';
3209
  $output .= '</div>';
my-calendar-settings.php CHANGED
@@ -32,7 +32,7 @@ function mc_settings_field( $name, $label, $default = '', $note = '', $atts = ar
32
  $attributes .= " $key='$value'";
33
  }
34
  }
35
- $value = ( '' != get_option( $name ) ) ? esc_attr( stripslashes( get_option( $name ) ) ) : $default;
36
  switch ( $type ) {
37
  case 'text':
38
  case 'url':
@@ -78,7 +78,7 @@ function mc_settings_field( $name, $label, $default = '', $note = '', $atts = ar
78
  $aria = '';
79
  }
80
  foreach ( $label as $k => $v ) {
81
- $checked = ( $k == $value ) ? ' checked="checked"' : '';
82
  $options .= "<li><input type='radio' id='$name-$k' value='" . esc_attr( $k ) . "' name='$name'$aria$attributes$checked /> <label for='$name-$k'>$v</label></li>";
83
  }
84
  $return = "$options $note";
@@ -94,7 +94,7 @@ function mc_settings_field( $name, $label, $default = '', $note = '', $atts = ar
94
  }
95
  if ( is_array( $default ) ) {
96
  foreach ( $default as $k => $v ) {
97
- $checked = ( $k == $value ) ? ' selected="selected"' : '';
98
  $options .= "<option value='" . esc_attr( $k ) . "'$checked>$v</option>";
99
  }
100
  }
@@ -222,8 +222,8 @@ function my_calendar_settings() {
222
  update_option( 'mc_drop_tables', $mc_drop_tables );
223
  update_option( 'mc_default_sort', $_POST['mc_default_sort'] );
224
  update_option( 'mc_default_direction', $_POST['mc_default_direction'] );
225
- if ( 2 == get_site_option( 'mc_multisite' ) ) {
226
- $mc_current_table = (int) $_POST['mc_current_table'];
227
  update_option( 'mc_current_table', $mc_current_table );
228
  }
229
  mc_show_notice( __( 'My Calendar Management Settings saved', 'my-calendar' ) . ". $clear" );
@@ -262,7 +262,7 @@ function my_calendar_settings() {
262
  $permalinks = get_option( 'mc_use_permalinks' );
263
  $mc_open_day_uri = ( ! empty( $_POST['mc_open_day_uri'] ) ) ? $_POST['mc_open_day_uri'] : '';
264
  update_option( 'mc_use_permalinks', ( ! empty( $_POST['mc_use_permalinks'] ) ) ? 'true' : 'false' );
265
- update_option( 'mc_open_uri', ( ! empty( $_POST['mc_open_uri'] ) && 'on' === $_POST['mc_open_uri'] && '' != get_option( 'mc_uri' ) ) ? 'true' : 'false' );
266
  update_option( 'mc_no_link', ( ! empty( $_POST['mc_no_link'] ) && 'on' === $_POST['mc_no_link'] ) ? 'true' : 'false' );
267
  update_option( 'mc_mini_uri', $_POST['mc_mini_uri'] );
268
  update_option( 'mc_open_day_uri', $mc_open_day_uri );
@@ -487,7 +487,7 @@ function my_calendar_settings() {
487
  $page_title = get_post( absint( get_option( 'mc_uri_id' ) ) )->post_title;
488
  $permalink = esc_url( get_permalink( absint( get_option( 'mc_uri_id' ) ) ) );
489
  }
490
- if ( '' != get_option( 'mc_uri' ) && ( get_option( 'mc_uri' ) != $permalink ) ) {
491
  ?>
492
  <li><?php mc_settings_field( 'mc_uri', __( 'Where is your main calendar page?', 'my-calendar' ), '', "$guess[message]", array( 'size' => '60' ), 'url' ); ?></li>
493
  <li>
@@ -578,7 +578,7 @@ function mc_remote_db() {
578
  <li><?php mc_settings_field( 'remigrate', __( 'Re-generate event occurrences table.', 'my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>
579
  <li><?php mc_settings_field( 'mc_drop_tables', __( 'Drop MySQL tables on uninstall', 'my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>
580
  <?php
581
- if ( get_site_option( 'mc_multisite' ) == 2 && my_calendar_table() !== my_calendar_table( 'global' ) ) {
582
  mc_settings_field(
583
  'mc_current_table',
584
  array(
@@ -644,12 +644,12 @@ function mc_remote_db() {
644
  <div><input type='hidden' name='mc_dates' value='true'/></div>
645
  <ul>
646
  <?php
647
- $month_format = ( '' == get_option( 'mc_month_format' ) ) ? date_i18n( 'F Y' ) : date_i18n( get_option( 'mc_month_format' ) );
648
- $time_format = ( '' == get_option( 'mc_time_format' ) ) ? date_i18n( get_option( 'time_format' ) ) : date_i18n( get_option( 'mc_time_format' ) );
649
- $week_format = ( '' == get_option( 'mc_week_format' ) ) ? date_i18n( 'M j, \'y' ) : date_i18n( get_option( 'mc_week_format' ) );
650
- $date_format = ( '' == get_option( 'mc_date_format' ) ) ? date_i18n( get_option( 'date_format' ) ) : date_i18n( get_option( 'mc_date_format' ) );
651
  $tomorrow = date( 'j' ) + 1;
652
- $multi_format = ( '' == get_option( 'mc_multidate_format' ) ) ? date_i18n( str_replace( '%d', $tomorrow, 'F j-%d, Y' ) ) : date_i18n( str_replace( '%j', $tomorrow, get_option( 'mc_multidate_format' ) ) );
653
  ?>
654
  <li><?php mc_settings_field( 'mc_date_format', __( 'Primary Date Format', 'my-calendar' ), '', $date_format ); ?></li>
655
  <li><?php mc_settings_field( 'mc_time_format', __( 'Time format', 'my-calendar' ), '', $time_format ); ?></li>
@@ -679,7 +679,7 @@ function mc_remote_db() {
679
  <legend><?php _e( 'Calendar Link Targets', 'my-calendar' ); ?></legend>
680
  <ul>
681
  <?php
682
- if ( isset( $_POST['mc_use_permalinks'] ) && '' != $note ) {
683
  $url = admin_url( 'options-permalink.php#mc_cpt_base' );
684
  // Translators: URL for WordPress Settings > Permalinks.
685
  $note = ' <span class="mc-notice">' . sprintf( __( 'Go to <a href="%s">permalink settings</a> to set the base URL for events.', 'my-calendar' ) . '</span>', $url );
@@ -763,7 +763,7 @@ function mc_remote_db() {
763
  $i = 1;
764
  $count = count( $missed );
765
  foreach ( $missed as $k => $v ) {
766
- if ( $i != $count ) {
767
  $buttons = "<button class='up'><i class='dashicons dashicons-arrow-up'></i><span class='screen-reader-text'>Up</span></button> <button class='down'><i class='dashicons dashicons-arrow-down'></i><span class='screen-reader-text'>Down</span></button>";
768
  } else {
769
  $buttons = "<button class='up'><i class='dashicons dashicons-arrow-up'></i><span class='screen-reader-text'>Up</span></button>";
32
  $attributes .= " $key='$value'";
33
  }
34
  }
35
+ $value = ( '' !== get_option( $name, '' ) ) ? esc_attr( stripslashes( get_option( $name ) ) ) : $default;
36
  switch ( $type ) {
37
  case 'text':
38
  case 'url':
78
  $aria = '';
79
  }
80
  foreach ( $label as $k => $v ) {
81
+ $checked = ( $k === $value ) ? ' checked="checked"' : '';
82
  $options .= "<li><input type='radio' id='$name-$k' value='" . esc_attr( $k ) . "' name='$name'$aria$attributes$checked /> <label for='$name-$k'>$v</label></li>";
83
  }
84
  $return = "$options $note";
94
  }
95
  if ( is_array( $default ) ) {
96
  foreach ( $default as $k => $v ) {
97
+ $checked = ( $k === $value ) ? ' selected="selected"' : '';
98
  $options .= "<option value='" . esc_attr( $k ) . "'$checked>$v</option>";
99
  }
100
  }
222
  update_option( 'mc_drop_tables', $mc_drop_tables );
223
  update_option( 'mc_default_sort', $_POST['mc_default_sort'] );
224
  update_option( 'mc_default_direction', $_POST['mc_default_direction'] );
225
+ if ( 2 === (int) get_site_option( 'mc_multisite' ) ) {
226
+ $mc_current_table = ( isset( $_POST['mc_current_table'] ) ) ? (int) $_POST['mc_current_table'] : 0;
227
  update_option( 'mc_current_table', $mc_current_table );
228
  }
229
  mc_show_notice( __( 'My Calendar Management Settings saved', 'my-calendar' ) . ". $clear" );
262
  $permalinks = get_option( 'mc_use_permalinks' );
263
  $mc_open_day_uri = ( ! empty( $_POST['mc_open_day_uri'] ) ) ? $_POST['mc_open_day_uri'] : '';
264
  update_option( 'mc_use_permalinks', ( ! empty( $_POST['mc_use_permalinks'] ) ) ? 'true' : 'false' );
265
+ update_option( 'mc_open_uri', ( ! empty( $_POST['mc_open_uri'] ) && 'on' === $_POST['mc_open_uri'] && '' !== get_option( 'mc_uri', '' ) ) ? 'true' : 'false' );
266
  update_option( 'mc_no_link', ( ! empty( $_POST['mc_no_link'] ) && 'on' === $_POST['mc_no_link'] ) ? 'true' : 'false' );
267
  update_option( 'mc_mini_uri', $_POST['mc_mini_uri'] );
268
  update_option( 'mc_open_day_uri', $mc_open_day_uri );
487
  $page_title = get_post( absint( get_option( 'mc_uri_id' ) ) )->post_title;
488
  $permalink = esc_url( get_permalink( absint( get_option( 'mc_uri_id' ) ) ) );
489
  }
490
+ if ( '' !== get_option( 'mc_uri', '' ) && ( get_option( 'mc_uri' ) !== $permalink ) ) {
491
  ?>
492
  <li><?php mc_settings_field( 'mc_uri', __( 'Where is your main calendar page?', 'my-calendar' ), '', "$guess[message]", array( 'size' => '60' ), 'url' ); ?></li>
493
  <li>
578
  <li><?php mc_settings_field( 'remigrate', __( 'Re-generate event occurrences table.', 'my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>
579
  <li><?php mc_settings_field( 'mc_drop_tables', __( 'Drop MySQL tables on uninstall', 'my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>
580
  <?php
581
+ if ( (int) get_site_option( 'mc_multisite' ) === 2 && my_calendar_table() !== my_calendar_table( 'global' ) ) {
582
  mc_settings_field(
583
  'mc_current_table',
584
  array(
644
  <div><input type='hidden' name='mc_dates' value='true'/></div>
645
  <ul>
646
  <?php
647
+ $month_format = ( '' === get_option( 'mc_month_format', '' ) ) ? date_i18n( 'F Y' ) : date_i18n( get_option( 'mc_month_format' ) );
648
+ $time_format = ( '' === get_option( 'mc_time_format', '' ) ) ? date_i18n( get_option( 'time_format' ) ) : date_i18n( get_option( 'mc_time_format' ) );
649
+ $week_format = ( '' === get_option( 'mc_week_format', '' ) ) ? date_i18n( 'M j, \'y' ) : date_i18n( get_option( 'mc_week_format' ) );
650
+ $date_format = ( '' === get_option( 'mc_date_format', '' ) ) ? date_i18n( get_option( 'date_format' ) ) : date_i18n( get_option( 'mc_date_format' ) );
651
  $tomorrow = date( 'j' ) + 1;
652
+ $multi_format = ( '' === get_option( 'mc_multidate_format', '' ) ) ? date_i18n( str_replace( '%d', $tomorrow, 'F j-%d, Y' ) ) : date_i18n( str_replace( '%j', $tomorrow, get_option( 'mc_multidate_format' ) ) );
653
  ?>
654
  <li><?php mc_settings_field( 'mc_date_format', __( 'Primary Date Format', 'my-calendar' ), '', $date_format ); ?></li>
655
  <li><?php mc_settings_field( 'mc_time_format', __( 'Time format', 'my-calendar' ), '', $time_format ); ?></li>
679
  <legend><?php _e( 'Calendar Link Targets', 'my-calendar' ); ?></legend>
680
  <ul>
681
  <?php
682
+ if ( isset( $_POST['mc_use_permalinks'] ) && '' !== $note ) {
683
  $url = admin_url( 'options-permalink.php#mc_cpt_base' );
684
  // Translators: URL for WordPress Settings > Permalinks.
685
  $note = ' <span class="mc-notice">' . sprintf( __( 'Go to <a href="%s">permalink settings</a> to set the base URL for events.', 'my-calendar' ) . '</span>', $url );
763
  $i = 1;
764
  $count = count( $missed );
765
  foreach ( $missed as $k => $v ) {
766
+ if ( $i !== $count ) {
767
  $buttons = "<button class='up'><i class='dashicons dashicons-arrow-up'></i><span class='screen-reader-text'>Up</span></button> <button class='down'><i class='dashicons dashicons-arrow-down'></i><span class='screen-reader-text'>Down</span></button>";
768
  } else {
769
  $buttons = "<button class='up'><i class='dashicons dashicons-arrow-up'></i><span class='screen-reader-text'>Up</span></button>";
my-calendar-shortcodes.php CHANGED
@@ -309,3 +309,26 @@ function my_calendar_now( $atts ) {
309
 
310
  return my_calendar_events_now( $args['category'], $args['template'], $args['site'] );
311
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
 
310
  return my_calendar_events_now( $args['category'], $args['template'], $args['site'] );
311
  }
312
+
313
+ /**
314
+ * Next Event My Calendar shortcode.
315
+ *
316
+ * @param array $atts Shortcode attributes.
317
+ *
318
+ * @return string event.
319
+ */
320
+ function my_calendar_next( $atts ) {
321
+ $args = shortcode_atts(
322
+ array(
323
+ 'category' => '',
324
+ 'template' => '<strong>{link_title}</strong> {timerange}',
325
+ 'skip' => 0,
326
+ 'site' => false,
327
+ ),
328
+ $atts,
329
+ 'my_calendar_next'
330
+ );
331
+
332
+ return my_calendar_events_next( $args['category'], $args['template'], $args['skip'], $args['site'] );
333
+ }
334
+
my-calendar-styles.php CHANGED
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
18
  */
19
  function my_calendar_style_edit() {
20
  $edit_files = true;
21
- if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT == true ) {
22
  $edit_files = false;
23
  mc_show_error( __( 'File editing is disallowed in your WordPress installation. Edit your stylesheets offline.', 'my-calendar' ) );
24
  }
@@ -40,7 +40,7 @@ function my_calendar_style_edit() {
40
  if ( 'disabled' === $wrote_styles ) {
41
  $message = '<p>' . __( 'Styles are disabled, and were not edited.', 'my-calendar' ) . '</p>';
42
  } else {
43
- $message = ( true == $wrote_styles ) ? '<p>' . __( 'The stylesheet has been updated.', 'my-calendar' ) . '</p>' : '<p><strong>' . __( 'Write Error! Please verify write permissions on the style file.', 'my-calendar' ) . '</strong></p>';
44
  }
45
 
46
  $mc_show_css = ( empty( $_POST['mc_show_css'] ) ) ? '' : stripcslashes( $_POST['mc_show_css'] );
@@ -70,7 +70,7 @@ function my_calendar_style_edit() {
70
  }
71
  }
72
  foreach ( $_POST['style_vars'] as $key => $value ) {
73
- if ( '' != $value ) {
74
  $styles[ $key ] = $value;
75
  }
76
  }
@@ -139,7 +139,7 @@ function my_calendar_style_edit() {
139
  if ( mc_is_custom_style( get_option( 'mc_css_file' ) ) ) {
140
  _e( 'The editor is not available for custom CSS files. Edit your custom CSS locally, then upload your changes.', 'my-calendar' );
141
  } else {
142
- $disabled = ( $edit_files || get_option( 'mc_use_styles' ) == 'true' ) ? '' : ' disabled="disabled"';
143
  ?>
144
  <label for="style"><?php _e( 'Edit the stylesheet for My Calendar', 'my-calendar' ); ?></label><br/><textarea <?php echo $disabled; ?> class="style-editor" id="style" name="style" rows="30" cols="80"><?php echo $my_calendar_style; ?></textarea>
145
  <?php
@@ -153,7 +153,7 @@ function my_calendar_style_edit() {
153
  $styles = get_option( 'mc_style_vars' );
154
  foreach ( $styles as $var => $style ) {
155
  $var_id = 'mc' . sanitize_key( $var );
156
- if ( ! in_array( $var, array( '--primary-dark', '--primary-light', '--secondary-light', '--secondary-dark', '--highlight-dark', '--highlight-light' ) ) ) {
157
  $delete = " <input type='checkbox' id='delete_var_$var_id' name='delete_var' value='" . esc_attr( $var ) . "' /><label for='delete_var_$var_id'>" . __( 'Delete', 'my-calendar' ) . '</label>';
158
  } else {
159
  $delete = '';
@@ -191,7 +191,7 @@ function my_calendar_style_edit() {
191
  )
192
  );
193
  echo '</div>';
194
- } elseif ( trim( $left_string ) != trim( $right_string ) ) {
195
  echo '<div class="wrap my-calendar-admin">';
196
  mc_show_notice( __( 'There have been updates to the stylesheet.', 'my-calendar' ) . ' <a href="' . admin_url( 'admin.php?page=my-calendar-styles&amp;diff#diff' ) . '">' . __( 'Compare Your Stylesheet with latest installed version of My Calendar.', 'my-calendar' ) . '</a>' );
197
  echo '</div>';
@@ -238,8 +238,8 @@ function mc_stylesheet_selector() {
238
  $test = 'mc_custom_' . $value;
239
  $filepath = mc_get_style_path( $test );
240
  $path = pathinfo( $filepath );
241
- if ( 'css' == $path['extension'] ) {
242
- $selected = ( get_option( 'mc_css_file' ) == $test ) ? ' selected="selected"' : '';
243
  $options .= "<option value='mc_custom_$value'$selected>$value</option>\n";
244
  }
245
  }
@@ -250,8 +250,8 @@ function mc_stylesheet_selector() {
250
  foreach ( $files as $value ) {
251
  $filepath = mc_get_style_path( $value );
252
  $path = pathinfo( $filepath );
253
- if ( 'css' == $path['extension'] ) {
254
- $selected = ( get_option( 'mc_css_file' ) == $value ) ? ' selected="selected"' : '';
255
  $options .= "<option value='$value'$selected>$value</option>\n";
256
  }
257
  }
@@ -287,11 +287,11 @@ function mc_get_style_path( $filename = false, $type = 'path' ) {
287
  }
288
  if ( 0 === strpos( $filename, 'mc_custom_' ) ) {
289
  $filename = str_replace( 'mc_custom_', '', $filename );
290
- $stylefile = ( 'path' == $type ) ? str_replace( '/my-calendar/', '', $dir ) . '/my-calendar-custom/styles/' . $filename : str_replace( '/my-calendar/', '', $url ) . '/my-calendar-custom/styles/' . $filename;
291
  } else {
292
- $stylefile = ( 'path' == $type ) ? dirname( __FILE__ ) . '/styles/' . $filename : plugins_url( 'styles', __FILE__ ) . '/' . $filename;
293
  }
294
- if ( 'path' == $type ) {
295
  if ( is_file( $stylefile ) ) {
296
  return $stylefile;
297
  } else {
@@ -369,7 +369,7 @@ function mc_css_list( $directory ) {
369
  // Keep going until all files in directory have been read.
370
  while ( $file = readdir( $handler ) ) {
371
  // If $file isn't this directory or parent, add it to the results array.
372
- if ( '.' != $file && '..' != $file ) {
373
  $results[] = $file;
374
  }
375
  }
@@ -388,7 +388,7 @@ function mc_css_list( $directory ) {
388
  * @return boolean;
389
  */
390
  function mc_write_styles( $file, $style ) {
391
- if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT == true ) {
392
  return false;
393
  }
394
 
@@ -397,12 +397,12 @@ function mc_write_styles( $file, $style ) {
397
  foreach ( $files as $f ) {
398
  $filepath = mc_get_style_path( $f );
399
  $path = pathinfo( $filepath );
400
- if ( 'css' == $path['extension'] ) {
401
  $styles_whitelist[] = $filepath;
402
  }
403
  }
404
 
405
- if ( in_array( $file, $styles_whitelist ) ) {
406
  if ( function_exists( 'wp_is_writable' ) ) {
407
  $is_writable = wp_is_writable( $file );
408
  } else {
18
  */
19
  function my_calendar_style_edit() {
20
  $edit_files = true;
21
+ if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT === true ) {
22
  $edit_files = false;
23
  mc_show_error( __( 'File editing is disallowed in your WordPress installation. Edit your stylesheets offline.', 'my-calendar' ) );
24
  }
40
  if ( 'disabled' === $wrote_styles ) {
41
  $message = '<p>' . __( 'Styles are disabled, and were not edited.', 'my-calendar' ) . '</p>';
42
  } else {
43
+ $message = ( true === $wrote_styles ) ? '<p>' . __( 'The stylesheet has been updated.', 'my-calendar' ) . '</p>' : '<p><strong>' . __( 'Write Error! Please verify write permissions on the style file.', 'my-calendar' ) . '</strong></p>';
44
  }
45
 
46
  $mc_show_css = ( empty( $_POST['mc_show_css'] ) ) ? '' : stripcslashes( $_POST['mc_show_css'] );
70
  }
71
  }
72
  foreach ( $_POST['style_vars'] as $key => $value ) {
73
+ if ( '' !== trim( $value ) ) {
74
  $styles[ $key ] = $value;
75
  }
76
  }
139
  if ( mc_is_custom_style( get_option( 'mc_css_file' ) ) ) {
140
  _e( 'The editor is not available for custom CSS files. Edit your custom CSS locally, then upload your changes.', 'my-calendar' );
141
  } else {
142
+ $disabled = ( $edit_files || get_option( 'mc_use_styles' ) === 'true' ) ? '' : ' disabled="disabled"';
143
  ?>
144
  <label for="style"><?php _e( 'Edit the stylesheet for My Calendar', 'my-calendar' ); ?></label><br/><textarea <?php echo $disabled; ?> class="style-editor" id="style" name="style" rows="30" cols="80"><?php echo $my_calendar_style; ?></textarea>
145
  <?php
153
  $styles = get_option( 'mc_style_vars' );
154
  foreach ( $styles as $var => $style ) {
155
  $var_id = 'mc' . sanitize_key( $var );
156
+ if ( ! in_array( $var, array( '--primary-dark', '--primary-light', '--secondary-light', '--secondary-dark', '--highlight-dark', '--highlight-light' ), true ) ) {
157
  $delete = " <input type='checkbox' id='delete_var_$var_id' name='delete_var' value='" . esc_attr( $var ) . "' /><label for='delete_var_$var_id'>" . __( 'Delete', 'my-calendar' ) . '</label>';
158
  } else {
159
  $delete = '';
191
  )
192
  );
193
  echo '</div>';
194
+ } elseif ( trim( $left_string ) !== trim( $right_string ) ) {
195
  echo '<div class="wrap my-calendar-admin">';
196
  mc_show_notice( __( 'There have been updates to the stylesheet.', 'my-calendar' ) . ' <a href="' . admin_url( 'admin.php?page=my-calendar-styles&amp;diff#diff' ) . '">' . __( 'Compare Your Stylesheet with latest installed version of My Calendar.', 'my-calendar' ) . '</a>' );
197
  echo '</div>';
238
  $test = 'mc_custom_' . $value;
239
  $filepath = mc_get_style_path( $test );
240
  $path = pathinfo( $filepath );
241
+ if ( 'css' === $path['extension'] ) {
242
+ $selected = ( get_option( 'mc_css_file' ) === $test ) ? ' selected="selected"' : '';
243
  $options .= "<option value='mc_custom_$value'$selected>$value</option>\n";
244
  }
245
  }
250
  foreach ( $files as $value ) {
251
  $filepath = mc_get_style_path( $value );
252
  $path = pathinfo( $filepath );
253
+ if ( 'css' === $path['extension'] ) {
254
+ $selected = ( get_option( 'mc_css_file' ) === $value ) ? ' selected="selected"' : '';
255
  $options .= "<option value='$value'$selected>$value</option>\n";
256
  }
257
  }
287
  }
288
  if ( 0 === strpos( $filename, 'mc_custom_' ) ) {
289
  $filename = str_replace( 'mc_custom_', '', $filename );
290
+ $stylefile = ( 'path' === $type ) ? str_replace( '/my-calendar/', '', $dir ) . '/my-calendar-custom/styles/' . $filename : str_replace( '/my-calendar/', '', $url ) . '/my-calendar-custom/styles/' . $filename;
291
  } else {
292
+ $stylefile = ( 'path' === $type ) ? dirname( __FILE__ ) . '/styles/' . $filename : plugins_url( 'styles', __FILE__ ) . '/' . $filename;
293
  }
294
+ if ( 'path' === $type ) {
295
  if ( is_file( $stylefile ) ) {
296
  return $stylefile;
297
  } else {
369
  // Keep going until all files in directory have been read.
370
  while ( $file = readdir( $handler ) ) {
371
  // If $file isn't this directory or parent, add it to the results array.
372
+ if ( '.' !== $file && '..' !== $file ) {
373
  $results[] = $file;
374
  }
375
  }
388
  * @return boolean;
389
  */
390
  function mc_write_styles( $file, $style ) {
391
+ if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT === true ) {
392
  return false;
393
  }
394
 
397
  foreach ( $files as $f ) {
398
  $filepath = mc_get_style_path( $f );
399
  $path = pathinfo( $filepath );
400
+ if ( 'css' === $path['extension'] ) {
401
  $styles_whitelist[] = $filepath;
402
  }
403
  }
404
 
405
+ if ( in_array( $file, $styles_whitelist, true ) ) {
406
  if ( function_exists( 'wp_is_writable' ) ) {
407
  $is_writable = wp_is_writable( $file );
408
  } else {
my-calendar-templates.php CHANGED
@@ -68,7 +68,7 @@ function mc_draw_template( $array, $template, $type = 'list' ) {
68
  $before = $matches[1][ $i ];
69
  $after = $matches[2][ $i ];
70
  $format = $matches[3][ $i ];
71
- if ( '' != $format ) {
72
  $value = date_i18n( stripslashes( $format ), strtotime( stripslashes( $value ) ) );
73
  }
74
  $value = ( '' === (string) trim( $value ) ) ? '' : $before . $value . $after;
@@ -124,6 +124,9 @@ function mc_map_string( $event, $source = 'event' ) {
124
  * @return object $event
125
  */
126
  function mc_clean_location( $event, $source = 'event' ) {
 
 
 
127
  if ( 'event' === $source ) {
128
  if ( 'none' === strtolower( $event->event_city ) ) {
129
  $event->event_city = '';
@@ -182,9 +185,9 @@ function mc_maplink( $event, $request = 'map', $source = 'event' ) {
182
  if ( 'gcal' === $request ) {
183
  return $map_string;
184
  }
185
- $zoom = ( 0 != $event->event_zoom ) ? $event->event_zoom : '15';
186
  $url = $event->event_url;
187
- $map_label = strip_tags( stripslashes( ( '' != $event->event_label ) ? $event->event_label : $event->event_title ), mc_strip_tags() );
188
  $map_string = str_replace( ' ', '+', $map_string );
189
  if ( '0.000000' !== $event->event_longitude && '0.000000' !== $event->event_latitude ) {
190
  $dir_lat = ( $event->event_latitude > 0 ) ? 'N' : 'S';
@@ -195,8 +198,8 @@ function mc_maplink( $event, $request = 'map', $source = 'event' ) {
195
  }
196
  } else {
197
  $url = $event->location_url;
198
- $map_label = strip_tags( stripslashes( ( '' != $event->location_label ) ? $event->location_label : '' ), mc_strip_tags() );
199
- $zoom = ( 0 != $event->location_zoom ) ? $event->location_zoom : '15';
200
  $map_string = str_replace( ' ', '+', $map_string );
201
  if ( '0.000000' !== $event->location_longitude && '0.000000' !== $event->location_latitude ) {
202
  $dir_lat = ( $event->location_latitude > 0 ) ? 'N' : 'S';
@@ -279,32 +282,32 @@ function mc_hcard( $event, $address = 'true', $map = 'true', $source = 'event' )
279
  if ( ! $url && ! $label && ! $street && ! $street2 && ! $city && ! $state && ! $zip && ! $country && ! $phone ) {
280
  return '';
281
  }
282
- $link = ( '' != $url ) ? "<a href='$url' class='location-link external'>$label</a>" : $label;
283
  $hcard = '<div class="address location vcard" itemprop="location" itemscope itemtype="http://schema.org/Place">';
284
  if ( 'true' === $address ) {
285
  $hcard .= '<div class="adr" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
286
- $hcard .= ( '' != $label ) ? '<strong class="org fn" itemprop="name">' . $link . '</strong>' : '';
287
- $hcard .= ( '' == $street . $street2 . $city . $state . $zip . $country . $phone ) ? '' : "<div class='sub-address'>";
288
- $hcard .= ( '' != $street ) ? '<div class="street-address" itemprop="streetAddress">' . $street . '</div>' : '';
289
- $hcard .= ( '' != $street2 ) ? '<div class="street-address" itemprop="streetAddress">' . $street2 . '</div>' : '';
290
- $hcard .= ( '' != $city . $state . $zip ) ? '<div>' : '';
291
- $hcard .= ( '' != $city ) ? '<span class="locality" itemprop="addressLocality">' . $city . '</span><span class="mc-sep">, </span>' : '';
292
- $hcard .= ( '' != $state ) ? '<span class="region" itemprop="addressRegion">' . $state . '</span> ' : '';
293
- $hcard .= ( '' != $zip ) ? ' <span class="postal-code" itemprop="postalCode">' . $zip . '</span>' : '';
294
- $hcard .= ( '' != $city . $state . $zip ) ? '</div>' : '';
295
- $hcard .= ( '' != $country ) ? '<div class="country-name" itemprop="addressCountry">' . $country . '</div>' : '';
296
- $hcard .= ( '' != $phone ) ? '<div class="tel" itemprop="telephone">' . $phone . '</div>' : '';
297
  $hcard .= ( '' === $street . $street2 . $city . $state . $zip . $country . $phone ) ? '' : '</div>';
298
  $hcard .= '</div>';
299
  }
300
- if ( 'true' === $map && false != $the_map ) {
301
  $hcard .= '<meta itemprop="name" content="' . esc_attr( $label ) . '"/>';
302
  $hcard .= '<meta itemprop="address" content="' . esc_attr( mc_map_string( $event, $source ) ) . '"/>';
303
  $the_map = "<a href='$the_map' class='url external'>" . __( 'Map', 'my-calendar' ) . "<span class='screen-reader-text fn'> $label</span></a>";
304
- $hcard .= ( '' != $the_map ) ? "<div class='map'>$the_map</div>" : '';
305
  }
306
  $hcard .= '</div>';
307
- $hcard = ( ( false != $the_map && 'true' === $map ) || ( '' != $link && 'true' === $address ) ) ? $hcard : '';
308
 
309
  return apply_filters( 'mc_hcard', $hcard, $event, $address, $map, $source );
310
  }
@@ -349,7 +352,7 @@ function mc_create_tags( $event, $context = 'filters' ) {
349
  $e['time'] = ( '00:00:00' === date( 'H:i:s', strtotime( $real_begin_date ) ) ) ? $notime : date( get_option( 'mc_time_format' ), strtotime( $real_begin_date ) );
350
  $e['time24'] = ( '00:00' === date( 'G:i', strtotime( $real_begin_date ) ) ) ? $notime : date( get_option( 'mc_time_format' ), strtotime( $real_begin_date ) );
351
  $endtime = ( '23:59:59' === $event->event_end ) ? '00:00:00' : date( 'H:i:s', strtotime( $real_end_date ) );
352
- $e['endtime'] = ( $real_end_date === $real_begin_date || 1 == $event->event_hide_end || '23:59:59' === date( 'H:i:s', strtotime( $real_end_date ) ) ) ? '' : date_i18n( get_option( 'mc_time_format' ), strtotime( $endtime ) );
353
  $e['runtime'] = mc_runtime( $event->ts_occur_begin, $event->ts_occur_end, $event );
354
  $e['duration'] = mc_duration( $event );
355
  $e['dtstart'] = date( 'Y-m-d\TH:i:s', strtotime( $real_begin_date ) ); // Date: hcal formatted.
@@ -362,15 +365,15 @@ function mc_create_tags( $event, $context = 'filters' ) {
362
  'occur_end' => $real_end_date,
363
  );
364
  $date_obj = (object) $date_arr;
365
- if ( 1 == $event->event_span ) {
366
  $dates = mc_event_date_span( $event->event_group_id, $event->event_span, array( 0 => $date_obj ) );
367
  } else {
368
  $dates = array();
369
  }
370
 
371
- $e['date'] = ( 1 != $event->event_span ) ? $date : mc_format_date_span( $dates, 'simple', $date );
372
  $e['enddate'] = $date_end;
373
- $e['daterange'] = ( $date === $date_end ) ? $date : "<span class='mc_db'>$date</span> <span>&ndash;</span> <span class='mc_de'>$date_end</span>";
374
  $e['timerange'] = ( ( $e['time'] === $e['endtime'] ) || 1 == $event->event_hide_end || '23:59:59' === date( 'H:i:s', strtotime( $real_end_date ) ) ) ? $e['time'] : "<span class='mc_tb'>" . $e['time'] . "</span> <span>&ndash;</span> <span class='mc_te'>" . $e['endtime'] . '</span>';
375
  $e['datespan'] = ( 1 == $event->event_span || ( $e['date'] != $e['enddate'] ) ) ? mc_format_date_span( $dates ) : $date;
376
  $e['multidate'] = mc_format_date_span( $dates, 'complex', "<span class='fallback-date'>$date</span><span class='separator'>,</span> <span class='fallback-time'>$e[time]</span>&ndash;<span class='fallback-endtime'>$e[endtime]</span>" );
@@ -454,27 +457,30 @@ function mc_create_tags( $event, $context = 'filters' ) {
454
 
455
  // location fields.
456
  $e['location_source'] = $event->event_location;
 
457
  if ( property_exists( $event, 'location' ) ) {
458
- $location = $event->location;
459
- $map = mc_maplink( $location, 'map', 'location' );
460
- $map_url = mc_maplink( $location, 'url', 'location' );
461
- $map_gcal = mc_maplink( $location, 'gcal', 'location' );
462
- $e['location'] = stripslashes( $location->location_label );
463
- $e['street'] = stripslashes( $location->location_street );
464
- $e['street2'] = stripslashes( $location->location_street2 );
465
- $e['phone'] = apply_filters( 'mc_phone_format', stripslashes( $location->location_phone ) );
466
- $e['phone2'] = apply_filters( 'mc_phone_format', stripslashes( $location->location_phone2 ) );
467
- $e['city'] = stripslashes( $location->location_city );
468
- $e['state'] = stripslashes( $location->location_state );
469
- $e['postcode'] = stripslashes( $location->location_postcode );
470
- $e['country'] = stripslashes( $location->location_country );
471
- $e['region'] = $location->location_region;
472
- $e['hcard'] = stripslashes( mc_hcard( $location, 'true', 'true', 'location' ) );
473
- $e['link_map'] = $map;
474
- $e['map_url'] = $map_url;
475
- $e['map'] = mc_generate_map( $location, 'location' );
476
- $e['location_access'] = mc_expand( unserialize( $location->location_access ) );
477
- $e['ical_location'] = trim( $location->location_label . ' ' . $location->location_street . ' ' . $location->location_street2 . ' ' . $location->location_city . ' ' . $location->location_state . ' ' . $location->location_postcode );
 
 
478
  } else {
479
  $map = mc_maplink( $event );
480
  $map_url = mc_maplink( $event, 'url' );
@@ -568,6 +574,11 @@ function mc_get_details_link( $event ) {
568
  if ( ! is_object( $event ) ) {
569
  return;
570
  }
 
 
 
 
 
571
  $uri = mc_get_uri( $event );
572
 
573
  // If available, and not querying remotely, use permalink.
@@ -601,8 +612,13 @@ function mc_get_details_link( $event ) {
601
  );
602
  }
603
  }
 
 
 
 
 
604
 
605
- return apply_filters( 'mc_customize_details_link', $details_link, $event );
606
  }
607
 
608
  /**
@@ -913,7 +929,7 @@ function mc_expand( $data ) {
913
  }
914
  $output .= "<li class='$class'><span>$label</span></li>\n";
915
  }
916
- $output = "<ul class='mc-access'>" . $output . '</ul>';
917
  }
918
 
919
  return $output;
68
  $before = $matches[1][ $i ];
69
  $after = $matches[2][ $i ];
70
  $format = $matches[3][ $i ];
71
+ if ( '' !== $format ) {
72
  $value = date_i18n( stripslashes( $format ), strtotime( stripslashes( $value ) ) );
73
  }
74
  $value = ( '' === (string) trim( $value ) ) ? '' : $before . $value . $after;
124
  * @return object $event
125
  */
126
  function mc_clean_location( $event, $source = 'event' ) {
127
+ if ( ! is_object( $event ) ) {
128
+ return $event;
129
+ }
130
  if ( 'event' === $source ) {
131
  if ( 'none' === strtolower( $event->event_city ) ) {
132
  $event->event_city = '';
185
  if ( 'gcal' === $request ) {
186
  return $map_string;
187
  }
188
+ $zoom = ( '0' !== $event->event_zoom ) ? $event->event_zoom : '15';
189
  $url = $event->event_url;
190
+ $map_label = strip_tags( stripslashes( ( '' !== trim( $event->event_label ) ) ? $event->event_label : $event->event_title ), mc_strip_tags() );
191
  $map_string = str_replace( ' ', '+', $map_string );
192
  if ( '0.000000' !== $event->event_longitude && '0.000000' !== $event->event_latitude ) {
193
  $dir_lat = ( $event->event_latitude > 0 ) ? 'N' : 'S';
198
  }
199
  } else {
200
  $url = $event->location_url;
201
+ $map_label = strip_tags( stripslashes( ( '' !== trim( $event->location_label ) ) ? $event->location_label : '' ), mc_strip_tags() );
202
+ $zoom = ( '0' !== $event->location_zoom ) ? $event->location_zoom : '15';
203
  $map_string = str_replace( ' ', '+', $map_string );
204
  if ( '0.000000' !== $event->location_longitude && '0.000000' !== $event->location_latitude ) {
205
  $dir_lat = ( $event->location_latitude > 0 ) ? 'N' : 'S';
282
  if ( ! $url && ! $label && ! $street && ! $street2 && ! $city && ! $state && ! $zip && ! $country && ! $phone ) {
283
  return '';
284
  }
285
+ $link = ( '' !== $url ) ? "<a href='$url' class='location-link external'>$label</a>" : $label;
286
  $hcard = '<div class="address location vcard" itemprop="location" itemscope itemtype="http://schema.org/Place">';
287
  if ( 'true' === $address ) {
288
  $hcard .= '<div class="adr" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
289
+ $hcard .= ( '' !== $label ) ? '<strong class="org fn" itemprop="name">' . $link . '</strong>' : '';
290
+ $hcard .= ( '' === $street . $street2 . $city . $state . $zip . $country . $phone ) ? '' : "<div class='sub-address'>";
291
+ $hcard .= ( '' !== $street ) ? '<div class="street-address" itemprop="streetAddress">' . $street . '</div>' : '';
292
+ $hcard .= ( '' !== $street2 ) ? '<div class="street-address" itemprop="streetAddress">' . $street2 . '</div>' : '';
293
+ $hcard .= ( '' !== $city . $state . $zip ) ? '<div>' : '';
294
+ $hcard .= ( '' !== $city ) ? '<span class="locality" itemprop="addressLocality">' . $city . '</span><span class="mc-sep">, </span>' : '';
295
+ $hcard .= ( '' !== $state ) ? '<span class="region" itemprop="addressRegion">' . $state . '</span> ' : '';
296
+ $hcard .= ( '' !== $zip ) ? ' <span class="postal-code" itemprop="postalCode">' . $zip . '</span>' : '';
297
+ $hcard .= ( '' !== $city . $state . $zip ) ? '</div>' : '';
298
+ $hcard .= ( '' !== $country ) ? '<div class="country-name" itemprop="addressCountry">' . $country . '</div>' : '';
299
+ $hcard .= ( '' !== $phone ) ? '<div class="tel" itemprop="telephone">' . $phone . '</div>' : '';
300
  $hcard .= ( '' === $street . $street2 . $city . $state . $zip . $country . $phone ) ? '' : '</div>';
301
  $hcard .= '</div>';
302
  }
303
+ if ( 'true' === $map && false !== $the_map ) {
304
  $hcard .= '<meta itemprop="name" content="' . esc_attr( $label ) . '"/>';
305
  $hcard .= '<meta itemprop="address" content="' . esc_attr( mc_map_string( $event, $source ) ) . '"/>';
306
  $the_map = "<a href='$the_map' class='url external'>" . __( 'Map', 'my-calendar' ) . "<span class='screen-reader-text fn'> $label</span></a>";
307
+ $hcard .= ( '' !== $the_map ) ? "<div class='map'>$the_map</div>" : '';
308
  }
309
  $hcard .= '</div>';
310
+ $hcard = ( ( false !== $the_map && 'true' === $map ) || ( '' !== $link && 'true' === $address ) ) ? $hcard : '';
311
 
312
  return apply_filters( 'mc_hcard', $hcard, $event, $address, $map, $source );
313
  }
352
  $e['time'] = ( '00:00:00' === date( 'H:i:s', strtotime( $real_begin_date ) ) ) ? $notime : date( get_option( 'mc_time_format' ), strtotime( $real_begin_date ) );
353
  $e['time24'] = ( '00:00' === date( 'G:i', strtotime( $real_begin_date ) ) ) ? $notime : date( get_option( 'mc_time_format' ), strtotime( $real_begin_date ) );
354
  $endtime = ( '23:59:59' === $event->event_end ) ? '00:00:00' : date( 'H:i:s', strtotime( $real_end_date ) );
355
+ $e['endtime'] = ( $real_end_date === $real_begin_date || '1' === $event->event_hide_end || '23:59:59' === date( 'H:i:s', strtotime( $real_end_date ) ) ) ? '' : date_i18n( get_option( 'mc_time_format' ), strtotime( $endtime ) );
356
  $e['runtime'] = mc_runtime( $event->ts_occur_begin, $event->ts_occur_end, $event );
357
  $e['duration'] = mc_duration( $event );
358
  $e['dtstart'] = date( 'Y-m-d\TH:i:s', strtotime( $real_begin_date ) ); // Date: hcal formatted.
365
  'occur_end' => $real_end_date,
366
  );
367
  $date_obj = (object) $date_arr;
368
+ if ( '1' === $event->event_span ) {
369
  $dates = mc_event_date_span( $event->event_group_id, $event->event_span, array( 0 => $date_obj ) );
370
  } else {
371
  $dates = array();
372
  }
373
 
374
+ $e['date'] = ( '1' !== $event->event_span ) ? $date : mc_format_date_span( $dates, 'simple', $date );
375
  $e['enddate'] = $date_end;
376
+ $e['daterange'] = ( $date === $date_end ) ? "<span class='mc_db'>$date</span>" : "<span class='mc_db'>$date</span> <span>&ndash;</span> <span class='mc_de'>$date_end</span>";
377
  $e['timerange'] = ( ( $e['time'] === $e['endtime'] ) || 1 == $event->event_hide_end || '23:59:59' === date( 'H:i:s', strtotime( $real_end_date ) ) ) ? $e['time'] : "<span class='mc_tb'>" . $e['time'] . "</span> <span>&ndash;</span> <span class='mc_te'>" . $e['endtime'] . '</span>';
378
  $e['datespan'] = ( 1 == $event->event_span || ( $e['date'] != $e['enddate'] ) ) ? mc_format_date_span( $dates ) : $date;
379
  $e['multidate'] = mc_format_date_span( $dates, 'complex', "<span class='fallback-date'>$date</span><span class='separator'>,</span> <span class='fallback-time'>$e[time]</span>&ndash;<span class='fallback-endtime'>$e[endtime]</span>" );
457
 
458
  // location fields.
459
  $e['location_source'] = $event->event_location;
460
+ $map_gcal = '';
461
  if ( property_exists( $event, 'location' ) ) {
462
+ $location = $event->location;
463
+ if ( is_object( $location ) ) {
464
+ $map = mc_maplink( $location, 'map', 'location' );
465
+ $map_url = mc_maplink( $location, 'url', 'location' );
466
+ $map_gcal = mc_maplink( $location, 'gcal', 'location' );
467
+ $e['location'] = stripslashes( $location->location_label );
468
+ $e['street'] = stripslashes( $location->location_street );
469
+ $e['street2'] = stripslashes( $location->location_street2 );
470
+ $e['phone'] = apply_filters( 'mc_phone_format', stripslashes( $location->location_phone ) );
471
+ $e['phone2'] = apply_filters( 'mc_phone_format', stripslashes( $location->location_phone2 ) );
472
+ $e['city'] = stripslashes( $location->location_city );
473
+ $e['state'] = stripslashes( $location->location_state );
474
+ $e['postcode'] = stripslashes( $location->location_postcode );
475
+ $e['country'] = stripslashes( $location->location_country );
476
+ $e['region'] = $location->location_region;
477
+ $e['hcard'] = stripslashes( mc_hcard( $location, 'true', 'true', 'location' ) );
478
+ $e['link_map'] = $map;
479
+ $e['map_url'] = $map_url;
480
+ $e['map'] = mc_generate_map( $location, 'location' );
481
+ $e['location_access'] = mc_expand( unserialize( $location->location_access ) );
482
+ $e['ical_location'] = trim( $location->location_label . ' ' . $location->location_street . ' ' . $location->location_street2 . ' ' . $location->location_city . ' ' . $location->location_state . ' ' . $location->location_postcode );
483
+ }
484
  } else {
485
  $map = mc_maplink( $event );
486
  $map_url = mc_maplink( $event, 'url' );
574
  if ( ! is_object( $event ) ) {
575
  return;
576
  }
577
+ $restore = false;
578
+ if ( is_multisite() && property_exists( $event, 'site_id' ) && get_current_blog_id() !== $event->site_id ) {
579
+ switch_to_blog( $event->site_id );
580
+ $restore = true;
581
+ }
582
  $uri = mc_get_uri( $event );
583
 
584
  // If available, and not querying remotely, use permalink.
612
  );
613
  }
614
  }
615
+ $details_link = apply_filters( 'mc_customize_details_link', $details_link, $event );
616
+
617
+ if ( $restore ) {
618
+ restore_current_blog();
619
+ }
620
 
621
+ return $details_link;
622
  }
623
 
624
  /**
929
  }
930
  $output .= "<li class='$class'><span>$label</span></li>\n";
931
  }
932
+ $output = ( $output ) ? "<ul class='mc-access'>" . $output . '</ul>' : '';
933
  }
934
 
935
  return $output;
my-calendar-templating.php CHANGED
@@ -41,7 +41,7 @@ function mc_templates_edit() {
41
  mc_show_notice( __( 'Custom templates cannot have the same key as a core template', 'my-calendar' ) );
42
  } else {
43
  if ( mc_is_core_template( $key ) && isset( $_POST['mc_template'] ) ) {
44
- $template = $_POST['mc_template'];
45
  $templates[ $key ] = $template;
46
  update_option( 'mc_templates', $templates );
47
  update_option( 'mc_use_' . $key . '_template', ( empty( $_POST['mc_use_template'] ) ? 0 : 1 ) );
@@ -60,11 +60,11 @@ function mc_templates_edit() {
60
  }
61
 
62
  $globals = mc_globals();
63
- $mc_grid_template = ( '' != $templates['grid'] ) ? $templates['grid'] : $globals['grid_template'];
64
- $mc_rss_template = ( '' != $templates['rss'] ) ? $templates['rss'] : $globals['rss_template'];
65
- $mc_list_template = ( '' != $templates['list'] ) ? $templates['list'] : $globals['list_template'];
66
- $mc_mini_template = ( '' != $templates['mini'] ) ? $templates['mini'] : $globals['mini_template'];
67
- $mc_details_template = ( '' != $templates['details'] ) ? $templates['details'] : $globals['single_template'];
68
 
69
  $template = ( mc_is_core_template( $key ) ) ? ${'mc_' . $key . '_template'} : mc_get_custom_template( $key );
70
  $template = stripslashes( $template );
@@ -83,9 +83,9 @@ function mc_templates_edit() {
83
  <p>
84
  <a href="<?php echo admin_url( 'admin.php?page=my-calendar-help#templates' ); ?>"><?php _e( 'Templates Help', 'my-calendar' ); ?></a> &raquo;
85
  </p>
86
- <?php echo ( '' != $core ) ? "<p class='template-description'>$core</p>" : ''; ?>
87
  <?php
88
- if ( 'add-new' == $key ) {
89
  ?>
90
  <form method="post" action="<?php echo add_query_arg( 'mc_template', $key, admin_url( 'admin.php?page=my-calendar-templates' ) ); ?>">
91
  <div>
@@ -303,11 +303,11 @@ function mc_get_custom_template( $key ) {
303
  */
304
  function mc_key_exists( $key ) {
305
  // Keys are md5 hashed, so should always be 32 chars.
306
- if ( 32 != strlen( $key ) ) {
307
  return false;
308
  }
309
 
310
- if ( 'missing' != get_option( "mc_ctemplate_$key", 'missing' ) ) {
311
  return true;
312
  }
313
 
@@ -353,7 +353,7 @@ function mc_update_template( $key, $template ) {
353
  * @return Description
354
  */
355
  function mc_template_description( $key ) {
356
- if ( 'add-new' == $key ) {
357
  return '';
358
  }
359
 
@@ -382,7 +382,7 @@ function mc_template_description( $key ) {
382
  $description = strip_tags( stripslashes( get_option( "mc_template_desc_$key" ) ) );
383
  }
384
 
385
- $br = ( '' != $description ) ? '<br />' : '';
386
 
387
  return $description . $br . $return;
388
  }
@@ -393,11 +393,11 @@ function mc_template_description( $key ) {
393
  function mc_list_templates() {
394
  $check = "<span class='dashicons dashicons-yes' aria-hidden='true'></span><span>" . __( 'Enabled', 'my-calendar' ) . '</span>';
395
  $uncheck = "<span class='dashicons dashicons-no' aria-hidden='true'></span><span>" . __( 'Not Enabled', 'my-calendar' ) . '</span>';
396
- $grid_enabled = ( get_option( 'mc_use_grid_template' ) == 1 ) ? $check : $uncheck;
397
- $list_enabled = ( get_option( 'mc_use_list_template' ) == 1 ) ? $check : $uncheck;
398
- $mini_enabled = ( get_option( 'mc_use_mini_template' ) == 1 ) ? $check : $uncheck;
399
- $details_enabled = ( get_option( 'mc_use_details_template' ) == 1 ) ? $check : $uncheck;
400
- $rss_enabled = ( get_option( 'mc_use_rss_template' ) == 1 ) ? $check : $uncheck;
401
 
402
  $list = "<table class='widefat'>
403
  <thead>
41
  mc_show_notice( __( 'Custom templates cannot have the same key as a core template', 'my-calendar' ) );
42
  } else {
43
  if ( mc_is_core_template( $key ) && isset( $_POST['mc_template'] ) ) {
44
+ $template = ( ! empty( $_POST['mc_template'] ) ) ? $_POST['mc_template'] : '';
45
  $templates[ $key ] = $template;
46
  update_option( 'mc_templates', $templates );
47
  update_option( 'mc_use_' . $key . '_template', ( empty( $_POST['mc_use_template'] ) ? 0 : 1 ) );
60
  }
61
 
62
  $globals = mc_globals();
63
+ $mc_grid_template = ( '' !== trim( $templates['grid'] ) ) ? $templates['grid'] : $globals['grid_template'];
64
+ $mc_rss_template = ( '' !== trim( $templates['rss'] ) ) ? $templates['rss'] : $globals['rss_template'];
65
+ $mc_list_template = ( '' !== trim( $templates['list'] ) ) ? $templates['list'] : $globals['list_template'];
66
+ $mc_mini_template = ( '' !== trim( $templates['mini'] ) ) ? $templates['mini'] : $globals['mini_template'];
67
+ $mc_details_template = ( '' !== trim( $templates['details'] ) ) ? $templates['details'] : $globals['single_template'];
68
 
69
  $template = ( mc_is_core_template( $key ) ) ? ${'mc_' . $key . '_template'} : mc_get_custom_template( $key );
70
  $template = stripslashes( $template );
83
  <p>
84
  <a href="<?php echo admin_url( 'admin.php?page=my-calendar-help#templates' ); ?>"><?php _e( 'Templates Help', 'my-calendar' ); ?></a> &raquo;
85
  </p>
86
+ <?php echo ( '' !== $core ) ? "<p class='template-description'>$core</p>" : ''; ?>
87
  <?php
88
+ if ( 'add-new' === $key ) {
89
  ?>
90
  <form method="post" action="<?php echo add_query_arg( 'mc_template', $key, admin_url( 'admin.php?page=my-calendar-templates' ) ); ?>">
91
  <div>
303
  */
304
  function mc_key_exists( $key ) {
305
  // Keys are md5 hashed, so should always be 32 chars.
306
+ if ( 32 !== strlen( $key ) ) {
307
  return false;
308
  }
309
 
310
+ if ( 'missing' !== get_option( "mc_ctemplate_$key", 'missing' ) ) {
311
  return true;
312
  }
313
 
353
  * @return Description
354
  */
355
  function mc_template_description( $key ) {
356
+ if ( 'add-new' === $key ) {
357
  return '';
358
  }
359
 
382
  $description = strip_tags( stripslashes( get_option( "mc_template_desc_$key" ) ) );
383
  }
384
 
385
+ $br = ( '' !== $description ) ? '<br />' : '';
386
 
387
  return $description . $br . $return;
388
  }
393
  function mc_list_templates() {
394
  $check = "<span class='dashicons dashicons-yes' aria-hidden='true'></span><span>" . __( 'Enabled', 'my-calendar' ) . '</span>';
395
  $uncheck = "<span class='dashicons dashicons-no' aria-hidden='true'></span><span>" . __( 'Not Enabled', 'my-calendar' ) . '</span>';
396
+ $grid_enabled = ( get_option( 'mc_use_grid_template' ) === '1' ) ? $check : $uncheck;
397
+ $list_enabled = ( get_option( 'mc_use_list_template' ) === '1' ) ? $check : $uncheck;
398
+ $mini_enabled = ( get_option( 'mc_use_mini_template' ) === '1' ) ? $check : $uncheck;
399
+ $details_enabled = ( get_option( 'mc_use_details_template' ) === '1' ) ? $check : $uncheck;
400
+ $rss_enabled = ( get_option( 'mc_use_rss_template' ) === '1' ) ? $check : $uncheck;
401
 
402
  $list = "<table class='widefat'>
403
  <thead>
my-calendar-widgets.php CHANGED
@@ -53,19 +53,19 @@ function my_calendar_upcoming_events( $args ) {
53
  $output = '';
54
  $defaults = mc_widget_defaults();
55
  $display_type = ( 'default' === $type ) ? $defaults['upcoming']['type'] : $type;
56
- $display_type = ( '' == $display_type ) ? 'events' : $display_type;
57
 
58
  // Get number of units we should go into the future.
59
  $after = ( 'default' === $after ) ? $defaults['upcoming']['after'] : $after;
60
- $after = ( '' == $after ) ? 10 : $after;
61
 
62
  // Get number of units we should go into the past.
63
  $before = ( 'default' === $before ) ? $defaults['upcoming']['before'] : $before;
64
- $before = ( '' == $before ) ? 0 : $before;
65
  $category = ( 'default' === $category ) ? '' : $category;
66
 
67
  // allow reference by file to external template.
68
- if ( '' != $template && mc_file_exists( $template ) ) {
69
  $template = file_get_contents( mc_get_file( $template ) );
70
  }
71
 
@@ -75,7 +75,7 @@ function my_calendar_upcoming_events( $args ) {
75
  }
76
 
77
  $template = apply_filters( 'mc_upcoming_events_template', $template );
78
- $no_event_text = ( '' == $substitute ) ? $defaults['upcoming']['text'] : $substitute;
79
  $header = "<ul id='upcoming-events-$hash' class='upcoming-events'>";
80
  $footer = '</ul>';
81
  $display_events = ( 'events' === $display_type || 'event' === $display_type ) ? true : false;
@@ -89,7 +89,7 @@ function my_calendar_upcoming_events( $args ) {
89
  $from = date( 'Y-m-1' );
90
  $to = date( 'Y-m-t' );
91
  }
92
- if ( 'custom' === $display_type && '' != $from && '' != $to ) {
93
  $from = date( 'Y-m-d', strtotime( $from ) );
94
  $to = ( 'today' === $to ) ? date( 'Y-m-d', current_time( 'timestamp' ) ) : date( 'Y-m-d', strtotime( $to ) );
95
  }
@@ -164,7 +164,7 @@ function my_calendar_upcoming_events( $args ) {
164
  $query = apply_filters( 'mc_upcoming_attributes', $query, $args );
165
  $event_array = my_calendar_events( $query );
166
 
167
- if ( 0 != count( $event_array ) ) {
168
  foreach ( $event_array as $key => $value ) {
169
  if ( is_array( $value ) ) {
170
  foreach ( $value as $k => $v ) {
@@ -185,10 +185,10 @@ function my_calendar_upcoming_events( $args ) {
185
  foreach ( reverse_array( $temp_array, true, $order ) as $event ) {
186
  $details = mc_create_tags( $event );
187
  $item = apply_filters( 'mc_draw_upcoming_event', '', $details, $template, $args );
188
- if ( '' == $item ) {
189
  $item = mc_draw_template( $details, $template );
190
  }
191
- if ( $i < $skip && 0 != $skip ) {
192
  $i ++;
193
  } else {
194
  $today = date( 'Y-m-d H:i', current_time( 'timestamp' ) );
@@ -200,9 +200,9 @@ function my_calendar_upcoming_events( $args ) {
200
  $prepend = apply_filters( 'mc_event_upcoming_before', "<li class='$class $category $classes'>", $class, $category );
201
  $append = apply_filters( 'mc_event_upcoming_after', '</li>', $class, $category );
202
  // If same group, and same date, use it.
203
- if ( ( $details['group'] !== $last_id || $details['date'] == $last_date ) || '0' == $details['group'] ) {
204
- if ( ! in_array( $details['dateid'], $skips ) ) {
205
- $output .= ( $item == $last_item ) ? '' : $prepend . $item . $append;
206
  }
207
  }
208
  }
@@ -323,13 +323,13 @@ function mc_produce_upcoming_events( $events, $template, $type = 'list', $order
323
  $beginning = $e->occur_begin;
324
  $end = $e->occur_end;
325
  // Store span time in an array to avoid repeating database query.
326
- if ( 1 == $e->event_span && ( ! isset( $spans[ $e->occur_group_id ] ) ) ) {
327
  // This is a multi-day event: treat each event as if it spanned the entire range of the group.
328
  $span_time = mc_span_time( $e->occur_group_id );
329
  $beginning = $span_time[0];
330
  $end = $span_time[1];
331
  $spans[ $e->occur_group_id ] = $span_time;
332
- } elseif ( 1 == $e->event_span && ( isset( $spans[ $e->occur_group_id ] ) ) ) {
333
  $span_time = $spans[ $e->occur_group_id ];
334
  $beginning = $span_time[0];
335
  $end = $span_time[1];
@@ -337,7 +337,7 @@ function mc_produce_upcoming_events( $events, $template, $type = 'list', $order
337
  $current = date( 'Y-m-d H:i:00', current_time( 'timestamp' ) );
338
  if ( $e ) {
339
  // If a multi-day event, show only once.
340
- if ( 0 != $e->occur_group_id && 1 == $e->event_span && in_array( $e->occur_group_id, $group ) || in_array( $e->occur_id, $occur ) ) {
341
  $md = true;
342
  } else {
343
  $group[] = $e->occur_group_id;
@@ -347,11 +347,11 @@ function mc_produce_upcoming_events( $events, $template, $type = 'list', $order
347
  // end multi-day reduction.
348
  if ( ! $md ) {
349
  // check if this event instance or this event group has already been displayed.
350
- $same_event = ( in_array( $e->occur_id, $last_events ) ) ? true : false;
351
- $same_group = ( in_array( $e->occur_group_id, $last_group ) ) ? true : false;
352
- if ( 'yes' == $show_today && my_calendar_date_equal( $beginning, $current ) ) {
353
  $in_total = apply_filters( 'mc_include_today_in_total', 'yes' ); // count todays events in total.
354
- if ( 'no' != $in_total ) {
355
  $near_events[] = $e;
356
  if ( $before > $after ) {
357
  $future ++;
@@ -372,7 +372,7 @@ function mc_produce_upcoming_events( $events, $template, $type = 'list', $order
372
  if ( my_calendar_date_comp( $beginning, $current ) ) {
373
  $past ++;
374
  } elseif ( my_calendar_date_equal( $beginning, $current ) ) {
375
- if ( 'yes' == $show_today ) {
376
  $extra ++;
377
  }
378
  } elseif ( ! my_calendar_date_comp( $end, $current ) ) {
@@ -383,7 +383,7 @@ function mc_produce_upcoming_events( $events, $template, $type = 'list', $order
383
  $last_group[] = $e->occur_group_id;
384
  $last_date = $beginning;
385
  }
386
- if ( $past > $before && $future > $after && 'yes' != $show_today ) {
387
  break;
388
  }
389
  }
@@ -407,7 +407,7 @@ function mc_produce_upcoming_events( $events, $template, $type = 'list', $order
407
 
408
  foreach ( reverse_array( $temp_array, true, $order ) as $event ) {
409
  $details = mc_create_tags( $event, $context );
410
- if ( ! in_array( $details['group'], $groups ) ) {
411
  $date = date( 'Y-m-d H:i:s', strtotime( $details['dtstart'] ) );
412
  $class = ( true === my_calendar_date_comp( $date, $today . ' ' . date( 'H:i', current_time( 'timestamp' ) ) ) ) ? 'past-event' : 'future-event';
413
  $category = mc_category_class( $details, 'mc_' );
@@ -416,7 +416,7 @@ function mc_produce_upcoming_events( $events, $template, $type = 'list', $order
416
  if ( my_calendar_date_equal( $date, $today ) ) {
417
  $class = 'today';
418
  }
419
- if ( 1 == $details['event_span'] ) {
420
  $class = 'multiday';
421
  }
422
  if ( 'list' === $type ) {
@@ -429,10 +429,10 @@ function mc_produce_upcoming_events( $events, $template, $type = 'list', $order
429
  $prepend = apply_filters( 'mc_event_upcoming_before', $prepend, $class, $category, $date );
430
  $append = apply_filters( 'mc_event_upcoming_after', $append, $class, $category, $date );
431
 
432
- if ( $i < $skip && 0 != $skip ) {
433
  $i ++;
434
  } else {
435
- if ( ! in_array( $details['dateid'], $skips ) ) {
436
 
437
  $item = apply_filters( 'mc_draw_upcoming_event', '', $details, $template, $type );
438
  if ( '' === $item ) {
@@ -443,7 +443,7 @@ function mc_produce_upcoming_events( $events, $template, $type = 'list', $order
443
  $skips[] = $details['dateid'];
444
  }
445
  }
446
- if ( 1 == $details['event_span'] ) {
447
  $groups[] = $details['group'];
448
  }
449
  }
@@ -498,7 +498,7 @@ function my_calendar_todays_events( $args ) {
498
  $output = '';
499
 
500
  // allow reference by file to external template.
501
- if ( '' != $template && mc_file_exists( $template ) ) {
502
  $template = file_get_contents( mc_get_file( $template ) );
503
  }
504
  $defaults = mc_widget_defaults();
@@ -509,7 +509,7 @@ function my_calendar_todays_events( $args ) {
509
  }
510
 
511
  $category = ( 'default' === $category ) ? $defaults['today']['category'] : $category;
512
- $no_event_text = ( '' == $substitute ) ? $defaults['today']['text'] : $substitute;
513
  if ( $date ) {
514
  $from = date( 'Y-m-d', strtotime( $date ) );
515
  $to = date( 'Y-m-d', strtotime( $date ) );
@@ -541,7 +541,7 @@ function my_calendar_todays_events( $args ) {
541
  // quick loop through all events today to check for holidays.
542
  if ( is_array( $today ) ) {
543
  foreach ( $today as $e ) {
544
- if ( ! mc_private_event( $e ) && ! in_array( $e->event_group_id, $groups ) ) {
545
  $event_details = mc_create_tags( $e );
546
  $ts = strtotime( get_date_from_gmt( date( 'Y-m-d H:i:s', $e->ts_occur_begin ) ) );
547
  $end = strtotime( get_date_from_gmt( date( 'Y-m-d H:i:s', $e->ts_occur_end ) ) );
@@ -571,7 +571,7 @@ function my_calendar_todays_events( $args ) {
571
  $output .= $now;
572
  }
573
  }
574
- if ( 0 != count( $events ) ) {
575
  $return = apply_filters( 'mc_todays_events_header', $header ) . $output . apply_filters( 'mc_todays_events_footer', $footer );
576
  } else {
577
  $return = stripcslashes( $no_event_text );
53
  $output = '';
54
  $defaults = mc_widget_defaults();
55
  $display_type = ( 'default' === $type ) ? $defaults['upcoming']['type'] : $type;
56
+ $display_type = ( '' === $display_type ) ? 'events' : $display_type;
57
 
58
  // Get number of units we should go into the future.
59
  $after = ( 'default' === $after ) ? $defaults['upcoming']['after'] : $after;
60
+ $after = ( '' === $after ) ? 10 : $after;
61
 
62
  // Get number of units we should go into the past.
63
  $before = ( 'default' === $before ) ? $defaults['upcoming']['before'] : $before;
64
+ $before = ( '' === $before ) ? 0 : $before;
65
  $category = ( 'default' === $category ) ? '' : $category;
66
 
67
  // allow reference by file to external template.
68
+ if ( '' !== $template && mc_file_exists( $template ) ) {
69
  $template = file_get_contents( mc_get_file( $template ) );
70
  }
71
 
75
  }
76
 
77
  $template = apply_filters( 'mc_upcoming_events_template', $template );
78
+ $no_event_text = ( '' === $substitute ) ? $defaults['upcoming']['text'] : $substitute;
79
  $header = "<ul id='upcoming-events-$hash' class='upcoming-events'>";
80
  $footer = '</ul>';
81
  $display_events = ( 'events' === $display_type || 'event' === $display_type ) ? true : false;
89
  $from = date( 'Y-m-1' );
90
  $to = date( 'Y-m-t' );
91
  }
92
+ if ( 'custom' === $display_type && '' !== $from && '' !== $to ) {
93
  $from = date( 'Y-m-d', strtotime( $from ) );
94
  $to = ( 'today' === $to ) ? date( 'Y-m-d', current_time( 'timestamp' ) ) : date( 'Y-m-d', strtotime( $to ) );
95
  }
164
  $query = apply_filters( 'mc_upcoming_attributes', $query, $args );
165
  $event_array = my_calendar_events( $query );
166
 
167
+ if ( 0 !== count( $event_array ) ) {
168
  foreach ( $event_array as $key => $value ) {
169
  if ( is_array( $value ) ) {
170
  foreach ( $value as $k => $v ) {
185
  foreach ( reverse_array( $temp_array, true, $order ) as $event ) {
186
  $details = mc_create_tags( $event );
187
  $item = apply_filters( 'mc_draw_upcoming_event', '', $details, $template, $args );
188
+ if ( '' === $item ) {
189
  $item = mc_draw_template( $details, $template );
190
  }
191
+ if ( $i < $skip && 0 !== $skip ) {
192
  $i ++;
193
  } else {
194
  $today = date( 'Y-m-d H:i', current_time( 'timestamp' ) );
200
  $prepend = apply_filters( 'mc_event_upcoming_before', "<li class='$class $category $classes'>", $class, $category );
201
  $append = apply_filters( 'mc_event_upcoming_after', '</li>', $class, $category );
202
  // If same group, and same date, use it.
203
+ if ( ( $details['group'] !== $last_id || $details['date'] === $last_date ) || '0' === $details['group'] ) {
204
+ if ( ! in_array( $details['dateid'], $skips, true ) ) {
205
+ $output .= ( $item === $last_item ) ? '' : $prepend . $item . $append;
206
  }
207
  }
208
  }
323
  $beginning = $e->occur_begin;
324
  $end = $e->occur_end;
325
  // Store span time in an array to avoid repeating database query.
326
+ if ( '1' === $e->event_span && ( ! isset( $spans[ $e->occur_group_id ] ) ) ) {
327
  // This is a multi-day event: treat each event as if it spanned the entire range of the group.
328
  $span_time = mc_span_time( $e->occur_group_id );
329
  $beginning = $span_time[0];
330
  $end = $span_time[1];
331
  $spans[ $e->occur_group_id ] = $span_time;
332
+ } elseif ( '1' === $e->event_span && ( isset( $spans[ $e->occur_group_id ] ) ) ) {
333
  $span_time = $spans[ $e->occur_group_id ];
334
  $beginning = $span_time[0];
335
  $end = $span_time[1];
337
  $current = date( 'Y-m-d H:i:00', current_time( 'timestamp' ) );
338
  if ( $e ) {
339
  // If a multi-day event, show only once.
340
+ if ( '0' !== $e->occur_group_id && '1' === $e->event_span && in_array( $e->occur_group_id, $group, true ) || in_array( $e->occur_id, $occur, true ) ) {
341
  $md = true;
342
  } else {
343
  $group[] = $e->occur_group_id;
347
  // end multi-day reduction.
348
  if ( ! $md ) {
349
  // check if this event instance or this event group has already been displayed.
350
+ $same_event = ( in_array( $e->occur_id, $last_events, true ) ) ? true : false;
351
+ $same_group = ( in_array( $e->occur_group_id, $last_group, true ) ) ? true : false;
352
+ if ( 'yes' === $show_today && my_calendar_date_equal( $beginning, $current ) ) {
353
  $in_total = apply_filters( 'mc_include_today_in_total', 'yes' ); // count todays events in total.
354
+ if ( 'no' !== $in_total ) {
355
  $near_events[] = $e;
356
  if ( $before > $after ) {
357
  $future ++;
372
  if ( my_calendar_date_comp( $beginning, $current ) ) {
373
  $past ++;
374
  } elseif ( my_calendar_date_equal( $beginning, $current ) ) {
375
+ if ( 'yes' === $show_today ) {
376
  $extra ++;
377
  }
378
  } elseif ( ! my_calendar_date_comp( $end, $current ) ) {
383
  $last_group[] = $e->occur_group_id;
384
  $last_date = $beginning;
385
  }
386
+ if ( $past > $before && $future > $after && 'yes' !== $show_today ) {
387
  break;
388
  }
389
  }
407
 
408
  foreach ( reverse_array( $temp_array, true, $order ) as $event ) {
409
  $details = mc_create_tags( $event, $context );
410
+ if ( ! in_array( $details['group'], $groups, true ) ) {
411
  $date = date( 'Y-m-d H:i:s', strtotime( $details['dtstart'] ) );
412
  $class = ( true === my_calendar_date_comp( $date, $today . ' ' . date( 'H:i', current_time( 'timestamp' ) ) ) ) ? 'past-event' : 'future-event';
413
  $category = mc_category_class( $details, 'mc_' );
416
  if ( my_calendar_date_equal( $date, $today ) ) {
417
  $class = 'today';
418
  }
419
+ if ( '1' === $details['event_span'] ) {
420
  $class = 'multiday';
421
  }
422
  if ( 'list' === $type ) {
429
  $prepend = apply_filters( 'mc_event_upcoming_before', $prepend, $class, $category, $date );
430
  $append = apply_filters( 'mc_event_upcoming_after', $append, $class, $category, $date );
431
 
432
+ if ( $i < $skip && 0 !== $skip ) {
433
  $i ++;
434
  } else {
435
+ if ( ! in_array( $details['dateid'], $skips, true ) ) {
436
 
437
  $item = apply_filters( 'mc_draw_upcoming_event', '', $details, $template, $type );
438
  if ( '' === $item ) {
443
  $skips[] = $details['dateid'];
444
  }
445
  }
446
+ if ( '1' === $details['event_span'] ) {
447
  $groups[] = $details['group'];
448
  }
449
  }
498
  $output = '';
499
 
500
  // allow reference by file to external template.
501
+ if ( '' !== $template && mc_file_exists( $template ) ) {
502
  $template = file_get_contents( mc_get_file( $template ) );
503
  }
504
  $defaults = mc_widget_defaults();
509
  }
510
 
511
  $category = ( 'default' === $category ) ? $defaults['today']['category'] : $category;
512
+ $no_event_text = ( '' === $substitute ) ? $defaults['today']['text'] : $substitute;
513
  if ( $date ) {
514
  $from = date( 'Y-m-d', strtotime( $date ) );
515
  $to = date( 'Y-m-d', strtotime( $date ) );
541
  // quick loop through all events today to check for holidays.
542
  if ( is_array( $today ) ) {
543
  foreach ( $today as $e ) {
544
+ if ( ! mc_private_event( $e ) && ! in_array( $e->event_group_id, $groups, true ) ) {
545
  $event_details = mc_create_tags( $e );
546
  $ts = strtotime( get_date_from_gmt( date( 'Y-m-d H:i:s', $e->ts_occur_begin ) ) );
547
  $end = strtotime( get_date_from_gmt( date( 'Y-m-d H:i:s', $e->ts_occur_end ) ) );
571
  $output .= $now;
572
  }
573
  }
574
+ if ( 0 !== count( $events ) ) {
575
  $return = apply_filters( 'mc_todays_events_header', $header ) . $output . apply_filters( 'mc_todays_events_footer', $footer );
576
  } else {
577
  $return = stripcslashes( $no_event_text );
my-calendar.php CHANGED
@@ -17,7 +17,7 @@
17
  * License: GPL-2.0+
18
  * License URI: http://www.gnu.org/license/gpl-2.0.txt
19
  * Domain Path: lang
20
- * Version: 3.1.13
21
  */
22
 
23
  /*
@@ -42,7 +42,7 @@ if ( ! defined( 'ABSPATH' ) ) {
42
  }
43
 
44
  global $mc_version, $wpdb;
45
- $mc_version = '3.1.13';
46
 
47
  define( 'MC_DEBUG', false );
48
 
@@ -423,3 +423,4 @@ add_shortcode( 'my_calendar_show_locations', 'my_calendar_show_locations_list' )
423
  add_shortcode( 'my_calendar_event', 'my_calendar_show_event' );
424
  add_shortcode( 'my_calendar_search', 'my_calendar_search' );
425
  add_shortcode( 'my_calendar_now', 'my_calendar_now' );
 
17
  * License: GPL-2.0+
18
  * License URI: http://www.gnu.org/license/gpl-2.0.txt
19
  * Domain Path: lang
20
+ * Version: 3.1.16
21
  */
22
 
23
  /*
42
  }
43
 
44
  global $mc_version, $wpdb;
45
+ $mc_version = '3.1.16';
46
 
47
  define( 'MC_DEBUG', false );
48
 
423
  add_shortcode( 'my_calendar_event', 'my_calendar_show_event' );
424
  add_shortcode( 'my_calendar_search', 'my_calendar_search' );
425
  add_shortcode( 'my_calendar_now', 'my_calendar_now' );
426
+ add_shortcode( 'my_calendar_next', 'my_calendar_next' );
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: calendar, dates, times, event, events, scheduling, schedule, event manager
5
  Requires at least: 4.4
6
  Tested up to: 5.2
7
  Requires PHP: 5.3
8
- Stable tag: 3.1.13
9
  Text domain: my-calendar
10
  License: GPLv2 or later
11
 
@@ -83,6 +83,24 @@ Translating my plug-ins is always appreciated. Visit <a href="https://translate.
83
 
84
  == Changelog ==
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  = 3.1.13 =
87
 
88
  * Bug fix: If plug-in name is translated, script references were broken.
5
  Requires at least: 4.4
6
  Tested up to: 5.2
7
  Requires PHP: 5.3
8
+ Stable tag: 3.1.16
9
  Text domain: my-calendar
10
  License: GPLv2 or later
11
 
83
 
84
  == Changelog ==
85
 
86
+ = 3.1.16 =
87
+
88
+ * Bug fix: restricting styles & JS to specific pages broken by strict type checks.
89
+ * New filter: mc_list_title_title
90
+
91
+ = 3.1.15 =
92
+
93
+ * Bug fix: List of access features produced empty UL if no results.
94
+ * Bug fix: Always produce a class on event accessibility selection list.
95
+ * Bug fix: Docs error in describing custom files directory.
96
+ * Add: support passing multiple site IDs into the calendar shortcode in multisite.
97
+
98
+ = 3.1.14 =
99
+
100
+ * Bug fix: Unescaped event title in HTML output.
101
+ * Bug fix: Improper saving of Edit All Categories permissions in user profile.
102
+ * New: [my_calendar_next] shortcode.
103
+
104
  = 3.1.13 =
105
 
106
  * Bug fix: If plug-in name is translated, script references were broken.