My Calendar - Version 3.2.4

Version Description

  • Bug fix: Permissions issue caused by variable type mismatch.
Download this release

Release Info

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

Code changes from version 3.2.0 to 3.2.4

css/mc-styles.css CHANGED
@@ -674,11 +674,8 @@ select[name="event_recur"] {
674
 
675
  .locations-container {
676
  position: relative;
677
- }
678
-
679
- .mc-locations .location-primary {
680
- width: 47%;
681
- margin-right: 20px;
682
  }
683
 
684
  .mc-locations:after {
@@ -687,13 +684,6 @@ select[name="event_recur"] {
687
  clear: both;
688
  }
689
 
690
- .mc-locations .location-secondary {
691
- position: absolute;
692
- left: 50%;
693
- top: 0;
694
- width: 47%;
695
- }
696
-
697
  .mc-locations .locations-container input {
698
  max-width: 90%;
699
  }
674
 
675
  .locations-container {
676
  position: relative;
677
+ display: grid;
678
+ grid-template-columns: 1fr 1fr;
 
 
 
679
  }
680
 
681
  .mc-locations:after {
684
  clear: both;
685
  }
686
 
 
 
 
 
 
 
 
687
  .mc-locations .locations-container input {
688
  max-width: 90%;
689
  }
includes/screen-options.php CHANGED
@@ -62,11 +62,11 @@ function mc_show_event_editing( $status, $args ) {
62
  // cannot change these keys.
63
  $input_labels = array(
64
  'event_location_dropdown' => __( 'Event Location Dropdown Menu', 'my-calendar' ),
65
- 'event_short' => __( 'Event Short Description field', 'my-calendar' ),
66
- 'event_desc' => __( 'Event Description Field', 'my-calendar' ),
67
- 'event_category' => __( 'Event Category field', 'my-calendar' ),
68
- 'event_image' => __( 'Event Image field', 'my-calendar' ),
69
- 'event_link' => __( 'Event Link field', 'my-calendar' ),
70
  'event_recurs' => __( 'Event Recurrence Options', 'my-calendar' ),
71
  'event_open' => __( 'Event Registration options', 'my-calendar' ),
72
  'event_location' => __( 'Event Location fields', 'my-calendar' ),
@@ -112,21 +112,35 @@ add_filter( 'set-screen-option', 'mc_set_event_editing', 11, 3 );
112
  *
113
  * @param string $status string.
114
  * @param string $option option name.
115
- * @param string $value new value.
116
  *
117
  * @return value
118
  */
119
  function mc_set_event_editing( $status, $option, $value ) {
120
  if ( 'mc_show_on_page' === $option ) {
121
- $orig = get_option( 'mc_input_options' );
122
- $value = array();
123
- foreach ( $orig as $k => $v ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  if ( isset( $_POST['mc_show_on_page'][ $k ] ) ) {
125
  $value[ $k ] = 'on';
126
  } else {
127
  $value[ $k ] = 'off';
128
  }
129
  }
 
130
  }
131
 
132
  return $value;
@@ -157,6 +171,9 @@ add_filter( 'set-screen-option', 'mc_set_screen_option', 10, 3 );
157
  * @return string $value
158
  */
159
  function mc_set_screen_option( $status, $option, $value ) {
 
 
 
160
 
161
  return $value;
162
  }
62
  // cannot change these keys.
63
  $input_labels = array(
64
  'event_location_dropdown' => __( 'Event Location Dropdown Menu', 'my-calendar' ),
65
+ 'event_short' => __( 'Event Short Description', 'my-calendar' ),
66
+ 'event_desc' => __( 'Event Description', 'my-calendar' ),
67
+ 'event_category' => __( 'Event Category', 'my-calendar' ),
68
+ 'event_image' => __( 'Event Image', 'my-calendar' ),
69
+ 'event_link' => __( 'Event Link', 'my-calendar' ),
70
  'event_recurs' => __( 'Event Recurrence Options', 'my-calendar' ),
71
  'event_open' => __( 'Event Registration options', 'my-calendar' ),
72
  'event_location' => __( 'Event Location fields', 'my-calendar' ),
112
  *
113
  * @param string $status string.
114
  * @param string $option option name.
115
+ * @param string $value rows to use.
116
  *
117
  * @return value
118
  */
119
  function mc_set_event_editing( $status, $option, $value ) {
120
  if ( 'mc_show_on_page' === $option ) {
121
+ $defaults = array(
122
+ 'event_location_dropdown' => 'on',
123
+ 'event_short' => 'on',
124
+ 'event_desc' => 'on',
125
+ 'event_category' => 'on',
126
+ 'event_image' => 'on',
127
+ 'event_link' => 'on',
128
+ 'event_recurs' => 'on',
129
+ 'event_open' => 'on',
130
+ 'event_location' => 'off',
131
+ 'event_specials' => 'on',
132
+ 'event_access' => 'on',
133
+ 'event_host' => 'on',
134
+ );
135
+ $value = array();
136
+ foreach ( $defaults as $k => $v ) {
137
  if ( isset( $_POST['mc_show_on_page'][ $k ] ) ) {
138
  $value[ $k ] = 'on';
139
  } else {
140
  $value[ $k ] = 'off';
141
  }
142
  }
143
+ update_user_meta( get_current_user_ID(), 'mc_show_on_page', $value );
144
  }
145
 
146
  return $value;
171
  * @return string $value
172
  */
173
  function mc_set_screen_option( $status, $option, $value ) {
174
+ if ( 'mc_num_per_page' === $option ) {
175
+ update_user_meta( get_current_user_ID(), 'mc_num_per_page', $value );
176
+ }
177
 
178
  return $value;
179
  }
my-calendar-api.php CHANGED
@@ -331,7 +331,7 @@ function mc_strip_to_xml( $value ) {
331
  }
332
  $length = strlen( $value );
333
  for ( $i = 0; $i < $length; $i ++ ) {
334
- $current = ord( $value{$i} );
335
  if ( ( 0x9 === $current ) || ( 0xA === $current ) || ( 0xD === $current ) || ( ( $current >= 0x20 ) && ( $current <= 0xD7FF ) ) || ( ( $current >= 0xE000 ) && ( $current <= 0xFFFD ) ) || ( ( $current >= 0x10000 ) && ( $current <= 0x10FFFF ) ) ) {
336
  $ret .= chr( $current );
337
  } else {
331
  }
332
  $length = strlen( $value );
333
  for ( $i = 0; $i < $length; $i ++ ) {
334
+ $current = ord( $value[ $i ] );
335
  if ( ( 0x9 === $current ) || ( 0xA === $current ) || ( 0xD === $current ) || ( ( $current >= 0x20 ) && ( $current <= 0xD7FF ) ) || ( ( $current >= 0xE000 ) && ( $current <= 0xFFFD ) ) || ( ( $current >= 0x10000 ) && ( $current <= 0x10FFFF ) ) ) {
336
  $ret .= chr( $current );
337
  } else {
my-calendar-categories.php CHANGED
@@ -420,8 +420,8 @@ function mc_edit_category_form( $view = 'edit', $cat_id = '' ) {
420
  $private_checked = '';
421
  }
422
  }
423
- $checked = ( 'add' === $view ) ? '' : mc_is_checked( 'mc_default_category', $cur_cat->category_id, '', true );
424
- $holiday_checked = ( 'add' === $view ) ? '' : mc_is_checked( 'mc_skip_holidays_category', $cur_cat->category_id, '', true );
425
  ?>
426
  <ul class='checkboxes'>
427
  <li>
@@ -817,7 +817,7 @@ function mc_category_select( $data = false, $option = true, $multiple = false, $
817
  if ( $multiple ) {
818
  if ( is_array( $category ) && in_array( $cat->category_id, $category, true ) ) {
819
  $selected = ' checked="checked"';
820
- } elseif ( (int) $category === (int) $cat->category_id ) {
821
  $selected = ' checked="checked"';
822
  }
823
  } else {
420
  $private_checked = '';
421
  }
422
  }
423
+ $checked = ( 'add' === $view ) ? '' : checked( get_option( 'mc_default_category' ), $cur_cat->category_id, false );
424
+ $holiday_checked = ( 'add' === $view ) ? '' : checked( get_option( 'mc_skip_holidays_category' ), $cur_cat->category_id, false );
425
  ?>
426
  <ul class='checkboxes'>
427
  <li>
817
  if ( $multiple ) {
818
  if ( is_array( $category ) && in_array( $cat->category_id, $category, true ) ) {
819
  $selected = ' checked="checked"';
820
+ } elseif ( is_numeric( $category ) && ( (int) $category === (int) $cat->category_id ) ) {
821
  $selected = ' checked="checked"';
822
  }
823
  } else {
my-calendar-core.php CHANGED
@@ -1581,8 +1581,7 @@ function mc_load_permalinks() {
1581
  *
1582
  * @return string
1583
  */
1584
- function mc_previous_post_link( $output, $format, $link, $post, $adj ) {
1585
- $output = '';
1586
  if ( is_singular( 'mc-events' ) && isset( $_GET['mc_id'] ) ) {
1587
  $mc_id = (int) $_GET['mc_id'];
1588
  $event = mc_adjacent_event( $mc_id, 'previous' );
@@ -1607,7 +1606,7 @@ function mc_previous_post_link( $output, $format, $link, $post, $adj ) {
1607
  *
1608
  * @return string
1609
  */
1610
- function mc_next_post_link( $output, $format, $link, $post, $adj ) {
1611
  $output = '';
1612
  if ( is_singular( 'mc-events' ) && isset( $_GET['mc_id'] ) ) {
1613
  $mc_id = (int) $_GET['mc_id'];
@@ -1647,14 +1646,26 @@ function mc_post_type() {
1647
  'menu_icon' => null,
1648
  'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields' ),
1649
  );
1650
- $types = array(
1651
- 'mc-events' => array(
 
 
 
 
 
1652
  __( 'event', 'my-calendar' ),
1653
  __( 'events', 'my-calendar' ),
1654
  __( 'Event', 'my-calendar' ),
1655
  __( 'Events', 'my-calendar' ),
1656
  $arguments,
1657
  ),
 
 
 
 
 
 
 
1658
  );
1659
 
1660
  return $types;
@@ -1664,8 +1675,7 @@ function mc_post_type() {
1664
  */
1665
  function mc_posttypes() {
1666
  $types = mc_post_type();
1667
- $enabled = array( 'mc-events' );
1668
- $slug = ( '' !== get_option( 'mc_cpt_base', '' ) ) ? get_option( 'mc_cpt_base' ) : 'mc-events';
1669
  if ( is_array( $enabled ) ) {
1670
  foreach ( $enabled as $key ) {
1671
  $value =& $types[ $key ];
@@ -1694,7 +1704,7 @@ function mc_posttypes() {
1694
  'query_var' => true,
1695
  'rewrite' => array(
1696
  'with_front' => false,
1697
- 'slug' => apply_filters( 'mc_event_slug', $slug ),
1698
  ),
1699
  'hierarchical' => false,
1700
  'menu_position' => 20,
@@ -1705,6 +1715,20 @@ function mc_posttypes() {
1705
  }
1706
  }
1707
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1708
  add_filter( 'the_posts', 'mc_close_comments' );
1709
  /**
1710
  * Most people don't want comments open on events. This will automatically close them.
@@ -1784,7 +1808,7 @@ function mc_taxonomies() {
1784
  function mc_posttypes_messages( $messages ) {
1785
  global $post, $post_ID;
1786
  $types = mc_post_type();
1787
- $enabled = array( 'mc-events' );
1788
  if ( is_array( $enabled ) ) {
1789
  foreach ( $enabled as $key ) {
1790
  $value = $types[ $key ];
1581
  *
1582
  * @return string
1583
  */
1584
+ function mc_previous_post_link( $output = '', $format = '', $link = '', $post = false, $adj = false ) {
 
1585
  if ( is_singular( 'mc-events' ) && isset( $_GET['mc_id'] ) ) {
1586
  $mc_id = (int) $_GET['mc_id'];
1587
  $event = mc_adjacent_event( $mc_id, 'previous' );
1606
  *
1607
  * @return string
1608
  */
1609
+ function mc_next_post_link( $output = '', $format = '', $link = '', $post = false, $adj = false ) {
1610
  $output = '';
1611
  if ( is_singular( 'mc-events' ) && isset( $_GET['mc_id'] ) ) {
1612
  $mc_id = (int) $_GET['mc_id'];
1646
  'menu_icon' => null,
1647
  'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields' ),
1648
  );
1649
+
1650
+ $loc_arguments = $arguments;
1651
+ $loc_arguments['supports'] = array( 'title', 'custom-fields', 'thumbnail' );
1652
+ $loc_arguments['exclude_from_search'] = apply_filters( 'mc_location_exclude_from_search', true );
1653
+
1654
+ $types = array(
1655
+ 'mc-events' => array(
1656
  __( 'event', 'my-calendar' ),
1657
  __( 'events', 'my-calendar' ),
1658
  __( 'Event', 'my-calendar' ),
1659
  __( 'Events', 'my-calendar' ),
1660
  $arguments,
1661
  ),
1662
+ 'mc-locations' => array(
1663
+ __( 'location', 'my-calendar' ),
1664
+ __( 'locations', 'my-calendar' ),
1665
+ __( 'Location', 'my-calendar' ),
1666
+ __( 'Locations', 'my-calendar' ),
1667
+ $loc_arguments,
1668
+ ),
1669
  );
1670
 
1671
  return $types;
1675
  */
1676
  function mc_posttypes() {
1677
  $types = mc_post_type();
1678
+ $enabled = array( 'mc-events', 'mc-locations' );
 
1679
  if ( is_array( $enabled ) ) {
1680
  foreach ( $enabled as $key ) {
1681
  $value =& $types[ $key ];
1704
  'query_var' => true,
1705
  'rewrite' => array(
1706
  'with_front' => false,
1707
+ 'slug' => apply_filters( 'mc_event_slug', $key ),
1708
  ),
1709
  'hierarchical' => false,
1710
  'menu_position' => 20,
1715
  }
1716
  }
1717
 
1718
+ /**
1719
+ * Replace the slug with saved option.
1720
+ *
1721
+ * @param string $slug Base post type name.
1722
+ *
1723
+ * @return string New permalink base.
1724
+ */
1725
+ function mc_filter_posttype_slug( $slug ) {
1726
+ $slug = ( '' !== get_option( 'mc_cpt_base', '' ) && 'mc-events' === $slug ) ? get_option( 'mc_cpt_base' ) : $slug;
1727
+
1728
+ return $slug;
1729
+ }
1730
+ add_filter( 'mc_event_slug', 'mc_filter_posttype_slug' );
1731
+
1732
  add_filter( 'the_posts', 'mc_close_comments' );
1733
  /**
1734
  * Most people don't want comments open on events. This will automatically close them.
1808
  function mc_posttypes_messages( $messages ) {
1809
  global $post, $post_ID;
1810
  $types = mc_post_type();
1811
+ $enabled = array( 'mc-events', 'mc-locations' );
1812
  if ( is_array( $enabled ) ) {
1813
  foreach ( $enabled as $key ) {
1814
  $value = $types[ $key ];
my-calendar-event-manager.php CHANGED
@@ -214,6 +214,17 @@ function mc_event_delete_posts( $deleted ) {
214
  }
215
  }
216
 
 
 
 
 
 
 
 
 
 
 
 
217
  /**
218
  * Update a single field in an event.
219
  *
@@ -239,17 +250,6 @@ function mc_update_event( $field, $data, $event, $type = '%d' ) {
239
  return $result;
240
  }
241
 
242
- /**
243
- * Delete custom post type associated with event
244
- *
245
- * @param int $event_id Event ID.
246
- * @param int $post_id Post ID.
247
- */
248
- function mc_event_delete_post( $event_id, $post_id ) {
249
- do_action( 'mc_deleted_post', $event_id, $post_id );
250
- wp_delete_post( $post_id, true );
251
- }
252
-
253
  /**
254
  * Handle a bulk action.
255
  *
@@ -1940,7 +1940,7 @@ function mc_list_events() {
1940
  }
1941
  $sorting = ( 'DESC' === $sortbydirection ) ? '&amp;order=ASC' : '&amp;order=DESC';
1942
  $allow_filters = true;
1943
- $status = ( isset( $_GET['limit'] ) ) ? $_GET['limit'] : 'all';
1944
  $restrict = ( isset( $_GET['restrict'] ) ) ? $_GET['restrict'] : 'all';
1945
  switch ( $status ) {
1946
  case 'all':
@@ -1956,7 +1956,7 @@ function mc_list_events() {
1956
  $limit = 'WHERE event_approved = 2';
1957
  break;
1958
  default:
1959
- $limit = '';
1960
  }
1961
  switch ( $restrict ) {
1962
  case 'all':
@@ -3500,15 +3500,18 @@ function mc_can_edit_category( $category, $user ) {
3500
  */
3501
  function mc_can_edit_event( $event = false ) {
3502
  if ( ! $event ) {
 
3503
  return false;
3504
  }
3505
 
3506
  $api = apply_filters( 'mc_api_can_edit_event', false, $event );
3507
  if ( $api ) {
 
3508
  return $api;
3509
  }
3510
 
3511
  if ( ! is_user_logged_in() ) {
 
3512
  return false;
3513
  }
3514
 
@@ -3524,6 +3527,7 @@ function mc_can_edit_event( $event = false ) {
3524
  $event_author = wp_get_current_user()->ID;
3525
  $event_id = $event;
3526
  }
 
3527
  $current_user = wp_get_current_user();
3528
  $user = $current_user->ID;
3529
  $categories = mc_get_categories( $event_id );
@@ -3539,7 +3543,8 @@ function mc_can_edit_event( $event = false ) {
3539
  }
3540
  $return = false;
3541
 
3542
- if ( ( current_user_can( 'mc_manage_events' ) && $has_permissions ) || ( $user === $event_author ) ) {
 
3543
  $return = true;
3544
  }
3545
 
214
  }
215
  }
216
 
217
+ /**
218
+ * Delete custom post type associated with event
219
+ *
220
+ * @param int $event_id Event ID.
221
+ * @param int $post_id Post ID.
222
+ */
223
+ function mc_event_delete_post( $event_id, $post_id ) {
224
+ do_action( 'mc_deleted_post', $event_id, $post_id );
225
+ wp_delete_post( $post_id, true );
226
+ }
227
+
228
  /**
229
  * Update a single field in an event.
230
  *
250
  return $result;
251
  }
252
 
 
 
 
 
 
 
 
 
 
 
 
253
  /**
254
  * Handle a bulk action.
255
  *
1940
  }
1941
  $sorting = ( 'DESC' === $sortbydirection ) ? '&amp;order=ASC' : '&amp;order=DESC';
1942
  $allow_filters = true;
1943
+ $status = ( isset( $_GET['limit'] ) ) ? $_GET['limit'] : '';
1944
  $restrict = ( isset( $_GET['restrict'] ) ) ? $_GET['restrict'] : 'all';
1945
  switch ( $status ) {
1946
  case 'all':
1956
  $limit = 'WHERE event_approved = 2';
1957
  break;
1958
  default:
1959
+ $limit = 'WHERE event_approved != 2';
1960
  }
1961
  switch ( $restrict ) {
1962
  case 'all':
3500
  */
3501
  function mc_can_edit_event( $event = false ) {
3502
  if ( ! $event ) {
3503
+
3504
  return false;
3505
  }
3506
 
3507
  $api = apply_filters( 'mc_api_can_edit_event', false, $event );
3508
  if ( $api ) {
3509
+
3510
  return $api;
3511
  }
3512
 
3513
  if ( ! is_user_logged_in() ) {
3514
+
3515
  return false;
3516
  }
3517
 
3527
  $event_author = wp_get_current_user()->ID;
3528
  $event_id = $event;
3529
  }
3530
+
3531
  $current_user = wp_get_current_user();
3532
  $user = $current_user->ID;
3533
  $categories = mc_get_categories( $event_id );
3543
  }
3544
  $return = false;
3545
 
3546
+ if ( ( current_user_can( 'mc_manage_events' ) && $has_permissions ) || ( $user === (int) $event_author ) ) {
3547
+
3548
  $return = true;
3549
  }
3550
 
my-calendar-locations.php CHANGED
@@ -13,6 +13,168 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  /**
17
  * Update a single field in a location.
18
  *
@@ -61,8 +223,25 @@ function mc_insert_location( $add ) {
61
  $add = array_map( 'mc_kses_post', $add );
62
  $formats = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%f', '%f', '%d', '%s', '%s', '%s' );
63
  $results = $wpdb->insert( my_calendar_locations_table(), $add, $formats );
 
 
 
 
 
64
 
65
- return $results;
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
 
68
  /**
@@ -119,7 +298,7 @@ function my_calendar_add_locations() {
119
  );
120
 
121
  $results = mc_insert_location( $add );
122
- do_action( 'mc_save_location', $results, $add );
123
  if ( $results ) {
124
  mc_show_notice( __( 'Location added successfully', 'my-calendar' ) );
125
  } else {
@@ -158,7 +337,7 @@ function my_calendar_add_locations() {
158
  $where = array( 'location_id' => (int) $_POST['location_id'] );
159
  $results = mc_modify_location( $update, $where );
160
 
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 ) {
@@ -208,7 +387,16 @@ function mc_show_location_form( $view = 'add', $loc_id = '' ) {
208
  <h2><?php _e( 'Location Editor', 'my-calendar' ); ?></h2>
209
 
210
  <div class="inside location_form">
211
- <form id="my-calendar" method="post" action="<?php echo admin_url( 'admin.php?page=my-calendar-locations' ); ?>">
 
 
 
 
 
 
 
 
 
212
  <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'my-calendar-nonce' ); ?>"/></div>
213
  <?php
214
  if ( 'add' === $view ) {
@@ -480,7 +668,9 @@ function mc_locations_fields( $has_data, $data, $context = 'location' ) {
480
  <p>
481
  <label for="e_latitude">' . __( 'Latitude', 'my-calendar' ) . '</label> <input type="text" id="e_latitude" name="' . $context . '_latitude" size="10" value="' . $event_lat . '" /> <label for="e_longitude">' . __( 'Longitude', 'my-calendar' ) . '</label> <input type="text" id="e_longitude" name="' . $context . '_longitude" size="10" value="' . $event_lon . '" />
482
  </p>
483
- </fieldset>
 
 
484
  </div>
485
  <div class="location-secondary">
486
  <fieldset>
@@ -526,7 +716,11 @@ function mc_locations_fields( $has_data, $data, $context = 'location' ) {
526
  }
527
  $return .= $access_list;
528
  $return .= '</ul>
529
- </fieldset></div>
 
 
 
 
530
  </div>
531
  </div>';
532
 
@@ -544,6 +738,141 @@ function mc_locations_fields( $has_data, $data, $context = 'location' ) {
544
  return $return;
545
  }
546
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
547
  /**
548
  * Array of location access features
549
  *
13
  exit;
14
  }
15
 
16
+ /**
17
+ * Handle updating location posts
18
+ *
19
+ * @param array $where Array with where query.
20
+ * @param array $data saved location data.
21
+ * @param int $post POST data.
22
+ *
23
+ * @return int post ID
24
+ */
25
+ function mc_update_location_post( $where, $data, $post ) {
26
+ // if the location save was successful.
27
+ $location_id = $where['location_id'];
28
+ $post_id = mc_get_location_post( $location_id, false );
29
+ // If, after all that, the post doesn't exist, create it.
30
+ if ( ! get_post_status( $post_id ) ) {
31
+ mc_create_location_post( $location_id, $data, $post );
32
+ }
33
+
34
+ $title = $data['location_label'];
35
+ $post_status = 'publish';
36
+ $auth = get_current_user_id();
37
+ $type = 'mc-locations';
38
+ $my_post = array(
39
+ 'ID' => $post_id,
40
+ 'post_title' => $title,
41
+ 'post_status' => $post_status,
42
+ 'post_author' => $auth,
43
+ 'post_name' => sanitize_title( $title ),
44
+ 'post_type' => $type,
45
+ );
46
+ if ( mc_switch_sites() && defined( BLOG_ID_CURRENT_SITE ) ) {
47
+ switch_to_blog( BLOG_ID_CURRENT_SITE );
48
+ }
49
+ $post_id = wp_update_post( $my_post );
50
+
51
+ do_action( 'mc_update_location_post', $post_id, $_POST, $data, $location_id );
52
+ if ( mc_switch_sites() ) {
53
+ restore_current_blog();
54
+ }
55
+
56
+ return $post_id;
57
+ }
58
+ add_action( 'mc_modify_location', 'mc_update_location_post', 10, 3 );
59
+
60
+ /**
61
+ * Create a post for My Calendar location data on save
62
+ *
63
+ * @param bool|int $location_id Result of save action; location ID or false.
64
+ * @param array $data Saved event data.
65
+ * @param array $post POST data.
66
+ *
67
+ * @return int newly created post ID
68
+ */
69
+ function mc_create_location_post( $location_id, $data, $post ) {
70
+ if ( ! $location_id ) {
71
+ return;
72
+ }
73
+ $post_id = mc_get_location_post( $location_id, false );
74
+ if ( ! $post_id ) {
75
+ $title = $data['location_label'];
76
+ $post_status = 'publish';
77
+ $auth = get_current_user_id();
78
+ $type = 'mc-locations';
79
+ $my_post = array(
80
+ 'post_title' => $title,
81
+ 'post_status' => $post_status,
82
+ 'post_author' => $auth,
83
+ 'post_name' => sanitize_title( $title ),
84
+ 'post_date' => current_time( 'Y-m-d H:i:s' ),
85
+ 'post_type' => $type,
86
+ );
87
+ $post_id = wp_insert_post( $my_post );
88
+ update_post_meta( $post_id, '_mc_location_id', $location_id );
89
+
90
+ do_action( 'mc_update_location_post', $post_id, $post, $data, $location_id );
91
+ wp_publish_post( $post_id );
92
+ }
93
+
94
+ return $post_id;
95
+ }
96
+ add_action( 'mc_save_location', 'mc_create_location_post', 10, 3 );
97
+
98
+ /**
99
+ * Update custom fields for a location.
100
+ *
101
+ * @param int $post_id Post ID associated with location.
102
+ * @param array $post POST data.
103
+ * @param array $data Saved location data.
104
+ * @param int $location_id Location ID in table.
105
+ *
106
+ * @return array Errors.
107
+ */
108
+ function mc_update_location_custom_fields( $post_id, $post, $data, $location_id ) {
109
+ $fields = mc_location_fields();
110
+ $field_errors = array();
111
+ foreach ( $fields as $name => $field ) {
112
+ if ( isset( $post[ $name ] ) ) {
113
+ if ( ! isset( $field['sanitize_callback'] ) || ( isset( $field['sanitize_callback'] ) && ! function_exists( $field['sanitize_callback'] ) ) ) {
114
+ // if no sanitization is provided, we'll prep it for SQL and strip tags.
115
+ $sanitized = esc_html( strip_tags( urldecode( $post[ $name ] ) ) );
116
+ } else {
117
+ $sanitized = call_user_func( $field['sanitize_callback'], urldecode( $post[ $name ] ) );
118
+ }
119
+ $success = update_post_meta( $post_id, $name, $sanitized );
120
+ if ( ! $success ) {
121
+ $field_errors[] = $name;
122
+ }
123
+ }
124
+ }
125
+
126
+ return $field_errors;
127
+ }
128
+ add_action( 'mc_update_location_post', 'mc_update_location_custom_fields', 10, 4 );
129
+
130
+ /**
131
+ * Delete custom post type associated with event
132
+ *
133
+ * @param int $result Result of delete action.
134
+ * @param int $location_id Location ID.
135
+ */
136
+ function mc_location_delete_post( $result, $location_id ) {
137
+ $posts = get_posts(
138
+ array(
139
+ 'post_type' => 'mc-locations',
140
+ 'meta_key' => '_mc_location_id',
141
+ 'meta_value' => $location_id,
142
+ )
143
+ );
144
+ if ( isset( $posts[0] ) && is_object( $posts[0] ) ) {
145
+ $post_id = $posts[0]->ID;
146
+ wp_delete_post( $post_id, true );
147
+ do_action( 'mc_delete_location_posts', $location_id, $posts );
148
+ }
149
+ }
150
+ add_action( 'mc_delete_location', 'mc_location_delete_post', 10, 2 );
151
+
152
+ /**
153
+ * Get the location post for a location.
154
+ *
155
+ * @param int $location_id Location ID.
156
+ * @param bool $type True for full post object.
157
+ *
158
+ * @return object $post
159
+ */
160
+ function mc_get_location_post( $location_id, $type = true ) {
161
+ $post_ID = false;
162
+ $post = false;
163
+ $posts = get_posts(
164
+ array(
165
+ 'post_type' => 'mc-locations',
166
+ 'meta_key' => '_mc_location_id',
167
+ 'meta_value' => $location_id,
168
+ )
169
+ );
170
+ if ( isset( $posts[0] ) && is_object( $posts[0] ) ) {
171
+ $post = $posts[0];
172
+ $post_ID = $post->ID;
173
+ }
174
+
175
+ return ( $type ) ? $post : $post_ID;
176
+ }
177
+
178
  /**
179
  * Update a single field in a location.
180
  *
223
  $add = array_map( 'mc_kses_post', $add );
224
  $formats = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%f', '%f', '%d', '%s', '%s', '%s' );
225
  $results = $wpdb->insert( my_calendar_locations_table(), $add, $formats );
226
+ if ( $results ) {
227
+ $insert_id = $wpdb->insert_id;
228
+ } else {
229
+ $insert_id = false;
230
+ }
231
 
232
+ return $insert_id;
233
+ }
234
+
235
+ /**
236
+ * Get count of locations.
237
+ *
238
+ * @return int
239
+ */
240
+ function mc_count_locations() {
241
+ global $wpdb;
242
+ $count = $wpdb->get_var( 'SELECT COUNT(*) FROM ' . my_calendar_locations_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
243
+
244
+ return $count;
245
  }
246
 
247
  /**
298
  );
299
 
300
  $results = mc_insert_location( $add );
301
+ do_action( 'mc_save_location', $results, $add, $_POST );
302
  if ( $results ) {
303
  mc_show_notice( __( 'Location added successfully', 'my-calendar' ) );
304
  } else {
337
  $where = array( 'location_id' => (int) $_POST['location_id'] );
338
  $results = mc_modify_location( $update, $where );
339
 
340
+ do_action( 'mc_modify_location', $where, $update, $_POST );
341
  if ( false === $results ) {
342
  mc_show_error( __( 'Location could not be edited.', 'my-calendar' ) );
343
  } elseif ( 0 === $results ) {
387
  <h2><?php _e( 'Location Editor', 'my-calendar' ); ?></h2>
388
 
389
  <div class="inside location_form">
390
+ <?php
391
+ $params = array();
392
+ if ( isset( $_GET['location_id'] ) ) {
393
+ $params = array(
394
+ 'mode' => $_GET['mode'],
395
+ 'location_id' => $_GET['location_id'],
396
+ );
397
+ }
398
+ ?>
399
+ <form id="my-calendar" method="post" action="<?php echo add_query_arg( $params, admin_url( 'admin.php?page=my-calendar-locations' ) ); ?>">
400
  <div><input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'my-calendar-nonce' ); ?>"/></div>
401
  <?php
402
  if ( 'add' === $view ) {
668
  <p>
669
  <label for="e_latitude">' . __( 'Latitude', 'my-calendar' ) . '</label> <input type="text" id="e_latitude" name="' . $context . '_latitude" size="10" value="' . $event_lat . '" /> <label for="e_longitude">' . __( 'Longitude', 'my-calendar' ) . '</label> <input type="text" id="e_longitude" name="' . $context . '_longitude" size="10" value="' . $event_lon . '" />
670
  </p>
671
+ </fieldset>';
672
+ $return .= apply_filters( 'mc_location_container_primary', '', $data, $context );
673
+ $return .= '
674
  </div>
675
  <div class="location-secondary">
676
  <fieldset>
716
  }
717
  $return .= $access_list;
718
  $return .= '</ul>
719
+ </fieldset>';
720
+ $fields = mc_display_location_fields( mc_location_fields(), $data, $context );
721
+ $return .= ( '' !== $fields ) ? '<div class="mc-custom-fields mc-locations"><fieldset><legend>' . __( 'Custom Fields', 'my-calendar' ) . '</legend>' . $fields . '</fieldset></div>' : '';
722
+ $return .= apply_filters( 'mc_location_container_secondary', '', $data, $context );
723
+ $return .= '</div>
724
  </div>
725
  </div>';
726
 
738
  return $return;
739
  }
740
 
741
+ /**
742
+ * Return a set of location fields.
743
+ *
744
+ * @return array
745
+ */
746
+ function mc_location_fields() {
747
+ $fields = apply_filters( 'mc_location_fields', array() );
748
+
749
+ return $fields;
750
+ }
751
+
752
+ /**
753
+ * Get custom data for a location.
754
+ *
755
+ * @param int $location_id Location ID.
756
+ * @param string $field Custom field name.
757
+ *
758
+ * @return mixed
759
+ */
760
+ function mc_location_custom_data( $location_id = false, $field ) {
761
+ $location_id = ( isset( $_GET['location_id'] ) ) ? (int) $_GET['location_id'] : $location_id;
762
+ $value = '';
763
+ if ( ! $location_id ) {
764
+ $location_id = ( isset( $_POST['location_id'] ) ) ? (int) $_POST['location_id'] : false;
765
+ }
766
+ if ( $location_id ) {
767
+ $post_id = mc_get_location_post( $location_id, false );
768
+ $value = get_post_meta( $post_id, $field, true );
769
+ }
770
+
771
+ return $value;
772
+ }
773
+
774
+ /**
775
+ * Add custom fields to event data output.
776
+ *
777
+ * @param array $e Event tag data.
778
+ * @param object $event Event object.
779
+ *
780
+ * @return array
781
+ */
782
+ function mc_template_location_fields( $e, $event ) {
783
+ $fields = mc_location_fields();
784
+ foreach ( $fields as $name => $field ) {
785
+ $value = mc_location_custom_data( $event->event_location, $name );
786
+ if ( ! isset( $field['display_callback'] ) || ( isset( $field['display_callback'] ) && ! function_exists( $field['display_callback'] ) ) ) {
787
+ // if no display callback is provided.
788
+ $display = stripslashes( $value );
789
+ } else {
790
+ $display = call_user_func( $field['display_callback'], $value, $field );
791
+ }
792
+ $key = 'location_' . $name;
793
+ $e[ $key ] = $display;
794
+ }
795
+
796
+ return $e;
797
+ }
798
+ add_filter( 'mc_filter_shortcodes', 'mc_template_location_fields', 10, 2 );
799
+
800
+ /**
801
+ * Expand custom fields from array to field output
802
+ *
803
+ * @param array $fields Array of field data.
804
+ * @param array $data Location data.
805
+ * @param string $context Location or event.
806
+ *
807
+ * @return string
808
+ */
809
+ function mc_display_location_fields( $fields, $data, $context ) {
810
+ if ( empty( $fields ) ) {
811
+ return '';
812
+ }
813
+ $output = '';
814
+ $return = '';
815
+
816
+ $custom_fields = apply_filters( 'mc_order_location_fields', $fields, $context );
817
+ foreach ( $custom_fields as $name => $field ) {
818
+ $user_value = mc_location_custom_data( $data, $name );
819
+ $required = isset( $field['required'] ) ? ' required' : '';
820
+ $req_label = isset( $field['required'] ) ? ' <span class="required">' . __( 'Required', 'my-calendar' ) . '</span>' : '';
821
+ switch ( $field['input_type'] ) {
822
+ case 'text':
823
+ case 'number':
824
+ case 'email':
825
+ case 'url':
826
+ case 'date':
827
+ case 'tel':
828
+ $output = "<input type='" . $field['input_type'] . "' name='$name' id='$name' value='$user_value'$required />";
829
+ break;
830
+ case 'hidden':
831
+ $output = "<input type='hidden' name='$name' value='$user_value' />";
832
+ break;
833
+ case 'textarea':
834
+ $output = "<textarea rows='6' cols='60' name='$name' id='$name'$required>$user_value</textarea>";
835
+ break;
836
+ case 'select':
837
+ if ( isset( $field['input_values'] ) ) {
838
+ $output = "<select name='$name' id='$name'$required>";
839
+ foreach ( $field['input_values'] as $value ) {
840
+ $value = esc_attr( stripslashes( $value ) );
841
+ if ( $value === $user_value ) {
842
+ $selected = " selected='selected'";
843
+ } else {
844
+ $selected = '';
845
+ }
846
+ $output .= "<option value='" . esc_attr( stripslashes( $value ) ) . "'$selected>" . $value . "</option>\n";
847
+ }
848
+ $output .= '</select>';
849
+ }
850
+ break;
851
+ case 'checkbox':
852
+ case 'radio':
853
+ if ( isset( $field['input_values'] ) ) {
854
+ $value = $field['input_values'];
855
+ if ( (string) $value === (string) $user_value ) {
856
+ $checked = ' checked="checked"';
857
+ } else {
858
+ $checked = '';
859
+ }
860
+ $output = "<input type='" . $field['input_type'] . "' name='$name' id='$name' value='" . esc_attr( stripslashes( $value ) ) . "'$checked $required />";
861
+ }
862
+ break;
863
+ default:
864
+ $output = "<input type='text' name='$name' id='$name' value='$user_value' $required />";
865
+ }
866
+ if ( 'hidden' !== $field['input_type'] ) {
867
+ $return .= ( 'checkbox' === $field['input_type'] || 'radio' === $field['input_type'] ) ? '<p class="' . $field['input_type'] . '">' . $output . " <label for='$name'>" . $field['title'] . $req_label . '</label></p>' : "<p><label for='$name'>" . $field['title'] . $req_label . '</label> ' . $output . '</p>';
868
+ } else {
869
+ $return .= $output;
870
+ }
871
+ }
872
+
873
+ return $return;
874
+ }
875
+
876
  /**
877
  * Array of location access features
878
  *
my-calendar-output.php CHANGED
@@ -22,12 +22,12 @@ if ( ! defined( 'ABSPATH' ) ) {
22
  */
23
  function mc_get_template( $template ) {
24
  $templates = get_option( 'mc_templates' );
25
- $template = ( isset( $templates[ $template ] ) ) ? $templates[ $template ] : $template;
26
 
27
- $keys = array( 'title', 'title_list', 'title_solo', 'link', 'mini', 'list', 'details', 'rss', 'grid' );
28
-
29
- if ( in_array( $template, $keys, true ) ) {
30
  $template = '';
 
 
31
  }
32
 
33
  return trim( $template );
@@ -537,26 +537,26 @@ function mc_get_details( $data, $template, $type ) {
537
  switch ( $type ) {
538
  case 'mini':
539
  $template = mc_get_template( 'mini' );
540
- if ( '1' === get_option( 'mc_use_mini_template' ) ) {
541
  $details = mc_draw_template( $data, $template );
542
  }
543
  break;
544
  case 'list':
545
  $template = mc_get_template( 'list' );
546
- if ( '1' === get_option( 'mc_use_list_template' ) ) {
547
  $details = mc_draw_template( $data, $template );
548
  }
549
  break;
550
  case 'single':
551
  $template = mc_get_template( 'details' );
552
- if ( '1' === get_option( 'mc_use_details_template' ) ) {
553
  $details = mc_draw_template( $data, $template );
554
  }
555
  break;
556
  case 'calendar':
557
  default:
558
  $template = mc_get_template( 'grid' );
559
- if ( '1' === get_option( 'mc_use_grid_template' ) ) {
560
  $details = mc_draw_template( $data, $template );
561
  }
562
  }
22
  */
23
  function mc_get_template( $template ) {
24
  $templates = get_option( 'mc_templates' );
25
+ $keys = array( 'title', 'title_list', 'title_solo', 'link', 'mini', 'list', 'details', 'rss', 'grid' );
26
 
27
+ if ( ! in_array( $template, $keys, true ) ) {
 
 
28
  $template = '';
29
+ } else {
30
+ $template = ( isset( $templates[ $template ] ) ) ? $templates[ $template ] : '';
31
  }
32
 
33
  return trim( $template );
537
  switch ( $type ) {
538
  case 'mini':
539
  $template = mc_get_template( 'mini' );
540
+ if ( '1' === get_option( 'mc_use_mini_template' ) && '' !== $template ) {
541
  $details = mc_draw_template( $data, $template );
542
  }
543
  break;
544
  case 'list':
545
  $template = mc_get_template( 'list' );
546
+ if ( '1' === get_option( 'mc_use_list_template' ) && '' !== $template ) {
547
  $details = mc_draw_template( $data, $template );
548
  }
549
  break;
550
  case 'single':
551
  $template = mc_get_template( 'details' );
552
+ if ( '1' === get_option( 'mc_use_details_template' ) && '' !== $template ) {
553
  $details = mc_draw_template( $data, $template );
554
  }
555
  break;
556
  case 'calendar':
557
  default:
558
  $template = mc_get_template( 'grid' );
559
+ if ( '1' === get_option( 'mc_use_grid_template' ) && '' !== $template ) {
560
  $details = mc_draw_template( $data, $template );
561
  }
562
  }
my-calendar-settings.php CHANGED
@@ -871,11 +871,11 @@ function mc_remote_db() {
871
  $input_options = get_option( 'mc_input_options' );
872
  $input_labels = array(
873
  'event_location_dropdown' => __( 'Event Location Dropdown Menu', 'my-calendar' ),
874
- 'event_short' => __( 'Event Short Description field', 'my-calendar' ),
875
- 'event_desc' => __( 'Event Description Field', 'my-calendar' ),
876
- 'event_category' => __( 'Event Category field', 'my-calendar' ),
877
- 'event_image' => __( 'Event Image field', 'my-calendar' ),
878
- 'event_link' => __( 'Event Link field', 'my-calendar' ),
879
  'event_recurs' => __( 'Event Recurrence Options', 'my-calendar' ),
880
  'event_open' => __( 'Event Registration options', 'my-calendar' ),
881
  'event_location' => __( 'Event Location fields', 'my-calendar' ),
871
  $input_options = get_option( 'mc_input_options' );
872
  $input_labels = array(
873
  'event_location_dropdown' => __( 'Event Location Dropdown Menu', 'my-calendar' ),
874
+ 'event_short' => __( 'Event Short Description', 'my-calendar' ),
875
+ 'event_desc' => __( 'Event Description', 'my-calendar' ),
876
+ 'event_category' => __( 'Event Category', 'my-calendar' ),
877
+ 'event_image' => __( 'Event Image', 'my-calendar' ),
878
+ 'event_link' => __( 'Event Link', 'my-calendar' ),
879
  'event_recurs' => __( 'Event Recurrence Options', 'my-calendar' ),
880
  'event_open' => __( 'Event Registration options', 'my-calendar' ),
881
  'event_location' => __( 'Event Location fields', 'my-calendar' ),
my-calendar-templates.php CHANGED
@@ -209,11 +209,11 @@ function mc_maplink( $event, $request = 'map', $source = 'event' ) {
209
  $map_string = $latitude . $dir_lat . ',' . $longitude . $dir_long;
210
  }
211
  }
 
 
212
  if ( strlen( trim( $map_string ) ) > 6 ) {
213
  $map_url = apply_filters( 'mc_map_url', "http://maps.google.com/maps?z=$zoom&amp;daddr=$map_string", $event );
214
- // Translators: Name of location.
215
- $label = sprintf( apply_filters( 'mc_map_label', __( 'Map<span> to %s</span>', 'my-calendar' ), $event ), $map_label );
216
- $map = '<a href="' . esc_url( $map_url ) . '" class="map-link external">' . $label . '</a>';
217
  } elseif ( esc_url( $url ) ) {
218
  $map_url = $url;
219
  $map = "<a href=\"$map_url\" class='map-link external map-url'>" . $label . '</a>';
209
  $map_string = $latitude . $dir_lat . ',' . $longitude . $dir_long;
210
  }
211
  }
212
+ // Translators: Name of location.
213
+ $label = sprintf( apply_filters( 'mc_map_label', __( 'Map<span> to %s</span>', 'my-calendar' ), $event ), $map_label );
214
  if ( strlen( trim( $map_string ) ) > 6 ) {
215
  $map_url = apply_filters( 'mc_map_url', "http://maps.google.com/maps?z=$zoom&amp;daddr=$map_string", $event );
216
+ $map = '<a href="' . esc_url( $map_url ) . '" class="map-link external">' . $label . '</a>';
 
 
217
  } elseif ( esc_url( $url ) ) {
218
  $map_url = $url;
219
  $map = "<a href=\"$map_url\" class='map-link external map-url'>" . $label . '</a>';
my-calendar-templating.php CHANGED
@@ -154,7 +154,7 @@ function mc_templates_edit() {
154
 
155
  <div class='mc_template_tags inside'>
156
  <p>
157
- <a href="<?php echo admin_url( 'admin.php?page=my-calendar-help#templates' ); ?>"><?php _e( 'All Template Tags &raquo;', 'my-calendar' ); ?></a>
158
  </p>
159
  <dl>
160
  <dt><code>{title}</code></dt>
@@ -254,12 +254,63 @@ function mc_templates_edit() {
254
  </div>
255
  </div>
256
  </div>
 
 
 
 
 
 
 
 
 
 
 
257
  </div>
258
  </div>
259
  <?php
260
  mc_show_sidebar();
261
  }
262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  /**
264
  * Check whether the current key refers to a core template
265
  *
154
 
155
  <div class='mc_template_tags inside'>
156
  <p>
157
+ <a href="<?php echo admin_url( 'admin.php?page=my-calendar-templates#templates' ); ?>"><?php _e( 'All Template Tags &raquo;', 'my-calendar' ); ?></a>
158
  </p>
159
  <dl>
160
  <dt><code>{title}</code></dt>
254
  </div>
255
  </div>
256
  </div>
257
+ <div id="templates" class="metabox-holder">
258
+ <div class="ui-sortable meta-box-sortables">
259
+ <div class="postbox">
260
+ <h2 class='hndle'><?php _e( 'All Event Template Tags (alphabetical)', 'my-calendar' ); ?></h2>
261
+
262
+ <div class='mc_template_tags inside'>
263
+ <?php echo mc_display_template_tags(); ?>
264
+ </div>
265
+ </div>
266
+ </div>
267
+ </div>
268
  </div>
269
  </div>
270
  <?php
271
  mc_show_sidebar();
272
  }
273
 
274
+ /**
275
+ * Display a list of all available template tags.
276
+ *
277
+ * @return string
278
+ */
279
+ function mc_display_template_tags() {
280
+ $event = false;
281
+ $data = array();
282
+ $output = '';
283
+ if ( ! isset( $_GET['mc-event'] ) ) {
284
+ $args = array(
285
+ 'before' => 1,
286
+ 'after' => 1,
287
+ 'today' => 'yes',
288
+ );
289
+ $events = mc_get_all_events( $args );
290
+ if ( isset( $events[0] ) ) {
291
+ $event = $events[0];
292
+ }
293
+ } else {
294
+ $mc_id = absint( $_GET['mc-event'] );
295
+ $event = mc_get_event( $mc_id );
296
+ }
297
+ if ( isset( $events[0] ) ) {
298
+ $data = mc_create_tags( $event );
299
+ }
300
+ ksort( $data );
301
+ if ( empty( $data ) ) {
302
+ return __( 'Template tag index will display after you create an event.', 'my-calendar' );
303
+ }
304
+ foreach ( $data as $key => $value ) {
305
+ $output .= '<dt><div class="mc-tag-' . $key . '"><code>{' . $key . '}</code></div></dt>';
306
+ if ( '' === $value ) {
307
+ $value = __( 'No output for this event.', 'my-calendar' );
308
+ }
309
+ $output .= '<dd><div class="mc-output-' . $key . '"><pre style="white-space:pre-wrap">' . esc_html( $value ) . '</pre></div></dd>';
310
+ }
311
+
312
+ return '<dl>' . $output . '</dl>';
313
+ }
314
  /**
315
  * Check whether the current key refers to a core template
316
  *
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.2.0
21
  */
22
 
23
  /*
@@ -42,7 +42,7 @@ if ( ! defined( 'ABSPATH' ) ) {
42
  }
43
 
44
  global $mc_version, $wpdb;
45
- $mc_version = '3.2.0';
46
 
47
  define( 'MC_DEBUG', false );
48
 
17
  * License: GPL-2.0+
18
  * License URI: http://www.gnu.org/license/gpl-2.0.txt
19
  * Domain Path: lang
20
+ * Version: 3.2.4
21
  */
22
 
23
  /*
42
  }
43
 
44
  global $mc_version, $wpdb;
45
+ $mc_version = '3.2.4';
46
 
47
  define( 'MC_DEBUG', false );
48
 
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.4
7
  Requires PHP: 5.6
8
- Stable tag: 3.2.0
9
  Text domain: my-calendar
10
  License: GPLv2 or later
11
 
@@ -83,6 +83,28 @@ Translating my plug-ins is always appreciated. Visit <a href="https://translate.
83
 
84
  == Changelog ==
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  = 3.2.0 =
87
 
88
  * Auto-toggle admin time format if display time format set to European format.
5
  Requires at least: 4.4
6
  Tested up to: 5.4
7
  Requires PHP: 5.6
8
+ Stable tag: 3.2.4
9
  Text domain: my-calendar
10
  License: GPLv2 or later
11
 
83
 
84
  == Changelog ==
85
 
86
+ = 3.2.4 =
87
+
88
+ * Bug fix: Permissions issue caused by variable type mismatch.
89
+
90
+ = 3.2.3 =
91
+
92
+ * Bug fix: 3.2.2 created multiple post types with the same slug, triggering 404 errors.
93
+ * Bug fix: Templates could return the name of the template if template empty/missing.
94
+
95
+ = 3.2.2 =
96
+
97
+ * Bug fix: Curly brace offset access deprecated
98
+ * Bug fix: Make next/prev post link arguments optional.
99
+ * Bug fix: Template queries could return an empty template.
100
+ * Change: Remove trashed events from default events list.
101
+
102
+ = 3.2.1 =
103
+
104
+ * PHP Notice: undefined variable.
105
+ * Bug fix: screen options not saving.
106
+ * Bug fix: Accidental auto-assigning of first category to events when editing.
107
+
108
  = 3.2.0 =
109
 
110
  * Auto-toggle admin time format if display time format set to European format.