Version Description
- Bug fix: If plug-in name is translated, script references were broken.
- Bug fix: If no holiday category assigned, Today's Events widget will return empty when category limits set.
- New filter: allow events post type to be made searchable. (Not recommended.)
- New: Support 'search' parameter in shortcode & URL parameters for main view.
- Remove option to disable max contrast category names.
Download this release
Release Info
Developer | joedolson |
Plugin | My Calendar |
Version | 3.1.13 |
Comparing to | |
See all releases |
Code changes from version 3.1.12 to 3.1.13
- includes/date-utilities.php +20 -20
- includes/db.php +1 -1
- includes/deprecated.php +13 -12
- my-calendar-api.php +5 -5
- my-calendar-behaviors.php +2 -2
- my-calendar-categories.php +5 -6
- my-calendar-core.php +93 -94
- my-calendar-event-manager.php +1 -1
- my-calendar-events.php +38 -35
- my-calendar-generator.php +4 -0
- my-calendar-group-manager.php +37 -37
- my-calendar-install.php +10 -11
- my-calendar-location-manager.php +3 -3
- my-calendar-locations.php +24 -24
- my-calendar-output.php +96 -90
- my-calendar-print.php +1 -1
- my-calendar-settings.php +43 -43
- my-calendar-shortcodes.php +13 -7
- my-calendar-styles.php +1 -1
- my-calendar-templates.php +69 -68
- my-calendar-templating.php +1 -1
- my-calendar-upgrade-db.php +4 -4
- my-calendar-widgets.php +32 -32
- my-calendar.php +5 -5
- readme.txt +9 -1
- uninstall.php +1 -1
includes/date-utilities.php
CHANGED
@@ -23,7 +23,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
23 |
function mc_dateclass( $current ) {
|
24 |
$now = current_time( 'timestamp' );
|
25 |
$dayclass = sanitize_html_class( strtolower( date_i18n( 'l', $current ) ) ) . ' ' . sanitize_html_class( strtolower( date_i18n( 'D', $current ) ) );
|
26 |
-
if ( date( 'Ymd', $now )
|
27 |
$dateclass = 'current-day';
|
28 |
} elseif ( my_calendar_date_comp( date( 'Y-m-d', $now ), date( 'Y-m-d', $current ) ) ) {
|
29 |
$dateclass = 'future-day';
|
@@ -103,7 +103,7 @@ function my_calendar_date_equal( $early, $late ) {
|
|
103 |
// convert full datetime to date only.
|
104 |
$firstdate = strtotime( date( 'Y-m-d', strtotime( $early ) ) );
|
105 |
$lastdate = strtotime( date( 'Y-m-d', strtotime( $late ) ) );
|
106 |
-
if ( $firstdate
|
107 |
|
108 |
return true;
|
109 |
} else {
|
@@ -121,7 +121,7 @@ function my_calendar_date_equal( $early, $late ) {
|
|
121 |
* @return int (ternary value)
|
122 |
*/
|
123 |
function mc_time_cmp( $a, $b ) {
|
124 |
-
if ( $a->occur_begin
|
125 |
|
126 |
return 0;
|
127 |
}
|
@@ -140,7 +140,7 @@ function mc_time_cmp( $a, $b ) {
|
|
140 |
function mc_datetime_cmp( $a, $b ) {
|
141 |
$event_dt_a = strtotime( $a->occur_begin );
|
142 |
$event_dt_b = strtotime( $b->occur_begin );
|
143 |
-
if ( $event_dt_a
|
144 |
// this should sub-sort by title if date is the same. But it doesn't seem to.
|
145 |
$ta = $a->event_title;
|
146 |
$tb = $b->event_title;
|
@@ -167,7 +167,7 @@ function mc_timediff_cmp( $a, $b ) {
|
|
167 |
$diff_a = mc_date_diff_precise( $event_dt_a );
|
168 |
$diff_b = mc_date_diff_precise( $event_dt_b );
|
169 |
|
170 |
-
if ( $diff_a
|
171 |
return 0;
|
172 |
}
|
173 |
|
@@ -183,7 +183,7 @@ function mc_timediff_cmp( $a, $b ) {
|
|
183 |
* @return absolute time diff
|
184 |
*/
|
185 |
function mc_date_diff_precise( $start, $end = 'NOW' ) {
|
186 |
-
if ( 'NOW'
|
187 |
$end = strtotime( 'NOW' );
|
188 |
}
|
189 |
$sdate = $start;
|
@@ -248,7 +248,7 @@ function mc_checkdate( $date ) {
|
|
248 |
* @return array day and month
|
249 |
*/
|
250 |
function mc_first_day_of_week( $date = false ) {
|
251 |
-
$start_of_week = ( get_option( 'start_of_week' )
|
252 |
if ( $date ) {
|
253 |
$today = date( 'w', $date );
|
254 |
$now = date( 'Y-m-d', $date );
|
@@ -260,30 +260,30 @@ function mc_first_day_of_week( $date = false ) {
|
|
260 |
$sub = 0; // don't change month.
|
261 |
switch ( $today ) {
|
262 |
case 1:
|
263 |
-
$sub = ( 1
|
264 |
break; // mon.
|
265 |
case 2:
|
266 |
-
$sub = ( 1
|
267 |
break; // tues.
|
268 |
case 3:
|
269 |
-
$sub = ( 1
|
270 |
break; // wed.
|
271 |
case 4:
|
272 |
-
$sub = ( 1
|
273 |
break; // thu.
|
274 |
case 5:
|
275 |
-
$sub = ( 1
|
276 |
break; // fri.
|
277 |
case 6:
|
278 |
-
$sub = ( 1
|
279 |
break; // sat.
|
280 |
case 0:
|
281 |
-
$sub = ( 1
|
282 |
break; // sun.
|
283 |
}
|
284 |
$day = date( 'j', strtotime( $now . ' -' . $sub . ' day' ) );
|
285 |
-
if ( 0
|
286 |
-
if ( date( 'n', strtotime( $now . ' -' . $sub . ' day' ) )
|
287 |
$month = - 1;
|
288 |
} else {
|
289 |
$month = 0;
|
@@ -344,7 +344,7 @@ function mc_name_days( $format ) {
|
|
344 |
'<abbr title="' . date_i18n( 'l', strtotime( 'Friday' ) ) . '" aria-hidden="true">' . date_i18n( 'D', strtotime( 'Friday' ) ) . '</abbr><span class="screen-reader-text">' . date_i18n( 'l', strtotime( 'Friday' ) ) . '</span>',
|
345 |
'<abbr title="' . date_i18n( 'l', strtotime( 'Saturday' ) ) . '" aria-hidden="true">' . date_i18n( 'D', strtotime( 'Saturday' ) ) . '</abbr><span class="screen-reader-text">' . date_i18n( 'l', strtotime( 'Saturday' ) ) . '</span>',
|
346 |
);
|
347 |
-
if ( 'mini'
|
348 |
// PHP doesn't have a single letter abbreviation, so this has to be a translatable.
|
349 |
$name_days = array(
|
350 |
'<span aria-hidden="true">' . __( '<abbr title="Sunday">S</abbr>', 'my-calendar' ) . '</span><span class="screen-reader-text">' . date_i18n( 'l', strtotime( 'Sunday' ) ) . '</span>',
|
@@ -380,10 +380,10 @@ function mc_exit_early( $event, $process_date ) {
|
|
380 |
$end = date( 'Y-m-d', strtotime( $event->occur_end ) );
|
381 |
// if event ends at midnight today (e.g., very first thing of the day), exit without re-drawing.
|
382 |
// or if event started yesterday & has event_hide_end checked.
|
383 |
-
$ends_at_midnight = ( '00:00:00'
|
384 |
|
385 |
// hides events if hiding end time & not first day.
|
386 |
-
$hide_day_two = ( $hide_days && ( $today
|
387 |
|
388 |
if ( $ends_at_midnight || $hide_day_two ) {
|
389 |
return true;
|
@@ -404,7 +404,7 @@ function mc_exit_early( $event, $process_date ) {
|
|
404 |
* @return boolean
|
405 |
*/
|
406 |
function mc_private_event( $event ) {
|
407 |
-
$status = ( 1
|
408 |
// custom filter to grant custom reasons for exiting.
|
409 |
// $event may not be an event object; in some cases it's a category object.
|
410 |
$status = apply_filters( 'mc_private_event', $status, $event );
|
23 |
function mc_dateclass( $current ) {
|
24 |
$now = current_time( 'timestamp' );
|
25 |
$dayclass = sanitize_html_class( strtolower( date_i18n( 'l', $current ) ) ) . ' ' . sanitize_html_class( strtolower( date_i18n( 'D', $current ) ) );
|
26 |
+
if ( date( 'Ymd', $now ) === date( 'Ymd', $current ) ) {
|
27 |
$dateclass = 'current-day';
|
28 |
} elseif ( my_calendar_date_comp( date( 'Y-m-d', $now ), date( 'Y-m-d', $current ) ) ) {
|
29 |
$dateclass = 'future-day';
|
103 |
// convert full datetime to date only.
|
104 |
$firstdate = strtotime( date( 'Y-m-d', strtotime( $early ) ) );
|
105 |
$lastdate = strtotime( date( 'Y-m-d', strtotime( $late ) ) );
|
106 |
+
if ( $firstdate === $lastdate ) {
|
107 |
|
108 |
return true;
|
109 |
} else {
|
121 |
* @return int (ternary value)
|
122 |
*/
|
123 |
function mc_time_cmp( $a, $b ) {
|
124 |
+
if ( $a->occur_begin === $b->occur_begin ) {
|
125 |
|
126 |
return 0;
|
127 |
}
|
140 |
function mc_datetime_cmp( $a, $b ) {
|
141 |
$event_dt_a = strtotime( $a->occur_begin );
|
142 |
$event_dt_b = strtotime( $b->occur_begin );
|
143 |
+
if ( $event_dt_a === $event_dt_b ) {
|
144 |
// this should sub-sort by title if date is the same. But it doesn't seem to.
|
145 |
$ta = $a->event_title;
|
146 |
$tb = $b->event_title;
|
167 |
$diff_a = mc_date_diff_precise( $event_dt_a );
|
168 |
$diff_b = mc_date_diff_precise( $event_dt_b );
|
169 |
|
170 |
+
if ( $diff_a === $diff_b ) {
|
171 |
return 0;
|
172 |
}
|
173 |
|
183 |
* @return absolute time diff
|
184 |
*/
|
185 |
function mc_date_diff_precise( $start, $end = 'NOW' ) {
|
186 |
+
if ( 'NOW' === $end ) {
|
187 |
$end = strtotime( 'NOW' );
|
188 |
}
|
189 |
$sdate = $start;
|
248 |
* @return array day and month
|
249 |
*/
|
250 |
function mc_first_day_of_week( $date = false ) {
|
251 |
+
$start_of_week = ( get_option( 'start_of_week' ) === '1' || get_option( 'start_of_week' ) === '0' ) ? absint( get_option( 'start_of_week' ) ) : 0;
|
252 |
if ( $date ) {
|
253 |
$today = date( 'w', $date );
|
254 |
$now = date( 'Y-m-d', $date );
|
260 |
$sub = 0; // don't change month.
|
261 |
switch ( $today ) {
|
262 |
case 1:
|
263 |
+
$sub = ( 1 === $start_of_week ) ? 0 : 1;
|
264 |
break; // mon.
|
265 |
case 2:
|
266 |
+
$sub = ( 1 === $start_of_week ) ? 1 : 2;
|
267 |
break; // tues.
|
268 |
case 3:
|
269 |
+
$sub = ( 1 === $start_of_week ) ? 2 : 3;
|
270 |
break; // wed.
|
271 |
case 4:
|
272 |
+
$sub = ( 1 === $start_of_week ) ? 3 : 4;
|
273 |
break; // thu.
|
274 |
case 5:
|
275 |
+
$sub = ( 1 === $start_of_week ) ? 4 : 5;
|
276 |
break; // fri.
|
277 |
case 6:
|
278 |
+
$sub = ( 1 === $start_of_week ) ? 5 : 6;
|
279 |
break; // sat.
|
280 |
case 0:
|
281 |
+
$sub = ( 1 === $start_of_week ) ? 6 : 0;
|
282 |
break; // sun.
|
283 |
}
|
284 |
$day = date( 'j', strtotime( $now . ' -' . $sub . ' day' ) );
|
285 |
+
if ( 0 !== $sub ) {
|
286 |
+
if ( date( 'n', strtotime( $now . ' -' . $sub . ' day' ) ) !== date( 'n', strtotime( $now ) ) ) {
|
287 |
$month = - 1;
|
288 |
} else {
|
289 |
$month = 0;
|
344 |
'<abbr title="' . date_i18n( 'l', strtotime( 'Friday' ) ) . '" aria-hidden="true">' . date_i18n( 'D', strtotime( 'Friday' ) ) . '</abbr><span class="screen-reader-text">' . date_i18n( 'l', strtotime( 'Friday' ) ) . '</span>',
|
345 |
'<abbr title="' . date_i18n( 'l', strtotime( 'Saturday' ) ) . '" aria-hidden="true">' . date_i18n( 'D', strtotime( 'Saturday' ) ) . '</abbr><span class="screen-reader-text">' . date_i18n( 'l', strtotime( 'Saturday' ) ) . '</span>',
|
346 |
);
|
347 |
+
if ( 'mini' === $format ) {
|
348 |
// PHP doesn't have a single letter abbreviation, so this has to be a translatable.
|
349 |
$name_days = array(
|
350 |
'<span aria-hidden="true">' . __( '<abbr title="Sunday">S</abbr>', 'my-calendar' ) . '</span><span class="screen-reader-text">' . date_i18n( 'l', strtotime( 'Sunday' ) ) . '</span>',
|
380 |
$end = date( 'Y-m-d', strtotime( $event->occur_end ) );
|
381 |
// if event ends at midnight today (e.g., very first thing of the day), exit without re-drawing.
|
382 |
// or if event started yesterday & has event_hide_end checked.
|
383 |
+
$ends_at_midnight = ( '00:00:00' === $event->event_endtime && $end === $process_date && $current !== $today ) ? true : false;
|
384 |
|
385 |
// hides events if hiding end time & not first day.
|
386 |
+
$hide_day_two = ( $hide_days && ( $today !== $current ) ) ? true : false;
|
387 |
|
388 |
if ( $ends_at_midnight || $hide_day_two ) {
|
389 |
return true;
|
404 |
* @return boolean
|
405 |
*/
|
406 |
function mc_private_event( $event ) {
|
407 |
+
$status = ( 1 === absint( $event->category_private ) && ! is_user_logged_in() ) ? true : false;
|
408 |
// custom filter to grant custom reasons for exiting.
|
409 |
// $event may not be an event object; in some cases it's a category object.
|
410 |
$status = apply_filters( 'mc_private_event', $status, $event );
|
includes/db.php
CHANGED
@@ -86,7 +86,7 @@ function my_calendar_select_table( $table = 'my_calendar_events', $site = false
|
|
86 |
$option = (int) get_site_option( 'mc_multisite' );
|
87 |
$choice = (int) get_option( 'mc_current_table' );
|
88 |
$show = (int) get_site_option( 'mc_multisite_show' ); // 1 == use global instead of local.
|
89 |
-
if ( 'global'
|
90 |
return $wpdb->base_prefix . $table;
|
91 |
}
|
92 |
if ( false != $site && $site ) {
|
86 |
$option = (int) get_site_option( 'mc_multisite' );
|
87 |
$choice = (int) get_option( 'mc_current_table' );
|
88 |
$show = (int) get_site_option( 'mc_multisite_show' ); // 1 == use global instead of local.
|
89 |
+
if ( 'global' === $site ) {
|
90 |
return $wpdb->base_prefix . $table;
|
91 |
}
|
92 |
if ( false != $site && $site ) {
|
includes/deprecated.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
|
13 |
// Define the table constants used in My Calendar in case anybody is still using them.
|
14 |
// These were eliminated some time ago.
|
15 |
-
if ( is_multisite() && get_site_option( 'mc_multisite_show' )
|
16 |
define( 'MY_CALENDAR_TABLE', $wpdb->base_prefix . 'my_calendar' );
|
17 |
define( 'MY_CALENDAR_EVENTS_TABLE', $wpdb->base_prefix . 'my_calendar_events' );
|
18 |
define( 'MY_CALENDAR_CATEGORIES_TABLE', $wpdb->base_prefix . 'my_calendar_categories' );
|
@@ -165,7 +165,8 @@ function my_calendar_is_odd( $int ) {
|
|
165 |
* @return string label
|
166 |
*/
|
167 |
function mc_event_repeats_forever( $recur, $repeats ) {
|
168 |
-
|
|
|
169 |
return true;
|
170 |
}
|
171 |
switch ( $recur ) {
|
@@ -173,20 +174,20 @@ function mc_event_repeats_forever( $recur, $repeats ) {
|
|
173 |
return false;
|
174 |
break;
|
175 |
case 'D': // daily.
|
176 |
-
return ( 500
|
177 |
break;
|
178 |
case 'W': // weekly.
|
179 |
-
return ( 240
|
180 |
break;
|
181 |
case 'B': // biweekly.
|
182 |
-
return ( 120
|
183 |
break;
|
184 |
case 'M': // monthly.
|
185 |
case 'U':
|
186 |
-
return ( 60
|
187 |
break;
|
188 |
case 'Y':
|
189 |
-
return ( 5
|
190 |
break;
|
191 |
default:
|
192 |
return false;
|
@@ -201,10 +202,10 @@ if ( ! function_exists( 'is_ssl' ) ) {
|
|
201 |
*/
|
202 |
function is_ssl() {
|
203 |
if ( isset( $_SERVER['HTTPS'] ) ) {
|
204 |
-
if ( 'on'
|
205 |
return true;
|
206 |
}
|
207 |
-
if ( '1'
|
208 |
return true;
|
209 |
}
|
210 |
} elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
|
@@ -241,7 +242,7 @@ function jd_draw_template( $array, $template, $type = 'list' ) {
|
|
241 |
* @return boolean
|
242 |
*/
|
243 |
function mc_dates_consecutive( $current, $last_date ) {
|
244 |
-
if ( strtotime( $last_date . '+ 1 day' )
|
245 |
|
246 |
return true;
|
247 |
} else {
|
@@ -260,7 +261,7 @@ function mc_dates_consecutive( $current, $last_date ) {
|
|
260 |
function my_calendar_reverse_datetime_cmp( $b, $a ) {
|
261 |
$event_dt_a = strtotime( $a->occur_begin );
|
262 |
$event_dt_b = strtotime( $b->occur_begin );
|
263 |
-
if ( $event_dt_a
|
264 |
return 0;
|
265 |
}
|
266 |
|
@@ -302,7 +303,7 @@ function jd_date_diff( $start, $end = 'NOW' ) {
|
|
302 |
*/
|
303 |
function get_week_date( $week, $year ) {
|
304 |
// Get the target week of the year with reference to the starting day of the year.
|
305 |
-
$start_of_week = ( get_option( 'start_of_week' )
|
306 |
$target_week = strtotime( "$week week", strtotime( "1 January $year" ) );
|
307 |
$date_info = getdate( $target_week );
|
308 |
$day_of_week = $date_info['wday'];
|
12 |
|
13 |
// Define the table constants used in My Calendar in case anybody is still using them.
|
14 |
// These were eliminated some time ago.
|
15 |
+
if ( is_multisite() && get_site_option( 'mc_multisite_show' ) === '1' ) {
|
16 |
define( 'MY_CALENDAR_TABLE', $wpdb->base_prefix . 'my_calendar' );
|
17 |
define( 'MY_CALENDAR_EVENTS_TABLE', $wpdb->base_prefix . 'my_calendar_events' );
|
18 |
define( 'MY_CALENDAR_CATEGORIES_TABLE', $wpdb->base_prefix . 'my_calendar_categories' );
|
165 |
* @return string label
|
166 |
*/
|
167 |
function mc_event_repeats_forever( $recur, $repeats ) {
|
168 |
+
$repeats = absint( $repeats );
|
169 |
+
if ( 'S' !== $recur && 0 === $repeats ) {
|
170 |
return true;
|
171 |
}
|
172 |
switch ( $recur ) {
|
174 |
return false;
|
175 |
break;
|
176 |
case 'D': // daily.
|
177 |
+
return ( 500 === $repeats ) ? true : false;
|
178 |
break;
|
179 |
case 'W': // weekly.
|
180 |
+
return ( 240 === $repeats ) ? true : false;
|
181 |
break;
|
182 |
case 'B': // biweekly.
|
183 |
+
return ( 120 === $repeats ) ? true : false;
|
184 |
break;
|
185 |
case 'M': // monthly.
|
186 |
case 'U':
|
187 |
+
return ( 60 === $repeats ) ? true : false;
|
188 |
break;
|
189 |
case 'Y':
|
190 |
+
return ( 5 === $repeats ) ? true : false;
|
191 |
break;
|
192 |
default:
|
193 |
return false;
|
202 |
*/
|
203 |
function is_ssl() {
|
204 |
if ( isset( $_SERVER['HTTPS'] ) ) {
|
205 |
+
if ( 'on' === strtolower( $_SERVER['HTTPS'] ) ) {
|
206 |
return true;
|
207 |
}
|
208 |
+
if ( '1' === $_SERVER['HTTPS'] ) {
|
209 |
return true;
|
210 |
}
|
211 |
} elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
|
242 |
* @return boolean
|
243 |
*/
|
244 |
function mc_dates_consecutive( $current, $last_date ) {
|
245 |
+
if ( strtotime( $last_date . '+ 1 day' ) === strtotime( $current ) ) {
|
246 |
|
247 |
return true;
|
248 |
} else {
|
261 |
function my_calendar_reverse_datetime_cmp( $b, $a ) {
|
262 |
$event_dt_a = strtotime( $a->occur_begin );
|
263 |
$event_dt_b = strtotime( $b->occur_begin );
|
264 |
+
if ( $event_dt_a === $event_dt_b ) {
|
265 |
return 0;
|
266 |
}
|
267 |
|
303 |
*/
|
304 |
function get_week_date( $week, $year ) {
|
305 |
// Get the target week of the year with reference to the starting day of the year.
|
306 |
+
$start_of_week = ( get_option( 'start_of_week' ) === '1' || get_option( 'start_of_week' ) === '0' ) ? get_option( 'start_of_week' ) : 0;
|
307 |
$target_week = strtotime( "$week week", strtotime( "1 January $year" ) );
|
308 |
$date_info = getdate( $target_week );
|
309 |
$day_of_week = $date_info['wday'];
|
my-calendar-api.php
CHANGED
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
18 |
*/
|
19 |
function my_calendar_api() {
|
20 |
if ( isset( $_REQUEST['my-calendar-api'] ) ) {
|
21 |
-
if ( 'true'
|
22 |
// use this filter to add custom scripting handling API keys.
|
23 |
$api_key = apply_filters( 'mc_api_key', true );
|
24 |
if ( $api_key ) {
|
@@ -273,7 +273,7 @@ function mc_format_rss( $events ) {
|
|
273 |
{guid}
|
274 |
</item>' . PHP_EOL;
|
275 |
|
276 |
-
if ( get_option( 'mc_use_rss_template' )
|
277 |
$template = mc_get_template( 'rss' );
|
278 |
}
|
279 |
|
@@ -453,7 +453,7 @@ function mc_api_format_ical( $data ) {
|
|
453 |
}
|
454 |
}
|
455 |
$output = html_entity_decode( preg_replace( "~(?<!\r)\n~", "\r\n", $templates['head'] . $output . $templates['foot'] ) );
|
456 |
-
if ( ! ( isset( $_GET['sync'] ) && 'true'
|
457 |
$sitename = sanitize_title( get_bloginfo( 'name' ) );
|
458 |
header( 'Content-Type: text/calendar; charset=UTF-8' );
|
459 |
header( 'Pragma: no-cache' );
|
@@ -531,8 +531,8 @@ function mc_generate_alert_ical( $alarm ) {
|
|
531 |
$values = array_merge( $defaults, $alarm );
|
532 |
$alert = PHP_EOL . 'BEGIN:VALARM' . PHP_EOL;
|
533 |
$alert .= "TRIGGER:$values[TRIGGER]\n";
|
534 |
-
$alert .= ( 0
|
535 |
-
$alert .= ( ''
|
536 |
$alert .= "ACTION:$values[ACTION]\n";
|
537 |
$alert .= "DESCRIPTION:$values[DESCRIPTION]\n";
|
538 |
$alert .= 'END:VALARM';
|
18 |
*/
|
19 |
function my_calendar_api() {
|
20 |
if ( isset( $_REQUEST['my-calendar-api'] ) ) {
|
21 |
+
if ( 'true' === get_option( 'mc_api_enabled' ) ) {
|
22 |
// use this filter to add custom scripting handling API keys.
|
23 |
$api_key = apply_filters( 'mc_api_key', true );
|
24 |
if ( $api_key ) {
|
273 |
{guid}
|
274 |
</item>' . PHP_EOL;
|
275 |
|
276 |
+
if ( get_option( 'mc_use_rss_template' ) === '1' ) {
|
277 |
$template = mc_get_template( 'rss' );
|
278 |
}
|
279 |
|
453 |
}
|
454 |
}
|
455 |
$output = html_entity_decode( preg_replace( "~(?<!\r)\n~", "\r\n", $templates['head'] . $output . $templates['foot'] ) );
|
456 |
+
if ( ! ( isset( $_GET['sync'] ) && 'true' === $_GET['sync'] ) ) {
|
457 |
$sitename = sanitize_title( get_bloginfo( 'name' ) );
|
458 |
header( 'Content-Type: text/calendar; charset=UTF-8' );
|
459 |
header( 'Pragma: no-cache' );
|
531 |
$values = array_merge( $defaults, $alarm );
|
532 |
$alert = PHP_EOL . 'BEGIN:VALARM' . PHP_EOL;
|
533 |
$alert .= "TRIGGER:$values[TRIGGER]\n";
|
534 |
+
$alert .= ( '0' !== $values['REPEAT'] ) ? "REPEAT:$values[REPEAT]\n" : '';
|
535 |
+
$alert .= ( '' !== $values['DURATION'] ) ? "REPEAT:$values[DURATION]\n" : '';
|
536 |
$alert .= "ACTION:$values[ACTION]\n";
|
537 |
$alert .= "DESCRIPTION:$values[DESCRIPTION]\n";
|
538 |
$alert .= 'END:VALARM';
|
my-calendar-behaviors.php
CHANGED
@@ -41,7 +41,7 @@ function my_calendar_behaviors_edit() {
|
|
41 |
update_option( 'mc_ajaxjs', $mc_ajaxjs );
|
42 |
}
|
43 |
|
44 |
-
$mc_show_js = ( ''
|
45 |
update_option( 'mc_show_js', $mc_show_js );
|
46 |
mc_show_notice( __( 'Behavior Settings saved', 'my-calendar' ) );
|
47 |
}
|
@@ -97,7 +97,7 @@ function my_calendar_behaviors_edit() {
|
|
97 |
<label for="ajax_js"><?php _e( 'Disable AJAX', 'my-calendar' ); ?></label></li>
|
98 |
</ul>
|
99 |
</div>
|
100 |
-
<?php if ( get_option( 'mc_use_custom_js' )
|
101 |
<p>
|
102 |
<label for="calendar-js"><?php _e( 'Calendar Behaviors: Grid View', 'my-calendar' ); ?></label><br/><textarea id="calendar-js" name="mc_caljs" rows="12" cols="80"><?php echo esc_textarea( $mc_caljs ); ?></textarea>
|
103 |
</p>
|
41 |
update_option( 'mc_ajaxjs', $mc_ajaxjs );
|
42 |
}
|
43 |
|
44 |
+
$mc_show_js = ( '' === $_POST['mc_show_js'] ) ? '' : $_POST['mc_show_js'];
|
45 |
update_option( 'mc_show_js', $mc_show_js );
|
46 |
mc_show_notice( __( 'Behavior Settings saved', 'my-calendar' ) );
|
47 |
}
|
97 |
<label for="ajax_js"><?php _e( 'Disable AJAX', 'my-calendar' ); ?></label></li>
|
98 |
</ul>
|
99 |
</div>
|
100 |
+
<?php if ( get_option( 'mc_use_custom_js' ) === '1' ) { ?>
|
101 |
<p>
|
102 |
<label for="calendar-js"><?php _e( 'Calendar Behaviors: Grid View', 'my-calendar' ); ?></label><br/><textarea id="calendar-js" name="mc_caljs" rows="12" cols="80"><?php echo esc_textarea( $mc_caljs ); ?></textarea>
|
103 |
</p>
|
my-calendar-categories.php
CHANGED
@@ -481,7 +481,6 @@ function mc_category_settings_update() {
|
|
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_inverse_color', ( ! empty( $_POST['mc_inverse_color'] ) && 'on' == $_POST['mc_inverse_color'] ) ? 'true' : 'false' );
|
485 |
update_option( 'mc_multiple_categories', ( ! empty( $_POST['mc_multiple_categories'] ) && 'on' == $_POST['mc_multiple_categories'] ) ? 'true' : 'false' );
|
486 |
|
487 |
$message = mc_show_notice( __( 'My Calendar Category Configuration Updated', 'my-calendar' ), false );
|
@@ -523,7 +522,6 @@ function mc_category_settings() {
|
|
523 |
</ul>
|
524 |
</fieldset>
|
525 |
<ul>
|
526 |
-
<li>' . mc_settings_field( 'mc_inverse_color', __( 'Optimize contrast for category colors.', 'my-calendar' ), '', '', array(), 'checkbox-single', false ) . '
|
527 |
<li>' . mc_settings_field( 'mc_hide_icons', __( 'Hide Category icons', 'my-calendar' ), '', '', array(), 'checkbox-single', false ) . '</li>
|
528 |
<li>' . mc_settings_field( 'mc_multiple_categories', __( 'Use multiple categories on events', 'my-calendar' ), '', '', array(), 'checkbox-single', false ) . '</li>
|
529 |
</ul>
|
@@ -713,7 +711,7 @@ function mc_profile() {
|
|
713 |
|
714 |
if ( user_can( $user_edit, 'mc_manage_events' ) && current_user_can( 'manage_options' ) ) {
|
715 |
$permissions = get_user_meta( $user_edit, 'mc_user_permissions', true );
|
716 |
-
$selected = ( empty( $permissions ) || in_array( 'all', $permissions ) ) ? ' checked="checked"' : '';
|
717 |
?>
|
718 |
<h3><?php _e( 'My Calendar Editor Permissions', 'my-calendar' ); ?></h3>
|
719 |
<table class="form-table">
|
@@ -827,11 +825,12 @@ function mc_category_select( $data = false, $option = true, $multiple = false, $
|
|
827 |
$selected = ' checked="checked"';
|
828 |
}
|
829 |
}
|
830 |
-
|
|
|
831 |
if ( $multiple ) {
|
832 |
-
$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 . '">' .
|
833 |
} else {
|
834 |
-
$c = '<option value="' . $cat->category_id . '" ' . $selected . '>' .
|
835 |
}
|
836 |
if ( get_option( 'mc_default_category' ) != $cat->category_id ) {
|
837 |
$list .= $c;
|
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 );
|
522 |
</ul>
|
523 |
</fieldset>
|
524 |
<ul>
|
|
|
525 |
<li>' . mc_settings_field( 'mc_hide_icons', __( 'Hide Category icons', 'my-calendar' ), '', '', array(), 'checkbox-single', false ) . '</li>
|
526 |
<li>' . mc_settings_field( 'mc_multiple_categories', __( 'Use multiple categories on events', 'my-calendar' ), '', '', array(), 'checkbox-single', false ) . '</li>
|
527 |
</ul>
|
711 |
|
712 |
if ( user_can( $user_edit, 'mc_manage_events' ) && current_user_can( 'manage_options' ) ) {
|
713 |
$permissions = get_user_meta( $user_edit, 'mc_user_permissions', true );
|
714 |
+
$selected = ( empty( $permissions ) || in_array( 'all', $permissions ) || user_can( $user_edit, 'manage_options' ) ) ? ' checked="checked"' : '';
|
715 |
?>
|
716 |
<h3><?php _e( 'My Calendar Editor Permissions', 'my-calendar' ); ?></h3>
|
717 |
<table class="form-table">
|
825 |
$selected = ' checked="checked"';
|
826 |
}
|
827 |
}
|
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 |
}
|
835 |
if ( get_option( 'mc_default_category' ) != $cat->category_id ) {
|
836 |
$list .= $c;
|
my-calendar-core.php
CHANGED
@@ -44,7 +44,7 @@ add_action( 'wp_feed_options', 'mc_cache_feeds' );
|
|
44 |
* @return array updated set of links
|
45 |
*/
|
46 |
function mc_plugin_action( $links, $file ) {
|
47 |
-
if ( plugin_basename( dirname( __FILE__ ) . '/my-calendar.php' )
|
48 |
$links[] = '<a href="admin.php?page=my-calendar-config">' . __( 'Settings', 'my-calendar' ) . '</a>';
|
49 |
$links[] = '<a href="admin.php?page=my-calendar-help">' . __( 'Help', 'my-calendar' ) . '</a>';
|
50 |
if ( ! function_exists( 'mcs_submissions' ) ) {
|
@@ -67,10 +67,10 @@ function mc_plugin_action( $links, $file ) {
|
|
67 |
function mc_custom_dirs( $type = 'path' ) {
|
68 |
$dirs = array();
|
69 |
|
70 |
-
$dirs[] = ( 'path'
|
71 |
-
$dirs[] = ( 'path'
|
72 |
-
$dirs[] = ( 'path'
|
73 |
-
$dirs[] = ( 'path'
|
74 |
|
75 |
$directories = apply_filters( 'mc_custom_dirs', $dirs, $type );
|
76 |
|
@@ -113,11 +113,11 @@ function mc_get_file( $file, $type = 'path' ) {
|
|
113 |
$file = sanitize_file_name( $file ); // This will remove slashes as well.
|
114 |
$dir = plugin_dir_path( __FILE__ );
|
115 |
$url = plugin_dir_url( __FILE__ );
|
116 |
-
$path = ( 'path'
|
117 |
|
118 |
foreach ( mc_custom_dirs() as $key => $dir ) {
|
119 |
if ( file_exists( $dir . $file ) ) {
|
120 |
-
if ( 'path'
|
121 |
$path = $dir . $file;
|
122 |
} else {
|
123 |
$urls = mc_custom_dirs( $type );
|
@@ -150,14 +150,14 @@ function mc_register_styles() {
|
|
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 = ( ''
|
154 |
-
$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'
|
161 |
$api_key = get_option( 'mc_gmap_api_key' );
|
162 |
if ( $api_key ) {
|
163 |
wp_enqueue_script( 'gmaps', "https://maps.googleapis.com/maps/api/js?key=$api_key" );
|
@@ -167,8 +167,8 @@ function mc_register_styles() {
|
|
167 |
}
|
168 |
}
|
169 |
// True means styles are disabled.
|
170 |
-
if ( 'true'
|
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 |
}
|
@@ -192,16 +192,16 @@ function mc_register_styles() {
|
|
192 |
function my_calendar_head() {
|
193 |
global $wpdb, $wp_query;
|
194 |
$mcdb = $wpdb;
|
195 |
-
if ( 'true'
|
196 |
$mcdb = mc_remote_db();
|
197 |
}
|
198 |
$array = array();
|
199 |
|
200 |
-
if ( get_option( 'mc_use_styles' )
|
201 |
$this_post = $wp_query->get_queried_object();
|
202 |
$id = ( is_object( $this_post ) && isset( $this_post->ID ) ) ? $this_post->ID : false;
|
203 |
-
$array = ( ''
|
204 |
-
if ( is_array( $array ) && in_array( $id, $array ) || get_option( 'mc_show_css' )
|
205 |
// generate category colors.
|
206 |
$category_styles = '';
|
207 |
$inv = '';
|
@@ -212,20 +212,18 @@ function my_calendar_head() {
|
|
212 |
$class = mc_category_class( $category, 'mc_' );
|
213 |
$hex = ( strpos( $category->category_color, '#' ) !== 0 ) ? '#' : '';
|
214 |
$color = $hex . $category->category_color;
|
215 |
-
if ( '#'
|
216 |
$hcolor = mc_shift_color( $category->category_color );
|
217 |
-
if ( 'font'
|
218 |
$type = 'color';
|
219 |
$alt = 'background';
|
220 |
-
} elseif ( 'background'
|
221 |
$type = 'background';
|
222 |
$alt = 'color';
|
223 |
}
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
}
|
228 |
-
if ( 'font' == get_option( 'mc_apply_color' ) || 'background' == get_option( 'mc_apply_color' ) ) {
|
229 |
// always an anchor as of 1.11.0, apply also to title.
|
230 |
$category_styles .= "\n.mc-main .$class .event-title, .mc-main .$class .event-title a { $type: $color; $inv }";
|
231 |
$category_styles .= "\n.mc-main .$class .event-title a:hover, .mc-main .$class .event-title a:focus { $type: $hcolor;}";
|
@@ -240,7 +238,7 @@ function my_calendar_head() {
|
|
240 |
$style_vars .= sanitize_key( $key ) . ': ' . $var . '; ';
|
241 |
}
|
242 |
}
|
243 |
-
if ( ''
|
244 |
$style_vars = '.mc-main {' . $style_vars . '}';
|
245 |
}
|
246 |
|
@@ -284,7 +282,7 @@ function mc_deal_with_deleted_user( $id ) {
|
|
284 |
* @return string New admin body classes
|
285 |
*/
|
286 |
function mc_admin_body_class( $classes ) {
|
287 |
-
if ( 'true'
|
288 |
$classes .= ' mc-sidebar-footer';
|
289 |
}
|
290 |
|
@@ -295,14 +293,14 @@ function mc_admin_body_class( $classes ) {
|
|
295 |
* Write custom JS in admin head.
|
296 |
*/
|
297 |
function my_calendar_write_js() {
|
298 |
-
if ( isset( $_GET['page'] ) && ( 'my-calendar'
|
299 |
?>
|
300 |
<script>
|
301 |
//<![CDATA[
|
302 |
jQuery(document).ready(function ($) {
|
303 |
$( '#mc-accordion' ).accordion( { collapsible: true, active: false, heightStyle: 'content' } );
|
304 |
<?php
|
305 |
-
if ( function_exists( 'wpt_post_to_twitter' ) && isset( $_GET['page'] ) && 'my-calendar'
|
306 |
?>
|
307 |
var mc_allowed = $( '#mc_twitter' ).attr( 'data-allowed' );
|
308 |
$('#mc_twitter').charCount({
|
@@ -351,7 +349,7 @@ function mc_footer_js() {
|
|
351 |
return;
|
352 |
} else {
|
353 |
$pages = array();
|
354 |
-
if ( get_option( 'mc_show_js' )
|
355 |
$pages = explode( ',', get_option( 'mc_show_js' ) );
|
356 |
}
|
357 |
if ( is_object( $wp_query ) && isset( $wp_query->post ) ) {
|
@@ -359,13 +357,13 @@ function mc_footer_js() {
|
|
359 |
} else {
|
360 |
$id = false;
|
361 |
}
|
362 |
-
if ( 1
|
363 |
$top = '';
|
364 |
$bottom = '';
|
365 |
$inner = '';
|
366 |
$list_js = stripcslashes( get_option( 'mc_listjs' ) );
|
367 |
$cal_js = stripcslashes( get_option( 'mc_caljs' ) );
|
368 |
-
if ( 'true'
|
369 |
// remove sections of javascript if necessary.
|
370 |
$replacements = array(
|
371 |
'$(this).parent().children().not(".event-title").toggle();',
|
@@ -375,13 +373,12 @@ function mc_footer_js() {
|
|
375 |
}
|
376 |
$mini_js = stripcslashes( get_option( 'mc_minijs' ) );
|
377 |
$open_day = get_option( 'mc_open_day_uri' );
|
378 |
-
if ( 'true'
|
379 |
$mini_js = str_replace( 'e.preventDefault();', '', $mini_js );
|
380 |
}
|
381 |
$ajax_js = stripcslashes( get_option( 'mc_ajaxjs' ) );
|
382 |
-
|
383 |
-
if ( ( is_array( $pages ) && in_array( $id, $pages ) ) || ''
|
384 |
-
$inner = '';
|
385 |
if ( get_option( 'mc_calendar_javascript' ) != 1 ) {
|
386 |
$inner .= "\n" . $cal_js;
|
387 |
}
|
@@ -400,11 +397,11 @@ function mc_footer_js() {
|
|
400 |
</script>';
|
401 |
}
|
402 |
$inner = apply_filters( 'mc_filter_javascript_footer', $inner );
|
403 |
-
echo ( ''
|
404 |
} else {
|
405 |
$enqueue_mcjs = false;
|
406 |
-
if ( ( is_array( $pages ) && in_array( $id, $pages ) ) || ''
|
407 |
-
if ( 1 != get_option( 'mc_calendar_javascript' ) && 'true'
|
408 |
$url = apply_filters( 'mc_grid_js', plugins_url( 'js/mc-grid.js', __FILE__ ) );
|
409 |
$enqueue_mcjs = true;
|
410 |
wp_enqueue_script( 'mc.grid', $url, array( 'jquery' ) );
|
@@ -416,7 +413,7 @@ function mc_footer_js() {
|
|
416 |
wp_enqueue_script( 'mc.list', $url, array( 'jquery' ) );
|
417 |
wp_localize_script( 'mc.list', 'mclist', 'true' );
|
418 |
}
|
419 |
-
if ( 1 != get_option( 'mc_mini_javascript' ) && 'true'
|
420 |
$url = apply_filters( 'mc_mini_js', plugins_url( 'js/mc-mini.js', __FILE__ ) );
|
421 |
$enqueue_mcjs = true;
|
422 |
wp_enqueue_script( 'mc.mini', $url, array( 'jquery' ) );
|
@@ -452,7 +449,7 @@ function my_calendar_add_styles() {
|
|
452 |
if ( false !== strpos( $id, 'my-calendar' ) ) {
|
453 |
wp_enqueue_style( 'mc-styles', plugins_url( 'css/mc-styles.css', __FILE__ ) );
|
454 |
|
455 |
-
if ( 'toplevel_page_my-calendar'
|
456 |
wp_enqueue_style( 'mc-pickadate-default', plugins_url( 'js/pickadate/themes/default.css', __FILE__ ) );
|
457 |
wp_enqueue_style( 'mc-pickadate-date', plugins_url( 'js/pickadate/themes/default.date.css', __FILE__ ) );
|
458 |
wp_enqueue_style( 'mc-pickadate-time', plugins_url( 'js/pickadate/themes/default.time.css', __FILE__ ) );
|
@@ -611,7 +608,7 @@ function my_calendar_exists() {
|
|
611 |
$tables = $wpdb->get_results( 'show tables;' );
|
612 |
foreach ( $tables as $table ) {
|
613 |
foreach ( $table as $value ) {
|
614 |
-
if ( my_calendar_table()
|
615 |
// if the table exists, then My Calendar was already installed.
|
616 |
return true;
|
617 |
}
|
@@ -629,13 +626,13 @@ function my_calendar_check() {
|
|
629 |
if ( current_user_can( 'manage_options' ) ) {
|
630 |
global $wpdb, $mc_version;
|
631 |
mc_if_needs_permissions();
|
632 |
-
$current_version = ( ''
|
633 |
if ( version_compare( $current_version, '2.3.12', '>=' ) ) {
|
634 |
// if current is a version higher than 2.3.11, they've already seen this notice and handled it.
|
635 |
update_option( 'mc_update_notice', 1 );
|
636 |
}
|
637 |
// If current version matches, don't bother running this.
|
638 |
-
if ( $current_version
|
639 |
|
640 |
return true;
|
641 |
}
|
@@ -644,9 +641,9 @@ function my_calendar_check() {
|
|
644 |
$upgrade_path = array();
|
645 |
$my_calendar_exists = my_calendar_exists();
|
646 |
|
647 |
-
if ( $my_calendar_exists && ''
|
648 |
// If the table exists, but I don't know what version it is, I have to run the full cycle of upgrades.
|
649 |
-
$current_version = '
|
650 |
}
|
651 |
|
652 |
if ( ! $my_calendar_exists ) {
|
@@ -654,7 +651,7 @@ function my_calendar_check() {
|
|
654 |
} else {
|
655 |
// For each release requiring an upgrade path, add a version compare.
|
656 |
// Loop will run every relevant upgrade cycle.
|
657 |
-
$valid_upgrades = array( '2.
|
658 |
foreach ( $valid_upgrades as $upgrade ) {
|
659 |
if ( version_compare( $current_version, $upgrade, '<' ) ) {
|
660 |
$upgrade_path[] = $upgrade;
|
@@ -664,7 +661,7 @@ function my_calendar_check() {
|
|
664 |
// Having determined upgrade path, assign new version number.
|
665 |
update_option( 'mc_version', $mc_version );
|
666 |
// Now we've determined what the current install is.
|
667 |
-
if ( true
|
668 |
// Add default settings.
|
669 |
mc_default_settings();
|
670 |
mc_create_category(
|
@@ -682,7 +679,7 @@ function my_calendar_check() {
|
|
682 |
* If the user has fully uninstalled the plugin but kept the database of events, this will restore default
|
683 |
* settings and upgrade db if needed.
|
684 |
*/
|
685 |
-
if ( 'true'
|
686 |
mc_default_settings();
|
687 |
update_option( 'mc_db_version', $mc_version );
|
688 |
delete_option( 'mc_uninstalled' );
|
@@ -700,6 +697,10 @@ function mc_do_upgrades( $upgrade_path ) {
|
|
700 |
|
701 |
foreach ( $upgrade_path as $upgrade ) {
|
702 |
switch ( $upgrade ) {
|
|
|
|
|
|
|
|
|
703 |
case '3.0.0':
|
704 |
delete_option( 'mc_event_open' );
|
705 |
delete_option( 'mc_widget_defaults' );
|
@@ -721,7 +722,6 @@ function mc_do_upgrades( $upgrade_path ) {
|
|
721 |
'--highlight-light' => '#efefef',
|
722 |
)
|
723 |
);
|
724 |
-
mc_upgrade_db();
|
725 |
mc_transition_categories();
|
726 |
break;
|
727 |
case '2.4.4': // 8-11-2015 (2.4.0).
|
@@ -743,7 +743,7 @@ function mc_do_upgrades( $upgrade_path ) {
|
|
743 |
case '2.3.0': // 4/10/2014.
|
744 |
delete_option( 'mc_location_control' );
|
745 |
$user_data = get_option( 'mc_user_settings' );
|
746 |
-
$loc_type = ( get_option( 'mc_location_type' )
|
747 |
$locations[ $loc_type ] = $user_data['my_calendar_location_default']['values'];
|
748 |
add_option( 'mc_use_permalinks', false );
|
749 |
delete_option( 'mc_modified_feeds' );
|
@@ -759,15 +759,6 @@ function mc_do_upgrades( $upgrade_path ) {
|
|
759 |
delete_option( 'mc_show_rss' );
|
760 |
delete_option( 'mc_draggable' );
|
761 |
delete_option( 'mc_caching_enabled' ); // remove caching support via options. Filter only.
|
762 |
-
add_option( 'mc_inverse_color', 'true' );
|
763 |
-
break;
|
764 |
-
case '2.0.0': // 11/20/2012 (2.0.12).
|
765 |
-
mc_migrate_db();
|
766 |
-
$mc_input = get_option( 'mc_input_options' );
|
767 |
-
if ( ! isset( $mc_input['event_specials'] ) ) {
|
768 |
-
$mc_input['event_specials'] = 'on';
|
769 |
-
update_option( 'mc_input_options', $mc_input );
|
770 |
-
}
|
771 |
break;
|
772 |
default:
|
773 |
break;
|
@@ -781,7 +772,7 @@ add_action( 'admin_bar_menu', 'my_calendar_admin_bar', 200 );
|
|
781 |
*/
|
782 |
function my_calendar_admin_bar() {
|
783 |
global $wp_admin_bar;
|
784 |
-
if ( current_user_can( 'mc_add_events' ) && 'true'
|
785 |
$url = apply_filters( 'mc_add_events_url', admin_url( 'admin.php?page=my-calendar' ) );
|
786 |
$args = array(
|
787 |
'id' => 'mc-add-event',
|
@@ -858,14 +849,14 @@ function my_calendar_send_email( $event ) {
|
|
858 |
$details = mc_create_tags( $event );
|
859 |
$headers = array();
|
860 |
// shift to boolean.
|
861 |
-
$send_email_option = ( 'true'
|
862 |
$send_email = apply_filters( 'mc_send_notification', $send_email_option, $details );
|
863 |
-
if ( true
|
864 |
add_filter( 'wp_mail_content_type', 'mc_html_type' );
|
865 |
}
|
866 |
-
if ( 'true'
|
867 |
$to = apply_filters( 'mc_event_mail_to', get_option( 'mc_event_mail_to' ), $details );
|
868 |
-
$from = ( ''
|
869 |
$from = apply_filters( 'mc_event_mail_from', $from, $details );
|
870 |
$headers[] = 'From: ' . __( 'Event Notifications', 'my-calendar' ) . " <$from>";
|
871 |
$bcc = apply_filters( 'mc_event_mail_bcc', get_option( 'mc_event_mail_bcc' ), $details );
|
@@ -885,7 +876,7 @@ function my_calendar_send_email( $event ) {
|
|
885 |
$message = mc_draw_template( $details, $body );
|
886 |
wp_mail( $to, $subject, $message, $headers );
|
887 |
}
|
888 |
-
if ( 'true'
|
889 |
remove_filter( 'wp_mail_content_type', 'mc_html_type' );
|
890 |
}
|
891 |
}
|
@@ -939,7 +930,7 @@ function mc_spam( $event_url = '', $description = '', $post = array() ) {
|
|
939 |
} else {
|
940 |
$response = akismet_http_post( $query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port );
|
941 |
}
|
942 |
-
if ( 'true'
|
943 |
return 1;
|
944 |
} else {
|
945 |
return 0;
|
@@ -977,7 +968,8 @@ add_action( 'admin_enqueue_scripts', 'mc_scripts' );
|
|
977 |
*/
|
978 |
function mc_scripts() {
|
979 |
global $current_screen;
|
980 |
-
$id
|
|
|
981 |
|
982 |
if ( false !== strpos( $id, 'my-calendar' ) ) {
|
983 |
wp_enqueue_script( 'mc.admin', plugins_url( 'js/jquery.admin.js', __FILE__ ), array( 'jquery', 'jquery-ui-sortable' ) );
|
@@ -985,11 +977,11 @@ function mc_scripts() {
|
|
985 |
wp_localize_script( 'mc.admin', 'draftText', __( 'Save Draft', 'my-calendar' ) );
|
986 |
}
|
987 |
|
988 |
-
if ( 'toplevel_page_my-calendar'
|
989 |
wp_enqueue_script( 'jquery-ui-accordion' );
|
990 |
}
|
991 |
|
992 |
-
if ( 'toplevel_page_my-calendar'
|
993 |
wp_enqueue_script( 'jquery-ui-autocomplete' ); // required for character counting.
|
994 |
wp_enqueue_script( 'pickadate', plugins_url( 'js/pickadate/picker.js', __FILE__ ), array( 'jquery' ) );
|
995 |
wp_enqueue_script( 'pickadate.date', plugins_url( 'js/pickadate/picker.date.js', __FILE__ ), array( 'pickadate' ) );
|
@@ -1035,7 +1027,7 @@ function mc_scripts() {
|
|
1035 |
'clear' => addslashes( __( 'Clear', 'my-calendar' ) ),
|
1036 |
'close' => addslashes( __( 'Close', 'my-calendar' ) ),
|
1037 |
// False-y values = Sunday, truth-y = Monday.
|
1038 |
-
'start' => ( 1
|
1039 |
),
|
1040 |
)
|
1041 |
);
|
@@ -1047,7 +1039,7 @@ function mc_scripts() {
|
|
1047 |
wp_enqueue_media();
|
1048 |
}
|
1049 |
}
|
1050 |
-
if ( '
|
1051 |
$api_key = get_option( 'mc_gmap_api_key' );
|
1052 |
if ( $api_key ) {
|
1053 |
wp_enqueue_script( 'gmaps', "https://maps.googleapis.com/maps/api/js?key=$api_key" );
|
@@ -1055,10 +1047,10 @@ function mc_scripts() {
|
|
1055 |
}
|
1056 |
}
|
1057 |
|
1058 |
-
if ( 'toplevel_page_my-calendar'
|
1059 |
wp_enqueue_script( 'charCount', plugins_url( 'wp-to-twitter/js/jquery.charcount.js' ), array( 'jquery' ) );
|
1060 |
}
|
1061 |
-
if ( 'toplevel_page_my-calendar'
|
1062 |
if ( current_user_can( 'mc_manage_events' ) ) {
|
1063 |
wp_enqueue_script( 'mc.ajax', plugins_url( 'js/ajax.js', __FILE__ ), array( 'jquery' ) );
|
1064 |
wp_localize_script(
|
@@ -1073,7 +1065,7 @@ function mc_scripts() {
|
|
1073 |
}
|
1074 |
}
|
1075 |
|
1076 |
-
if ( '
|
1077 |
wp_enqueue_script( 'jquery-ui-autocomplete' );
|
1078 |
wp_enqueue_script(
|
1079 |
'mc.suggest',
|
@@ -1086,7 +1078,7 @@ function mc_scripts() {
|
|
1086 |
wp_localize_script( 'mc.suggest', 'mc_ajax_action', 'mc_post_lookup' );
|
1087 |
}
|
1088 |
|
1089 |
-
if ( '
|
1090 |
wp_enqueue_style( 'wp-color-picker' );
|
1091 |
// Switch to wp_add_inline_script when no longer supporting WP 4.4.x.
|
1092 |
wp_enqueue_script( 'mc-color-picker', plugins_url( 'js/color-picker.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
|
@@ -1218,7 +1210,7 @@ function mc_ajax_add_date() {
|
|
1218 |
}
|
1219 |
|
1220 |
$begin = strtotime( $event_date . ' ' . $event_time );
|
1221 |
-
$end = ( ''
|
1222 |
|
1223 |
$format = array( '%d', '%s', '%s', '%d' );
|
1224 |
$data = array(
|
@@ -1287,9 +1279,13 @@ function mc_is_tablet() {
|
|
1287 |
/**
|
1288 |
* As of version 3.0.0, this only checks for 'my-calendar', to see if this plug-in already exists.
|
1289 |
*
|
1290 |
-
* @return
|
1291 |
*/
|
1292 |
function mc_guess_calendar() {
|
|
|
|
|
|
|
|
|
1293 |
global $wpdb;
|
1294 |
$has_uri = mc_get_uri( 'boolean' );
|
1295 |
$current = mc_get_uri();
|
@@ -1297,9 +1293,9 @@ function mc_guess_calendar() {
|
|
1297 |
if ( $has_uri && esc_url( $current ) ) {
|
1298 |
$response = wp_remote_head( $current );
|
1299 |
if ( ! is_wp_error( $response ) ) {
|
1300 |
-
$http = $response['response']['code'];
|
1301 |
// Only modify the value if it's explicitly missing. Redirects or secured pages are fine.
|
1302 |
-
if ( 404
|
1303 |
$current = '';
|
1304 |
}
|
1305 |
}
|
@@ -1340,7 +1336,7 @@ function mc_guess_calendar() {
|
|
1340 |
}
|
1341 |
}
|
1342 |
|
1343 |
-
return;
|
1344 |
}
|
1345 |
|
1346 |
/**
|
@@ -1356,9 +1352,9 @@ function mc_get_support_form() {
|
|
1356 |
$mc_css = get_option( 'mc_css_file' );
|
1357 |
|
1358 |
// Pro license status.
|
1359 |
-
$license = ( ''
|
1360 |
$license_valid = get_option( 'mcs_license_key_valid' );
|
1361 |
-
$checked = ( 'valid'
|
1362 |
|
1363 |
if ( $license ) {
|
1364 |
$license = "
|
@@ -1434,12 +1430,12 @@ $plugins_string
|
|
1434 |
wp_die( 'Security check failed' );
|
1435 |
}
|
1436 |
$request = ( ! empty( $_POST['support_request'] ) ) ? stripslashes( $_POST['support_request'] ) : false;
|
1437 |
-
$has_read_faq = ( 'on'
|
1438 |
$subject = 'My Calendar Pro support request.';
|
1439 |
$message = $request . "\n\n" . $data;
|
1440 |
// Get the site domain and get rid of www. from pluggable.php.
|
1441 |
$sitename = strtolower( $_SERVER['SERVER_NAME'] );
|
1442 |
-
if ( 'www.'
|
1443 |
$sitename = substr( $sitename, 4 );
|
1444 |
}
|
1445 |
$from_email = 'wordpress@' . $sitename;
|
@@ -1452,7 +1448,7 @@ $plugins_string
|
|
1452 |
} else {
|
1453 |
$sent = wp_mail( 'plugins@joedolson.com', $subject, $message, $from );
|
1454 |
if ( $sent ) {
|
1455 |
-
if ( 'Donor'
|
1456 |
mc_show_notice( __( 'Thank you for supporting the continuing development of this plug-in! I\'ll get back to you as soon as I can.', 'my-calendar' ) );
|
1457 |
} else {
|
1458 |
mc_show_notice( __( 'I\'ll get back to you as soon as I can, after dealing with any support requests from plug-in supporters.', 'my-calendar' ) . __( 'You should receive an automatic response to your request when I receive it. If you do not receive this notice, then either I did not receive your message or the email it was sent from was not a valid address.', 'my-calendar' ) );
|
@@ -1530,7 +1526,7 @@ function mc_load_permalinks() {
|
|
1530 |
* Custom field callback for permalinks settings
|
1531 |
*/
|
1532 |
function mc_field_callback() {
|
1533 |
-
$value = ( ''
|
1534 |
echo '<input type="text" value="' . esc_attr( $value ) . '" name="mc_cpt_base" id="mc_cpt_base" class="regular-text" />';
|
1535 |
}
|
1536 |
|
@@ -1541,7 +1537,10 @@ function mc_post_type() {
|
|
1541 |
$arguments = array(
|
1542 |
'public' => apply_filters( 'mc_event_posts_public', true ),
|
1543 |
'publicly_queryable' => true,
|
1544 |
-
|
|
|
|
|
|
|
1545 |
'show_ui' => true,
|
1546 |
'show_in_menu' => apply_filters( 'mc_show_custom_posts_in_menu', false ),
|
1547 |
'menu_icon' => null,
|
@@ -1565,7 +1564,7 @@ function mc_post_type() {
|
|
1565 |
function mc_posttypes() {
|
1566 |
$types = mc_post_type();
|
1567 |
$enabled = array( 'mc-events' );
|
1568 |
-
$slug = ( ''
|
1569 |
if ( is_array( $enabled ) ) {
|
1570 |
foreach ( $enabled as $key ) {
|
1571 |
$value =& $types[ $key ];
|
@@ -1618,8 +1617,8 @@ function mc_close_comments( $posts ) {
|
|
1618 |
return $posts;
|
1619 |
}
|
1620 |
|
1621 |
-
if ( 'mc-events'
|
1622 |
-
if ( apply_filters( 'mc_autoclose_comments', true ) && 'closed'
|
1623 |
$posts[0]->comment_status = 'closed';
|
1624 |
$posts[0]->ping_status = 'closed';
|
1625 |
wp_update_post( $posts[0] );
|
@@ -1718,7 +1717,7 @@ add_action( 'admin_init', 'mc_dismiss_notice' );
|
|
1718 |
* Dismiss admin notices
|
1719 |
*/
|
1720 |
function mc_dismiss_notice() {
|
1721 |
-
if ( isset( $_GET['dismiss'] ) && 'update'
|
1722 |
update_option( 'mc_update_notice', 1 );
|
1723 |
}
|
1724 |
}
|
@@ -1735,7 +1734,7 @@ function mc_update_notice() {
|
|
1735 |
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>';
|
1736 |
}
|
1737 |
if ( current_user_can( 'manage_options' ) && isset( $_GET['page'] ) && stripos( $_GET['page'], 'my-calendar' ) !== false ) {
|
1738 |
-
if ( 'true'
|
1739 |
mc_show_notice( __( 'My Calendar is configured to retrieve events from a remote source.', 'my-calendar' ) . ' <a href="' . admin_url( 'admin.php?page=my-calendar-config' ) . '">' . __( 'Update Settings', 'my-calendar' ) . '</a>' );
|
1740 |
}
|
1741 |
}
|
@@ -1812,7 +1811,7 @@ function my_calendar_privacy_export( $email_address, $page = 1 ) {
|
|
1812 |
);
|
1813 |
}
|
1814 |
foreach ( $meta as $mkey => $mvalue ) {
|
1815 |
-
if ( false !== stripos( $mkey, '_mt_' ) || '_mc_event_data'
|
1816 |
continue;
|
1817 |
}
|
1818 |
// Omit empty values.
|
@@ -1887,7 +1886,7 @@ function my_calendar_privacy_eraser( $email_address, $page = 1 ) {
|
|
1887 |
// for deletion, if *author*, delete; if *host*, change host.
|
1888 |
$calendar = $wpdb->get_results( $wpdb->prepare( 'SELECT event_id, event_host, event_author FROM ' . my_calendar_table() . ' WHERE event_host = %d OR event_author = %d', $user_ID, $user_ID ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
1889 |
foreach ( $calendar as $obj ) {
|
1890 |
-
if ( $user_ID
|
1891 |
$updates[] = array( $obj->event_id, $obj->event_author );
|
1892 |
} else {
|
1893 |
$deletions[] = $obj->event_id;
|
44 |
* @return array updated set of links
|
45 |
*/
|
46 |
function mc_plugin_action( $links, $file ) {
|
47 |
+
if ( plugin_basename( dirname( __FILE__ ) . '/my-calendar.php' ) === $file ) {
|
48 |
$links[] = '<a href="admin.php?page=my-calendar-config">' . __( 'Settings', 'my-calendar' ) . '</a>';
|
49 |
$links[] = '<a href="admin.php?page=my-calendar-help">' . __( 'Help', 'my-calendar' ) . '</a>';
|
50 |
if ( ! function_exists( 'mcs_submissions' ) ) {
|
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 |
|
75 |
$directories = apply_filters( 'mc_custom_dirs', $dirs, $type );
|
76 |
|
113 |
$file = sanitize_file_name( $file ); // This will remove slashes as well.
|
114 |
$dir = plugin_dir_path( __FILE__ );
|
115 |
$url = plugin_dir_url( __FILE__ );
|
116 |
+
$path = ( 'path' === $type ) ? $dir . $file : $url . $file;
|
117 |
|
118 |
foreach ( mc_custom_dirs() as $key => $dir ) {
|
119 |
if ( file_exists( $dir . $file ) ) {
|
120 |
+
if ( 'path' === $type ) {
|
121 |
$path = $dir . $file;
|
122 |
} else {
|
123 |
$urls = mc_custom_dirs( $type );
|
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' );
|
162 |
if ( $api_key ) {
|
163 |
wp_enqueue_script( 'gmaps', "https://maps.googleapis.com/maps/api/js?key=$api_key" );
|
167 |
}
|
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 |
}
|
192 |
function my_calendar_head() {
|
193 |
global $wpdb, $wp_query;
|
194 |
$mcdb = $wpdb;
|
195 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
196 |
$mcdb = mc_remote_db();
|
197 |
}
|
198 |
$array = array();
|
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 = '';
|
212 |
$class = mc_category_class( $category, 'mc_' );
|
213 |
$hex = ( strpos( $category->category_color, '#' ) !== 0 ) ? '#' : '';
|
214 |
$color = $hex . $category->category_color;
|
215 |
+
if ( '#' !== $color ) {
|
216 |
$hcolor = mc_shift_color( $category->category_color );
|
217 |
+
if ( 'font' === get_option( 'mc_apply_color' ) ) {
|
218 |
$type = 'color';
|
219 |
$alt = 'background';
|
220 |
+
} elseif ( 'background' === get_option( 'mc_apply_color' ) ) {
|
221 |
$type = 'background';
|
222 |
$alt = 'color';
|
223 |
}
|
224 |
+
$inverse = mc_inverse_color( $color );
|
225 |
+
$inv = "$alt: $inverse;";
|
226 |
+
if ( 'font' === get_option( 'mc_apply_color' ) || 'background' === get_option( 'mc_apply_color' ) ) {
|
|
|
|
|
227 |
// always an anchor as of 1.11.0, apply also to title.
|
228 |
$category_styles .= "\n.mc-main .$class .event-title, .mc-main .$class .event-title a { $type: $color; $inv }";
|
229 |
$category_styles .= "\n.mc-main .$class .event-title a:hover, .mc-main .$class .event-title a:focus { $type: $hcolor;}";
|
238 |
$style_vars .= sanitize_key( $key ) . ': ' . $var . '; ';
|
239 |
}
|
240 |
}
|
241 |
+
if ( '' !== $style_vars ) {
|
242 |
$style_vars = '.mc-main {' . $style_vars . '}';
|
243 |
}
|
244 |
|
282 |
* @return string New admin body classes
|
283 |
*/
|
284 |
function mc_admin_body_class( $classes ) {
|
285 |
+
if ( 'true' === get_option( 'mc_sidebar_footer' ) ) {
|
286 |
$classes .= ' mc-sidebar-footer';
|
287 |
}
|
288 |
|
293 |
* Write custom JS in admin head.
|
294 |
*/
|
295 |
function my_calendar_write_js() {
|
296 |
+
if ( isset( $_GET['page'] ) && ( 'my-calendar' === $_GET['page'] || 'my-calendar-locations' === $_GET['page'] ) ) {
|
297 |
?>
|
298 |
<script>
|
299 |
//<![CDATA[
|
300 |
jQuery(document).ready(function ($) {
|
301 |
$( '#mc-accordion' ).accordion( { collapsible: true, active: false, heightStyle: 'content' } );
|
302 |
<?php
|
303 |
+
if ( function_exists( 'wpt_post_to_twitter' ) && isset( $_GET['page'] ) && 'my-calendar' === $_GET['page'] ) {
|
304 |
?>
|
305 |
var mc_allowed = $( '#mc_twitter' ).attr( 'data-allowed' );
|
306 |
$('#mc_twitter').charCount({
|
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 ) ) {
|
357 |
} else {
|
358 |
$id = false;
|
359 |
}
|
360 |
+
if ( '1' === get_option( 'mc_use_custom_js' ) ) {
|
361 |
$top = '';
|
362 |
$bottom = '';
|
363 |
$inner = '';
|
364 |
$list_js = stripcslashes( get_option( 'mc_listjs' ) );
|
365 |
$cal_js = stripcslashes( get_option( 'mc_caljs' ) );
|
366 |
+
if ( 'true' === get_option( 'mc_open_uri' ) ) {
|
367 |
// remove sections of javascript if necessary.
|
368 |
$replacements = array(
|
369 |
'$(this).parent().children().not(".event-title").toggle();',
|
373 |
}
|
374 |
$mini_js = stripcslashes( get_option( 'mc_minijs' ) );
|
375 |
$open_day = get_option( 'mc_open_day_uri' );
|
376 |
+
if ( 'true' === $open_day || 'listanchor' === $open_day || 'calendaranchor' === $open_day ) {
|
377 |
$mini_js = str_replace( 'e.preventDefault();', '', $mini_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 |
}
|
397 |
</script>';
|
398 |
}
|
399 |
$inner = apply_filters( 'mc_filter_javascript_footer', $inner );
|
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' ) );
|
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' ) );
|
449 |
if ( false !== strpos( $id, 'my-calendar' ) ) {
|
450 |
wp_enqueue_style( 'mc-styles', plugins_url( 'css/mc-styles.css', __FILE__ ) );
|
451 |
|
452 |
+
if ( 'toplevel_page_my-calendar' === $id ) {
|
453 |
wp_enqueue_style( 'mc-pickadate-default', plugins_url( 'js/pickadate/themes/default.css', __FILE__ ) );
|
454 |
wp_enqueue_style( 'mc-pickadate-date', plugins_url( 'js/pickadate/themes/default.date.css', __FILE__ ) );
|
455 |
wp_enqueue_style( 'mc-pickadate-time', plugins_url( 'js/pickadate/themes/default.time.css', __FILE__ ) );
|
608 |
$tables = $wpdb->get_results( 'show tables;' );
|
609 |
foreach ( $tables as $table ) {
|
610 |
foreach ( $table as $value ) {
|
611 |
+
if ( my_calendar_table() === $value ) {
|
612 |
// if the table exists, then My Calendar was already installed.
|
613 |
return true;
|
614 |
}
|
626 |
if ( current_user_can( 'manage_options' ) ) {
|
627 |
global $wpdb, $mc_version;
|
628 |
mc_if_needs_permissions();
|
629 |
+
$current_version = ( '' === get_option( 'mc_version', '' ) ) ? get_option( 'my_calendar_version' ) : get_option( 'mc_version' );
|
630 |
if ( version_compare( $current_version, '2.3.12', '>=' ) ) {
|
631 |
// if current is a version higher than 2.3.11, they've already seen this notice and handled it.
|
632 |
update_option( 'mc_update_notice', 1 );
|
633 |
}
|
634 |
// If current version matches, don't bother running this.
|
635 |
+
if ( $current_version === $mc_version ) {
|
636 |
|
637 |
return true;
|
638 |
}
|
641 |
$upgrade_path = array();
|
642 |
$my_calendar_exists = my_calendar_exists();
|
643 |
|
644 |
+
if ( $my_calendar_exists && '' === $current_version ) {
|
645 |
// If the table exists, but I don't know what version it is, I have to run the full cycle of upgrades.
|
646 |
+
$current_version = '2.2.9';
|
647 |
}
|
648 |
|
649 |
if ( ! $my_calendar_exists ) {
|
651 |
} else {
|
652 |
// For each release requiring an upgrade path, add a version compare.
|
653 |
// Loop will run every relevant upgrade cycle.
|
654 |
+
$valid_upgrades = array( '2.2.10', '2.3.0', '2.3.11', '2.3.15', '2.4.4', '3.0.0', '3.1.13' );
|
655 |
foreach ( $valid_upgrades as $upgrade ) {
|
656 |
if ( version_compare( $current_version, $upgrade, '<' ) ) {
|
657 |
$upgrade_path[] = $upgrade;
|
661 |
// Having determined upgrade path, assign new version number.
|
662 |
update_option( 'mc_version', $mc_version );
|
663 |
// Now we've determined what the current install is.
|
664 |
+
if ( true === $new_install ) {
|
665 |
// Add default settings.
|
666 |
mc_default_settings();
|
667 |
mc_create_category(
|
679 |
* If the user has fully uninstalled the plugin but kept the database of events, this will restore default
|
680 |
* settings and upgrade db if needed.
|
681 |
*/
|
682 |
+
if ( 'true' === get_option( 'mc_uninstalled' ) ) {
|
683 |
mc_default_settings();
|
684 |
update_option( 'mc_db_version', $mc_version );
|
685 |
delete_option( 'mc_uninstalled' );
|
697 |
|
698 |
foreach ( $upgrade_path as $upgrade ) {
|
699 |
switch ( $upgrade ) {
|
700 |
+
case '3.1.13':
|
701 |
+
delete_option( 'mc_inverse_color' );
|
702 |
+
mc_upgrade_db();
|
703 |
+
break;
|
704 |
case '3.0.0':
|
705 |
delete_option( 'mc_event_open' );
|
706 |
delete_option( 'mc_widget_defaults' );
|
722 |
'--highlight-light' => '#efefef',
|
723 |
)
|
724 |
);
|
|
|
725 |
mc_transition_categories();
|
726 |
break;
|
727 |
case '2.4.4': // 8-11-2015 (2.4.0).
|
743 |
case '2.3.0': // 4/10/2014.
|
744 |
delete_option( 'mc_location_control' );
|
745 |
$user_data = get_option( 'mc_user_settings' );
|
746 |
+
$loc_type = ( get_option( 'mc_location_type', '' ) === '' ) ? 'event_state' : get_option( 'mc_location_type' );
|
747 |
$locations[ $loc_type ] = $user_data['my_calendar_location_default']['values'];
|
748 |
add_option( 'mc_use_permalinks', false );
|
749 |
delete_option( 'mc_modified_feeds' );
|
759 |
delete_option( 'mc_show_rss' );
|
760 |
delete_option( 'mc_draggable' );
|
761 |
delete_option( 'mc_caching_enabled' ); // remove caching support via options. Filter only.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
762 |
break;
|
763 |
default:
|
764 |
break;
|
772 |
*/
|
773 |
function my_calendar_admin_bar() {
|
774 |
global $wp_admin_bar;
|
775 |
+
if ( current_user_can( 'mc_add_events' ) && 'true' !== get_option( 'mc_remote' ) ) {
|
776 |
$url = apply_filters( 'mc_add_events_url', admin_url( 'admin.php?page=my-calendar' ) );
|
777 |
$args = array(
|
778 |
'id' => 'mc-add-event',
|
849 |
$details = mc_create_tags( $event );
|
850 |
$headers = array();
|
851 |
// shift to boolean.
|
852 |
+
$send_email_option = ( 'true' === get_option( 'mc_event_mail' ) ) ? true : false;
|
853 |
$send_email = apply_filters( 'mc_send_notification', $send_email_option, $details );
|
854 |
+
if ( true === $send_email ) {
|
855 |
add_filter( 'wp_mail_content_type', 'mc_html_type' );
|
856 |
}
|
857 |
+
if ( 'true' === get_option( 'mc_event_mail' ) ) {
|
858 |
$to = apply_filters( 'mc_event_mail_to', get_option( 'mc_event_mail_to' ), $details );
|
859 |
+
$from = ( '' === get_option( 'mc_event_mail_from', '' ) ) ? get_bloginfo( 'admin_email' ) : get_option( 'mc_event_mail_from' );
|
860 |
$from = apply_filters( 'mc_event_mail_from', $from, $details );
|
861 |
$headers[] = 'From: ' . __( 'Event Notifications', 'my-calendar' ) . " <$from>";
|
862 |
$bcc = apply_filters( 'mc_event_mail_bcc', get_option( 'mc_event_mail_bcc' ), $details );
|
876 |
$message = mc_draw_template( $details, $body );
|
877 |
wp_mail( $to, $subject, $message, $headers );
|
878 |
}
|
879 |
+
if ( 'true' === get_option( 'mc_html_email' ) ) {
|
880 |
remove_filter( 'wp_mail_content_type', 'mc_html_type' );
|
881 |
}
|
882 |
}
|
930 |
} else {
|
931 |
$response = akismet_http_post( $query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port );
|
932 |
}
|
933 |
+
if ( 'true' === $response[1] ) {
|
934 |
return 1;
|
935 |
} else {
|
936 |
return 0;
|
968 |
*/
|
969 |
function mc_scripts() {
|
970 |
global $current_screen;
|
971 |
+
$id = $current_screen->id;
|
972 |
+
$slug = sanitize_title( __( 'My Calendar', 'my-calendar' ) );
|
973 |
|
974 |
if ( false !== strpos( $id, 'my-calendar' ) ) {
|
975 |
wp_enqueue_script( 'mc.admin', plugins_url( 'js/jquery.admin.js', __FILE__ ), array( 'jquery', 'jquery-ui-sortable' ) );
|
977 |
wp_localize_script( 'mc.admin', 'draftText', __( 'Save Draft', 'my-calendar' ) );
|
978 |
}
|
979 |
|
980 |
+
if ( 'toplevel_page_my-calendar' === $id || $slug . '_my-calendar-groups' === $id || $slug . '_page_my-calendar-locations' === $id ) {
|
981 |
wp_enqueue_script( 'jquery-ui-accordion' );
|
982 |
}
|
983 |
|
984 |
+
if ( 'toplevel_page_my-calendar' === $id || $slug . '_page_my-calendar-groups' === $id ) {
|
985 |
wp_enqueue_script( 'jquery-ui-autocomplete' ); // required for character counting.
|
986 |
wp_enqueue_script( 'pickadate', plugins_url( 'js/pickadate/picker.js', __FILE__ ), array( 'jquery' ) );
|
987 |
wp_enqueue_script( 'pickadate.date', plugins_url( 'js/pickadate/picker.date.js', __FILE__ ), array( 'pickadate' ) );
|
1027 |
'clear' => addslashes( __( 'Clear', 'my-calendar' ) ),
|
1028 |
'close' => addslashes( __( 'Close', 'my-calendar' ) ),
|
1029 |
// False-y values = Sunday, truth-y = Monday.
|
1030 |
+
'start' => ( 1 === $sweek || 0 === $sweek ) ? $sweek : 0,
|
1031 |
),
|
1032 |
)
|
1033 |
);
|
1039 |
wp_enqueue_media();
|
1040 |
}
|
1041 |
}
|
1042 |
+
if ( $slug . '_page_my-calendar-locations' === $id || 'toplevel_page_my-calendar' === $id ) {
|
1043 |
$api_key = get_option( 'mc_gmap_api_key' );
|
1044 |
if ( $api_key ) {
|
1045 |
wp_enqueue_script( 'gmaps', "https://maps.googleapis.com/maps/api/js?key=$api_key" );
|
1047 |
}
|
1048 |
}
|
1049 |
|
1050 |
+
if ( 'toplevel_page_my-calendar' === $id && function_exists( 'wpt_post_to_twitter' ) ) {
|
1051 |
wp_enqueue_script( 'charCount', plugins_url( 'wp-to-twitter/js/jquery.charcount.js' ), array( 'jquery' ) );
|
1052 |
}
|
1053 |
+
if ( 'toplevel_page_my-calendar' === $id ) {
|
1054 |
if ( current_user_can( 'mc_manage_events' ) ) {
|
1055 |
wp_enqueue_script( 'mc.ajax', plugins_url( 'js/ajax.js', __FILE__ ), array( 'jquery' ) );
|
1056 |
wp_localize_script(
|
1065 |
}
|
1066 |
}
|
1067 |
|
1068 |
+
if ( $slug . '_page_my-calendar-config' === $id ) {
|
1069 |
wp_enqueue_script( 'jquery-ui-autocomplete' );
|
1070 |
wp_enqueue_script(
|
1071 |
'mc.suggest',
|
1078 |
wp_localize_script( 'mc.suggest', 'mc_ajax_action', 'mc_post_lookup' );
|
1079 |
}
|
1080 |
|
1081 |
+
if ( $slug . '_page_my-calendar-categories' === $id ) {
|
1082 |
wp_enqueue_style( 'wp-color-picker' );
|
1083 |
// Switch to wp_add_inline_script when no longer supporting WP 4.4.x.
|
1084 |
wp_enqueue_script( 'mc-color-picker', plugins_url( 'js/color-picker.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
|
1210 |
}
|
1211 |
|
1212 |
$begin = strtotime( $event_date . ' ' . $event_time );
|
1213 |
+
$end = ( '' !== $event_endtime ) ? strtotime( $event_end . ' ' . $event_endtime ) : strtotime( $event_end . ' ' . $event_time ) + HOUR_IN_SECONDS;
|
1214 |
|
1215 |
$format = array( '%d', '%s', '%s', '%d' );
|
1216 |
$data = array(
|
1279 |
/**
|
1280 |
* As of version 3.0.0, this only checks for 'my-calendar', to see if this plug-in already exists.
|
1281 |
*
|
1282 |
+
* @return array
|
1283 |
*/
|
1284 |
function mc_guess_calendar() {
|
1285 |
+
$return = array(
|
1286 |
+
'response' => false,
|
1287 |
+
'message' => __( 'Calendar query was not able to run.', 'my-calendar' ),
|
1288 |
+
);
|
1289 |
global $wpdb;
|
1290 |
$has_uri = mc_get_uri( 'boolean' );
|
1291 |
$current = mc_get_uri();
|
1293 |
if ( $has_uri && esc_url( $current ) ) {
|
1294 |
$response = wp_remote_head( $current );
|
1295 |
if ( ! is_wp_error( $response ) ) {
|
1296 |
+
$http = (string) $response['response']['code'];
|
1297 |
// Only modify the value if it's explicitly missing. Redirects or secured pages are fine.
|
1298 |
+
if ( '404' === $http ) {
|
1299 |
$current = '';
|
1300 |
}
|
1301 |
}
|
1336 |
}
|
1337 |
}
|
1338 |
|
1339 |
+
return $return;
|
1340 |
}
|
1341 |
|
1342 |
/**
|
1352 |
$mc_css = get_option( 'mc_css_file' );
|
1353 |
|
1354 |
// Pro license status.
|
1355 |
+
$license = ( '' !== get_option( 'mcs_license_key', '' ) ) ? get_option( 'mcs_license_key' ) : '';
|
1356 |
$license_valid = get_option( 'mcs_license_key_valid' );
|
1357 |
+
$checked = ( 'valid' === $license_valid ) ? true : false;
|
1358 |
|
1359 |
if ( $license ) {
|
1360 |
$license = "
|
1430 |
wp_die( 'Security check failed' );
|
1431 |
}
|
1432 |
$request = ( ! empty( $_POST['support_request'] ) ) ? stripslashes( $_POST['support_request'] ) : false;
|
1433 |
+
$has_read_faq = ( 'on' === $_POST['has_read_faq'] ) ? 'Read FAQ' : false;
|
1434 |
$subject = 'My Calendar Pro support request.';
|
1435 |
$message = $request . "\n\n" . $data;
|
1436 |
// Get the site domain and get rid of www. from pluggable.php.
|
1437 |
$sitename = strtolower( $_SERVER['SERVER_NAME'] );
|
1438 |
+
if ( 'www.' === substr( $sitename, 0, 4 ) ) {
|
1439 |
$sitename = substr( $sitename, 4 );
|
1440 |
}
|
1441 |
$from_email = 'wordpress@' . $sitename;
|
1448 |
} else {
|
1449 |
$sent = wp_mail( 'plugins@joedolson.com', $subject, $message, $from );
|
1450 |
if ( $sent ) {
|
1451 |
+
if ( 'Donor' === $has_donated || 'Purchaser' === $has_purchased ) {
|
1452 |
mc_show_notice( __( 'Thank you for supporting the continuing development of this plug-in! I\'ll get back to you as soon as I can.', 'my-calendar' ) );
|
1453 |
} else {
|
1454 |
mc_show_notice( __( 'I\'ll get back to you as soon as I can, after dealing with any support requests from plug-in supporters.', 'my-calendar' ) . __( 'You should receive an automatic response to your request when I receive it. If you do not receive this notice, then either I did not receive your message or the email it was sent from was not a valid address.', 'my-calendar' ) );
|
1526 |
* Custom field callback for permalinks settings
|
1527 |
*/
|
1528 |
function mc_field_callback() {
|
1529 |
+
$value = ( '' !== get_option( 'mc_cpt_base', '' ) ) ? get_option( 'mc_cpt_base' ) : 'mc-events';
|
1530 |
echo '<input type="text" value="' . esc_attr( $value ) . '" name="mc_cpt_base" id="mc_cpt_base" class="regular-text" />';
|
1531 |
}
|
1532 |
|
1537 |
$arguments = array(
|
1538 |
'public' => apply_filters( 'mc_event_posts_public', true ),
|
1539 |
'publicly_queryable' => true,
|
1540 |
+
// WARNING: Allowing the post type to be searchable will not provide a true event search, especially with respect to recurring events.
|
1541 |
+
// It will not search recurring events by date, only the post content from each event. Enable only if requirements for search are limited to post content.
|
1542 |
+
// Details: https://github.com/joedolson/my-calendar/issues/23.
|
1543 |
+
'exclude_from_search' => apply_filters( 'mc_event_exclude_from_search', true ),
|
1544 |
'show_ui' => true,
|
1545 |
'show_in_menu' => apply_filters( 'mc_show_custom_posts_in_menu', false ),
|
1546 |
'menu_icon' => null,
|
1564 |
function mc_posttypes() {
|
1565 |
$types = mc_post_type();
|
1566 |
$enabled = array( 'mc-events' );
|
1567 |
+
$slug = ( '' !== get_option( 'mc_cpt_base', '' ) ) ? get_option( 'mc_cpt_base' ) : 'mc-events';
|
1568 |
if ( is_array( $enabled ) ) {
|
1569 |
foreach ( $enabled as $key ) {
|
1570 |
$value =& $types[ $key ];
|
1617 |
return $posts;
|
1618 |
}
|
1619 |
|
1620 |
+
if ( 'mc-events' === get_post_type( $posts[0]->ID ) ) {
|
1621 |
+
if ( apply_filters( 'mc_autoclose_comments', true ) && 'closed' !== $posts[0]->comment_status ) {
|
1622 |
$posts[0]->comment_status = 'closed';
|
1623 |
$posts[0]->ping_status = 'closed';
|
1624 |
wp_update_post( $posts[0] );
|
1717 |
* Dismiss admin notices
|
1718 |
*/
|
1719 |
function mc_dismiss_notice() {
|
1720 |
+
if ( isset( $_GET['dismiss'] ) && 'update' === $_GET['dismiss'] ) {
|
1721 |
update_option( 'mc_update_notice', 1 );
|
1722 |
}
|
1723 |
}
|
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>';
|
1735 |
}
|
1736 |
if ( current_user_can( 'manage_options' ) && isset( $_GET['page'] ) && stripos( $_GET['page'], 'my-calendar' ) !== false ) {
|
1737 |
+
if ( 'true' === get_option( 'mc_remote' ) ) {
|
1738 |
mc_show_notice( __( 'My Calendar is configured to retrieve events from a remote source.', 'my-calendar' ) . ' <a href="' . admin_url( 'admin.php?page=my-calendar-config' ) . '">' . __( 'Update Settings', 'my-calendar' ) . '</a>' );
|
1739 |
}
|
1740 |
}
|
1811 |
);
|
1812 |
}
|
1813 |
foreach ( $meta as $mkey => $mvalue ) {
|
1814 |
+
if ( false !== stripos( $mkey, '_mt_' ) || '_mc_event_data' === $mkey || '_mc_event_desc' === $mkey ) {
|
1815 |
continue;
|
1816 |
}
|
1817 |
// Omit empty values.
|
1886 |
// for deletion, if *author*, delete; if *host*, change host.
|
1887 |
$calendar = $wpdb->get_results( $wpdb->prepare( 'SELECT event_id, event_host, event_author FROM ' . my_calendar_table() . ' WHERE event_host = %d OR event_author = %d', $user_ID, $user_ID ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
1888 |
foreach ( $calendar as $obj ) {
|
1889 |
+
if ( absint( $user_ID ) === absint( $obj->event_host ) && absint( $obj->event_host ) !== absint( $obj->event_author ) ) {
|
1890 |
$updates[] = array( $obj->event_id, $obj->event_author );
|
1891 |
} else {
|
1892 |
$deletions[] = $obj->event_id;
|
my-calendar-event-manager.php
CHANGED
@@ -1690,7 +1690,7 @@ function mc_form_fields( $data, $mode, $event_id ) {
|
|
1690 |
}
|
1691 |
if ( mc_show_edit_block( 'event_specials' ) ) {
|
1692 |
$hol_checked = ( 'true' == get_option( 'mc_skip_holidays' ) ) ? ' checked="checked"' : '';
|
1693 |
-
$fifth_checked = ( 'true'
|
1694 |
if ( $has_data ) {
|
1695 |
$hol_checked = ( '1' == $data->event_holiday ) ? ' checked="checked"' : '';
|
1696 |
$fifth_checked = ( '1' == $data->event_fifth_week ) ? ' checked="checked"' : '';
|
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"' : '';
|
1696 |
$fifth_checked = ( '1' == $data->event_fifth_week ) ? ' checked="checked"' : '';
|
my-calendar-events.php
CHANGED
@@ -79,16 +79,16 @@ function my_calendar_get_events( $args ) {
|
|
79 |
|
80 |
global $wpdb;
|
81 |
$mcdb = $wpdb;
|
82 |
-
if ( 'true'
|
83 |
$mcdb = mc_remote_db();
|
84 |
}
|
85 |
|
86 |
-
if ( 'holidays'
|
87 |
return array();
|
88 |
}
|
89 |
|
90 |
if ( null === $holidays ) {
|
91 |
-
$ccategory = ( isset( $_GET['mcat'] ) && ''
|
92 |
} else {
|
93 |
$ccategory = $category;
|
94 |
}
|
@@ -98,7 +98,7 @@ function my_calendar_get_events( $args ) {
|
|
98 |
$clhost = ( isset( $_GET['mc_host'] ) ) ? $_GET['mc_host'] : $host;
|
99 |
|
100 |
// If location value is not set, then location type shouldn't be set.
|
101 |
-
if ( 'all'
|
102 |
$cltype = 'all';
|
103 |
}
|
104 |
|
@@ -106,11 +106,11 @@ function my_calendar_get_events( $args ) {
|
|
106 |
return array();
|
107 |
} // Not valid dates.
|
108 |
|
109 |
-
$cat_limit = ( 'all'
|
110 |
$join = ( isset( $cat_limit[0] ) ) ? $cat_limit[0] : '';
|
111 |
$select_category = ( isset( $cat_limit[1] ) ) ? $cat_limit[1] : '';
|
112 |
-
$select_author = ( 'all'
|
113 |
-
$select_host = ( 'all'
|
114 |
$select_location = mc_select_location( $cltype, $clvalue );
|
115 |
$select_access = ( isset( $_GET['access'] ) ) ? mc_access_limit( $_GET['access'] ) : '';
|
116 |
$select_published = mc_select_published();
|
@@ -188,19 +188,19 @@ function mc_get_all_events( $args ) {
|
|
188 |
|
189 |
global $wpdb;
|
190 |
$mcdb = $wpdb;
|
191 |
-
if ( 'true'
|
192 |
$mcdb = mc_remote_db();
|
193 |
}
|
194 |
|
195 |
$exclude_categories = mc_private_categories();
|
196 |
-
$cat_limit = ( 'default'
|
197 |
$join = ( isset( $cat_limit[0] ) ) ? $cat_limit[0] : '';
|
198 |
$select_category = ( isset( $cat_limit[1] ) ) ? $cat_limit[1] : '';
|
199 |
$select_location = mc_select_location( $ltype, $lvalue );
|
200 |
$select_access = ( isset( $_GET['access'] ) ) ? mc_access_limit( $_GET['access'] ) : '';
|
201 |
$select_published = mc_select_published();
|
202 |
-
$select_author = ( 'default'
|
203 |
-
$select_host = ( 'default'
|
204 |
$date = date( 'Y-m-d', current_time( 'timestamp' ) );
|
205 |
|
206 |
$limit = "$select_published $select_category $select_author $select_host $select_location $select_access $search";
|
@@ -226,7 +226,7 @@ function mc_get_all_events( $args ) {
|
|
226 |
);
|
227 |
}
|
228 |
// Events happening today.
|
229 |
-
if ( 'yes'
|
230 |
$events3 = $mcdb->get_results(
|
231 |
'SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end
|
232 |
FROM ' . my_calendar_event_table( $site ) . '
|
@@ -315,7 +315,7 @@ function mc_get_all_holidays( $before, $after, $today ) {
|
|
315 |
function mc_get_rss_events( $cat_id = false ) {
|
316 |
global $wpdb;
|
317 |
$mcdb = $wpdb;
|
318 |
-
if ( 'true'
|
319 |
$mcdb = mc_remote_db();
|
320 |
}
|
321 |
if ( $cat_id ) {
|
@@ -372,7 +372,7 @@ function mc_get_search_results( $search ) {
|
|
372 |
global $wpdb;
|
373 |
$mcdb = $wpdb;
|
374 |
$event_array = array();
|
375 |
-
if ( 'true'
|
376 |
$mcdb = mc_remote_db();
|
377 |
}
|
378 |
$before = apply_filters( 'mc_past_search_results', 0 );
|
@@ -439,7 +439,7 @@ function mc_get_event_core( $id, $rebuild = false ) {
|
|
439 |
|
440 |
global $wpdb;
|
441 |
$mcdb = $wpdb;
|
442 |
-
if ( 'true'
|
443 |
$mcdb = mc_remote_db();
|
444 |
}
|
445 |
|
@@ -463,7 +463,7 @@ function mc_get_event_core( $id, $rebuild = false ) {
|
|
463 |
function mc_get_first_event( $id ) {
|
464 |
global $wpdb;
|
465 |
$mcdb = $wpdb;
|
466 |
-
if ( 'true'
|
467 |
$mcdb = mc_remote_db();
|
468 |
}
|
469 |
$event = $mcdb->get_row( $wpdb->prepare( 'SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end FROM ' . my_calendar_event_table() . ' JOIN ' . my_calendar_table() . ' ON (event_id=occur_event_id) JOIN ' . my_calendar_categories_table() . ' ON (event_category=category_id) WHERE occur_event_id=%d', $id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
@@ -482,7 +482,7 @@ function mc_get_first_event( $id ) {
|
|
482 |
function mc_get_nearest_event( $id ) {
|
483 |
global $wpdb;
|
484 |
$mcdb = $wpdb;
|
485 |
-
if ( 'true'
|
486 |
$mcdb = mc_remote_db();
|
487 |
}
|
488 |
$event = $mcdb->get_row( $wpdb->prepare( 'SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end FROM ' . my_calendar_event_table() . ' JOIN ' . my_calendar_table() . ' ON (event_id=occur_event_id) JOIN ' . my_calendar_categories_table() . ' ON (event_category=category_id) WHERE occur_event_id=%d ORDER BY ABS( DATEDIFF( occur_begin, NOW() ) )', $id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
@@ -506,11 +506,11 @@ function mc_get_event( $id, $type = 'object' ) {
|
|
506 |
|
507 |
global $wpdb;
|
508 |
$mcdb = $wpdb;
|
509 |
-
if ( 'true'
|
510 |
$mcdb = mc_remote_db();
|
511 |
}
|
512 |
$event = $mcdb->get_row( $wpdb->prepare( 'SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end FROM ' . my_calendar_event_table() . ' JOIN ' . my_calendar_table() . ' ON (event_id=occur_event_id) JOIN ' . my_calendar_categories_table() . ' ON (event_category=category_id) WHERE occur_id=%d', $id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
513 |
-
if ( 'object'
|
514 |
$event = mc_event_object( $event );
|
515 |
return $event;
|
516 |
} else {
|
@@ -535,7 +535,7 @@ function mc_get_event( $id, $type = 'object' ) {
|
|
535 |
function mc_get_data( $field, $id ) {
|
536 |
global $wpdb;
|
537 |
$mcdb = $wpdb;
|
538 |
-
if ( 'true'
|
539 |
$mcdb = mc_remote_db();
|
540 |
}
|
541 |
$result = $mcdb->get_var( $mcdb->prepare( "SELECT $field FROM " . my_calendar_table() . ' WHERE event_id = %d', $id ) );
|
@@ -554,15 +554,18 @@ function mc_get_data( $field, $id ) {
|
|
554 |
* @return array Array of event objects with dates as keys.
|
555 |
*/
|
556 |
function my_calendar_events( $args ) {
|
557 |
-
$args
|
558 |
-
$events
|
559 |
-
$event_array
|
560 |
-
|
|
|
561 |
// Get holidays to filter out.
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
|
|
|
|
566 |
// Get events into an easily parseable set, keyed by date.
|
567 |
if ( is_array( $events ) && ! empty( $events ) ) {
|
568 |
$event_array = mc_set_date_array( $events );
|
@@ -585,19 +588,19 @@ function my_calendar_events( $args ) {
|
|
585 |
*/
|
586 |
function my_calendar_events_now( $category = 'default', $template = '<strong>{link_title}</strong> {timerange}', $site = false ) {
|
587 |
if ( $site ) {
|
588 |
-
$site = ( 'global'
|
589 |
switch_to_blog( $site );
|
590 |
}
|
591 |
|
592 |
global $wpdb;
|
593 |
$mcdb = $wpdb;
|
594 |
-
if ( 'true'
|
595 |
$mcdb = mc_remote_db();
|
596 |
}
|
597 |
|
598 |
$arr_events = array();
|
599 |
$select_published = mc_select_published();
|
600 |
-
$cat_limit = ( 'default'
|
601 |
$join = ( isset( $cat_limit[0] ) ) ? $cat_limit[0] : '';
|
602 |
$select_category = ( isset( $cat_limit[1] ) ) ? $cat_limit[1] : '';
|
603 |
$exclude_categories = mc_private_categories();
|
@@ -688,7 +691,7 @@ function mc_get_related( $id ) {
|
|
688 |
* @return boolean
|
689 |
*/
|
690 |
function mc_is_preview() {
|
691 |
-
if ( isset( $_GET['preview'] ) && 'true'
|
692 |
return true;
|
693 |
}
|
694 |
|
@@ -730,7 +733,7 @@ function mc_set_date_array( $events ) {
|
|
730 |
foreach ( $events as $event ) {
|
731 |
$date = date( 'Y-m-d', strtotime( $event->occur_begin ) );
|
732 |
$end = date( 'Y-m-d', strtotime( $event->occur_end ) );
|
733 |
-
if ( $date
|
734 |
$start = strtotime( $date );
|
735 |
$end = strtotime( $end );
|
736 |
do {
|
@@ -778,14 +781,14 @@ function mc_get_db_type() {
|
|
778 |
global $wpdb;
|
779 |
$mcdb = $wpdb;
|
780 |
$db_type = 'MyISAM';
|
781 |
-
if ( 'true'
|
782 |
$mcdb = mc_remote_db();
|
783 |
}
|
784 |
$my_calendar = my_calendar_table();
|
785 |
$dbs = $mcdb->get_results( $wpdb->prepare( 'SHOW TABLE STATUS WHERE name=%s', $my_calendar ) );
|
786 |
foreach ( $dbs as $db ) {
|
787 |
$db = (array) $db;
|
788 |
-
if ( my_calendar_table()
|
789 |
$db_type = $db['Engine'];
|
790 |
}
|
791 |
}
|
79 |
|
80 |
global $wpdb;
|
81 |
$mcdb = $wpdb;
|
82 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
83 |
$mcdb = mc_remote_db();
|
84 |
}
|
85 |
|
86 |
+
if ( 'holidays' === $holidays && '' === $category ) {
|
87 |
return array();
|
88 |
}
|
89 |
|
90 |
if ( null === $holidays ) {
|
91 |
+
$ccategory = ( isset( $_GET['mcat'] ) && '' !== trim( $_GET['mcat'] ) ) ? $_GET['mcat'] : $category;
|
92 |
} else {
|
93 |
$ccategory = $category;
|
94 |
}
|
98 |
$clhost = ( isset( $_GET['mc_host'] ) ) ? $_GET['mc_host'] : $host;
|
99 |
|
100 |
// If location value is not set, then location type shouldn't be set.
|
101 |
+
if ( 'all' === $clvalue ) {
|
102 |
$cltype = 'all';
|
103 |
}
|
104 |
|
106 |
return array();
|
107 |
} // Not valid dates.
|
108 |
|
109 |
+
$cat_limit = ( 'all' !== $ccategory ) ? mc_select_category( $ccategory ) : array();
|
110 |
$join = ( isset( $cat_limit[0] ) ) ? $cat_limit[0] : '';
|
111 |
$select_category = ( isset( $cat_limit[1] ) ) ? $cat_limit[1] : '';
|
112 |
+
$select_author = ( 'all' !== $clauth ) ? mc_select_author( $clauth ) : '';
|
113 |
+
$select_host = ( 'all' !== $clhost ) ? mc_select_host( $clhost ) : '';
|
114 |
$select_location = mc_select_location( $cltype, $clvalue );
|
115 |
$select_access = ( isset( $_GET['access'] ) ) ? mc_access_limit( $_GET['access'] ) : '';
|
116 |
$select_published = mc_select_published();
|
188 |
|
189 |
global $wpdb;
|
190 |
$mcdb = $wpdb;
|
191 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
192 |
$mcdb = mc_remote_db();
|
193 |
}
|
194 |
|
195 |
$exclude_categories = mc_private_categories();
|
196 |
+
$cat_limit = ( 'default' !== $category ) ? mc_select_category( $category ) : array();
|
197 |
$join = ( isset( $cat_limit[0] ) ) ? $cat_limit[0] : '';
|
198 |
$select_category = ( isset( $cat_limit[1] ) ) ? $cat_limit[1] : '';
|
199 |
$select_location = mc_select_location( $ltype, $lvalue );
|
200 |
$select_access = ( isset( $_GET['access'] ) ) ? mc_access_limit( $_GET['access'] ) : '';
|
201 |
$select_published = mc_select_published();
|
202 |
+
$select_author = ( 'default' !== $author ) ? mc_select_author( $author ) : '';
|
203 |
+
$select_host = ( 'default' !== $host ) ? mc_select_host( $host ) : '';
|
204 |
$date = date( 'Y-m-d', current_time( 'timestamp' ) );
|
205 |
|
206 |
$limit = "$select_published $select_category $select_author $select_host $select_location $select_access $search";
|
226 |
);
|
227 |
}
|
228 |
// Events happening today.
|
229 |
+
if ( 'yes' === $today ) {
|
230 |
$events3 = $mcdb->get_results(
|
231 |
'SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end
|
232 |
FROM ' . my_calendar_event_table( $site ) . '
|
315 |
function mc_get_rss_events( $cat_id = false ) {
|
316 |
global $wpdb;
|
317 |
$mcdb = $wpdb;
|
318 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
319 |
$mcdb = mc_remote_db();
|
320 |
}
|
321 |
if ( $cat_id ) {
|
372 |
global $wpdb;
|
373 |
$mcdb = $wpdb;
|
374 |
$event_array = array();
|
375 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
376 |
$mcdb = mc_remote_db();
|
377 |
}
|
378 |
$before = apply_filters( 'mc_past_search_results', 0 );
|
439 |
|
440 |
global $wpdb;
|
441 |
$mcdb = $wpdb;
|
442 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
443 |
$mcdb = mc_remote_db();
|
444 |
}
|
445 |
|
463 |
function mc_get_first_event( $id ) {
|
464 |
global $wpdb;
|
465 |
$mcdb = $wpdb;
|
466 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
467 |
$mcdb = mc_remote_db();
|
468 |
}
|
469 |
$event = $mcdb->get_row( $wpdb->prepare( 'SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end FROM ' . my_calendar_event_table() . ' JOIN ' . my_calendar_table() . ' ON (event_id=occur_event_id) JOIN ' . my_calendar_categories_table() . ' ON (event_category=category_id) WHERE occur_event_id=%d', $id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
482 |
function mc_get_nearest_event( $id ) {
|
483 |
global $wpdb;
|
484 |
$mcdb = $wpdb;
|
485 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
486 |
$mcdb = mc_remote_db();
|
487 |
}
|
488 |
$event = $mcdb->get_row( $wpdb->prepare( 'SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end FROM ' . my_calendar_event_table() . ' JOIN ' . my_calendar_table() . ' ON (event_id=occur_event_id) JOIN ' . my_calendar_categories_table() . ' ON (event_category=category_id) WHERE occur_event_id=%d ORDER BY ABS( DATEDIFF( occur_begin, NOW() ) )', $id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
506 |
|
507 |
global $wpdb;
|
508 |
$mcdb = $wpdb;
|
509 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
510 |
$mcdb = mc_remote_db();
|
511 |
}
|
512 |
$event = $mcdb->get_row( $wpdb->prepare( 'SELECT *, UNIX_TIMESTAMP(occur_begin) AS ts_occur_begin, UNIX_TIMESTAMP(occur_end) AS ts_occur_end FROM ' . my_calendar_event_table() . ' JOIN ' . my_calendar_table() . ' ON (event_id=occur_event_id) JOIN ' . my_calendar_categories_table() . ' ON (event_category=category_id) WHERE occur_id=%d', $id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
513 |
+
if ( 'object' === $type ) {
|
514 |
$event = mc_event_object( $event );
|
515 |
return $event;
|
516 |
} else {
|
535 |
function mc_get_data( $field, $id ) {
|
536 |
global $wpdb;
|
537 |
$mcdb = $wpdb;
|
538 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
539 |
$mcdb = mc_remote_db();
|
540 |
}
|
541 |
$result = $mcdb->get_var( $mcdb->prepare( "SELECT $field FROM " . my_calendar_table() . ' WHERE event_id = %d', $id ) );
|
554 |
* @return array Array of event objects with dates as keys.
|
555 |
*/
|
556 |
function my_calendar_events( $args ) {
|
557 |
+
$args = apply_filters( 'my_calendar_events_args', $args );
|
558 |
+
$events = my_calendar_get_events( $args );
|
559 |
+
$event_array = array();
|
560 |
+
$holiday_array = array();
|
561 |
+
$holidays = array();
|
562 |
// Get holidays to filter out.
|
563 |
+
if ( get_option( 'mc_skip_holidays_category' ) ) {
|
564 |
+
$args['category'] = get_option( 'mc_skip_holidays_category' );
|
565 |
+
$args['holidays'] = 'holidays';
|
566 |
+
$holidays = my_calendar_get_events( $args );
|
567 |
+
$holiday_array = mc_set_date_array( $holidays );
|
568 |
+
}
|
569 |
// Get events into an easily parseable set, keyed by date.
|
570 |
if ( is_array( $events ) && ! empty( $events ) ) {
|
571 |
$event_array = mc_set_date_array( $events );
|
588 |
*/
|
589 |
function my_calendar_events_now( $category = 'default', $template = '<strong>{link_title}</strong> {timerange}', $site = false ) {
|
590 |
if ( $site ) {
|
591 |
+
$site = ( 'global' === $site ) ? BLOG_ID_CURRENT_SITE : $site;
|
592 |
switch_to_blog( $site );
|
593 |
}
|
594 |
|
595 |
global $wpdb;
|
596 |
$mcdb = $wpdb;
|
597 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
598 |
$mcdb = mc_remote_db();
|
599 |
}
|
600 |
|
601 |
$arr_events = array();
|
602 |
$select_published = mc_select_published();
|
603 |
+
$cat_limit = ( 'default' !== $category ) ? mc_select_category( $category ) : array();
|
604 |
$join = ( isset( $cat_limit[0] ) ) ? $cat_limit[0] : '';
|
605 |
$select_category = ( isset( $cat_limit[1] ) ) ? $cat_limit[1] : '';
|
606 |
$exclude_categories = mc_private_categories();
|
691 |
* @return boolean
|
692 |
*/
|
693 |
function mc_is_preview() {
|
694 |
+
if ( isset( $_GET['preview'] ) && 'true' === $_GET['preview'] && current_user_can( 'mc_manage_events' ) ) {
|
695 |
return true;
|
696 |
}
|
697 |
|
733 |
foreach ( $events as $event ) {
|
734 |
$date = date( 'Y-m-d', strtotime( $event->occur_begin ) );
|
735 |
$end = date( 'Y-m-d', strtotime( $event->occur_end ) );
|
736 |
+
if ( $date !== $end ) {
|
737 |
$start = strtotime( $date );
|
738 |
$end = strtotime( $end );
|
739 |
do {
|
781 |
global $wpdb;
|
782 |
$mcdb = $wpdb;
|
783 |
$db_type = 'MyISAM';
|
784 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
785 |
$mcdb = mc_remote_db();
|
786 |
}
|
787 |
$my_calendar = my_calendar_table();
|
788 |
$dbs = $mcdb->get_results( $wpdb->prepare( 'SHOW TABLE STATUS WHERE name=%s', $my_calendar ) );
|
789 |
foreach ( $dbs as $db ) {
|
790 |
$db = (array) $db;
|
791 |
+
if ( my_calendar_table() === $db['Name'] ) {
|
792 |
$db_type = $db['Engine'];
|
793 |
}
|
794 |
}
|
my-calendar-generator.php
CHANGED
@@ -241,6 +241,10 @@ function mc_generator( $type ) {
|
|
241 |
<label for="months" id='lmonths'><?php _e( 'Months to show in list view', 'my-calendar' ); ?></label>
|
242 |
<input type="number" min="1" max="12" step="1" name="months" id="lmonths" value="" /><br/>
|
243 |
</p>
|
|
|
|
|
|
|
|
|
244 |
<?php
|
245 |
}
|
246 |
if ( 'upcoming' == $type || 'today' == $type ) {
|
241 |
<label for="months" id='lmonths'><?php _e( 'Months to show in list view', 'my-calendar' ); ?></label>
|
242 |
<input type="number" min="1" max="12" step="1" name="months" id="lmonths" value="" /><br/>
|
243 |
</p>
|
244 |
+
<p>
|
245 |
+
<label for="search" id='sterm'><?php _e( 'Search keyword', 'my-calendar' ); ?></label>
|
246 |
+
<input type="text" name="search" id="sterm" value="" /><br/>
|
247 |
+
</p>
|
248 |
<?php
|
249 |
}
|
250 |
if ( 'upcoming' == $type || 'today' == $type ) {
|
my-calendar-group-manager.php
CHANGED
@@ -24,7 +24,7 @@ function my_calendar_group_edit() {
|
|
24 |
$group_id = ! empty( $_POST['group_id'] ) ? $_POST['group_id'] : '';
|
25 |
|
26 |
if ( isset( $_GET['mode'] ) ) {
|
27 |
-
if ( 'edit'
|
28 |
$action = 'edit';
|
29 |
$event_id = (int) $_GET['event_id'];
|
30 |
$group_id = (int) $_GET['group_id'];
|
@@ -91,7 +91,7 @@ function my_calendar_group_edit() {
|
|
91 |
<div class="wrap my-calendar-admin" id="my-calendar">
|
92 |
<?php
|
93 |
my_calendar_check_db();
|
94 |
-
if ( 'edit'
|
95 |
echo '<h1>' . __( 'Edit Event Group', 'my-calendar' ) . '</h1>';
|
96 |
if ( empty( $event_id ) || empty( $group_id ) ) {
|
97 |
mc_show_error( __( 'You must provide an event group id in order to edit it', 'my-calendar' ) );
|
@@ -146,7 +146,7 @@ function my_calendar_save_group( $action, $output, $event_id = false ) {
|
|
146 |
$proceed = $output[0];
|
147 |
$message = '';
|
148 |
|
149 |
-
if ( 'edit'
|
150 |
$event_author = (int) ( $_POST['event_author'] );
|
151 |
if ( mc_can_edit_event( $event_id ) ) {
|
152 |
$update = $output[2];
|
@@ -189,7 +189,7 @@ function my_calendar_save_group( $action, $output, $event_id = false ) {
|
|
189 |
function mc_group_data( $event_id = false ) {
|
190 |
global $wpdb, $submission;
|
191 |
if ( false !== $event_id ) {
|
192 |
-
if ( intval( $event_id )
|
193 |
return mc_show_error( __( 'Sorry! That\'s an invalid event key.', 'my-calendar' ), false );
|
194 |
} else {
|
195 |
$data = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . my_calendar_table() . ' WHERE event_id=%d LIMIT 1', $event_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
@@ -230,7 +230,7 @@ function mc_compare_group_members( $group_id, $field = false ) {
|
|
230 |
$count = count( $results );
|
231 |
for ( $i = 0; $i < $count; $i ++ ) {
|
232 |
$n = ( ( $i + 1 ) > $count - 1 ) ? 0 : $i + 1;
|
233 |
-
if ( md5( implode( '', $results[ $i ] ) )
|
234 |
return false;
|
235 |
}
|
236 |
}
|
@@ -251,28 +251,28 @@ function mc_group_form( $group_id, $type = 'break' ) {
|
|
251 |
$event_id = (int) $_GET['event_id'];
|
252 |
$nonce = wp_create_nonce( 'my-calendar-nonce' );
|
253 |
$results = $wpdb->get_results( $wpdb->prepare( 'SELECT event_id, event_begin, event_time FROM ' . my_calendar_table() . ' WHERE event_group_id = %d', $group_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
254 |
-
if ( 'apply'
|
255 |
$warning = ( ! mc_compare_group_members( $group_id ) ) ? '<p class="warning">' . __( '<strong>NOTE:</strong> The group editable fields for the events in this group do not match', 'my-calendar' ) . '</p>' : '<p class="matched">' . __( 'The group editable fields for the events in this group match.', 'my-calendar' ) . '</p>';
|
256 |
} else {
|
257 |
$warning = '';
|
258 |
}
|
259 |
-
$class = ( 'break'
|
260 |
$group = "<div class='group $class'>";
|
261 |
$group .= $warning;
|
262 |
-
$group .= ( 'apply'
|
263 |
-
$group .= ( 'break'
|
264 |
<div><input type='hidden' value='" . esc_attr( $group_id ) . "' name='group_id' /><input type='hidden' value='" . esc_attr( $type ) . "' name='event_action' /><input type='hidden' name='_wpnonce' value='$nonce' />
|
265 |
</div>" : '';
|
266 |
$group .= "<ul class='checkboxes'>";
|
267 |
-
$checked = ( 'apply'
|
268 |
foreach ( $results as $result ) {
|
269 |
$date = date_i18n( 'D, j M, Y', strtotime( $result->event_begin ) );
|
270 |
$time = date_i18n( 'g:i a', strtotime( $result->event_time ) );
|
271 |
$group .= "<li><input type='checkbox' name='$type" . "[]' value='$result->event_id' id='$type$result->event_id'$checked /> <label for='break$result->event_id'><a href='#event$result->event_id'>#$result->event_id</a>: $date; $time</label></li>\n";
|
272 |
}
|
273 |
$group .= "<li><input type='checkbox' class='selectall' id='$type'$checked /> <label for='$type'><b>" . __( 'Check/Uncheck all', 'my-calendar' ) . "</b></label></li>\n</ul>";
|
274 |
-
$group .= ( 'apply'
|
275 |
-
$group .= ( 'break'
|
276 |
$group .= '</div>';
|
277 |
|
278 |
return $group;
|
@@ -318,7 +318,7 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
|
|
318 |
$current_user = wp_get_current_user();
|
319 |
$has_data = ( empty( $data ) ) ? false : true;
|
320 |
$user = get_userdata( $user_ID );
|
321 |
-
$input_all = ( get_option( 'mc_input_options_administrators' )
|
322 |
$mc_input = get_option( 'mc_input_options' );
|
323 |
$group_id = ( ! empty( $data->event_group_id ) ) ? $data->event_group_id : mc_group_id();
|
324 |
$title = '';
|
@@ -368,7 +368,7 @@ 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'
|
372 |
$span_checked = '';
|
373 |
if ( ! empty( $data ) && 1 == $data->event_span ) {
|
374 |
$span_checked = ' checked="checked"';
|
@@ -393,7 +393,7 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
|
|
393 |
<div><input type='hidden' name='event_span' value='<?php echo esc_attr( $data->event_span ); ?>'/></div>
|
394 |
<?php
|
395 |
}
|
396 |
-
if ( 'on'
|
397 |
?>
|
398 |
<div id="group_description">
|
399 |
<label for="content">
|
@@ -408,7 +408,7 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
|
|
408 |
</div>
|
409 |
<?php
|
410 |
}
|
411 |
-
if ( 'on'
|
412 |
?>
|
413 |
<p>
|
414 |
<label for="e_short">
|
@@ -478,20 +478,20 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
|
|
478 |
} elseif ( is_object( $u ) && $u->ID == $user->ID && empty( $data->event_host ) ) {
|
479 |
echo ' selected="selected"';
|
480 |
}
|
481 |
-
$display_name = ( ''
|
482 |
echo ">$display_name</option>\n";
|
483 |
}
|
484 |
?>
|
485 |
</select>
|
486 |
</p>
|
487 |
<?php
|
488 |
-
if ( 'on'
|
489 |
$match = '';
|
490 |
if ( ! mc_compare_group_members( $group_id, 'event_category' ) ) {
|
491 |
$match = ' <span class="nomatch">' . __( 'Fields do not match', 'my-calendar' ) . '</span>';
|
492 |
}
|
493 |
|
494 |
-
if ( 'true'
|
495 |
$select = mc_category_select( $data, true, false );
|
496 |
$return = '<p class="mc_category"><label for="event_category">' . __( 'Category', 'my-calendar-submissions' ) . $match . '</label><select class="widefat" name="event_category" id="e_category">' . $select . '</select></p>';
|
497 |
} else {
|
@@ -506,12 +506,12 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
|
|
506 |
</div>
|
507 |
<?php
|
508 |
}
|
509 |
-
if ( 'on'
|
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'
|
515 |
$exp_checked = ' checked="checked"';
|
516 |
}
|
517 |
?>
|
@@ -535,7 +535,7 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
|
|
535 |
</div>
|
536 |
</div>
|
537 |
<?php
|
538 |
-
if ( 'on'
|
539 |
?>
|
540 |
<div class="ui-sortable meta-box-sortables">
|
541 |
<div class="postbox">
|
@@ -558,7 +558,7 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
|
|
558 |
</div>
|
559 |
<?php
|
560 |
}
|
561 |
-
if ( ( 'on'
|
562 |
?>
|
563 |
<div class="ui-sortable meta-box-sortables">
|
564 |
<div class="postbox">
|
@@ -569,7 +569,7 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
|
|
569 |
<legend><?php _e( 'Event Location', 'my-calendar' ); ?></legend>
|
570 |
<?php
|
571 |
}
|
572 |
-
if ( 'on'
|
573 |
$locations = mc_get_locations( 'group-manager' );
|
574 |
if ( ! empty( $locations ) ) {
|
575 |
?>
|
@@ -596,7 +596,7 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
|
|
596 |
} else {
|
597 |
echo '<input type="hidden" name="location_preset" value="none"/>';
|
598 |
}
|
599 |
-
if ( 'on'
|
600 |
?>
|
601 |
<p>
|
602 |
<label for="e_label">
|
@@ -769,7 +769,7 @@ function my_calendar_print_group_fields( $data, $mode, $event_id, $group_id = ''
|
|
769 |
</fieldset>
|
770 |
<?php
|
771 |
}
|
772 |
-
if ( ( 'on'
|
773 |
?>
|
774 |
</fieldset>
|
775 |
</div>
|
@@ -806,7 +806,7 @@ function mc_check_group_data( $action, $post ) {
|
|
806 |
return '';
|
807 |
}
|
808 |
$errors = '';
|
809 |
-
if ( 'add'
|
810 |
$title = ! empty( $post['event_title'] ) ? trim( $post['event_title'] ) : '';
|
811 |
$desc = ! empty( $post['content'] ) ? trim( $post['content'] ) : '';
|
812 |
$short = ! empty( $post['event_short'] ) ? trim( $post['event_short'] ) : '';
|
@@ -837,7 +837,7 @@ function mc_check_group_data( $action, $post ) {
|
|
837 |
$event_image = esc_url_raw( $post['event_image'] );
|
838 |
$event_span = ! empty( $post['event_span'] ) ? 1 : 0;
|
839 |
// Set location.
|
840 |
-
if ( 'none'
|
841 |
$location = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . my_calendar_locations_table() . ' WHERE location_id = %d', $location_preset ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
842 |
$event_label = $location->location_label;
|
843 |
$event_street = $location->location_street;
|
@@ -916,7 +916,7 @@ function mc_check_group_data( $action, $post ) {
|
|
916 |
|
917 |
$submit = array_map( 'mc_kses_post', $submit );
|
918 |
|
919 |
-
if ( 'edit'
|
920 |
unset( $submit['event_author'] );
|
921 |
}
|
922 |
$data = array( $proceed, false, $submit, $errors );
|
@@ -935,7 +935,7 @@ function mc_list_groups() {
|
|
935 |
|
936 |
$sortby = ( isset( $_GET['sort'] ) ) ? (int) $_GET['sort'] : get_option( 'mc_default_sort' );
|
937 |
if ( isset( $_GET['order'] ) ) {
|
938 |
-
$sortdir = ( isset( $_GET['order'] ) && 'ASC'
|
939 |
} else {
|
940 |
$sortdir = 'default';
|
941 |
}
|
@@ -971,8 +971,8 @@ function mc_list_groups() {
|
|
971 |
$sortbyvalue = 'event_begin';
|
972 |
}
|
973 |
}
|
974 |
-
$sortbydirection = ( 'default'
|
975 |
-
$sorting = ( 'DESC'
|
976 |
|
977 |
$current = empty( $_GET['paged'] ) ? 1 : intval( $_GET['paged'] );
|
978 |
$screen = get_current_screen();
|
@@ -1003,13 +1003,13 @@ function mc_list_groups() {
|
|
1003 |
<div class='inside'>
|
1004 |
<ul class="links">
|
1005 |
<li>
|
1006 |
-
<a <?php echo ( isset( $_GET['limit'] ) && 'grouped'
|
1007 |
</li>
|
1008 |
<li>
|
1009 |
-
<a <?php echo ( isset( $_GET['limit'] ) && 'ungrouped'
|
1010 |
</li>
|
1011 |
<li>
|
1012 |
-
<a <?php echo ( isset( $_GET['limit'] ) && 'all'
|
1013 |
</li>
|
1014 |
</ul>
|
1015 |
<p><?php _e( 'Check a set of events to group them for mass editing.', 'my-calendar' ); ?></p>
|
@@ -1069,7 +1069,7 @@ function mc_list_groups() {
|
|
1069 |
$class = '';
|
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'
|
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';
|
@@ -1130,7 +1130,7 @@ function mc_list_groups() {
|
|
1130 |
</td>
|
1131 |
<td><?php echo strip_tags( stripslashes( $event->event_label ) ); ?></td>
|
1132 |
<?php
|
1133 |
-
if ( '23:59:59'
|
1134 |
$event_time = date_i18n( get_option( 'mc_time_format' ), strtotime( $event->event_time ) );
|
1135 |
} else {
|
1136 |
$event_time = mc_notime_label( $event );
|
24 |
$group_id = ! empty( $_POST['group_id'] ) ? $_POST['group_id'] : '';
|
25 |
|
26 |
if ( isset( $_GET['mode'] ) ) {
|
27 |
+
if ( 'edit' === $_GET['mode'] ) {
|
28 |
$action = 'edit';
|
29 |
$event_id = (int) $_GET['event_id'];
|
30 |
$group_id = (int) $_GET['group_id'];
|
91 |
<div class="wrap my-calendar-admin" id="my-calendar">
|
92 |
<?php
|
93 |
my_calendar_check_db();
|
94 |
+
if ( 'edit' === $action ) {
|
95 |
echo '<h1>' . __( 'Edit Event Group', 'my-calendar' ) . '</h1>';
|
96 |
if ( empty( $event_id ) || empty( $group_id ) ) {
|
97 |
mc_show_error( __( 'You must provide an event group id in order to edit it', 'my-calendar' ) );
|
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];
|
189 |
function mc_group_data( $event_id = false ) {
|
190 |
global $wpdb, $submission;
|
191 |
if ( false !== $event_id ) {
|
192 |
+
if ( intval( $event_id ) !== $event_id ) {
|
193 |
return mc_show_error( __( 'Sorry! That\'s an invalid event key.', 'my-calendar' ), false );
|
194 |
} else {
|
195 |
$data = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . my_calendar_table() . ' WHERE event_id=%d LIMIT 1', $event_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
230 |
$count = count( $results );
|
231 |
for ( $i = 0; $i < $count; $i ++ ) {
|
232 |
$n = ( ( $i + 1 ) > $count - 1 ) ? 0 : $i + 1;
|
233 |
+
if ( md5( implode( '', $results[ $i ] ) ) !== md5( implode( '', $results[ $n ] ) ) ) {
|
234 |
return false;
|
235 |
}
|
236 |
}
|
251 |
$event_id = (int) $_GET['event_id'];
|
252 |
$nonce = wp_create_nonce( 'my-calendar-nonce' );
|
253 |
$results = $wpdb->get_results( $wpdb->prepare( 'SELECT event_id, event_begin, event_time FROM ' . my_calendar_table() . ' WHERE event_group_id = %d', $group_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
254 |
+
if ( 'apply' === $type ) {
|
255 |
$warning = ( ! mc_compare_group_members( $group_id ) ) ? '<p class="warning">' . __( '<strong>NOTE:</strong> The group editable fields for the events in this group do not match', 'my-calendar' ) . '</p>' : '<p class="matched">' . __( 'The group editable fields for the events in this group match.', 'my-calendar' ) . '</p>';
|
256 |
} else {
|
257 |
$warning = '';
|
258 |
}
|
259 |
+
$class = ( 'break' === $type ) ? 'break' : 'apply';
|
260 |
$group = "<div class='group $class'>";
|
261 |
$group .= $warning;
|
262 |
+
$group .= ( 'apply' === $type ) ? '<fieldset><legend>' . __( 'Apply these changes to:', 'my-calendar' ) . '</legend>' : '';
|
263 |
+
$group .= ( 'break' === $type ) ? "<form method='post' action='" . admin_url( "admin.php?page=my-calendar-groups&mode=edit&event_id=$event_id&group_id=$group_id" ) . "'>
|
264 |
<div><input type='hidden' value='" . esc_attr( $group_id ) . "' name='group_id' /><input type='hidden' value='" . esc_attr( $type ) . "' name='event_action' /><input type='hidden' name='_wpnonce' value='$nonce' />
|
265 |
</div>" : '';
|
266 |
$group .= "<ul class='checkboxes'>";
|
267 |
+
$checked = ( 'apply' === $type ) ? ' checked="checked"' : '';
|
268 |
foreach ( $results as $result ) {
|
269 |
$date = date_i18n( 'D, j M, Y', strtotime( $result->event_begin ) );
|
270 |
$time = date_i18n( 'g:i a', strtotime( $result->event_time ) );
|
271 |
$group .= "<li><input type='checkbox' name='$type" . "[]' value='$result->event_id' id='$type$result->event_id'$checked /> <label for='break$result->event_id'><a href='#event$result->event_id'>#$result->event_id</a>: $date; $time</label></li>\n";
|
272 |
}
|
273 |
$group .= "<li><input type='checkbox' class='selectall' id='$type'$checked /> <label for='$type'><b>" . __( 'Check/Uncheck all', 'my-calendar' ) . "</b></label></li>\n</ul>";
|
274 |
+
$group .= ( 'apply' === $type ) ? '</fieldset>' : '';
|
275 |
+
$group .= ( 'break' === $type ) ? "<p><input type='submit' class='button' value='" . __( 'Remove checked events from this group', 'my-calendar' ) . "' /></p></form>" : '';
|
276 |
$group .= '</div>';
|
277 |
|
278 |
return $group;
|
318 |
$current_user = wp_get_current_user();
|
319 |
$has_data = ( empty( $data ) ) ? false : true;
|
320 |
$user = get_userdata( $user_ID );
|
321 |
+
$input_all = ( get_option( 'mc_input_options_administrators' ) === 'true' && current_user_can( 'manage_options' ) ) ? true : false;
|
322 |
$mc_input = get_option( 'mc_input_options' );
|
323 |
$group_id = ( ! empty( $data->event_group_id ) ) ? $data->event_group_id : mc_group_id();
|
324 |
$title = '';
|
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"';
|
393 |
<div><input type='hidden' name='event_span' value='<?php echo esc_attr( $data->event_span ); ?>'/></div>
|
394 |
<?php
|
395 |
}
|
396 |
+
if ( 'on' === $mc_input['event_desc'] || $input_all ) {
|
397 |
?>
|
398 |
<div id="group_description">
|
399 |
<label for="content">
|
408 |
</div>
|
409 |
<?php
|
410 |
}
|
411 |
+
if ( 'on' === $mc_input['event_short'] || $input_all ) {
|
412 |
?>
|
413 |
<p>
|
414 |
<label for="e_short">
|
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;
|
482 |
echo ">$display_name</option>\n";
|
483 |
}
|
484 |
?>
|
485 |
</select>
|
486 |
</p>
|
487 |
<?php
|
488 |
+
if ( 'on' === $mc_input['event_category'] || $input_all ) {
|
489 |
$match = '';
|
490 |
if ( ! mc_compare_group_members( $group_id, 'event_category' ) ) {
|
491 |
$match = ' <span class="nomatch">' . __( 'Fields do not match', 'my-calendar' ) . '</span>';
|
492 |
}
|
493 |
|
494 |
+
if ( 'true' !== get_option( 'mc_multiple_categories' ) ) {
|
495 |
$select = mc_category_select( $data, true, false );
|
496 |
$return = '<p class="mc_category"><label for="event_category">' . __( 'Category', 'my-calendar-submissions' ) . $match . '</label><select class="widefat" name="event_category" id="e_category">' . $select . '</select></p>';
|
497 |
} else {
|
506 |
</div>
|
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"';
|
516 |
}
|
517 |
?>
|
535 |
</div>
|
536 |
</div>
|
537 |
<?php
|
538 |
+
if ( 'on' === $mc_input['event_open'] || $input_all ) { // Add a "don't change" option here. JCD TODO.
|
539 |
?>
|
540 |
<div class="ui-sortable meta-box-sortables">
|
541 |
<div class="postbox">
|
558 |
</div>
|
559 |
<?php
|
560 |
}
|
561 |
+
if ( ( 'on' === $mc_input['event_location'] || 'on' === $mc_input['event_location_dropdown'] ) || $input_all ) {
|
562 |
?>
|
563 |
<div class="ui-sortable meta-box-sortables">
|
564 |
<div class="postbox">
|
569 |
<legend><?php _e( 'Event Location', 'my-calendar' ); ?></legend>
|
570 |
<?php
|
571 |
}
|
572 |
+
if ( 'on' === $mc_input['event_location_dropdown'] || $input_all ) {
|
573 |
$locations = mc_get_locations( 'group-manager' );
|
574 |
if ( ! empty( $locations ) ) {
|
575 |
?>
|
596 |
} else {
|
597 |
echo '<input type="hidden" name="location_preset" value="none"/>';
|
598 |
}
|
599 |
+
if ( 'on' === $mc_input['event_location'] || $input_all ) {
|
600 |
?>
|
601 |
<p>
|
602 |
<label for="e_label">
|
769 |
</fieldset>
|
770 |
<?php
|
771 |
}
|
772 |
+
if ( ( 'on' === $mc_input['event_location'] || 'on' === $mc_input['event_location_dropdown'] ) || $input_all ) {
|
773 |
?>
|
774 |
</fieldset>
|
775 |
</div>
|
806 |
return '';
|
807 |
}
|
808 |
$errors = '';
|
809 |
+
if ( 'add' === $action || 'edit' === $action || 'copy' === $action ) {
|
810 |
$title = ! empty( $post['event_title'] ) ? trim( $post['event_title'] ) : '';
|
811 |
$desc = ! empty( $post['content'] ) ? trim( $post['content'] ) : '';
|
812 |
$short = ! empty( $post['event_short'] ) ? trim( $post['event_short'] ) : '';
|
837 |
$event_image = esc_url_raw( $post['event_image'] );
|
838 |
$event_span = ! empty( $post['event_span'] ) ? 1 : 0;
|
839 |
// Set location.
|
840 |
+
if ( 'none' !== $location_preset ) {
|
841 |
$location = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . my_calendar_locations_table() . ' WHERE location_id = %d', $location_preset ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
842 |
$event_label = $location->location_label;
|
843 |
$event_street = $location->location_street;
|
916 |
|
917 |
$submit = array_map( 'mc_kses_post', $submit );
|
918 |
|
919 |
+
if ( 'edit' === $action ) {
|
920 |
unset( $submit['event_author'] );
|
921 |
}
|
922 |
$data = array( $proceed, false, $submit, $errors );
|
935 |
|
936 |
$sortby = ( isset( $_GET['sort'] ) ) ? (int) $_GET['sort'] : get_option( 'mc_default_sort' );
|
937 |
if ( isset( $_GET['order'] ) ) {
|
938 |
+
$sortdir = ( isset( $_GET['order'] ) && 'ASC' === $_GET['order'] ) ? 'ASC' : 'default';
|
939 |
} else {
|
940 |
$sortdir = 'default';
|
941 |
}
|
971 |
$sortbyvalue = 'event_begin';
|
972 |
}
|
973 |
}
|
974 |
+
$sortbydirection = ( 'default' === $sortdir ) ? 'DESC' : $sortdir;
|
975 |
+
$sorting = ( 'DESC' === $sortbydirection ) ? '&order=ASC' : '';
|
976 |
|
977 |
$current = empty( $_GET['paged'] ) ? 1 : intval( $_GET['paged'] );
|
978 |
$screen = get_current_screen();
|
1003 |
<div class='inside'>
|
1004 |
<ul class="links">
|
1005 |
<li>
|
1006 |
+
<a <?php echo ( isset( $_GET['limit'] ) && 'grouped' === $_GET['limit'] ) ? ' class="active-link"' : ''; ?> href="<?php echo admin_url( 'admin.php?page=my-calendar-groups&limit=grouped#my-calendar-admin-table' ); ?>"><?php _e( 'Grouped Events', 'my-calendar' ); ?></a>
|
1007 |
</li>
|
1008 |
<li>
|
1009 |
+
<a <?php echo ( isset( $_GET['limit'] ) && 'ungrouped' === $_GET['limit'] ) ? ' class="active-link"' : ''; ?> href="<?php echo admin_url( 'admin.php?page=my-calendar-groups&limit=ungrouped#my-calendar-admin-table' ); ?>"><?php _e( 'Ungrouped Events', 'my-calendar' ); ?></a>
|
1010 |
</li>
|
1011 |
<li>
|
1012 |
+
<a <?php echo ( isset( $_GET['limit'] ) && 'all' === $_GET['limit'] || ! isset( $_GET['limit'] ) ) ? ' class="active-link"' : ''; ?> href="<?php echo admin_url( 'admin.php?page=my-calendar-groups#my-calendar-admin-table' ); ?>"><?php _e( 'All', 'my-calendar' ); ?></a>
|
1013 |
</li>
|
1014 |
</ul>
|
1015 |
<p><?php _e( 'Check a set of events to group them for mass editing.', 'my-calendar' ); ?></p>
|
1069 |
$class = '';
|
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';
|
1130 |
</td>
|
1131 |
<td><?php echo strip_tags( stripslashes( $event->event_label ) ); ?></td>
|
1132 |
<?php
|
1133 |
+
if ( '23:59:59' !== $event->event_endtime ) {
|
1134 |
$event_time = date_i18n( get_option( 'mc_time_format' ), strtotime( $event->event_time ) );
|
1135 |
} else {
|
1136 |
$event_time = mc_notime_label( $event );
|
my-calendar-install.php
CHANGED
@@ -116,7 +116,7 @@ function mc_globals() {
|
|
116 |
);
|
117 |
|
118 |
$charset_collate = $wpdb->get_charset_collate();
|
119 |
-
$event_fifth_week = ( get_option( 'mc_no_fifth_week' )
|
120 |
|
121 |
$initial_db = 'CREATE TABLE ' . my_calendar_table() . " (
|
122 |
event_id INT(11) NOT NULL AUTO_INCREMENT,
|
@@ -255,7 +255,6 @@ function mc_default_settings() {
|
|
255 |
add_option( 'mc_multiple_categories', 'true' );
|
256 |
add_option( 'mc_event_link_expires', 'false' );
|
257 |
add_option( 'mc_apply_color', 'background' );
|
258 |
-
add_option( 'mc_inverse_color', 'true' );
|
259 |
add_option(
|
260 |
'mc_input_options',
|
261 |
array(
|
@@ -324,7 +323,7 @@ function mc_default_settings() {
|
|
324 |
update_option( 'mc_update_notice', 1 );
|
325 |
mc_add_roles();
|
326 |
$has_uri = mc_guess_calendar();
|
327 |
-
if ( false
|
328 |
// if mc_guess_calendar returns a string, no valid URI was found.
|
329 |
$slug = sanitize_title( __( 'My Calendar', 'my-calendar' ) );
|
330 |
mc_generate_calendar_page( $slug );
|
@@ -383,18 +382,18 @@ function mc_migrate_db() {
|
|
383 |
// Step 1) check if early escapement is needed.
|
384 |
$count = $wpdb->get_var( 'SELECT count(1) from ' . my_calendar_event_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
385 |
$count2 = $wpdb->get_var( 'SELECT count(1) from ' . my_calendar_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
|
|
386 |
if ( $count2 > 0 && $count > 0 ) {
|
387 |
return;
|
388 |
}
|
389 |
-
if ( 0
|
390 |
return; // No events, migration unnecessary.
|
391 |
}
|
392 |
-
|
393 |
// Step 2) migrate events.
|
394 |
$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
|
395 |
foreach ( $events as $event ) {
|
396 |
// assign endtimes to all events.
|
397 |
-
if ( '00:00:00'
|
398 |
$event->event_endtime = date( 'H:i:s', strtotime( "$event->event_time +1 hour" ) );
|
399 |
mc_flag_event( $event->event_id, $event->event_endtime );
|
400 |
}
|
@@ -470,7 +469,7 @@ function mc_check_location_table( $event, $locations ) {
|
|
470 |
* @since 2.3.0
|
471 |
*/
|
472 |
function mc_transition_db() {
|
473 |
-
if ( 'true'
|
474 |
global $wpdb;
|
475 |
$results = $wpdb->get_results( 'SELECT * FROM ' . my_calendar_locations_table(), ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
476 |
$locations = array();
|
@@ -502,7 +501,7 @@ function mc_transition_db() {
|
|
502 |
if ( $location ) {
|
503 |
mc_update_event( 'event_location', $location, $event['event_id'] );
|
504 |
} else {
|
505 |
-
if ( ''
|
506 |
// don't insert the row if location does not have basic data.
|
507 |
} else {
|
508 |
$add = array(
|
@@ -534,7 +533,7 @@ function mc_transition_db() {
|
|
534 |
*/
|
535 |
function mc_check_imports() {
|
536 |
$output = '';
|
537 |
-
if ( 'true'
|
538 |
if ( function_exists( 'check_calendar' ) ) {
|
539 |
$output .= "
|
540 |
<div id='message' class='updated'>
|
@@ -640,7 +639,7 @@ function my_calendar_rmdirr( $dirname ) {
|
|
640 |
* @param array $plugin Current plugin.
|
641 |
*/
|
642 |
function my_calendar_backup( $process, $plugin ) {
|
643 |
-
if ( isset( $plugin['plugin'] ) && 'my-calendar/my-calendar.php'
|
644 |
$to = dirname( __FILE__ ) . '/../styles_backup/';
|
645 |
$from = dirname( __FILE__ ) . '/styles/';
|
646 |
my_calendar_copyr( $from, $to );
|
@@ -658,7 +657,7 @@ function my_calendar_backup( $process, $plugin ) {
|
|
658 |
* @param array $plugin Current plugin.
|
659 |
*/
|
660 |
function my_calendar_recover( $process, $plugin ) {
|
661 |
-
if ( isset( $plugin['plugin'] ) && 'my-calendar/my-calendar.php'
|
662 |
$from = dirname( __FILE__ ) . '/../styles_backup/';
|
663 |
$to = dirname( __FILE__ ) . '/styles/';
|
664 |
my_calendar_copyr( $from, $to );
|
116 |
);
|
117 |
|
118 |
$charset_collate = $wpdb->get_charset_collate();
|
119 |
+
$event_fifth_week = ( get_option( 'mc_no_fifth_week' ) === 'true' ) ? 1 : 0;
|
120 |
|
121 |
$initial_db = 'CREATE TABLE ' . my_calendar_table() . " (
|
122 |
event_id INT(11) NOT NULL AUTO_INCREMENT,
|
255 |
add_option( 'mc_multiple_categories', 'true' );
|
256 |
add_option( 'mc_event_link_expires', 'false' );
|
257 |
add_option( 'mc_apply_color', 'background' );
|
|
|
258 |
add_option(
|
259 |
'mc_input_options',
|
260 |
array(
|
323 |
update_option( 'mc_update_notice', 1 );
|
324 |
mc_add_roles();
|
325 |
$has_uri = mc_guess_calendar();
|
326 |
+
if ( false === $has_uri['response'] ) {
|
327 |
// if mc_guess_calendar returns a string, no valid URI was found.
|
328 |
$slug = sanitize_title( __( 'My Calendar', 'my-calendar' ) );
|
329 |
mc_generate_calendar_page( $slug );
|
382 |
// Step 1) check if early escapement is needed.
|
383 |
$count = $wpdb->get_var( 'SELECT count(1) from ' . my_calendar_event_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
384 |
$count2 = $wpdb->get_var( 'SELECT count(1) from ' . my_calendar_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
385 |
+
// If both tables have rows, the drop failed and this should exit.
|
386 |
if ( $count2 > 0 && $count > 0 ) {
|
387 |
return;
|
388 |
}
|
389 |
+
if ( 0 === $count2 && 0 === $count ) {
|
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 |
}
|
469 |
* @since 2.3.0
|
470 |
*/
|
471 |
function mc_transition_db() {
|
472 |
+
if ( 'true' !== get_option( 'mc_remote' ) ) {
|
473 |
global $wpdb;
|
474 |
$results = $wpdb->get_results( 'SELECT * FROM ' . my_calendar_locations_table(), ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
475 |
$locations = array();
|
501 |
if ( $location ) {
|
502 |
mc_update_event( 'event_location', $location, $event['event_id'] );
|
503 |
} else {
|
504 |
+
if ( '' === $event['event_label'] && '' === $event['event_street'] && '' === $event['event_url'] && '' === $event['event_city'] && '' === $event['event_state'] && '' === $event['event_country'] ) {
|
505 |
// don't insert the row if location does not have basic data.
|
506 |
} else {
|
507 |
$add = array(
|
533 |
*/
|
534 |
function mc_check_imports() {
|
535 |
$output = '';
|
536 |
+
if ( 'true' !== get_option( 'ko_calendar_imported' ) ) {
|
537 |
if ( function_exists( 'check_calendar' ) ) {
|
538 |
$output .= "
|
539 |
<div id='message' class='updated'>
|
639 |
* @param array $plugin Current plugin.
|
640 |
*/
|
641 |
function my_calendar_backup( $process, $plugin ) {
|
642 |
+
if ( isset( $plugin['plugin'] ) && 'my-calendar/my-calendar.php' === $plugin['plugin'] ) {
|
643 |
$to = dirname( __FILE__ ) . '/../styles_backup/';
|
644 |
$from = dirname( __FILE__ ) . '/styles/';
|
645 |
my_calendar_copyr( $from, $to );
|
657 |
* @param array $plugin Current plugin.
|
658 |
*/
|
659 |
function my_calendar_recover( $process, $plugin ) {
|
660 |
+
if ( isset( $plugin['plugin'] ) && 'my-calendar/my-calendar.php' === $plugin['plugin'] ) {
|
661 |
$from = dirname( __FILE__ ) . '/../styles_backup/';
|
662 |
$to = dirname( __FILE__ ) . '/styles/';
|
663 |
my_calendar_copyr( $from, $to );
|
my-calendar-location-manager.php
CHANGED
@@ -118,8 +118,8 @@ function mc_manage_locations() {
|
|
118 |
if ( isset( $_POST['mcl'] ) ) {
|
119 |
$query = $_POST['mcl'];
|
120 |
$db_type = mc_get_db_type();
|
121 |
-
if ( ''
|
122 |
-
if ( 'MyISAM'
|
123 |
$query = esc_sql( $query ); // Prepare query.
|
124 |
$search = ' WHERE MATCH(' . apply_filters( 'mc_search_fields', 'location_label,location_city,location_state,location_region,location_street,location_street2,location_phone' ) . ") AGAINST ( '$query' IN BOOLEAN MODE ) ";
|
125 |
} else {
|
@@ -225,7 +225,7 @@ function mc_manage_locations() {
|
|
225 |
<?php
|
226 |
$class = '';
|
227 |
foreach ( $locations as $location ) {
|
228 |
-
$class = ( 'alternate'
|
229 |
?>
|
230 |
<tr class="<?php echo $class; ?>">
|
231 |
<th scope="row">
|
118 |
if ( isset( $_POST['mcl'] ) ) {
|
119 |
$query = $_POST['mcl'];
|
120 |
$db_type = mc_get_db_type();
|
121 |
+
if ( '' !== $query ) {
|
122 |
+
if ( 'MyISAM' === $db_type ) {
|
123 |
$query = esc_sql( $query ); // Prepare query.
|
124 |
$search = ' WHERE MATCH(' . apply_filters( 'mc_search_fields', 'location_label,location_city,location_state,location_region,location_street,location_street2,location_phone' ) . ") AGAINST ( '$query' IN BOOLEAN MODE ) ";
|
125 |
} else {
|
225 |
<?php
|
226 |
$class = '';
|
227 |
foreach ( $locations as $location ) {
|
228 |
+
$class = ( 'alternate' === $class ) ? '' : 'alternate';
|
229 |
?>
|
230 |
<tr class="<?php echo $class; ?>">
|
231 |
<th scope="row">
|
my-calendar-locations.php
CHANGED
@@ -34,7 +34,7 @@ function mc_update_location( $field, $data, $location ) {
|
|
34 |
* Update settings for how location inputs are limited.
|
35 |
*/
|
36 |
function mc_update_location_controls() {
|
37 |
-
if ( isset( $_POST['mc_locations'] ) && 'true'
|
38 |
$nonce = $_POST['_wpnonce'];
|
39 |
if ( ! wp_verify_nonce( $nonce, 'my-calendar-nonce' ) ) {
|
40 |
wp_die( 'Invalid nonce' );
|
@@ -99,7 +99,7 @@ function my_calendar_add_locations() {
|
|
99 |
die( 'Security check failed' );
|
100 |
}
|
101 |
}
|
102 |
-
if ( isset( $_POST['mode'] ) && 'add'
|
103 |
$add = array(
|
104 |
'location_label' => $_POST['location_label'],
|
105 |
'location_street' => $_POST['location_street'],
|
@@ -125,7 +125,7 @@ function my_calendar_add_locations() {
|
|
125 |
} else {
|
126 |
mc_show_error( __( 'Location could not be added to database', 'my-calendar' ) );
|
127 |
}
|
128 |
-
} elseif ( isset( $_GET['location_id'] ) && 'delete'
|
129 |
$results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . my_calendar_locations_table() . ' WHERE location_id=%d', $_GET['location_id'] ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
130 |
do_action( 'mc_delete_location', $results, (int) $_GET['location_id'] );
|
131 |
if ( $results ) {
|
@@ -133,10 +133,10 @@ function my_calendar_add_locations() {
|
|
133 |
} else {
|
134 |
mc_show_error( __( 'Location could not be deleted', 'my-calendar' ) );
|
135 |
}
|
136 |
-
} elseif ( isset( $_GET['mode'] ) && isset( $_GET['location_id'] ) && 'edit'
|
137 |
$cur_loc = (int) $_GET['location_id'];
|
138 |
mc_show_location_form( 'edit', $cur_loc );
|
139 |
-
} elseif ( isset( $_POST['location_id'] ) && isset( $_POST['location_label'] ) && 'edit'
|
140 |
$update = array(
|
141 |
'location_label' => $_POST['location_label'],
|
142 |
'location_street' => $_POST['location_street'],
|
@@ -171,7 +171,7 @@ function my_calendar_add_locations() {
|
|
171 |
|
172 |
}
|
173 |
|
174 |
-
if ( isset( $_GET['mode'] ) && 'edit'
|
175 |
mc_show_location_form( 'add' );
|
176 |
}
|
177 |
}
|
@@ -184,11 +184,11 @@ function my_calendar_add_locations() {
|
|
184 |
*/
|
185 |
function mc_show_location_form( $view = 'add', $loc_id = '' ) {
|
186 |
$cur_loc = false;
|
187 |
-
if ( ''
|
188 |
$cur_loc = mc_get_location( $loc_id );
|
189 |
}
|
190 |
$has_data = ( empty( $cur_loc ) ) ? false : true;
|
191 |
-
if ( 'add'
|
192 |
?>
|
193 |
<h1><?php _e( 'Add New Location', 'my-calendar' ); ?></h1>
|
194 |
<?php
|
@@ -211,7 +211,7 @@ function mc_show_location_form( $view = 'add', $loc_id = '' ) {
|
|
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'
|
215 |
?>
|
216 |
<div>
|
217 |
<input type="hidden" name="mode" value="add" />
|
@@ -229,14 +229,14 @@ function mc_show_location_form( $view = 'add', $loc_id = '' ) {
|
|
229 |
echo mc_locations_fields( $has_data, $cur_loc, 'location' );
|
230 |
?>
|
231 |
<p>
|
232 |
-
<input type="submit" name="save" class="button-primary" value="<?php echo ( 'edit'
|
233 |
</p>
|
234 |
</form>
|
235 |
</div>
|
236 |
</div>
|
237 |
</div>
|
238 |
<?php
|
239 |
-
if ( 'edit'
|
240 |
?>
|
241 |
<p>
|
242 |
<a href="<?php echo admin_url( 'admin.php?page=my-calendar-locations' ); ?>"><?php _e( 'Add a New Location', 'my-calendar' ); ?> »</a>
|
@@ -282,7 +282,7 @@ function mc_controlled_field( $this_field ) {
|
|
282 |
return false;
|
283 |
}
|
284 |
$controlled = array_keys( $controls );
|
285 |
-
if ( in_array( 'event_' . $this_field, $controlled ) && ! empty( $controls[ 'event_' . $this_field ] ) ) {
|
286 |
return true;
|
287 |
} else {
|
288 |
return false;
|
@@ -299,19 +299,19 @@ function mc_controlled_field( $this_field ) {
|
|
299 |
* @return string HTML select element with values
|
300 |
*/
|
301 |
function mc_location_controller( $fieldname, $selected, $context = 'location' ) {
|
302 |
-
$field = ( 'location'
|
303 |
$selected = esc_attr( trim( $selected ) );
|
304 |
$options = get_option( 'mc_location_controls' );
|
305 |
$regions = $options[ 'event_' . $fieldname ];
|
306 |
$form = "<select name='$field' id='e_$fieldname'>";
|
307 |
$form .= "<option value=''>" . __( 'Select', 'my-calendar' ) . '</option>';
|
308 |
-
if ( is_admin() && ''
|
309 |
$form .= "<option value='$selected'>$selected :" . __( '(Not a controlled value)', 'my-calendar' ) . '</option>';
|
310 |
}
|
311 |
foreach ( $regions as $key => $value ) {
|
312 |
$key = esc_attr( trim( $key ) );
|
313 |
$value = esc_html( trim( $value ) );
|
314 |
-
$aselected = ( $selected
|
315 |
$form .= "<option value='$key'$aselected>$value</option>\n";
|
316 |
}
|
317 |
$form .= '</select>';
|
@@ -355,7 +355,7 @@ function mc_location_controls() {
|
|
355 |
$locations .= stripslashes( "$key,$value" ) . PHP_EOL;
|
356 |
}
|
357 |
}
|
358 |
-
if ( ''
|
359 |
$class = ' class="active-limit"';
|
360 |
$active = ' (' . __( 'active limits', 'my-calendar' ) . ')';
|
361 |
}
|
@@ -384,7 +384,7 @@ function mc_location_controls() {
|
|
384 |
*/
|
385 |
function mc_locations_fields( $has_data, $data, $context = 'location' ) {
|
386 |
$return = '<div class="mc-locations">';
|
387 |
-
if ( current_user_can( 'mc_edit_locations' ) && 'event'
|
388 |
$return .= '<p class="checkboxes"><input type="checkbox" value="on" name="mc_copy_location" id="mc_copy_location" /> <label for="mc_copy_location">' . __( 'Copy this location into the locations table', 'my-calendar' ) . '</label></p>';
|
389 |
}
|
390 |
$return .= '
|
@@ -496,7 +496,7 @@ function mc_locations_fields( $has_data, $data, $context = 'location' ) {
|
|
496 |
$access = apply_filters( 'mc_venue_accessibility', mc_location_access() );
|
497 |
$access_list = '';
|
498 |
if ( $has_data ) {
|
499 |
-
if ( 'location'
|
500 |
$location_access = unserialize( $data->{$context . '_access'} );
|
501 |
} else {
|
502 |
if ( property_exists( $data, 'event_location' ) ) {
|
@@ -514,7 +514,7 @@ function mc_locations_fields( $has_data, $data, $context = 'location' ) {
|
|
514 |
$label = $a;
|
515 |
$checked = '';
|
516 |
if ( is_array( $location_access ) ) {
|
517 |
-
$checked = ( in_array( $a, $location_access ) || in_array( $k, $location_access ) ) ? " checked='checked'" : '';
|
518 |
}
|
519 |
$item = sprintf( '<li><input type="checkbox" id="%1$s" name="' . $context . '_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( $a ) );
|
520 |
$access_list .= $item;
|
@@ -530,7 +530,7 @@ function mc_locations_fields( $has_data, $data, $context = 'location' ) {
|
|
530 |
$return .= '<h3>' . __( 'Location Map', 'my-calendar' ) . '</h3>';
|
531 |
$map = mc_generate_map( $data, $context );
|
532 |
|
533 |
-
$return .= ( ''
|
534 |
} else {
|
535 |
// Translators: URL to settings page to add key.
|
536 |
$return .= sprintf( __( 'Add a <a href="%s">Google Maps API Key</a> to generate a location map.', 'my-calendar' ), admin_url( 'admin.php?page=my-calendar-config#mc-output' ) );
|
@@ -575,7 +575,7 @@ function mc_location_data( $field, $id ) {
|
|
575 |
if ( $id ) {
|
576 |
global $wpdb;
|
577 |
$mcdb = $wpdb;
|
578 |
-
if ( 'true'
|
579 |
$mcdb = mc_remote_db();
|
580 |
}
|
581 |
$field = $field;
|
@@ -602,7 +602,7 @@ function mc_location_select( $location = false ) {
|
|
602 |
foreach ( $locs as $loc ) {
|
603 |
$l = '<option value="' . $loc->location_id . '"';
|
604 |
if ( $location ) {
|
605 |
-
if ( $location
|
606 |
$l .= ' selected="selected"';
|
607 |
}
|
608 |
}
|
@@ -635,12 +635,12 @@ function mc_get_locations( $args ) {
|
|
635 |
$where = '1';
|
636 |
$is = '1';
|
637 |
}
|
638 |
-
if ( ! ( 'ASC'
|
639 |
// Prevent invalid order parameters.
|
640 |
$order = 'ASC';
|
641 |
}
|
642 |
$valid_args = $wpdb->get_col( 'DESC ' . my_calendar_locations_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
643 |
-
if ( ! ( in_array( $orderby, $valid_args ) ) ) {
|
644 |
// Prevent invalid order columns.
|
645 |
$orderby = 'location_label';
|
646 |
}
|
34 |
* Update settings for how location inputs are limited.
|
35 |
*/
|
36 |
function mc_update_location_controls() {
|
37 |
+
if ( isset( $_POST['mc_locations'] ) && 'true' === $_POST['mc_locations'] ) {
|
38 |
$nonce = $_POST['_wpnonce'];
|
39 |
if ( ! wp_verify_nonce( $nonce, 'my-calendar-nonce' ) ) {
|
40 |
wp_die( 'Invalid nonce' );
|
99 |
die( 'Security check failed' );
|
100 |
}
|
101 |
}
|
102 |
+
if ( isset( $_POST['mode'] ) && 'add' === $_POST['mode'] ) {
|
103 |
$add = array(
|
104 |
'location_label' => $_POST['location_label'],
|
105 |
'location_street' => $_POST['location_street'],
|
125 |
} else {
|
126 |
mc_show_error( __( 'Location could not be added to database', 'my-calendar' ) );
|
127 |
}
|
128 |
+
} elseif ( isset( $_GET['location_id'] ) && 'delete' === $_GET['mode'] ) {
|
129 |
$results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . my_calendar_locations_table() . ' WHERE location_id=%d', $_GET['location_id'] ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
130 |
do_action( 'mc_delete_location', $results, (int) $_GET['location_id'] );
|
131 |
if ( $results ) {
|
133 |
} else {
|
134 |
mc_show_error( __( 'Location could not be deleted', 'my-calendar' ) );
|
135 |
}
|
136 |
+
} elseif ( isset( $_GET['mode'] ) && isset( $_GET['location_id'] ) && 'edit' === $_GET['mode'] && ! isset( $_POST['mode'] ) ) {
|
137 |
$cur_loc = (int) $_GET['location_id'];
|
138 |
mc_show_location_form( 'edit', $cur_loc );
|
139 |
+
} elseif ( isset( $_POST['location_id'] ) && isset( $_POST['location_label'] ) && 'edit' === $_POST['mode'] ) {
|
140 |
$update = array(
|
141 |
'location_label' => $_POST['location_label'],
|
142 |
'location_street' => $_POST['location_street'],
|
171 |
|
172 |
}
|
173 |
|
174 |
+
if ( isset( $_GET['mode'] ) && 'edit' !== $_GET['mode'] || isset( $_POST['mode'] ) && 'edit' !== $_POST['mode'] || ! isset( $_GET['mode'] ) && ! isset( $_POST['mode'] ) ) {
|
175 |
mc_show_location_form( 'add' );
|
176 |
}
|
177 |
}
|
184 |
*/
|
185 |
function mc_show_location_form( $view = 'add', $loc_id = '' ) {
|
186 |
$cur_loc = false;
|
187 |
+
if ( '' !== $loc_id ) {
|
188 |
$cur_loc = mc_get_location( $loc_id );
|
189 |
}
|
190 |
$has_data = ( empty( $cur_loc ) ) ? false : true;
|
191 |
+
if ( 'add' === $view ) {
|
192 |
?>
|
193 |
<h1><?php _e( 'Add New Location', 'my-calendar' ); ?></h1>
|
194 |
<?php
|
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 ) {
|
215 |
?>
|
216 |
<div>
|
217 |
<input type="hidden" name="mode" value="add" />
|
229 |
echo mc_locations_fields( $has_data, $cur_loc, 'location' );
|
230 |
?>
|
231 |
<p>
|
232 |
+
<input type="submit" name="save" class="button-primary" value="<?php echo ( 'edit' === $view ) ? __( 'Save Changes', 'my-calendar' ) : __( 'Add Location', 'my-calendar' ); ?> »"/>
|
233 |
</p>
|
234 |
</form>
|
235 |
</div>
|
236 |
</div>
|
237 |
</div>
|
238 |
<?php
|
239 |
+
if ( 'edit' === $view ) {
|
240 |
?>
|
241 |
<p>
|
242 |
<a href="<?php echo admin_url( 'admin.php?page=my-calendar-locations' ); ?>"><?php _e( 'Add a New Location', 'my-calendar' ); ?> »</a>
|
282 |
return false;
|
283 |
}
|
284 |
$controlled = array_keys( $controls );
|
285 |
+
if ( in_array( 'event_' . $this_field, $controlled, true ) && ! empty( $controls[ 'event_' . $this_field ] ) ) {
|
286 |
return true;
|
287 |
} else {
|
288 |
return false;
|
299 |
* @return string HTML select element with values
|
300 |
*/
|
301 |
function mc_location_controller( $fieldname, $selected, $context = 'location' ) {
|
302 |
+
$field = ( 'location' === $context ) ? 'location_' . $fieldname : 'event_' . $fieldname;
|
303 |
$selected = esc_attr( trim( $selected ) );
|
304 |
$options = get_option( 'mc_location_controls' );
|
305 |
$regions = $options[ 'event_' . $fieldname ];
|
306 |
$form = "<select name='$field' id='e_$fieldname'>";
|
307 |
$form .= "<option value=''>" . __( 'Select', 'my-calendar' ) . '</option>';
|
308 |
+
if ( is_admin() && '' !== $selected ) {
|
309 |
$form .= "<option value='$selected'>$selected :" . __( '(Not a controlled value)', 'my-calendar' ) . '</option>';
|
310 |
}
|
311 |
foreach ( $regions as $key => $value ) {
|
312 |
$key = esc_attr( trim( $key ) );
|
313 |
$value = esc_html( trim( $value ) );
|
314 |
+
$aselected = ( $selected === $key ) ? ' selected="selected"' : '';
|
315 |
$form .= "<option value='$key'$aselected>$value</option>\n";
|
316 |
}
|
317 |
$form .= '</select>';
|
355 |
$locations .= stripslashes( "$key,$value" ) . PHP_EOL;
|
356 |
}
|
357 |
}
|
358 |
+
if ( '' !== trim( $locations ) ) {
|
359 |
$class = ' class="active-limit"';
|
360 |
$active = ' (' . __( 'active limits', 'my-calendar' ) . ')';
|
361 |
}
|
384 |
*/
|
385 |
function mc_locations_fields( $has_data, $data, $context = 'location' ) {
|
386 |
$return = '<div class="mc-locations">';
|
387 |
+
if ( current_user_can( 'mc_edit_locations' ) && 'event' === $context ) {
|
388 |
$return .= '<p class="checkboxes"><input type="checkbox" value="on" name="mc_copy_location" id="mc_copy_location" /> <label for="mc_copy_location">' . __( 'Copy this location into the locations table', 'my-calendar' ) . '</label></p>';
|
389 |
}
|
390 |
$return .= '
|
496 |
$access = apply_filters( 'mc_venue_accessibility', mc_location_access() );
|
497 |
$access_list = '';
|
498 |
if ( $has_data ) {
|
499 |
+
if ( 'location' === $context ) {
|
500 |
$location_access = unserialize( $data->{$context . '_access'} );
|
501 |
} else {
|
502 |
if ( property_exists( $data, 'event_location' ) ) {
|
514 |
$label = $a;
|
515 |
$checked = '';
|
516 |
if ( is_array( $location_access ) ) {
|
517 |
+
$checked = ( in_array( $a, $location_access, true ) || in_array( $k, $location_access, true ) ) ? " checked='checked'" : '';
|
518 |
}
|
519 |
$item = sprintf( '<li><input type="checkbox" id="%1$s" name="' . $context . '_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( $a ) );
|
520 |
$access_list .= $item;
|
530 |
$return .= '<h3>' . __( 'Location Map', 'my-calendar' ) . '</h3>';
|
531 |
$map = mc_generate_map( $data, $context );
|
532 |
|
533 |
+
$return .= ( '' === $map ) ? __( 'Not enough information to generate a map', 'my-calendar' ) : $map;
|
534 |
} else {
|
535 |
// Translators: URL to settings page to add key.
|
536 |
$return .= sprintf( __( 'Add a <a href="%s">Google Maps API Key</a> to generate a location map.', 'my-calendar' ), admin_url( 'admin.php?page=my-calendar-config#mc-output' ) );
|
575 |
if ( $id ) {
|
576 |
global $wpdb;
|
577 |
$mcdb = $wpdb;
|
578 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
579 |
$mcdb = mc_remote_db();
|
580 |
}
|
581 |
$field = $field;
|
602 |
foreach ( $locs as $loc ) {
|
603 |
$l = '<option value="' . $loc->location_id . '"';
|
604 |
if ( $location ) {
|
605 |
+
if ( (int) $location === (int) $loc->location_id ) {
|
606 |
$l .= ' selected="selected"';
|
607 |
}
|
608 |
}
|
635 |
$where = '1';
|
636 |
$is = '1';
|
637 |
}
|
638 |
+
if ( ! ( 'ASC' === $order || 'DESC' === $order ) ) {
|
639 |
// Prevent invalid order parameters.
|
640 |
$order = 'ASC';
|
641 |
}
|
642 |
$valid_args = $wpdb->get_col( 'DESC ' . my_calendar_locations_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
643 |
+
if ( ! ( in_array( $orderby, $valid_args, true ) ) ) {
|
644 |
// Prevent invalid order columns.
|
645 |
$orderby = 'location_label';
|
646 |
}
|
my-calendar-output.php
CHANGED
@@ -26,7 +26,7 @@ function mc_get_template( $template ) {
|
|
26 |
|
27 |
$keys = array( 'title', 'title_list', 'title_solo', 'link', 'mini', 'list', 'details', 'rss', 'grid' );
|
28 |
|
29 |
-
if ( in_array( $template, $keys ) ) {
|
30 |
$template = '';
|
31 |
}
|
32 |
|
@@ -39,7 +39,7 @@ function mc_get_template( $template ) {
|
|
39 |
* @return string
|
40 |
*/
|
41 |
function mc_date_format() {
|
42 |
-
$date_format = ( ''
|
43 |
|
44 |
return $date_format;
|
45 |
}
|
@@ -58,23 +58,23 @@ function mc_time_html( $e, $type ) {
|
|
58 |
$time_format = get_option( 'mc_time_format' );
|
59 |
$start = date( 'Y-m-d', strtotime( $e->occur_begin ) );
|
60 |
$end = date( 'Y-m-d', strtotime( $e->occur_end ) );
|
61 |
-
$has_time = ( '00:00:00'
|
62 |
$final = '';
|
63 |
// Manipulate date_format based on event data.
|
64 |
-
if ( $e->event_end
|
65 |
-
$mult_format = get_option( 'mc_multidate_format' );
|
66 |
-
$mult_format = ( ''
|
67 |
$date_format = str_replace( '%d', date( 'j', strtotime( $e->occur_end ) ), $mult_format );
|
68 |
}
|
69 |
// If this event crosses years or months, use original date format & show both dates.
|
70 |
-
if ( date( 'Y', strtotime( $e->occur_end ) )
|
71 |
$current = date_i18n( $orig_format, strtotime( $e->occur_begin ) ) . ' – ' . date_i18n( $orig_format, strtotime( $e->occur_end ) );
|
72 |
} else {
|
73 |
$current = date_i18n( $date_format, strtotime( $e->occur_begin ) );
|
74 |
-
$final = ( $e->event_end
|
75 |
}
|
76 |
// Do not show info in list view.
|
77 |
-
$time_content = ( 'list'
|
78 |
// Handle cases.
|
79 |
if ( $has_time ) {
|
80 |
$time_content .= "\n
|
@@ -84,7 +84,7 @@ function mc_time_html( $e, $type ) {
|
|
84 |
</time>
|
85 |
</span>';
|
86 |
if ( 0 == $e->event_hide_end ) {
|
87 |
-
if ( ''
|
88 |
$time_content .= "
|
89 |
<span class='time-separator'> – </span>$final
|
90 |
<span class='end-time dtend'>
|
@@ -96,7 +96,7 @@ function mc_time_html( $e, $type ) {
|
|
96 |
} else {
|
97 |
$notime = mc_notime_label( $e );
|
98 |
$time_content .= "<span class='event-time'>";
|
99 |
-
$time_content .= ( 'N/A'
|
100 |
$time_content .= '</span>';
|
101 |
}
|
102 |
$time_content .= apply_filters( 'mcs_end_time_block', '', $e );
|
@@ -121,11 +121,11 @@ function mc_category_icon( $event, $type = 'html' ) {
|
|
121 |
if ( is_object( $event ) && property_exists( $event, 'category_icon' ) ) {
|
122 |
$url = plugin_dir_url( __FILE__ );
|
123 |
$image = '';
|
124 |
-
if ( 'true'
|
125 |
if ( '' != $event->category_icon ) {
|
126 |
$path = ( mc_is_custom_icon() ) ? str_replace( 'my-calendar', 'my-calendar-custom', $url ) : plugins_url( 'images/icons', __FILE__ ) . '/';
|
127 |
$hex = ( strpos( $event->category_color, '#' ) !== 0 ) ? '#' : '';
|
128 |
-
if ( 'html'
|
129 |
$image = '<img src="' . $path . $event->category_icon . '" alt="' . __( 'Category', 'my-calendar' ) . ': ' . esc_attr( $event->category_name ) . '" class="category-icon" style="background:' . $hex . $event->category_color . '" />';
|
130 |
} else {
|
131 |
$image = $path . $event->category_icon;
|
@@ -135,6 +135,8 @@ function mc_category_icon( $event, $type = 'html' ) {
|
|
135 |
|
136 |
return apply_filters( 'mc_category_icon', $image, $event, $type );
|
137 |
}
|
|
|
|
|
138 |
}
|
139 |
|
140 |
add_filter( 'the_title', 'mc_category_icon_title', 10, 2 );
|
@@ -180,7 +182,7 @@ function my_calendar_draw_events( $events, $params, $process_date, $template = '
|
|
180 |
$time = $params['time'];
|
181 |
|
182 |
$open_option = get_option( 'mc_open_day_uri' );
|
183 |
-
if ( 'mini'
|
184 |
return true;
|
185 |
}
|
186 |
// We need to sort arrays of objects by time.
|
@@ -189,20 +191,20 @@ function my_calendar_draw_events( $events, $params, $process_date, $template = '
|
|
189 |
$begin = '';
|
190 |
$event_output = '';
|
191 |
$end = '';
|
192 |
-
if ( 'mini'
|
193 |
$begin .= "<div id='date-$process_date' class='calendar-events'>";
|
194 |
}
|
195 |
foreach ( array_keys( $events ) as $key ) {
|
196 |
$event =& $events[ $key ];
|
197 |
-
if ( 'S1'
|
198 |
$check = get_post_meta( $event->event_post, '_occurrence_overlap', true );
|
199 |
-
if ( 'false'
|
200 |
$check = mc_test_occurrence_overlap( $event, true );
|
201 |
}
|
202 |
} else {
|
203 |
$check = '';
|
204 |
}
|
205 |
-
if ( ''
|
206 |
$output_array[] = my_calendar_draw_event( $event, $type, $process_date, $time, $template );
|
207 |
}
|
208 |
}
|
@@ -212,10 +214,10 @@ function my_calendar_draw_events( $events, $params, $process_date, $template = '
|
|
212 |
$event_output .= $value;
|
213 |
}
|
214 |
}
|
215 |
-
if ( ''
|
216 |
return '';
|
217 |
}
|
218 |
-
if ( 'mini'
|
219 |
$end .= '</div>';
|
220 |
}
|
221 |
|
@@ -289,22 +291,22 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
|
|
289 |
$uid = 'mc_' . $type . '_' . $day_id . '_' . $event->occur_id;
|
290 |
$image = mc_category_icon( $event );
|
291 |
$img = '';
|
292 |
-
$has_image = ( ''
|
293 |
$event_classes = mc_event_classes( $event, $day_id, $type );
|
294 |
$header .= "<div id='$uid-$type' class='$event_classes'>\n";
|
295 |
|
296 |
switch ( $type ) {
|
297 |
case 'calendar':
|
298 |
-
$title_template = ( mc_get_template( 'title' )
|
299 |
break;
|
300 |
case 'list':
|
301 |
-
$title_template = ( mc_get_template( 'title_list' )
|
302 |
break;
|
303 |
case 'single':
|
304 |
-
$title_template = ( mc_get_template( 'title_solo' )
|
305 |
break;
|
306 |
default:
|
307 |
-
$title_template = ( mc_get_template( 'title' )
|
308 |
}
|
309 |
|
310 |
$event_title = mc_draw_template( $data, $title_template );
|
@@ -312,11 +314,11 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
|
|
312 |
// If the first two characters of the title are ": ", this is the default templates but no time.
|
313 |
$event_title = str_replace( ': ', '', $event_title );
|
314 |
}
|
315 |
-
$event_title = ( ''
|
316 |
$no_link = apply_filters( 'mc_disable_link', false, $data );
|
317 |
|
318 |
-
if ( ( ( strpos( $event_title, 'href' ) === false ) && 'mini'
|
319 |
-
if ( 'true'
|
320 |
$details_link = esc_url( mc_get_details_link( $event ) );
|
321 |
$wrap = ( _mc_is_url( $details_link ) ) ? "<a href='$details_link' class='url summary$has_image'>" : '<span class="no-link">';
|
322 |
$balance = ( _mc_is_url( $details_link ) ) ? '</a>' : '</span>';
|
@@ -332,9 +334,9 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
|
|
332 |
$group_class = ( 1 == $event->event_span ) ? ' multidate group' . $event->event_group_id : '';
|
333 |
$hlevel = apply_filters( 'mc_heading_level_table', 'h3', $type, $time, $template );
|
334 |
$inner_heading = apply_filters( 'mc_heading_inner_title', $wrap . $image . trim( $event_title ) . $balance, $event_title, $event );
|
335 |
-
$header .= ( 'single'
|
336 |
-
$event_title = ( 'single'
|
337 |
-
$title = ( 'single'
|
338 |
$title = apply_filters( 'mc_event_title', $title, $event, $event_title, $image );
|
339 |
$header .= '<span class="summary">' . $title . '</span>';
|
340 |
|
@@ -342,25 +344,25 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
|
|
342 |
$close_button = "<button type='button' aria-controls='$uid-$type-details' class='mc-toggle close' data-action='shiftforward'>$close_image</button>";
|
343 |
|
344 |
if ( mc_show_details( $time, $type ) ) {
|
345 |
-
$close = ( 'calendar'
|
346 |
|
347 |
if ( false === $details ) {
|
348 |
-
if ( ( 'true'
|
349 |
$address = mc_hcard( $event, $display_address, $display_map );
|
350 |
}
|
351 |
$time_html = mc_time_html( $event, $type );
|
352 |
-
if ( 'list'
|
353 |
$hlevel = apply_filters( 'mc_heading_level_list', 'h3', $type, $time, $template );
|
354 |
$list_title = "<$hlevel class='event-title summary' id='mc_$event->occur_id-title'>$image" . $event_title . "</$hlevel>\n";
|
355 |
}
|
356 |
-
if ( 'true'
|
357 |
if ( 0 != $event->event_author ) {
|
358 |
$e = get_userdata( $event->event_author );
|
359 |
$author = '<p class="event-author">' . __( 'Posted by', 'my-calendar' ) . ' <span class="author-name">' . $e->display_name . "</span></p>\n";
|
360 |
}
|
361 |
}
|
362 |
|
363 |
-
if ( 'false'
|
364 |
$details_label = mc_get_details_label( $event, $data );
|
365 |
$details_link = mc_get_details_link( $event );
|
366 |
// Translators: Event title.
|
@@ -373,30 +375,30 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
|
|
373 |
}
|
374 |
$more = apply_filters( 'mc_details_grid_link', $more, $event );
|
375 |
|
376 |
-
if ( 'true'
|
377 |
$gcal = "<p class='gcal'>" . mc_draw_template( $data, '{gcal_link}' ) . '</p>';
|
378 |
}
|
379 |
|
380 |
-
if ( 'true'
|
381 |
$vcal = "<p class='ical'>" . mc_draw_template( $data, '{ical_html}' ) . '</p>';
|
382 |
}
|
383 |
|
384 |
-
if ( 'true'
|
385 |
$img = mc_get_event_image( $event, $data );
|
386 |
}
|
387 |
|
388 |
-
if ( 'calendar'
|
389 |
// In all cases, this is semantically a duplicate of the title, but can be beneficial for sighted users.
|
390 |
-
$headingtype = ( 'h3'
|
391 |
$inner_title = '<h4 class="mc-title" aria-hidden="true">' . $event_title . '</h4>';
|
392 |
}
|
393 |
|
394 |
-
if ( 'true'
|
395 |
$description = wpautop( stripcslashes( mc_kses_post( $event->event_desc ) ), 1 );
|
396 |
$description = "<div class='longdesc description' itemprop='description'>$description</div>";
|
397 |
}
|
398 |
|
399 |
-
if ( 'true'
|
400 |
$info = wpautop( $event->event_registration );
|
401 |
$url = esc_url( $event->event_tickets );
|
402 |
$external = ( $url && mc_external_link( $url ) ) ? 'external' : '';
|
@@ -404,14 +406,14 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
|
|
404 |
$tickets = $info . $tickets;
|
405 |
}
|
406 |
|
407 |
-
if ( 'true'
|
408 |
$short = wpautop( stripcslashes( mc_kses_post( $event->event_short ) ), 1 );
|
409 |
$short = "<div class='shortdesc description'>$short</div>";
|
410 |
}
|
411 |
|
412 |
$status = apply_filters( 'mc_registration_state', '', $event );
|
413 |
$return_url = apply_filters( 'mc_return_uri', mc_get_uri( $event ) );
|
414 |
-
$return = ( 'single'
|
415 |
|
416 |
if ( ! mc_show_details( $time, $type ) ) {
|
417 |
$description = '';
|
@@ -419,16 +421,16 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
|
|
419 |
$status = '';
|
420 |
}
|
421 |
|
422 |
-
if ( 'true'
|
423 |
-
$map = ( is_singular( 'mc-events' ) || 'single'
|
424 |
} else {
|
425 |
$map = '';
|
426 |
}
|
427 |
$event_link = mc_event_link( $event );
|
428 |
|
429 |
-
if ( ''
|
430 |
$external_class = ( mc_external_link( $event_link ) ) ? "$type-link external url" : "$type-link url";
|
431 |
-
$link_template = ( ''
|
432 |
$link_text = mc_draw_template( $data, $link_template );
|
433 |
$link = "
|
434 |
<p>
|
@@ -457,11 +459,11 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
|
|
457 |
. $return;
|
458 |
} else {
|
459 |
// If a custom template is in use.
|
460 |
-
$toggle = ( 'calendar'
|
461 |
$details = $toggle . $details . "\n";
|
462 |
}
|
463 |
|
464 |
-
$img_class = ( ''
|
465 |
$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";
|
466 |
$container .= "<meta itemprop='name' content='" . strip_tags( $event->event_title ) . "' />";
|
467 |
$container = apply_filters( 'mc_before_event', $container, $event, $type, $time );
|
@@ -487,10 +489,10 @@ function my_calendar_draw_event( $event, $type = 'calendar', $process_date, $tim
|
|
487 |
*/
|
488 |
function mc_get_details( $data, $template, $type ) {
|
489 |
$details = false;
|
490 |
-
if ( ''
|
491 |
$template = file_get_contents( mc_get_file( $template ) );
|
492 |
$details = mc_draw_template( $data, $template );
|
493 |
-
} elseif ( ''
|
494 |
$template = mc_get_custom_template( $template );
|
495 |
$details = mc_draw_template( $data, $template );
|
496 |
} else {
|
@@ -536,7 +538,7 @@ function mc_get_details( $data, $template, $type ) {
|
|
536 |
function mc_get_event_image( $event, $data ) {
|
537 |
$image = '';
|
538 |
$sizes = get_intermediate_image_sizes();
|
539 |
-
if ( in_array( 'large', $sizes ) ) {
|
540 |
$default_size = 'large';
|
541 |
} else {
|
542 |
$default_size = 'medium';
|
@@ -550,7 +552,7 @@ function mc_get_event_image( $event, $data ) {
|
|
550 |
} else {
|
551 |
$alt = esc_attr( apply_filters( 'mc_event_image_alt', '', $event ) );
|
552 |
$image_url = $event->event_image;
|
553 |
-
$image = ( ''
|
554 |
}
|
555 |
|
556 |
$meta = ( $image ) ? "<meta itemprop='image' content='$image_url' />" : '';
|
@@ -568,7 +570,7 @@ function mc_get_event_image( $event, $data ) {
|
|
568 |
*/
|
569 |
function mc_disable_link( $status, $event ) {
|
570 |
$option = get_option( 'mc_no_link' );
|
571 |
-
if ( 'true'
|
572 |
$status = true;
|
573 |
}
|
574 |
|
@@ -605,11 +607,11 @@ function mc_event_classes( $event, $uid, $type ) {
|
|
605 |
$date_relation,
|
606 |
);
|
607 |
|
608 |
-
if ( $event->event_begin
|
609 |
$classes[] = 'multidate';
|
610 |
}
|
611 |
|
612 |
-
if ( 'upcoming'
|
613 |
$classes[] = 'vevent';
|
614 |
}
|
615 |
|
@@ -671,7 +673,7 @@ function mc_category_class( $object, $prefix ) {
|
|
671 |
function mc_show_details( $time, $type ) {
|
672 |
$no_link = apply_filters( 'mc_disable_link', false, array() );
|
673 |
|
674 |
-
return ( ( 'calendar'
|
675 |
}
|
676 |
|
677 |
add_filter( 'mc_after_event', 'mc_edit_panel', 10, 4 );
|
@@ -688,14 +690,14 @@ add_filter( 'mc_after_event', 'mc_edit_panel', 10, 4 );
|
|
688 |
function mc_edit_panel( $html, $event, $type, $time ) {
|
689 |
// Create edit links.
|
690 |
$edit = '';
|
691 |
-
if ( mc_can_edit_event( $event ) && get_option( 'mc_remote' )
|
692 |
$mc_id = $event->occur_id;
|
693 |
$groupedit = ( 0 != $event->event_group_id ) ? " • <a href='" . admin_url( "admin.php?page=my-calendar-groups&mode=edit&event_id=$event->event_id&group_id=$event->event_group_id" ) . "' class='group'>" . __( 'Edit Group', 'my-calendar' ) . "</a>\n" : '';
|
694 |
$recurs = str_split( $event->event_recur, 1 );
|
695 |
$recur = $recurs[0];
|
696 |
$referer = urlencode( mc_get_current_url() );
|
697 |
$edit = "<div class='mc_edit_links'><p>";
|
698 |
-
if ( 'S'
|
699 |
$edit .= "<a href='" . admin_url( "admin.php?page=my-calendar&mode=edit&event_id=$event->event_id&ref=$referer" ) . "' class='edit'>" . __( 'Edit', 'my-calendar' ) . "</a> • <a href='" . admin_url( "admin.php?page=my-calendar-manage&mode=delete&event_id=$event->event_id&ref=$referer" ) . "' class='delete'>" . __( 'Delete', 'my-calendar' ) . "</a>$groupedit";
|
700 |
} else {
|
701 |
$edit .= "<a href='" . admin_url( "admin.php?page=my-calendar&mode=edit&event_id=$event->event_id&date=$mc_id&ref=$referer" ) . "' class='edit'>" . __( 'Edit This Date', 'my-calendar' ) . "</a> • <a href='" . admin_url( "admin.php?page=my-calendar&mode=edit&event_id=$event->event_id&ref=$referer" ) . "' class='edit'>" . __( 'Edit All', 'my-calendar' ) . "</a> • <a href='" . admin_url( "admin.php?page=my-calendar-manage&mode=delete&event_id=$event->event_id&date=$mc_id&ref=$referer" ) . "' class='delete'>" . __( 'Delete This Date', 'my-calendar' ) . "</a> • <a href='" . admin_url( "admin.php?page=my-calendar-manage&mode=delete&event_id=$event->event_id&ref=$referer" ) . "' class='delete'>" . __( 'Delete All', 'my-calendar' ) . "</a>
|
@@ -721,7 +723,7 @@ function mc_edit_panel( $html, $event, $type, $time ) {
|
|
721 |
* @return string HTML output.
|
722 |
*/
|
723 |
function mc_date_switcher( $type = 'calendar', $cid = 'all', $time = 'month', $date = array() ) {
|
724 |
-
if ( 'week'
|
725 |
return '';
|
726 |
}
|
727 |
global $wpdb;
|
@@ -729,7 +731,7 @@ function mc_date_switcher( $type = 'calendar', $cid = 'all', $time = 'month', $d
|
|
729 |
$c_month = isset( $date['month'] ) ? $date['month'] : date( 'n', current_time( 'timestamp' ) );
|
730 |
$c_year = isset( $date['year'] ) ? $date['year'] : date( 'Y', current_time( 'timestamp' ) );
|
731 |
$c_day = isset( $date['day'] ) ? $date['day'] : date( 'j', current_time( 'timestamp' ) );
|
732 |
-
if ( 'true'
|
733 |
$mcdb = mc_remote_db();
|
734 |
}
|
735 |
$current_url = mc_get_current_url();
|
@@ -749,12 +751,12 @@ function mc_date_switcher( $type = 'calendar', $cid = 'all', $time = 'month', $d
|
|
749 |
} else {
|
750 |
$argument = esc_attr( strip_tags( $argument ) );
|
751 |
}
|
752 |
-
if ( 'month'
|
753 |
$date_switcher .= '<input type="hidden" name="' . $name . '" value="' . $argument . '" />';
|
754 |
}
|
755 |
}
|
756 |
$day_switcher = '';
|
757 |
-
if ( 'day'
|
758 |
$day_switcher = ' <label class="maybe-hide" for="' . $cid . '-day">' . __( 'Day', 'my-calendar' ) . '</label> <select id="' . $cid . '-day" name="dy">' . "\n";
|
759 |
for ( $i = 1; $i <= 31; $i++ ) {
|
760 |
$day_switcher .= "<option value='$i'" . selected( $i, $c_day, false ) . '>' . $i . '</option>' . "\n";
|
@@ -814,7 +816,7 @@ function mc_date_switcher( $type = 'calendar', $cid = 'all', $time = 'month', $d
|
|
814 |
* @return string HTML output
|
815 |
*/
|
816 |
function mc_format_toggle( $format, $toggle, $time ) {
|
817 |
-
if ( 'mini'
|
818 |
$toggle = "<div class='mc-format'>";
|
819 |
switch ( $format ) {
|
820 |
case 'list':
|
@@ -831,11 +833,11 @@ function mc_format_toggle( $format, $toggle, $time ) {
|
|
831 |
$toggle = '';
|
832 |
}
|
833 |
|
834 |
-
if ( 'day'
|
835 |
$toggle = "<div class='mc-format'><span class='mc-active list'>" . __( '<span class="maybe-hide">View as </span>List', 'my-calendar' ) . '</span></div>';
|
836 |
}
|
837 |
|
838 |
-
if ( ( 'true'
|
839 |
$toggle = '';
|
840 |
}
|
841 |
|
@@ -860,7 +862,7 @@ function mc_time_toggle( $format, $time, $month, $year, $current, $start_of_week
|
|
860 |
if ( isset( $_GET['dy'] ) ) {
|
861 |
$current_day = absint( $_GET['dy'] );
|
862 |
$current_set = mktime( 0, 0, 0, $month, $current_day, $year );
|
863 |
-
if ( date( 'N', $current_set )
|
864 |
$weeks_day = mc_first_day_of_week( $current_set );
|
865 |
} else {
|
866 |
$weeks_day = mc_first_day_of_week( $current );
|
@@ -869,7 +871,7 @@ function mc_time_toggle( $format, $time, $month, $year, $current, $start_of_week
|
|
869 |
$weeks_day = mc_first_day_of_week( current_time( 'timestamp' ) );
|
870 |
}
|
871 |
$day = $weeks_day[0];
|
872 |
-
if ( isset( $_GET['time'] ) && 'day'
|
873 |
// don't adjust day if viewing day format.
|
874 |
} else {
|
875 |
// if the current date is displayed and the week beginning day is greater than 20 in the month.
|
@@ -880,7 +882,7 @@ function mc_time_toggle( $format, $time, $month, $year, $current, $start_of_week
|
|
880 |
$adjust = ( isset( $weeks_day[1] ) ) ? $weeks_day[1] : 0;
|
881 |
$toggle = '';
|
882 |
|
883 |
-
if ( 'mini'
|
884 |
$toggle = "<div class='mc-time'>";
|
885 |
$current_url = mc_get_current_url();
|
886 |
if ( -1 == $adjust ) {
|
@@ -952,7 +954,7 @@ function mc_date_array( $timestamp, $period ) {
|
|
952 |
switch ( $period ) {
|
953 |
case 'month':
|
954 |
case 'month+1':
|
955 |
-
if ( 'month+1'
|
956 |
$timestamp = strtotime( '+1 month', $timestamp );
|
957 |
}
|
958 |
$start_of_week = get_option( 'start_of_week' );
|
@@ -960,7 +962,7 @@ function mc_date_array( $timestamp, $period ) {
|
|
960 |
$sub = date( 'w', $timestamp ); // numeric (how WordPress option is stored).
|
961 |
$n = ( 1 == $start_of_week ) ? $first - 1 : $first;
|
962 |
|
963 |
-
if ( $sub
|
964 |
$from = date( 'Y-m-d', $timestamp );
|
965 |
} else {
|
966 |
$start = strtotime( "-$n days", $timestamp );
|
@@ -1015,7 +1017,7 @@ function mc_events_class( $events, $date = false ) {
|
|
1015 |
} else {
|
1016 |
foreach ( array_keys( $events ) as $key ) {
|
1017 |
$event =& $events[ $key ];
|
1018 |
-
if ( '00:00:00'
|
1019 |
continue;
|
1020 |
}
|
1021 |
$author = ' author' . $event->event_author;
|
@@ -1082,7 +1084,7 @@ function mc_list_titles( $events ) {
|
|
1082 |
|
1083 |
$result = apply_filters( 'mc_titles_format', '', $titles );
|
1084 |
|
1085 |
-
if ( ''
|
1086 |
$result = implode( apply_filters( 'mc_list_titles_separator', ', ' ), $titles );
|
1087 |
}
|
1088 |
|
@@ -1199,16 +1201,16 @@ function mc_search_exportlinks() {
|
|
1199 |
$print = "<div class='mc-print'><a href='$mc_print_url'>" . __( 'Print<span class="maybe-hide"> View</span>', 'my-calendar' ) . '</a></div>';
|
1200 |
|
1201 |
// Set up exports.
|
1202 |
-
if ( ''
|
1203 |
$above = array_map( 'trim', explode( ',', get_option( 'mc_topnav' ) ) );
|
1204 |
}
|
1205 |
|
1206 |
-
if ( ''
|
1207 |
$below = array_map( 'trim', explode( ',', get_option( 'mc_bottomnav' ) ) );
|
1208 |
}
|
1209 |
$used = array_merge( $above, $below );
|
1210 |
|
1211 |
-
if ( in_array( 'exports', $used ) ) {
|
1212 |
$ics_add = array( 'searched' => true );
|
1213 |
$exports = mc_export_links( 1, 1, 1, $ics_add, $subtract );
|
1214 |
} else {
|
@@ -1281,7 +1283,7 @@ function mc_hidden_event() {
|
|
1281 |
if ( ! $post ) {
|
1282 |
return;
|
1283 |
}
|
1284 |
-
if ( is_object( $post ) && 'mc-events'
|
1285 |
$event_id = get_post_meta( $post->ID, '_mc_event_id', true );
|
1286 |
if ( ! $event_id ) {
|
1287 |
return;
|
@@ -1325,10 +1327,10 @@ function mc_event_filter( $title, $sep = ' | ', $seplocation = 'right' ) {
|
|
1325 |
return $title;
|
1326 |
}
|
1327 |
$array = mc_create_tags( $event );
|
1328 |
-
$left_sep = ( 'right'
|
1329 |
-
$right_sep = ( 'right'
|
1330 |
-
$template = get_option( 'mc_event_title_template' );
|
1331 |
-
$template = ( ''
|
1332 |
|
1333 |
return strip_tags( mc_draw_template( $array, $template ) );
|
1334 |
} else {
|
@@ -1346,7 +1348,7 @@ function mc_event_filter( $title, $sep = ' | ', $seplocation = 'right' ) {
|
|
1346 |
function mc_valid_id( $mc_id ) {
|
1347 |
global $wpdb;
|
1348 |
$mcdb = $wpdb;
|
1349 |
-
if ( 'true'
|
1350 |
$mcdb = mc_remote_db();
|
1351 |
}
|
1352 |
|
@@ -1372,7 +1374,7 @@ function mc_show_event_template( $content ) {
|
|
1372 |
if ( is_single() && in_the_loop() && is_main_query() ) {
|
1373 |
// Some early versions of this placed the shortcode into the post content. Strip that out.
|
1374 |
$new_content = $content;
|
1375 |
-
if ( 'mc-events'
|
1376 |
if ( isset( $_GET['mc_id'] ) && mc_valid_id( $_GET['mc_id'] ) ) {
|
1377 |
$mc_id = intval( $_GET['mc_id'] );
|
1378 |
$event_id = get_post_meta( $post->ID, '_mc_event_id', true );
|
@@ -1526,6 +1528,7 @@ function mc_calendar_params( $args ) {
|
|
1526 |
$smonth = isset( $args['month'] ) ? $args['month'] : false;
|
1527 |
$sday = isset( $args['day'] ) ? $args['day'] : false;
|
1528 |
$source = isset( $args['source'] ) ? $args['source'] : 'shortcode';
|
|
|
1529 |
$site = ( isset( $args['site'] ) && '' != trim( $args['site'] ) ) ? $args['site'] : false;
|
1530 |
$months = isset( $args['months'] ) ? $args['months'] : false;
|
1531 |
|
@@ -1575,6 +1578,7 @@ function mc_calendar_params( $args ) {
|
|
1575 |
'syear' => $syear,
|
1576 |
'smonth' => $smonth,
|
1577 |
'sday' => $sday,
|
|
|
1578 |
);
|
1579 |
|
1580 |
// Hash cannot include 'time', 'category', or 'format', since those can be changed by navigation.
|
@@ -1614,7 +1618,8 @@ function my_calendar( $args ) {
|
|
1614 |
$show_weekends = ( get_option( 'mc_show_weekends' ) == 'true' ) ? true : false;
|
1615 |
$skip_holidays = get_option( 'mc_skip_holidays_category' );
|
1616 |
$month_format = ( get_option( 'mc_month_format' ) == '' ) ? 'F Y' : get_option( 'mc_month_format' );
|
1617 |
-
$show_months = apply_filters( 'mc_show_months', get_option( 'mc_show_months' ), $args );
|
|
|
1618 |
$caption_text = ' ' . stripslashes( trim( get_option( 'mc_caption' ) ) );
|
1619 |
$week_format = ( ! get_option( 'mc_week_format' ) ) ? 'M j, \'y' : get_option( 'mc_week_format' );
|
1620 |
$week_template = ( get_option( 'mc_week_caption' ) != '' ) ? get_option( 'mc_week_caption' ) : 'Week of {date format="M jS"}';
|
@@ -1623,7 +1628,7 @@ function my_calendar( $args ) {
|
|
1623 |
$list_events = get_option( 'mc_show_list_events' );
|
1624 |
|
1625 |
if ( $site ) {
|
1626 |
-
$site = ( 'global'
|
1627 |
switch_to_blog( $site );
|
1628 |
}
|
1629 |
my_calendar_check();
|
@@ -1679,7 +1684,7 @@ function my_calendar( $args ) {
|
|
1679 |
'lvalue' => $params['lvalue'],
|
1680 |
'author' => $params['author'],
|
1681 |
'host' => $params['host'],
|
1682 |
-
'search' => '',
|
1683 |
'source' => 'calendar',
|
1684 |
'site' => $site,
|
1685 |
);
|
@@ -2014,6 +2019,7 @@ function mc_generate_calendar_nav( $params, $cat, $start_of_week, $show_months,
|
|
2014 |
// Fallback values.
|
2015 |
$mc_toporder = array( 'nav', 'toggle', 'jump', 'print', 'timeframe' );
|
2016 |
$mc_bottomorder = array( 'key', 'feeds' );
|
|
|
2017 |
|
2018 |
if ( 'none' == $above ) {
|
2019 |
$mc_toporder = array();
|
@@ -2129,14 +2135,14 @@ function mc_generate_calendar_nav( $params, $cat, $start_of_week, $show_months,
|
|
2129 |
}
|
2130 |
|
2131 |
foreach ( $mc_toporder as $value ) {
|
2132 |
-
if ( 'none' != $value && in_array( $value, $used ) ) {
|
2133 |
$value = trim( $value );
|
2134 |
$mc_topnav .= ${$value};
|
2135 |
}
|
2136 |
}
|
2137 |
|
2138 |
foreach ( $mc_bottomorder as $value ) {
|
2139 |
-
if ( 'none' != $value && 'stop' != $value && in_array( $value, $used ) ) {
|
2140 |
$value = trim( $value );
|
2141 |
$mc_bottomnav .= ${$value};
|
2142 |
}
|
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 |
|
39 |
* @return string
|
40 |
*/
|
41 |
function mc_date_format() {
|
42 |
+
$date_format = ( '' === get_option( 'mc_date_format', '' ) ) ? get_option( 'date_format' ) : get_option( 'mc_date_format' );
|
43 |
|
44 |
return $date_format;
|
45 |
}
|
58 |
$time_format = get_option( 'mc_time_format' );
|
59 |
$start = date( 'Y-m-d', strtotime( $e->occur_begin ) );
|
60 |
$end = date( 'Y-m-d', strtotime( $e->occur_end ) );
|
61 |
+
$has_time = ( '00:00:00' !== $e->event_time && '' !== $e->event_time ) ? true : false;
|
62 |
$final = '';
|
63 |
// Manipulate date_format based on event data.
|
64 |
+
if ( $e->event_end !== $e->event_begin && ! $has_time ) {
|
65 |
+
$mult_format = get_option( 'mc_multidate_format', '' );
|
66 |
+
$mult_format = ( '' !== $mult_format ) ? $mult_format : 'F j-%d, Y';
|
67 |
$date_format = str_replace( '%d', date( 'j', strtotime( $e->occur_end ) ), $mult_format );
|
68 |
}
|
69 |
// If this event crosses years or months, use original date format & show both dates.
|
70 |
+
if ( date( 'Y', strtotime( $e->occur_end ) ) !== date( 'Y', strtotime( $e->occur_begin ) ) || date( 'm', strtotime( $e->occur_end ) ) !== date( 'm', strtotime( $e->occur_begin ) ) ) {
|
71 |
$current = date_i18n( $orig_format, strtotime( $e->occur_begin ) ) . ' – ' . date_i18n( $orig_format, strtotime( $e->occur_end ) );
|
72 |
} else {
|
73 |
$current = date_i18n( $date_format, strtotime( $e->occur_begin ) );
|
74 |
+
$final = ( $e->event_end !== $e->event_begin ) ? date_i18n( $date_format, strtotime( $e->occur_end ) ) : $final;
|
75 |
}
|
76 |
// Do not show info in list view.
|
77 |
+
$time_content = ( 'list' === $type ) ? '' : "<span class='mc-event-date dtstart' itemprop='startDate' title='" . $start . 'T' . $e->event_time . "' content='" . $start . 'T' . $e->event_time . "'>$current</span>";
|
78 |
// Handle cases.
|
79 |
if ( $has_time ) {
|
80 |
$time_content .= "\n
|
84 |
</time>
|
85 |
</span>';
|
86 |
if ( 0 == $e->event_hide_end ) {
|
87 |
+
if ( '' !== $e->event_endtime && $e->event_endtime !== $e->event_time ) {
|
88 |
$time_content .= "
|
89 |
<span class='time-separator'> – </span>$final
|
90 |
<span class='end-time dtend'>
|
96 |
} else {
|
97 |
$notime = mc_notime_label( $e );
|
98 |
$time_content .= "<span class='event-time'>";
|
99 |
+
$time_content .= ( 'N/A' === $notime ) ? "<abbr title='" . __( 'Not Applicable', 'my-calendar' ) . "'>" . __( 'N/A', 'my-calendar' ) . "</abbr>\n" : esc_html( $notime );
|
100 |
$time_content .= '</span>';
|
101 |
}
|
102 |
$time_content .= apply_filters( 'mcs_end_time_block', '', $e );
|
121 |
if ( is_object( $event ) && property_exists( $event, 'category_icon' ) ) {
|
122 |
$url = plugin_dir_url( __FILE__ );
|
123 |
$image = '';
|
124 |
+
if ( 'true' !== get_option( 'mc_hide_icons' ) ) {
|
125 |
if ( '' != $event->category_icon ) {
|
126 |
$path = ( mc_is_custom_icon() ) ? str_replace( 'my-calendar', 'my-calendar-custom', $url ) : plugins_url( 'images/icons', __FILE__ ) . '/';
|
127 |
$hex = ( strpos( $event->category_color, '#' ) !== 0 ) ? '#' : '';
|
128 |
+
if ( 'html' === $type ) {
|
129 |
$image = '<img src="' . $path . $event->category_icon . '" alt="' . __( 'Category', 'my-calendar' ) . ': ' . esc_attr( $event->category_name ) . '" class="category-icon" style="background:' . $hex . $event->category_color . '" />';
|
130 |
} else {
|
131 |
$image = $path . $event->category_icon;
|
135 |
|
136 |
return apply_filters( 'mc_category_icon', $image, $event, $type );
|
137 |
}
|
138 |
+
|
139 |
+
return '';
|
140 |
}
|
141 |
|
142 |
add_filter( 'the_title', 'mc_category_icon_title', 10, 2 );
|
182 |
$time = $params['time'];
|
183 |
|
184 |
$open_option = get_option( 'mc_open_day_uri' );
|
185 |
+
if ( 'mini' === $type && ( 'true' === $open_option || 'listanchor' === $open_option || 'calendaranchor' === $open_option ) ) {
|
186 |
return true;
|
187 |
}
|
188 |
// We need to sort arrays of objects by time.
|
191 |
$begin = '';
|
192 |
$event_output = '';
|
193 |
$end = '';
|
194 |
+
if ( 'mini' === $type && count( $events ) > 0 ) {
|
195 |
$begin .= "<div id='date-$process_date' class='calendar-events'>";
|
196 |
}
|
197 |
foreach ( array_keys( $events ) as $key ) {
|
198 |
$event =& $events[ $key ];
|
199 |
+
if ( 'S1' !== $event->event_recur ) {
|
200 |
$check = get_post_meta( $event->event_post, '_occurrence_overlap', true );
|
201 |
+
if ( 'false' === $check ) {
|
202 |
$check = mc_test_occurrence_overlap( $event, true );
|
203 |
}
|
204 |
} else {
|
205 |
$check = '';
|
206 |
}
|
207 |
+
if ( '' === $check ) {
|
208 |
$output_array[] = my_calendar_draw_event( $event, $type, $process_date, $time, $template );
|
209 |
}
|
210 |
}
|
214 |
$event_output .= $value;
|
215 |
}
|
216 |
}
|
217 |
+
if ( '' === $event_output ) {
|
218 |
return '';
|
219 |
}
|
220 |
+
if ( 'mini' === $type && count( $events ) > 0 ) {
|
221 |
$end .= '</div>';
|
222 |
}
|
223 |
|
291 |
$uid = 'mc_' . $type . '_' . $day_id . '_' . $event->occur_id;
|
292 |
$image = mc_category_icon( $event );
|
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':
|
300 |
+
$title_template = ( mc_get_template( 'title' ) === '' ) ? '{title}' : mc_get_template( 'title' );
|
301 |
break;
|
302 |
case 'list':
|
303 |
+
$title_template = ( mc_get_template( 'title_list' ) === '' ) ? '{title}' : mc_get_template( 'title_list' );
|
304 |
break;
|
305 |
case 'single':
|
306 |
+
$title_template = ( mc_get_template( 'title_solo' ) === '' ) ? '{title}' : mc_get_template( 'title_solo' );
|
307 |
break;
|
308 |
default:
|
309 |
+
$title_template = ( mc_get_template( 'title' ) === '' ) ? '{title}' : mc_get_template( 'title' );
|
310 |
}
|
311 |
|
312 |
$event_title = mc_draw_template( $data, $title_template );
|
314 |
// If the first two characters of the title are ": ", this is the default templates but no time.
|
315 |
$event_title = str_replace( ': ', '', $event_title );
|
316 |
}
|
317 |
+
$event_title = ( '' === $event_title ) ? $data['title'] : strip_tags( $event_title, mc_strip_tags() );
|
318 |
$no_link = apply_filters( 'mc_disable_link', false, $data );
|
319 |
|
320 |
+
if ( ( ( strpos( $event_title, 'href' ) === false ) && 'mini' !== $type && 'list' !== $type ) && ! $no_link ) {
|
321 |
+
if ( 'true' === $open_uri ) {
|
322 |
$details_link = esc_url( mc_get_details_link( $event ) );
|
323 |
$wrap = ( _mc_is_url( $details_link ) ) ? "<a href='$details_link' class='url summary$has_image'>" : '<span class="no-link">';
|
324 |
$balance = ( _mc_is_url( $details_link ) ) ? '</a>' : '</span>';
|
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 );
|
341 |
$header .= '<span class="summary">' . $title . '</span>';
|
342 |
|
344 |
$close_button = "<button type='button' aria-controls='$uid-$type-details' class='mc-toggle close' data-action='shiftforward'>$close_image</button>";
|
345 |
|
346 |
if ( mc_show_details( $time, $type ) ) {
|
347 |
+
$close = ( 'calendar' === $type || 'mini' === $type ) ? $close_button : '';
|
348 |
|
349 |
if ( false === $details ) {
|
350 |
+
if ( ( 'true' === $display_address || 'true' === $display_map ) ) {
|
351 |
$address = mc_hcard( $event, $display_address, $display_map );
|
352 |
}
|
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 ) {
|
360 |
$e = get_userdata( $event->event_author );
|
361 |
$author = '<p class="event-author">' . __( 'Posted by', 'my-calendar' ) . ' <span class="author-name">' . $e->display_name . "</span></p>\n";
|
362 |
}
|
363 |
}
|
364 |
|
365 |
+
if ( 'false' !== $display_more && ! isset( $_GET['mc_id'] ) ) {
|
366 |
$details_label = mc_get_details_label( $event, $data );
|
367 |
$details_link = mc_get_details_link( $event );
|
368 |
// Translators: Event title.
|
375 |
}
|
376 |
$more = apply_filters( 'mc_details_grid_link', $more, $event );
|
377 |
|
378 |
+
if ( 'true' === $display_gcal ) {
|
379 |
$gcal = "<p class='gcal'>" . mc_draw_template( $data, '{gcal_link}' ) . '</p>';
|
380 |
}
|
381 |
|
382 |
+
if ( 'true' === $display_vcal ) {
|
383 |
$vcal = "<p class='ical'>" . mc_draw_template( $data, '{ical_html}' ) . '</p>';
|
384 |
}
|
385 |
|
386 |
+
if ( 'true' === $display_image ) {
|
387 |
$img = mc_get_event_image( $event, $data );
|
388 |
}
|
389 |
|
390 |
+
if ( 'calendar' === $type && 'true' === $display_title ) {
|
391 |
// In all cases, this is semantically a duplicate of the title, but can be beneficial for sighted users.
|
392 |
+
$headingtype = ( 'h3' === $hlevel ) ? 'h4' : 'h' . ( ( (int) str_replace( 'h', '', $hlevel ) ) - 1 );
|
393 |
$inner_title = '<h4 class="mc-title" aria-hidden="true">' . $event_title . '</h4>';
|
394 |
}
|
395 |
|
396 |
+
if ( 'true' === $display_desc || 'single' === $type ) {
|
397 |
$description = wpautop( stripcslashes( mc_kses_post( $event->event_desc ) ), 1 );
|
398 |
$description = "<div class='longdesc description' itemprop='description'>$description</div>";
|
399 |
}
|
400 |
|
401 |
+
if ( 'true' === $display_reg ) {
|
402 |
$info = wpautop( $event->event_registration );
|
403 |
$url = esc_url( $event->event_tickets );
|
404 |
$external = ( $url && mc_external_link( $url ) ) ? 'external' : '';
|
406 |
$tickets = $info . $tickets;
|
407 |
}
|
408 |
|
409 |
+
if ( 'true' === $display_short && 'single' !== $type ) {
|
410 |
$short = wpautop( stripcslashes( mc_kses_post( $event->event_short ) ), 1 );
|
411 |
$short = "<div class='shortdesc description'>$short</div>";
|
412 |
}
|
413 |
|
414 |
$status = apply_filters( 'mc_registration_state', '', $event );
|
415 |
$return_url = apply_filters( 'mc_return_uri', mc_get_uri( $event ) );
|
416 |
+
$return = ( 'single' === $type ) ? "<p class='view-full'><a href='$return_url'>" . __( 'View full calendar', 'my-calendar' ) . '</a></p>' : '';
|
417 |
|
418 |
if ( ! mc_show_details( $time, $type ) ) {
|
419 |
$description = '';
|
421 |
$status = '';
|
422 |
}
|
423 |
|
424 |
+
if ( 'true' === $display_gmap ) {
|
425 |
+
$map = ( is_singular( 'mc-events' ) || 'single' === $type ) ? mc_generate_map( $event ) : '';
|
426 |
} else {
|
427 |
$map = '';
|
428 |
}
|
429 |
$event_link = mc_event_link( $event );
|
430 |
|
431 |
+
if ( '' !== $event_link && 'false' !== $display_link ) {
|
432 |
$external_class = ( mc_external_link( $event_link ) ) ? "$type-link external url" : "$type-link url";
|
433 |
+
$link_template = ( '' !== mc_get_template( 'link' ) ) ? mc_get_template( 'link' ) : __( 'More information', 'my-calendar' );
|
434 |
$link_text = mc_draw_template( $data, $link_template );
|
435 |
$link = "
|
436 |
<p>
|
459 |
. $return;
|
460 |
} else {
|
461 |
// If a custom template is in use.
|
462 |
+
$toggle = ( 'calendar' === $type || 'mini' === $type ) ? $close_button : '';
|
463 |
$details = $toggle . $details . "\n";
|
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 );
|
489 |
*/
|
490 |
function mc_get_details( $data, $template, $type ) {
|
491 |
$details = false;
|
492 |
+
if ( '' !== $template && mc_file_exists( $template ) ) {
|
493 |
$template = file_get_contents( mc_get_file( $template ) );
|
494 |
$details = mc_draw_template( $data, $template );
|
495 |
+
} elseif ( '' !== $template && mc_key_exists( $template ) ) {
|
496 |
$template = mc_get_custom_template( $template );
|
497 |
$details = mc_draw_template( $data, $template );
|
498 |
} else {
|
538 |
function mc_get_event_image( $event, $data ) {
|
539 |
$image = '';
|
540 |
$sizes = get_intermediate_image_sizes();
|
541 |
+
if ( in_array( 'large', $sizes, true ) ) {
|
542 |
$default_size = 'large';
|
543 |
} else {
|
544 |
$default_size = 'medium';
|
552 |
} else {
|
553 |
$alt = esc_attr( apply_filters( 'mc_event_image_alt', '', $event ) );
|
554 |
$image_url = $event->event_image;
|
555 |
+
$image = ( '' !== $event->event_image ) ? "<img src='$event->event_image' alt='$alt' class='mc-image photo' />" : '';
|
556 |
}
|
557 |
|
558 |
$meta = ( $image ) ? "<meta itemprop='image' content='$image_url' />" : '';
|
570 |
*/
|
571 |
function mc_disable_link( $status, $event ) {
|
572 |
$option = get_option( 'mc_no_link' );
|
573 |
+
if ( 'true' === $option ) {
|
574 |
$status = true;
|
575 |
}
|
576 |
|
607 |
$date_relation,
|
608 |
);
|
609 |
|
610 |
+
if ( $event->event_begin !== $event->event_end ) {
|
611 |
$classes[] = 'multidate';
|
612 |
}
|
613 |
|
614 |
+
if ( 'upcoming' !== $type && 'related' !== $type ) {
|
615 |
$classes[] = 'vevent';
|
616 |
}
|
617 |
|
673 |
function mc_show_details( $time, $type ) {
|
674 |
$no_link = apply_filters( 'mc_disable_link', false, array() );
|
675 |
|
676 |
+
return ( ( 'calendar' === $type && 'true' === get_option( 'mc_open_uri' ) && 'day' !== $time ) || $no_link ) ? false : true;
|
677 |
}
|
678 |
|
679 |
add_filter( 'mc_after_event', 'mc_edit_panel', 10, 4 );
|
690 |
function mc_edit_panel( $html, $event, $type, $time ) {
|
691 |
// Create edit links.
|
692 |
$edit = '';
|
693 |
+
if ( mc_can_edit_event( $event ) && get_option( 'mc_remote' ) !== 'true' ) {
|
694 |
$mc_id = $event->occur_id;
|
695 |
$groupedit = ( 0 != $event->event_group_id ) ? " • <a href='" . admin_url( "admin.php?page=my-calendar-groups&mode=edit&event_id=$event->event_id&group_id=$event->event_group_id" ) . "' class='group'>" . __( 'Edit Group', 'my-calendar' ) . "</a>\n" : '';
|
696 |
$recurs = str_split( $event->event_recur, 1 );
|
697 |
$recur = $recurs[0];
|
698 |
$referer = urlencode( mc_get_current_url() );
|
699 |
$edit = "<div class='mc_edit_links'><p>";
|
700 |
+
if ( 'S' === $recur ) {
|
701 |
$edit .= "<a href='" . admin_url( "admin.php?page=my-calendar&mode=edit&event_id=$event->event_id&ref=$referer" ) . "' class='edit'>" . __( 'Edit', 'my-calendar' ) . "</a> • <a href='" . admin_url( "admin.php?page=my-calendar-manage&mode=delete&event_id=$event->event_id&ref=$referer" ) . "' class='delete'>" . __( 'Delete', 'my-calendar' ) . "</a>$groupedit";
|
702 |
} else {
|
703 |
$edit .= "<a href='" . admin_url( "admin.php?page=my-calendar&mode=edit&event_id=$event->event_id&date=$mc_id&ref=$referer" ) . "' class='edit'>" . __( 'Edit This Date', 'my-calendar' ) . "</a> • <a href='" . admin_url( "admin.php?page=my-calendar&mode=edit&event_id=$event->event_id&ref=$referer" ) . "' class='edit'>" . __( 'Edit All', 'my-calendar' ) . "</a> • <a href='" . admin_url( "admin.php?page=my-calendar-manage&mode=delete&event_id=$event->event_id&date=$mc_id&ref=$referer" ) . "' class='delete'>" . __( 'Delete This Date', 'my-calendar' ) . "</a> • <a href='" . admin_url( "admin.php?page=my-calendar-manage&mode=delete&event_id=$event->event_id&ref=$referer" ) . "' class='delete'>" . __( 'Delete All', 'my-calendar' ) . "</a>
|
723 |
* @return string HTML output.
|
724 |
*/
|
725 |
function mc_date_switcher( $type = 'calendar', $cid = 'all', $time = 'month', $date = array() ) {
|
726 |
+
if ( 'week' === $time ) {
|
727 |
return '';
|
728 |
}
|
729 |
global $wpdb;
|
731 |
$c_month = isset( $date['month'] ) ? $date['month'] : date( 'n', current_time( 'timestamp' ) );
|
732 |
$c_year = isset( $date['year'] ) ? $date['year'] : date( 'Y', current_time( 'timestamp' ) );
|
733 |
$c_day = isset( $date['day'] ) ? $date['day'] : date( 'j', current_time( 'timestamp' ) );
|
734 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
735 |
$mcdb = mc_remote_db();
|
736 |
}
|
737 |
$current_url = mc_get_current_url();
|
751 |
} else {
|
752 |
$argument = esc_attr( strip_tags( $argument ) );
|
753 |
}
|
754 |
+
if ( 'month' !== $name && 'yr' !== $name && 'dy' !== $name ) {
|
755 |
$date_switcher .= '<input type="hidden" name="' . $name . '" value="' . $argument . '" />';
|
756 |
}
|
757 |
}
|
758 |
$day_switcher = '';
|
759 |
+
if ( 'day' === $time ) {
|
760 |
$day_switcher = ' <label class="maybe-hide" for="' . $cid . '-day">' . __( 'Day', 'my-calendar' ) . '</label> <select id="' . $cid . '-day" name="dy">' . "\n";
|
761 |
for ( $i = 1; $i <= 31; $i++ ) {
|
762 |
$day_switcher .= "<option value='$i'" . selected( $i, $c_day, false ) . '>' . $i . '</option>' . "\n";
|
816 |
* @return string HTML output
|
817 |
*/
|
818 |
function mc_format_toggle( $format, $toggle, $time ) {
|
819 |
+
if ( 'mini' !== $format && 'yes' === $toggle ) {
|
820 |
$toggle = "<div class='mc-format'>";
|
821 |
switch ( $format ) {
|
822 |
case 'list':
|
833 |
$toggle = '';
|
834 |
}
|
835 |
|
836 |
+
if ( 'day' === $time ) {
|
837 |
$toggle = "<div class='mc-format'><span class='mc-active list'>" . __( '<span class="maybe-hide">View as </span>List', 'my-calendar' ) . '</span></div>';
|
838 |
}
|
839 |
|
840 |
+
if ( ( 'true' === get_option( 'mc_convert' ) || 'mini' === get_option( 'mc_convert' ) ) && mc_is_mobile() ) {
|
841 |
$toggle = '';
|
842 |
}
|
843 |
|
862 |
if ( isset( $_GET['dy'] ) ) {
|
863 |
$current_day = absint( $_GET['dy'] );
|
864 |
$current_set = mktime( 0, 0, 0, $month, $current_day, $year );
|
865 |
+
if ( date( 'N', $current_set ) === $start_of_week ) {
|
866 |
$weeks_day = mc_first_day_of_week( $current_set );
|
867 |
} else {
|
868 |
$weeks_day = mc_first_day_of_week( $current );
|
871 |
$weeks_day = mc_first_day_of_week( current_time( 'timestamp' ) );
|
872 |
}
|
873 |
$day = $weeks_day[0];
|
874 |
+
if ( isset( $_GET['time'] ) && 'day' === $_GET['time'] ) {
|
875 |
// don't adjust day if viewing day format.
|
876 |
} else {
|
877 |
// if the current date is displayed and the week beginning day is greater than 20 in the month.
|
882 |
$adjust = ( isset( $weeks_day[1] ) ) ? $weeks_day[1] : 0;
|
883 |
$toggle = '';
|
884 |
|
885 |
+
if ( 'mini' !== $format ) {
|
886 |
$toggle = "<div class='mc-time'>";
|
887 |
$current_url = mc_get_current_url();
|
888 |
if ( -1 == $adjust ) {
|
954 |
switch ( $period ) {
|
955 |
case 'month':
|
956 |
case 'month+1':
|
957 |
+
if ( 'month+1' === $period ) {
|
958 |
$timestamp = strtotime( '+1 month', $timestamp );
|
959 |
}
|
960 |
$start_of_week = get_option( 'start_of_week' );
|
962 |
$sub = date( 'w', $timestamp ); // numeric (how WordPress option is stored).
|
963 |
$n = ( 1 == $start_of_week ) ? $first - 1 : $first;
|
964 |
|
965 |
+
if ( $sub === $start_of_week ) {
|
966 |
$from = date( 'Y-m-d', $timestamp );
|
967 |
} else {
|
968 |
$start = strtotime( "-$n days", $timestamp );
|
1017 |
} else {
|
1018 |
foreach ( array_keys( $events ) as $key ) {
|
1019 |
$event =& $events[ $key ];
|
1020 |
+
if ( '00:00:00' === $event->event_endtime && date( 'Y-m-d', strtotime( $event->occur_end ) ) === $date && date( 'Y-m-d', strtotime( $event->occur_begin ) ) !== $date ) {
|
1021 |
continue;
|
1022 |
}
|
1023 |
$author = ' author' . $event->event_author;
|
1084 |
|
1085 |
$result = apply_filters( 'mc_titles_format', '', $titles );
|
1086 |
|
1087 |
+
if ( '' === $result ) {
|
1088 |
$result = implode( apply_filters( 'mc_list_titles_separator', ', ' ), $titles );
|
1089 |
}
|
1090 |
|
1201 |
$print = "<div class='mc-print'><a href='$mc_print_url'>" . __( 'Print<span class="maybe-hide"> View</span>', 'my-calendar' ) . '</a></div>';
|
1202 |
|
1203 |
// Set up exports.
|
1204 |
+
if ( '' !== get_option( 'mc_topnav', '' ) ) {
|
1205 |
$above = array_map( 'trim', explode( ',', get_option( 'mc_topnav' ) ) );
|
1206 |
}
|
1207 |
|
1208 |
+
if ( '' !== get_option( 'mc_bottomnav', '' ) ) {
|
1209 |
$below = array_map( 'trim', explode( ',', get_option( 'mc_bottomnav' ) ) );
|
1210 |
}
|
1211 |
$used = array_merge( $above, $below );
|
1212 |
|
1213 |
+
if ( in_array( 'exports', $used, true ) ) {
|
1214 |
$ics_add = array( 'searched' => true );
|
1215 |
$exports = mc_export_links( 1, 1, 1, $ics_add, $subtract );
|
1216 |
} else {
|
1283 |
if ( ! $post ) {
|
1284 |
return;
|
1285 |
}
|
1286 |
+
if ( is_object( $post ) && 'mc-events' === $post->post_type ) {
|
1287 |
$event_id = get_post_meta( $post->ID, '_mc_event_id', true );
|
1288 |
if ( ! $event_id ) {
|
1289 |
return;
|
1327 |
return $title;
|
1328 |
}
|
1329 |
$array = mc_create_tags( $event );
|
1330 |
+
$left_sep = ( 'right' !== $seplocation ? ' ' . $sep . ' ' : '' );
|
1331 |
+
$right_sep = ( 'right' !== $seplocation ? '' : ' ' . $sep . ' ' );
|
1332 |
+
$template = get_option( 'mc_event_title_template', '' );
|
1333 |
+
$template = ( '' !== $template ) ? stripslashes( $template ) : "$left_sep {title} $sep {date} $right_sep ";
|
1334 |
|
1335 |
return strip_tags( mc_draw_template( $array, $template ) );
|
1336 |
} else {
|
1348 |
function mc_valid_id( $mc_id ) {
|
1349 |
global $wpdb;
|
1350 |
$mcdb = $wpdb;
|
1351 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
1352 |
$mcdb = mc_remote_db();
|
1353 |
}
|
1354 |
|
1374 |
if ( is_single() && in_the_loop() && is_main_query() ) {
|
1375 |
// Some early versions of this placed the shortcode into the post content. Strip that out.
|
1376 |
$new_content = $content;
|
1377 |
+
if ( 'mc-events' === $post->post_type ) {
|
1378 |
if ( isset( $_GET['mc_id'] ) && mc_valid_id( $_GET['mc_id'] ) ) {
|
1379 |
$mc_id = intval( $_GET['mc_id'] );
|
1380 |
$event_id = get_post_meta( $post->ID, '_mc_event_id', true );
|
1528 |
$smonth = isset( $args['month'] ) ? $args['month'] : false;
|
1529 |
$sday = isset( $args['day'] ) ? $args['day'] : false;
|
1530 |
$source = isset( $args['source'] ) ? $args['source'] : 'shortcode';
|
1531 |
+
$search = isset( $args['search'] ) ? $args['search'] : '';
|
1532 |
$site = ( isset( $args['site'] ) && '' != trim( $args['site'] ) ) ? $args['site'] : false;
|
1533 |
$months = isset( $args['months'] ) ? $args['months'] : false;
|
1534 |
|
1578 |
'syear' => $syear,
|
1579 |
'smonth' => $smonth,
|
1580 |
'sday' => $sday,
|
1581 |
+
'search' => $search,
|
1582 |
);
|
1583 |
|
1584 |
// Hash cannot include 'time', 'category', or 'format', since those can be changed by navigation.
|
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"}';
|
1628 |
$list_events = get_option( 'mc_show_list_events' );
|
1629 |
|
1630 |
if ( $site ) {
|
1631 |
+
$site = ( 'global' === $site ) ? BLOG_ID_CURRENT_SITE : $site;
|
1632 |
switch_to_blog( $site );
|
1633 |
}
|
1634 |
my_calendar_check();
|
1684 |
'lvalue' => $params['lvalue'],
|
1685 |
'author' => $params['author'],
|
1686 |
'host' => $params['host'],
|
1687 |
+
'search' => $params['search'],
|
1688 |
'source' => 'calendar',
|
1689 |
'site' => $site,
|
1690 |
);
|
2019 |
// Fallback values.
|
2020 |
$mc_toporder = array( 'nav', 'toggle', 'jump', 'print', 'timeframe' );
|
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();
|
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 |
}
|
my-calendar-print.php
CHANGED
@@ -18,7 +18,7 @@ add_action( 'template_redirect', 'my_calendar_print_view' );
|
|
18 |
* Redirect to print view if query set.
|
19 |
*/
|
20 |
function my_calendar_print_view() {
|
21 |
-
if ( isset( $_GET['cid'] ) && 'mc-print-view'
|
22 |
echo my_calendar_print();
|
23 |
exit;
|
24 |
}
|
18 |
* Redirect to print view if query set.
|
19 |
*/
|
20 |
function my_calendar_print_view() {
|
21 |
+
if ( isset( $_GET['cid'] ) && 'mc-print-view' === $_GET['cid'] ) {
|
22 |
echo my_calendar_print();
|
23 |
exit;
|
24 |
}
|
my-calendar-settings.php
CHANGED
@@ -107,7 +107,7 @@ function mc_settings_field( $name, $label, $default = '', $note = '', $atts = ar
|
|
107 |
break;
|
108 |
}
|
109 |
|
110 |
-
if ( true
|
111 |
echo $return;
|
112 |
} else {
|
113 |
return $return;
|
@@ -118,13 +118,13 @@ function mc_settings_field( $name, $label, $default = '', $note = '', $atts = ar
|
|
118 |
* Display the admin configuration page
|
119 |
*/
|
120 |
function my_calendar_import() {
|
121 |
-
if ( 'true'
|
122 |
global $wpdb;
|
123 |
$events = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'calendar', 'ARRAY_A' );
|
124 |
$event_ids = array();
|
125 |
$events_results = false;
|
126 |
foreach ( $events as $key ) {
|
127 |
-
$endtime = ( '00:00:00'
|
128 |
$data = array(
|
129 |
'event_title' => $key['event_title'],
|
130 |
'event_desc' => $key['event_desc'],
|
@@ -200,9 +200,9 @@ function my_calendar_settings() {
|
|
200 |
if ( isset( $_POST['mc_manage'] ) ) {
|
201 |
// Management.
|
202 |
$clear = '';
|
203 |
-
$mc_api_enabled = ( ! empty( $_POST['mc_api_enabled'] ) && 'on'
|
204 |
-
$mc_remote = ( ! empty( $_POST['mc_remote'] ) && 'on'
|
205 |
-
$mc_drop_tables = ( ! empty( $_POST['mc_drop_tables'] ) && 'on'
|
206 |
// Handle My Calendar primary URL.
|
207 |
$mc_uri = get_option( 'mc_uri' );
|
208 |
if ( isset( $_POST['mc_uri'] ) && ! isset( $_POST['mc_uri_id'] ) ) {
|
@@ -262,15 +262,15 @@ 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'
|
266 |
-
update_option( 'mc_no_link', ( ! empty( $_POST['mc_no_link'] ) && 'on'
|
267 |
update_option( 'mc_mini_uri', $_POST['mc_mini_uri'] );
|
268 |
update_option( 'mc_open_day_uri', $mc_open_day_uri );
|
269 |
-
update_option( 'mc_display_author', ( ! empty( $_POST['mc_display_author'] ) && 'on'
|
270 |
-
update_option( 'mc_show_event_vcal', ( ! empty( $_POST['mc_show_event_vcal'] ) && 'on'
|
271 |
-
update_option( 'mc_show_gcal', ( ! empty( $_POST['mc_show_gcal'] ) && 'on'
|
272 |
-
update_option( 'mc_show_list_info', ( ! empty( $_POST['mc_show_list_info'] ) && 'on'
|
273 |
-
update_option( 'mc_show_list_events', ( ! empty( $_POST['mc_show_list_events'] ) && 'on'
|
274 |
update_option( 'mc_show_months', (int) $_POST['mc_show_months'] );
|
275 |
// Calculate sequence for navigation elements.
|
276 |
$top = array();
|
@@ -278,16 +278,16 @@ function my_calendar_settings() {
|
|
278 |
$nav = $_POST['mc_nav'];
|
279 |
$set = 'top';
|
280 |
foreach ( $nav as $n ) {
|
281 |
-
if ( 'calendar'
|
282 |
$set = 'bottom';
|
283 |
} else {
|
284 |
-
if ( 'top'
|
285 |
$top[] = $n;
|
286 |
} else {
|
287 |
$bottom[] = $n;
|
288 |
}
|
289 |
}
|
290 |
-
if ( 'stop'
|
291 |
break;
|
292 |
}
|
293 |
}
|
@@ -295,21 +295,21 @@ function my_calendar_settings() {
|
|
295 |
$bottom = ( empty( $bottom ) ) ? 'none' : implode( ',', $bottom );
|
296 |
update_option( 'mc_bottomnav', $bottom );
|
297 |
update_option( 'mc_topnav', $top );
|
298 |
-
update_option( 'mc_show_map', ( ! empty( $_POST['mc_show_map'] ) && 'on'
|
299 |
-
update_option( 'mc_gmap', ( ! empty( $_POST['mc_gmap'] ) && 'on'
|
300 |
update_option( 'mc_gmap_api_key', ( ! empty( $_POST['mc_gmap_api_key'] ) ) ? strip_tags( $_POST['mc_gmap_api_key'] ) : '' );
|
301 |
-
update_option( 'mc_show_address', ( ! empty( $_POST['mc_show_address'] ) && 'on'
|
302 |
-
update_option( 'mc_display_more', ( ! empty( $_POST['mc_display_more'] ) && 'on'
|
303 |
-
update_option( 'mc_event_registration', ( ! empty( $_POST['mc_event_registration'] ) && 'on'
|
304 |
-
update_option( 'mc_short', ( ! empty( $_POST['mc_short'] ) && 'on'
|
305 |
-
update_option( 'mc_desc', ( ! empty( $_POST['mc_desc'] ) && 'on'
|
306 |
-
update_option( 'mc_process_shortcodes', ( ! empty( $_POST['mc_process_shortcodes'] ) && 'on'
|
307 |
-
update_option( 'mc_event_link', ( ! empty( $_POST['mc_event_link'] ) && 'on'
|
308 |
-
update_option( 'mc_image', ( ! empty( $_POST['mc_image'] ) && 'on'
|
309 |
-
update_option( 'mc_show_weekends', ( ! empty( $_POST['mc_show_weekends'] ) && 'on'
|
310 |
-
update_option( 'mc_title', ( ! empty( $_POST['mc_title'] ) && 'on'
|
311 |
update_option( 'mc_convert', ( ! empty( $_POST['mc_convert'] ) ) ? $_POST['mc_convert'] : 'false' );
|
312 |
-
if ( ( isset( $_POST['mc_use_permalinks'] ) && 'true'
|
313 |
$url = admin_url( 'options-permalink.php#mc_cpt_base' );
|
314 |
// Translators: URL to permalink settings page.
|
315 |
$note = ' ' . sprintf( __( 'You activated My Calendar permalinks. Go to <a href="%s">permalink settings</a> to set the base URL for My Calendar Events.', 'my-calendar' ), $url );
|
@@ -320,7 +320,7 @@ function my_calendar_settings() {
|
|
320 |
}
|
321 |
// INPUT.
|
322 |
if ( isset( $_POST['mc_input'] ) ) {
|
323 |
-
$mc_input_options_administrators = ( ! empty( $_POST['mc_input_options_administrators'] ) && 'on'
|
324 |
$mc_input_options = array(
|
325 |
'event_short' => ( ! empty( $_POST['mci_event_short'] ) && $_POST['mci_event_short'] ) ? 'on' : 'off',
|
326 |
'event_desc' => ( ! empty( $_POST['mci_event_desc'] ) && $_POST['mci_event_desc'] ) ? 'on' : 'off',
|
@@ -337,9 +337,9 @@ function my_calendar_settings() {
|
|
337 |
);
|
338 |
update_option( 'mc_input_options', $mc_input_options );
|
339 |
update_option( 'mc_input_options_administrators', $mc_input_options_administrators );
|
340 |
-
update_option( 'mc_skip_holidays', ( ! empty( $_POST['mc_skip_holidays'] ) && 'on'
|
341 |
-
update_option( 'mc_no_fifth_week', ( ! empty( $_POST['mc_no_fifth_week'] ) && 'on'
|
342 |
-
update_option( 'mc_event_link_expires', ( ! empty( $_POST['mc_event_link_expires'] ) && 'on'
|
343 |
mc_show_notice( __( 'Input Settings saved', 'my-calendar' ) );
|
344 |
}
|
345 |
if ( current_user_can( 'manage_network' ) && is_multisite() ) {
|
@@ -387,8 +387,8 @@ function my_calendar_settings() {
|
|
387 |
}
|
388 |
// Mail function by Roland.
|
389 |
if ( isset( $_POST['mc_email'] ) ) {
|
390 |
-
$mc_event_mail = ( ! empty( $_POST['mc_event_mail'] ) && 'on'
|
391 |
-
$mc_html_email = ( ! empty( $_POST['mc_html_email'] ) && 'on'
|
392 |
$mc_event_mail_to = $_POST['mc_event_mail_to'];
|
393 |
$mc_event_mail_from = $_POST['mc_event_mail_from'];
|
394 |
$mc_event_mail_subject = $_POST['mc_event_mail_subject'];
|
@@ -422,14 +422,14 @@ function my_calendar_settings() {
|
|
422 |
<div class="mc-tabs settings postbox-container jcd-wide">
|
423 |
<div class="metabox-holder">
|
424 |
<?php
|
425 |
-
if ( isset( $_POST['import'] ) && 'true'
|
426 |
$nonce = $_REQUEST['_wpnonce'];
|
427 |
if ( ! wp_verify_nonce( $nonce, 'my-calendar-nonce' ) ) {
|
428 |
die( 'Security check failed' );
|
429 |
}
|
430 |
my_calendar_import();
|
431 |
}
|
432 |
-
if ( 'true'
|
433 |
if ( function_exists( 'check_calendar' ) ) {
|
434 |
?>
|
435 |
<div class='import upgrade-db'>
|
@@ -559,7 +559,7 @@ function my_calendar_settings() {
|
|
559 |
</li>
|
560 |
<li><?php mc_settings_field( 'mc_remote', __( 'Get data (events, categories and locations) from a remote database.', 'my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>
|
561 |
<?php
|
562 |
-
if ( 'true'
|
563 |
?>
|
564 |
<li><?php _e( 'Add this code to your theme\'s <code>functions.php</code> file:', 'my-calendar' ); ?>
|
565 |
<pre>
|
@@ -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()
|
582 |
mc_settings_field(
|
583 |
'mc_current_table',
|
584 |
array(
|
@@ -591,7 +591,7 @@ function mc_remote_db() {
|
|
591 |
'radio'
|
592 |
);
|
593 |
} else {
|
594 |
-
if ( get_option( 'mc_remote' )
|
595 |
?>
|
596 |
<li><?php _e( 'You are currently working in the primary site for this network; your local calendar is also the global table.', 'my-calendar' ); ?></li>
|
597 |
<?php
|
@@ -748,7 +748,7 @@ function mc_remote_db() {
|
|
748 |
$v = ( isset( $nav_elements[ $k ] ) ) ? $nav_elements[ $k ] : false;
|
749 |
if ( false !== $v ) {
|
750 |
$inserted[ $k ] = $v;
|
751 |
-
if ( 'stop'
|
752 |
$label = 'hide';
|
753 |
} else {
|
754 |
$label = $k;
|
@@ -885,7 +885,7 @@ function mc_remote_db() {
|
|
885 |
$input_options = get_option( 'mc_input_options' );
|
886 |
}
|
887 |
foreach ( $input_options as $key => $value ) {
|
888 |
-
$checked = ( 'on'
|
889 |
if ( isset( $input_labels[ $key ] ) ) {
|
890 |
$output .= "<li><input type='checkbox' id='mci_$key' name='mci_$key' $checked /> <label for='mci_$key'>$input_labels[$key]</label></li>";
|
891 |
}
|
@@ -989,7 +989,7 @@ function mc_remote_db() {
|
|
989 |
'mc_view_help' => __( 'View Help', 'my-calendar' ),
|
990 |
);
|
991 |
foreach ( $roles as $role => $rolename ) {
|
992 |
-
if ( 'administrator'
|
993 |
continue;
|
994 |
}
|
995 |
$role_container .= "<div class='mc_$role mc_permissions' id='container_mc_$role'><fieldset id='mc_$role' class='roles'><legend>$rolename</legend>";
|
107 |
break;
|
108 |
}
|
109 |
|
110 |
+
if ( true === $echo ) {
|
111 |
echo $return;
|
112 |
} else {
|
113 |
return $return;
|
118 |
* Display the admin configuration page
|
119 |
*/
|
120 |
function my_calendar_import() {
|
121 |
+
if ( 'true' !== get_option( 'ko_calendar_imported' ) ) {
|
122 |
global $wpdb;
|
123 |
$events = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'calendar', 'ARRAY_A' );
|
124 |
$event_ids = array();
|
125 |
$events_results = false;
|
126 |
foreach ( $events as $key ) {
|
127 |
+
$endtime = ( '00:00:00' === $key['event_time'] ) ? '00:00:00' : date( 'H:i:s', strtotime( "$key[event_time] +1 hour" ) );
|
128 |
$data = array(
|
129 |
'event_title' => $key['event_title'],
|
130 |
'event_desc' => $key['event_desc'],
|
200 |
if ( isset( $_POST['mc_manage'] ) ) {
|
201 |
// Management.
|
202 |
$clear = '';
|
203 |
+
$mc_api_enabled = ( ! empty( $_POST['mc_api_enabled'] ) && 'on' === $_POST['mc_api_enabled'] ) ? 'true' : 'false';
|
204 |
+
$mc_remote = ( ! empty( $_POST['mc_remote'] ) && 'on' === $_POST['mc_remote'] ) ? 'true' : 'false';
|
205 |
+
$mc_drop_tables = ( ! empty( $_POST['mc_drop_tables'] ) && 'on' === $_POST['mc_drop_tables'] ) ? 'true' : 'false';
|
206 |
// Handle My Calendar primary URL.
|
207 |
$mc_uri = get_option( 'mc_uri' );
|
208 |
if ( isset( $_POST['mc_uri'] ) && ! isset( $_POST['mc_uri_id'] ) ) {
|
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 );
|
269 |
+
update_option( 'mc_display_author', ( ! empty( $_POST['mc_display_author'] ) && 'on' === $_POST['mc_display_author'] ) ? 'true' : 'false' );
|
270 |
+
update_option( 'mc_show_event_vcal', ( ! empty( $_POST['mc_show_event_vcal'] ) && 'on' === $_POST['mc_show_event_vcal'] ) ? 'true' : 'false' );
|
271 |
+
update_option( 'mc_show_gcal', ( ! empty( $_POST['mc_show_gcal'] ) && 'on' === $_POST['mc_show_gcal'] ) ? 'true' : 'false' );
|
272 |
+
update_option( 'mc_show_list_info', ( ! empty( $_POST['mc_show_list_info'] ) && 'on' === $_POST['mc_show_list_info'] ) ? 'true' : 'false' );
|
273 |
+
update_option( 'mc_show_list_events', ( ! empty( $_POST['mc_show_list_events'] ) && 'on' === $_POST['mc_show_list_events'] ) ? 'true' : 'false' );
|
274 |
update_option( 'mc_show_months', (int) $_POST['mc_show_months'] );
|
275 |
// Calculate sequence for navigation elements.
|
276 |
$top = array();
|
278 |
$nav = $_POST['mc_nav'];
|
279 |
$set = 'top';
|
280 |
foreach ( $nav as $n ) {
|
281 |
+
if ( 'calendar' === $n ) {
|
282 |
$set = 'bottom';
|
283 |
} else {
|
284 |
+
if ( 'top' === $set ) {
|
285 |
$top[] = $n;
|
286 |
} else {
|
287 |
$bottom[] = $n;
|
288 |
}
|
289 |
}
|
290 |
+
if ( 'stop' === $n ) {
|
291 |
break;
|
292 |
}
|
293 |
}
|
295 |
$bottom = ( empty( $bottom ) ) ? 'none' : implode( ',', $bottom );
|
296 |
update_option( 'mc_bottomnav', $bottom );
|
297 |
update_option( 'mc_topnav', $top );
|
298 |
+
update_option( 'mc_show_map', ( ! empty( $_POST['mc_show_map'] ) && 'on' === $_POST['mc_show_map'] ) ? 'true' : 'false' );
|
299 |
+
update_option( 'mc_gmap', ( ! empty( $_POST['mc_gmap'] ) && 'on' === $_POST['mc_gmap'] ) ? 'true' : 'false' );
|
300 |
update_option( 'mc_gmap_api_key', ( ! empty( $_POST['mc_gmap_api_key'] ) ) ? strip_tags( $_POST['mc_gmap_api_key'] ) : '' );
|
301 |
+
update_option( 'mc_show_address', ( ! empty( $_POST['mc_show_address'] ) && 'on' === $_POST['mc_show_address'] ) ? 'true' : 'false' );
|
302 |
+
update_option( 'mc_display_more', ( ! empty( $_POST['mc_display_more'] ) && 'on' === $_POST['mc_display_more'] ) ? 'true' : 'false' );
|
303 |
+
update_option( 'mc_event_registration', ( ! empty( $_POST['mc_event_registration'] ) && 'on' === $_POST['mc_event_registration'] ) ? 'true' : 'false' );
|
304 |
+
update_option( 'mc_short', ( ! empty( $_POST['mc_short'] ) && 'on' === $_POST['mc_short'] ) ? 'true' : 'false' );
|
305 |
+
update_option( 'mc_desc', ( ! empty( $_POST['mc_desc'] ) && 'on' === $_POST['mc_desc'] ) ? 'true' : 'false' );
|
306 |
+
update_option( 'mc_process_shortcodes', ( ! empty( $_POST['mc_process_shortcodes'] ) && 'on' === $_POST['mc_process_shortcodes'] ) ? 'true' : 'false' );
|
307 |
+
update_option( 'mc_event_link', ( ! empty( $_POST['mc_event_link'] ) && 'on' === $_POST['mc_event_link'] ) ? 'true' : 'false' );
|
308 |
+
update_option( 'mc_image', ( ! empty( $_POST['mc_image'] ) && 'on' === $_POST['mc_image'] ) ? 'true' : 'false' );
|
309 |
+
update_option( 'mc_show_weekends', ( ! empty( $_POST['mc_show_weekends'] ) && 'on' === $_POST['mc_show_weekends'] ) ? 'true' : 'false' );
|
310 |
+
update_option( 'mc_title', ( ! empty( $_POST['mc_title'] ) && 'on' === $_POST['mc_title'] ) ? 'true' : 'false' );
|
311 |
update_option( 'mc_convert', ( ! empty( $_POST['mc_convert'] ) ) ? $_POST['mc_convert'] : 'false' );
|
312 |
+
if ( ( isset( $_POST['mc_use_permalinks'] ) && 'true' === get_option( 'mc_use_permalinks' ) ) && 'true' !== $permalinks ) {
|
313 |
$url = admin_url( 'options-permalink.php#mc_cpt_base' );
|
314 |
// Translators: URL to permalink settings page.
|
315 |
$note = ' ' . sprintf( __( 'You activated My Calendar permalinks. Go to <a href="%s">permalink settings</a> to set the base URL for My Calendar Events.', 'my-calendar' ), $url );
|
320 |
}
|
321 |
// INPUT.
|
322 |
if ( isset( $_POST['mc_input'] ) ) {
|
323 |
+
$mc_input_options_administrators = ( ! empty( $_POST['mc_input_options_administrators'] ) && 'on' === $_POST['mc_input_options_administrators'] ) ? 'true' : 'false';
|
324 |
$mc_input_options = array(
|
325 |
'event_short' => ( ! empty( $_POST['mci_event_short'] ) && $_POST['mci_event_short'] ) ? 'on' : 'off',
|
326 |
'event_desc' => ( ! empty( $_POST['mci_event_desc'] ) && $_POST['mci_event_desc'] ) ? 'on' : 'off',
|
337 |
);
|
338 |
update_option( 'mc_input_options', $mc_input_options );
|
339 |
update_option( 'mc_input_options_administrators', $mc_input_options_administrators );
|
340 |
+
update_option( 'mc_skip_holidays', ( ! empty( $_POST['mc_skip_holidays'] ) && 'on' === $_POST['mc_skip_holidays'] ) ? 'true' : 'false' );
|
341 |
+
update_option( 'mc_no_fifth_week', ( ! empty( $_POST['mc_no_fifth_week'] ) && 'on' === $_POST['mc_no_fifth_week'] ) ? 'true' : 'false' );
|
342 |
+
update_option( 'mc_event_link_expires', ( ! empty( $_POST['mc_event_link_expires'] ) && 'on' === $_POST['mc_event_link_expires'] ) ? 'true' : 'false' );
|
343 |
mc_show_notice( __( 'Input Settings saved', 'my-calendar' ) );
|
344 |
}
|
345 |
if ( current_user_can( 'manage_network' ) && is_multisite() ) {
|
387 |
}
|
388 |
// Mail function by Roland.
|
389 |
if ( isset( $_POST['mc_email'] ) ) {
|
390 |
+
$mc_event_mail = ( ! empty( $_POST['mc_event_mail'] ) && 'on' === $_POST['mc_event_mail'] ) ? 'true' : 'false';
|
391 |
+
$mc_html_email = ( ! empty( $_POST['mc_html_email'] ) && 'on' === $_POST['mc_html_email'] ) ? 'true' : 'false';
|
392 |
$mc_event_mail_to = $_POST['mc_event_mail_to'];
|
393 |
$mc_event_mail_from = $_POST['mc_event_mail_from'];
|
394 |
$mc_event_mail_subject = $_POST['mc_event_mail_subject'];
|
422 |
<div class="mc-tabs settings postbox-container jcd-wide">
|
423 |
<div class="metabox-holder">
|
424 |
<?php
|
425 |
+
if ( isset( $_POST['import'] ) && 'true' === $_POST['import'] ) {
|
426 |
$nonce = $_REQUEST['_wpnonce'];
|
427 |
if ( ! wp_verify_nonce( $nonce, 'my-calendar-nonce' ) ) {
|
428 |
die( 'Security check failed' );
|
429 |
}
|
430 |
my_calendar_import();
|
431 |
}
|
432 |
+
if ( 'true' !== get_option( 'ko_calendar_imported' ) ) {
|
433 |
if ( function_exists( 'check_calendar' ) ) {
|
434 |
?>
|
435 |
<div class='import upgrade-db'>
|
559 |
</li>
|
560 |
<li><?php mc_settings_field( 'mc_remote', __( 'Get data (events, categories and locations) from a remote database.', 'my-calendar' ), '', '', array(), 'checkbox-single' ); ?></li>
|
561 |
<?php
|
562 |
+
if ( 'true' === get_option( 'mc_remote' ) && ! function_exists( 'mc_remote_db' ) ) {
|
563 |
?>
|
564 |
<li><?php _e( 'Add this code to your theme\'s <code>functions.php</code> file:', 'my-calendar' ); ?>
|
565 |
<pre>
|
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(
|
591 |
'radio'
|
592 |
);
|
593 |
} else {
|
594 |
+
if ( get_option( 'mc_remote' ) !== 'true' && current_user_can( 'manage_network' ) && is_multisite() && is_main_site() ) {
|
595 |
?>
|
596 |
<li><?php _e( 'You are currently working in the primary site for this network; your local calendar is also the global table.', 'my-calendar' ); ?></li>
|
597 |
<?php
|
748 |
$v = ( isset( $nav_elements[ $k ] ) ) ? $nav_elements[ $k ] : false;
|
749 |
if ( false !== $v ) {
|
750 |
$inserted[ $k ] = $v;
|
751 |
+
if ( 'stop' === $k ) {
|
752 |
$label = 'hide';
|
753 |
} else {
|
754 |
$label = $k;
|
885 |
$input_options = get_option( 'mc_input_options' );
|
886 |
}
|
887 |
foreach ( $input_options as $key => $value ) {
|
888 |
+
$checked = ( 'on' === $value ) ? "checked='checked'" : '';
|
889 |
if ( isset( $input_labels[ $key ] ) ) {
|
890 |
$output .= "<li><input type='checkbox' id='mci_$key' name='mci_$key' $checked /> <label for='mci_$key'>$input_labels[$key]</label></li>";
|
891 |
}
|
989 |
'mc_view_help' => __( 'View Help', 'my-calendar' ),
|
990 |
);
|
991 |
foreach ( $roles as $role => $rolename ) {
|
992 |
+
if ( 'administrator' === $role ) {
|
993 |
continue;
|
994 |
}
|
995 |
$role_container .= "<div class='mc_$role mc_permissions' id='container_mc_$role'><fieldset id='mc_$role' class='roles'><legend>$rolename</legend>";
|
my-calendar-shortcodes.php
CHANGED
@@ -41,21 +41,27 @@ function my_calendar_insert( $atts, $content = null ) {
|
|
41 |
'day' => false,
|
42 |
'site' => false,
|
43 |
'months' => false,
|
|
|
44 |
),
|
45 |
$atts,
|
46 |
'my_calendar'
|
47 |
);
|
48 |
|
49 |
-
if ( 'mini'
|
50 |
if ( isset( $_GET['format'] ) ) {
|
51 |
$args['format'] = $_GET['format'];
|
52 |
}
|
53 |
}
|
|
|
|
|
|
|
|
|
|
|
54 |
global $user_ID;
|
55 |
-
if ( 'current'
|
56 |
$args['author'] = apply_filters( 'mc_display_author', $user_ID, 'main' );
|
57 |
}
|
58 |
-
if ( 'current'
|
59 |
$args['host'] = apply_filters( 'mc_display_host', $user_ID, 'main' );
|
60 |
}
|
61 |
|
@@ -94,10 +100,10 @@ function my_calendar_insert_upcoming( $atts ) {
|
|
94 |
);
|
95 |
|
96 |
global $user_ID;
|
97 |
-
if ( 'current'
|
98 |
$args['author'] = apply_filters( 'mc_display_author', $user_ID, 'upcoming' );
|
99 |
}
|
100 |
-
if ( 'current'
|
101 |
$args['host'] = apply_filters( 'mc_display_host', $user_ID, 'upcoming' );
|
102 |
}
|
103 |
|
@@ -127,10 +133,10 @@ function my_calendar_insert_today( $atts ) {
|
|
127 |
);
|
128 |
|
129 |
global $user_ID;
|
130 |
-
if ( 'current'
|
131 |
$args['author'] = apply_filters( 'mc_display_author', $user_ID, 'today' );
|
132 |
}
|
133 |
-
if ( 'current'
|
134 |
$args['host'] = apply_filters( 'mc_display_host', $user_ID, 'today' );
|
135 |
}
|
136 |
|
41 |
'day' => false,
|
42 |
'site' => false,
|
43 |
'months' => false,
|
44 |
+
'search' => '',
|
45 |
),
|
46 |
$atts,
|
47 |
'my_calendar'
|
48 |
);
|
49 |
|
50 |
+
if ( 'mini' !== $args['format'] ) {
|
51 |
if ( isset( $_GET['format'] ) ) {
|
52 |
$args['format'] = $_GET['format'];
|
53 |
}
|
54 |
}
|
55 |
+
|
56 |
+
if ( isset( $_GET['search'] ) ) {
|
57 |
+
$args['search'] = $_GET['search'];
|
58 |
+
}
|
59 |
+
|
60 |
global $user_ID;
|
61 |
+
if ( 'current' === $args['author'] ) {
|
62 |
$args['author'] = apply_filters( 'mc_display_author', $user_ID, 'main' );
|
63 |
}
|
64 |
+
if ( 'current' === $args['host'] ) {
|
65 |
$args['host'] = apply_filters( 'mc_display_host', $user_ID, 'main' );
|
66 |
}
|
67 |
|
100 |
);
|
101 |
|
102 |
global $user_ID;
|
103 |
+
if ( 'current' === $args['author'] ) {
|
104 |
$args['author'] = apply_filters( 'mc_display_author', $user_ID, 'upcoming' );
|
105 |
}
|
106 |
+
if ( 'current' === $args['host'] ) {
|
107 |
$args['host'] = apply_filters( 'mc_display_host', $user_ID, 'upcoming' );
|
108 |
}
|
109 |
|
133 |
);
|
134 |
|
135 |
global $user_ID;
|
136 |
+
if ( 'current' === $args['author'] ) {
|
137 |
$args['author'] = apply_filters( 'mc_display_author', $user_ID, 'today' );
|
138 |
}
|
139 |
+
if ( 'current' === $args['host'] ) {
|
140 |
$args['host'] = apply_filters( 'mc_display_host', $user_ID, 'today' );
|
141 |
}
|
142 |
|
my-calendar-styles.php
CHANGED
@@ -488,7 +488,7 @@ add_action(
|
|
488 |
return;
|
489 |
}
|
490 |
|
491 |
-
if ( 'my-
|
492 |
return;
|
493 |
}
|
494 |
|
488 |
return;
|
489 |
}
|
490 |
|
491 |
+
if ( sanitize_title( __( 'My Calendar', 'my-calendar' ) ) . '_page_my-calendar-styles' !== get_current_screen()->id ) {
|
492 |
return;
|
493 |
}
|
494 |
|
my-calendar-templates.php
CHANGED
@@ -50,11 +50,11 @@ function mc_draw_template( $array, $template, $type = 'list' ) {
|
|
50 |
// If a value is an object, ignore it.
|
51 |
} else {
|
52 |
if ( strpos( $template, '{' . $key ) !== false ) {
|
53 |
-
if ( 'list'
|
54 |
-
if ( 'link'
|
55 |
$value = mc_get_uri( false, $array );
|
56 |
}
|
57 |
-
if ( 'guid'
|
58 |
$value = htmlentities( $value );
|
59 |
}
|
60 |
}
|
@@ -71,7 +71,7 @@ function mc_draw_template( $array, $template, $type = 'list' ) {
|
|
71 |
if ( '' != $format ) {
|
72 |
$value = date_i18n( stripslashes( $format ), strtotime( stripslashes( $value ) ) );
|
73 |
}
|
74 |
-
$value = ( ''
|
75 |
$search = $matches[0][ $i ];
|
76 |
$template = str_replace( $search, $value, $template );
|
77 |
$value = $orig;
|
@@ -106,7 +106,7 @@ function mc_draw_template( $array, $template, $type = 'list' ) {
|
|
106 |
*/
|
107 |
function mc_map_string( $event, $source = 'event' ) {
|
108 |
$event = mc_clean_location( $event, $source );
|
109 |
-
if ( 'event'
|
110 |
$map_string = $event->event_street . ' ' . $event->event_street2 . ' ' . $event->event_city . ' ' . $event->event_state . ' ' . $event->event_postcode . ' ' . $event->event_country;
|
111 |
} else {
|
112 |
$map_string = $event->location_street . ' ' . $event->location_street2 . ' ' . $event->location_city . ' ' . $event->location_state . ' ' . $event->location_postcode . ' ' . $event->location_country;
|
@@ -124,42 +124,42 @@ function mc_map_string( $event, $source = 'event' ) {
|
|
124 |
* @return object $event
|
125 |
*/
|
126 |
function mc_clean_location( $event, $source = 'event' ) {
|
127 |
-
if ( 'event'
|
128 |
-
if ( 'none'
|
129 |
$event->event_city = '';
|
130 |
}
|
131 |
-
if ( 'none'
|
132 |
$event->event_state = '';
|
133 |
}
|
134 |
-
if ( 'none'
|
135 |
$event->event_country = '';
|
136 |
}
|
137 |
-
if ( 'none'
|
138 |
$event->event_postcode = '';
|
139 |
}
|
140 |
-
if ( 'none'
|
141 |
$event->event_region = '';
|
142 |
}
|
143 |
-
if ( 'none'
|
144 |
$event->event_location = '';
|
145 |
}
|
146 |
} else {
|
147 |
-
if ( 'none'
|
148 |
$event->location_city = '';
|
149 |
}
|
150 |
-
if ( 'none'
|
151 |
$event->location_state = '';
|
152 |
}
|
153 |
-
if ( 'none'
|
154 |
$event->location_country = '';
|
155 |
}
|
156 |
-
if ( 'none'
|
157 |
$event->location_postcode = '';
|
158 |
}
|
159 |
-
if ( 'none'
|
160 |
$event->location_region = '';
|
161 |
}
|
162 |
-
if ( 'none'
|
163 |
$event->location_label = '';
|
164 |
}
|
165 |
}
|
@@ -178,15 +178,15 @@ function mc_clean_location( $event, $source = 'event' ) {
|
|
178 |
*/
|
179 |
function mc_maplink( $event, $request = 'map', $source = 'event' ) {
|
180 |
$map_string = mc_map_string( $event, $source );
|
181 |
-
if ( 'event'
|
182 |
-
if ( 'gcal'
|
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'
|
190 |
$dir_lat = ( $event->event_latitude > 0 ) ? 'N' : 'S';
|
191 |
$latitude = abs( $event->event_latitude );
|
192 |
$dir_long = ( $event->event_longitude > 0 ) ? 'E' : 'W';
|
@@ -198,7 +198,7 @@ function mc_maplink( $event, $request = 'map', $source = 'event' ) {
|
|
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'
|
202 |
$dir_lat = ( $event->location_latitude > 0 ) ? 'N' : 'S';
|
203 |
$latitude = abs( $event->location_latitude );
|
204 |
$dir_long = ( $event->location_longitude > 0 ) ? 'E' : 'W';
|
@@ -218,7 +218,7 @@ function mc_maplink( $event, $request = 'map', $source = 'event' ) {
|
|
218 |
$map_url = '';
|
219 |
$map = '';
|
220 |
}
|
221 |
-
if ( 'url'
|
222 |
return $map_url;
|
223 |
} else {
|
224 |
return $map;
|
@@ -263,25 +263,25 @@ function mc_google_cal( $dtstart, $dtend, $url, $title, $location, $description
|
|
263 |
function mc_hcard( $event, $address = 'true', $map = 'true', $source = 'event' ) {
|
264 |
$the_map = mc_maplink( $event, 'url', $source );
|
265 |
$event = mc_clean_location( $event, $source );
|
266 |
-
$url = ( 'event'
|
267 |
$url = esc_url( $url );
|
268 |
-
$label = strip_tags( stripslashes( ( 'event'
|
269 |
-
$street = strip_tags( stripslashes( ( 'event'
|
270 |
-
$street2 = strip_tags( stripslashes( ( 'event'
|
271 |
-
$city = strip_tags( stripslashes( ( 'event'
|
272 |
-
$state = strip_tags( stripslashes( ( 'event'
|
273 |
-
$state = strip_tags( stripslashes( ( 'event'
|
274 |
-
$zip = strip_tags( stripslashes( ( 'event'
|
275 |
-
$zip = strip_tags( stripslashes( ( 'event'
|
276 |
-
$country = strip_tags( stripslashes( ( 'event'
|
277 |
-
$country = strip_tags( stripslashes( ( 'event'
|
278 |
-
$phone = strip_tags( stripslashes( ( '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'
|
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'>";
|
@@ -294,17 +294,17 @@ function mc_hcard( $event, $address = 'true', $map = 'true', $source = 'event' )
|
|
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 .= ( ''
|
298 |
$hcard .= '</div>';
|
299 |
}
|
300 |
-
if ( 'true'
|
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'
|
308 |
|
309 |
return apply_filters( 'mc_hcard', $hcard, $event, $address, $map, $source );
|
310 |
}
|
@@ -346,10 +346,10 @@ function mc_create_tags( $event, $context = 'filters' ) {
|
|
346 |
$e['date_utc'] = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_begin_ts' ), $event->ts_occur_begin );
|
347 |
$e['date_end_utc'] = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_end_ts' ), $event->ts_occur_end );
|
348 |
$notime = esc_html( mc_notime_label( $event ) );
|
349 |
-
$e['time'] = ( '00:00:00'
|
350 |
-
$e['time24'] = ( '00:00'
|
351 |
-
$endtime = ( '23:59:59'
|
352 |
-
$e['endtime'] = ( $real_end_date
|
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.
|
@@ -370,8 +370,8 @@ function mc_create_tags( $event, $context = 'filters' ) {
|
|
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
|
374 |
-
$e['timerange'] = ( ( $e['time']
|
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>–<span class='fallback-endtime'>$e[endtime]</span>" );
|
377 |
$e['began'] = $event->event_begin; // returns date of first occurrence of an event.
|
@@ -508,7 +508,7 @@ function mc_create_tags( $event, $context = 'filters' ) {
|
|
508 |
$e['event_span'] = $event->event_span;
|
509 |
|
510 |
// RSS guid.
|
511 |
-
$e['guid'] = "<guid isPermaLink='true'>" . esc_url( $e_link ) .
|
512 |
|
513 |
// ICAL.
|
514 |
$e['ical_description'] = str_replace( "\r", '=0D=0A=', $event->event_desc );
|
@@ -549,7 +549,7 @@ function mc_notime_label( $event ) {
|
|
549 |
} else {
|
550 |
$notime = '';
|
551 |
}
|
552 |
-
$notime = ( ''
|
553 |
|
554 |
return apply_filters( 'mc_notime_label', $notime, $event );
|
555 |
}
|
@@ -574,7 +574,7 @@ function mc_get_details_link( $event ) {
|
|
574 |
$permalinks = apply_filters( 'mc_use_permalinks', get_option( 'mc_use_permalinks' ) );
|
575 |
$permalinks = ( 1 === $permalinks || true === $permalinks || 'true' === $permalinks ) ? true : false;
|
576 |
$details_link = mc_event_link( $event );
|
577 |
-
if ( 0 != $event->event_post && 'true'
|
578 |
$details_link = add_query_arg( 'mc_id', $event->occur_id, get_permalink( $event->event_post ) );
|
579 |
} else {
|
580 |
if ( mc_get_uri( 'boolean' ) ) {
|
@@ -627,9 +627,9 @@ function mc_get_uri( $event = false, $args = array() ) {
|
|
627 |
$mc_uri = get_option( 'mc_uri' );
|
628 |
$mc_id = get_option( 'mc_uri_id' );
|
629 |
|
630 |
-
$uri = ( get_permalink( $mc_id )
|
631 |
|
632 |
-
if ( 'boolean'
|
633 |
if ( ! _mc_is_url( $uri ) ) {
|
634 |
return false;
|
635 |
} else {
|
@@ -680,7 +680,7 @@ function mc_get_details_label( $event, $e ) {
|
|
680 |
* @return string formatted time
|
681 |
*/
|
682 |
function mc_format_timestamp( $os, $source ) {
|
683 |
-
if ( isset( $_GET['outlook'] ) || 'outlook'
|
684 |
// Should iCal be in UTC or in current timezone.
|
685 |
$timezone_string = get_option( 'timezone_string' );
|
686 |
if ( ! $timezone_string ) {
|
@@ -717,7 +717,7 @@ function mc_format_timestamp( $os, $source ) {
|
|
717 |
*/
|
718 |
function mc_runtime( $start, $end, $event ) {
|
719 |
$return = '';
|
720 |
-
if ( ! ( $event->event_hide_end || $start == $end || '23:59:59'
|
721 |
$return = human_time_diff( $start, $end );
|
722 |
}
|
723 |
|
@@ -764,8 +764,9 @@ function mc_duration( $event ) {
|
|
764 |
* @return string
|
765 |
*/
|
766 |
function mc_event_link( $event ) {
|
|
|
767 |
if ( ! is_object( $event ) ) {
|
768 |
-
return;
|
769 |
}
|
770 |
$expired = mc_event_expired( $event );
|
771 |
if ( 0 == $event->event_link_expires ) {
|
@@ -816,7 +817,7 @@ function mc_generate_map( $event, $source = 'event' ) {
|
|
816 |
$value = '';
|
817 |
if ( $api_key ) {
|
818 |
$id = rand();
|
819 |
-
$source = ( 'event'
|
820 |
$zoom = ( 0 != $event->{$source . '_zoom'} ) ? $event->{$source . '_zoom'} : '15';
|
821 |
$category_icon = mc_category_icon( $event, 'img' );
|
822 |
if ( ! $category_icon ) {
|
@@ -824,7 +825,7 @@ function mc_generate_map( $event, $source = 'event' ) {
|
|
824 |
}
|
825 |
$address = addslashes( mc_map_string( $event, $source ) );
|
826 |
|
827 |
-
if ( '0.000000'
|
828 |
$latlng = 'latLng: [' . $event->{$source . '_latitude'} . ', ' . $event->{$source . '_longitude'} . '],';
|
829 |
} else {
|
830 |
$latlng = false;
|
@@ -934,7 +935,7 @@ function mc_event_date_span( $group_id, $event_span, $dates = array() ) {
|
|
934 |
if ( get_transient( 'mc_event_date_span_' . $group_id . '_' . $event_span ) ) {
|
935 |
return get_transient( 'mc_event_date_span_' . $group_id . '_' . $event_span );
|
936 |
}
|
937 |
-
if ( 'true'
|
938 |
$mcdb = mc_remote_db();
|
939 |
}
|
940 |
$group_id = (int) $group_id;
|
@@ -964,7 +965,7 @@ function mc_format_date_span( $dates, $display = 'simple', $default = '' ) {
|
|
964 |
}
|
965 |
$count = count( $dates );
|
966 |
$last = $count - 1;
|
967 |
-
if ( 'simple'
|
968 |
$begin = $dates[0]->occur_begin;
|
969 |
$end = $dates[ $last ]->occur_end;
|
970 |
$begin = date_i18n( apply_filters( 'mc_date_format', mc_date_format(), 'date_span_begin' ), strtotime( $begin ) );
|
@@ -978,10 +979,10 @@ function mc_format_date_span( $dates, $display = 'simple', $default = '' ) {
|
|
978 |
$day_begin = date( 'Y-m-d', strtotime( $begin ) );
|
979 |
$day_end = date( 'Y-m-d', strtotime( $end ) );
|
980 |
$bformat = '<span class="multidate-date">' . date_i18n( mc_date_format(), strtotime( $begin ) ) . "</span> <span class='multidate-time'>" . date_i18n( get_option( 'mc_time_format' ), strtotime( $begin ) ) . '</span>';
|
981 |
-
$endtimeformat = ( '00:00:00'
|
982 |
-
$eformat = ( $day_begin
|
983 |
-
$span = ( ''
|
984 |
-
$endspan = ( ''
|
985 |
$return .= "<li>$bformat" . $span . date_i18n( $eformat, strtotime( $end ) ) . "$endspan</li>";
|
986 |
}
|
987 |
$return .= '</ul>';
|
@@ -1010,10 +1011,10 @@ function mc_author_data( $e, $event ) {
|
|
1010 |
$e['author_id'] = $event->event_author;
|
1011 |
}
|
1012 |
if ( $host ) {
|
1013 |
-
$e['host'] = ( ! $host || ''
|
1014 |
$e['host_id'] = $event->event_host;
|
1015 |
-
$e['host_email'] = ( ! $host || ''
|
1016 |
-
$e['host_gravatar'] = ( ! $host || ''
|
1017 |
}
|
1018 |
} else {
|
1019 |
$e['author'] = 'Public Submitter';
|
@@ -1042,7 +1043,7 @@ function mc_auto_excerpt( $e, $event ) {
|
|
1042 |
$description = $e['description'];
|
1043 |
$shortdesc = $e['shortdesc'];
|
1044 |
$excerpt = '';
|
1045 |
-
if ( ''
|
1046 |
$num_words = apply_filters( 'mc_excerpt_length', 55 );
|
1047 |
$excerpt = wp_trim_words( $description, $num_words );
|
1048 |
} else {
|
@@ -1074,7 +1075,7 @@ function mc_image_data( $e, $event ) {
|
|
1074 |
$e[ $size ] = get_the_post_thumbnail( $event->event_post, $size, $atts );
|
1075 |
$e[ $size . '_url' ] = $src[0];
|
1076 |
}
|
1077 |
-
if ( isset( $e['large'] ) && ''
|
1078 |
$e['image_url'] = strip_tags( $e['large'] );
|
1079 |
$e['image'] = $e['large'];
|
1080 |
} else {
|
@@ -1089,8 +1090,8 @@ function mc_image_data( $e, $event ) {
|
|
1089 |
$e[ $size ] = '';
|
1090 |
$e[ $size . '_url' ] = '';
|
1091 |
}
|
1092 |
-
$e['image_url'] = ( ''
|
1093 |
-
$e['image'] = ( ''
|
1094 |
}
|
1095 |
|
1096 |
return $e;
|
50 |
// If a value is an object, ignore it.
|
51 |
} else {
|
52 |
if ( strpos( $template, '{' . $key ) !== false ) {
|
53 |
+
if ( 'list' !== $type ) {
|
54 |
+
if ( 'link' === $key && '' === $value ) {
|
55 |
$value = mc_get_uri( false, $array );
|
56 |
}
|
57 |
+
if ( 'guid' !== $key ) {
|
58 |
$value = htmlentities( $value );
|
59 |
}
|
60 |
}
|
71 |
if ( '' != $format ) {
|
72 |
$value = date_i18n( stripslashes( $format ), strtotime( stripslashes( $value ) ) );
|
73 |
}
|
74 |
+
$value = ( '' === (string) trim( $value ) ) ? '' : $before . $value . $after;
|
75 |
$search = $matches[0][ $i ];
|
76 |
$template = str_replace( $search, $value, $template );
|
77 |
$value = $orig;
|
106 |
*/
|
107 |
function mc_map_string( $event, $source = 'event' ) {
|
108 |
$event = mc_clean_location( $event, $source );
|
109 |
+
if ( 'event' === $source ) {
|
110 |
$map_string = $event->event_street . ' ' . $event->event_street2 . ' ' . $event->event_city . ' ' . $event->event_state . ' ' . $event->event_postcode . ' ' . $event->event_country;
|
111 |
} else {
|
112 |
$map_string = $event->location_street . ' ' . $event->location_street2 . ' ' . $event->location_city . ' ' . $event->location_state . ' ' . $event->location_postcode . ' ' . $event->location_country;
|
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 = '';
|
130 |
}
|
131 |
+
if ( 'none' === strtolower( $event->event_state ) ) {
|
132 |
$event->event_state = '';
|
133 |
}
|
134 |
+
if ( 'none' === strtolower( $event->event_country ) ) {
|
135 |
$event->event_country = '';
|
136 |
}
|
137 |
+
if ( 'none' === strtolower( $event->event_postcode ) ) {
|
138 |
$event->event_postcode = '';
|
139 |
}
|
140 |
+
if ( 'none' === strtolower( $event->event_region ) ) {
|
141 |
$event->event_region = '';
|
142 |
}
|
143 |
+
if ( 'none' === strtolower( $event->event_location ) ) {
|
144 |
$event->event_location = '';
|
145 |
}
|
146 |
} else {
|
147 |
+
if ( 'none' === strtolower( $event->location_city ) ) {
|
148 |
$event->location_city = '';
|
149 |
}
|
150 |
+
if ( 'none' === strtolower( $event->location_state ) ) {
|
151 |
$event->location_state = '';
|
152 |
}
|
153 |
+
if ( 'none' === strtolower( $event->location_country ) ) {
|
154 |
$event->location_country = '';
|
155 |
}
|
156 |
+
if ( 'none' === strtolower( $event->location_postcode ) ) {
|
157 |
$event->location_postcode = '';
|
158 |
}
|
159 |
+
if ( 'none' === strtolower( $event->location_region ) ) {
|
160 |
$event->location_region = '';
|
161 |
}
|
162 |
+
if ( 'none' === strtolower( $event->location_label ) ) {
|
163 |
$event->location_label = '';
|
164 |
}
|
165 |
}
|
178 |
*/
|
179 |
function mc_maplink( $event, $request = 'map', $source = 'event' ) {
|
180 |
$map_string = mc_map_string( $event, $source );
|
181 |
+
if ( 'event' === $source ) {
|
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';
|
191 |
$latitude = abs( $event->event_latitude );
|
192 |
$dir_long = ( $event->event_longitude > 0 ) ? 'E' : 'W';
|
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';
|
203 |
$latitude = abs( $event->location_latitude );
|
204 |
$dir_long = ( $event->location_longitude > 0 ) ? 'E' : 'W';
|
218 |
$map_url = '';
|
219 |
$map = '';
|
220 |
}
|
221 |
+
if ( 'url' === $request || 'location' === $source ) {
|
222 |
return $map_url;
|
223 |
} else {
|
224 |
return $map;
|
263 |
function mc_hcard( $event, $address = 'true', $map = 'true', $source = 'event' ) {
|
264 |
$the_map = mc_maplink( $event, 'url', $source );
|
265 |
$event = mc_clean_location( $event, $source );
|
266 |
+
$url = ( 'event' === $source ) ? $event->event_url : $event->location_url;
|
267 |
$url = esc_url( $url );
|
268 |
+
$label = strip_tags( stripslashes( ( 'event' === $source ) ? $event->event_label : $event->location_label ), mc_strip_tags() );
|
269 |
+
$street = strip_tags( stripslashes( ( 'event' === $source ) ? $event->event_street : $event->location_street ), mc_strip_tags() );
|
270 |
+
$street2 = strip_tags( stripslashes( ( 'event' === $source ) ? $event->event_street2 : $event->location_street2 ), mc_strip_tags() );
|
271 |
+
$city = strip_tags( stripslashes( ( 'event' === $source ) ? $event->event_city : $event->location_city ), mc_strip_tags() );
|
272 |
+
$state = strip_tags( stripslashes( ( 'event' === $source ) ? $event->event_state : $event->location_state ), mc_strip_tags() );
|
273 |
+
$state = strip_tags( stripslashes( ( 'event' === $source ) ? $event->event_state : $event->location_state ), mc_strip_tags() );
|
274 |
+
$zip = strip_tags( stripslashes( ( 'event' === $source ) ? $event->event_postcode : $event->location_postcode ), mc_strip_tags() );
|
275 |
+
$zip = strip_tags( stripslashes( ( 'event' === $source ) ? $event->event_postcode : $event->location_postcode ), mc_strip_tags() );
|
276 |
+
$country = strip_tags( stripslashes( ( 'event' === $source ) ? $event->event_country : $event->location_country ), mc_strip_tags() );
|
277 |
+
$country = strip_tags( stripslashes( ( 'event' === $source ) ? $event->event_country : $event->location_country ), mc_strip_tags() );
|
278 |
+
$phone = strip_tags( stripslashes( ( 'event' === $source ) ? $event->event_phone : $event->location_phone ), mc_strip_tags() );
|
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'>";
|
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 |
}
|
346 |
$e['date_utc'] = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_begin_ts' ), $event->ts_occur_begin );
|
347 |
$e['date_end_utc'] = date_i18n( apply_filters( 'mc_date_format', $date_format, 'template_end_ts' ), $event->ts_occur_end );
|
348 |
$notime = esc_html( mc_notime_label( $event ) );
|
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.
|
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>–</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>–</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>–<span class='fallback-endtime'>$e[endtime]</span>" );
|
377 |
$e['began'] = $event->event_begin; // returns date of first occurrence of an event.
|
508 |
$e['event_span'] = $event->event_span;
|
509 |
|
510 |
// RSS guid.
|
511 |
+
$e['guid'] = "<guid isPermaLink='true'>" . esc_url( $e_link ) . '</guid>';
|
512 |
|
513 |
// ICAL.
|
514 |
$e['ical_description'] = str_replace( "\r", '=0D=0A=', $event->event_desc );
|
549 |
} else {
|
550 |
$notime = '';
|
551 |
}
|
552 |
+
$notime = ( '' !== $notime ) ? $notime : get_option( 'mc_notime_text' );
|
553 |
|
554 |
return apply_filters( 'mc_notime_label', $notime, $event );
|
555 |
}
|
574 |
$permalinks = apply_filters( 'mc_use_permalinks', get_option( 'mc_use_permalinks' ) );
|
575 |
$permalinks = ( 1 === $permalinks || true === $permalinks || 'true' === $permalinks ) ? true : false;
|
576 |
$details_link = mc_event_link( $event );
|
577 |
+
if ( 0 != $event->event_post && 'true' !== get_option( 'mc_remote' ) && $permalinks ) {
|
578 |
$details_link = add_query_arg( 'mc_id', $event->occur_id, get_permalink( $event->event_post ) );
|
579 |
} else {
|
580 |
if ( mc_get_uri( 'boolean' ) ) {
|
627 |
$mc_uri = get_option( 'mc_uri' );
|
628 |
$mc_id = get_option( 'mc_uri_id' );
|
629 |
|
630 |
+
$uri = ( get_permalink( $mc_id ) !== get_option( 'mc_uri' ) ) ? get_option( 'mc_uri' ) : get_permalink( $mc_id );
|
631 |
|
632 |
+
if ( 'boolean' === $event ) {
|
633 |
if ( ! _mc_is_url( $uri ) ) {
|
634 |
return false;
|
635 |
} else {
|
680 |
* @return string formatted time
|
681 |
*/
|
682 |
function mc_format_timestamp( $os, $source ) {
|
683 |
+
if ( isset( $_GET['outlook'] ) || 'outlook' === $source ) {
|
684 |
// Should iCal be in UTC or in current timezone.
|
685 |
$timezone_string = get_option( 'timezone_string' );
|
686 |
if ( ! $timezone_string ) {
|
717 |
*/
|
718 |
function mc_runtime( $start, $end, $event ) {
|
719 |
$return = '';
|
720 |
+
if ( ! ( $event->event_hide_end || $start == $end || '23:59:59' === date( 'H:i:s', strtotime( $end ) ) ) ) {
|
721 |
$return = human_time_diff( $start, $end );
|
722 |
}
|
723 |
|
764 |
* @return string
|
765 |
*/
|
766 |
function mc_event_link( $event ) {
|
767 |
+
$link = '';
|
768 |
if ( ! is_object( $event ) ) {
|
769 |
+
return $link;
|
770 |
}
|
771 |
$expired = mc_event_expired( $event );
|
772 |
if ( 0 == $event->event_link_expires ) {
|
817 |
$value = '';
|
818 |
if ( $api_key ) {
|
819 |
$id = rand();
|
820 |
+
$source = ( 'event' === $source ) ? 'event' : 'location';
|
821 |
$zoom = ( 0 != $event->{$source . '_zoom'} ) ? $event->{$source . '_zoom'} : '15';
|
822 |
$category_icon = mc_category_icon( $event, 'img' );
|
823 |
if ( ! $category_icon ) {
|
825 |
}
|
826 |
$address = addslashes( mc_map_string( $event, $source ) );
|
827 |
|
828 |
+
if ( '0.000000' !== $event->{$source . '_longitude'} && '0.000000' !== $event->{$source . '_latitude'} ) {
|
829 |
$latlng = 'latLng: [' . $event->{$source . '_latitude'} . ', ' . $event->{$source . '_longitude'} . '],';
|
830 |
} else {
|
831 |
$latlng = false;
|
935 |
if ( get_transient( 'mc_event_date_span_' . $group_id . '_' . $event_span ) ) {
|
936 |
return get_transient( 'mc_event_date_span_' . $group_id . '_' . $event_span );
|
937 |
}
|
938 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
939 |
$mcdb = mc_remote_db();
|
940 |
}
|
941 |
$group_id = (int) $group_id;
|
965 |
}
|
966 |
$count = count( $dates );
|
967 |
$last = $count - 1;
|
968 |
+
if ( 'simple' === $display ) {
|
969 |
$begin = $dates[0]->occur_begin;
|
970 |
$end = $dates[ $last ]->occur_end;
|
971 |
$begin = date_i18n( apply_filters( 'mc_date_format', mc_date_format(), 'date_span_begin' ), strtotime( $begin ) );
|
979 |
$day_begin = date( 'Y-m-d', strtotime( $begin ) );
|
980 |
$day_end = date( 'Y-m-d', strtotime( $end ) );
|
981 |
$bformat = '<span class="multidate-date">' . date_i18n( mc_date_format(), strtotime( $begin ) ) . "</span> <span class='multidate-time'>" . date_i18n( get_option( 'mc_time_format' ), strtotime( $begin ) ) . '</span>';
|
982 |
+
$endtimeformat = ( '00:00:00' === $date->occur_end ) ? '' : ' ' . get_option( 'mc_time_format' );
|
983 |
+
$eformat = ( $day_begin !== $day_end ) ? mc_date_format() . $endtimeformat : $endtimeformat;
|
984 |
+
$span = ( '' !== $eformat ) ? " <span>–</span> <span class='multidate-end'>" : '';
|
985 |
+
$endspan = ( '' !== $eformat ) ? '</span>' : '';
|
986 |
$return .= "<li>$bformat" . $span . date_i18n( $eformat, strtotime( $end ) ) . "$endspan</li>";
|
987 |
}
|
988 |
$return .= '</ul>';
|
1011 |
$e['author_id'] = $event->event_author;
|
1012 |
}
|
1013 |
if ( $host ) {
|
1014 |
+
$e['host'] = ( ! $host || '' === $host->display_name ) ? $author->display_name : $host->display_name;
|
1015 |
$e['host_id'] = $event->event_host;
|
1016 |
+
$e['host_email'] = ( ! $host || '' === $host->user_email ) ? $author->user_email : $host->user_email;
|
1017 |
+
$e['host_gravatar'] = ( ! $host || '' === $host->user_email ) ? $e['gravatar'] : get_avatar( $host->user_email );
|
1018 |
}
|
1019 |
} else {
|
1020 |
$e['author'] = 'Public Submitter';
|
1043 |
$description = $e['description'];
|
1044 |
$shortdesc = $e['shortdesc'];
|
1045 |
$excerpt = '';
|
1046 |
+
if ( '' !== $description && '' === $shortdesc ) { // if description is empty, this won't work, so skip it.
|
1047 |
$num_words = apply_filters( 'mc_excerpt_length', 55 );
|
1048 |
$excerpt = wp_trim_words( $description, $num_words );
|
1049 |
} else {
|
1075 |
$e[ $size ] = get_the_post_thumbnail( $event->event_post, $size, $atts );
|
1076 |
$e[ $size . '_url' ] = $src[0];
|
1077 |
}
|
1078 |
+
if ( isset( $e['large'] ) && '' !== $e['large'] ) {
|
1079 |
$e['image_url'] = strip_tags( $e['large'] );
|
1080 |
$e['image'] = $e['large'];
|
1081 |
} else {
|
1090 |
$e[ $size ] = '';
|
1091 |
$e[ $size . '_url' ] = '';
|
1092 |
}
|
1093 |
+
$e['image_url'] = ( '' !== $event->event_image ) ? $event->event_image : '';
|
1094 |
+
$e['image'] = ( '' !== $event->event_image ) ? "<img src='$event->event_image' alt='' class='mc-image' />" : '';
|
1095 |
}
|
1096 |
|
1097 |
return $e;
|
my-calendar-templating.php
CHANGED
@@ -458,7 +458,7 @@ add_action(
|
|
458 |
return;
|
459 |
}
|
460 |
|
461 |
-
if ( 'my-
|
462 |
return;
|
463 |
}
|
464 |
|
458 |
return;
|
459 |
}
|
460 |
|
461 |
+
if ( sanitize_title( __( 'My Calendar', 'my-calendar' ) ) . '_page_my-calendar-templates' !== get_current_screen()->id ) {
|
462 |
return;
|
463 |
}
|
464 |
|
my-calendar-upgrade-db.php
CHANGED
@@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
17 |
* Check whether the My Calendar database is up to date
|
18 |
*/
|
19 |
function my_calendar_check_db() {
|
20 |
-
if ( 'true'
|
21 |
return;
|
22 |
}
|
23 |
|
@@ -25,11 +25,11 @@ function my_calendar_check_db() {
|
|
25 |
$cols = $wpdb->get_col( 'DESC ' . my_calendar_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
26 |
$needs_update = false;
|
27 |
|
28 |
-
if ( ! in_array( 'event_tickets', $cols ) ) {
|
29 |
$needs_update = true;
|
30 |
}
|
31 |
|
32 |
-
if ( isset( $_POST['upgrade'] ) && 'true'
|
33 |
mc_upgrade_db();
|
34 |
?>
|
35 |
<div class='upgrade-db updated'>
|
@@ -37,7 +37,7 @@ function my_calendar_check_db() {
|
|
37 |
</div>
|
38 |
<?php
|
39 |
} elseif ( $needs_update ) {
|
40 |
-
if ( 'my-calendar-config'
|
41 |
?>
|
42 |
<div class='upgrade-db error'>
|
43 |
<p>
|
17 |
* Check whether the My Calendar database is up to date
|
18 |
*/
|
19 |
function my_calendar_check_db() {
|
20 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
21 |
return;
|
22 |
}
|
23 |
|
25 |
$cols = $wpdb->get_col( 'DESC ' . my_calendar_table() ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
26 |
$needs_update = false;
|
27 |
|
28 |
+
if ( ! in_array( 'event_tickets', $cols, true ) ) {
|
29 |
$needs_update = true;
|
30 |
}
|
31 |
|
32 |
+
if ( isset( $_POST['upgrade'] ) && 'true' === $_POST['upgrade'] ) {
|
33 |
mc_upgrade_db();
|
34 |
?>
|
35 |
<div class='upgrade-db updated'>
|
37 |
</div>
|
38 |
<?php
|
39 |
} elseif ( $needs_update ) {
|
40 |
+
if ( 'my-calendar-config' === $_GET['page'] ) {
|
41 |
?>
|
42 |
<div class='upgrade-db error'>
|
43 |
<p>
|
my-calendar-widgets.php
CHANGED
@@ -45,31 +45,31 @@ function my_calendar_upcoming_events( $args ) {
|
|
45 |
$site = ( isset( $args['site'] ) ) ? $args['site'] : false;
|
46 |
|
47 |
if ( $site ) {
|
48 |
-
$site = ( 'global'
|
49 |
switch_to_blog( $site );
|
50 |
}
|
51 |
|
52 |
$hash = md5( implode( ',', $args ) );
|
53 |
$output = '';
|
54 |
$defaults = mc_widget_defaults();
|
55 |
-
$display_type = ( 'default'
|
56 |
$display_type = ( '' == $display_type ) ? 'events' : $display_type;
|
57 |
|
58 |
// Get number of units we should go into the future.
|
59 |
-
$after = ( 'default'
|
60 |
$after = ( '' == $after ) ? 10 : $after;
|
61 |
|
62 |
// Get number of units we should go into the past.
|
63 |
-
$before = ( 'default'
|
64 |
$before = ( '' == $before ) ? 0 : $before;
|
65 |
-
$category = ( 'default'
|
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 |
|
72 |
-
$template = ( ! $template || 'default'
|
73 |
if ( mc_key_exists( $template ) ) {
|
74 |
$template = mc_get_custom_template( $template );
|
75 |
}
|
@@ -78,71 +78,71 @@ function my_calendar_upcoming_events( $args ) {
|
|
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'
|
82 |
if ( ! $display_events ) {
|
83 |
$temp_array = array();
|
84 |
-
if ( 'days'
|
85 |
$from = date( 'Y-m-d', strtotime( "-$before days" ) );
|
86 |
$to = date( 'Y-m-d', strtotime( "+$after days" ) );
|
87 |
}
|
88 |
-
if ( 'month'
|
89 |
$from = date( 'Y-m-1' );
|
90 |
$to = date( 'Y-m-t' );
|
91 |
}
|
92 |
-
if ( 'custom'
|
93 |
$from = date( 'Y-m-d', strtotime( $from ) );
|
94 |
-
$to = ( 'today'
|
95 |
}
|
96 |
/* Yes, this is crude. But sometimes simplicity works best. There are only 12 possibilities, after all. */
|
97 |
-
if ( 'month+1'
|
98 |
$from = date( 'Y-m-1', strtotime( '+1 month' ) );
|
99 |
$to = date( 'Y-m-t', strtotime( '+1 month' ) );
|
100 |
}
|
101 |
-
if ( 'month+2'
|
102 |
$from = date( 'Y-m-1', strtotime( '+2 month' ) );
|
103 |
$to = date( 'Y-m-t', strtotime( '+2 month' ) );
|
104 |
}
|
105 |
-
if ( 'month+3'
|
106 |
$from = date( 'Y-m-1', strtotime( '+3 month' ) );
|
107 |
$to = date( 'Y-m-t', strtotime( '+3 month' ) );
|
108 |
}
|
109 |
-
if ( 'month+4'
|
110 |
$from = date( 'Y-m-1', strtotime( '+4 month' ) );
|
111 |
$to = date( 'Y-m-t', strtotime( '+4 month' ) );
|
112 |
}
|
113 |
-
if ( 'month+5'
|
114 |
$from = date( 'Y-m-1', strtotime( '+5 month' ) );
|
115 |
$to = date( 'Y-m-t', strtotime( '+5 month' ) );
|
116 |
}
|
117 |
-
if ( 'month+6'
|
118 |
$from = date( 'Y-m-1', strtotime( '+6 month' ) );
|
119 |
$to = date( 'Y-m-t', strtotime( '+6 month' ) );
|
120 |
}
|
121 |
-
if ( 'month+7'
|
122 |
$from = date( 'Y-m-1', strtotime( '+7 month' ) );
|
123 |
$to = date( 'Y-m-t', strtotime( '+7 month' ) );
|
124 |
}
|
125 |
-
if ( 'month+8'
|
126 |
$from = date( 'Y-m-1', strtotime( '+8 month' ) );
|
127 |
$to = date( 'Y-m-t', strtotime( '+8 month' ) );
|
128 |
}
|
129 |
-
if ( 'month+9'
|
130 |
$from = date( 'Y-m-1', strtotime( '+9 month' ) );
|
131 |
$to = date( 'Y-m-t', strtotime( '+9 month' ) );
|
132 |
}
|
133 |
-
if ( 'month+10'
|
134 |
$from = date( 'Y-m-1', strtotime( '+10 month' ) );
|
135 |
$to = date( 'Y-m-t', strtotime( '+10 month' ) );
|
136 |
}
|
137 |
-
if ( 'month+11'
|
138 |
$from = date( 'Y-m-1', strtotime( '+11 month' ) );
|
139 |
$to = date( 'Y-m-t', strtotime( '+11 month' ) );
|
140 |
}
|
141 |
-
if ( 'month+12'
|
142 |
$from = date( 'Y-m-1', strtotime( '+12 month' ) );
|
143 |
$to = date( 'Y-m-t', strtotime( '+12 month' ) );
|
144 |
}
|
145 |
-
if ( 'year'
|
146 |
$from = date( 'Y-1-1' );
|
147 |
$to = date( 'Y-12-31' );
|
148 |
}
|
@@ -240,7 +240,7 @@ function my_calendar_upcoming_events( $args ) {
|
|
240 |
$output = '';
|
241 |
}
|
242 |
}
|
243 |
-
if ( ''
|
244 |
$output = apply_filters( 'mc_upcoming_events_header', $header ) . $output . apply_filters( 'mc_upcoming_events_footer', $footer );
|
245 |
$return = mc_run_shortcodes( $output );
|
246 |
} else {
|
@@ -264,7 +264,7 @@ function my_calendar_upcoming_events( $args ) {
|
|
264 |
function mc_span_time( $group_id ) {
|
265 |
global $wpdb;
|
266 |
$mcdb = $wpdb;
|
267 |
-
if ( 'true'
|
268 |
$mcdb = mc_remote_db();
|
269 |
}
|
270 |
$group_id = (int) $group_id;
|
@@ -419,7 +419,7 @@ function mc_produce_upcoming_events( $events, $template, $type = 'list', $order
|
|
419 |
if ( 1 == $details['event_span'] ) {
|
420 |
$class = 'multiday';
|
421 |
}
|
422 |
-
if ( 'list'
|
423 |
$prepend = "\n<li class=\"$class $category $classes\">";
|
424 |
$append = "</li>\n";
|
425 |
} else {
|
@@ -435,7 +435,7 @@ function mc_produce_upcoming_events( $events, $template, $type = 'list', $order
|
|
435 |
if ( ! in_array( $details['dateid'], $skips ) ) {
|
436 |
|
437 |
$item = apply_filters( 'mc_draw_upcoming_event', '', $details, $template, $type );
|
438 |
-
if ( ''
|
439 |
$item = mc_draw_template( $details, $template, $type );
|
440 |
}
|
441 |
|
@@ -482,7 +482,7 @@ function my_calendar_todays_events( $args ) {
|
|
482 |
$site = ( isset( $args['site'] ) ) ? $args['site'] : false;
|
483 |
|
484 |
if ( $site ) {
|
485 |
-
$site = ( 'global'
|
486 |
switch_to_blog( $site );
|
487 |
}
|
488 |
|
@@ -502,13 +502,13 @@ function my_calendar_todays_events( $args ) {
|
|
502 |
$template = file_get_contents( mc_get_file( $template ) );
|
503 |
}
|
504 |
$defaults = mc_widget_defaults();
|
505 |
-
$template = ( ! $template || 'default'
|
506 |
|
507 |
if ( mc_key_exists( $template ) ) {
|
508 |
$template = mc_get_custom_template( $template );
|
509 |
}
|
510 |
|
511 |
-
$category = ( 'default'
|
512 |
$no_event_text = ( '' == $substitute ) ? $defaults['today']['text'] : $substitute;
|
513 |
if ( $date ) {
|
514 |
$from = date( 'Y-m-d', strtotime( $date ) );
|
@@ -559,7 +559,7 @@ function my_calendar_todays_events( $args ) {
|
|
559 |
$append = apply_filters( 'mc_todays_events_after', '</li>' );
|
560 |
|
561 |
$item = apply_filters( 'mc_draw_todays_event', '', $event_details, $template );
|
562 |
-
if ( ''
|
563 |
$item = mc_draw_template( $event_details, $template );
|
564 |
}
|
565 |
$todays_events[ $ts ][] = $prepend . $item . $append;
|
45 |
$site = ( isset( $args['site'] ) ) ? $args['site'] : false;
|
46 |
|
47 |
if ( $site ) {
|
48 |
+
$site = ( 'global' === $site ) ? BLOG_ID_CURRENT_SITE : $site;
|
49 |
switch_to_blog( $site );
|
50 |
}
|
51 |
|
52 |
$hash = md5( implode( ',', $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 |
|
72 |
+
$template = ( ! $template || 'default' === $template ) ? $defaults['upcoming']['template'] : $template;
|
73 |
if ( mc_key_exists( $template ) ) {
|
74 |
$template = mc_get_custom_template( $template );
|
75 |
}
|
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;
|
82 |
if ( ! $display_events ) {
|
83 |
$temp_array = array();
|
84 |
+
if ( 'days' === $display_type ) {
|
85 |
$from = date( 'Y-m-d', strtotime( "-$before days" ) );
|
86 |
$to = date( 'Y-m-d', strtotime( "+$after days" ) );
|
87 |
}
|
88 |
+
if ( 'month' === $display_type ) {
|
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 |
}
|
96 |
/* Yes, this is crude. But sometimes simplicity works best. There are only 12 possibilities, after all. */
|
97 |
+
if ( 'month+1' === $display_type ) {
|
98 |
$from = date( 'Y-m-1', strtotime( '+1 month' ) );
|
99 |
$to = date( 'Y-m-t', strtotime( '+1 month' ) );
|
100 |
}
|
101 |
+
if ( 'month+2' === $display_type ) {
|
102 |
$from = date( 'Y-m-1', strtotime( '+2 month' ) );
|
103 |
$to = date( 'Y-m-t', strtotime( '+2 month' ) );
|
104 |
}
|
105 |
+
if ( 'month+3' === $display_type ) {
|
106 |
$from = date( 'Y-m-1', strtotime( '+3 month' ) );
|
107 |
$to = date( 'Y-m-t', strtotime( '+3 month' ) );
|
108 |
}
|
109 |
+
if ( 'month+4' === $display_type ) {
|
110 |
$from = date( 'Y-m-1', strtotime( '+4 month' ) );
|
111 |
$to = date( 'Y-m-t', strtotime( '+4 month' ) );
|
112 |
}
|
113 |
+
if ( 'month+5' === $display_type ) {
|
114 |
$from = date( 'Y-m-1', strtotime( '+5 month' ) );
|
115 |
$to = date( 'Y-m-t', strtotime( '+5 month' ) );
|
116 |
}
|
117 |
+
if ( 'month+6' === $display_type ) {
|
118 |
$from = date( 'Y-m-1', strtotime( '+6 month' ) );
|
119 |
$to = date( 'Y-m-t', strtotime( '+6 month' ) );
|
120 |
}
|
121 |
+
if ( 'month+7' === $display_type ) {
|
122 |
$from = date( 'Y-m-1', strtotime( '+7 month' ) );
|
123 |
$to = date( 'Y-m-t', strtotime( '+7 month' ) );
|
124 |
}
|
125 |
+
if ( 'month+8' === $display_type ) {
|
126 |
$from = date( 'Y-m-1', strtotime( '+8 month' ) );
|
127 |
$to = date( 'Y-m-t', strtotime( '+8 month' ) );
|
128 |
}
|
129 |
+
if ( 'month+9' === $display_type ) {
|
130 |
$from = date( 'Y-m-1', strtotime( '+9 month' ) );
|
131 |
$to = date( 'Y-m-t', strtotime( '+9 month' ) );
|
132 |
}
|
133 |
+
if ( 'month+10' === $display_type ) {
|
134 |
$from = date( 'Y-m-1', strtotime( '+10 month' ) );
|
135 |
$to = date( 'Y-m-t', strtotime( '+10 month' ) );
|
136 |
}
|
137 |
+
if ( 'month+11' === $display_type ) {
|
138 |
$from = date( 'Y-m-1', strtotime( '+11 month' ) );
|
139 |
$to = date( 'Y-m-t', strtotime( '+11 month' ) );
|
140 |
}
|
141 |
+
if ( 'month+12' === $display_type ) {
|
142 |
$from = date( 'Y-m-1', strtotime( '+12 month' ) );
|
143 |
$to = date( 'Y-m-t', strtotime( '+12 month' ) );
|
144 |
}
|
145 |
+
if ( 'year' === $display_type ) {
|
146 |
$from = date( 'Y-1-1' );
|
147 |
$to = date( 'Y-12-31' );
|
148 |
}
|
240 |
$output = '';
|
241 |
}
|
242 |
}
|
243 |
+
if ( '' !== $output ) {
|
244 |
$output = apply_filters( 'mc_upcoming_events_header', $header ) . $output . apply_filters( 'mc_upcoming_events_footer', $footer );
|
245 |
$return = mc_run_shortcodes( $output );
|
246 |
} else {
|
264 |
function mc_span_time( $group_id ) {
|
265 |
global $wpdb;
|
266 |
$mcdb = $wpdb;
|
267 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
268 |
$mcdb = mc_remote_db();
|
269 |
}
|
270 |
$group_id = (int) $group_id;
|
419 |
if ( 1 == $details['event_span'] ) {
|
420 |
$class = 'multiday';
|
421 |
}
|
422 |
+
if ( 'list' === $type ) {
|
423 |
$prepend = "\n<li class=\"$class $category $classes\">";
|
424 |
$append = "</li>\n";
|
425 |
} else {
|
435 |
if ( ! in_array( $details['dateid'], $skips ) ) {
|
436 |
|
437 |
$item = apply_filters( 'mc_draw_upcoming_event', '', $details, $template, $type );
|
438 |
+
if ( '' === $item ) {
|
439 |
$item = mc_draw_template( $details, $template, $type );
|
440 |
}
|
441 |
|
482 |
$site = ( isset( $args['site'] ) ) ? $args['site'] : false;
|
483 |
|
484 |
if ( $site ) {
|
485 |
+
$site = ( 'global' === $site ) ? BLOG_ID_CURRENT_SITE : $site;
|
486 |
switch_to_blog( $site );
|
487 |
}
|
488 |
|
502 |
$template = file_get_contents( mc_get_file( $template ) );
|
503 |
}
|
504 |
$defaults = mc_widget_defaults();
|
505 |
+
$template = ( ! $template || 'default' === $template ) ? $defaults['today']['template'] : $template;
|
506 |
|
507 |
if ( mc_key_exists( $template ) ) {
|
508 |
$template = mc_get_custom_template( $template );
|
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 ) );
|
559 |
$append = apply_filters( 'mc_todays_events_after', '</li>' );
|
560 |
|
561 |
$item = apply_filters( 'mc_draw_todays_event', '', $event_details, $template );
|
562 |
+
if ( '' === $item ) {
|
563 |
$item = mc_draw_template( $event_details, $template );
|
564 |
}
|
565 |
$todays_events[ $ts ][] = $prepend . $item . $append;
|
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.
|
21 |
*/
|
22 |
|
23 |
/*
|
@@ -42,7 +42,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
42 |
}
|
43 |
|
44 |
global $mc_version, $wpdb;
|
45 |
-
$mc_version = '3.1.
|
46 |
|
47 |
define( 'MC_DEBUG', false );
|
48 |
|
@@ -365,7 +365,7 @@ function mc_show_sidebar( $show = '', $add = false, $remove = false ) {
|
|
365 |
*/
|
366 |
function my_calendar_menu() {
|
367 |
if ( function_exists( 'add_menu_page' ) ) {
|
368 |
-
if ( 'true'
|
369 |
add_menu_page( __( 'My Calendar', 'my-calendar' ), __( 'My Calendar', 'my-calendar' ), 'mc_add_events', apply_filters( 'mc_modify_default', 'my-calendar' ), apply_filters( 'mc_modify_default_cb', 'my_calendar_edit' ), 'dashicons-calendar' );
|
370 |
} else {
|
371 |
add_menu_page( __( 'My Calendar', 'my-calendar' ), __( 'My Calendar', 'my-calendar' ), 'mc_edit_settings', 'my-calendar', 'my_calendar_settings', 'dashicons-calendar' );
|
@@ -374,7 +374,7 @@ function my_calendar_menu() {
|
|
374 |
if ( function_exists( 'add_submenu_page' ) ) {
|
375 |
add_action( 'admin_head', 'my_calendar_write_js' );
|
376 |
add_action( 'admin_enqueue_scripts', 'my_calendar_add_styles' );
|
377 |
-
if ( 'true'
|
378 |
// If we're accessing a remote site, remove these pages.
|
379 |
} else {
|
380 |
if ( isset( $_GET['event_id'] ) ) {
|
@@ -406,7 +406,7 @@ function my_calendar_menu() {
|
|
406 |
add_action( 'admin_head', 'my_calendar_sub_styles' );
|
407 |
add_submenu_page( 'my-calendar', __( 'My Calendar Pro Settings', 'my-calendar' ), __( 'My Calendar Pro', 'my-calendar' ), $permission, 'my-calendar-submissions', 'mcs_settings' );
|
408 |
// Only show payments screen if enabled.
|
409 |
-
if ( 'true'
|
410 |
add_submenu_page( 'my-calendar', __( 'Payments Received', 'my-calendar' ), __( 'Payments', 'my-calendar' ), $permission, 'my-calendar-payments', 'mcs_sales_page' );
|
411 |
}
|
412 |
}
|
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 |
}
|
43 |
|
44 |
global $mc_version, $wpdb;
|
45 |
+
$mc_version = '3.1.13';
|
46 |
|
47 |
define( 'MC_DEBUG', false );
|
48 |
|
365 |
*/
|
366 |
function my_calendar_menu() {
|
367 |
if ( function_exists( 'add_menu_page' ) ) {
|
368 |
+
if ( 'true' !== get_option( 'mc_remote' ) ) {
|
369 |
add_menu_page( __( 'My Calendar', 'my-calendar' ), __( 'My Calendar', 'my-calendar' ), 'mc_add_events', apply_filters( 'mc_modify_default', 'my-calendar' ), apply_filters( 'mc_modify_default_cb', 'my_calendar_edit' ), 'dashicons-calendar' );
|
370 |
} else {
|
371 |
add_menu_page( __( 'My Calendar', 'my-calendar' ), __( 'My Calendar', 'my-calendar' ), 'mc_edit_settings', 'my-calendar', 'my_calendar_settings', 'dashicons-calendar' );
|
374 |
if ( function_exists( 'add_submenu_page' ) ) {
|
375 |
add_action( 'admin_head', 'my_calendar_write_js' );
|
376 |
add_action( 'admin_enqueue_scripts', 'my_calendar_add_styles' );
|
377 |
+
if ( 'true' === get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) {
|
378 |
// If we're accessing a remote site, remove these pages.
|
379 |
} else {
|
380 |
if ( isset( $_GET['event_id'] ) ) {
|
406 |
add_action( 'admin_head', 'my_calendar_sub_styles' );
|
407 |
add_submenu_page( 'my-calendar', __( 'My Calendar Pro Settings', 'my-calendar' ), __( 'My Calendar Pro', 'my-calendar' ), $permission, 'my-calendar-submissions', 'mcs_settings' );
|
408 |
// Only show payments screen if enabled.
|
409 |
+
if ( 'true' === get_option( 'mcs_payments' ) ) {
|
410 |
add_submenu_page( 'my-calendar', __( 'Payments Received', 'my-calendar' ), __( 'Payments', 'my-calendar' ), $permission, 'my-calendar-payments', 'mcs_sales_page' );
|
411 |
}
|
412 |
}
|
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.
|
9 |
Text domain: my-calendar
|
10 |
License: GPLv2 or later
|
11 |
|
@@ -83,6 +83,14 @@ Translating my plug-ins is always appreciated. Visit <a href="https://translate.
|
|
83 |
|
84 |
== Changelog ==
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
= 3.1.12 =
|
87 |
|
88 |
* Bug fix: User-specific category permissions didn't handle unset (default) values.
|
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 |
|
84 |
== Changelog ==
|
85 |
|
86 |
+
= 3.1.13 =
|
87 |
+
|
88 |
+
* Bug fix: If plug-in name is translated, script references were broken.
|
89 |
+
* Bug fix: If no holiday category assigned, Today's Events widget will return empty when category limits set.
|
90 |
+
* New filter: allow events post type to be made searchable. (Not recommended.)
|
91 |
+
* New: Support 'search' parameter in shortcode & URL parameters for main view.
|
92 |
+
* Remove option to disable max contrast category names.
|
93 |
+
|
94 |
= 3.1.12 =
|
95 |
|
96 |
* Bug fix: User-specific category permissions didn't handle unset (default) values.
|
uninstall.php
CHANGED
@@ -124,7 +124,7 @@ if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|
124 |
delete_option( 'mc_update_notice' );
|
125 |
delete_option( 'mc_default_direction' );
|
126 |
|
127 |
-
if ( get_option( 'mc_drop_tables' )
|
128 |
global $wpdb;
|
129 |
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'my_calendar' );
|
130 |
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'my_calendar_events' );
|
124 |
delete_option( 'mc_update_notice' );
|
125 |
delete_option( 'mc_default_direction' );
|
126 |
|
127 |
+
if ( get_option( 'mc_drop_tables' ) === 'true' ) {
|
128 |
global $wpdb;
|
129 |
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'my_calendar' );
|
130 |
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'my_calendar_events' );
|