My Calendar - Version 3.2.15

Version Description

  • Bug fix: Hide event details section if no fields are visible for section.
  • Bug fix: Update localization to correct usage of l10n parameter.
  • Bug fix: Location AJAX query executed function that only existed in Pro.
Download this release

Release Info

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

Code changes from version 3.2.14 to 3.2.15

js/jquery.admin.js CHANGED
@@ -55,7 +55,7 @@ jQuery(document).ready(function ($) {
55
  $( '#e_approved' ).on( 'change', function (e) {
56
  var event_status = $(this).val();
57
  if ( event_status == 0 ) {
58
- $( 'input[name=save]' ).val( draftText );
59
  } else {
60
  $( 'input[name=save]' ).val( publishText );
61
  }
@@ -170,8 +170,8 @@ var mediaPopup = '';
170
  width = '';
171
  if (selection) {
172
  id = selection.first().attributes.id;
173
- height = thumbHeight;
174
- width = ( ( selection.first().attributes.width ) / ( selection.first().attributes.height ) ) * thumbHeight;
175
  img = "<img src='" + selection.first().attributes.url + "' width='" + width + "' height='" + height + "' />";
176
  $inpField.val(selection.first().attributes.url);
177
  $idField.val(id);
55
  $( '#e_approved' ).on( 'change', function (e) {
56
  var event_status = $(this).val();
57
  if ( event_status == 0 ) {
58
+ $( 'input[name=save]' ).val( mcAdmin.draftText );
59
  } else {
60
  $( 'input[name=save]' ).val( publishText );
61
  }
170
  width = '';
171
  if (selection) {
172
  id = selection.first().attributes.id;
173
+ height = mcAdmin.thumbHeight;
174
+ width = ( ( selection.first().attributes.width ) / ( selection.first().attributes.height ) ) * height;
175
  img = "<img src='" + selection.first().attributes.url + "' width='" + width + "' height='" + height + "' />";
176
  $inpField.val(selection.first().attributes.url);
177
  $idField.val(id);
js/jquery.suggest.js CHANGED
@@ -1,18 +1,18 @@
1
  (function ($) {
2
- $(function () {
3
- $('.suggest').autocomplete({
4
- minLength: 3,
5
- source: function (req, response) {
6
- $.getJSON(ajaxurl + '?callback=?&action=' + mc_ajax_action, req, response);
7
- },
8
- select: function (event, ui) {
9
- var label = $(this).attr('id');
10
- $( 'input[name=mc_uri_id]' ).val(ui.item.id);
11
  $( '#mc_uri_id-note' ).html( ' = (' + ui.item.value + ')' );
12
 
13
- return false;
14
- }
15
- }
16
- );
17
- });
18
  }(jQuery));
1
  (function ($) {
2
+ $(function () {
3
+ $('.suggest').autocomplete({
4
+ minLength: 3,
5
+ source: function (req, response) {
6
+ $.getJSON(ajaxurl + '?callback=?&action=' + mc_ajax_action.action, req, response);
7
+ },
8
+ select: function (event, ui) {
9
+ var label = $(this).attr('id');
10
+ $( 'input[name=mc_uri_id]' ).val(ui.item.id);
11
  $( '#mc_uri_id-note' ).html( ' = (' + ui.item.value + ')' );
12
 
13
+ return false;
14
+ }
15
+ }
16
+ );
17
+ });
18
  }(jQuery));
js/mc-ajax.js CHANGED
@@ -26,16 +26,16 @@
26
  }
27
  // functions to execute when new view loads.
28
  // List view.
29
- if ( typeof( mclist ) !== "undefined" && mclist == 'true' ) {
30
  $('li.mc-events').children().not('.event-date').hide();
31
  $('li.current-day').children().show();
32
  }
33
  // Grid view.
34
- if ( typeof( mcgrid ) !== "undefined" && mcgrid == 'true' ) {
35
  $('.calendar-event').children().not('.event-title').hide();
36
  }
37
  // Mini view.
38
- if ( typeof( mcmini ) !== "undefined" && mcmini == 'true' ) {
39
  $('.mini .has-events').children().not('.trigger, .mc-date, .event-date').hide();
40
  }
41
  // All views.
26
  }
27
  // functions to execute when new view loads.
28
  // List view.
29
+ if ( typeof( mclist.list ) !== "undefined" && mclist.list == 'true' ) {
30
  $('li.mc-events').children().not('.event-date').hide();
31
  $('li.current-day').children().show();
32
  }
33
  // Grid view.
34
+ if ( typeof( mcgrid.grid ) !== "undefined" && mcgrid.grid == 'true' ) {
35
  $('.calendar-event').children().not('.event-title').hide();
36
  }
37
  // Mini view.
38
+ if ( typeof( mcmini.mini ) !== "undefined" && mcmini.mini == 'true' ) {
39
  $('.mini .has-events').children().not('.trigger, .mc-date, .event-date').hide();
40
  }
41
  // All views.
js/mc-datepicker.js CHANGED
@@ -17,8 +17,8 @@ if ( typeof(mc_months) !== "undefined" ) {
17
  }
18
  });
19
  $( '.mc-timepicker' ).pickatime({
20
- interval: parseInt( mc_interval ),
21
- format: mc_time_format,
22
  editable: true
23
  });
24
 
17
  }
18
  });
19
  $( '.mc-timepicker' ).pickatime({
20
+ interval: parseInt( mcTime.interval ),
21
+ format: mcTime.time_format,
22
  editable: true
23
  });
24
 
my-calendar-core.php CHANGED
@@ -428,25 +428,49 @@ function mc_footer_js() {
428
  $url = apply_filters( 'mc_grid_js', plugins_url( 'js/mc-grid.js', __FILE__ ) );
429
  $enqueue_mcjs = true;
430
  wp_enqueue_script( 'mc.grid', $url, array( 'jquery' ) );
431
- wp_localize_script( 'mc.grid', 'mcgrid', 'true' );
 
 
 
 
 
 
432
  }
433
  if ( '1' !== get_option( 'mc_list_javascript' ) ) {
434
  $url = apply_filters( 'mc_list_js', plugins_url( 'js/mc-list.js', __FILE__ ) );
435
  $enqueue_mcjs = true;
436
  wp_enqueue_script( 'mc.list', $url, array( 'jquery' ) );
437
- wp_localize_script( 'mc.list', 'mclist', 'true' );
 
 
 
 
 
 
438
  }
439
  if ( '1' !== get_option( 'mc_mini_javascript' ) && 'true' !== get_option( 'mc_open_day_uri' ) ) {
440
  $url = apply_filters( 'mc_mini_js', plugins_url( 'js/mc-mini.js', __FILE__ ) );
441
  $enqueue_mcjs = true;
442
  wp_enqueue_script( 'mc.mini', $url, array( 'jquery' ) );
443
- wp_localize_script( 'mc.mini', 'mcmini', 'true' );
 
 
 
 
 
 
444
  }
445
  if ( '1' !== get_option( 'mc_ajax_javascript' ) ) {
446
  $url = apply_filters( 'mc_ajax_js', plugins_url( 'js/mc-ajax.js', __FILE__ ) );
447
  $enqueue_mcjs = true;
448
  wp_enqueue_script( 'mc.ajax', $url, array( 'jquery' ) );
449
- wp_localize_script( 'mc.ajax', 'mcAjax', 'true' );
 
 
 
 
 
 
450
  }
451
  if ( $enqueue_mcjs ) {
452
  wp_enqueue_script( 'mc.mcjs', plugins_url( 'js/mcjs.js', __FILE__ ), array( 'jquery' ) );
@@ -1002,8 +1026,14 @@ function mc_scripts() {
1002
 
1003
  if ( false !== strpos( $id, 'my-calendar' ) ) {
1004
  wp_enqueue_script( 'mc.admin', plugins_url( 'js/jquery.admin.js', __FILE__ ), array( 'jquery', 'jquery-ui-sortable' ) );
1005
- wp_localize_script( 'mc.admin', 'thumbHeight', get_option( 'thumbnail_size_h' ) );
1006
- wp_localize_script( 'mc.admin', 'draftText', __( 'Save Draft', 'my-calendar' ) );
 
 
 
 
 
 
1007
  }
1008
 
1009
  if ( 'toplevel_page_my-calendar' === $id || $slug . '_my-calendar-groups' === $id || $slug . '_page_my-calendar-locations' === $id ) {
@@ -1060,8 +1090,14 @@ function mc_scripts() {
1060
  ),
1061
  )
1062
  );
1063
- wp_localize_script( 'pickadate.time', 'mc_time_format', apply_filters( 'mc_time_format', 'h:i A' ) );
1064
- wp_localize_script( 'pickadate.time', 'mc_interval', apply_filters( 'mc_interval', '15' ) );
 
 
 
 
 
 
1065
  wp_enqueue_script( 'mc.pickadate', plugins_url( 'js/mc-datepicker.js', __FILE__ ), array( 'jquery', 'pickadate.date', 'pickadate.time' ) );
1066
 
1067
  if ( function_exists( 'wp_enqueue_media' ) && ! did_action( 'wp_enqueue_media' ) ) {
@@ -1118,7 +1154,13 @@ function mc_scripts() {
1118
  'jquery-ui-autocomplete',
1119
  )
1120
  );
1121
- wp_localize_script( 'mc.suggest', 'mc_ajax_action', 'mc_post_lookup' );
 
 
 
 
 
 
1122
  }
1123
 
1124
  if ( $slug . '_page_my-calendar-categories' === $id ) {
428
  $url = apply_filters( 'mc_grid_js', plugins_url( 'js/mc-grid.js', __FILE__ ) );
429
  $enqueue_mcjs = true;
430
  wp_enqueue_script( 'mc.grid', $url, array( 'jquery' ) );
431
+ wp_localize_script(
432
+ 'mc.grid',
433
+ 'mcgrid',
434
+ array(
435
+ 'grid' => 'true',
436
+ )
437
+ );
438
  }
439
  if ( '1' !== get_option( 'mc_list_javascript' ) ) {
440
  $url = apply_filters( 'mc_list_js', plugins_url( 'js/mc-list.js', __FILE__ ) );
441
  $enqueue_mcjs = true;
442
  wp_enqueue_script( 'mc.list', $url, array( 'jquery' ) );
443
+ wp_localize_script(
444
+ 'mc.list',
445
+ 'mclist',
446
+ array(
447
+ 'list' => 'true',
448
+ )
449
+ );
450
  }
451
  if ( '1' !== get_option( 'mc_mini_javascript' ) && 'true' !== get_option( 'mc_open_day_uri' ) ) {
452
  $url = apply_filters( 'mc_mini_js', plugins_url( 'js/mc-mini.js', __FILE__ ) );
453
  $enqueue_mcjs = true;
454
  wp_enqueue_script( 'mc.mini', $url, array( 'jquery' ) );
455
+ wp_localize_script(
456
+ 'mc.mini',
457
+ 'mcmini',
458
+ array(
459
+ 'mini' => 'true',
460
+ )
461
+ );
462
  }
463
  if ( '1' !== get_option( 'mc_ajax_javascript' ) ) {
464
  $url = apply_filters( 'mc_ajax_js', plugins_url( 'js/mc-ajax.js', __FILE__ ) );
465
  $enqueue_mcjs = true;
466
  wp_enqueue_script( 'mc.ajax', $url, array( 'jquery' ) );
467
+ wp_localize_script(
468
+ 'mc.ajax',
469
+ 'mcAjax',
470
+ array(
471
+ 'ajax' => 'true',
472
+ )
473
+ );
474
  }
475
  if ( $enqueue_mcjs ) {
476
  wp_enqueue_script( 'mc.mcjs', plugins_url( 'js/mcjs.js', __FILE__ ), array( 'jquery' ) );
1026
 
1027
  if ( false !== strpos( $id, 'my-calendar' ) ) {
1028
  wp_enqueue_script( 'mc.admin', plugins_url( 'js/jquery.admin.js', __FILE__ ), array( 'jquery', 'jquery-ui-sortable' ) );
1029
+ wp_localize_script(
1030
+ 'mc.admin',
1031
+ 'mcAdmin',
1032
+ array(
1033
+ 'thumbHeight' => get_option( 'thumbnail_size_h' ),
1034
+ 'draftText' => __( 'Save Draft', 'my-calendar' ),
1035
+ )
1036
+ );
1037
  }
1038
 
1039
  if ( 'toplevel_page_my-calendar' === $id || $slug . '_my-calendar-groups' === $id || $slug . '_page_my-calendar-locations' === $id ) {
1090
  ),
1091
  )
1092
  );
1093
+ wp_localize_script(
1094
+ 'pickadate.time',
1095
+ 'mcTime',
1096
+ array(
1097
+ 'time_format' => apply_filters( 'mc_time_format', 'h:i A' ),
1098
+ 'interval' => apply_filters( 'mc_interval', '15' ),
1099
+ )
1100
+ );
1101
  wp_enqueue_script( 'mc.pickadate', plugins_url( 'js/mc-datepicker.js', __FILE__ ), array( 'jquery', 'pickadate.date', 'pickadate.time' ) );
1102
 
1103
  if ( function_exists( 'wp_enqueue_media' ) && ! did_action( 'wp_enqueue_media' ) ) {
1154
  'jquery-ui-autocomplete',
1155
  )
1156
  );
1157
+ wp_localize_script(
1158
+ 'mc.suggest',
1159
+ 'mc_ajax_action',
1160
+ array(
1161
+ 'action' => 'mc_post_lookup',
1162
+ )
1163
+ );
1164
  }
1165
 
1166
  if ( $slug . '_page_my-calendar-categories' === $id ) {
my-calendar-event-manager.php CHANGED
@@ -1106,6 +1106,78 @@ function mc_show_edit_block( $field ) {
1106
  }
1107
  }
1108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1109
  /**
1110
  * Show a block of enabled fields.
1111
  *
@@ -1636,22 +1708,28 @@ function mc_form_fields( $data, $mode, $event_id ) {
1636
  </div>
1637
  </div>
1638
  </div>
1639
- <?php mc_show_block( 'event_recurs', $has_data, $data ); ?>
1640
- <div class="ui-sortable meta-box-sortables">
1641
- <div class="postbox">
1642
- <h2><?php _e( 'Event Details', 'my-calendar' ); ?></h2>
1643
- <div class="inside">
1644
  <?php
1645
- mc_show_block( 'event_short', $has_data, $data );
1646
- mc_show_block( 'event_image', $has_data, $data );
1647
- mc_show_block( 'event_host', $has_data, $data );
1648
- mc_show_block( 'event_author', $has_data, $data, true, $event_author );
1649
- mc_show_block( 'event_link', $has_data, $data );
1650
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
1651
  </div>
1652
- </div>
1653
- </div>
1654
- <?php
1655
  $custom_fields = apply_filters( 'mc_event_details', '', $has_data, $data, 'admin' );
1656
  if ( '' !== $custom_fields ) {
1657
  ?>
1106
  }
1107
  }
1108
 
1109
+ /**
1110
+ * Does an editing block contain visible fields.
1111
+ *
1112
+ * @param string $field Name of field group.
1113
+ *
1114
+ * @return bool
1115
+ */
1116
+ function mc_edit_block_is_visible( $field ) {
1117
+ $admin = ( 'true' === get_option( 'mc_input_options_administrators' ) && current_user_can( 'manage_options' ) ) ? true : false;
1118
+ $input = get_option( 'mc_input_options' );
1119
+ // Array of all options in off position.
1120
+ $defaults = array(
1121
+ 'event_location_dropdown' => 'on',
1122
+ 'event_short' => 'on',
1123
+ 'event_desc' => 'on',
1124
+ 'event_category' => 'on',
1125
+ 'event_image' => 'on',
1126
+ 'event_link' => 'on',
1127
+ 'event_recurs' => 'on',
1128
+ 'event_open' => 'on',
1129
+ 'event_location' => 'off',
1130
+ 'event_specials' => 'on',
1131
+ 'event_access' => 'on',
1132
+ 'event_host' => 'on',
1133
+ );
1134
+
1135
+ $input = array_merge( $defaults, $input );
1136
+ $user = get_current_user_id();
1137
+ $screen = get_current_screen();
1138
+ $option = $screen->get_option( 'mc_show_on_page', 'option' );
1139
+ $show = get_user_meta( $user, $option, true );
1140
+ if ( empty( $show ) || $show < 1 ) {
1141
+ $show = $screen->get_option( 'mc_show_on_page', 'default' );
1142
+ }
1143
+ // if this doesn't exist in array, return false. Field is hidden.
1144
+ if ( ! isset( $input[ $field ] ) || ! isset( $show[ $field ] ) ) {
1145
+ return false;
1146
+ }
1147
+ if ( $admin ) {
1148
+ if ( isset( $show[ $field ] ) && 'on' === $show[ $field ] ) {
1149
+ return true;
1150
+ } else {
1151
+ return false;
1152
+ }
1153
+ } else {
1154
+ if ( 'off' === $input[ $field ] || '' === $input[ $field ] ) {
1155
+ return false;
1156
+ } elseif ( 'off' === $show[ $field ] ) {
1157
+ return false;
1158
+ } else {
1159
+ return true;
1160
+ }
1161
+ }
1162
+ }
1163
+
1164
+ /**
1165
+ * Determine whether any of a set of fields are enabled.
1166
+ *
1167
+ * @param array $fields Array of field keys.
1168
+ *
1169
+ * @return bool
1170
+ */
1171
+ function mc_show_edit_blocks( $fields ) {
1172
+ foreach ( $fields as $field ) {
1173
+ if ( mc_edit_block_is_visible( $field ) ) {
1174
+ return true;
1175
+ }
1176
+ }
1177
+
1178
+ return false;
1179
+ }
1180
+
1181
  /**
1182
  * Show a block of enabled fields.
1183
  *
1708
  </div>
1709
  </div>
1710
  </div>
 
 
 
 
 
1711
  <?php
1712
+ mc_show_block( 'event_recurs', $has_data, $data );
1713
+ if ( mc_show_edit_blocks( array( 'event_short', 'event_image', 'event_host', 'event_author', 'event_link' ) ) ) {
1714
+ ?>
1715
+ <div class="ui-sortable meta-box-sortables">
1716
+ <div class="postbox">
1717
+ <h2><?php _e( 'Event Details', 'my-calendar' ); ?></h2>
1718
+ <div class="inside">
1719
+ <?php
1720
+ }
1721
+ mc_show_block( 'event_short', $has_data, $data );
1722
+ mc_show_block( 'event_image', $has_data, $data );
1723
+ mc_show_block( 'event_host', $has_data, $data );
1724
+ mc_show_block( 'event_author', $has_data, $data, true, $event_author );
1725
+ mc_show_block( 'event_link', $has_data, $data );
1726
+ if ( mc_show_edit_blocks( array( 'event_short', 'event_image', 'event_host', 'event_author', 'event_link' ) ) ) {
1727
+ ?>
1728
+ </div>
1729
+ </div>
1730
  </div>
1731
+ <?php
1732
+ }
 
1733
  $custom_fields = apply_filters( 'mc_event_details', '', $has_data, $data, 'admin' );
1734
  if ( '' !== $custom_fields ) {
1735
  ?>
my-calendar-locations.php CHANGED
@@ -1019,6 +1019,37 @@ function mc_get_locations( $args ) {
1019
  return apply_filters( 'mc_filter_results', $results, $args );
1020
  }
1021
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1022
 
1023
  /**
1024
  * Get information about locations.
@@ -1036,7 +1067,7 @@ function mc_core_autocomplete_search_locations() {
1036
  }
1037
  $query = $_REQUEST['data'];
1038
 
1039
- $locations = mc_search_locations( $query, array( 'location_id', 'location_label' ) );
1040
  $response = array();
1041
  foreach ( $locations as $location ) {
1042
  $response[] = array(
1019
  return apply_filters( 'mc_filter_results', $results, $args );
1020
  }
1021
 
1022
+ /**
1023
+ * Search location titles.
1024
+ *
1025
+ * @param string $query Location query.
1026
+ *
1027
+ * @return array locations
1028
+ */
1029
+ function mc_core_search_locations( $query = '' ) {
1030
+ global $wpdb;
1031
+ $search = '';
1032
+ $results = array();
1033
+ $current = empty( $_GET['paged'] ) ? 1 : intval( $_GET['paged'] );
1034
+ $db_type = mc_get_db_type();
1035
+ $query = esc_sql( $query );
1036
+
1037
+ if ( '' !== $query ) {
1038
+ // Fulltext is supported in InnoDB since MySQL 5.6; minimum required by WP is 5.0 as of WP 5.5.
1039
+ // 37% of installs still below 5.6 as of 11/30/2020.
1040
+ if ( 'MyISAM' === $db_type ) {
1041
+ $search = ' WHERE MATCH(' . apply_filters( 'mc_search_fields', 'location_label' ) . ") AGAINST ( '$query' IN BOOLEAN MODE ) ";
1042
+ } else {
1043
+ $search = " WHERE location_label LIKE '%$query%' ";
1044
+ }
1045
+ } else {
1046
+ $search = '';
1047
+ }
1048
+
1049
+ $locations = $wpdb->get_results( 'SELECT SQL_CALC_FOUND_ROWS location_id, location_label FROM ' . my_calendar_locations_table() . " $search ORDER BY location_label ASC" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
1050
+
1051
+ return $locations;
1052
+ }
1053
 
1054
  /**
1055
  * Get information about locations.
1067
  }
1068
  $query = $_REQUEST['data'];
1069
 
1070
+ $locations = mc_core_search_locations( $query, array( 'location_id', 'location_label' ) );
1071
  $response = array();
1072
  foreach ( $locations as $location ) {
1073
  $response[] = array(
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.14
21
  */
22
 
23
  /*
@@ -42,7 +42,7 @@ if ( ! defined( 'ABSPATH' ) ) {
42
  }
43
 
44
  global $mc_version, $wpdb;
45
- $mc_version = '3.2.14';
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.15
21
  */
22
 
23
  /*
42
  }
43
 
44
  global $mc_version, $wpdb;
45
+ $mc_version = '3.2.15';
46
 
47
  define( 'MC_DEBUG', false );
48
 
readme.txt CHANGED
@@ -6,7 +6,7 @@ Requires at least: 4.4
6
  Tested up to: 5.6
7
  Requires PHP: 5.6
8
  Text domain: my-calendar
9
- Stable tag: 3.2.14
10
  License: GPLv2 or later
11
 
12
  Accessible WordPress event calendar plugin. Show events from multiple calendars on pages, in posts, or in widgets.
@@ -84,6 +84,12 @@ Translating my plug-ins is always appreciated. Visit <a href="https://translate.
84
 
85
  == Changelog ==
86
 
 
 
 
 
 
 
87
  = 3.2.14 =
88
 
89
  * Bug fixes: Misc. type casting issues.
6
  Tested up to: 5.6
7
  Requires PHP: 5.6
8
  Text domain: my-calendar
9
+ Stable tag: 3.2.15
10
  License: GPLv2 or later
11
 
12
  Accessible WordPress event calendar plugin. Show events from multiple calendars on pages, in posts, or in widgets.
84
 
85
  == Changelog ==
86
 
87
+ = 3.2.15 =
88
+
89
+ * Bug fix: Hide event details section if no fields are visible for section.
90
+ * Bug fix: Update localization to correct usage of l10n parameter.
91
+ * Bug fix: Location AJAX query executed function that only existed in Pro.
92
+
93
  = 3.2.14 =
94
 
95
  * Bug fixes: Misc. type casting issues.