@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Shared functions |
|
4 | - * |
|
5 | - * Functions shared by both back end and front end components. |
|
6 | - * |
|
7 | - * @package SimpleCalendar/Functions |
|
8 | - */ |
|
3 | + * Shared functions |
|
4 | + * |
|
5 | + * Functions shared by both back end and front end components. |
|
6 | + * |
|
7 | + * @package SimpleCalendar/Functions |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | 11 | exit; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @package SimpleCalendar/Functions |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function is_simple_calendar() { |
22 | 22 | |
23 | - if ( is_singular() ) { |
|
23 | + if (is_singular()) { |
|
24 | 24 | |
25 | 25 | global $post, $post_type; |
26 | 26 | |
27 | - if ( 'calendar' == $post_type ) { |
|
27 | + if ('calendar' == $post_type) { |
|
28 | 28 | return true; |
29 | 29 | } else { |
30 | - if ( false !== get_post_meta( $post->ID, '_simcal_attach_calendar_id', true ) ) { |
|
30 | + if (false !== get_post_meta($post->ID, '_simcal_attach_calendar_id', true)) { |
|
31 | 31 | return true; |
32 | 32 | } |
33 | - if ( has_shortcode( $post->post_content, 'calendar' ) ) { |
|
33 | + if (has_shortcode($post->post_content, 'calendar')) { |
|
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | } |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return string |
48 | 48 | */ |
49 | -function simcal_get_url( $url ) { |
|
50 | - return \SimpleCalendar\plugin()->get_url( $url ); |
|
49 | +function simcal_get_url($url) { |
|
50 | + return \SimpleCalendar\plugin()->get_url($url); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return null|\SimpleCalendar\Abstracts\Feed |
73 | 73 | */ |
74 | -function simcal_get_feed( $object ) { |
|
74 | +function simcal_get_feed($object) { |
|
75 | 75 | $objects = \SimpleCalendar\plugin()->objects; |
76 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_feed( $object ) : null; |
|
76 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_feed($object) : null; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return null|\SimpleCalendar\Abstracts\Calendar |
99 | 99 | */ |
100 | -function simcal_get_calendar( $object ) { |
|
100 | +function simcal_get_calendar($object) { |
|
101 | 101 | $objects = \SimpleCalendar\plugin()->objects; |
102 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar( $object ) : null; |
|
102 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar($object) : null; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return mixed |
114 | 114 | */ |
115 | -function simcal_get_calendar_view( $id = 0, $name = '' ) { |
|
115 | +function simcal_get_calendar_view($id = 0, $name = '') { |
|
116 | 116 | $objects = \SimpleCalendar\plugin()->objects; |
117 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar_view( $id, $name ) : false; |
|
117 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar_view($id, $name) : false; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return void |
128 | 128 | */ |
129 | -function simcal_print_calendar( $object ) { |
|
129 | +function simcal_print_calendar($object) { |
|
130 | 130 | |
131 | - $calendar = simcal_get_calendar( $object ); |
|
131 | + $calendar = simcal_get_calendar($object); |
|
132 | 132 | |
133 | - if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) { |
|
133 | + if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) { |
|
134 | 134 | $calendar->html(); |
135 | 135 | } |
136 | 136 | } |
@@ -148,21 +148,21 @@ discard block |
||
148 | 148 | |
149 | 149 | $vars = array( |
150 | 150 | 'ajax_url' => \SimpleCalendar\plugin()->ajax_url(), |
151 | - 'nonce' => wp_create_nonce( 'simcal' ), |
|
151 | + 'nonce' => wp_create_nonce('simcal'), |
|
152 | 152 | 'locale' => \SimpleCalendar\plugin()->locale, |
153 | 153 | 'text_dir' => is_rtl() ? 'rtl' : 'ltr', |
154 | 154 | 'months' => array( |
155 | - 'full' => simcal_get_calendar_names_i18n( 'month', 'full' ), |
|
156 | - 'short' => simcal_get_calendar_names_i18n( 'month', 'short' ), |
|
155 | + 'full' => simcal_get_calendar_names_i18n('month', 'full'), |
|
156 | + 'short' => simcal_get_calendar_names_i18n('month', 'short'), |
|
157 | 157 | ), |
158 | 158 | 'days' => array( |
159 | - 'full' => simcal_get_calendar_names_i18n( 'day', 'full' ), |
|
160 | - 'short' => simcal_get_calendar_names_i18n( 'day', 'short' ), |
|
159 | + 'full' => simcal_get_calendar_names_i18n('day', 'full'), |
|
160 | + 'short' => simcal_get_calendar_names_i18n('day', 'short'), |
|
161 | 161 | ), |
162 | - 'meridiem' => simcal_get_calendar_names_i18n( 'meridiem' ), |
|
162 | + 'meridiem' => simcal_get_calendar_names_i18n('meridiem'), |
|
163 | 163 | ); |
164 | 164 | |
165 | - return array_merge( $vars, apply_filters( 'simcal_common_scripts_variables', array() ) ); |
|
165 | + return array_merge($vars, apply_filters('simcal_common_scripts_variables', array())); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -175,31 +175,31 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return array Associative array with ids as keys and feed titles as values. |
177 | 177 | */ |
178 | -function simcal_get_calendars( $exclude = '', $cached = true ) { |
|
178 | +function simcal_get_calendars($exclude = '', $cached = true) { |
|
179 | 179 | |
180 | - $calendars = get_transient( '_simple-calendar_feed_ids' ); |
|
180 | + $calendars = get_transient('_simple-calendar_feed_ids'); |
|
181 | 181 | |
182 | - if ( ! $calendars || $cached === false ) { |
|
182 | + if ( ! $calendars || $cached === false) { |
|
183 | 183 | |
184 | - $posts = get_posts( array( |
|
184 | + $posts = get_posts(array( |
|
185 | 185 | 'post_type' => 'calendar', |
186 | 186 | 'nopaging' => true, |
187 | - ) ); |
|
187 | + )); |
|
188 | 188 | |
189 | 189 | $calendars = array(); |
190 | - foreach ( $posts as $post ) { |
|
191 | - $calendars[ $post->ID ] = $post->post_title; |
|
190 | + foreach ($posts as $post) { |
|
191 | + $calendars[$post->ID] = $post->post_title; |
|
192 | 192 | } |
193 | - asort( $calendars ); |
|
193 | + asort($calendars); |
|
194 | 194 | |
195 | - set_transient( '_simple-calendar_feed_ids', $calendars, 604800 ); |
|
195 | + set_transient('_simple-calendar_feed_ids', $calendars, 604800); |
|
196 | 196 | } |
197 | 197 | |
198 | - if ( ! empty( $exclude ) ) { |
|
199 | - if ( is_numeric( $exclude ) ) { |
|
200 | - unset( $calendars[ intval( $exclude ) ] ); |
|
201 | - } elseif ( is_array( $exclude ) ) { |
|
202 | - array_diff_key( $calendars, array_map( 'intval', array_keys( $exclude ) ) ); |
|
198 | + if ( ! empty($exclude)) { |
|
199 | + if (is_numeric($exclude)) { |
|
200 | + unset($calendars[intval($exclude)]); |
|
201 | + } elseif (is_array($exclude)) { |
|
202 | + array_diff_key($calendars, array_map('intval', array_keys($exclude))); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
@@ -218,45 +218,45 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return array |
220 | 220 | */ |
221 | -function simcal_get_calendar_names_i18n( $group, $style = 'full' ) { |
|
221 | +function simcal_get_calendar_names_i18n($group, $style = 'full') { |
|
222 | 222 | |
223 | 223 | $names = array(); |
224 | 224 | |
225 | - if ( in_array( $group, array( 'month', 'day', 'meridiem' ) ) ) { |
|
225 | + if (in_array($group, array('month', 'day', 'meridiem'))) { |
|
226 | 226 | |
227 | 227 | $format = ''; |
228 | 228 | $length = 0; |
229 | 229 | |
230 | 230 | $date = Carbon\Carbon::now(); |
231 | 231 | |
232 | - if ( 'month' == $group ) { |
|
233 | - $date->month( 0 )->startOfMonth(); |
|
232 | + if ('month' == $group) { |
|
233 | + $date->month(0)->startOfMonth(); |
|
234 | 234 | $format = 'short' == $style ? 'M' : 'F'; |
235 | 235 | $length = 11; |
236 | - } elseif ( 'day' == $group ) { |
|
237 | - $date->next( 6 ); |
|
236 | + } elseif ('day' == $group) { |
|
237 | + $date->next(6); |
|
238 | 238 | $format = 'short' == $style ? 'D' : 'l'; |
239 | 239 | $length = 6; |
240 | - } elseif ( 'meridiem' == $group ) { |
|
240 | + } elseif ('meridiem' == $group) { |
|
241 | 241 | $date->startOfDay(); |
242 | - $am = $date->addHour( 1 )->getTimestamp(); |
|
243 | - $pm = $date->addHours( 13 )->getTimestamp(); |
|
242 | + $am = $date->addHour(1)->getTimestamp(); |
|
243 | + $pm = $date->addHours(13)->getTimestamp(); |
|
244 | 244 | return array( |
245 | - 'AM' => date_i18n( 'A', $am ), |
|
246 | - 'am' => date_i18n( 'a', $am ), |
|
247 | - 'PM' => date_i18n( 'A', $pm ), |
|
248 | - 'pm' => date_i18n( 'a', $pm ), |
|
245 | + 'AM' => date_i18n('A', $am), |
|
246 | + 'am' => date_i18n('a', $am), |
|
247 | + 'PM' => date_i18n('A', $pm), |
|
248 | + 'pm' => date_i18n('a', $pm), |
|
249 | 249 | ); |
250 | 250 | } |
251 | 251 | |
252 | 252 | $i = 0; |
253 | - while ( $i <= $length ) { |
|
254 | - if ( 'month' == $group ) { |
|
255 | - $date->addMonths( 1 ); |
|
253 | + while ($i <= $length) { |
|
254 | + if ('month' == $group) { |
|
255 | + $date->addMonths(1); |
|
256 | 256 | } else { |
257 | - $date->addDays( 1 ); |
|
257 | + $date->addDays(1); |
|
258 | 258 | } |
259 | - $names[ strval( $i ) ] = date_i18n( $format, $date->getTimestamp() ); |
|
259 | + $names[strval($i)] = date_i18n($format, $date->getTimestamp()); |
|
260 | 260 | $i++; |
261 | 261 | } |
262 | 262 | |
@@ -274,15 +274,15 @@ discard block |
||
274 | 274 | */ |
275 | 275 | function simcal_default_event_template() { |
276 | 276 | |
277 | - $content = '<strong>' . '[title]' . '</strong>'; |
|
277 | + $content = '<strong>'.'[title]'.'</strong>'; |
|
278 | 278 | $content .= "\n\n"; |
279 | - $content .= '[when]' . "\n"; |
|
279 | + $content .= '[when]'."\n"; |
|
280 | 280 | $content .= '[location]'; |
281 | 281 | $content .= "\n"; |
282 | - $content .= '<div>' . '[description]' . '</div>'; |
|
283 | - $content .= "\n" . '[link newwindow="yes"]' . __( 'See more details', 'google-calendar-events' ) . '[/link]'; |
|
282 | + $content .= '<div>'.'[description]'.'</div>'; |
|
283 | + $content .= "\n".'[link newwindow="yes"]'.__('See more details', 'google-calendar-events').'[/link]'; |
|
284 | 284 | |
285 | - return apply_filters( 'simcal_default_event_template', $content ); |
|
285 | + return apply_filters('simcal_default_event_template', $content); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -297,21 +297,21 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return array |
299 | 299 | */ |
300 | -function simcal_get_date_format_order( $date_format ) { |
|
300 | +function simcal_get_date_format_order($date_format) { |
|
301 | 301 | |
302 | 302 | $pos = array( |
303 | - 'd' => strpos( $date_format, strpbrk( $date_format, 'Dj' ) ), |
|
304 | - 'm' => strpos( $date_format, strpbrk( $date_format, 'FMmn' ) ), |
|
305 | - 'y' => strpos( $date_format, strpbrk( $date_format, 'Yy' ) ), |
|
303 | + 'd' => strpos($date_format, strpbrk($date_format, 'Dj')), |
|
304 | + 'm' => strpos($date_format, strpbrk($date_format, 'FMmn')), |
|
305 | + 'y' => strpos($date_format, strpbrk($date_format, 'Yy')), |
|
306 | 306 | ); |
307 | 307 | |
308 | 308 | // @TODO When one date piece is not found, perhaps fallback to ISO standard position. |
309 | 309 | |
310 | 310 | $order = array(); |
311 | - foreach ( $pos as $k => $v ) { |
|
312 | - $order[ $k ] = $v; |
|
311 | + foreach ($pos as $k => $v) { |
|
312 | + $order[$k] = $v; |
|
313 | 313 | } |
314 | - ksort( $order ); |
|
314 | + ksort($order); |
|
315 | 315 | |
316 | 316 | return $order; |
317 | 317 | } |
@@ -327,11 +327,11 @@ discard block |
||
327 | 327 | */ |
328 | 328 | function simcal_get_wp_timezone() { |
329 | 329 | |
330 | - $timezone = get_option( 'timezone_string' ); |
|
330 | + $timezone = get_option('timezone_string'); |
|
331 | 331 | |
332 | - if ( empty( $timezone ) ) { |
|
333 | - $gmt = get_option( 'gmt_offset' ); |
|
334 | - $timezone = simcal_get_timezone_from_gmt_offset( $gmt ); |
|
332 | + if (empty($timezone)) { |
|
333 | + $gmt = get_option('gmt_offset'); |
|
334 | + $timezone = simcal_get_timezone_from_gmt_offset($gmt); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | return $timezone; |
@@ -348,26 +348,26 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return null|string |
350 | 350 | */ |
351 | -function simcal_get_timezone_from_gmt_offset( $offset ) { |
|
351 | +function simcal_get_timezone_from_gmt_offset($offset) { |
|
352 | 352 | |
353 | - if ( is_numeric( $offset ) ) { |
|
353 | + if (is_numeric($offset)) { |
|
354 | 354 | |
355 | - if ( 0 === intval( $offset ) ) { |
|
355 | + if (0 === intval($offset)) { |
|
356 | 356 | return 'UTC'; |
357 | 357 | } else { |
358 | - $offset = floatval( $offset ) * 3600; |
|
358 | + $offset = floatval($offset) * 3600; |
|
359 | 359 | } |
360 | 360 | |
361 | - $timezone = timezone_name_from_abbr( null, $offset, false ); |
|
361 | + $timezone = timezone_name_from_abbr(null, $offset, false); |
|
362 | 362 | // This is buggy and might return false: |
363 | 363 | // @see http://php.net/manual/en/function.timezone-name-from-abbr.php#86928 |
364 | 364 | // Therefore: |
365 | - if ( false == $timezone ) { |
|
365 | + if (false == $timezone) { |
|
366 | 366 | |
367 | 367 | $list = timezone_abbreviations_list(); |
368 | - foreach ( $list as $abbr ) { |
|
369 | - foreach ( $abbr as $city ) { |
|
370 | - if ( $offset == $city['offset'] ) { |
|
368 | + foreach ($list as $abbr) { |
|
369 | + foreach ($abbr as $city) { |
|
370 | + if ($offset == $city['offset']) { |
|
371 | 371 | return $city['timezone_id']; |
372 | 372 | } |
373 | 373 | } |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @return int Unix time offset |
392 | 392 | */ |
393 | -function simcal_get_timezone_offset( $timezone ) { |
|
394 | - return \Carbon\Carbon::now( $timezone )->offset; |
|
393 | +function simcal_get_timezone_offset($timezone) { |
|
394 | + return \Carbon\Carbon::now($timezone)->offset; |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * |
405 | 405 | * @return mixed|string |
406 | 406 | */ |
407 | -function simcal_esc_timezone( $tz, $default = 'UTC' ) { |
|
408 | - return in_array( $tz, timezone_identifiers_list() ) ? $tz : $default; |
|
407 | +function simcal_esc_timezone($tz, $default = 'UTC') { |
|
408 | + return in_array($tz, timezone_identifiers_list()) ? $tz : $default; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -417,57 +417,57 @@ discard block |
||
417 | 417 | * |
418 | 418 | * @return bool |
419 | 419 | */ |
420 | -function simcal_delete_feed_transients( $id = '' ) { |
|
420 | +function simcal_delete_feed_transients($id = '') { |
|
421 | 421 | |
422 | - $grouped_ids = get_post_meta( $id, '_grouped_calendars_ids', true ); |
|
422 | + $grouped_ids = get_post_meta($id, '_grouped_calendars_ids', true); |
|
423 | 423 | |
424 | 424 | // If there are group IDs we need to construct an array to pass along with the grouped IDs + the original $post_id |
425 | - if ( is_array( $grouped_ids ) ) { |
|
425 | + if (is_array($grouped_ids)) { |
|
426 | 426 | $temp_id = $id; |
427 | 427 | $id = $grouped_ids; |
428 | 428 | $id[] = $temp_id; |
429 | 429 | } |
430 | 430 | |
431 | - if ( is_numeric( $id ) ) { |
|
432 | - $id = intval( $id ) > 0 ? absint( $id ) : simcal_get_calendars(); |
|
433 | - } elseif ( $id instanceof WP_Post ) { |
|
431 | + if (is_numeric($id)) { |
|
432 | + $id = intval($id) > 0 ? absint($id) : simcal_get_calendars(); |
|
433 | + } elseif ($id instanceof WP_Post) { |
|
434 | 434 | $id = $id->ID; |
435 | - } elseif ( is_array( $id ) ) { |
|
436 | - $id = array_map( 'absint', $id ); |
|
435 | + } elseif (is_array($id)) { |
|
436 | + $id = array_map('absint', $id); |
|
437 | 437 | } else { |
438 | - $id = simcal_get_calendars( '', true ); |
|
438 | + $id = simcal_get_calendars('', true); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | $feed_types = simcal_get_feed_types(); |
442 | 442 | |
443 | - if ( is_array( $id ) ) { |
|
443 | + if (is_array($id)) { |
|
444 | 444 | |
445 | - $posts = get_posts( array( |
|
445 | + $posts = get_posts(array( |
|
446 | 446 | 'post_type' => 'calendar', |
447 | 447 | 'fields' => 'ids', |
448 | 448 | 'post__in' => $id, |
449 | 449 | 'nopaging' => true, |
450 | - ) ); |
|
450 | + )); |
|
451 | 451 | |
452 | - foreach ( $posts as $post ) { |
|
453 | - $calendar = simcal_get_calendar( $post ); |
|
454 | - if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) { |
|
455 | - foreach ( $feed_types as $feed_type ) { |
|
456 | - delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type ); |
|
452 | + foreach ($posts as $post) { |
|
453 | + $calendar = simcal_get_calendar($post); |
|
454 | + if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) { |
|
455 | + foreach ($feed_types as $feed_type) { |
|
456 | + delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | 461 | } else { |
462 | 462 | |
463 | - $post = get_post( $id ); |
|
464 | - $calendar = simcal_get_calendar( $post ); |
|
465 | - if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) { |
|
466 | - foreach ( $feed_types as $feed_type ) { |
|
467 | - delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type ); |
|
463 | + $post = get_post($id); |
|
464 | + $calendar = simcal_get_calendar($post); |
|
465 | + if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) { |
|
466 | + foreach ($feed_types as $feed_type) { |
|
467 | + delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | } |
471 | 471 | |
472 | - return delete_transient( '_simple-calendar_feed_ids' ); |
|
472 | + return delete_transient('_simple-calendar_feed_ids'); |
|
473 | 473 | } |
474 | 474 | \ No newline at end of file |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct() { |
28 | 28 | // Register custom taxonomies. |
29 | - add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 5 ); |
|
29 | + add_action('init', array(__CLASS__, 'register_taxonomies'), 5); |
|
30 | 30 | // Register custom post types. |
31 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 ); |
|
31 | + add_action('init', array(__CLASS__, 'register_post_types'), 5); |
|
32 | 32 | // Filter the calendar feed post content to display a calendar view. |
33 | - add_filter( 'the_content', array( $this, 'filter_post_content' ), 100 ); |
|
33 | + add_filter('the_content', array($this, 'filter_post_content'), 100); |
|
34 | 34 | // Delete calendar transients and notices upon post deletion. |
35 | - add_action( 'before_delete_post', array( $this, 'upon_deletion' ), 10, 1 ); |
|
35 | + add_action('before_delete_post', array($this, 'upon_deletion'), 10, 1); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -42,32 +42,32 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function register_taxonomies() { |
44 | 44 | |
45 | - do_action( 'simcal_register_taxonomies' ); |
|
45 | + do_action('simcal_register_taxonomies'); |
|
46 | 46 | |
47 | - if ( ! taxonomy_exists( 'calendar_feed' ) ) { |
|
47 | + if ( ! taxonomy_exists('calendar_feed')) { |
|
48 | 48 | |
49 | 49 | // Feed Type. |
50 | 50 | $labels = array( |
51 | - 'name' => __( 'Events Source Types', 'google-calendar-events' ), |
|
52 | - 'singular_name' => __( 'Events Source Type', 'google-calendar-events' ), |
|
53 | - 'menu_name' => __( 'Events Source Type', 'google-calendar-events' ), |
|
54 | - 'all_items' => __( 'All Events Source Types', 'google-calendar-events' ), |
|
55 | - 'parent_item' => __( 'Parent Events Source Type', 'google-calendar-events' ), |
|
56 | - 'parent_item_colon' => __( 'Parent Events Source Type:', 'google-calendar-events' ), |
|
57 | - 'new_item_name' => __( 'New Events Source Type', 'google-calendar-events' ), |
|
58 | - 'add_new_item' => __( 'Add New Events Source Type', 'google-calendar-events' ), |
|
59 | - 'edit_item' => __( 'Edit Events Source Type', 'google-calendar-events' ), |
|
60 | - 'update_item' => __( 'Update Events Source Type', 'google-calendar-events' ), |
|
61 | - 'view_item' => __( 'View Events Source Type', 'google-calendar-events' ), |
|
62 | - 'separate_items_with_commas' => __( 'Separate events source types with commas', 'google-calendar-events' ), |
|
63 | - 'add_or_remove_items' => __( 'Add or remove events source types', 'google-calendar-events' ), |
|
64 | - 'choose_from_most_used' => __( 'Choose from the most used', 'google-calendar-events' ), |
|
65 | - 'popular_items' => __( 'Popular events source types', 'google-calendar-events' ), |
|
66 | - 'search_items' => __( 'Search Events Source Types', 'google-calendar-events' ), |
|
67 | - 'not_found' => __( 'Not Found', 'google-calendar-events' ), |
|
51 | + 'name' => __('Events Source Types', 'google-calendar-events'), |
|
52 | + 'singular_name' => __('Events Source Type', 'google-calendar-events'), |
|
53 | + 'menu_name' => __('Events Source Type', 'google-calendar-events'), |
|
54 | + 'all_items' => __('All Events Source Types', 'google-calendar-events'), |
|
55 | + 'parent_item' => __('Parent Events Source Type', 'google-calendar-events'), |
|
56 | + 'parent_item_colon' => __('Parent Events Source Type:', 'google-calendar-events'), |
|
57 | + 'new_item_name' => __('New Events Source Type', 'google-calendar-events'), |
|
58 | + 'add_new_item' => __('Add New Events Source Type', 'google-calendar-events'), |
|
59 | + 'edit_item' => __('Edit Events Source Type', 'google-calendar-events'), |
|
60 | + 'update_item' => __('Update Events Source Type', 'google-calendar-events'), |
|
61 | + 'view_item' => __('View Events Source Type', 'google-calendar-events'), |
|
62 | + 'separate_items_with_commas' => __('Separate events source types with commas', 'google-calendar-events'), |
|
63 | + 'add_or_remove_items' => __('Add or remove events source types', 'google-calendar-events'), |
|
64 | + 'choose_from_most_used' => __('Choose from the most used', 'google-calendar-events'), |
|
65 | + 'popular_items' => __('Popular events source types', 'google-calendar-events'), |
|
66 | + 'search_items' => __('Search Events Source Types', 'google-calendar-events'), |
|
67 | + 'not_found' => __('Not Found', 'google-calendar-events'), |
|
68 | 68 | ); |
69 | 69 | |
70 | - $args = array( |
|
70 | + $args = array( |
|
71 | 71 | 'hierarchical' => true, |
72 | 72 | 'labels' => $labels, |
73 | 73 | 'public' => false, |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | 'show_tagcloud' => false, |
77 | 77 | 'show_ui' => false, |
78 | 78 | ); |
79 | - register_taxonomy( 'calendar_feed', array( 'calendar' ), $args ); |
|
79 | + register_taxonomy('calendar_feed', array('calendar'), $args); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | - if ( ! taxonomy_exists( 'calendar_type' ) ) { |
|
83 | + if ( ! taxonomy_exists('calendar_type')) { |
|
84 | 84 | |
85 | 85 | // Calendar Type. |
86 | 86 | $labels = array( |
87 | - 'name' => __( 'Calendar Types', 'google-calendar-events' ), |
|
88 | - 'singular_name' => __( 'Calendar Type', 'google-calendar-events' ), |
|
89 | - 'menu_name' => __( 'Calendar Type', 'google-calendar-events' ), |
|
90 | - 'all_items' => __( 'All Calendar Types', 'google-calendar-events' ), |
|
91 | - 'parent_item' => __( 'Parent Calendar Type', 'google-calendar-events' ), |
|
92 | - 'parent_item_colon' => __( 'Parent Calendar Type:', 'google-calendar-events' ), |
|
93 | - 'new_item_name' => __( 'New Calendar Type', 'google-calendar-events' ), |
|
94 | - 'add_new_item' => __( 'Add New Calendar Type', 'google-calendar-events' ), |
|
95 | - 'edit_item' => __( 'Edit Calendar Type', 'google-calendar-events' ), |
|
96 | - 'update_item' => __( 'Update Calendar Type', 'google-calendar-events' ), |
|
97 | - 'view_item' => __( 'View Calendar Type', 'google-calendar-events' ), |
|
98 | - 'separate_items_with_commas' => __( 'Separate calendar types with commas', 'google-calendar-events' ), |
|
99 | - 'add_or_remove_items' => __( 'Add or remove calendar types', 'google-calendar-events' ), |
|
100 | - 'choose_from_most_used' => __( 'Choose from the most used', 'google-calendar-events' ), |
|
101 | - 'popular_items' => __( 'Popular calendar types', 'google-calendar-events' ), |
|
102 | - 'search_items' => __( 'Search Calendar Types', 'google-calendar-events' ), |
|
103 | - 'not_found' => __( 'Not Found', 'google-calendar-events' ), |
|
87 | + 'name' => __('Calendar Types', 'google-calendar-events'), |
|
88 | + 'singular_name' => __('Calendar Type', 'google-calendar-events'), |
|
89 | + 'menu_name' => __('Calendar Type', 'google-calendar-events'), |
|
90 | + 'all_items' => __('All Calendar Types', 'google-calendar-events'), |
|
91 | + 'parent_item' => __('Parent Calendar Type', 'google-calendar-events'), |
|
92 | + 'parent_item_colon' => __('Parent Calendar Type:', 'google-calendar-events'), |
|
93 | + 'new_item_name' => __('New Calendar Type', 'google-calendar-events'), |
|
94 | + 'add_new_item' => __('Add New Calendar Type', 'google-calendar-events'), |
|
95 | + 'edit_item' => __('Edit Calendar Type', 'google-calendar-events'), |
|
96 | + 'update_item' => __('Update Calendar Type', 'google-calendar-events'), |
|
97 | + 'view_item' => __('View Calendar Type', 'google-calendar-events'), |
|
98 | + 'separate_items_with_commas' => __('Separate calendar types with commas', 'google-calendar-events'), |
|
99 | + 'add_or_remove_items' => __('Add or remove calendar types', 'google-calendar-events'), |
|
100 | + 'choose_from_most_used' => __('Choose from the most used', 'google-calendar-events'), |
|
101 | + 'popular_items' => __('Popular calendar types', 'google-calendar-events'), |
|
102 | + 'search_items' => __('Search Calendar Types', 'google-calendar-events'), |
|
103 | + 'not_found' => __('Not Found', 'google-calendar-events'), |
|
104 | 104 | ); |
105 | 105 | |
106 | - $args = array( |
|
106 | + $args = array( |
|
107 | 107 | 'hierarchical' => true, |
108 | 108 | 'labels' => $labels, |
109 | 109 | 'public' => false, |
@@ -112,34 +112,34 @@ discard block |
||
112 | 112 | 'show_tagcloud' => false, |
113 | 113 | 'show_ui' => false, |
114 | 114 | ); |
115 | - register_taxonomy( 'calendar_type', array( 'calendar' ), $args ); |
|
115 | + register_taxonomy('calendar_type', array('calendar'), $args); |
|
116 | 116 | |
117 | 117 | } |
118 | 118 | |
119 | - if ( ! taxonomy_exists( 'calendar_category' ) ) { |
|
119 | + if ( ! taxonomy_exists('calendar_category')) { |
|
120 | 120 | |
121 | 121 | // Feed Category. |
122 | 122 | $labels = array( |
123 | - 'name' => __( 'Categories', 'google-calendar-events' ), |
|
124 | - 'singular_name' => __( 'Category', 'google-calendar-events' ), |
|
125 | - 'menu_name' => __( 'Categories', 'google-calendar-events' ), |
|
126 | - 'all_items' => __( 'All Categories', 'google-calendar-events' ), |
|
127 | - 'parent_item' => __( 'Parent Category', 'google-calendar-events' ), |
|
128 | - 'parent_item_colon' => __( 'Parent Category:', 'google-calendar-events' ), |
|
129 | - 'new_item_name' => __( 'New Category', 'google-calendar-events' ), |
|
130 | - 'add_new_item' => __( 'Add New Category', 'google-calendar-events' ), |
|
131 | - 'edit_item' => __( 'Edit Category', 'google-calendar-events' ), |
|
132 | - 'update_item' => __( 'Update Category', 'google-calendar-events' ), |
|
133 | - 'view_item' => __( 'View Category', 'google-calendar-events' ), |
|
134 | - 'separate_items_with_commas' => __( 'Separate categories with commas', 'google-calendar-events' ), |
|
135 | - 'add_or_remove_items' => __( 'Add or remove categories', 'google-calendar-events' ), |
|
136 | - 'choose_from_most_used' => __( 'Choose from the most used', 'google-calendar-events' ), |
|
137 | - 'popular_items' => __( 'Popular Categories', 'google-calendar-events' ), |
|
138 | - 'search_items' => __( 'Search Categories', 'google-calendar-events' ), |
|
139 | - 'not_found' => __( 'Not Found', 'google-calendar-events' ), |
|
123 | + 'name' => __('Categories', 'google-calendar-events'), |
|
124 | + 'singular_name' => __('Category', 'google-calendar-events'), |
|
125 | + 'menu_name' => __('Categories', 'google-calendar-events'), |
|
126 | + 'all_items' => __('All Categories', 'google-calendar-events'), |
|
127 | + 'parent_item' => __('Parent Category', 'google-calendar-events'), |
|
128 | + 'parent_item_colon' => __('Parent Category:', 'google-calendar-events'), |
|
129 | + 'new_item_name' => __('New Category', 'google-calendar-events'), |
|
130 | + 'add_new_item' => __('Add New Category', 'google-calendar-events'), |
|
131 | + 'edit_item' => __('Edit Category', 'google-calendar-events'), |
|
132 | + 'update_item' => __('Update Category', 'google-calendar-events'), |
|
133 | + 'view_item' => __('View Category', 'google-calendar-events'), |
|
134 | + 'separate_items_with_commas' => __('Separate categories with commas', 'google-calendar-events'), |
|
135 | + 'add_or_remove_items' => __('Add or remove categories', 'google-calendar-events'), |
|
136 | + 'choose_from_most_used' => __('Choose from the most used', 'google-calendar-events'), |
|
137 | + 'popular_items' => __('Popular Categories', 'google-calendar-events'), |
|
138 | + 'search_items' => __('Search Categories', 'google-calendar-events'), |
|
139 | + 'not_found' => __('Not Found', 'google-calendar-events'), |
|
140 | 140 | ); |
141 | 141 | |
142 | - $args = array( |
|
142 | + $args = array( |
|
143 | 143 | 'hierarchical' => true, |
144 | 144 | 'labels' => $labels, |
145 | 145 | 'public' => true, |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | 'show_ui' => true, |
150 | 150 | ); |
151 | 151 | |
152 | - register_taxonomy( 'calendar_category', array( 'calendar' ), $args ); |
|
152 | + register_taxonomy('calendar_category', array('calendar'), $args); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | } |
@@ -161,27 +161,27 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public static function register_post_types() { |
163 | 163 | |
164 | - do_action( 'simcal_register_post_types' ); |
|
164 | + do_action('simcal_register_post_types'); |
|
165 | 165 | |
166 | - if ( ! post_type_exists( 'calendar' ) ) { |
|
166 | + if ( ! post_type_exists('calendar')) { |
|
167 | 167 | |
168 | 168 | // Calendar feed post type. |
169 | - $labels = array( |
|
170 | - 'name' => _x( 'Calendars', 'Post Type General Name', 'google-calendar-events' ), |
|
171 | - 'singular_name' => _x( 'Calendar', 'Post Type Singular Name', 'google-calendar-events' ), |
|
172 | - 'menu_name' => __( 'Calendars', 'google-calendar-events' ), |
|
173 | - 'name_admin_bar' => __( 'Calendar', 'google-calendar-events' ), |
|
174 | - 'parent_item_colon' => __( 'Parent Calendar:', 'google-calendar-events' ), |
|
175 | - 'all_items' => __( 'All Calendars', 'google-calendar-events' ), |
|
176 | - 'add_new_item' => __( 'Add New Calendar', 'google-calendar-events' ), |
|
177 | - 'add_new' => __( 'Add New', 'google-calendar-events' ), |
|
178 | - 'new_item' => __( 'New Calendar', 'google-calendar-events' ), |
|
179 | - 'edit_item' => __( 'Edit Calendar', 'google-calendar-events' ), |
|
180 | - 'update_item' => __( 'Update Calendar', 'google-calendar-events' ), |
|
181 | - 'view_item' => __( 'View Calendar', 'google-calendar-events' ), |
|
182 | - 'search_items' => __( 'Search Calendar', 'google-calendar-events' ), |
|
183 | - 'not_found' => __( 'Calendars not found', 'google-calendar-events' ), |
|
184 | - 'not_found_in_trash' => __( 'Calendars not found in Trash', 'google-calendar-events' ), |
|
169 | + $labels = array( |
|
170 | + 'name' => _x('Calendars', 'Post Type General Name', 'google-calendar-events'), |
|
171 | + 'singular_name' => _x('Calendar', 'Post Type Singular Name', 'google-calendar-events'), |
|
172 | + 'menu_name' => __('Calendars', 'google-calendar-events'), |
|
173 | + 'name_admin_bar' => __('Calendar', 'google-calendar-events'), |
|
174 | + 'parent_item_colon' => __('Parent Calendar:', 'google-calendar-events'), |
|
175 | + 'all_items' => __('All Calendars', 'google-calendar-events'), |
|
176 | + 'add_new_item' => __('Add New Calendar', 'google-calendar-events'), |
|
177 | + 'add_new' => __('Add New', 'google-calendar-events'), |
|
178 | + 'new_item' => __('New Calendar', 'google-calendar-events'), |
|
179 | + 'edit_item' => __('Edit Calendar', 'google-calendar-events'), |
|
180 | + 'update_item' => __('Update Calendar', 'google-calendar-events'), |
|
181 | + 'view_item' => __('View Calendar', 'google-calendar-events'), |
|
182 | + 'search_items' => __('Search Calendar', 'google-calendar-events'), |
|
183 | + 'not_found' => __('Calendars not found', 'google-calendar-events'), |
|
184 | + 'not_found_in_trash' => __('Calendars not found in Trash', 'google-calendar-events'), |
|
185 | 185 | ); |
186 | 186 | |
187 | 187 | $rewrite_rules = array( |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | |
194 | 194 | $svg_icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iU2hhcGVzX3hBMF9JbWFnZV8xXyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDEwMjQgMTAyNCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIGQ9Ik01MTMuNCwxMDEzLjNjLTE2My44LDAtMzI3LjcsMC00OTEuNSwwYy05LjcsMC04LjgsMC45LTguOC04LjljMC0yNDMuNywwLjItNDg3LjMtMC4zLTczMWMtMC4xLTM5LjYsMjcuNy03Ni40LDY5LjYtODIuM2MzLTAuNCw2LTAuNSw5LTAuNWMzNSwwLDcwLDAuMSwxMDUtMC4xYzUuMSwwLDYuNSwxLjQsNi41LDYuNWMtMC4yLDI2LjgsMC4xLDUzLjctMC4yLDgwLjVjLTAuMiwxNS4yLDMuOSwyOC4yLDE1LjksMzguMmMyLjcsMi4yLDUsNC44LDcuNCw3LjRjOCw4LjYsMTguMSwxMi40LDI5LjYsMTIuNGMzMC43LDAuMiw2MS4zLDAuMiw5MiwwYzExLjItMC4xLDIxLjItMy45LDI5LjEtMTIuMmMzLjQtMy42LDctNy4yLDEwLjYtMTAuNmM5LTguNCwxMi43LTE4LjksMTIuNy0zMWMwLjEtMjguMiwwLTU2LjMsMC04NC41YzAtNi42LDAtNi42LDYuNi02LjZjNzEuNSwwLDE0MywwLDIxNC41LDBjNi42LDAsNi42LDAsNi42LDYuN2MwLDI2LjgsMC4yLDUzLjctMC4xLDgwLjVjLTAuMiwxNSw1LjEsMjYuOCwxNS40LDM4YzEzLjYsMTQuNywyOC45LDIwLjgsNDguNywyMC4xYzI1LjYtMSw1MS4zLTAuNCw3Ny0wLjJjMTMuOSwwLjEsMjQuOC01LjEsMzUuNC0xNC40YzE1LjktMTQsMjIuMS0zMC40LDIxLjEtNTEuM2MtMS4xLTI0LjMtMC4xLTQ4LjctMC40LTczYzAtNS4xLDEuNC02LjUsNi41LTYuNWMzNC43LDAuMiw2OS4zLDAsMTA0LDAuMWM0Mi4zLDAuMiw3OC4zLDM2LDc4LjMsNzguM2MwLjEsMjQ2LDAsNDkyLDAsNzM4YzAsNi40LDAsNi40LTcuMyw2LjRDODQyLDEwMTMuMyw2NzcuNywxMDEzLjMsNTEzLjQsMTAxMy4zeiBNNDM5LjUsNjc4LjljMS42LTEsMi4yLTEuNSwzLTEuOGMxMS44LTUuOCwyMS41LTE0LjIsMjktMjQuOGMyNC4zLTM0LjEsMjQuMy03MC45LDguNi0xMDcuOGMtMTMuMy0zMS4zLTM5LjMtNDkuMy03MS01OS40Yy0yNy42LTguOC01Ni05LjQtODQuNS01LjZjLTIwLjMsMi43LTM5LjIsOS42LTU1LjUsMjIuMmMtMzUuNSwyNy4yLTQ4LjQsNjUuMS01MC40LDEwOGMtMC4yLDMuNywyLjEsMy45LDQuOCwzLjljMjIuMiwwLDQ0LjMtMC4xLDY2LjUsMGMzLjgsMCw1LjQtMS4xLDUuMy01LjFjLTAuMS03LjcsMS0xNS4zLDMtMjIuN2M1LjQtMjAsMTYuNS0zNC43LDM3LjgtMzkuN2M4LjEtMS45LDE2LjMtMi4xLDI0LjQtMS4zYzIxLjQsMi4xLDM2LjMsMTMuMSw0My41LDMzLjdjMy41LDEwLjEsMy45LDIwLjQsMi45LDMxYy0yLjIsMjMuNC0xNi4yLDM5LjctMzkuMSw0NC42Yy0xMy4yLDIuOC0yNi42LDQuMS00MC4yLDRjLTMuNywwLTUsMS4yLTQuOSw0LjljMC4xLDE2LjUsMC4yLDMzLDAsNDkuNWMwLDQsMS41LDUuMiw1LjMsNS4xYzEyLjktMC4zLDI1LjYsMC45LDM4LjMsM2MyNi4zLDQuMiw0My41LDE4LjgsNDkuMiw0MmMzLjMsMTMuNSwzLDI3LjEtMC4yLDQwLjZjLTIuMyw5LjctNi44LDE4LjQtMTMuOCwyNS43Yy0xNS40LDE2LjEtMzQuNSwyMS42LTU2LDE4LjljLTI3LjUtMy40LTQzLjUtMTgtNTAuNS00NC44Yy0xLjktNy4zLTMuMS0xNC43LTIuOC0yMi4yYzAuMi00LTEuMS01LjYtNS40LTUuNmMtMjMuNywwLjItNDcuMywwLjItNzEsMGMtNCwwLTUuNCwxLjItNC45LDUuMmMxLjQsMTMuMiwyLjcsMjYuNSw1LjksMzkuNWMxMS4xLDQ1LjIsMzguMiw3NS42LDgzLjQsODguMmMzNi43LDEwLjMsNzMuOCwxMC4xLDExMC41LDAuMWMyNC41LTYuNiw0NC43LTIwLjEsNjEtMzkuOGMyNC41LTI5LjcsMzQuNC02My45LDMxLjQtMTAxLjljLTIuMi0yNy40LTEyLjUtNTEuMy0zMy42LTY5LjhDNDYwLjcsNjg5LjMsNDUxLjksNjgyLDQzOS41LDY3OC45eiBNNzU1LDY5Mi41YzAtNjguNi0wLjEtMTM3LjMsMC4xLTIwNS45YzAtNS4xLTEuNC02LjUtNi41LTYuNGMtMTguMywwLjMtMzYuNywwLjQtNTUsMGMtNS43LTAuMS03LjIsMS45LTguMiw3Yy01LjksMzIuMS0yNC40LDUzLTU2LjMsNjEuMWMtMTcuNSw0LjUtMzUuNiw1LTUzLjUsNS44Yy0zLjksMC4yLTUuMiwxLjQtNS4yLDUuM2MwLjIsMTUuMywwLjIsMzAuNywwLDQ2Yy0wLjEsNC4zLDEuNiw1LjQsNS42LDUuM2MxNC4yLTAuMiwyOC4zLTAuMSw0Mi41LTAuMWMxNS41LDAsMzEsMC4xLDQ2LjUtMC4xYzQuMSwwLDUuOSwxLjMsNS41LDUuNGMtMC4xLDEuNywwLDMuMywwLDVjMCw5Mi4xLDAsMTg0LjMsMCwyNzYuNGMwLDcuMiwwLDcuMiw3LDcuMmMyMy41LDAsNDcsMCw3MC41LDBjNywwLDcsMCw3LTcuMkM3NTUsODI5LjEsNzU1LDc2MC44LDc1NSw2OTIuNXoiLz48cGF0aCBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgZD0iTTM3Ni43LDE5OS4yYzAsMjQuMiwwLDQ4LjMsMCw3Mi41Yy0wLjEsMjMuMS0xNy40LDQwLjUtNDAuNCw0MC42Yy0yMy4zLDAuMS00Ni42LDAuMS03MCwwYy0yMi44LTAuMS00MC4zLTE3LjQtNDAuMy00MC4xYy0wLjEtNDguNS0wLjEtOTYuOSwwLTE0NS40YzAtMjIuNCwxNy41LTQwLDM5LjktNDAuMWMyMy43LTAuMSw0Ny4zLTAuMSw3MSwwYzIyLjQsMC4xLDM5LjgsMTcuNywzOS44LDQwLjFDMzc2LjgsMTUwLjksMzc2LjcsMTc1LjEsMzc2LjcsMTk5LjJ6Ii8+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIGQ9Ik04MDEuNywxOTkuNmMwLDI0LDAsNDgsMCw3MmMwLDIzLjQtMTcuMyw0MC43LTQwLjcsNDAuOGMtMjMuMiwwLjEtNDYuMywwLjEtNjkuNSwwYy0yMy4xLTAuMS00MC41LTE3LjQtNDAuNS00MC41Yy0wLjEtNDguMy0wLjEtOTYuNiwwLTE0NC45YzAtMjIuNywxNy41LTQwLjIsNDAuMi00MC4zYzIzLjMtMC4xLDQ2LjYtMC4xLDcwLDBjMjMuMSwwLjEsNDAuNCwxNy40LDQwLjUsNDAuNUM4MDEuOCwxNTEuMyw4MDEuNywxNzUuNCw4MDEuNywxOTkuNnoiLz48L3N2Zz4='; |
195 | 195 | |
196 | - $args = array( |
|
196 | + $args = array( |
|
197 | 197 | 'capability_type' => 'post', |
198 | 198 | 'exclude_from_search' => false, |
199 | 199 | 'has_archive' => false, |
200 | 200 | 'hierarchical' => false, |
201 | - 'label' => __( 'Calendar', 'google-calendar-events' ), |
|
201 | + 'label' => __('Calendar', 'google-calendar-events'), |
|
202 | 202 | 'labels' => $labels, |
203 | 203 | 'query_var' => true, |
204 | 204 | 'public' => true, |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | 'show_in_menu' => true, |
211 | 211 | 'show_in_nav_menus' => true, |
212 | 212 | 'show_ui' => true, |
213 | - 'supports' => array( 'title', 'editor' ), |
|
213 | + 'supports' => array('title', 'editor'), |
|
214 | 214 | 'taxonomies' => array( |
215 | 215 | 'calendar_category', |
216 | 216 | 'calendar_feed', |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | ), |
219 | 219 | ); |
220 | 220 | |
221 | - register_post_type( 'calendar', $args ); |
|
221 | + register_post_type('calendar', $args); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | } |
@@ -232,49 +232,49 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return string |
234 | 234 | */ |
235 | - public function filter_post_content( $the_content ) { |
|
235 | + public function filter_post_content($the_content) { |
|
236 | 236 | |
237 | - if ( is_singular() ) { |
|
237 | + if (is_singular()) { |
|
238 | 238 | |
239 | 239 | global $post; |
240 | 240 | |
241 | - if ( 'calendar' == $post->post_type ) { |
|
241 | + if ('calendar' == $post->post_type) { |
|
242 | 242 | |
243 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
243 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
244 | 244 | return ''; |
245 | 245 | } else { |
246 | 246 | ob_start(); |
247 | - simcal_print_calendar( $post ); |
|
247 | + simcal_print_calendar($post); |
|
248 | 248 | return ob_get_clean(); |
249 | 249 | } |
250 | 250 | |
251 | 251 | } else { |
252 | 252 | |
253 | 253 | $post_types = array(); |
254 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
255 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
254 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
255 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
256 | 256 | $post_types = $settings['general']['attach_calendars_posts']; |
257 | 257 | } |
258 | 258 | |
259 | - if ( empty( $post_types ) ) { |
|
259 | + if (empty($post_types)) { |
|
260 | 260 | return $the_content; |
261 | 261 | } |
262 | 262 | |
263 | - if ( in_array( $post->post_type, (array) $post_types ) ) { |
|
263 | + if (in_array($post->post_type, (array) $post_types)) { |
|
264 | 264 | |
265 | - $id = absint( get_post_meta( $post->ID, '_simcal_attach_calendar_id', true ) ); |
|
265 | + $id = absint(get_post_meta($post->ID, '_simcal_attach_calendar_id', true)); |
|
266 | 266 | |
267 | - if ( $id > 0 ) { |
|
267 | + if ($id > 0) { |
|
268 | 268 | |
269 | - $pos = esc_attr( get_post_meta( $post->ID, '_simcal_attach_calendar_position', true ) ); |
|
269 | + $pos = esc_attr(get_post_meta($post->ID, '_simcal_attach_calendar_position', true)); |
|
270 | 270 | |
271 | 271 | ob_start(); |
272 | 272 | |
273 | - if ( 'after' == $pos ) { |
|
273 | + if ('after' == $pos) { |
|
274 | 274 | echo $the_content; |
275 | - simcal_print_calendar( $id ); |
|
276 | - } elseif ( 'before' == $pos ) { |
|
277 | - simcal_print_calendar( $id ); |
|
275 | + simcal_print_calendar($id); |
|
276 | + } elseif ('before' == $pos) { |
|
277 | + simcal_print_calendar($id); |
|
278 | 278 | echo $the_content; |
279 | 279 | } else { |
280 | 280 | echo $the_content; |
@@ -300,20 +300,20 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @param $post_id |
302 | 302 | */ |
303 | - public function upon_deletion( $post_id ) { |
|
303 | + public function upon_deletion($post_id) { |
|
304 | 304 | |
305 | - $post_type = get_post_type( $post_id ); |
|
305 | + $post_type = get_post_type($post_id); |
|
306 | 306 | |
307 | - if ( 'calendar' == $post_type ) { |
|
307 | + if ('calendar' == $post_type) { |
|
308 | 308 | |
309 | - $notices = get_option( 'simple-calendar_admin_notices', array() ); |
|
309 | + $notices = get_option('simple-calendar_admin_notices', array()); |
|
310 | 310 | |
311 | - if ( ! empty( $notices ) && isset( $notices[ 'calendar_' . strval( $post_id ) ] ) ) { |
|
312 | - unset( $notices[ 'calendar_' . strval( $post_id ) ] ); |
|
313 | - update_option( 'simple-calendar_admin_notices', $notices ); |
|
311 | + if ( ! empty($notices) && isset($notices['calendar_'.strval($post_id)])) { |
|
312 | + unset($notices['calendar_'.strval($post_id)]); |
|
313 | + update_option('simple-calendar_admin_notices', $notices); |
|
314 | 314 | } |
315 | 315 | |
316 | - simcal_delete_feed_transients( $post_id ); |
|
316 | + simcal_delete_feed_transients($post_id); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | use SimpleCalendar\Events\Event_Builder; |
12 | 12 | use SimpleCalendar\Events\Events; |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | * @param int|object|\WP_Post|Calendar $calendar |
235 | 235 | * @param string $view |
236 | 236 | */ |
237 | - public function __construct( $calendar, $view = '' ) { |
|
237 | + public function __construct($calendar, $view = '') { |
|
238 | 238 | |
239 | 239 | // Set the post object. |
240 | - $this->set_post_object( $calendar ); |
|
240 | + $this->set_post_object($calendar); |
|
241 | 241 | |
242 | - if ( ! is_null( $this->post ) ) { |
|
242 | + if ( ! is_null($this->post)) { |
|
243 | 243 | |
244 | 244 | // Set calendar type and events source. |
245 | 245 | $this->set_taxonomies(); |
@@ -256,23 +256,23 @@ discard block |
||
256 | 256 | $this->set_events_template(); |
257 | 257 | |
258 | 258 | // Get events source data. |
259 | - $feed = simcal_get_feed( $this ); |
|
260 | - if ( $feed instanceof Feed ) { |
|
261 | - if ( ! empty( $feed->events ) ) { |
|
262 | - if ( is_array( $feed->events ) ) { |
|
263 | - $this->set_events( $feed->events ); |
|
264 | - if ( 'use_calendar' == get_post_meta( $this->id, '_feed_timezone_setting', true ) ) { |
|
259 | + $feed = simcal_get_feed($this); |
|
260 | + if ($feed instanceof Feed) { |
|
261 | + if ( ! empty($feed->events)) { |
|
262 | + if (is_array($feed->events)) { |
|
263 | + $this->set_events($feed->events); |
|
264 | + if ('use_calendar' == get_post_meta($this->id, '_feed_timezone_setting', true)) { |
|
265 | 265 | $this->timezone = $feed->timezone; |
266 | - $this->set_start( $feed->timezone ); |
|
266 | + $this->set_start($feed->timezone); |
|
267 | 267 | } |
268 | - } elseif ( is_string( $feed->events ) ) { |
|
268 | + } elseif (is_string($feed->events)) { |
|
269 | 269 | $this->errors[] = $feed->events; |
270 | 270 | } |
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | 274 | // Set general purpose timestamps. |
275 | - $now = Carbon::now( $this->timezone ); |
|
275 | + $now = Carbon::now($this->timezone); |
|
276 | 276 | $this->now = $now->getTimestamp(); |
277 | 277 | $this->today = $now->startOfDay()->getTimestamp(); |
278 | 278 | $this->offset = $now->getOffset(); |
@@ -283,26 +283,26 @@ discard block |
||
283 | 283 | $this->set_datetime_separator(); |
284 | 284 | |
285 | 285 | // Set earliest and latest event timestamps. |
286 | - if ( $this->events && is_array( $this->events ) ) { |
|
287 | - $this->earliest_event = intval( current( array_keys( $this->events ) ) ); |
|
288 | - $this->latest_event = intval( key( array_slice( $this->events, -1, 1, true ) ) ); |
|
286 | + if ($this->events && is_array($this->events)) { |
|
287 | + $this->earliest_event = intval(current(array_keys($this->events))); |
|
288 | + $this->latest_event = intval(key(array_slice($this->events, -1, 1, true))); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | // Set calendar end. |
292 | 292 | $this->set_end(); |
293 | 293 | |
294 | 294 | // Set view. |
295 | - if ( ! $view ) { |
|
295 | + if ( ! $view) { |
|
296 | 296 | |
297 | - $calendar_view = get_post_meta( $this->id, '_calendar_view', true ); |
|
298 | - $calendar_view = isset( $calendar_view[ $this->type ] ) ? $calendar_view[ $this->type ] : ''; |
|
297 | + $calendar_view = get_post_meta($this->id, '_calendar_view', true); |
|
298 | + $calendar_view = isset($calendar_view[$this->type]) ? $calendar_view[$this->type] : ''; |
|
299 | 299 | |
300 | - $view = esc_attr( $calendar_view ); |
|
300 | + $view = esc_attr($calendar_view); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
304 | 304 | // Get view. |
305 | - $this->view = $this->get_view( $view ); |
|
305 | + $this->view = $this->get_view($view); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @return bool |
316 | 316 | */ |
317 | - public function __isset( $key ) { |
|
318 | - return metadata_exists( 'post', $this->id, '_' . $key ); |
|
317 | + public function __isset($key) { |
|
318 | + return metadata_exists('post', $this->id, '_'.$key); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return mixed |
329 | 329 | */ |
330 | - public function __get( $key ) { |
|
331 | - $value = get_post_meta( $this->id, '_' . $key, true ); |
|
332 | - if ( ! empty( $value ) ) { |
|
330 | + public function __get($key) { |
|
331 | + $value = get_post_meta($this->id, '_'.$key, true); |
|
332 | + if ( ! empty($value)) { |
|
333 | 333 | $this->$key = $value; |
334 | 334 | } |
335 | 335 | return $value; |
@@ -342,17 +342,17 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @param int|object|\WP_Post|Calendar $calendar |
344 | 344 | */ |
345 | - public function set_post_object( $calendar ) { |
|
346 | - if ( is_numeric( $calendar ) ) { |
|
347 | - $this->id = absint( $calendar ); |
|
348 | - $this->post = get_post( $this->id ); |
|
349 | - } elseif ( $calendar instanceof Calendar ) { |
|
350 | - $this->id = absint( $calendar->id ); |
|
345 | + public function set_post_object($calendar) { |
|
346 | + if (is_numeric($calendar)) { |
|
347 | + $this->id = absint($calendar); |
|
348 | + $this->post = get_post($this->id); |
|
349 | + } elseif ($calendar instanceof Calendar) { |
|
350 | + $this->id = absint($calendar->id); |
|
351 | 351 | $this->post = $calendar->post; |
352 | - } elseif ( $calendar instanceof \WP_Post ) { |
|
353 | - $this->id = absint( $calendar->ID ); |
|
352 | + } elseif ($calendar instanceof \WP_Post) { |
|
353 | + $this->id = absint($calendar->ID); |
|
354 | 354 | $this->post = $calendar; |
355 | - } elseif ( isset( $calendar->id ) && isset( $calendar->post ) ) { |
|
355 | + } elseif (isset($calendar->id) && isset($calendar->post)) { |
|
356 | 356 | $this->id = $calendar->id; |
357 | 357 | $this->post = $calendar->post; |
358 | 358 | } |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | * @return string |
367 | 367 | */ |
368 | 368 | public function get_title() { |
369 | - $title = isset( $this->post->post_title ) ? $this->post->post_title : ''; |
|
370 | - return apply_filters( 'simcal_calendar_title', $title ); |
|
369 | + $title = isset($this->post->post_title) ? $this->post->post_title : ''; |
|
370 | + return apply_filters('simcal_calendar_title', $title); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -389,16 +389,16 @@ discard block |
||
389 | 389 | */ |
390 | 390 | protected function set_taxonomies() { |
391 | 391 | // Set calendar type. |
392 | - if ( $type = wp_get_object_terms( $this->id, 'calendar_type' ) ) { |
|
393 | - $this->type = sanitize_title( current( $type )->name ); |
|
392 | + if ($type = wp_get_object_terms($this->id, 'calendar_type')) { |
|
393 | + $this->type = sanitize_title(current($type)->name); |
|
394 | 394 | } else { |
395 | - $this->type = apply_filters( 'simcal_calendar_default_type', 'default-calendar' ); |
|
395 | + $this->type = apply_filters('simcal_calendar_default_type', 'default-calendar'); |
|
396 | 396 | } |
397 | 397 | // Set feed type. |
398 | - if ( $feed_type = wp_get_object_terms( $this->id, 'calendar_feed' ) ) { |
|
399 | - $this->feed = sanitize_title( current( $feed_type )->name ); |
|
398 | + if ($feed_type = wp_get_object_terms($this->id, 'calendar_feed')) { |
|
399 | + $this->feed = sanitize_title(current($feed_type)->name); |
|
400 | 400 | } else { |
401 | - $this->feed = apply_filters( 'simcal_calendar_default_feed', 'google' ); |
|
401 | + $this->feed = apply_filters('simcal_calendar_default_feed', 'google'); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @return Events |
411 | 411 | */ |
412 | 412 | public function get_events() { |
413 | - return new Events( $this->events, $this->timezone ); |
|
413 | + return new Events($this->events, $this->timezone); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -420,14 +420,14 @@ discard block |
||
420 | 420 | * |
421 | 421 | * @param array $array |
422 | 422 | */ |
423 | - public function set_events( array $array ) { |
|
423 | + public function set_events(array $array) { |
|
424 | 424 | |
425 | 425 | $events = array(); |
426 | 426 | |
427 | - if ( ! empty( $array ) ) { |
|
428 | - foreach ( $array as $tz => $e ) { |
|
429 | - foreach ( $e as $event ) { |
|
430 | - $events[ $tz ][] = $event instanceof Event ? $event : new Event( $event ); |
|
427 | + if ( ! empty($array)) { |
|
428 | + foreach ($array as $tz => $e) { |
|
429 | + foreach ($e as $event) { |
|
430 | + $events[$tz][] = $event instanceof Event ? $event : new Event($event); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | } |
@@ -444,24 +444,24 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return string |
446 | 446 | */ |
447 | - public function set_events_template( $template = '' ) { |
|
448 | - if ( empty( $template ) ) { |
|
449 | - $template = isset( $this->post->post_content ) ? $this->post->post_content : ''; |
|
447 | + public function set_events_template($template = '') { |
|
448 | + if (empty($template)) { |
|
449 | + $template = isset($this->post->post_content) ? $this->post->post_content : ''; |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | // TODO: Removed wpautop() call. |
453 | 453 | |
454 | - $event_formatting = get_post_meta( $this->id, '_event_formatting', true ); |
|
454 | + $event_formatting = get_post_meta($this->id, '_event_formatting', true); |
|
455 | 455 | |
456 | - switch( $event_formatting ) { |
|
456 | + switch ($event_formatting) { |
|
457 | 457 | case 'none': |
458 | - $this->events_template = wp_kses_post( trim( $template ) ); |
|
458 | + $this->events_template = wp_kses_post(trim($template)); |
|
459 | 459 | break; |
460 | 460 | case 'no_linebreaks': |
461 | - $this->events_template = wpautop( wp_kses_post( trim( $template ) ), false ); |
|
461 | + $this->events_template = wpautop(wp_kses_post(trim($template)), false); |
|
462 | 462 | break; |
463 | 463 | default: |
464 | - $this->events_template = wpautop( wp_kses_post( trim( $template ) ), true ); |
|
464 | + $this->events_template = wpautop(wp_kses_post(trim($template)), true); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | //$this->events_template = wpautop( wp_kses_post( trim( $template ) ), true ); |
@@ -474,32 +474,32 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @param string $tz Timezone. |
476 | 476 | */ |
477 | - public function set_timezone( $tz = '' ) { |
|
477 | + public function set_timezone($tz = '') { |
|
478 | 478 | |
479 | - $site_tz = esc_attr( simcal_get_wp_timezone() ); |
|
479 | + $site_tz = esc_attr(simcal_get_wp_timezone()); |
|
480 | 480 | |
481 | - if ( empty( $tz ) ) { |
|
481 | + if (empty($tz)) { |
|
482 | 482 | |
483 | - $timezone_setting = get_post_meta( $this->id, '_feed_timezone_setting', true ); |
|
483 | + $timezone_setting = get_post_meta($this->id, '_feed_timezone_setting', true); |
|
484 | 484 | |
485 | - if ( 'use_site' == $timezone_setting ) { |
|
485 | + if ('use_site' == $timezone_setting) { |
|
486 | 486 | $tz = $site_tz; |
487 | - } elseif ( 'use_custom' == $timezone_setting ) { |
|
488 | - $custom_timezone = esc_attr( get_post_meta( $this->id, '_feed_timezone', true ) ); |
|
487 | + } elseif ('use_custom' == $timezone_setting) { |
|
488 | + $custom_timezone = esc_attr(get_post_meta($this->id, '_feed_timezone', true)); |
|
489 | 489 | // One may be using a non standard timezone in GMT (UTC) offset format. |
490 | - if ( ( strpos( $custom_timezone, 'UTC+' ) === 0 ) || ( strpos( $custom_timezone, 'UTC-' ) === 0 ) ) { |
|
491 | - $tz = simcal_get_timezone_from_gmt_offset( substr( $custom_timezone, 3 ) ); |
|
490 | + if ((strpos($custom_timezone, 'UTC+') === 0) || (strpos($custom_timezone, 'UTC-') === 0)) { |
|
491 | + $tz = simcal_get_timezone_from_gmt_offset(substr($custom_timezone, 3)); |
|
492 | 492 | } else { |
493 | - $tz = ! empty( $custom_timezone ) ? $custom_timezone : 'UTC'; |
|
493 | + $tz = ! empty($custom_timezone) ? $custom_timezone : 'UTC'; |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | - $this->timezone = empty( $tz ) ? 'UTC' : $tz; |
|
497 | + $this->timezone = empty($tz) ? 'UTC' : $tz; |
|
498 | 498 | return; |
499 | 499 | } |
500 | 500 | |
501 | 501 | $this->site_timezone = $site_tz; |
502 | - $this->timezone = simcal_esc_timezone( $tz, $this->timezone ); |
|
502 | + $this->timezone = simcal_esc_timezone($tz, $this->timezone); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
@@ -509,20 +509,20 @@ discard block |
||
509 | 509 | * |
510 | 510 | * @param string $format PHP datetime format. |
511 | 511 | */ |
512 | - public function set_date_format( $format = '' ) { |
|
512 | + public function set_date_format($format = '') { |
|
513 | 513 | |
514 | 514 | $date_format_custom = $date_format_default = $format; |
515 | 515 | |
516 | - if ( empty( $date_format_custom ) ) { |
|
516 | + if (empty($date_format_custom)) { |
|
517 | 517 | |
518 | - $date_format_option = esc_attr( get_post_meta( $this->id, '_calendar_date_format_setting', true ) ); |
|
519 | - $date_format_default = esc_attr( get_option( 'date_format' ) ); |
|
518 | + $date_format_option = esc_attr(get_post_meta($this->id, '_calendar_date_format_setting', true)); |
|
519 | + $date_format_default = esc_attr(get_option('date_format')); |
|
520 | 520 | $date_format_custom = ''; |
521 | 521 | |
522 | - if ( 'use_custom' == $date_format_option ) { |
|
523 | - $date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format', true ) ); |
|
524 | - } elseif ( 'use_custom_php' == $date_format_option ) { |
|
525 | - $date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format_php', true ) ); |
|
522 | + if ('use_custom' == $date_format_option) { |
|
523 | + $date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format', true)); |
|
524 | + } elseif ('use_custom_php' == $date_format_option) { |
|
525 | + $date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format_php', true)); |
|
526 | 526 | } |
527 | 527 | } |
528 | 528 | |
@@ -536,20 +536,20 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @param string $format PHP datetime format. |
538 | 538 | */ |
539 | - public function set_time_format( $format = '' ) { |
|
539 | + public function set_time_format($format = '') { |
|
540 | 540 | |
541 | 541 | $time_format_custom = $time_format_default = $format; |
542 | 542 | |
543 | - if ( empty( $time_format_custom ) ) { |
|
543 | + if (empty($time_format_custom)) { |
|
544 | 544 | |
545 | - $time_format_option = esc_attr( get_post_meta( $this->id, '_calendar_time_format_setting', true ) ); |
|
546 | - $time_format_default = esc_attr( get_option( 'time_format' ) ); |
|
545 | + $time_format_option = esc_attr(get_post_meta($this->id, '_calendar_time_format_setting', true)); |
|
546 | + $time_format_default = esc_attr(get_option('time_format')); |
|
547 | 547 | $time_format_custom = ''; |
548 | 548 | |
549 | - if ( 'use_custom' == $time_format_option ) { |
|
550 | - $time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format', true ) ); |
|
551 | - } elseif ( 'use_custom_php' == $time_format_option ) { |
|
552 | - $time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format_php', true ) ); |
|
549 | + if ('use_custom' == $time_format_option) { |
|
550 | + $time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format', true)); |
|
551 | + } elseif ('use_custom_php' == $time_format_option) { |
|
552 | + $time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format_php', true)); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | |
@@ -563,13 +563,13 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @param string $separator A UTF8 character used as separator. |
565 | 565 | */ |
566 | - public function set_datetime_separator( $separator = '' ) { |
|
566 | + public function set_datetime_separator($separator = '') { |
|
567 | 567 | |
568 | - if ( empty( $separator ) ) { |
|
569 | - $separator = get_post_meta( $this->id, '_calendar_datetime_separator', true ); |
|
568 | + if (empty($separator)) { |
|
569 | + $separator = get_post_meta($this->id, '_calendar_datetime_separator', true); |
|
570 | 570 | } |
571 | 571 | |
572 | - $this->datetime_separator = esc_attr( $separator ); |
|
572 | + $this->datetime_separator = esc_attr($separator); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -579,18 +579,18 @@ discard block |
||
579 | 579 | * |
580 | 580 | * @param int $weekday From 0 (Sunday) to 6 (Friday). |
581 | 581 | */ |
582 | - public function set_start_of_week( $weekday = -1 ) { |
|
582 | + public function set_start_of_week($weekday = -1) { |
|
583 | 583 | |
584 | - $week_starts = is_int( $weekday ) ? $weekday : -1; |
|
584 | + $week_starts = is_int($weekday) ? $weekday : -1; |
|
585 | 585 | |
586 | - if ( $week_starts < 0 || $week_starts > 6 ) { |
|
586 | + if ($week_starts < 0 || $week_starts > 6) { |
|
587 | 587 | |
588 | - $week_starts_setting = get_post_meta( $this->id, '_calendar_week_starts_on_setting', true ); |
|
589 | - $week_starts = intval( get_option( 'start_of_week' ) ); |
|
588 | + $week_starts_setting = get_post_meta($this->id, '_calendar_week_starts_on_setting', true); |
|
589 | + $week_starts = intval(get_option('start_of_week')); |
|
590 | 590 | |
591 | - if ( 'use_custom' == $week_starts_setting ) { |
|
592 | - $week_starts_on = get_post_meta( $this->id, '_calendar_week_starts_on', true ); |
|
593 | - $week_starts = is_numeric( $week_starts_on ) ? intval( $week_starts_on ) : $week_starts; |
|
591 | + if ('use_custom' == $week_starts_setting) { |
|
592 | + $week_starts_on = get_post_meta($this->id, '_calendar_week_starts_on', true); |
|
593 | + $week_starts = is_numeric($week_starts_on) ? intval($week_starts_on) : $week_starts; |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
@@ -604,51 +604,51 @@ discard block |
||
604 | 604 | * |
605 | 605 | * @param int $timestamp |
606 | 606 | */ |
607 | - public function set_start( $timestamp = 0 ) { |
|
607 | + public function set_start($timestamp = 0) { |
|
608 | 608 | |
609 | - if ( is_int( $timestamp ) && $timestamp !== 0 ) { |
|
609 | + if (is_int($timestamp) && $timestamp !== 0) { |
|
610 | 610 | $this->start = $timestamp; |
611 | 611 | return; |
612 | 612 | } |
613 | 613 | |
614 | - $this->start = Carbon::now( $this->timezone )->getTimestamp(); |
|
614 | + $this->start = Carbon::now($this->timezone)->getTimestamp(); |
|
615 | 615 | |
616 | - $calendar_begins = esc_attr( get_post_meta( $this->id, '_calendar_begins', true ) ); |
|
617 | - $nth = max( absint( get_post_meta( $this->id, '_calendar_begins_nth', true ) ), 1 ); |
|
616 | + $calendar_begins = esc_attr(get_post_meta($this->id, '_calendar_begins', true)); |
|
617 | + $nth = max(absint(get_post_meta($this->id, '_calendar_begins_nth', true)), 1); |
|
618 | 618 | |
619 | - if ( 'today' == $calendar_begins ) { |
|
620 | - $this->start = Carbon::today( $this->timezone )->getTimestamp(); |
|
621 | - } elseif ( 'days_before' == $calendar_begins ) { |
|
622 | - $this->start = Carbon::today( $this->timezone )->subDays( $nth )->getTimestamp(); |
|
623 | - } elseif ( 'days_after' == $calendar_begins ) { |
|
624 | - $this->start = Carbon::today( $this->timezone )->addDays( $nth )->getTimestamp(); |
|
625 | - } elseif ( 'this_week' == $calendar_begins ) { |
|
626 | - $week = new Carbon( 'now', $this->timezone ); |
|
627 | - $week->setWeekStartsAt( $this->week_starts ); |
|
619 | + if ('today' == $calendar_begins) { |
|
620 | + $this->start = Carbon::today($this->timezone)->getTimestamp(); |
|
621 | + } elseif ('days_before' == $calendar_begins) { |
|
622 | + $this->start = Carbon::today($this->timezone)->subDays($nth)->getTimestamp(); |
|
623 | + } elseif ('days_after' == $calendar_begins) { |
|
624 | + $this->start = Carbon::today($this->timezone)->addDays($nth)->getTimestamp(); |
|
625 | + } elseif ('this_week' == $calendar_begins) { |
|
626 | + $week = new Carbon('now', $this->timezone); |
|
627 | + $week->setWeekStartsAt($this->week_starts); |
|
628 | 628 | $this->start = $week->startOfWeek()->getTimestamp(); |
629 | - } elseif ( 'weeks_before' == $calendar_begins ) { |
|
630 | - $week = new Carbon( 'now', $this->timezone ); |
|
631 | - $week->setWeekStartsAt( $this->week_starts ); |
|
632 | - $this->start = $week->startOfWeek()->subWeeks( $nth )->getTimestamp(); |
|
633 | - } elseif ( 'weeks_after' == $calendar_begins ) { |
|
634 | - $week = new Carbon( 'now', $this->timezone ); |
|
635 | - $week->setWeekStartsAt( $this->week_starts ); |
|
636 | - $this->start = $week->startOfWeek()->addWeeks( $nth )->getTimestamp(); |
|
637 | - } elseif ( 'this_month' == $calendar_begins ) { |
|
638 | - $this->start = Carbon::today( $this->timezone )->startOfMonth()->getTimeStamp(); |
|
639 | - } elseif ( 'months_before' == $calendar_begins ) { |
|
640 | - $this->start = Carbon::today( $this->timezone )->subMonths( $nth )->startOfMonth()->getTimeStamp(); |
|
641 | - } elseif ( 'months_after' == $calendar_begins ) { |
|
642 | - $this->start = Carbon::today( $this->timezone )->addMonths( $nth )->startOfMonth()->getTimeStamp(); |
|
643 | - } elseif ( 'this_year' == $calendar_begins ) { |
|
644 | - $this->start = Carbon::today( $this->timezone )->startOfYear()->getTimestamp(); |
|
645 | - } elseif ( 'years_before' == $calendar_begins ) { |
|
646 | - $this->start = Carbon::today( $this->timezone )->subYears( $nth )->startOfYear()->getTimeStamp(); |
|
647 | - } elseif ( 'years_after' == $calendar_begins ) { |
|
648 | - $this->start = Carbon::today( $this->timezone )->addYears( $nth )->startOfYear()->getTimeStamp(); |
|
649 | - } elseif ( 'custom_date' == $calendar_begins ) { |
|
650 | - if ( $date = get_post_meta( $this->id, '_calendar_begins_custom_date', true ) ) { |
|
651 | - $this->start = Carbon::createFromFormat( 'Y-m-d', esc_attr( $date ), $this->timezone )->setTimezone( $this->timezone )->startOfDay()->getTimestamp(); |
|
629 | + } elseif ('weeks_before' == $calendar_begins) { |
|
630 | + $week = new Carbon('now', $this->timezone); |
|
631 | + $week->setWeekStartsAt($this->week_starts); |
|
632 | + $this->start = $week->startOfWeek()->subWeeks($nth)->getTimestamp(); |
|
633 | + } elseif ('weeks_after' == $calendar_begins) { |
|
634 | + $week = new Carbon('now', $this->timezone); |
|
635 | + $week->setWeekStartsAt($this->week_starts); |
|
636 | + $this->start = $week->startOfWeek()->addWeeks($nth)->getTimestamp(); |
|
637 | + } elseif ('this_month' == $calendar_begins) { |
|
638 | + $this->start = Carbon::today($this->timezone)->startOfMonth()->getTimeStamp(); |
|
639 | + } elseif ('months_before' == $calendar_begins) { |
|
640 | + $this->start = Carbon::today($this->timezone)->subMonths($nth)->startOfMonth()->getTimeStamp(); |
|
641 | + } elseif ('months_after' == $calendar_begins) { |
|
642 | + $this->start = Carbon::today($this->timezone)->addMonths($nth)->startOfMonth()->getTimeStamp(); |
|
643 | + } elseif ('this_year' == $calendar_begins) { |
|
644 | + $this->start = Carbon::today($this->timezone)->startOfYear()->getTimestamp(); |
|
645 | + } elseif ('years_before' == $calendar_begins) { |
|
646 | + $this->start = Carbon::today($this->timezone)->subYears($nth)->startOfYear()->getTimeStamp(); |
|
647 | + } elseif ('years_after' == $calendar_begins) { |
|
648 | + $this->start = Carbon::today($this->timezone)->addYears($nth)->startOfYear()->getTimeStamp(); |
|
649 | + } elseif ('custom_date' == $calendar_begins) { |
|
650 | + if ($date = get_post_meta($this->id, '_calendar_begins_custom_date', true)) { |
|
651 | + $this->start = Carbon::createFromFormat('Y-m-d', esc_attr($date), $this->timezone)->setTimezone($this->timezone)->startOfDay()->getTimestamp(); |
|
652 | 652 | } |
653 | 653 | } |
654 | 654 | } |
@@ -660,8 +660,8 @@ discard block |
||
660 | 660 | * |
661 | 661 | * @param int $timestamp |
662 | 662 | */ |
663 | - public function set_end( $timestamp = 0 ) { |
|
664 | - $latest = is_int( $timestamp ) && $timestamp !== 0 ? $timestamp : $this->latest_event; |
|
663 | + public function set_end($timestamp = 0) { |
|
664 | + $latest = is_int($timestamp) && $timestamp !== 0 ? $timestamp : $this->latest_event; |
|
665 | 665 | $this->end = $latest > $this->start ? $latest : $this->start; |
666 | 666 | } |
667 | 667 | |
@@ -672,14 +672,14 @@ discard block |
||
672 | 672 | * |
673 | 673 | * @param string|bool $static |
674 | 674 | */ |
675 | - public function set_static( $static = '' ) { |
|
675 | + public function set_static($static = '') { |
|
676 | 676 | |
677 | - if ( ! empty( $static ) && is_bool( $static ) ) { |
|
677 | + if ( ! empty($static) && is_bool($static)) { |
|
678 | 678 | $this->static = $static; |
679 | 679 | return; |
680 | 680 | } |
681 | 681 | |
682 | - if ( 'yes' == get_post_meta( $this->id, '_calendar_is_static', true ) ) { |
|
682 | + if ('yes' == get_post_meta($this->id, '_calendar_is_static', true)) { |
|
683 | 683 | $this->static = true; |
684 | 684 | return; |
685 | 685 | } |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * |
708 | 708 | * @return Calendar_View |
709 | 709 | */ |
710 | - abstract public function get_view( $view = '' ); |
|
710 | + abstract public function get_view($view = ''); |
|
711 | 711 | |
712 | 712 | /** |
713 | 713 | * Get event HTML parsed by template. |
@@ -719,11 +719,11 @@ discard block |
||
719 | 719 | * |
720 | 720 | * @return string |
721 | 721 | */ |
722 | - public function get_event_html( Event $event, $template = '' ) { |
|
723 | - $event_builder = new Event_Builder( $event, $this ); |
|
722 | + public function get_event_html(Event $event, $template = '') { |
|
723 | + $event_builder = new Event_Builder($event, $this); |
|
724 | 724 | // Use the event template to parse tags; if empty, fallback to calendar post content. |
725 | - $template = empty( $template ) ? ( empty( $event->template ) ? $this->events_template : $event->template ) : $template; |
|
726 | - return $event_builder->parse_event_template_tags( $template ); |
|
725 | + $template = empty($template) ? (empty($event->template) ? $this->events_template : $event->template) : $template; |
|
726 | + return $event_builder->parse_event_template_tags($template); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
@@ -733,58 +733,58 @@ discard block |
||
733 | 733 | * |
734 | 734 | * @param string $view The calendar view to display. |
735 | 735 | */ |
736 | - public function html( $view = '' ) { |
|
736 | + public function html($view = '') { |
|
737 | 737 | |
738 | - $view = empty( $view ) ? $this->view : $this->get_view( $view ); |
|
738 | + $view = empty($view) ? $this->view : $this->get_view($view); |
|
739 | 739 | |
740 | - if ( $view instanceof Calendar_View ) { |
|
740 | + if ($view instanceof Calendar_View) { |
|
741 | 741 | |
742 | - if ( ! empty( $this->errors ) ) { |
|
742 | + if ( ! empty($this->errors)) { |
|
743 | 743 | |
744 | - if ( current_user_can( 'manage_options' ) ) { |
|
744 | + if (current_user_can('manage_options')) { |
|
745 | 745 | echo '<pre><code>'; |
746 | - foreach ( $this->errors as $error ) { echo $error; } |
|
746 | + foreach ($this->errors as $error) { echo $error; } |
|
747 | 747 | echo '</code></pre>'; |
748 | 748 | } |
749 | 749 | |
750 | 750 | } else { |
751 | 751 | |
752 | 752 | // Get a CSS class from the class name of the calendar view (minus namespace part). |
753 | - $view_name = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( get_class( $view ) ) ) ) ); |
|
754 | - $view_class = substr( $view_name, strrpos( $view_name, '\\' ) + 1 ); |
|
753 | + $view_name = implode('-', array_map('lcfirst', explode('_', strtolower(get_class($view))))); |
|
754 | + $view_class = substr($view_name, strrpos($view_name, '\\') + 1); |
|
755 | 755 | |
756 | - $calendar_class = trim( implode( ' simcal-', apply_filters( 'simcal_calendar_class', array( |
|
756 | + $calendar_class = trim(implode(' simcal-', apply_filters('simcal_calendar_class', array( |
|
757 | 757 | 'simcal-calendar', |
758 | 758 | $this->type, |
759 | 759 | $view_class, |
760 | - ), $this->id ) ) ); |
|
761 | - |
|
762 | - echo '<div class="' . $calendar_class . '" ' |
|
763 | - . 'data-calendar-id="' . $this->id . '" ' |
|
764 | - . 'data-timezone="' . $this->timezone . '" ' |
|
765 | - . 'data-offset="' . $this->offset . '" ' |
|
766 | - . 'data-week-start="' . $this->week_starts . '" ' |
|
767 | - . 'data-calendar-start="' . $this->start .'" ' |
|
768 | - . 'data-calendar-end="' . $this->end . '" ' |
|
769 | - . 'data-events-first="' . $this->earliest_event .'" ' |
|
770 | - . 'data-events-last="' . $this->latest_event . '"' |
|
760 | + ), $this->id))); |
|
761 | + |
|
762 | + echo '<div class="'.$calendar_class.'" ' |
|
763 | + . 'data-calendar-id="'.$this->id.'" ' |
|
764 | + . 'data-timezone="'.$this->timezone.'" ' |
|
765 | + . 'data-offset="'.$this->offset.'" ' |
|
766 | + . 'data-week-start="'.$this->week_starts.'" ' |
|
767 | + . 'data-calendar-start="'.$this->start.'" ' |
|
768 | + . 'data-calendar-end="'.$this->end.'" ' |
|
769 | + . 'data-events-first="'.$this->earliest_event.'" ' |
|
770 | + . 'data-events-last="'.$this->latest_event.'"' |
|
771 | 771 | . '>'; |
772 | 772 | |
773 | - date_default_timezone_set( $this->timezone ); |
|
774 | - do_action( 'simcal_calendar_html_before', $this->id ); |
|
773 | + date_default_timezone_set($this->timezone); |
|
774 | + do_action('simcal_calendar_html_before', $this->id); |
|
775 | 775 | |
776 | 776 | $view->html(); |
777 | 777 | |
778 | - do_action( 'simcal_calendar_html_after', $this->id ); |
|
779 | - date_default_timezone_set( $this->site_timezone ); |
|
778 | + do_action('simcal_calendar_html_after', $this->id); |
|
779 | + date_default_timezone_set($this->site_timezone); |
|
780 | 780 | |
781 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
782 | - $poweredby = isset( $settings['poweredby']['opt_in'] ) ? $settings['poweredby']['opt_in'] : ''; |
|
781 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
782 | + $poweredby = isset($settings['poweredby']['opt_in']) ? $settings['poweredby']['opt_in'] : ''; |
|
783 | 783 | |
784 | - if ( 'yes' == $poweredby ) { |
|
784 | + if ('yes' == $poweredby) { |
|
785 | 785 | $align = is_rtl() ? 'left' : 'right'; |
786 | - echo '<small class="simcal-powered simcal-align-' . $align .'">' . |
|
787 | - sprintf( __( 'Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events' ), simcal_get_url( 'home' ) ) . |
|
786 | + echo '<small class="simcal-powered simcal-align-'.$align.'">'. |
|
787 | + sprintf(__('Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events'), simcal_get_url('home')). |
|
788 | 788 | '</small>'; |
789 | 789 | } |
790 | 790 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | use SimpleCalendar\Abstracts\Feed; |
12 | 12 | use SimpleCalendar\Abstracts\Field; |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -31,40 +31,40 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @param \WP_Post $post |
33 | 33 | */ |
34 | - public static function html( $post ) { |
|
34 | + public static function html($post) { |
|
35 | 35 | |
36 | 36 | // @see Meta_Boxes::save_meta_boxes() |
37 | - wp_nonce_field( 'simcal_save_data', 'simcal_meta_nonce' ); |
|
37 | + wp_nonce_field('simcal_save_data', 'simcal_meta_nonce'); |
|
38 | 38 | |
39 | 39 | ?> |
40 | 40 | <div class="simcal-panels-wrap"> |
41 | 41 | |
42 | 42 | <span class="simcal-box-handle"> |
43 | - <?php self::settings_handle( $post ); ?> |
|
43 | + <?php self::settings_handle($post); ?> |
|
44 | 44 | </span> |
45 | 45 | |
46 | 46 | <ul class="simcal-tabs"> |
47 | - <?php self::settings_tabs( $post ); ?> |
|
48 | - <?php do_action( 'simcal_settings_meta_tabs' ); ?> |
|
47 | + <?php self::settings_tabs($post); ?> |
|
48 | + <?php do_action('simcal_settings_meta_tabs'); ?> |
|
49 | 49 | </ul> |
50 | 50 | |
51 | 51 | <div class="simcal-panels"> |
52 | 52 | <div id="events-settings-panel" class="simcal-panel"> |
53 | - <?php self::events_settings_panel( $post ); ?> |
|
54 | - <?php do_action( 'simcal_settings_meta_events_panel', $post->ID ); ?> |
|
53 | + <?php self::events_settings_panel($post); ?> |
|
54 | + <?php do_action('simcal_settings_meta_events_panel', $post->ID); ?> |
|
55 | 55 | </div> |
56 | 56 | <div id="calendar-settings-panel" class="simcal-panel"> |
57 | - <?php do_action( 'simcal_settings_meta_calendar_panel', $post->ID ); ?> |
|
58 | - <?php self::calendar_settings_panel( $post ); ?> |
|
57 | + <?php do_action('simcal_settings_meta_calendar_panel', $post->ID); ?> |
|
58 | + <?php self::calendar_settings_panel($post); ?> |
|
59 | 59 | </div> |
60 | 60 | <?php |
61 | 61 | // Hook for additional settings panels. |
62 | - do_action( 'simcal_settings_meta_panels', $post->ID ); |
|
62 | + do_action('simcal_settings_meta_panels', $post->ID); |
|
63 | 63 | // Thus advanced panel is always the last one: |
64 | 64 | ?> |
65 | 65 | <div id="advanced-settings-panel" class="simcal-panel"> |
66 | - <?php self::advanced_settings_panel( $post ) ?> |
|
67 | - <?php do_action( 'simcal_settings_meta_advanced_panel', $post->ID ); ?> |
|
66 | + <?php self::advanced_settings_panel($post) ?> |
|
67 | + <?php do_action('simcal_settings_meta_advanced_panel', $post->ID); ?> |
|
68 | 68 | </div> |
69 | 69 | </div> |
70 | 70 | |
@@ -84,45 +84,45 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param \WP_Post $post |
86 | 86 | */ |
87 | - private static function settings_handle( $post ) { |
|
87 | + private static function settings_handle($post) { |
|
88 | 88 | |
89 | 89 | $feed_options = $calendar_options = $calendar_views = array(); |
90 | 90 | |
91 | 91 | $feed_types = simcal_get_feed_types(); |
92 | - foreach ( $feed_types as $feed_type ) { |
|
92 | + foreach ($feed_types as $feed_type) { |
|
93 | 93 | |
94 | - $feed = simcal_get_feed( $feed_type ); |
|
94 | + $feed = simcal_get_feed($feed_type); |
|
95 | 95 | |
96 | - if ( $feed instanceof Feed ) { |
|
97 | - $feed_options[ $feed_type ] = $feed->name; |
|
96 | + if ($feed instanceof Feed) { |
|
97 | + $feed_options[$feed_type] = $feed->name; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | $calendar_types = simcal_get_calendar_types(); |
102 | - foreach ( $calendar_types as $calendar_type => $views ) { |
|
102 | + foreach ($calendar_types as $calendar_type => $views) { |
|
103 | 103 | |
104 | - $calendar = simcal_get_calendar( $calendar_type ); |
|
104 | + $calendar = simcal_get_calendar($calendar_type); |
|
105 | 105 | |
106 | - if ( $calendar instanceof Calendar ) { |
|
107 | - $calendar_options[ $calendar_type ] = $calendar->name; |
|
108 | - $calendar_views[ $calendar_type ] = $calendar->views; |
|
106 | + if ($calendar instanceof Calendar) { |
|
107 | + $calendar_options[$calendar_type] = $calendar->name; |
|
108 | + $calendar_views[$calendar_type] = $calendar->views; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - if ( $feed_options ) { |
|
112 | + if ($feed_options) { |
|
113 | 113 | |
114 | - if ( $feed_types = wp_get_object_terms( $post->ID, 'calendar_feed' ) ) { |
|
115 | - $feed_type = sanitize_title( current( $feed_types )->name ); |
|
114 | + if ($feed_types = wp_get_object_terms($post->ID, 'calendar_feed')) { |
|
115 | + $feed_type = sanitize_title(current($feed_types)->name); |
|
116 | 116 | } else { |
117 | - $feed_type = apply_filters( 'simcal_default_feed_type', 'google' ); |
|
117 | + $feed_type = apply_filters('simcal_default_feed_type', 'google'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | ?> |
121 | - <label for="_feed_type"><span><?php _e( 'Event Source', 'google-calendar-events' ); ?></span> |
|
121 | + <label for="_feed_type"><span><?php _e('Event Source', 'google-calendar-events'); ?></span> |
|
122 | 122 | <select name="_feed_type" id="_feed_type"> |
123 | - <optgroup label="<?php _ex( 'Get events from', 'From which calendar source to load events from', 'google-calendar-events' ) ?>"> |
|
124 | - <?php foreach ( $feed_options as $feed => $name ) { ?> |
|
125 | - <option value="<?php echo $feed; ?>" <?php selected( $feed, $feed_type, true ); ?>><?php echo $name; ?></option> |
|
123 | + <optgroup label="<?php _ex('Get events from', 'From which calendar source to load events from', 'google-calendar-events') ?>"> |
|
124 | + <?php foreach ($feed_options as $feed => $name) { ?> |
|
125 | + <option value="<?php echo $feed; ?>" <?php selected($feed, $feed_type, true); ?>><?php echo $name; ?></option> |
|
126 | 126 | <?php } ?> |
127 | 127 | </optgroup> |
128 | 128 | </select> |
@@ -131,40 +131,40 @@ discard block |
||
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | - if ( $calendar_options ) { |
|
134 | + if ($calendar_options) { |
|
135 | 135 | |
136 | - if ( $calendar_types = wp_get_object_terms( $post->ID, 'calendar_type' ) ) { |
|
137 | - $calendar_type = sanitize_title( current( $calendar_types )->name ); |
|
136 | + if ($calendar_types = wp_get_object_terms($post->ID, 'calendar_type')) { |
|
137 | + $calendar_type = sanitize_title(current($calendar_types)->name); |
|
138 | 138 | } else { |
139 | - $calendar_type = apply_filters( 'simcal_default_calendar_type', 'default-calendar' ); |
|
139 | + $calendar_type = apply_filters('simcal_default_calendar_type', 'default-calendar'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | ?> |
143 | - <label for="_calendar_type"><span><?php _e( 'Calendar', 'google-calendar-events' ); ?></span> |
|
143 | + <label for="_calendar_type"><span><?php _e('Calendar', 'google-calendar-events'); ?></span> |
|
144 | 144 | <select name="_calendar_type" id="_calendar_type"> |
145 | - <optgroup label="<?php _e( 'Calendar to use', 'google-calendar-events' ); ?>"> |
|
146 | - <?php foreach ( $calendar_options as $calendar => $name ) { ?> |
|
147 | - <option value="<?php echo $calendar; ?>" <?php selected( $calendar, $calendar_type, true ); ?>><?php echo $name; ?></option> |
|
145 | + <optgroup label="<?php _e('Calendar to use', 'google-calendar-events'); ?>"> |
|
146 | + <?php foreach ($calendar_options as $calendar => $name) { ?> |
|
147 | + <option value="<?php echo $calendar; ?>" <?php selected($calendar, $calendar_type, true); ?>><?php echo $name; ?></option> |
|
148 | 148 | <?php } ?> |
149 | 149 | </optgroup> |
150 | 150 | </select> |
151 | 151 | </label> |
152 | 152 | <?php |
153 | 153 | |
154 | - if ( $calendar_views ) { |
|
154 | + if ($calendar_views) { |
|
155 | 155 | |
156 | - $calendar_view = get_post_meta( $post->ID, '_calendar_view', true ); |
|
156 | + $calendar_view = get_post_meta($post->ID, '_calendar_view', true); |
|
157 | 157 | |
158 | - foreach ( $calendar_views as $calendar => $views ) { |
|
158 | + foreach ($calendar_views as $calendar => $views) { |
|
159 | 159 | |
160 | - $calendar_type_view = isset( $calendar_view[ $calendar ] ) ? $calendar_view[ $calendar ] : ''; |
|
160 | + $calendar_type_view = isset($calendar_view[$calendar]) ? $calendar_view[$calendar] : ''; |
|
161 | 161 | |
162 | 162 | ?> |
163 | - <label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e( 'View', 'google-calendar-events' ); ?></span> |
|
163 | + <label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e('View', 'google-calendar-events'); ?></span> |
|
164 | 164 | <select name="_calendar_view[<?php echo $calendar; ?>]" id="_calendar_view_<?php echo $calendar; ?>"> |
165 | - <optgroup label="<?php _e( 'View to display', 'google-calendar-events' ); ?>"> |
|
166 | - <?php foreach ( $views as $view => $name ) { ?> |
|
167 | - <option value="<?php echo $view; ?>" <?php selected( $view, $calendar_type_view, true ); ?>><?php echo $name; ?></option> |
|
165 | + <optgroup label="<?php _e('View to display', 'google-calendar-events'); ?>"> |
|
166 | + <?php foreach ($views as $view => $name) { ?> |
|
167 | + <option value="<?php echo $view; ?>" <?php selected($view, $calendar_type_view, true); ?>><?php echo $name; ?></option> |
|
168 | 168 | <?php } ?> |
169 | 169 | </optgroup> |
170 | 170 | </select> |
@@ -184,42 +184,42 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @param \WP_Post $post |
186 | 186 | */ |
187 | - private static function settings_tabs( $post ) { |
|
187 | + private static function settings_tabs($post) { |
|
188 | 188 | |
189 | 189 | // Hook to add more tabs. |
190 | - $tabs = apply_filters( 'simcal_settings_meta_tabs_li', array( |
|
190 | + $tabs = apply_filters('simcal_settings_meta_tabs_li', array( |
|
191 | 191 | 'events' => array( |
192 | - 'label' => __( 'Events', 'google-calendar-events' ), |
|
192 | + 'label' => __('Events', 'google-calendar-events'), |
|
193 | 193 | 'target' => 'events-settings-panel', |
194 | - 'class' => array( 'active' ), |
|
194 | + 'class' => array('active'), |
|
195 | 195 | 'icon' => 'simcal-icon-event', |
196 | 196 | ), |
197 | 197 | 'calendar' => array( |
198 | - 'label' => __( 'Appearance', 'google-calendar-events' ), |
|
198 | + 'label' => __('Appearance', 'google-calendar-events'), |
|
199 | 199 | 'target' => 'calendar-settings-panel', |
200 | 200 | 'class' => array(), |
201 | 201 | 'icon' => 'simcal-icon-calendar', |
202 | 202 | ), |
203 | - ), $post->ID ); |
|
203 | + ), $post->ID); |
|
204 | 204 | |
205 | 205 | // Always keep advanced tab as the last one. |
206 | 206 | $tabs['advanced'] = array( |
207 | - 'label' => __( 'Advanced', 'google-calendar-events' ), |
|
207 | + 'label' => __('Advanced', 'google-calendar-events'), |
|
208 | 208 | 'target' => 'advanced-settings-panel', |
209 | 209 | 'class' => array(), |
210 | 210 | 'icon' => 'simcal-icon-settings', |
211 | 211 | ); |
212 | 212 | |
213 | 213 | // Output the tabs as list items. |
214 | - foreach ( $tabs as $key => $tab ) { |
|
214 | + foreach ($tabs as $key => $tab) { |
|
215 | 215 | |
216 | - if ( isset( $tab['target'] ) && isset( $tab['label'] ) ) { |
|
216 | + if (isset($tab['target']) && isset($tab['label'])) { |
|
217 | 217 | |
218 | 218 | $icon = $tab['icon'] ? $tab['icon'] : 'simcal-icon-panel'; |
219 | 219 | $class = $tab['class'] ? $tab['class'] : array(); |
220 | 220 | |
221 | - echo '<li class="' . $key . '-settings ' . $key . '-tab ' . implode( ' ', $class ) . '" data-tab="' . $key . '">'; |
|
222 | - echo '<a href="#' . $tab['target'] . '"><i class="' . $icon . '" ></i> <span>' . esc_html( $tab['label'] ) . '</span></a>'; |
|
221 | + echo '<li class="'.$key.'-settings '.$key.'-tab '.implode(' ', $class).'" data-tab="'.$key.'">'; |
|
222 | + echo '<a href="#'.$tab['target'].'"><i class="'.$icon.'" ></i> <span>'.esc_html($tab['label']).'</span></a>'; |
|
223 | 223 | echo '</li>'; |
224 | 224 | } |
225 | 225 | } |
@@ -233,22 +233,22 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @param \WP_Post $post |
235 | 235 | */ |
236 | - private static function events_settings_panel( $post ) { |
|
236 | + private static function events_settings_panel($post) { |
|
237 | 237 | |
238 | 238 | ?> |
239 | 239 | <table> |
240 | 240 | <thead> |
241 | - <tr><th colspan="2"><?php _e( 'Events setting', 'google-calendar-events' ); ?></th></tr> |
|
241 | + <tr><th colspan="2"><?php _e('Events setting', 'google-calendar-events'); ?></th></tr> |
|
242 | 242 | </thead> |
243 | 243 | <tbody class="simcal-panel-section simcal-panel-section-events-range"> |
244 | 244 | <tr class="simcal-panel-field"> |
245 | - <th><label for="_calendar_begins"><?php _e( 'Calendar start', 'google-calendar-events' ); ?></label></th> |
|
245 | + <th><label for="_calendar_begins"><?php _e('Calendar start', 'google-calendar-events'); ?></label></th> |
|
246 | 246 | <td> |
247 | 247 | <?php |
248 | 248 | |
249 | - $calendar_begins = esc_attr( get_post_meta( $post->ID, '_calendar_begins', true ) ); |
|
250 | - $calendar_begins_nth = max( absint( get_post_meta( $post->ID, '_calendar_begins_nth', true ) ), 1 ); |
|
251 | - $calendar_begins_nth_show = in_array( $calendar_begins, array( |
|
249 | + $calendar_begins = esc_attr(get_post_meta($post->ID, '_calendar_begins', true)); |
|
250 | + $calendar_begins_nth = max(absint(get_post_meta($post->ID, '_calendar_begins_nth', true)), 1); |
|
251 | + $calendar_begins_nth_show = in_array($calendar_begins, array( |
|
252 | 252 | 'days_before', |
253 | 253 | 'days_after', |
254 | 254 | 'weeks_before', |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | 'months_after', |
258 | 258 | 'years_before', |
259 | 259 | 'years_after', |
260 | - ) ); |
|
260 | + )); |
|
261 | 261 | |
262 | - simcal_print_field( array( |
|
262 | + simcal_print_field(array( |
|
263 | 263 | 'type' => 'standard', |
264 | 264 | 'subtype' => 'number', |
265 | 265 | 'name' => '_calendar_begins_nth', |
266 | 266 | 'id' => '_calendar_begins_nth', |
267 | - 'value' => strval( $calendar_begins_nth ), |
|
267 | + 'value' => strval($calendar_begins_nth), |
|
268 | 268 | 'attributes' => array( |
269 | 269 | 'min' => '1', |
270 | 270 | ), |
@@ -272,97 +272,97 @@ discard block |
||
272 | 272 | 'simcal-field-inline', |
273 | 273 | 'simcal-field-tiny', |
274 | 274 | ), |
275 | - 'style' => ! $calendar_begins_nth_show ? array( 'display' => 'none' ) : '', |
|
276 | - ) ); |
|
275 | + 'style' => ! $calendar_begins_nth_show ? array('display' => 'none') : '', |
|
276 | + )); |
|
277 | 277 | |
278 | 278 | ?> |
279 | 279 | <select name="_calendar_begins" |
280 | 280 | id="_calendar_begins" |
281 | 281 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
282 | - <optgroup label="<?php _e( 'Days range', 'google-calendar-events' ); ?>"> |
|
282 | + <optgroup label="<?php _e('Days range', 'google-calendar-events'); ?>"> |
|
283 | 283 | <option value="today" |
284 | 284 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
285 | - <?php selected( 'today', $calendar_begins, true ); ?>><?php _e( 'Today', 'google-calendar-events' ); ?></option> |
|
285 | + <?php selected('today', $calendar_begins, true); ?>><?php _e('Today', 'google-calendar-events'); ?></option> |
|
286 | 286 | <option value="now" |
287 | 287 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
288 | - <?php selected( 'now', $calendar_begins, true ); ?>><?php _e( 'Now', 'google-calendar-events' ); ?></option> |
|
288 | + <?php selected('now', $calendar_begins, true); ?>><?php _e('Now', 'google-calendar-events'); ?></option> |
|
289 | 289 | <option value="days_before" |
290 | 290 | data-hide-field="_calendar_begins_custom_date" |
291 | - data-show-field="_calendar_begins_nth" <?php selected( 'days_before', $calendar_begins, true ); ?>><?php _e( 'Day(s) before today', 'google-calendar-events' ); ?></option> |
|
291 | + data-show-field="_calendar_begins_nth" <?php selected('days_before', $calendar_begins, true); ?>><?php _e('Day(s) before today', 'google-calendar-events'); ?></option> |
|
292 | 292 | <option value="days_after" |
293 | 293 | data-hide-field="_calendar_begins_custom_date" |
294 | - data-show-field="_calendar_begins_nth" <?php selected( 'days_after', $calendar_begins, true ); ?>><?php _e( 'Day(s) after today', 'google-calendar-events' ); ?></option> |
|
294 | + data-show-field="_calendar_begins_nth" <?php selected('days_after', $calendar_begins, true); ?>><?php _e('Day(s) after today', 'google-calendar-events'); ?></option> |
|
295 | 295 | </optgroup> |
296 | - <optgroup label="<?php _e( 'Weeks range', 'google-calendar-events' ); ?>"> |
|
296 | + <optgroup label="<?php _e('Weeks range', 'google-calendar-events'); ?>"> |
|
297 | 297 | <option value="this_week" |
298 | 298 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
299 | - <?php selected( 'this_week', $calendar_begins, true ); ?>><?php _e( 'This week', 'google-calendar-events' ); ?></option> |
|
299 | + <?php selected('this_week', $calendar_begins, true); ?>><?php _e('This week', 'google-calendar-events'); ?></option> |
|
300 | 300 | <option value="weeks_before" |
301 | 301 | data-hide-field="_calendar_begins_custom_date" |
302 | - data-show-field="_calendar_begins_nth" <?php selected( 'weeks_before', $calendar_begins, true ); ?>><?php _e( 'Week(s) before current', 'google-calendar-events' ); ?></option> |
|
302 | + data-show-field="_calendar_begins_nth" <?php selected('weeks_before', $calendar_begins, true); ?>><?php _e('Week(s) before current', 'google-calendar-events'); ?></option> |
|
303 | 303 | <option value="weeks_after" |
304 | 304 | data-hide-field="_calendar_begins_custom_date" |
305 | - data-show-field="_calendar_begins_nth" <?php selected( 'weeks_after', $calendar_begins, true ); ?>><?php _e( 'Week(s) after current', 'google-calendar-events' ); ?></option> |
|
305 | + data-show-field="_calendar_begins_nth" <?php selected('weeks_after', $calendar_begins, true); ?>><?php _e('Week(s) after current', 'google-calendar-events'); ?></option> |
|
306 | 306 | </optgroup> |
307 | - <optgroup label="<?php _e( 'Months range', 'google-calendar-events' ); ?>"> |
|
307 | + <optgroup label="<?php _e('Months range', 'google-calendar-events'); ?>"> |
|
308 | 308 | <option value="this_month" |
309 | 309 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
310 | - <?php selected( 'this_month', $calendar_begins, true ); ?>><?php _e( 'This month', 'google-calendar-events' ); ?></option> |
|
310 | + <?php selected('this_month', $calendar_begins, true); ?>><?php _e('This month', 'google-calendar-events'); ?></option> |
|
311 | 311 | <option value="months_before" |
312 | 312 | data-hide-field="_calendar_begins_custom_date" |
313 | - data-show-field="_calendar_begins_nth" <?php selected( 'months_before', $calendar_begins, true ); ?>><?php _e( 'Month(s) before current', 'google-calendar-events' ); ?></option> |
|
313 | + data-show-field="_calendar_begins_nth" <?php selected('months_before', $calendar_begins, true); ?>><?php _e('Month(s) before current', 'google-calendar-events'); ?></option> |
|
314 | 314 | <option value="months_after" |
315 | 315 | data-hide-field="_calendar_begins_custom_date" |
316 | - data-show-field="_calendar_begins_nth" <?php selected( 'months_after', $calendar_begins, true ); ?>><?php _e( 'Month(s) after current', 'google-calendar-events' ); ?></option> |
|
316 | + data-show-field="_calendar_begins_nth" <?php selected('months_after', $calendar_begins, true); ?>><?php _e('Month(s) after current', 'google-calendar-events'); ?></option> |
|
317 | 317 | </optgroup> |
318 | - <optgroup label="<?php _e( 'Years range', 'google-calendar-events' ); ?>"> |
|
318 | + <optgroup label="<?php _e('Years range', 'google-calendar-events'); ?>"> |
|
319 | 319 | <option value="this_year" |
320 | 320 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
321 | - <?php selected( 'this_year', $calendar_begins, true ); ?>><?php _e( 'This year', 'google-calendar-events' ); ?></option> |
|
321 | + <?php selected('this_year', $calendar_begins, true); ?>><?php _e('This year', 'google-calendar-events'); ?></option> |
|
322 | 322 | <option value="years_before" |
323 | - data-show-field="_calendar_begins_nth" <?php selected( 'years_before', $calendar_begins, true ); ?>><?php _e( 'Year(s) before current', 'google-calendar-events' ); ?></option> |
|
323 | + data-show-field="_calendar_begins_nth" <?php selected('years_before', $calendar_begins, true); ?>><?php _e('Year(s) before current', 'google-calendar-events'); ?></option> |
|
324 | 324 | <option value="years_after" |
325 | 325 | data-hide-field="_calendar_begins_custom_date" |
326 | - data-show-field="_calendar_begins_nth" <?php selected( 'years_after', $calendar_begins, true ); ?>><?php _e( 'Year(s) after current', 'google-calendar-events' ); ?></option> |
|
326 | + data-show-field="_calendar_begins_nth" <?php selected('years_after', $calendar_begins, true); ?>><?php _e('Year(s) after current', 'google-calendar-events'); ?></option> |
|
327 | 327 | </optgroup> |
328 | - <optgroup label="<?php _e( 'Other', 'google-calendar-events' ); ?>"> |
|
328 | + <optgroup label="<?php _e('Other', 'google-calendar-events'); ?>"> |
|
329 | 329 | <option value="custom_date" |
330 | 330 | data-hide-field="_calendar_begins_nth" |
331 | - data-show-field="_calendar_begins_custom_date" <?php selected( 'custom_date', $calendar_begins, true ); ?>><?php _e( 'Specific date', 'google-calendar-events' ); ?></option> |
|
331 | + data-show-field="_calendar_begins_custom_date" <?php selected('custom_date', $calendar_begins, true); ?>><?php _e('Specific date', 'google-calendar-events'); ?></option> |
|
332 | 332 | </optgroup> |
333 | 333 | </select> |
334 | 334 | <?php |
335 | 335 | |
336 | - simcal_print_field( array( |
|
336 | + simcal_print_field(array( |
|
337 | 337 | 'type' => 'date-picker', |
338 | 338 | 'name' => '_calendar_begins_custom_date', |
339 | 339 | 'id' => '_calendar_begins_custom_date', |
340 | - 'value' => get_post_meta( $post->ID, '_calendar_begins_custom_date', true ), |
|
340 | + 'value' => get_post_meta($post->ID, '_calendar_begins_custom_date', true), |
|
341 | 341 | 'class' => array( |
342 | 342 | 'simcal-field-inline', |
343 | 343 | ), |
344 | - 'style' => 'custom_date' != $calendar_begins ? array( 'display' => 'none' ) : '', |
|
345 | - ) ); |
|
344 | + 'style' => 'custom_date' != $calendar_begins ? array('display' => 'none') : '', |
|
345 | + )); |
|
346 | 346 | |
347 | 347 | ?> |
348 | 348 | <i class="simcal-icon-help simcal-help-tip" |
349 | - data-tip="<?php _e( 'The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events' ); ?>"></i> |
|
349 | + data-tip="<?php _e('The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events'); ?>"></i> |
|
350 | 350 | </td> |
351 | 351 | </tr> |
352 | 352 | <tr class="simcal-panel-field"> |
353 | - <th><label for="_feed_earliest_event_date"><?php _e( 'Earliest event', 'google-calendar-events' ); ?></label></th> |
|
353 | + <th><label for="_feed_earliest_event_date"><?php _e('Earliest event', 'google-calendar-events'); ?></label></th> |
|
354 | 354 | <td> |
355 | 355 | <?php |
356 | 356 | |
357 | - $earliest_event_saved = get_post_meta( $post->ID, '_feed_earliest_event_date', true ); |
|
358 | - $earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr( $earliest_event_saved ); |
|
357 | + $earliest_event_saved = get_post_meta($post->ID, '_feed_earliest_event_date', true); |
|
358 | + $earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr($earliest_event_saved); |
|
359 | 359 | |
360 | - simcal_print_field( array( |
|
360 | + simcal_print_field(array( |
|
361 | 361 | 'type' => 'standard', |
362 | 362 | 'subtype' => 'number', |
363 | 363 | 'name' => '_feed_earliest_event_date_range', |
364 | 364 | 'id' => '_feed_earliest_event_date_range', |
365 | - 'value' => strval( max( absint( get_post_meta( $post->ID, '_feed_earliest_event_date_range', true ) ), 1 ) ), |
|
365 | + 'value' => strval(max(absint(get_post_meta($post->ID, '_feed_earliest_event_date_range', true)), 1)), |
|
366 | 366 | 'attributes' => array( |
367 | 367 | 'min' => '1', |
368 | 368 | ), |
@@ -370,37 +370,37 @@ discard block |
||
370 | 370 | 'simcal-field-inline', |
371 | 371 | 'simcal-field-tiny', |
372 | 372 | ), |
373 | - 'style' => ( 'now' != $earliest_event ) && ( 'today' != $earliest_event ) ? array( 'display' => 'none' ) : '', |
|
374 | - ) ); |
|
373 | + 'style' => ('now' != $earliest_event) && ('today' != $earliest_event) ? array('display' => 'none') : '', |
|
374 | + )); |
|
375 | 375 | |
376 | 376 | ?> |
377 | 377 | <select name="_feed_earliest_event_date" |
378 | 378 | id="_feed_earliest_event_date" |
379 | 379 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
380 | - <option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Same as start date', 'google-calendar-events' ); ?></option> |
|
381 | - <option value="days_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'days_before', $earliest_event, true ); ?>><?php _e( 'Day(s) before start date', 'google-calendar-events' ); ?></option> |
|
382 | - <option value="weeks_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'weeks_before', $earliest_event, true ); ?>><?php _e( 'Week(s) before start date', 'google-calendar-events' ); ?></option> |
|
383 | - <option value="months_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'months_before', $earliest_event, true ); ?>><?php _e( 'Month(s) before start date', 'google-calendar-events' ); ?></option> |
|
384 | - <option value="years_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'years_before', $earliest_event, true ); ?>><?php _e( 'Year(s) before start date', 'google-calendar-events' ); ?></option> |
|
380 | + <option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Same as start date', 'google-calendar-events'); ?></option> |
|
381 | + <option value="days_before" data-show-field="_feed_earliest_event_date_range" <?php selected('days_before', $earliest_event, true); ?>><?php _e('Day(s) before start date', 'google-calendar-events'); ?></option> |
|
382 | + <option value="weeks_before" data-show-field="_feed_earliest_event_date_range" <?php selected('weeks_before', $earliest_event, true); ?>><?php _e('Week(s) before start date', 'google-calendar-events'); ?></option> |
|
383 | + <option value="months_before" data-show-field="_feed_earliest_event_date_range" <?php selected('months_before', $earliest_event, true); ?>><?php _e('Month(s) before start date', 'google-calendar-events'); ?></option> |
|
384 | + <option value="years_before" data-show-field="_feed_earliest_event_date_range" <?php selected('years_before', $earliest_event, true); ?>><?php _e('Year(s) before start date', 'google-calendar-events'); ?></option> |
|
385 | 385 | </select> |
386 | 386 | <i class="simcal-icon-help simcal-help-tip" |
387 | - data-tip="<?php _e( 'Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events' ); ?>"></i> |
|
387 | + data-tip="<?php _e('Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events'); ?>"></i> |
|
388 | 388 | </td> |
389 | 389 | </tr> |
390 | 390 | <tr class="simcal-panel-field"> |
391 | - <th><label for="_feed_latest_event_date"><?php _e( 'Latest event', 'google-calendar-events' ); ?></label></th> |
|
391 | + <th><label for="_feed_latest_event_date"><?php _e('Latest event', 'google-calendar-events'); ?></label></th> |
|
392 | 392 | <td> |
393 | 393 | <?php |
394 | 394 | |
395 | - $latest_event_saved = get_post_meta( $post->ID, '_feed_latest_event_date', true ); |
|
396 | - $latest_event = false == $latest_event_saved ? 'years_after' : esc_attr( $latest_event_saved ); |
|
395 | + $latest_event_saved = get_post_meta($post->ID, '_feed_latest_event_date', true); |
|
396 | + $latest_event = false == $latest_event_saved ? 'years_after' : esc_attr($latest_event_saved); |
|
397 | 397 | |
398 | - simcal_print_field( array( |
|
398 | + simcal_print_field(array( |
|
399 | 399 | 'type' => 'standard', |
400 | 400 | 'subtype' => 'number', |
401 | 401 | 'name' => '_feed_latest_event_date_range', |
402 | 402 | 'id' => '_feed_latest_event_date_range', |
403 | - 'value' => strval( max( absint( get_post_meta( $post->ID, '_feed_latest_event_date_range', true ) ), 1 ) ), |
|
403 | + 'value' => strval(max(absint(get_post_meta($post->ID, '_feed_latest_event_date_range', true)), 1)), |
|
404 | 404 | 'attributes' => array( |
405 | 405 | 'min' => '1', |
406 | 406 | ), |
@@ -408,21 +408,21 @@ discard block |
||
408 | 408 | 'simcal-field-inline', |
409 | 409 | 'simcal-field-tiny', |
410 | 410 | ), |
411 | - 'style' => 'indefinite' != $latest_event ? array( 'display' => 'none' ) : '', |
|
412 | - ) ); |
|
411 | + 'style' => 'indefinite' != $latest_event ? array('display' => 'none') : '', |
|
412 | + )); |
|
413 | 413 | |
414 | 414 | ?> |
415 | 415 | <select name="_feed_latest_event_date" |
416 | 416 | id="_feed_latest_event_date" |
417 | 417 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
418 | - <option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Day end of start date', 'google-calendar-events' ); ?></option> |
|
419 | - <option value="days_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'days_after', $latest_event, true ); ?>><?php _e( 'Day(s) after start date', 'google-calendar-events' ); ?></option> |
|
420 | - <option value="weeks_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'weeks_after', $latest_event, true ); ?>><?php _e( 'Weeks(s) after start date', 'google-calendar-events' ); ?></option> |
|
421 | - <option value="months_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'months_after', $latest_event, true ); ?>><?php _e( 'Month(s) after start date', 'google-calendar-events' ); ?></option> |
|
422 | - <option value="years_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'years_after', $latest_event, true ); ?>><?php _e( 'Year(s) after start date', 'google-calendar-events' ); ?></option> |
|
418 | + <option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Day end of start date', 'google-calendar-events'); ?></option> |
|
419 | + <option value="days_after" data-show-field="_feed_latest_event_date_range" <?php selected('days_after', $latest_event, true); ?>><?php _e('Day(s) after start date', 'google-calendar-events'); ?></option> |
|
420 | + <option value="weeks_after" data-show-field="_feed_latest_event_date_range" <?php selected('weeks_after', $latest_event, true); ?>><?php _e('Weeks(s) after start date', 'google-calendar-events'); ?></option> |
|
421 | + <option value="months_after" data-show-field="_feed_latest_event_date_range" <?php selected('months_after', $latest_event, true); ?>><?php _e('Month(s) after start date', 'google-calendar-events'); ?></option> |
|
422 | + <option value="years_after" data-show-field="_feed_latest_event_date_range" <?php selected('years_after', $latest_event, true); ?>><?php _e('Year(s) after start date', 'google-calendar-events'); ?></option> |
|
423 | 423 | </select> |
424 | 424 | <i class="simcal-icon-help simcal-help-tip" |
425 | - data-tip="<?php _e( 'Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events' ); ?>"></i> |
|
425 | + data-tip="<?php _e('Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events'); ?>"></i> |
|
426 | 426 | </td> |
427 | 427 | </tr> |
428 | 428 | </tbody> |
@@ -439,68 +439,68 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @param \WP_Post $post |
441 | 441 | */ |
442 | - private static function calendar_settings_panel( $post ) { |
|
442 | + private static function calendar_settings_panel($post) { |
|
443 | 443 | |
444 | 444 | ?> |
445 | 445 | <table> |
446 | 446 | <thead> |
447 | - <tr><th colspan="2"><?php _e( 'Miscellaneous', 'google-calendar-events' ); ?></th></tr> |
|
447 | + <tr><th colspan="2"><?php _e('Miscellaneous', 'google-calendar-events'); ?></th></tr> |
|
448 | 448 | </thead> |
449 | 449 | <tbody class="simcal-panel-section"> |
450 | 450 | <tr class="simcal-panel-field"> |
451 | - <th><label for="_calendar_is_static"><?php _e( 'Static calendar', 'google-calendar-events' ); ?></label></th> |
|
451 | + <th><label for="_calendar_is_static"><?php _e('Static calendar', 'google-calendar-events'); ?></label></th> |
|
452 | 452 | <td> |
453 | 453 | <?php |
454 | 454 | |
455 | - $fixed = get_post_meta( $post->ID, '_calendar_is_static', true ); |
|
455 | + $fixed = get_post_meta($post->ID, '_calendar_is_static', true); |
|
456 | 456 | |
457 | - simcal_print_field( array( |
|
457 | + simcal_print_field(array( |
|
458 | 458 | 'type' => 'checkbox', |
459 | 459 | 'name' => '_calendar_is_static', |
460 | 460 | 'id' => '_calendar_is_static', |
461 | - 'tooltip' => __( 'Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events' ), |
|
461 | + 'tooltip' => __('Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events'), |
|
462 | 462 | 'value' => 'yes' == $fixed ? 'yes' : 'no', |
463 | - ) ); |
|
463 | + )); |
|
464 | 464 | |
465 | 465 | ?> |
466 | 466 | </td> |
467 | 467 | </tr> |
468 | 468 | <tr class="simcal-panel-field"> |
469 | - <th><label for="_no_events_message"><?php _e( 'No events message', 'google-calendar-events' ); ?></label></th> |
|
469 | + <th><label for="_no_events_message"><?php _e('No events message', 'google-calendar-events'); ?></label></th> |
|
470 | 470 | <td> |
471 | 471 | <?php |
472 | 472 | |
473 | - simcal_print_field( array( |
|
473 | + simcal_print_field(array( |
|
474 | 474 | 'type' => 'textarea', |
475 | 475 | 'name' => '_no_events_message', |
476 | 476 | 'id' => '_no_events_message', |
477 | - 'tooltip' => __( 'Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events' ), |
|
478 | - 'value' => get_post_meta( $post->ID, '_no_events_message', true ), |
|
479 | - ) ); |
|
477 | + 'tooltip' => __('Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events'), |
|
478 | + 'value' => get_post_meta($post->ID, '_no_events_message', true), |
|
479 | + )); |
|
480 | 480 | |
481 | 481 | ?> |
482 | 482 | </td> |
483 | 483 | </tr> |
484 | 484 | <tr class="simcal-panel-field"> |
485 | - <th><label for="_event_formatting"><?php _e( 'Event Formatting', 'google-calendar-events' ); ?></label></th> |
|
485 | + <th><label for="_event_formatting"><?php _e('Event Formatting', 'google-calendar-events'); ?></label></th> |
|
486 | 486 | <td> |
487 | 487 | <?php |
488 | 488 | |
489 | - $event_formatting = get_post_meta( $post->ID, '_event_formatting', true ); |
|
489 | + $event_formatting = get_post_meta($post->ID, '_event_formatting', true); |
|
490 | 490 | |
491 | - simcal_print_field( array( |
|
491 | + simcal_print_field(array( |
|
492 | 492 | 'type' => 'select', |
493 | 493 | 'name' => '_event_formatting', |
494 | 494 | 'id' => '_event_formatting', |
495 | - 'tooltip' => __( 'How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events' ), |
|
495 | + 'tooltip' => __('How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events'), |
|
496 | 496 | 'value' => $event_formatting, |
497 | 497 | 'default' => 'preserve_linebreaks', |
498 | 498 | 'options' => array( |
499 | - 'preserve_linebreaks' => __( 'Preserve line breaks, auto paragraphs (default)', 'google-calendar-events' ), |
|
500 | - 'no_linebreaks' => __( 'No line breaks, auto paragraphs', 'google-calendar-events' ), |
|
501 | - 'none' => __( 'No line breaks, no auto paragraphs', 'google-calendar-events' ), |
|
499 | + 'preserve_linebreaks' => __('Preserve line breaks, auto paragraphs (default)', 'google-calendar-events'), |
|
500 | + 'no_linebreaks' => __('No line breaks, auto paragraphs', 'google-calendar-events'), |
|
501 | + 'none' => __('No line breaks, no auto paragraphs', 'google-calendar-events'), |
|
502 | 502 | ), |
503 | - ) ); |
|
503 | + )); |
|
504 | 504 | |
505 | 505 | ?> |
506 | 506 | </td> |
@@ -519,23 +519,23 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @param \WP_Post $post |
521 | 521 | */ |
522 | - private static function advanced_settings_panel( $post ) { |
|
522 | + private static function advanced_settings_panel($post) { |
|
523 | 523 | |
524 | 524 | ?> |
525 | 525 | <table> |
526 | 526 | <thead> |
527 | - <tr><th colspan="2"><?php _e( 'Date and Time', 'google-calendar-events' ); ?></th></tr> |
|
527 | + <tr><th colspan="2"><?php _e('Date and Time', 'google-calendar-events'); ?></th></tr> |
|
528 | 528 | </thead> |
529 | 529 | <tbody class="simcal-panel-section simcal-panel-datetime-formatting"> |
530 | 530 | <tr class="simcal-panel-field"> |
531 | - <th><label for="_calendar_timezone_setting"><?php _e( 'Timezone', 'google-calendar-events' ); ?></label></th> |
|
531 | + <th><label for="_calendar_timezone_setting"><?php _e('Timezone', 'google-calendar-events'); ?></label></th> |
|
532 | 532 | <td> |
533 | 533 | <?php |
534 | 534 | |
535 | 535 | $timezone_wordpress = simcal_get_wp_timezone(); |
536 | 536 | $timezone_default = $timezone_wordpress ? $timezone_wordpress : 'UTC'; |
537 | - $timezone_setting = esc_attr( get_post_meta( $post->ID, '_feed_timezone_setting', true ) ); |
|
538 | - $timezone = esc_attr( get_post_meta( $post->ID, '_feed_timezone', true ) ); |
|
537 | + $timezone_setting = esc_attr(get_post_meta($post->ID, '_feed_timezone_setting', true)); |
|
538 | + $timezone = esc_attr(get_post_meta($post->ID, '_feed_timezone', true)); |
|
539 | 539 | $timezone = $timezone ? $timezone : $timezone_default; |
540 | 540 | |
541 | 541 | ?> |
@@ -543,51 +543,51 @@ discard block |
||
543 | 543 | id="_feed_timezone_setting" |
544 | 544 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next" |
545 | 545 | data-show-next-if-value="use_custom"> |
546 | - <option value="use_calendar" <?php selected( 'use_calendar', $timezone_setting, true ); ?>><?php _ex( 'Events source default', 'Use the calendar default setting', 'google-calendar-events' ); ?></option> |
|
547 | - <option value="use_site" <?php selected( 'use_site', $timezone_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', $timezone_default ); ?></option> |
|
548 | - <option value="use_custom" <?php selected( 'use_custom', $timezone_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
546 | + <option value="use_calendar" <?php selected('use_calendar', $timezone_setting, true); ?>><?php _ex('Events source default', 'Use the calendar default setting', 'google-calendar-events'); ?></option> |
|
547 | + <option value="use_site" <?php selected('use_site', $timezone_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', $timezone_default); ?></option> |
|
548 | + <option value="use_custom" <?php selected('use_custom', $timezone_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
549 | 549 | </select> |
550 | 550 | <select name="_feed_timezone" |
551 | 551 | id="_feed_timezone" |
552 | 552 | class="simcal-field simcal-field-select simcal-field-inline" |
553 | 553 | <?php echo 'use_custom' != $timezone_setting ? 'style="display: none;"' : ''; ?>> |
554 | - <?php echo wp_timezone_choice( $timezone ); ?> |
|
554 | + <?php echo wp_timezone_choice($timezone); ?> |
|
555 | 555 | </select> |
556 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Using a different timezone may alter the date and time display of your calendar events. It is recommended to keep the calendar default timezone.', 'google-calendar-events' ); ?>"></i> |
|
556 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Using a different timezone may alter the date and time display of your calendar events. It is recommended to keep the calendar default timezone.', 'google-calendar-events'); ?>"></i> |
|
557 | 557 | </td> |
558 | 558 | </tr> |
559 | 559 | <tr class="simcal-panel-field"> |
560 | - <th><label for="_calendar_date_format_setting"><?php _e( 'Date format', 'google-calendar-events' ); ?></label></th> |
|
560 | + <th><label for="_calendar_date_format_setting"><?php _e('Date format', 'google-calendar-events'); ?></label></th> |
|
561 | 561 | <td> |
562 | 562 | <?php |
563 | 563 | |
564 | - $date_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_setting', true ) ); |
|
565 | - $date_format_default = esc_attr( get_option( 'date_format' ) ); |
|
566 | - $date_format = esc_attr( get_post_meta( $post->ID, '_calendar_date_format', true ) ); |
|
567 | - $date_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_php', true ) ); |
|
564 | + $date_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_date_format_setting', true)); |
|
565 | + $date_format_default = esc_attr(get_option('date_format')); |
|
566 | + $date_format = esc_attr(get_post_meta($post->ID, '_calendar_date_format', true)); |
|
567 | + $date_format_php = esc_attr(get_post_meta($post->ID, '_calendar_date_format_php', true)); |
|
568 | 568 | $date_format_php = $date_format_php ? $date_format_php : $date_format_default; |
569 | 569 | |
570 | 570 | ?> |
571 | 571 | <select name="_calendar_date_format_setting" |
572 | 572 | id="_calendar_date_format_setting" |
573 | 573 | class="simcal-field simcal-field-select simcal-field-show-other"> |
574 | - <option value="use_site" data-show-field="_calendar_date_format_default" <?php selected( 'use_site', $date_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option> |
|
575 | - <option value="use_custom" data-show-field="_calendar_date_format" <?php selected( 'use_custom', $date_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
576 | - <option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected( 'use_custom_php', $date_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option> |
|
574 | + <option value="use_site" data-show-field="_calendar_date_format_default" <?php selected('use_site', $date_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option> |
|
575 | + <option value="use_custom" data-show-field="_calendar_date_format" <?php selected('use_custom', $date_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
576 | + <option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected('use_custom_php', $date_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option> |
|
577 | 577 | </select> |
578 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i> |
|
578 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i> |
|
579 | 579 | <p id="_calendar_date_format_default" style="<?php echo $date_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
580 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
581 | - <code><?php echo date_i18n( $date_format_default, time() ); ?></code> |
|
580 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
581 | + <code><?php echo date_i18n($date_format_default, time()); ?></code> |
|
582 | 582 | </p> |
583 | - <?php simcal_print_field( array( |
|
583 | + <?php simcal_print_field(array( |
|
584 | 584 | 'type' => 'datetime-format', |
585 | 585 | 'subtype' => 'date', |
586 | 586 | 'name' => '_calendar_date_format', |
587 | 587 | 'id' => '_calendar_date_format', |
588 | 588 | 'value' => $date_format, |
589 | - 'style' => $date_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
590 | - ) ); ?> |
|
589 | + 'style' => $date_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
590 | + )); ?> |
|
591 | 591 | <div class="simcal-field-datetime-format-php" id="_calendar_date_format_php_field" style="<?php echo $date_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
592 | 592 | <br> |
593 | 593 | <label for="_calendar_date_format_php"> |
@@ -596,70 +596,70 @@ discard block |
||
596 | 596 | id="_calendar_date_format_php" |
597 | 597 | class="simcal-field simcal-field-text simcal-field-small" |
598 | 598 | value="<?php echo $date_format_php; ?>" /> |
599 | - <?php printf( __( 'Enter a date format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?> |
|
599 | + <?php printf(__('Enter a date format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> |
|
600 | 600 | </label> |
601 | 601 | <p> |
602 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
603 | - <code><?php echo date_i18n( $date_format_php, time() ); ?></code> |
|
602 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
603 | + <code><?php echo date_i18n($date_format_php, time()); ?></code> |
|
604 | 604 | </p> |
605 | 605 | </div> |
606 | 606 | </td> |
607 | 607 | </tr> |
608 | 608 | <tr class="simcal-panel-field"> |
609 | - <th><label for="_calendar_datetime_separator"><?php _e( 'Separator', 'google-calendar-events' ); ?></label></th> |
|
609 | + <th><label for="_calendar_datetime_separator"><?php _e('Separator', 'google-calendar-events'); ?></label></th> |
|
610 | 610 | <td> |
611 | 611 | <?php |
612 | 612 | |
613 | - $separator = get_post_meta( $post->ID, '_calendar_datetime_separator', true ); |
|
613 | + $separator = get_post_meta($post->ID, '_calendar_datetime_separator', true); |
|
614 | 614 | $separator = false == $separator ? '@' : $separator; |
615 | 615 | |
616 | - simcal_print_field( array( |
|
616 | + simcal_print_field(array( |
|
617 | 617 | 'type' => 'standard', |
618 | 618 | 'subtype' => 'text', |
619 | 619 | 'name' => '_calendar_datetime_separator', |
620 | 620 | 'id' => '_calendar_datetime_separator', |
621 | 621 | 'value' => $separator, |
622 | - 'tooltip' => __( 'Used to divide date and time when both are shown.', 'google-calendar-events' ), |
|
622 | + 'tooltip' => __('Used to divide date and time when both are shown.', 'google-calendar-events'), |
|
623 | 623 | 'class' => array( |
624 | 624 | 'simcal-field-tiny', |
625 | 625 | ), |
626 | - ) ); |
|
626 | + )); |
|
627 | 627 | |
628 | 628 | ?> |
629 | 629 | </td> |
630 | 630 | </tr> |
631 | 631 | <tr class="simcal-panel-field"> |
632 | - <th><label for="_calendar_time_format_setting"><?php _e( 'Time format', 'google-calendar-events' ); ?></label></th> |
|
632 | + <th><label for="_calendar_time_format_setting"><?php _e('Time format', 'google-calendar-events'); ?></label></th> |
|
633 | 633 | <td> |
634 | 634 | <?php |
635 | 635 | |
636 | - $time_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_setting', true ) ); |
|
637 | - $time_format_default = esc_attr( get_option( 'time_format' ) ); |
|
638 | - $time_format = esc_attr( get_post_meta( $post->ID, '_calendar_time_format', true ) ); |
|
639 | - $time_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_php', true ) ); |
|
636 | + $time_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_time_format_setting', true)); |
|
637 | + $time_format_default = esc_attr(get_option('time_format')); |
|
638 | + $time_format = esc_attr(get_post_meta($post->ID, '_calendar_time_format', true)); |
|
639 | + $time_format_php = esc_attr(get_post_meta($post->ID, '_calendar_time_format_php', true)); |
|
640 | 640 | $time_format_php = $time_format_php ? $time_format_php : $time_format_default; |
641 | 641 | |
642 | 642 | ?> |
643 | 643 | <select name="_calendar_time_format_setting" |
644 | 644 | id="_calendar_time_format_setting" |
645 | 645 | class="simcal-field simcal-field-select simcal-field-show-other"> |
646 | - <option value="use_site" data-show-field="_calendar_time_format_default" <?php selected( 'use_site', $time_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option> |
|
647 | - <option value="use_custom" data-show-field="_calendar_time_format" <?php selected( 'use_custom', $time_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
648 | - <option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected( 'use_custom_php', $time_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option> |
|
646 | + <option value="use_site" data-show-field="_calendar_time_format_default" <?php selected('use_site', $time_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option> |
|
647 | + <option value="use_custom" data-show-field="_calendar_time_format" <?php selected('use_custom', $time_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
648 | + <option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected('use_custom_php', $time_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option> |
|
649 | 649 | </select> |
650 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i> |
|
650 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i> |
|
651 | 651 | <p id="_calendar_time_format_default" style="<?php echo $time_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
652 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
653 | - <code><?php echo date_i18n( $time_format_default, time() ); ?></code> |
|
652 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
653 | + <code><?php echo date_i18n($time_format_default, time()); ?></code> |
|
654 | 654 | </p> |
655 | - <?php simcal_print_field( array( |
|
655 | + <?php simcal_print_field(array( |
|
656 | 656 | 'type' => 'datetime-format', |
657 | 657 | 'subtype' => 'time', |
658 | 658 | 'name' => '_calendar_time_format', |
659 | 659 | 'id' => '_calendar_time_format', |
660 | 660 | 'value' => $time_format, |
661 | - 'style' => $time_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
662 | - ) ); ?> |
|
661 | + 'style' => $time_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
662 | + )); ?> |
|
663 | 663 | <div class="simcal-field-datetime-format-php" id="_calendar_time_format_php_field" style="<?php echo $time_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
664 | 664 | <br> |
665 | 665 | <label for="_calendar_date_format_php"> |
@@ -668,24 +668,24 @@ discard block |
||
668 | 668 | id="_calendar_time_format_php" |
669 | 669 | class="simcal-field simcal-field-text simcal-field-small" |
670 | 670 | value="<?php echo $time_format_php; ?>"/> |
671 | - <?php printf( __( 'Enter a time format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?> |
|
671 | + <?php printf(__('Enter a time format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> |
|
672 | 672 | </label> |
673 | 673 | <p> |
674 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
675 | - <code><?php echo date_i18n( $time_format_php, time() ); ?></code> |
|
674 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
675 | + <code><?php echo date_i18n($time_format_php, time()); ?></code> |
|
676 | 676 | </p> |
677 | 677 | </div> |
678 | 678 | </td> |
679 | 679 | </tr> |
680 | 680 | <tr class="simcal-panel-field"> |
681 | - <th><label for="_calendar_week_starts_on_setting"><?php _e( 'Week starts on', 'google-calendar-events' ); ?></label></th> |
|
681 | + <th><label for="_calendar_week_starts_on_setting"><?php _e('Week starts on', 'google-calendar-events'); ?></label></th> |
|
682 | 682 | <td> |
683 | 683 | <?php |
684 | 684 | |
685 | - $week_starts_setting = esc_attr( get_post_meta( $post->ID, '_calendar_week_starts_on_setting', true ) ); |
|
686 | - $week_starts_default = esc_attr( get_option( 'start_of_week' ) ); |
|
687 | - $week_starts = intval( get_post_meta( $post->ID, '_calendar_week_starts_on', true ) ); |
|
688 | - $week_starts = is_numeric( $week_starts ) ? strval( $week_starts ) : $week_starts_default; |
|
685 | + $week_starts_setting = esc_attr(get_post_meta($post->ID, '_calendar_week_starts_on_setting', true)); |
|
686 | + $week_starts_default = esc_attr(get_option('start_of_week')); |
|
687 | + $week_starts = intval(get_post_meta($post->ID, '_calendar_week_starts_on', true)); |
|
688 | + $week_starts = is_numeric($week_starts) ? strval($week_starts) : $week_starts_default; |
|
689 | 689 | |
690 | 690 | ?> |
691 | 691 | <select |
@@ -693,39 +693,39 @@ discard block |
||
693 | 693 | id="_calendar_week_starts_on_setting" |
694 | 694 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next" |
695 | 695 | data-show-next-if-value="use_custom"> |
696 | - <option value="use_site" <?php selected( 'use_site', $week_starts_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', date_i18n( 'l', strtotime( "Sunday + $week_starts_default Days" ) ) ); ?></option> |
|
697 | - <option value="use_custom" <?php selected( 'use_custom', $week_starts_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
696 | + <option value="use_site" <?php selected('use_site', $week_starts_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', date_i18n('l', strtotime("Sunday + $week_starts_default Days"))); ?></option> |
|
697 | + <option value="use_custom" <?php selected('use_custom', $week_starts_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
698 | 698 | </select> |
699 | 699 | <select |
700 | 700 | name="_calendar_week_starts_on" |
701 | 701 | id="_calendar_week_starts_on" |
702 | 702 | class="simcal-field simcal-field-select simcal-field-inline" |
703 | 703 | <?php echo 'use_custom' != $week_starts_setting ? 'style="display: none;"' : ''; ?>> |
704 | - <?php $day_names = simcal_get_calendar_names_i18n( 'day', 'full' ); ?> |
|
705 | - <?php for ( $i = 0; $i <= 6; $i++ ) : ?> |
|
706 | - <option value="<?php echo $i; ?>" <?php selected( $i, $week_starts, true ); ?>><?php echo $day_names[ $i ]; ?></option> |
|
704 | + <?php $day_names = simcal_get_calendar_names_i18n('day', 'full'); ?> |
|
705 | + <?php for ($i = 0; $i <= 6; $i++) : ?> |
|
706 | + <option value="<?php echo $i; ?>" <?php selected($i, $week_starts, true); ?>><?php echo $day_names[$i]; ?></option> |
|
707 | 707 | <?php endfor; ?> |
708 | 708 | </select> |
709 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events' ); ?>"></i> |
|
709 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events'); ?>"></i> |
|
710 | 710 | </td> |
711 | 711 | </tr> |
712 | 712 | </tbody> |
713 | 713 | </table> |
714 | 714 | <table> |
715 | 715 | <thead> |
716 | - <tr><th colspan="2"><?php _e( 'Cache', 'google-calendar-events' ); ?></th></tr> |
|
716 | + <tr><th colspan="2"><?php _e('Cache', 'google-calendar-events'); ?></th></tr> |
|
717 | 717 | </thead> |
718 | 718 | <tbody class="simcal-panel-section simcal-panel-section-cache"> |
719 | 719 | <?php |
720 | 720 | |
721 | - $cache_freq = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_amount', true ) ); |
|
722 | - $cache_unit = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_unit', true ) ); |
|
723 | - $cache_freq = is_int( $cache_freq ) && $cache_freq >= 0 ? $cache_freq : '2'; |
|
721 | + $cache_freq = esc_attr(get_post_meta($post->ID, '_feed_cache_user_amount', true)); |
|
722 | + $cache_unit = esc_attr(get_post_meta($post->ID, '_feed_cache_user_unit', true)); |
|
723 | + $cache_freq = is_int($cache_freq) && $cache_freq >= 0 ? $cache_freq : '2'; |
|
724 | 724 | $cache_unit = $cache_unit ? $cache_unit : '3600'; |
725 | 725 | |
726 | 726 | ?> |
727 | 727 | <tr class="simcal-panel-field"> |
728 | - <th><label for="_feed_cache_user_amount"><?php _ex( 'Refresh interval', 'Cache maximum interval', 'google-calendar-events' ); ?></label></th> |
|
728 | + <th><label for="_feed_cache_user_amount"><?php _ex('Refresh interval', 'Cache maximum interval', 'google-calendar-events'); ?></label></th> |
|
729 | 729 | <td> |
730 | 730 | <input type="number" |
731 | 731 | name="_feed_cache_user_amount" |
@@ -736,12 +736,12 @@ discard block |
||
736 | 736 | <select name="_feed_cache_user_unit" |
737 | 737 | id="_feed_cache_user_unit" |
738 | 738 | class="simcal-field simcalfield-select simcal-field-inline"> |
739 | - <option value="60" <?php selected( '60', $cache_unit, true ); ?>><?php _e( 'Minute(s)', 'google-calendar-events' ); ?></option> |
|
740 | - <option value="3600" <?php selected( '3600', $cache_unit, true ); ?>><?php _e( 'Hour(s)', 'google-calendar-events' ); ?></option> |
|
741 | - <option value="86400" <?php selected( '86400', $cache_unit, true ); ?>><?php _e( 'Day(s)', 'google-calendar-events' ); ?></option> |
|
742 | - <option value="604800" <?php selected( '604800', $cache_unit, true ); ?>><?php _e( 'Week(s)', 'google-calendar-events' ); ?></option> |
|
739 | + <option value="60" <?php selected('60', $cache_unit, true); ?>><?php _e('Minute(s)', 'google-calendar-events'); ?></option> |
|
740 | + <option value="3600" <?php selected('3600', $cache_unit, true); ?>><?php _e('Hour(s)', 'google-calendar-events'); ?></option> |
|
741 | + <option value="86400" <?php selected('86400', $cache_unit, true); ?>><?php _e('Day(s)', 'google-calendar-events'); ?></option> |
|
742 | + <option value="604800" <?php selected('604800', $cache_unit, true); ?>><?php _e('Week(s)', 'google-calendar-events'); ?></option> |
|
743 | 743 | </select> |
744 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events' ); ?>"></i> |
|
744 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events'); ?>"></i> |
|
745 | 745 | </td> |
746 | 746 | </tr> |
747 | 747 | </tbody> |
@@ -760,21 +760,21 @@ discard block |
||
760 | 760 | * |
761 | 761 | * @return void |
762 | 762 | */ |
763 | - public static function print_panel_fields( $array, $post_id ) { |
|
763 | + public static function print_panel_fields($array, $post_id) { |
|
764 | 764 | |
765 | - foreach ( $array as $section => $fields ) : |
|
765 | + foreach ($array as $section => $fields) : |
|
766 | 766 | |
767 | - if ( $fields && is_array( $fields ) ) : |
|
767 | + if ($fields && is_array($fields)) : |
|
768 | 768 | |
769 | 769 | ?> |
770 | - <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr( $section ); ?>"> |
|
771 | - <?php foreach ( $fields as $key => $field ) : |
|
770 | + <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr($section); ?>"> |
|
771 | + <?php foreach ($fields as $key => $field) : |
|
772 | 772 | |
773 | - $value = get_post_meta( $post_id, $key, true ); |
|
774 | - $field['value'] = $value ? $value : ( isset( $field['default'] ) ? $field['default'] : '' ); |
|
775 | - $the_field = simcal_get_field( $field ); ?> |
|
773 | + $value = get_post_meta($post_id, $key, true); |
|
774 | + $field['value'] = $value ? $value : (isset($field['default']) ? $field['default'] : ''); |
|
775 | + $the_field = simcal_get_field($field); ?> |
|
776 | 776 | |
777 | - <?php if ( $the_field instanceof Field ) : ?> |
|
777 | + <?php if ($the_field instanceof Field) : ?> |
|
778 | 778 | <tr class="simcal-panel-field"> |
779 | 779 | <th><label for="<?php echo $the_field->id ?>"><?php echo $the_field->title; ?></label></th> |
780 | 780 | <td><?php $the_field->html(); ?></td> |
@@ -801,30 +801,30 @@ discard block |
||
801 | 801 | * |
802 | 802 | * @return void |
803 | 803 | */ |
804 | - public static function save( $post_id, $post ) { |
|
804 | + public static function save($post_id, $post) { |
|
805 | 805 | |
806 | 806 | /* ====================== * |
807 | 807 | * Calendar type and view * |
808 | 808 | * ====================== */ |
809 | 809 | |
810 | 810 | // Unlink existing terms for feed type and calendar type. |
811 | - wp_delete_object_term_relationships( $post_id, array( |
|
811 | + wp_delete_object_term_relationships($post_id, array( |
|
812 | 812 | 'calendar_feed', |
813 | 813 | 'calendar_type', |
814 | - ) ); |
|
814 | + )); |
|
815 | 815 | |
816 | 816 | // Set the feed type as term. |
817 | - $feed_type = isset( $_POST['_feed_type'] ) ? sanitize_title( stripslashes( $_POST['_feed_type'] ) ) : apply_filters( 'simcal_default_feed_type', 'google' ); |
|
818 | - wp_set_object_terms( $post_id, $feed_type, 'calendar_feed' ); |
|
817 | + $feed_type = isset($_POST['_feed_type']) ? sanitize_title(stripslashes($_POST['_feed_type'])) : apply_filters('simcal_default_feed_type', 'google'); |
|
818 | + wp_set_object_terms($post_id, $feed_type, 'calendar_feed'); |
|
819 | 819 | |
820 | 820 | // Set the calendar type as a term. |
821 | - $calendar_type = isset( $_POST['_calendar_type'] ) ? sanitize_title( stripslashes( $_POST['_calendar_type'] ) ) : apply_filters( 'simcal_default_calendar_type', 'default-calendar' ); |
|
822 | - wp_set_object_terms( $post_id, $calendar_type, 'calendar_type' ); |
|
821 | + $calendar_type = isset($_POST['_calendar_type']) ? sanitize_title(stripslashes($_POST['_calendar_type'])) : apply_filters('simcal_default_calendar_type', 'default-calendar'); |
|
822 | + wp_set_object_terms($post_id, $calendar_type, 'calendar_type'); |
|
823 | 823 | // Set the calendar type view as post meta. |
824 | - $calendar_view = isset( $_POST['_calendar_view'] ) ? $_POST['_calendar_view'] : ''; |
|
825 | - if ( $calendar_view && is_array( $calendar_view ) ) { |
|
826 | - $views = array_map( 'sanitize_title', $calendar_view ); |
|
827 | - update_post_meta( $post_id, '_calendar_view', $views ); |
|
824 | + $calendar_view = isset($_POST['_calendar_view']) ? $_POST['_calendar_view'] : ''; |
|
825 | + if ($calendar_view && is_array($calendar_view)) { |
|
826 | + $views = array_map('sanitize_title', $calendar_view); |
|
827 | + update_post_meta($post_id, '_calendar_view', $views); |
|
828 | 828 | } |
829 | 829 | |
830 | 830 | /* ===================== * |
@@ -832,102 +832,102 @@ discard block |
||
832 | 832 | * ===================== */ |
833 | 833 | |
834 | 834 | // Calendar opening. |
835 | - $calendar_begins = isset( $_POST['_calendar_begins'] ) ? sanitize_key( $_POST['_calendar_begins'] ) : 'this_month'; |
|
836 | - update_post_meta( $post_id, '_calendar_begins', $calendar_begins ); |
|
837 | - $calendar_begins_nth = isset( $_POST['_calendar_begins_nth'] ) ? absint( $_POST['_calendar_begins_nth'] ) : 2; |
|
838 | - update_post_meta( $post_id, '_calendar_begins_nth', $calendar_begins_nth ); |
|
839 | - $calendar_begins_custom_date = isset( $_POST['_calendar_begins_custom_date'] ) ? sanitize_title( $_POST['_calendar_begins_custom_date'] ) : ''; |
|
840 | - update_post_meta( $post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date ); |
|
835 | + $calendar_begins = isset($_POST['_calendar_begins']) ? sanitize_key($_POST['_calendar_begins']) : 'this_month'; |
|
836 | + update_post_meta($post_id, '_calendar_begins', $calendar_begins); |
|
837 | + $calendar_begins_nth = isset($_POST['_calendar_begins_nth']) ? absint($_POST['_calendar_begins_nth']) : 2; |
|
838 | + update_post_meta($post_id, '_calendar_begins_nth', $calendar_begins_nth); |
|
839 | + $calendar_begins_custom_date = isset($_POST['_calendar_begins_custom_date']) ? sanitize_title($_POST['_calendar_begins_custom_date']) : ''; |
|
840 | + update_post_meta($post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date); |
|
841 | 841 | |
842 | 842 | // Feed earliest events date. |
843 | - $earliest_events = isset( $_POST['_feed_earliest_event_date'] ) ? sanitize_key( $_POST['_feed_earliest_event_date'] ) : ''; |
|
844 | - update_post_meta( $post_id, '_feed_earliest_event_date', $earliest_events ); |
|
845 | - $earliest_events_range = isset( $_POST['_feed_earliest_event_date_range'] ) ? max( absint( $_POST['_feed_earliest_event_date_range'] ), 1 ) : 1; |
|
846 | - update_post_meta( $post_id, '_feed_earliest_event_date_range', $earliest_events_range ); |
|
843 | + $earliest_events = isset($_POST['_feed_earliest_event_date']) ? sanitize_key($_POST['_feed_earliest_event_date']) : ''; |
|
844 | + update_post_meta($post_id, '_feed_earliest_event_date', $earliest_events); |
|
845 | + $earliest_events_range = isset($_POST['_feed_earliest_event_date_range']) ? max(absint($_POST['_feed_earliest_event_date_range']), 1) : 1; |
|
846 | + update_post_meta($post_id, '_feed_earliest_event_date_range', $earliest_events_range); |
|
847 | 847 | |
848 | 848 | // Feed latest events date. |
849 | - $latest_events = isset( $_POST['_feed_latest_event_date'] ) ? sanitize_key( $_POST['_feed_latest_event_date'] ) : ''; |
|
850 | - update_post_meta( $post_id, '_feed_latest_event_date', $latest_events ); |
|
851 | - $latest_events_range = isset( $_POST['_feed_latest_event_date_range'] ) ? max( absint( $_POST['_feed_latest_event_date_range'] ), 1 ) : 1; |
|
852 | - update_post_meta( $post_id, '_feed_latest_event_date_range', $latest_events_range ); |
|
849 | + $latest_events = isset($_POST['_feed_latest_event_date']) ? sanitize_key($_POST['_feed_latest_event_date']) : ''; |
|
850 | + update_post_meta($post_id, '_feed_latest_event_date', $latest_events); |
|
851 | + $latest_events_range = isset($_POST['_feed_latest_event_date_range']) ? max(absint($_POST['_feed_latest_event_date_range']), 1) : 1; |
|
852 | + update_post_meta($post_id, '_feed_latest_event_date_range', $latest_events_range); |
|
853 | 853 | |
854 | 854 | /* ======================= * |
855 | 855 | * Calendar settings panel * |
856 | 856 | * ======================= */ |
857 | 857 | |
858 | 858 | // Static calendar. |
859 | - $static = isset( $_POST['_calendar_is_static'] ) ? 'yes' : 'no'; |
|
860 | - update_post_meta( $post_id, '_calendar_is_static', $static ); |
|
859 | + $static = isset($_POST['_calendar_is_static']) ? 'yes' : 'no'; |
|
860 | + update_post_meta($post_id, '_calendar_is_static', $static); |
|
861 | 861 | |
862 | 862 | // No events message. |
863 | - $message = isset( $_POST['_no_events_message'] ) ? wp_kses_post( $_POST['_no_events_message'] ) : ''; |
|
864 | - update_post_meta( $post_id, '_no_events_message', $message ); |
|
863 | + $message = isset($_POST['_no_events_message']) ? wp_kses_post($_POST['_no_events_message']) : ''; |
|
864 | + update_post_meta($post_id, '_no_events_message', $message); |
|
865 | 865 | |
866 | 866 | // _event_formatting |
867 | - $event_formatting = isset( $_POST['_event_formatting'] ) ? sanitize_key( $_POST['_event_formatting'] ) : 'preserve_linebreaks'; |
|
868 | - update_post_meta( $post_id, '_event_formatting', $event_formatting ); |
|
867 | + $event_formatting = isset($_POST['_event_formatting']) ? sanitize_key($_POST['_event_formatting']) : 'preserve_linebreaks'; |
|
868 | + update_post_meta($post_id, '_event_formatting', $event_formatting); |
|
869 | 869 | |
870 | 870 | /* ======================= * |
871 | 871 | * Advanced settings panel * |
872 | 872 | * ======================= */ |
873 | 873 | |
874 | 874 | // Timezone. |
875 | - $feed_timezone_setting = isset( $_POST['_feed_timezone_setting'] ) ? sanitize_key( $_POST['_feed_timezone_setting'] ) : 'use_calendar'; |
|
876 | - update_post_meta( $post_id, '_feed_timezone_setting', $feed_timezone_setting ); |
|
875 | + $feed_timezone_setting = isset($_POST['_feed_timezone_setting']) ? sanitize_key($_POST['_feed_timezone_setting']) : 'use_calendar'; |
|
876 | + update_post_meta($post_id, '_feed_timezone_setting', $feed_timezone_setting); |
|
877 | 877 | $default_timezone = simcal_get_wp_timezone(); |
878 | 878 | $feed_timezone = $default_timezone ? $default_timezone : 'UTC'; |
879 | - $feed_timezone = isset( $_POST['_feed_timezone'] ) ? sanitize_text_field( $_POST['_feed_timezone'] ) : $feed_timezone; |
|
880 | - update_post_meta( $post_id, '_feed_timezone', $feed_timezone ); |
|
879 | + $feed_timezone = isset($_POST['_feed_timezone']) ? sanitize_text_field($_POST['_feed_timezone']) : $feed_timezone; |
|
880 | + update_post_meta($post_id, '_feed_timezone', $feed_timezone); |
|
881 | 881 | |
882 | 882 | // Date format. |
883 | - $date_format_setting = isset( $_POST['_calendar_date_format_setting'] ) ? sanitize_key( $_POST['_calendar_date_format_setting'] ) : 'use_site'; |
|
884 | - update_post_meta( $post_id, '_calendar_date_format_setting', $date_format_setting ); |
|
885 | - $date_format = isset( $_POST['_calendar_date_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format'] ) ) : get_option( 'date_format' ); |
|
886 | - update_post_meta( $post_id, '_calendar_date_format', $date_format ); |
|
887 | - $date_format_php = isset( $_POST['_calendar_date_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format_php'] ) ) : get_option( 'date_format' ); |
|
888 | - update_post_meta( $post_id, '_calendar_date_format_php', $date_format_php ); |
|
883 | + $date_format_setting = isset($_POST['_calendar_date_format_setting']) ? sanitize_key($_POST['_calendar_date_format_setting']) : 'use_site'; |
|
884 | + update_post_meta($post_id, '_calendar_date_format_setting', $date_format_setting); |
|
885 | + $date_format = isset($_POST['_calendar_date_format']) ? sanitize_text_field(trim($_POST['_calendar_date_format'])) : get_option('date_format'); |
|
886 | + update_post_meta($post_id, '_calendar_date_format', $date_format); |
|
887 | + $date_format_php = isset($_POST['_calendar_date_format_php']) ? sanitize_text_field(trim($_POST['_calendar_date_format_php'])) : get_option('date_format'); |
|
888 | + update_post_meta($post_id, '_calendar_date_format_php', $date_format_php); |
|
889 | 889 | |
890 | 890 | // Time format. |
891 | - $time_format_setting = isset( $_POST['_calendar_time_format_setting'] ) ? sanitize_key( $_POST['_calendar_time_format_setting'] ) : 'use_site'; |
|
892 | - update_post_meta( $post_id, '_calendar_time_format_setting', $time_format_setting ); |
|
893 | - $time_format = isset( $_POST['_calendar_time_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format'] ) ) : get_option( 'time_format' ); |
|
894 | - update_post_meta( $post_id, '_calendar_time_format', $time_format ); |
|
895 | - $time_format_php = isset( $_POST['_calendar_time_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format_php'] ) ) : get_option( 'time_format' ); |
|
896 | - update_post_meta( $post_id, '_calendar_time_format_php', $time_format_php ); |
|
891 | + $time_format_setting = isset($_POST['_calendar_time_format_setting']) ? sanitize_key($_POST['_calendar_time_format_setting']) : 'use_site'; |
|
892 | + update_post_meta($post_id, '_calendar_time_format_setting', $time_format_setting); |
|
893 | + $time_format = isset($_POST['_calendar_time_format']) ? sanitize_text_field(trim($_POST['_calendar_time_format'])) : get_option('time_format'); |
|
894 | + update_post_meta($post_id, '_calendar_time_format', $time_format); |
|
895 | + $time_format_php = isset($_POST['_calendar_time_format_php']) ? sanitize_text_field(trim($_POST['_calendar_time_format_php'])) : get_option('time_format'); |
|
896 | + update_post_meta($post_id, '_calendar_time_format_php', $time_format_php); |
|
897 | 897 | |
898 | 898 | // Date-time separator. |
899 | - $datetime_separator = isset( $_POST['_calendar_datetime_separator'] ) ? sanitize_text_field( $_POST['_calendar_datetime_separator'] ) : ' '; |
|
900 | - update_post_meta( $post_id, '_calendar_datetime_separator', $datetime_separator ); |
|
899 | + $datetime_separator = isset($_POST['_calendar_datetime_separator']) ? sanitize_text_field($_POST['_calendar_datetime_separator']) : ' '; |
|
900 | + update_post_meta($post_id, '_calendar_datetime_separator', $datetime_separator); |
|
901 | 901 | |
902 | 902 | // Week start. |
903 | - $week_start_setting = isset( $_POST['_calendar_week_starts_on_setting'] ) ? sanitize_key( $_POST['_calendar_week_starts_on_setting'] ) : 'use_site'; |
|
904 | - update_post_meta( $post_id, '_calendar_week_starts_on_setting', $week_start_setting ); |
|
905 | - $week_start = isset( $_POST['_calendar_week_starts_on'] ) ? intval( $_POST['_calendar_week_starts_on'] ) : get_option( 'start_of_week' ); |
|
906 | - update_post_meta( $post_id, '_calendar_week_starts_on', $week_start ); |
|
903 | + $week_start_setting = isset($_POST['_calendar_week_starts_on_setting']) ? sanitize_key($_POST['_calendar_week_starts_on_setting']) : 'use_site'; |
|
904 | + update_post_meta($post_id, '_calendar_week_starts_on_setting', $week_start_setting); |
|
905 | + $week_start = isset($_POST['_calendar_week_starts_on']) ? intval($_POST['_calendar_week_starts_on']) : get_option('start_of_week'); |
|
906 | + update_post_meta($post_id, '_calendar_week_starts_on', $week_start); |
|
907 | 907 | |
908 | 908 | // Cache interval. |
909 | 909 | $cache = 7200; |
910 | - if ( isset( $_POST['_feed_cache_user_amount'] ) && isset( $_POST['_feed_cache_user_unit'] ) ) { |
|
911 | - $amount = is_numeric( $_POST['_feed_cache_user_amount'] ) || $_POST['_feed_cache_user_amount'] == 0 ? absint( $_POST['_feed_cache_user_amount'] ) : 1; |
|
912 | - $unit = is_numeric( $_POST['_feed_cache_user_unit'] ) ? absint( $_POST['_feed_cache_user_unit'] ) : 3600; |
|
913 | - update_post_meta( $post_id, '_feed_cache_user_amount', $amount ); |
|
914 | - update_post_meta( $post_id, '_feed_cache_user_unit', $unit ); |
|
915 | - $cache = ( ( $amount * $unit ) > 0 ) ? $amount * $unit : 1; |
|
910 | + if (isset($_POST['_feed_cache_user_amount']) && isset($_POST['_feed_cache_user_unit'])) { |
|
911 | + $amount = is_numeric($_POST['_feed_cache_user_amount']) || $_POST['_feed_cache_user_amount'] == 0 ? absint($_POST['_feed_cache_user_amount']) : 1; |
|
912 | + $unit = is_numeric($_POST['_feed_cache_user_unit']) ? absint($_POST['_feed_cache_user_unit']) : 3600; |
|
913 | + update_post_meta($post_id, '_feed_cache_user_amount', $amount); |
|
914 | + update_post_meta($post_id, '_feed_cache_user_unit', $unit); |
|
915 | + $cache = (($amount * $unit) > 0) ? $amount * $unit : 1; |
|
916 | 916 | } |
917 | - update_post_meta( $post_id, '_feed_cache', $cache ); |
|
917 | + update_post_meta($post_id, '_feed_cache', $cache); |
|
918 | 918 | |
919 | 919 | /* ============= * |
920 | 920 | * Miscellaneous * |
921 | 921 | * ============= */ |
922 | 922 | |
923 | 923 | // Update version. |
924 | - update_post_meta( $post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION ); |
|
924 | + update_post_meta($post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION); |
|
925 | 925 | |
926 | 926 | // Action hook. |
927 | - do_action( 'simcal_process_settings_meta', $post_id ); |
|
927 | + do_action('simcal_process_settings_meta', $post_id); |
|
928 | 928 | |
929 | 929 | // Clear cache. |
930 | - simcal_delete_feed_transients( $post_id ); |
|
930 | + simcal_delete_feed_transients($post_id); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | use SimpleCalendar\Events\Event; |
14 | 14 | use SimpleCalendar\Calendars\Default_Calendar; |
15 | 15 | |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param string|Calendar $calendar |
57 | 57 | */ |
58 | - public function __construct( $calendar = '' ) { |
|
58 | + public function __construct($calendar = '') { |
|
59 | 59 | $this->calendar = $calendar; |
60 | 60 | } |
61 | 61 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return string |
90 | 90 | */ |
91 | 91 | public function get_name() { |
92 | - return __( 'Grid', 'google-calendar-events' ); |
|
92 | + return __('Grid', 'google-calendar-events'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @since 3.0.0 |
99 | 99 | */ |
100 | 100 | public function add_ajax_actions() { |
101 | - add_action( 'wp_ajax_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) ); |
|
102 | - add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) ); |
|
101 | + add_action('wp_ajax_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax')); |
|
102 | + add_action('wp_ajax_nopriv_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -113,16 +113,16 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return array |
115 | 115 | */ |
116 | - public function scripts( $min = '' ) { |
|
116 | + public function scripts($min = '') { |
|
117 | 117 | return array( |
118 | 118 | 'simcal-qtip' => array( |
119 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js', |
|
120 | - 'deps' => array( 'jquery' ), |
|
119 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js', |
|
120 | + 'deps' => array('jquery'), |
|
121 | 121 | 'ver' => '2.2.1', |
122 | 122 | 'in_footer' => true, |
123 | 123 | ), |
124 | 124 | 'simcal-default-calendar' => array( |
125 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js', |
|
125 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js', |
|
126 | 126 | 'deps' => array( |
127 | 127 | 'jquery', |
128 | 128 | 'simcal-qtip', |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return array |
149 | 149 | */ |
150 | - public function styles( $min = '' ) { |
|
150 | + public function styles($min = '') { |
|
151 | 151 | return array( |
152 | 152 | 'simcal-qtip' => array( |
153 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/vendor/qtip' . $min . '.css', |
|
153 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/vendor/qtip'.$min.'.css', |
|
154 | 154 | 'ver' => '2.2.1', |
155 | 155 | 'media' => 'all', |
156 | 156 | ), |
157 | 157 | 'simcal-default-calendar-grid' => array( |
158 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-grid' . $min . '.css', |
|
158 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-grid'.$min.'.css', |
|
159 | 159 | 'deps' => array( |
160 | 160 | 'simcal-qtip', |
161 | 161 | ), |
@@ -174,22 +174,22 @@ discard block |
||
174 | 174 | |
175 | 175 | $calendar = $this->calendar; |
176 | 176 | |
177 | - if ( $calendar instanceof Default_Calendar ) { |
|
177 | + if ($calendar instanceof Default_Calendar) { |
|
178 | 178 | |
179 | 179 | ?> |
180 | 180 | |
181 | - <?php edit_post_link( __( 'Edit Calendar', 'google-calendar-events' ), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id ); ?> |
|
181 | + <?php edit_post_link(__('Edit Calendar', 'google-calendar-events'), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id); ?> |
|
182 | 182 | |
183 | 183 | <table class="simcal-calendar-grid" |
184 | 184 | data-event-bubble-trigger="<?php echo $calendar->event_bubble_trigger; ?>"> |
185 | 185 | <thead class="simcal-calendar-head"> |
186 | 186 | <tr> |
187 | - <?php if ( ! $calendar->static ) { ?> |
|
188 | - <th class="simcal-nav simcal-prev-wrapper" colspan=colspan="<?php echo apply_filters( 'simcal_prev_cols', '1' ); ?>"> |
|
189 | - <button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e( 'Previous Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-left"></i></button> |
|
187 | + <?php if ( ! $calendar->static) { ?> |
|
188 | + <th class="simcal-nav simcal-prev-wrapper" colspan=colspan="<?php echo apply_filters('simcal_prev_cols', '1'); ?>"> |
|
189 | + <button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e('Previous Month', 'google-calendar-events'); ?>"><i class="simcal-icon-left"></i></button> |
|
190 | 190 | </th> |
191 | 191 | <?php } ?> |
192 | - <th colspan="<?php echo apply_filters( 'simcal_current_cols', $calendar->static ? '7' : '5' ); ?>" |
|
192 | + <th colspan="<?php echo apply_filters('simcal_current_cols', $calendar->static ? '7' : '5'); ?>" |
|
193 | 193 | class="simcal-nav simcal-current" |
194 | 194 | data-calendar-current="<?php echo $calendar->start; ?>"> |
195 | 195 | <?php |
@@ -198,26 +198,26 @@ discard block |
||
198 | 198 | |
199 | 199 | // Display month and year according to user date format preference. |
200 | 200 | |
201 | - $year_pos = strcspn( $calendar->date_format, 'Y y' ); |
|
202 | - $month_pos = strcspn( $calendar->date_format, 'F M m n' ); |
|
201 | + $year_pos = strcspn($calendar->date_format, 'Y y'); |
|
202 | + $month_pos = strcspn($calendar->date_format, 'F M m n'); |
|
203 | 203 | |
204 | - $current = array( 'month' => 'F', 'year' => 'Y' ); |
|
204 | + $current = array('month' => 'F', 'year' => 'Y'); |
|
205 | 205 | |
206 | - if ( $year_pos < $month_pos ) { |
|
207 | - $current = array_reverse( $current ); |
|
206 | + if ($year_pos < $month_pos) { |
|
207 | + $current = array_reverse($current); |
|
208 | 208 | } |
209 | 209 | |
210 | - foreach ( $current as $k => $v ) { |
|
211 | - echo ' <span class="simcal-current-' . $k , '">' . date_i18n( $v, $calendar->start ) . '</span> '; |
|
210 | + foreach ($current as $k => $v) { |
|
211 | + echo ' <span class="simcal-current-'.$k, '">'.date_i18n($v, $calendar->start).'</span> '; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | echo '</h3>'; |
215 | 215 | |
216 | 216 | ?> |
217 | 217 | </th> |
218 | - <?php if ( ! $calendar->static ) { ?> |
|
219 | - <th class="simcal-nav simcal-next-wrapper" colspan="<?php echo apply_filters( 'simcal_next_cols', '1' ); ?>"> |
|
220 | - <button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e( 'Next Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-right"></i></button> |
|
218 | + <?php if ( ! $calendar->static) { ?> |
|
219 | + <th class="simcal-nav simcal-next-wrapper" colspan="<?php echo apply_filters('simcal_next_cols', '1'); ?>"> |
|
220 | + <button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e('Next Month', 'google-calendar-events'); ?>"><i class="simcal-icon-right"></i></button> |
|
221 | 221 | </th> |
222 | 222 | <?php } ?> |
223 | 223 | </tr> |
@@ -227,28 +227,28 @@ discard block |
||
227 | 227 | // Print day names in short or long form for different viewport sizes. |
228 | 228 | |
229 | 229 | $week_starts = $calendar->week_starts; |
230 | - $week_days_short = simcal_get_calendar_names_i18n( 'day', 'short' ); |
|
231 | - $week_days_full = simcal_get_calendar_names_i18n( 'day', 'full' ); |
|
230 | + $week_days_short = simcal_get_calendar_names_i18n('day', 'short'); |
|
231 | + $week_days_full = simcal_get_calendar_names_i18n('day', 'full'); |
|
232 | 232 | |
233 | - for ( $i = $week_starts; $i <= 6; $i ++ ) : |
|
233 | + for ($i = $week_starts; $i <= 6; $i++) : |
|
234 | 234 | |
235 | 235 | ?> |
236 | 236 | <th class="simcal-week-day simcal-week-day-<?php echo $i ?>" |
237 | - data-screen-small="<?php echo mb_substr( $week_days_short[ $i ], 0, 1, 'UTF-8' ); ?>" |
|
238 | - data-screen-medium="<?php echo $week_days_short[ $i ]; ?>" |
|
239 | - data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th> |
|
237 | + data-screen-small="<?php echo mb_substr($week_days_short[$i], 0, 1, 'UTF-8'); ?>" |
|
238 | + data-screen-medium="<?php echo $week_days_short[$i]; ?>" |
|
239 | + data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th> |
|
240 | 240 | <?php |
241 | 241 | |
242 | 242 | endfor; |
243 | 243 | |
244 | - if ( $week_starts !== 0 ) : |
|
245 | - for ( $i = 0; $i < $week_starts; $i ++ ) : |
|
244 | + if ($week_starts !== 0) : |
|
245 | + for ($i = 0; $i < $week_starts; $i++) : |
|
246 | 246 | |
247 | 247 | ?> |
248 | 248 | <th class="simcal-week-day simcal-week-day-<?php echo $i ?>" |
249 | - data-screen-small="<?php echo mb_substr( $week_days_short[ $i ], 0, 1, 'UTF-8' ); ?>" |
|
250 | - data-screen-medium="<?php echo $week_days_short[ $i ]; ?>" |
|
251 | - data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th> |
|
249 | + data-screen-small="<?php echo mb_substr($week_days_short[$i], 0, 1, 'UTF-8'); ?>" |
|
250 | + data-screen-medium="<?php echo $week_days_short[$i]; ?>" |
|
251 | + data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th> |
|
252 | 252 | <?php |
253 | 253 | |
254 | 254 | endfor; |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | </tr> |
259 | 259 | </thead> |
260 | 260 | |
261 | - <?php echo $this->draw_month( date( 'n', $calendar->start ), date( 'Y', $calendar->start ) ); ?> |
|
261 | + <?php echo $this->draw_month(date('n', $calendar->start), date('Y', $calendar->start)); ?> |
|
262 | 262 | |
263 | 263 | </table> |
264 | 264 | |
@@ -284,82 +284,82 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return string |
286 | 286 | */ |
287 | - private function draw_month( $month, $year, $id = 0 ) { |
|
287 | + private function draw_month($month, $year, $id = 0) { |
|
288 | 288 | |
289 | 289 | $calendar = $this->calendar; |
290 | - if ( empty( $calendar ) ) { |
|
291 | - $calendar = simcal_get_calendar( intval( $id ) ); |
|
292 | - if ( ! $calendar ) { |
|
290 | + if (empty($calendar)) { |
|
291 | + $calendar = simcal_get_calendar(intval($id)); |
|
292 | + if ( ! $calendar) { |
|
293 | 293 | return ''; |
294 | 294 | } |
295 | 295 | } |
296 | - date_default_timezone_set( $calendar->timezone ); |
|
296 | + date_default_timezone_set($calendar->timezone); |
|
297 | 297 | $events = $calendar->events; |
298 | 298 | |
299 | 299 | // Variables to cycle days in current month and find today in calendar. |
300 | 300 | $now = $calendar->now; |
301 | - $current = Carbon::create( $year, $month, 1, 0, 0, 0, $calendar->timezone ); |
|
301 | + $current = Carbon::create($year, $month, 1, 0, 0, 0, $calendar->timezone); |
|
302 | 302 | $current_min = $current->getTimestamp(); |
303 | 303 | $current_max = $current->endOfDay()->getTimestamp(); |
304 | 304 | |
305 | 305 | // Calendar grid variables. |
306 | 306 | $week_starts = $calendar->week_starts; |
307 | - $week_of_year = $current->weekOfYear; // Relative count of the week number of the year. |
|
308 | - $month_starts = $current->dayOfWeek; // Day upon which the month starts. |
|
309 | - $days_in_month = $current->daysInMonth; // Number of days in the given month. |
|
307 | + $week_of_year = $current->weekOfYear; // Relative count of the week number of the year. |
|
308 | + $month_starts = $current->dayOfWeek; // Day upon which the month starts. |
|
309 | + $days_in_month = $current->daysInMonth; // Number of days in the given month. |
|
310 | 310 | |
311 | 311 | // Set current month events timestamp boundaries. |
312 | 312 | $this->start = $current_min; |
313 | 313 | $this->end = $current->endOfMonth()->timestamp; |
314 | 314 | |
315 | 315 | // Get daily events for this month. |
316 | - if ( $events && is_array( $events ) ) { |
|
316 | + if ($events && is_array($events)) { |
|
317 | 317 | |
318 | 318 | // Filter events within the boundaries previously set above. |
319 | - $timestamps = array_keys( $events ); |
|
320 | - $lower_bound = array_filter( $timestamps, array( $this, 'filter_events_before' ) ); |
|
321 | - $higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) ); |
|
322 | - $filtered = ( is_array( $events ) && is_array( $higher_bound) ) && ! empty( $events ) && ! empty( $higher_bound ) ? array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ) : array(); |
|
319 | + $timestamps = array_keys($events); |
|
320 | + $lower_bound = array_filter($timestamps, array($this, 'filter_events_before')); |
|
321 | + $higher_bound = array_filter($lower_bound, array($this, 'filter_events_after')); |
|
322 | + $filtered = (is_array($events) && is_array($higher_bound)) && ! empty($events) && ! empty($higher_bound) ? array_intersect_key($events, array_combine($higher_bound, $higher_bound)) : array(); |
|
323 | 323 | |
324 | 324 | // Put resulting events in an associative array, with day of the month as key for easy retrieval in calendar days loop. |
325 | 325 | $day_events = array(); |
326 | - foreach ( $filtered as $timestamp => $events_in_day ) { |
|
327 | - foreach ( $events_in_day as $event ) { |
|
328 | - if ( $event instanceof Event ){ |
|
329 | - $day = intval( Carbon::createFromTimestamp( $timestamp, $event->timezone )->endOfDay()->day ); |
|
330 | - $day_events[ $day ][] = $event; |
|
326 | + foreach ($filtered as $timestamp => $events_in_day) { |
|
327 | + foreach ($events_in_day as $event) { |
|
328 | + if ($event instanceof Event) { |
|
329 | + $day = intval(Carbon::createFromTimestamp($timestamp, $event->timezone)->endOfDay()->day); |
|
330 | + $day_events[$day][] = $event; |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
335 | - ksort( $day_events, SORT_NUMERIC ); |
|
335 | + ksort($day_events, SORT_NUMERIC); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | ob_start(); |
339 | 339 | |
340 | - echo '<tbody class="simcal-month simcal-month-' . $month . '">' . "\n"; |
|
341 | - echo "\t" . '<tr class="simcal-week simcal-week-' . $week_of_year . '">'; |
|
340 | + echo '<tbody class="simcal-month simcal-month-'.$month.'">'."\n"; |
|
341 | + echo "\t".'<tr class="simcal-week simcal-week-'.$week_of_year.'">'; |
|
342 | 342 | |
343 | 343 | $days_in_row = 0; |
344 | 344 | // Week may start on an arbitrary day (sun, 0 - sat, 6). |
345 | 345 | $week_day = $week_starts; |
346 | 346 | |
347 | 347 | // This fixes a possible bug when a month starts by Sunday (0). |
348 | - if ( 0 !== $week_starts ) { |
|
348 | + if (0 !== $week_starts) { |
|
349 | 349 | $b = $month_starts === 0 ? 7 : $month_starts; |
350 | 350 | } else { |
351 | 351 | $b = $month_starts; |
352 | 352 | } |
353 | 353 | |
354 | 354 | // Void days in first week. |
355 | - for ( $a = $week_starts; $a < $b; $a++ ) : |
|
355 | + for ($a = $week_starts; $a < $b; $a++) : |
|
356 | 356 | |
357 | - $last_void_day_class = ( $a === ( $b - 1 ) ) ? 'simcal-day-void-last' : ''; |
|
357 | + $last_void_day_class = ($a === ($b - 1)) ? 'simcal-day-void-last' : ''; |
|
358 | 358 | |
359 | - echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n"; |
|
359 | + echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n"; |
|
360 | 360 | |
361 | 361 | // Reset day of the week count (sun, 0 - sat, 6). |
362 | - if ( $week_day === 6 ) { |
|
362 | + if ($week_day === 6) { |
|
363 | 363 | $week_day = -1; |
364 | 364 | } |
365 | 365 | $week_day++; |
@@ -369,91 +369,91 @@ discard block |
||
369 | 369 | endfor; |
370 | 370 | |
371 | 371 | // Actual days of the month. |
372 | - for ( $day = 1; $day <= $days_in_month; $day++ ) : |
|
372 | + for ($day = 1; $day <= $days_in_month; $day++) : |
|
373 | 373 | |
374 | 374 | $count = 0; |
375 | 375 | $calendar_classes = array(); |
376 | - $day_classes = 'simcal-day-' . $day . ' simcal-weekday-' . $week_day; |
|
376 | + $day_classes = 'simcal-day-'.$day.' simcal-weekday-'.$week_day; |
|
377 | 377 | |
378 | 378 | $border_style = $bg_color = $color = ''; |
379 | 379 | |
380 | 380 | // Is this the present, the past or the future, Doc? |
381 | - if ( $current_min <= $now && $current_max >= $now ) { |
|
381 | + if ($current_min <= $now && $current_max >= $now) { |
|
382 | 382 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
383 | - $the_color = new Color( $calendar->today_color ); |
|
384 | - $bg_color = '#' . $the_color->getHex(); |
|
383 | + $the_color = new Color($calendar->today_color); |
|
384 | + $bg_color = '#'.$the_color->getHex(); |
|
385 | 385 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
386 | - $border_style = ' style="border: 1px solid ' . $bg_color . ';"'; |
|
387 | - } elseif ( $current_max < $now ) { |
|
386 | + $border_style = ' style="border: 1px solid '.$bg_color.';"'; |
|
387 | + } elseif ($current_max < $now) { |
|
388 | 388 | $day_classes .= ' simcal-past simcal-day'; |
389 | - } elseif ( $current_min > $now ) { |
|
389 | + } elseif ($current_min > $now) { |
|
390 | 390 | $day_classes .= ' simcal-future simcal-day'; |
391 | 391 | } |
392 | 392 | |
393 | 393 | // Print events for the current day in loop, if found any. |
394 | - if ( isset( $day_events[ $day ] ) ) : |
|
394 | + if (isset($day_events[$day])) : |
|
395 | 395 | |
396 | 396 | $list_events = '<ul class="simcal-events">'; |
397 | 397 | |
398 | - foreach ( $day_events[ $day ] as $event ) : |
|
398 | + foreach ($day_events[$day] as $event) : |
|
399 | 399 | |
400 | 400 | $event_classes = $event_visibility = ''; |
401 | 401 | |
402 | - if ( $event instanceof Event ) : |
|
402 | + if ($event instanceof Event) : |
|
403 | 403 | |
404 | 404 | // Store the calendar id where the event belongs (useful in grouped calendar feeds) |
405 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
406 | - $calendar_classes[] = $calendar_class ; |
|
405 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
406 | + $calendar_classes[] = $calendar_class; |
|
407 | 407 | |
408 | 408 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
409 | 409 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
410 | 410 | |
411 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class . ' simcal-tooltip'; |
|
411 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class.' simcal-tooltip'; |
|
412 | 412 | |
413 | 413 | // Toggle some events visibility if more than optional limit. |
414 | - if ( ( $calendar->events_limit > -1 ) && ( $count >= $calendar->events_limit ) ) : |
|
414 | + if (($calendar->events_limit > -1) && ($count >= $calendar->events_limit)) : |
|
415 | 415 | $event_classes .= ' simcal-event-toggled'; |
416 | 416 | $event_visibility = ' style="display: none"'; |
417 | 417 | endif; |
418 | 418 | |
419 | 419 | // Event title in list. |
420 | - $title = ! empty( $event->title ) ? trim( $event->title ) : __( 'Event', 'google-calendar-events' ); |
|
421 | - if ( $calendar->trim_titles >= 1 ) { |
|
422 | - $title = strlen( $title ) > $calendar->trim_titles ? mb_substr( $title, 0, $calendar->trim_titles ) . '…' : $title; |
|
420 | + $title = ! empty($event->title) ? trim($event->title) : __('Event', 'google-calendar-events'); |
|
421 | + if ($calendar->trim_titles >= 1) { |
|
422 | + $title = strlen($title) > $calendar->trim_titles ? mb_substr($title, 0, $calendar->trim_titles).'…' : $title; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | // Event color. |
426 | 426 | $bullet = ''; |
427 | 427 | $event_color = $event->get_color(); |
428 | - if ( ! empty( $event_color ) ) { |
|
429 | - $bullet = '<span style="color: ' . $event_color . ';">■</span> '; |
|
428 | + if ( ! empty($event_color)) { |
|
429 | + $bullet = '<span style="color: '.$event_color.';">■</span> '; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | // Event contents. |
433 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . ' itemscope itemtype="http://schema.org/Event">' . "\n"; |
|
434 | - $list_events .= "\t\t" . '<span class="simcal-event-title">' . $bullet . $title . '</span>' . "\n"; |
|
435 | - $list_events .= "\t\t" . '<div class="simcal-event-details simcal-tooltip-content" style="display: none;">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
436 | - $list_events .= "\t" . '</li>' . "\n"; |
|
433 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.' itemscope itemtype="http://schema.org/Event">'."\n"; |
|
434 | + $list_events .= "\t\t".'<span class="simcal-event-title">'.$bullet.$title.'</span>'."\n"; |
|
435 | + $list_events .= "\t\t".'<div class="simcal-event-details simcal-tooltip-content" style="display: none;">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
436 | + $list_events .= "\t".'</li>'."\n"; |
|
437 | 437 | |
438 | - $count ++; |
|
438 | + $count++; |
|
439 | 439 | |
440 | 440 | endif; |
441 | 441 | |
442 | 442 | endforeach; |
443 | 443 | |
444 | - if ( ( $current_min <= $now ) && ( $current_max >= $now ) ) { |
|
444 | + if (($current_min <= $now) && ($current_max >= $now)) { |
|
445 | 445 | $day_classes .= ' simcal-today-has-events'; |
446 | 446 | } |
447 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
447 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
448 | 448 | |
449 | - if ( $calendar_classes ) { |
|
450 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
449 | + if ($calendar_classes) { |
|
450 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
451 | 451 | } |
452 | 452 | |
453 | - $list_events .= '</ul>' . "\n"; |
|
453 | + $list_events .= '</ul>'."\n"; |
|
454 | 454 | |
455 | 455 | // Optional button to toggle hidden events in list. |
456 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
456 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
457 | 457 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
458 | 458 | endif; |
459 | 459 | |
@@ -465,49 +465,49 @@ discard block |
||
465 | 465 | endif; |
466 | 466 | |
467 | 467 | // The actual days with numbers and events in each row cell. |
468 | - echo '<td class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
469 | - |
|
470 | - if ( $color ) { |
|
471 | - $day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"'; |
|
472 | - } elseif ( $count > 0 ) { |
|
473 | - $the_color = new Color( $calendar->days_events_color ); |
|
474 | - $color = ! $color ? ( $the_color->isDark() ? '#ffffff' : '#000000' ) : $color; |
|
475 | - $bg_color = ! $bg_color ? '#' . $the_color->getHex() : $bg_color; |
|
476 | - $day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"'; |
|
468 | + echo '<td class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
469 | + |
|
470 | + if ($color) { |
|
471 | + $day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"'; |
|
472 | + } elseif ($count > 0) { |
|
473 | + $the_color = new Color($calendar->days_events_color); |
|
474 | + $color = ! $color ? ($the_color->isDark() ? '#ffffff' : '#000000') : $color; |
|
475 | + $bg_color = ! $bg_color ? '#'.$the_color->getHex() : $bg_color; |
|
476 | + $day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"'; |
|
477 | 477 | } else { |
478 | 478 | $day_style = ''; |
479 | 479 | } |
480 | 480 | |
481 | - echo "\t" . '<div' . $border_style . '>' . "\n"; |
|
482 | - echo "\t\t" . '<span class="simcal-day-label simcal-day-number"' . $day_style . '>' . $day . '</span>' . "\n"; |
|
483 | - echo "\t\t" . $list_events . "\n"; |
|
481 | + echo "\t".'<div'.$border_style.'>'."\n"; |
|
482 | + echo "\t\t".'<span class="simcal-day-label simcal-day-number"'.$day_style.'>'.$day.'</span>'."\n"; |
|
483 | + echo "\t\t".$list_events."\n"; |
|
484 | 484 | echo "\t\t"; |
485 | 485 | echo '<span class="simcal-events-dots" style="display: none;">'; |
486 | 486 | |
487 | 487 | // Event bullets for calendar mobile mode. |
488 | - for( $i = 0; $i < $count; $i++ ) { |
|
488 | + for ($i = 0; $i < $count; $i++) { |
|
489 | 489 | echo '<b> • </b>'; |
490 | 490 | } |
491 | 491 | |
492 | - echo '</span>' . "\n"; |
|
493 | - echo "\t" . '</div>' . "\n"; |
|
494 | - echo '</td>' . "\n"; |
|
492 | + echo '</span>'."\n"; |
|
493 | + echo "\t".'</div>'."\n"; |
|
494 | + echo '</td>'."\n"; |
|
495 | 495 | |
496 | 496 | // Reset day of the week count (sun, 0 - sat, 6). |
497 | - if ( $week_day === 6 ) { |
|
497 | + if ($week_day === 6) { |
|
498 | 498 | $week_day = - 1; |
499 | 499 | } |
500 | 500 | $week_day++; |
501 | 501 | |
502 | 502 | // Reset count of days for this row (0-6). |
503 | - if ( $days_in_row === 6 ) : |
|
503 | + if ($days_in_row === 6) : |
|
504 | 504 | |
505 | 505 | // Close the week row. |
506 | 506 | echo '</tr>'; |
507 | 507 | |
508 | 508 | // Open a new week row. |
509 | - if ( $day < $days_in_month ) { |
|
510 | - echo '<tr class="simcal-week simcal-week-' . $week_of_year++ . '">' . "\n"; |
|
509 | + if ($day < $days_in_month) { |
|
510 | + echo '<tr class="simcal-week simcal-week-'.$week_of_year++.'">'."\n"; |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | $days_in_row = -1; |
@@ -516,27 +516,27 @@ discard block |
||
516 | 516 | |
517 | 517 | $days_in_row++; |
518 | 518 | |
519 | - $current_min = Carbon::createFromTimestamp( $current_min, $calendar->timezone )->addDay()->getTimestamp(); |
|
520 | - $current_max = Carbon::createFromTimestamp( $current_max, $calendar->timezone )->addDay()->getTimestamp(); |
|
519 | + $current_min = Carbon::createFromTimestamp($current_min, $calendar->timezone)->addDay()->getTimestamp(); |
|
520 | + $current_max = Carbon::createFromTimestamp($current_max, $calendar->timezone)->addDay()->getTimestamp(); |
|
521 | 521 | |
522 | 522 | endfor; |
523 | 523 | |
524 | 524 | // Void days at the end of the month. |
525 | - $remainder_days = ( 6 - $days_in_row ); |
|
525 | + $remainder_days = (6 - $days_in_row); |
|
526 | 526 | |
527 | - for ( $i = 0; $i <= $remainder_days; $i ++ ) { |
|
527 | + for ($i = 0; $i <= $remainder_days; $i++) { |
|
528 | 528 | |
529 | - $last_void_day_class = ( $i == $remainder_days ) ? 'simcal-day-void-last' : ''; |
|
529 | + $last_void_day_class = ($i == $remainder_days) ? 'simcal-day-void-last' : ''; |
|
530 | 530 | |
531 | - echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n"; |
|
531 | + echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n"; |
|
532 | 532 | |
533 | 533 | $week_day++; |
534 | 534 | } |
535 | 535 | |
536 | - echo "\t" . '</tr>' . "\n"; |
|
537 | - echo '</tbody>' . "\n"; |
|
536 | + echo "\t".'</tr>'."\n"; |
|
537 | + echo '</tbody>'."\n"; |
|
538 | 538 | |
539 | - date_default_timezone_set( $calendar->site_timezone ); |
|
539 | + date_default_timezone_set($calendar->site_timezone); |
|
540 | 540 | |
541 | 541 | return ob_get_clean(); |
542 | 542 | } |
@@ -548,17 +548,17 @@ discard block |
||
548 | 548 | */ |
549 | 549 | public function draw_grid_ajax() { |
550 | 550 | |
551 | - if ( isset( $_POST['month'] ) && isset( $_POST['year'] ) && isset( $_POST['id'] ) ) { |
|
551 | + if (isset($_POST['month']) && isset($_POST['year']) && isset($_POST['id'])) { |
|
552 | 552 | |
553 | - $month = absint( $_POST['month'] ); |
|
554 | - $year = absint( $_POST['year'] ); |
|
555 | - $id = absint( $_POST['id'] ); |
|
553 | + $month = absint($_POST['month']); |
|
554 | + $year = absint($_POST['year']); |
|
555 | + $id = absint($_POST['id']); |
|
556 | 556 | |
557 | - wp_send_json_success( $this->draw_month( $month, $year, $id ) ); |
|
557 | + wp_send_json_success($this->draw_month($month, $year, $id)); |
|
558 | 558 | |
559 | 559 | } else { |
560 | 560 | |
561 | - wp_send_json_error( 'Missing arguments in default calendar grid ajax request.' ); |
|
561 | + wp_send_json_error('Missing arguments in default calendar grid ajax request.'); |
|
562 | 562 | |
563 | 563 | } |
564 | 564 | |
@@ -574,8 +574,8 @@ discard block |
||
574 | 574 | * |
575 | 575 | * @return bool |
576 | 576 | */ |
577 | - private function filter_events_before( $event ) { |
|
578 | - return intval( $event ) >= intval( $this->start ); |
|
577 | + private function filter_events_before($event) { |
|
578 | + return intval($event) >= intval($this->start); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | * |
589 | 589 | * @return bool |
590 | 590 | */ |
591 | - private function filter_events_after( $event ) { |
|
592 | - return intval( $event ) < intval( $this->end ); |
|
591 | + private function filter_events_after($event) { |
|
592 | + return intval($event) < intval($this->end); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | use SimpleCalendar\Calendars\Default_Calendar; |
14 | 14 | use SimpleCalendar\Events\Event; |
15 | 15 | |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string|Calendar $calendar |
73 | 73 | */ |
74 | - public function __construct( $calendar = '' ) { |
|
74 | + public function __construct($calendar = '') { |
|
75 | 75 | $this->calendar = $calendar; |
76 | 76 | } |
77 | 77 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return string |
106 | 106 | */ |
107 | 107 | public function get_name() { |
108 | - return __( 'List', 'google-calendar-events' ); |
|
108 | + return __('List', 'google-calendar-events'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @since 3.0.0 |
115 | 115 | */ |
116 | 116 | public function add_ajax_actions() { |
117 | - add_action( 'wp_ajax_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) ); |
|
118 | - add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) ); |
|
117 | + add_action('wp_ajax_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax')); |
|
118 | + add_action('wp_ajax_nopriv_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax')); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -129,16 +129,16 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public function scripts( $min = '' ) { |
|
132 | + public function scripts($min = '') { |
|
133 | 133 | return array( |
134 | 134 | 'simcal-qtip' => array( |
135 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js', |
|
136 | - 'deps' => array( 'jquery' ), |
|
135 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js', |
|
136 | + 'deps' => array('jquery'), |
|
137 | 137 | 'ver' => '2.2.1', |
138 | 138 | 'in_footer' => true, |
139 | 139 | ), |
140 | 140 | 'simcal-default-calendar' => array( |
141 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js', |
|
141 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js', |
|
142 | 142 | 'deps' => array( |
143 | 143 | 'jquery', |
144 | 144 | 'simcal-qtip', |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array |
165 | 165 | */ |
166 | - public function styles( $min = '' ) { |
|
166 | + public function styles($min = '') { |
|
167 | 167 | return array( |
168 | 168 | 'simcal-default-calendar-list' => array( |
169 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $min . '.css', |
|
169 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$min.'.css', |
|
170 | 170 | 'ver' => SIMPLE_CALENDAR_VERSION, |
171 | 171 | 'media' => 'all', |
172 | 172 | ), |
@@ -182,49 +182,49 @@ discard block |
||
182 | 182 | |
183 | 183 | $calendar = $this->calendar; |
184 | 184 | |
185 | - if ( $calendar instanceof Default_Calendar ) { |
|
185 | + if ($calendar instanceof Default_Calendar) { |
|
186 | 186 | |
187 | 187 | $disabled = $calendar->static === true ? ' disabled="disabled"' : ''; |
188 | 188 | |
189 | 189 | |
190 | - $hide_header = get_post_meta( $this->calendar->id, '_default_calendar_list_header', true ) == 'yes' ? true : false; |
|
191 | - $static_calendar = get_post_meta( $this->calendar->id, '_calendar_is_static', true ) == 'yes' ? true : false; |
|
190 | + $hide_header = get_post_meta($this->calendar->id, '_default_calendar_list_header', true) == 'yes' ? true : false; |
|
191 | + $static_calendar = get_post_meta($this->calendar->id, '_calendar_is_static', true) == 'yes' ? true : false; |
|
192 | 192 | |
193 | 193 | $header_class = ''; |
194 | 194 | $compact_list_class = $calendar->compact_list ? 'simcal-calendar-list-compact' : ''; |
195 | 195 | |
196 | - edit_post_link( __( 'Edit Calendar', 'google-calendar-events' ), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id ); |
|
196 | + edit_post_link(__('Edit Calendar', 'google-calendar-events'), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id); |
|
197 | 197 | |
198 | - echo '<div class="simcal-calendar-list ' . $compact_list_class . '">'; |
|
198 | + echo '<div class="simcal-calendar-list '.$compact_list_class.'">'; |
|
199 | 199 | |
200 | - if ( ! $hide_header && ! $static_calendar ) { |
|
201 | - echo '<nav class="simcal-calendar-head">' . "\n"; |
|
200 | + if ( ! $hide_header && ! $static_calendar) { |
|
201 | + echo '<nav class="simcal-calendar-head">'."\n"; |
|
202 | 202 | |
203 | - echo "\t" . '<div class="simcal-nav">' . "\n"; |
|
204 | - echo "\t\t" . '<button class="simcal-nav-button simcal-prev" title="' . __('Previous', 'google-calendar-events') . '"' . $disabled . '>' . "\n"; |
|
205 | - echo "\t\t\t" . '<i class="simcal-icon-left"></i>' . "\n"; |
|
206 | - echo "\t\t" . '</button>' . "\n"; |
|
207 | - echo "\t" . '</div>' . "\n"; |
|
203 | + echo "\t".'<div class="simcal-nav">'."\n"; |
|
204 | + echo "\t\t".'<button class="simcal-nav-button simcal-prev" title="'.__('Previous', 'google-calendar-events').'"'.$disabled.'>'."\n"; |
|
205 | + echo "\t\t\t".'<i class="simcal-icon-left"></i>'."\n"; |
|
206 | + echo "\t\t".'</button>'."\n"; |
|
207 | + echo "\t".'</div>'."\n"; |
|
208 | 208 | |
209 | - if ( $hide_header ) { |
|
209 | + if ($hide_header) { |
|
210 | 210 | $header_class = 'simcal-hide-header'; |
211 | 211 | } |
212 | 212 | |
213 | 213 | |
214 | - echo "\t" . '<div class="simcal-nav simcal-current ' . $header_class . '" data-calendar-current="' . $calendar->start . '">' . "\n"; |
|
215 | - echo "\t\t" . '<h3 class="simcal-current-label"> </h3>' . "\n"; |
|
216 | - echo "\t" . '</div>' . "\n"; |
|
214 | + echo "\t".'<div class="simcal-nav simcal-current '.$header_class.'" data-calendar-current="'.$calendar->start.'">'."\n"; |
|
215 | + echo "\t\t".'<h3 class="simcal-current-label"> </h3>'."\n"; |
|
216 | + echo "\t".'</div>'."\n"; |
|
217 | 217 | |
218 | - echo "\t" . '<div class="simcal-nav">'; |
|
219 | - echo "\t\t" . '<button class="simcal-nav-button simcal-next" title="' . __('Next', 'google-calendar-events') . '"' . $disabled . '>'; |
|
220 | - echo "\t\t\t" . '<i class="simcal-icon-right"></i>' . "\n"; |
|
221 | - echo "\t\t" . '</button>' . "\n"; |
|
222 | - echo "\t" . '</div>' . "\n"; |
|
218 | + echo "\t".'<div class="simcal-nav">'; |
|
219 | + echo "\t\t".'<button class="simcal-nav-button simcal-next" title="'.__('Next', 'google-calendar-events').'"'.$disabled.'>'; |
|
220 | + echo "\t\t\t".'<i class="simcal-icon-right"></i>'."\n"; |
|
221 | + echo "\t\t".'</button>'."\n"; |
|
222 | + echo "\t".'</div>'."\n"; |
|
223 | 223 | |
224 | - echo '</nav>' . "\n"; |
|
224 | + echo '</nav>'."\n"; |
|
225 | 225 | } |
226 | 226 | |
227 | - echo $this->draw_list( $calendar->start ); |
|
227 | + echo $this->draw_list($calendar->start); |
|
228 | 228 | |
229 | 229 | echo '<div class="simcal-ajax-loader simcal-spinner-top" style="display: none;"><i class="simcal-icon-spinner simcal-icon-spin"></i></div>'; |
230 | 230 | |
@@ -244,92 +244,92 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return array |
246 | 246 | */ |
247 | - private function get_events( $timestamp ) { |
|
247 | + private function get_events($timestamp) { |
|
248 | 248 | |
249 | 249 | $calendar = $this->calendar; |
250 | 250 | $timezone = $calendar->timezone; |
251 | 251 | |
252 | - if ( ! $calendar->group_type || ! $calendar->group_span ) { |
|
252 | + if ( ! $calendar->group_type || ! $calendar->group_span) { |
|
253 | 253 | return array(); |
254 | 254 | } |
255 | 255 | |
256 | - $current = Carbon::createFromTimestamp( $timestamp, $timezone ); |
|
256 | + $current = Carbon::createFromTimestamp($timestamp, $timezone); |
|
257 | 257 | $prev = clone $current; |
258 | 258 | $next = clone $current; |
259 | 259 | |
260 | 260 | $this->start = $current->getTimestamp(); |
261 | 261 | |
262 | - $interval = $span = max( absint( $calendar->group_span ), 1 ); |
|
263 | - |
|
264 | - if ( 'monthly' == $calendar->group_type ) { |
|
265 | - $this->prev = $prev->subMonths( $span )->getTimestamp(); |
|
266 | - $this->next = $next->addMonths( $span )->getTimestamp(); |
|
267 | - } elseif ( 'weekly' == $calendar->group_type ) { |
|
268 | - $week = new Carbon( $calendar->timezone ); |
|
269 | - $week->setTimestamp( $timestamp ); |
|
270 | - $week->setWeekStartsAt( $calendar->week_starts ); |
|
271 | - $this->prev = $prev->subWeeks( $span )->getTimestamp(); |
|
272 | - $this->next = $next->addWeeks( $span )->getTimestamp(); |
|
273 | - } elseif ( 'daily' == $calendar->group_type ) { |
|
274 | - $this->prev = $prev->subDays( $span )->getTimestamp(); |
|
275 | - $this->next = $next->addDays( $span )->getTimestamp(); |
|
262 | + $interval = $span = max(absint($calendar->group_span), 1); |
|
263 | + |
|
264 | + if ('monthly' == $calendar->group_type) { |
|
265 | + $this->prev = $prev->subMonths($span)->getTimestamp(); |
|
266 | + $this->next = $next->addMonths($span)->getTimestamp(); |
|
267 | + } elseif ('weekly' == $calendar->group_type) { |
|
268 | + $week = new Carbon($calendar->timezone); |
|
269 | + $week->setTimestamp($timestamp); |
|
270 | + $week->setWeekStartsAt($calendar->week_starts); |
|
271 | + $this->prev = $prev->subWeeks($span)->getTimestamp(); |
|
272 | + $this->next = $next->addWeeks($span)->getTimestamp(); |
|
273 | + } elseif ('daily' == $calendar->group_type) { |
|
274 | + $this->prev = $prev->subDays($span)->getTimestamp(); |
|
275 | + $this->next = $next->addDays($span)->getTimestamp(); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | $events = $calendar->events; |
279 | 279 | $daily_events = $paged_events = $flattened_events = array(); |
280 | 280 | |
281 | - if ( 'events' != $calendar->group_type ) { |
|
281 | + if ('events' != $calendar->group_type) { |
|
282 | 282 | |
283 | - $this->end = $this->next - 1; |
|
283 | + $this->end = $this->next - 1; |
|
284 | 284 | |
285 | - $timestamps = array_keys( $events ); |
|
286 | - $lower_bound = array_filter( $timestamps, array( $this, 'filter_events_before' ) ); |
|
287 | - $higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) ); |
|
285 | + $timestamps = array_keys($events); |
|
286 | + $lower_bound = array_filter($timestamps, array($this, 'filter_events_before')); |
|
287 | + $higher_bound = array_filter($lower_bound, array($this, 'filter_events_after')); |
|
288 | 288 | |
289 | - if ( is_array( $higher_bound ) && !empty( $higher_bound ) ) { |
|
290 | - $filtered = array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ); |
|
291 | - foreach ( $filtered as $timestamp => $events ) { |
|
292 | - $paged_events[ intval( $timestamp ) ] = $events; |
|
289 | + if (is_array($higher_bound) && ! empty($higher_bound)) { |
|
290 | + $filtered = array_intersect_key($events, array_combine($higher_bound, $higher_bound)); |
|
291 | + foreach ($filtered as $timestamp => $events) { |
|
292 | + $paged_events[intval($timestamp)] = $events; |
|
293 | 293 | } |
294 | 294 | } |
295 | 295 | |
296 | 296 | } else { |
297 | 297 | |
298 | - foreach ( $events as $timestamp => $e ) { |
|
298 | + foreach ($events as $timestamp => $e) { |
|
299 | 299 | $second = 0; |
300 | - foreach ( $e as $event ) { |
|
301 | - $flattened_events[ intval( $timestamp + $second ) ][] = $event; |
|
300 | + foreach ($e as $event) { |
|
301 | + $flattened_events[intval($timestamp + $second)][] = $event; |
|
302 | 302 | $second++; |
303 | 303 | } |
304 | 304 | } |
305 | - ksort( $flattened_events, SORT_NUMERIC ); |
|
305 | + ksort($flattened_events, SORT_NUMERIC); |
|
306 | 306 | |
307 | - $keys = array_keys( $flattened_events ); |
|
307 | + $keys = array_keys($flattened_events); |
|
308 | 308 | $current = 0; |
309 | - foreach ( $keys as $timestamp ) { |
|
310 | - if ( $timestamp <= $this->start ) { |
|
309 | + foreach ($keys as $timestamp) { |
|
310 | + if ($timestamp <= $this->start) { |
|
311 | 311 | $current++; |
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | - $paged_events = array_slice( $flattened_events, $current, $interval, true ); |
|
315 | + $paged_events = array_slice($flattened_events, $current, $interval, true); |
|
316 | 316 | |
317 | - $events_end = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $calendar->end; |
|
317 | + $events_end = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $calendar->end; |
|
318 | 318 | $this->end = $events_end > $calendar->end ? $calendar->end : $events_end; |
319 | 319 | // -1 adjusts the interval count to index count, which starts at 0. |
320 | - $this->prev = isset( $keys[ $current - $interval - 1 ] ) ? $keys[ $current - $interval - 1 ] : $calendar->earliest_event; |
|
321 | - $this->next = isset( $keys[ $current + $interval - 1 ] ) ? $keys[ $current + $interval - 1 ] : $this->end; |
|
320 | + $this->prev = isset($keys[$current - $interval - 1]) ? $keys[$current - $interval - 1] : $calendar->earliest_event; |
|
321 | + $this->next = isset($keys[$current + $interval - 1]) ? $keys[$current + $interval - 1] : $this->end; |
|
322 | 322 | |
323 | 323 | } |
324 | 324 | |
325 | 325 | // Put resulting events in an associative array, with Ymd date as key for easy retrieval in calendar days loop. |
326 | - foreach ( $paged_events as $timestamp => $events ) { |
|
327 | - if ( $timestamp <= $this->end ) { |
|
328 | - $date = Carbon::createFromTimestamp( $timestamp, $calendar->timezone )->endOfDay()->format( 'Ymd' ); |
|
329 | - $daily_events[ intval( $date ) ][] = $events; |
|
326 | + foreach ($paged_events as $timestamp => $events) { |
|
327 | + if ($timestamp <= $this->end) { |
|
328 | + $date = Carbon::createFromTimestamp($timestamp, $calendar->timezone)->endOfDay()->format('Ymd'); |
|
329 | + $daily_events[intval($date)][] = $events; |
|
330 | 330 | } |
331 | 331 | } |
332 | - ksort( $daily_events, SORT_NUMERIC ); |
|
332 | + ksort($daily_events, SORT_NUMERIC); |
|
333 | 333 | |
334 | 334 | return $daily_events; |
335 | 335 | } |
@@ -347,71 +347,71 @@ discard block |
||
347 | 347 | private function get_heading() { |
348 | 348 | |
349 | 349 | $calendar = $this->calendar; |
350 | - $start = Carbon::createFromTimestamp( $this->start, $calendar->timezone ); |
|
351 | - $end = Carbon::createFromTimestamp( $this->end, $calendar->timezone ); |
|
350 | + $start = Carbon::createFromTimestamp($this->start, $calendar->timezone); |
|
351 | + $end = Carbon::createFromTimestamp($this->end, $calendar->timezone); |
|
352 | 352 | $date_format = $this->calendar->date_format; |
353 | - $date_order = simcal_get_date_format_order( $date_format ); |
|
353 | + $date_order = simcal_get_date_format_order($date_format); |
|
354 | 354 | |
355 | - if ( ( $start->day == $end->day ) && ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
355 | + if (($start->day == $end->day) && ($start->month == $end->month) && ($start->year == $end->year)) { |
|
356 | 356 | // Start and end on the same day. |
357 | 357 | // e.g. 1 February 2020 |
358 | - $large = $small = date_i18n( $calendar->date_format , $this->start ); |
|
359 | - if ( ( $date_order['d'] !== false ) && ( $date_order['m'] !== false ) ) { |
|
360 | - if ( $date_order['m'] > $date_order['d'] ) { |
|
361 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
362 | - $small = date_i18n( 'Y, d M', $this->start ); |
|
358 | + $large = $small = date_i18n($calendar->date_format, $this->start); |
|
359 | + if (($date_order['d'] !== false) && ($date_order['m'] !== false)) { |
|
360 | + if ($date_order['m'] > $date_order['d']) { |
|
361 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
362 | + $small = date_i18n('Y, d M', $this->start); |
|
363 | 363 | } else { |
364 | - $small = date_i18n( 'd M Y', $this->start ); |
|
364 | + $small = date_i18n('d M Y', $this->start); |
|
365 | 365 | } |
366 | 366 | } else { |
367 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
368 | - $small = date_i18n( 'Y, M d', $this->start ); |
|
367 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
368 | + $small = date_i18n('Y, M d', $this->start); |
|
369 | 369 | } else { |
370 | - $small = date_i18n( 'M d Y', $this->start ); |
|
370 | + $small = date_i18n('M d Y', $this->start); |
|
371 | 371 | } |
372 | 372 | } |
373 | 373 | } |
374 | - } elseif ( ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
374 | + } elseif (($start->month == $end->month) && ($start->year == $end->year)) { |
|
375 | 375 | // Start and end days on the same month. |
376 | 376 | // e.g. August 2020 |
377 | - if ( $date_order['y'] === false ) { |
|
377 | + if ($date_order['y'] === false) { |
|
378 | 378 | // August. |
379 | - $large = $small = date_i18n( 'F', $this->start ); |
|
379 | + $large = $small = date_i18n('F', $this->start); |
|
380 | 380 | } else { |
381 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
381 | + if ($date_order['y'] < $date_order['m']) { |
|
382 | 382 | // 2020 August. |
383 | - $large = date_i18n( 'Y F', $this->start ); |
|
384 | - $small = date_i18n( 'Y M', $this->start ); |
|
383 | + $large = date_i18n('Y F', $this->start); |
|
384 | + $small = date_i18n('Y M', $this->start); |
|
385 | 385 | } else { |
386 | 386 | // August 2020. |
387 | - $large = date_i18n( 'F Y', $this->start ); |
|
388 | - $small = date_i18n( 'M Y', $this->start ); |
|
387 | + $large = date_i18n('F Y', $this->start); |
|
388 | + $small = date_i18n('M Y', $this->start); |
|
389 | 389 | } |
390 | 390 | } |
391 | - } elseif ( $start->year == $end->year ) { |
|
391 | + } elseif ($start->year == $end->year) { |
|
392 | 392 | // Start and end days on months of the same year. |
393 | 393 | // e.g. August - September 2020 |
394 | - if ( $date_order['y'] === false ) { |
|
394 | + if ($date_order['y'] === false) { |
|
395 | 395 | // August - September. |
396 | - $large = date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ); |
|
397 | - $small = date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ); |
|
396 | + $large = date_i18n('F', $this->start).' - '.date_i18n('F', $this->end); |
|
397 | + $small = date_i18n('M', $this->start).' - '.date_i18n('M', $this->end); |
|
398 | 398 | } else { |
399 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
399 | + if ($date_order['y'] < $date_order['m']) { |
|
400 | 400 | // 2020, August - September. |
401 | - $large = $small = date( 'Y', $this->start ) . ', '; |
|
402 | - $large .= date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ); |
|
403 | - $small .= date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ); |
|
401 | + $large = $small = date('Y', $this->start).', '; |
|
402 | + $large .= date_i18n('F', $this->start).' - '.date_i18n('F', $this->end); |
|
403 | + $small .= date_i18n('M', $this->start).' - '.date_i18n('M', $this->end); |
|
404 | 404 | } else { |
405 | 405 | // August - September, 2020. |
406 | - $large = date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ) . ', '; |
|
407 | - $small = date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ) . ' '; |
|
408 | - $year = date( 'Y', $this->start ); |
|
406 | + $large = date_i18n('F', $this->start).' - '.date_i18n('F', $this->end).', '; |
|
407 | + $small = date_i18n('M', $this->start).' - '.date_i18n('M', $this->end).' '; |
|
408 | + $year = date('Y', $this->start); |
|
409 | 409 | $large .= $year; |
410 | 410 | $small .= $year; |
411 | 411 | } |
412 | 412 | } |
413 | 413 | } else { |
414 | - $large = $small = date( 'Y', $this->start ) . ' - ' . date( 'Y', $this->end ); |
|
414 | + $large = $small = date('Y', $this->start).' - '.date('Y', $this->end); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | return array( |
@@ -433,123 +433,123 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @return string |
435 | 435 | */ |
436 | - private function draw_list( $timestamp, $id = 0 ) { |
|
436 | + private function draw_list($timestamp, $id = 0) { |
|
437 | 437 | |
438 | 438 | $calendar = $this->calendar; |
439 | 439 | |
440 | - if ( empty( $calendar ) ) { |
|
441 | - $calendar = $this->calendar = simcal_get_calendar( intval( $id ) ); |
|
442 | - if ( ! $calendar instanceof Default_Calendar ) { |
|
440 | + if (empty($calendar)) { |
|
441 | + $calendar = $this->calendar = simcal_get_calendar(intval($id)); |
|
442 | + if ( ! $calendar instanceof Default_Calendar) { |
|
443 | 443 | return ''; |
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | - date_default_timezone_set( $calendar->timezone ); |
|
447 | + date_default_timezone_set($calendar->timezone); |
|
448 | 448 | |
449 | 449 | $now = $calendar->now; |
450 | - $current_events = $this->get_events( $timestamp ); |
|
451 | - $day_format = explode( ' ', $calendar->date_format ); |
|
450 | + $current_events = $this->get_events($timestamp); |
|
451 | + $day_format = explode(' ', $calendar->date_format); |
|
452 | 452 | |
453 | 453 | ob_start(); |
454 | 454 | |
455 | 455 | // Draw the events. |
456 | 456 | |
457 | - $block_tag = $calendar->compact_list && ! empty( $current_events ) ? 'div' : 'dl'; |
|
457 | + $block_tag = $calendar->compact_list && ! empty($current_events) ? 'div' : 'dl'; |
|
458 | 458 | |
459 | 459 | $data_heading = ''; |
460 | 460 | $heading = $this->get_heading(); |
461 | - foreach ( $heading as $k => $v ) { |
|
462 | - $data_heading .= ' data-heading-' . $k . '="' . $v . '"'; |
|
461 | + foreach ($heading as $k => $v) { |
|
462 | + $data_heading .= ' data-heading-'.$k.'="'.$v.'"'; |
|
463 | 463 | } |
464 | 464 | |
465 | - echo '<' . $block_tag . ' class="simcal-events-list-container"' . |
|
466 | - ' data-prev="' . $this->prev . '"' . |
|
467 | - ' data-next="' . $this->next . '"' . |
|
468 | - $data_heading . '>'; |
|
465 | + echo '<'.$block_tag.' class="simcal-events-list-container"'. |
|
466 | + ' data-prev="'.$this->prev.'"'. |
|
467 | + ' data-next="'.$this->next.'"'. |
|
468 | + $data_heading.'>'; |
|
469 | 469 | |
470 | - if ( ! empty( $current_events ) && is_array( $current_events ) ) : |
|
470 | + if ( ! empty($current_events) && is_array($current_events)) : |
|
471 | 471 | |
472 | - foreach ( $current_events as $ymd => $events ) : |
|
472 | + foreach ($current_events as $ymd => $events) : |
|
473 | 473 | |
474 | 474 | // This is where we can find out if an event is a multi-day event and if it needs to be shown. |
475 | 475 | // Since this is for list view we are showing the event on the day viewed if it is part of that day even when |
476 | 476 | // expand multi-day events are turned off. |
477 | - if ( isset( $events[0][0]->multiple_days ) && $events[0][0]->multiple_days > 0 ) { |
|
478 | - if ( 'current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true ) ) { |
|
477 | + if (isset($events[0][0]->multiple_days) && $events[0][0]->multiple_days > 0) { |
|
478 | + if ('current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true)) { |
|
479 | 479 | |
480 | - $year = substr( $ymd, 0, 4 ); |
|
481 | - $month = substr( $ymd, 4, 2 ); |
|
482 | - $day = substr( $ymd, 6, 2 ); |
|
480 | + $year = substr($ymd, 0, 4); |
|
481 | + $month = substr($ymd, 4, 2); |
|
482 | + $day = substr($ymd, 6, 2); |
|
483 | 483 | |
484 | - $temp_date = Carbon::createFromDate( $year, $month, $day ); |
|
484 | + $temp_date = Carbon::createFromDate($year, $month, $day); |
|
485 | 485 | |
486 | - if( ! ( $temp_date < Carbon::now()->endOfDay() ) ) { |
|
486 | + if ( ! ($temp_date < Carbon::now()->endOfDay())) { |
|
487 | 487 | continue; |
488 | 488 | } |
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | - $day_ts = Carbon::createFromFormat( 'Ymd', $ymd, $calendar->timezone )->getTimestamp(); |
|
492 | + $day_ts = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone)->getTimestamp(); |
|
493 | 493 | |
494 | - if ( ! $calendar->compact_list ) : |
|
494 | + if ( ! $calendar->compact_list) : |
|
495 | 495 | |
496 | - $date = new Carbon( 'now', $calendar->timezone ); |
|
497 | - $date->setLocale( substr( get_locale(), 0, 2 ) ); |
|
498 | - $date->setTimestamp( $day_ts ); |
|
496 | + $date = new Carbon('now', $calendar->timezone); |
|
497 | + $date->setLocale(substr(get_locale(), 0, 2)); |
|
498 | + $date->setTimestamp($day_ts); |
|
499 | 499 | |
500 | - if ( $date->isToday() ) { |
|
501 | - $the_color = new Color( $calendar->today_color ); |
|
500 | + if ($date->isToday()) { |
|
501 | + $the_color = new Color($calendar->today_color); |
|
502 | 502 | } else { |
503 | - $the_color = new Color( $calendar->days_events_color ); |
|
503 | + $the_color = new Color($calendar->days_events_color); |
|
504 | 504 | } |
505 | 505 | |
506 | - $bg_color = '#' . $the_color->getHex(); |
|
506 | + $bg_color = '#'.$the_color->getHex(); |
|
507 | 507 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
508 | - $border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" '; |
|
509 | - $bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"'; |
|
508 | + $border_style = ' style="border-bottom: 1px solid '.$bg_color.';" '; |
|
509 | + $bg_style = ' style="background-color: '.$bg_color.'; color: '.$color.';"'; |
|
510 | 510 | |
511 | - echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>'; |
|
512 | - echo '<span' . $bg_style .'>'; |
|
513 | - foreach ( $day_format as $format ) { |
|
514 | - echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n( $format, $day_ts ) . '</span> ' : ' '; |
|
511 | + echo "\t".'<dt class="simcal-day-label"'.$border_style.'>'; |
|
512 | + echo '<span'.$bg_style.'>'; |
|
513 | + foreach ($day_format as $format) { |
|
514 | + echo $format ? '<span class="simcal-date-format" data-date-format="'.$format.'">'.date_i18n($format, $day_ts).'</span> ' : ' '; |
|
515 | 515 | } |
516 | 516 | echo '</span>'; |
517 | - echo '</dt>' . "\n"; |
|
517 | + echo '</dt>'."\n"; |
|
518 | 518 | |
519 | 519 | endif; |
520 | 520 | |
521 | - $list_events = '<ul class="simcal-events">' . "\n"; |
|
521 | + $list_events = '<ul class="simcal-events">'."\n"; |
|
522 | 522 | |
523 | 523 | $calendar_classes = array(); |
524 | - $day_classes = 'simcal-weekday-' . date( 'w', $day_ts ); |
|
524 | + $day_classes = 'simcal-weekday-'.date('w', $day_ts); |
|
525 | 525 | |
526 | 526 | // Is this the present, the past or the future, Doc? |
527 | - if ( $timestamp <= $now && $timestamp >= $now ) { |
|
527 | + if ($timestamp <= $now && $timestamp >= $now) { |
|
528 | 528 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
529 | - } elseif ( $timestamp < $now ) { |
|
529 | + } elseif ($timestamp < $now) { |
|
530 | 530 | $day_classes .= ' simcal-past simcal-day'; |
531 | - } elseif ( $this->end > $now ) { |
|
531 | + } elseif ($this->end > $now) { |
|
532 | 532 | $day_classes .= ' simcal-future simcal-day'; |
533 | 533 | } |
534 | 534 | |
535 | 535 | $count = 0; |
536 | 536 | |
537 | - foreach ( $events as $day_events ) : |
|
538 | - foreach ( $day_events as $event ) : |
|
539 | - if ( $event instanceof Event ) : |
|
537 | + foreach ($events as $day_events) : |
|
538 | + foreach ($day_events as $event) : |
|
539 | + if ($event instanceof Event) : |
|
540 | 540 | |
541 | 541 | $event_classes = $event_visibility = ''; |
542 | 542 | |
543 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
543 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
544 | 544 | $calendar_classes[] = $calendar_class; |
545 | 545 | |
546 | 546 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
547 | 547 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
548 | 548 | |
549 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class; |
|
549 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class; |
|
550 | 550 | |
551 | 551 | // Toggle some events visibility if more than optional limit. |
552 | - if ( ( $calendar->events_limit > - 1 ) && ( $count >= $calendar->events_limit ) ) : |
|
552 | + if (($calendar->events_limit > - 1) && ($count >= $calendar->events_limit)) : |
|
553 | 553 | $event_classes .= ' simcal-event-toggled'; |
554 | 554 | $event_visibility = ' style="display: none"'; |
555 | 555 | endif; |
@@ -557,75 +557,75 @@ discard block |
||
557 | 557 | $event_color = ''; |
558 | 558 | $bullet = ''; |
559 | 559 | $event_color = $event->get_color(); |
560 | - if ( ! empty( $event_color ) ) { |
|
560 | + if ( ! empty($event_color)) { |
|
561 | 561 | $side = is_rtl() ? 'right' : 'left'; |
562 | - $event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"'; |
|
562 | + $event_color = ' style="border-'.$side.': 4px solid '.$event_color.'; padding-'.$side.': 8px;"'; |
|
563 | 563 | } |
564 | 564 | |
565 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemscope itemtype="http://schema.org/Event">' . "\n"; |
|
566 | - $list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
567 | - $list_events .= "\t" . '</li>' . "\n"; |
|
565 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.$event_color.' itemscope itemtype="http://schema.org/Event">'."\n"; |
|
566 | + $list_events .= "\t\t".'<div class="simcal-event-details">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
567 | + $list_events .= "\t".'</li>'."\n"; |
|
568 | 568 | |
569 | - $count ++; |
|
569 | + $count++; |
|
570 | 570 | |
571 | 571 | // Event falls within today. |
572 | - if ( ( $this->end <= $now ) && ( $this->start >= $now ) ) : |
|
572 | + if (($this->end <= $now) && ($this->start >= $now)) : |
|
573 | 573 | $day_classes .= ' simcal-today-has-events'; |
574 | 574 | endif; |
575 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
575 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
576 | 576 | |
577 | - if ( $calendar_classes ) : |
|
578 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
577 | + if ($calendar_classes) : |
|
578 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
579 | 579 | endif; |
580 | 580 | |
581 | 581 | endif; |
582 | 582 | endforeach; |
583 | 583 | endforeach; |
584 | 584 | |
585 | - $list_events .= '</ul>' . "\n"; |
|
585 | + $list_events .= '</ul>'."\n"; |
|
586 | 586 | |
587 | 587 | // If events visibility is limited, print the button toggle. |
588 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
588 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
589 | 589 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
590 | 590 | endif; |
591 | 591 | |
592 | 592 | // Print final list of events for the current day. |
593 | 593 | $tag = $calendar->compact_list ? 'div' : 'dd'; |
594 | - echo '<' . $tag . ' class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
595 | - echo "\t" . $list_events . "\n"; |
|
596 | - echo '</' . $tag . '>' . "\n"; |
|
594 | + echo '<'.$tag.' class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
595 | + echo "\t".$list_events."\n"; |
|
596 | + echo '</'.$tag.'>'."\n"; |
|
597 | 597 | |
598 | 598 | endforeach; |
599 | 599 | |
600 | 600 | else : |
601 | 601 | |
602 | - echo "\t" . '<p>'; |
|
602 | + echo "\t".'<p>'; |
|
603 | 603 | |
604 | - $message = get_post_meta( $calendar->id, '_no_events_message', true ); |
|
604 | + $message = get_post_meta($calendar->id, '_no_events_message', true); |
|
605 | 605 | |
606 | - if ( 'events' == $calendar->group_type ) { |
|
607 | - echo ! empty( $message ) ? $message : __( 'Nothing to show.', 'google-calendar-events' ); |
|
606 | + if ('events' == $calendar->group_type) { |
|
607 | + echo ! empty($message) ? $message : __('Nothing to show.', 'google-calendar-events'); |
|
608 | 608 | } else { |
609 | - if ( ! empty( $message ) ) { |
|
609 | + if ( ! empty($message)) { |
|
610 | 610 | echo $message; |
611 | 611 | } else { |
612 | - $from = Carbon::createFromTimestamp( $this->start, $calendar->timezone )->getTimestamp(); |
|
613 | - $to = Carbon::createFromTimestamp( $this->end, $calendar->timezone )->getTimestamp(); |
|
614 | - echo apply_filters( 'simcal_no_events_message', sprintf( |
|
615 | - __( 'Nothing from %1$s to %2$s.', 'google-calendar-events' ), |
|
616 | - date_i18n( $calendar->date_format, $from ), |
|
617 | - date_i18n( $calendar->date_format, $to ) |
|
618 | - ), $calendar->id, $from, $to ); |
|
612 | + $from = Carbon::createFromTimestamp($this->start, $calendar->timezone)->getTimestamp(); |
|
613 | + $to = Carbon::createFromTimestamp($this->end, $calendar->timezone)->getTimestamp(); |
|
614 | + echo apply_filters('simcal_no_events_message', sprintf( |
|
615 | + __('Nothing from %1$s to %2$s.', 'google-calendar-events'), |
|
616 | + date_i18n($calendar->date_format, $from), |
|
617 | + date_i18n($calendar->date_format, $to) |
|
618 | + ), $calendar->id, $from, $to); |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 | |
622 | - echo "\t" . '</p>' . "\n"; |
|
622 | + echo "\t".'</p>'."\n"; |
|
623 | 623 | |
624 | 624 | endif; |
625 | 625 | |
626 | - echo '</' . $block_tag . '>'; |
|
626 | + echo '</'.$block_tag.'>'; |
|
627 | 627 | |
628 | - date_default_timezone_set( $calendar->site_timezone ); |
|
628 | + date_default_timezone_set($calendar->site_timezone); |
|
629 | 629 | |
630 | 630 | return ob_get_clean(); |
631 | 631 | } |
@@ -637,16 +637,16 @@ discard block |
||
637 | 637 | */ |
638 | 638 | public function draw_list_ajax() { |
639 | 639 | |
640 | - if ( isset( $_POST['ts'] ) && isset( $_POST['id'] ) ) { |
|
640 | + if (isset($_POST['ts']) && isset($_POST['id'])) { |
|
641 | 641 | |
642 | - $ts = absint( $_POST['ts'] ); |
|
643 | - $id = absint( $_POST['id'] ); |
|
642 | + $ts = absint($_POST['ts']); |
|
643 | + $id = absint($_POST['id']); |
|
644 | 644 | |
645 | - wp_send_json_success( $this->draw_list( $ts, $id ) ); |
|
645 | + wp_send_json_success($this->draw_list($ts, $id)); |
|
646 | 646 | |
647 | 647 | } else { |
648 | 648 | |
649 | - wp_send_json_error( 'Missing arguments in default calendar list ajax request.' ); |
|
649 | + wp_send_json_error('Missing arguments in default calendar list ajax request.'); |
|
650 | 650 | |
651 | 651 | } |
652 | 652 | } |
@@ -661,8 +661,8 @@ discard block |
||
661 | 661 | * |
662 | 662 | * @return bool |
663 | 663 | */ |
664 | - private function filter_events_before( $event ) { |
|
665 | - return intval( $event ) >= intval( $this->start ); |
|
664 | + private function filter_events_before($event) { |
|
665 | + return intval($event) >= intval($this->start); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
@@ -675,8 +675,8 @@ discard block |
||
675 | 675 | * |
676 | 676 | * @return bool |
677 | 677 | */ |
678 | - private function filter_events_after( $event ) { |
|
679 | - return intval( $event ) < intval( $this->end ); |
|
678 | + private function filter_events_after($event) { |
|
679 | + return intval($event) < intval($this->end); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | } |
@@ -594,21 +594,21 @@ discard block |
||
594 | 594 | if ( ! $event->whole_day ) { |
595 | 595 | |
596 | 596 | $time_start = $this->calendar->datetime_separator . |
597 | - ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
598 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
599 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
600 | - 'itemprop="startDate" data-content="' . $start->toIso8601String() . '">' . |
|
601 | - date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
602 | - '</span> '; |
|
597 | + ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
598 | + 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
599 | + 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
600 | + 'itemprop="startDate" data-content="' . $start->toIso8601String() . '">' . |
|
601 | + date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
602 | + '</span> '; |
|
603 | 603 | |
604 | 604 | if ( $end instanceof Carbon ) { |
605 | 605 | |
606 | 606 | $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . |
607 | - 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
608 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
609 | - 'itemprop="endDate" data-content="' . $end->toIso8601String() . '">' . |
|
610 | - date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
611 | - '</span> '; |
|
607 | + 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
608 | + 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
609 | + 'itemprop="endDate" data-content="' . $end->toIso8601String() . '">' . |
|
610 | + date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
611 | + '</span> '; |
|
612 | 612 | |
613 | 613 | } |
614 | 614 | |
@@ -617,23 +617,23 @@ discard block |
||
617 | 617 | if ( $event->multiple_days ) { |
618 | 618 | |
619 | 619 | $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
620 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
621 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
622 | - 'itemprop="startDate" data-content="' . $start->toIso8601String() . '">' . |
|
623 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
624 | - '</span> ' . |
|
625 | - $time_start; |
|
620 | + 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
621 | + 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
622 | + 'itemprop="startDate" data-content="' . $start->toIso8601String() . '">' . |
|
623 | + date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
624 | + '</span> ' . |
|
625 | + $time_start; |
|
626 | 626 | |
627 | 627 | if ( $end instanceof Carbon ) { |
628 | 628 | |
629 | 629 | $output .= '-' . |
630 | - ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
631 | - 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
632 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
633 | - 'itemprop="endDate" data-content="' . $end->toIso8601String() . '">' . |
|
634 | - date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
635 | - '</span> ' . |
|
636 | - $time_end; |
|
630 | + ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
631 | + 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
632 | + 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
633 | + 'itemprop="endDate" data-content="' . $end->toIso8601String() . '">' . |
|
634 | + date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
635 | + '</span> ' . |
|
636 | + $time_end; |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | } else { |
@@ -641,12 +641,12 @@ discard block |
||
641 | 641 | $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
642 | 642 | |
643 | 643 | $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
644 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
645 | - 'data-event-format="' . $this->calendar->date_format . '">' . |
|
646 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
647 | - '</span> ' . |
|
648 | - $time_start . |
|
649 | - $time_end; |
|
644 | + 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
645 | + 'data-event-format="' . $this->calendar->date_format . '">' . |
|
646 | + date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
647 | + '</span> ' . |
|
648 | + $time_start . |
|
649 | + $time_end; |
|
650 | 650 | |
651 | 651 | } |
652 | 652 | |
@@ -705,11 +705,11 @@ discard block |
||
705 | 705 | } |
706 | 706 | |
707 | 707 | return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '" ' . |
708 | - 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '" ' . |
|
709 | - 'data-event-format="' . $dt_format . '" ' . |
|
710 | - 'itemprop="' . $bound . 'Date" data-content="' . $event_dt->toIso8601String() . '">' . |
|
711 | - $value . |
|
712 | - '</span>'; |
|
708 | + 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '" ' . |
|
709 | + 'data-event-format="' . $dt_format . '" ' . |
|
710 | + 'itemprop="' . $bound . 'Date" data-content="' . $event_dt->toIso8601String() . '">' . |
|
711 | + $value . |
|
712 | + '</span>'; |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | /** |
@@ -928,35 +928,35 @@ discard block |
||
928 | 928 | $tagregexp = implode( '|', array_values( $this->tags ) ); |
929 | 929 | |
930 | 930 | return '/' |
931 | - . '\\[' // Opening bracket |
|
932 | - . '(\\[?)' // 1: Optional second opening bracket for escaping tags: [[tag]] |
|
933 | - . "($tagregexp)" // 2: Tag name |
|
934 | - . '(?![\\w-])' // Not followed by word character or hyphen |
|
935 | - . '(' // 3: Unroll the loop: Inside the opening tag |
|
936 | - . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
937 | - . '(?:' |
|
938 | - . '\\/(?!\\])' // A forward slash not followed by a closing bracket |
|
939 | - . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
940 | - . ')*?' |
|
941 | - . ')' |
|
942 | - . '(?:' |
|
943 | - . '(\\/)' // 4: Self closing tag ... |
|
944 | - . '\\]' // ... and closing bracket |
|
945 | - . '|' |
|
946 | - . '\\]' // Closing bracket |
|
947 | - . '(?:' |
|
948 | - . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing tags |
|
949 | - . '[^\\[]*+' // Not an opening bracket |
|
950 | - . '(?:' |
|
951 | - . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag |
|
952 | - . '[^\\[]*+' // Not an opening bracket |
|
953 | - . ')*+' |
|
954 | - . ')' |
|
955 | - . '\\[\\/\\2\\]' // Closing tag |
|
956 | - . ')?' |
|
957 | - . ')' |
|
958 | - . '(\\]?)' // 6: Optional second closing bracket for escaping tags: [[tag]] |
|
959 | - . '/s'; |
|
931 | + . '\\[' // Opening bracket |
|
932 | + . '(\\[?)' // 1: Optional second opening bracket for escaping tags: [[tag]] |
|
933 | + . "($tagregexp)" // 2: Tag name |
|
934 | + . '(?![\\w-])' // Not followed by word character or hyphen |
|
935 | + . '(' // 3: Unroll the loop: Inside the opening tag |
|
936 | + . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
937 | + . '(?:' |
|
938 | + . '\\/(?!\\])' // A forward slash not followed by a closing bracket |
|
939 | + . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
940 | + . ')*?' |
|
941 | + . ')' |
|
942 | + . '(?:' |
|
943 | + . '(\\/)' // 4: Self closing tag ... |
|
944 | + . '\\]' // ... and closing bracket |
|
945 | + . '|' |
|
946 | + . '\\]' // Closing bracket |
|
947 | + . '(?:' |
|
948 | + . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing tags |
|
949 | + . '[^\\[]*+' // Not an opening bracket |
|
950 | + . '(?:' |
|
951 | + . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag |
|
952 | + . '[^\\[]*+' // Not an opening bracket |
|
953 | + . ')*+' |
|
954 | + . ')' |
|
955 | + . '\\[\\/\\2\\]' // Closing tag |
|
956 | + . ')?' |
|
957 | + . ')' |
|
958 | + . '(\\]?)' // 6: Optional second closing bracket for escaping tags: [[tag]] |
|
959 | + . '/s'; |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Carbon\Carbon; |
10 | 10 | use SimpleCalendar\Abstracts\Calendar; |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param Event $event |
55 | 55 | * @param Calendar $calendar |
56 | 56 | */ |
57 | - public function __construct( Event $event, Calendar $calendar ) { |
|
57 | + public function __construct(Event $event, Calendar $calendar) { |
|
58 | 58 | $this->event = $event; |
59 | 59 | $this->calendar = $calendar; |
60 | 60 | $this->tags = $this->get_content_tags(); |
@@ -74,84 +74,84 @@ discard block |
||
74 | 74 | * Content Tags * |
75 | 75 | * ============ */ |
76 | 76 | |
77 | - 'title', // The event title. |
|
78 | - 'event-title', // @deprecated An alias for 'title' tag. |
|
79 | - 'description', // The event description. |
|
80 | - |
|
81 | - 'when', // Date and time of the event. |
|
82 | - 'start-time', // Start time of the event. |
|
83 | - 'start-date', // Start date of the event. |
|
84 | - 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
85 | - 'start-human', // Start time in a human friendly format. |
|
86 | - 'end-time', // End time of the event. |
|
87 | - 'end-date', // End date of the event. |
|
88 | - 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
89 | - 'end-human', // End date-time in a human friendly format. |
|
90 | - |
|
91 | - 'duration', // How long the events lasts, in a human-readable format. |
|
92 | - 'length', // @deprecated An alias of 'duration' tag. |
|
93 | - |
|
94 | - 'location', // Alias of start-location. |
|
95 | - 'start-location', // Location name where the event starts. |
|
96 | - 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
97 | - 'start-location-link', // Link to Google Maps querying the event start location address. |
|
98 | - 'end-location', // Location name where the event ends. |
|
99 | - 'end-location-link', // Link to Google Maps querying the event end location address. |
|
100 | - |
|
101 | - 'link', // An HTML link to the event URL. |
|
102 | - 'url', // A string with the raw event link URL. |
|
103 | - |
|
104 | - 'calendar', // The title of the source calendar. |
|
105 | - 'feed-title', // @deprecated An alias of 'calendar'. |
|
106 | - |
|
107 | - 'id', // The event unique ID. |
|
108 | - 'uid', // An alias of ID. |
|
109 | - 'event-id', // @deprecated An alias for 'id' tag. |
|
110 | - 'calendar-id', // The calendar ID. |
|
111 | - 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
112 | - 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
77 | + 'title', // The event title. |
|
78 | + 'event-title', // @deprecated An alias for 'title' tag. |
|
79 | + 'description', // The event description. |
|
80 | + |
|
81 | + 'when', // Date and time of the event. |
|
82 | + 'start-time', // Start time of the event. |
|
83 | + 'start-date', // Start date of the event. |
|
84 | + 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
85 | + 'start-human', // Start time in a human friendly format. |
|
86 | + 'end-time', // End time of the event. |
|
87 | + 'end-date', // End date of the event. |
|
88 | + 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
89 | + 'end-human', // End date-time in a human friendly format. |
|
90 | + |
|
91 | + 'duration', // How long the events lasts, in a human-readable format. |
|
92 | + 'length', // @deprecated An alias of 'duration' tag. |
|
93 | + |
|
94 | + 'location', // Alias of start-location. |
|
95 | + 'start-location', // Location name where the event starts. |
|
96 | + 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
97 | + 'start-location-link', // Link to Google Maps querying the event start location address. |
|
98 | + 'end-location', // Location name where the event ends. |
|
99 | + 'end-location-link', // Link to Google Maps querying the event end location address. |
|
100 | + |
|
101 | + 'link', // An HTML link to the event URL. |
|
102 | + 'url', // A string with the raw event link URL. |
|
103 | + |
|
104 | + 'calendar', // The title of the source calendar. |
|
105 | + 'feed-title', // @deprecated An alias of 'calendar'. |
|
106 | + |
|
107 | + 'id', // The event unique ID. |
|
108 | + 'uid', // An alias of ID. |
|
109 | + 'event-id', // @deprecated An alias for 'id' tag. |
|
110 | + 'calendar-id', // The calendar ID. |
|
111 | + 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
112 | + 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
113 | 113 | |
114 | 114 | /* ========= * |
115 | 115 | * Meta Tags * |
116 | 116 | * ========= */ |
117 | 117 | |
118 | - 'attachments', // List of attachments. |
|
119 | - 'attendees', // List of attendees. |
|
120 | - 'organizer', // Creator info. |
|
118 | + 'attachments', // List of attachments. |
|
119 | + 'attendees', // List of attendees. |
|
120 | + 'organizer', // Creator info. |
|
121 | 121 | |
122 | 122 | /* ================ * |
123 | 123 | * Conditional Tags * |
124 | 124 | * ================ */ |
125 | 125 | |
126 | - 'if-title', // If the event has a title. |
|
127 | - 'if-description', // If the event has a description. |
|
128 | - |
|
129 | - 'if-now', // If the event is taking place now. |
|
130 | - 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
131 | - 'if-started', // If the event has started (and may as well as ended). |
|
132 | - 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
133 | - 'if-ended', // If the event has ended (event could be any time in the past). |
|
134 | - 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
135 | - |
|
136 | - 'if-whole-day', // If the event lasts the whole day. |
|
137 | - 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
138 | - 'if-not-whole-day', // If the event does NOT last the whole day. |
|
139 | - 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
140 | - 'if-end-time', // If the event has a set end time. |
|
141 | - 'if-no-end-time', // If the event has NOT a set end time. |
|
142 | - |
|
143 | - 'if-multi-day', // If the event spans multiple days. |
|
144 | - 'if-single-day', // If the event does not span multiple days. |
|
145 | - |
|
146 | - 'if-recurring', // If the event is a recurring event. |
|
147 | - 'if-not-recurring', // If the event is NOT a recurring event. |
|
148 | - |
|
149 | - 'if-location', // @deprecated Alias for 'if-start-location'. |
|
150 | - 'if-start-location', // Does the event has a start location? |
|
151 | - 'if-end-location', // Does the event has an end location? |
|
152 | - 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
126 | + 'if-title', // If the event has a title. |
|
127 | + 'if-description', // If the event has a description. |
|
128 | + |
|
129 | + 'if-now', // If the event is taking place now. |
|
130 | + 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
131 | + 'if-started', // If the event has started (and may as well as ended). |
|
132 | + 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
133 | + 'if-ended', // If the event has ended (event could be any time in the past). |
|
134 | + 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
135 | + |
|
136 | + 'if-whole-day', // If the event lasts the whole day. |
|
137 | + 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
138 | + 'if-not-whole-day', // If the event does NOT last the whole day. |
|
139 | + 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
140 | + 'if-end-time', // If the event has a set end time. |
|
141 | + 'if-no-end-time', // If the event has NOT a set end time. |
|
142 | + |
|
143 | + 'if-multi-day', // If the event spans multiple days. |
|
144 | + 'if-single-day', // If the event does not span multiple days. |
|
145 | + |
|
146 | + 'if-recurring', // If the event is a recurring event. |
|
147 | + 'if-not-recurring', // If the event is NOT a recurring event. |
|
148 | + |
|
149 | + 'if-location', // @deprecated Alias for 'if-start-location'. |
|
150 | + 'if-start-location', // Does the event has a start location? |
|
151 | + 'if-end-location', // Does the event has an end location? |
|
152 | + 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
153 | 153 | 'if-not-start-location', // Does the event has NOT a start location? |
154 | - 'if-not-end-location', // Does the event has NOT an end location? |
|
154 | + 'if-not-end-location', // Does the event has NOT an end location? |
|
155 | 155 | |
156 | 156 | ); |
157 | 157 | } |
@@ -165,19 +165,19 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return string |
167 | 167 | */ |
168 | - public function parse_event_template_tags( $template_tags = '' ) { |
|
168 | + public function parse_event_template_tags($template_tags = '') { |
|
169 | 169 | |
170 | 170 | // Process tags. |
171 | 171 | $result = preg_replace_callback( |
172 | 172 | $this->get_regex(), |
173 | - array( $this, 'process_event_content' ), |
|
173 | + array($this, 'process_event_content'), |
|
174 | 174 | $template_tags |
175 | 175 | ); |
176 | 176 | |
177 | 177 | // Removes extra consecutive <br> tags. |
178 | 178 | // TODO: Doesn't seem to work but going to remove it to allow multiple <br> tags in the editor |
179 | 179 | /*return preg_replace( '#(<br *//*?>\s*)+#i', '<br />', trim( $result ) );*/ |
180 | - return trim( $result ); |
|
180 | + return trim($result); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - public function process_event_content( $match ) { |
|
192 | + public function process_event_content($match) { |
|
193 | 193 | |
194 | - if ( $match[1] == '[' && $match[6] == ']' ) { |
|
195 | - return substr( $match[0], 1, - 1 ); |
|
194 | + if ($match[1] == '[' && $match[6] == ']') { |
|
195 | + return substr($match[0], 1, - 1); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $tag = $match[2]; // Tag name without square brackets. |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | $calendar = $this->calendar; |
205 | 205 | $event = $this->event; |
206 | 206 | |
207 | - if ( ( $calendar instanceof Calendar ) && ( $event instanceof Event ) ) { |
|
207 | + if (($calendar instanceof Calendar) && ($event instanceof Event)) { |
|
208 | 208 | |
209 | - switch ( $tag ) { |
|
209 | + switch ($tag) { |
|
210 | 210 | |
211 | 211 | /* ============ * |
212 | 212 | * Content Tags * |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | |
215 | 215 | case 'title' : |
216 | 216 | case 'event-title' : |
217 | - return $this->get_title( $event->title, $attr ); |
|
217 | + return $this->get_title($event->title, $attr); |
|
218 | 218 | |
219 | 219 | case 'description' : |
220 | - return $this->get_description( $event->description, $attr ); |
|
220 | + return $this->get_description($event->description, $attr); |
|
221 | 221 | |
222 | 222 | case 'when' : |
223 | - return $this->get_when( $event ); |
|
223 | + return $this->get_when($event); |
|
224 | 224 | |
225 | 225 | case 'end-date' : |
226 | 226 | case 'end-custom' : |
@@ -230,40 +230,40 @@ discard block |
||
230 | 230 | case 'start-date' : |
231 | 231 | case 'start-human' : |
232 | 232 | case 'start-time' : |
233 | - return $this->get_dt( $tag, $event, $attr ); |
|
233 | + return $this->get_dt($tag, $event, $attr); |
|
234 | 234 | |
235 | 235 | case 'length' : |
236 | 236 | case 'duration' : |
237 | - if ( false !== $event->end ) { |
|
237 | + if (false !== $event->end) { |
|
238 | 238 | $duration = $event->start - $event->end; |
239 | - $value = human_time_diff( $event->start, $event->end ); |
|
239 | + $value = human_time_diff($event->start, $event->end); |
|
240 | 240 | } else { |
241 | 241 | $duration = '-1'; |
242 | - $value = __( 'No end time', 'google-calendar-events' ); |
|
242 | + $value = __('No end time', 'google-calendar-events'); |
|
243 | 243 | } |
244 | - return ' <span class="simcal-event-duration" data-event-duration="' . $duration . '">' . $value . '</span>'; |
|
244 | + return ' <span class="simcal-event-duration" data-event-duration="'.$duration.'">'.$value.'</span>'; |
|
245 | 245 | |
246 | 246 | case 'location' : |
247 | 247 | case 'start-location' : |
248 | 248 | case 'end-location' : |
249 | 249 | $location = $tag == 'end-location' ? $event->end_location['address'] : $event->start_location['address']; |
250 | 250 | $location_class = $tag == 'end-location' ? 'end' : 'start'; |
251 | - return ' <span class="simcal-event-address simcal-event-' . $location_class . '-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . wp_strip_all_tags( $location ) . '</span>'; |
|
251 | + return ' <span class="simcal-event-address simcal-event-'.$location_class.'-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'.wp_strip_all_tags($location).'</span>'; |
|
252 | 252 | |
253 | 253 | case 'start-location-link': |
254 | 254 | case 'end-location-link' : |
255 | 255 | case 'maps-link' : |
256 | 256 | $location = $tag == 'end-location-link' ? $event->end_location['address'] : $event->start_location['address']; |
257 | - if ( ! empty( $location ) ) { |
|
258 | - $url = '//maps.google.com?q=' . urlencode( $location ); |
|
259 | - return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr ); |
|
257 | + if ( ! empty($location)) { |
|
258 | + $url = '//maps.google.com?q='.urlencode($location); |
|
259 | + return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr); |
|
260 | 260 | } |
261 | 261 | break; |
262 | 262 | |
263 | 263 | case 'link' : |
264 | 264 | case 'url' : |
265 | - $content = 'link' == $tag ? $calendar->get_event_html( $event, $partial ) : ''; |
|
266 | - return $this->make_link( $tag, $event->link, $content , $attr ); |
|
265 | + $content = 'link' == $tag ? $calendar->get_event_html($event, $partial) : ''; |
|
266 | + return $this->make_link($tag, $event->link, $content, $attr); |
|
267 | 267 | |
268 | 268 | case 'calendar' : |
269 | 269 | case 'feed-title' : |
@@ -285,22 +285,22 @@ discard block |
||
285 | 285 | |
286 | 286 | case 'attachments' : |
287 | 287 | $attachments = $event->get_attachments(); |
288 | - if ( ! empty( $attachments ) ) { |
|
289 | - return $this->get_attachments( $attachments ); |
|
288 | + if ( ! empty($attachments)) { |
|
289 | + return $this->get_attachments($attachments); |
|
290 | 290 | } |
291 | 291 | break; |
292 | 292 | |
293 | 293 | case 'attendees' : |
294 | 294 | $attendees = $event->get_attendees(); |
295 | - if ( ! empty( $attendees ) ) { |
|
296 | - return $this->get_attendees( $attendees, $attr ); |
|
295 | + if ( ! empty($attendees)) { |
|
296 | + return $this->get_attendees($attendees, $attr); |
|
297 | 297 | } |
298 | 298 | break; |
299 | 299 | |
300 | 300 | case 'organizer' : |
301 | 301 | $organizer = $event->get_organizer(); |
302 | - if ( ! empty( $organizer ) ) { |
|
303 | - return $this->get_organizer( $organizer, $attr ); |
|
302 | + if ( ! empty($organizer)) { |
|
303 | + return $this->get_organizer($organizer, $attr); |
|
304 | 304 | } |
305 | 305 | break; |
306 | 306 | |
@@ -309,35 +309,35 @@ discard block |
||
309 | 309 | * ================ */ |
310 | 310 | |
311 | 311 | case 'if-title': |
312 | - if ( ! empty( $event->title ) ) { |
|
313 | - return $calendar->get_event_html( $event, $partial ); |
|
312 | + if ( ! empty($event->title)) { |
|
313 | + return $calendar->get_event_html($event, $partial); |
|
314 | 314 | } |
315 | 315 | break; |
316 | 316 | |
317 | 317 | case 'if-description': |
318 | - if ( ! empty( $event->description ) ) { |
|
319 | - return $calendar->get_event_html( $event, $partial ); |
|
318 | + if ( ! empty($event->description)) { |
|
319 | + return $calendar->get_event_html($event, $partial); |
|
320 | 320 | } |
321 | 321 | break; |
322 | 322 | |
323 | 323 | case 'if-now' : |
324 | 324 | case 'if-not-now' : |
325 | 325 | |
326 | - $start_dt = $event->start_dt->setTimezone( $calendar->timezone ); |
|
326 | + $start_dt = $event->start_dt->setTimezone($calendar->timezone); |
|
327 | 327 | $start = $start_dt->getTimestamp(); |
328 | 328 | |
329 | - if ( $event->end_dt instanceof Carbon ) { |
|
330 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
329 | + if ($event->end_dt instanceof Carbon) { |
|
330 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
331 | 331 | } else { |
332 | 332 | return ''; |
333 | 333 | } |
334 | 334 | |
335 | - $now = ( $start <= $calendar->now ) && ( $end >= $calendar->now ); |
|
335 | + $now = ($start <= $calendar->now) && ($end >= $calendar->now); |
|
336 | 336 | |
337 | - if ( ( 'if-now' == $tag ) && $now ) { |
|
338 | - return $calendar->get_event_html( $event, $partial ); |
|
339 | - } elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) { |
|
340 | - return $calendar->get_event_html( $event, $partial ); |
|
337 | + if (('if-now' == $tag) && $now) { |
|
338 | + return $calendar->get_event_html($event, $partial); |
|
339 | + } elseif (('if-not-now' == $tag) && (false == $now)) { |
|
340 | + return $calendar->get_event_html($event, $partial); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | break; |
@@ -345,15 +345,15 @@ discard block |
||
345 | 345 | case 'if-started' : |
346 | 346 | case 'if-not-started' : |
347 | 347 | |
348 | - $start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
348 | + $start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
349 | 349 | |
350 | - if ( 'if-started' == $tag ) { |
|
351 | - if ( $start < $calendar->now ) { |
|
352 | - return $calendar->get_event_html( $event, $partial ); |
|
350 | + if ('if-started' == $tag) { |
|
351 | + if ($start < $calendar->now) { |
|
352 | + return $calendar->get_event_html($event, $partial); |
|
353 | 353 | } |
354 | - } elseif ( 'if-not-started' == $tag ) { |
|
355 | - if ( $start > $calendar->now ) { |
|
356 | - return $calendar->get_event_html( $event, $partial ); |
|
354 | + } elseif ('if-not-started' == $tag) { |
|
355 | + if ($start > $calendar->now) { |
|
356 | + return $calendar->get_event_html($event, $partial); |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | |
@@ -362,17 +362,17 @@ discard block |
||
362 | 362 | case 'if-ended' : |
363 | 363 | case 'if-not-ended' : |
364 | 364 | |
365 | - if ( false !== $event->end ) { |
|
365 | + if (false !== $event->end) { |
|
366 | 366 | |
367 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
367 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
368 | 368 | |
369 | - if ( 'if-ended' == $tag ) { |
|
370 | - if ( $end < $calendar->now ) { |
|
371 | - return $calendar->get_event_html( $event, $partial ); |
|
369 | + if ('if-ended' == $tag) { |
|
370 | + if ($end < $calendar->now) { |
|
371 | + return $calendar->get_event_html($event, $partial); |
|
372 | 372 | } |
373 | - } elseif ( 'if-not-ended' == $tag ) { |
|
374 | - if ( $end > $calendar->now ) { |
|
375 | - return $calendar->get_event_html( $event, $partial ); |
|
373 | + } elseif ('if-not-ended' == $tag) { |
|
374 | + if ($end > $calendar->now) { |
|
375 | + return $calendar->get_event_html($event, $partial); |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
@@ -381,14 +381,14 @@ discard block |
||
381 | 381 | break; |
382 | 382 | |
383 | 383 | case 'if-end-time' : |
384 | - if ( false !== $event->end ) { |
|
385 | - return $calendar->get_event_html( $event, $partial ); |
|
384 | + if (false !== $event->end) { |
|
385 | + return $calendar->get_event_html($event, $partial); |
|
386 | 386 | } |
387 | 387 | break; |
388 | 388 | |
389 | 389 | case 'if-no-end-time' : |
390 | - if ( false === $event->end ) { |
|
391 | - return $calendar->get_event_html( $event, $partial ); |
|
390 | + if (false === $event->end) { |
|
391 | + return $calendar->get_event_html($event, $partial); |
|
392 | 392 | } |
393 | 393 | break; |
394 | 394 | |
@@ -396,59 +396,59 @@ discard block |
||
396 | 396 | case 'if-whole-day' : |
397 | 397 | case 'if-not-all-day' : |
398 | 398 | case 'if-not-whole-day' : |
399 | - $bool = strstr( $tag, 'not' ) ? false : true; |
|
400 | - if ( $bool === $event->whole_day ) { |
|
401 | - return $calendar->get_event_html( $event, $partial ); |
|
399 | + $bool = strstr($tag, 'not') ? false : true; |
|
400 | + if ($bool === $event->whole_day) { |
|
401 | + return $calendar->get_event_html($event, $partial); |
|
402 | 402 | } |
403 | 403 | break; |
404 | 404 | |
405 | 405 | case 'if-recurring' : |
406 | - if ( ! empty( $event->recurrence ) ) { |
|
407 | - return $calendar->get_event_html( $event, $partial ); |
|
406 | + if ( ! empty($event->recurrence)) { |
|
407 | + return $calendar->get_event_html($event, $partial); |
|
408 | 408 | } |
409 | 409 | break; |
410 | 410 | |
411 | 411 | case 'if-not-recurring' : |
412 | - if ( false === $event->recurrence ) { |
|
413 | - return $calendar->get_event_html( $event, $partial ); |
|
412 | + if (false === $event->recurrence) { |
|
413 | + return $calendar->get_event_html($event, $partial); |
|
414 | 414 | } |
415 | 415 | break; |
416 | 416 | |
417 | 417 | case 'if-multi-day' : |
418 | - if ( false !== $event->multiple_days ) { |
|
419 | - return $calendar->get_event_html( $event, $partial ); |
|
418 | + if (false !== $event->multiple_days) { |
|
419 | + return $calendar->get_event_html($event, $partial); |
|
420 | 420 | } |
421 | 421 | break; |
422 | 422 | |
423 | 423 | case 'if-single-day' : |
424 | - if ( false === $event->multiple_days ) { |
|
425 | - return $calendar->get_event_html( $event, $partial ); |
|
424 | + if (false === $event->multiple_days) { |
|
425 | + return $calendar->get_event_html($event, $partial); |
|
426 | 426 | } |
427 | 427 | break; |
428 | 428 | |
429 | 429 | case 'if-location' : |
430 | 430 | case 'if-start-location' : |
431 | - if ( ! empty( $event->start_location['address'] ) ) { |
|
432 | - return $calendar->get_event_html( $event, $partial ); |
|
431 | + if ( ! empty($event->start_location['address'])) { |
|
432 | + return $calendar->get_event_html($event, $partial); |
|
433 | 433 | } |
434 | 434 | return false; |
435 | 435 | |
436 | 436 | case 'if-not-location' : |
437 | 437 | case 'if-not-start-location' : |
438 | - if ( empty( $event->start_location['address'] ) ) { |
|
439 | - return $calendar->get_event_html( $event, $partial ); |
|
438 | + if (empty($event->start_location['address'])) { |
|
439 | + return $calendar->get_event_html($event, $partial); |
|
440 | 440 | } |
441 | 441 | return ''; |
442 | 442 | |
443 | 443 | case 'if-not-end-location' : |
444 | - if ( empty( $event->end_location['address'] ) ) { |
|
445 | - return $calendar->get_event_html( $event, $partial ); |
|
444 | + if (empty($event->end_location['address'])) { |
|
445 | + return $calendar->get_event_html($event, $partial); |
|
446 | 446 | } |
447 | 447 | return ''; |
448 | 448 | |
449 | 449 | case 'if-end-location' : |
450 | - if ( ! empty( $event->end_location['address'] ) ) { |
|
451 | - return $calendar->get_event_html( $event, $partial ); |
|
450 | + if ( ! empty($event->end_location['address'])) { |
|
451 | + return $calendar->get_event_html($event, $partial); |
|
452 | 452 | } |
453 | 453 | return ''; |
454 | 454 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * ======= */ |
458 | 458 | |
459 | 459 | default : |
460 | - return wp_kses_post( $before . $partial . $after ); |
|
460 | + return wp_kses_post($before.$partial.$after); |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | |
@@ -475,14 +475,14 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @return string |
477 | 477 | */ |
478 | - private function limit_words( $text, $limit ) { |
|
478 | + private function limit_words($text, $limit) { |
|
479 | 479 | |
480 | - $limit = max( absint( $limit ), 0 ); |
|
480 | + $limit = max(absint($limit), 0); |
|
481 | 481 | |
482 | - if ( $limit > 0 && ( str_word_count( $text, 0 ) > $limit ) ) { |
|
483 | - $words = str_word_count( $text, 2 ); |
|
484 | - $pos = array_keys( $words ); |
|
485 | - $text = trim( substr( $text, 0, $pos[ $limit ] ) ) . '…'; |
|
482 | + if ($limit > 0 && (str_word_count($text, 0) > $limit)) { |
|
483 | + $words = str_word_count($text, 2); |
|
484 | + $pos = array_keys($words); |
|
485 | + $text = trim(substr($text, 0, $pos[$limit])).'…'; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | return $text; |
@@ -499,26 +499,26 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return string |
501 | 501 | */ |
502 | - private function get_title( $title, $attr ) { |
|
502 | + private function get_title($title, $attr) { |
|
503 | 503 | |
504 | - if ( empty( $title ) ) { |
|
504 | + if (empty($title)) { |
|
505 | 505 | return ''; |
506 | 506 | } |
507 | 507 | |
508 | - $attr = array_merge( array( |
|
509 | - 'html' => '', // Parse HTML |
|
510 | - 'limit' => 0, // Trim length to amount of words |
|
511 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
508 | + $attr = array_merge(array( |
|
509 | + 'html' => '', // Parse HTML |
|
510 | + 'limit' => 0, // Trim length to amount of words |
|
511 | + ), (array) shortcode_parse_atts($attr)); |
|
512 | 512 | |
513 | - if ( ! empty( $attr['html'] ) ) { |
|
514 | - $title = wp_kses_post( $title ); |
|
513 | + if ( ! empty($attr['html'])) { |
|
514 | + $title = wp_kses_post($title); |
|
515 | 515 | $tag = 'div'; |
516 | 516 | } else { |
517 | - $title = $this->limit_words( $title, $attr['limit'] ); |
|
517 | + $title = $this->limit_words($title, $attr['limit']); |
|
518 | 518 | $tag = 'span'; |
519 | 519 | } |
520 | 520 | |
521 | - return '<' . $tag . ' class="simcal-event-title" itemprop="name">' . $title . '</' . $tag . '>'; |
|
521 | + return '<'.$tag.' class="simcal-event-title" itemprop="name">'.$title.'</'.$tag.'>'; |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -532,42 +532,42 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return string |
534 | 534 | */ |
535 | - private function get_description( $description, $attr ) { |
|
535 | + private function get_description($description, $attr) { |
|
536 | 536 | |
537 | - if ( empty( $description ) ) { |
|
537 | + if (empty($description)) { |
|
538 | 538 | return ''; |
539 | 539 | } |
540 | 540 | |
541 | - $attr = array_merge( array( |
|
542 | - 'limit' => 0, // Trim length to number of words |
|
543 | - 'html' => 'no', // Parse HTML content |
|
544 | - 'markdown' => 'no', // Parse Markdown content |
|
545 | - 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
546 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
541 | + $attr = array_merge(array( |
|
542 | + 'limit' => 0, // Trim length to number of words |
|
543 | + 'html' => 'no', // Parse HTML content |
|
544 | + 'markdown' => 'no', // Parse Markdown content |
|
545 | + 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
546 | + ), (array) shortcode_parse_atts($attr)); |
|
547 | 547 | |
548 | - $allow_html = 'no' != $attr['html'] ? true : false; |
|
548 | + $allow_html = 'no' != $attr['html'] ? true : false; |
|
549 | 549 | $allow_md = 'no' != $attr['markdown'] ? true : false; |
550 | 550 | |
551 | 551 | $html = '<div class="simcal-event-description" itemprop="description">'; |
552 | 552 | |
553 | 553 | // Markdown and HTML don't play well together, use one or the other in the same tag. |
554 | - if ( $allow_html || $allow_md ) { |
|
555 | - if ( $allow_html ) { |
|
556 | - $description = wp_kses_post( $description ); |
|
557 | - } elseif ( $allow_md ) { |
|
554 | + if ($allow_html || $allow_md) { |
|
555 | + if ($allow_html) { |
|
556 | + $description = wp_kses_post($description); |
|
557 | + } elseif ($allow_md) { |
|
558 | 558 | $markdown = new \Parsedown(); |
559 | - $description = $markdown->text( wp_strip_all_tags( $description ) ); |
|
559 | + $description = $markdown->text(wp_strip_all_tags($description)); |
|
560 | 560 | } |
561 | 561 | } else { |
562 | - $description = wpautop( $description ); |
|
562 | + $description = wpautop($description); |
|
563 | 563 | } |
564 | 564 | |
565 | - $description = $this->limit_words( $description, $attr['limit'] ); |
|
565 | + $description = $this->limit_words($description, $attr['limit']); |
|
566 | 566 | |
567 | - $html .= $description . '</div>'; |
|
567 | + $html .= $description.'</div>'; |
|
568 | 568 | |
569 | - if ( 'no' != $attr['autolink'] ) { |
|
570 | - $html = ' ' . make_clickable( $html ); |
|
569 | + if ('no' != $attr['autolink']) { |
|
570 | + $html = ' '.make_clickable($html); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | return $html; |
@@ -583,74 +583,74 @@ discard block |
||
583 | 583 | * |
584 | 584 | * @return string |
585 | 585 | */ |
586 | - private function get_when( Event $event ) { |
|
586 | + private function get_when(Event $event) { |
|
587 | 587 | |
588 | - $start = $event->start_dt->setTimezone( $event->timezone ); |
|
589 | - $end = ! is_null( $event->end_dt ) ? $event->end_dt->setTimezone( $event->timezone ) : null; |
|
588 | + $start = $event->start_dt->setTimezone($event->timezone); |
|
589 | + $end = ! is_null($event->end_dt) ? $event->end_dt->setTimezone($event->timezone) : null; |
|
590 | 590 | |
591 | 591 | $time_start = ''; |
592 | 592 | $time_end = ''; |
593 | 593 | |
594 | - if ( ! $event->whole_day ) { |
|
594 | + if ( ! $event->whole_day) { |
|
595 | 595 | |
596 | - $time_start = $this->calendar->datetime_separator . |
|
597 | - ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
598 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
599 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
600 | - 'itemprop="startDate" data-content="' . $start->toIso8601String() . '">' . |
|
601 | - date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
596 | + $time_start = $this->calendar->datetime_separator. |
|
597 | + ' <span class="simcal-event-start simcal-event-start-time" '. |
|
598 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
599 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
600 | + 'itemprop="startDate" data-content="'.$start->toIso8601String().'">'. |
|
601 | + date_i18n($this->calendar->time_format, $start->getTimestamp()). |
|
602 | 602 | '</span> '; |
603 | 603 | |
604 | - if ( $end instanceof Carbon ) { |
|
604 | + if ($end instanceof Carbon) { |
|
605 | 605 | |
606 | - $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . |
|
607 | - 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
608 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
609 | - 'itemprop="endDate" data-content="' . $end->toIso8601String() . '">' . |
|
610 | - date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
606 | + $time_end = ' <span class="simcal-event-end simcal-event-end-time" '. |
|
607 | + 'data-event-end="'.$end->getTimestamp().'" '. |
|
608 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
609 | + 'itemprop="endDate" data-content="'.$end->toIso8601String().'">'. |
|
610 | + date_i18n($this->calendar->time_format, $end->getTimestamp()). |
|
611 | 611 | '</span> '; |
612 | 612 | |
613 | 613 | } |
614 | 614 | |
615 | 615 | } |
616 | 616 | |
617 | - if ( $event->multiple_days ) { |
|
617 | + if ($event->multiple_days) { |
|
618 | 618 | |
619 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
620 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
621 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
622 | - 'itemprop="startDate" data-content="' . $start->toIso8601String() . '">' . |
|
623 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
624 | - '</span> ' . |
|
619 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
620 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
621 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
622 | + 'itemprop="startDate" data-content="'.$start->toIso8601String().'">'. |
|
623 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
624 | + '</span> '. |
|
625 | 625 | $time_start; |
626 | 626 | |
627 | - if ( $end instanceof Carbon ) { |
|
627 | + if ($end instanceof Carbon) { |
|
628 | 628 | |
629 | - $output .= '-' . |
|
630 | - ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
631 | - 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
632 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
633 | - 'itemprop="endDate" data-content="' . $end->toIso8601String() . '">' . |
|
634 | - date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
635 | - '</span> ' . |
|
629 | + $output .= '-'. |
|
630 | + ' <span class="simcal-event-start simcal-event-end-date" '. |
|
631 | + 'data-event-start="'.$end->getTimestamp().'" '. |
|
632 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
633 | + 'itemprop="endDate" data-content="'.$end->toIso8601String().'">'. |
|
634 | + date_i18n($this->calendar->date_format, $end->getTimestamp()). |
|
635 | + '</span> '. |
|
636 | 636 | $time_end; |
637 | 637 | } |
638 | 638 | |
639 | 639 | } else { |
640 | 640 | |
641 | - $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
|
641 | + $time_end = ! empty($time_start) && ! empty($time_end) ? ' - '.$time_end : ''; |
|
642 | 642 | |
643 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
644 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
645 | - 'data-event-format="' . $this->calendar->date_format . '">' . |
|
646 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
647 | - '</span> ' . |
|
648 | - $time_start . |
|
643 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
644 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
645 | + 'data-event-format="'.$this->calendar->date_format.'">'. |
|
646 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
647 | + '</span> '. |
|
648 | + $time_start. |
|
649 | 649 | $time_end; |
650 | 650 | |
651 | 651 | } |
652 | 652 | |
653 | - return trim( $output ); |
|
653 | + return trim($output); |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | /** |
@@ -665,50 +665,50 @@ discard block |
||
665 | 665 | * |
666 | 666 | * @return string |
667 | 667 | */ |
668 | - private function get_dt( $tag, Event $event, $attr ) { |
|
668 | + private function get_dt($tag, Event $event, $attr) { |
|
669 | 669 | |
670 | - $bound = 0 === strpos( $tag, 'end' ) ? 'end' : 'start'; |
|
671 | - if ( ( 'end' == $bound ) && ( false === $event->end ) ) { |
|
670 | + $bound = 0 === strpos($tag, 'end') ? 'end' : 'start'; |
|
671 | + if (('end' == $bound) && (false === $event->end)) { |
|
672 | 672 | return ''; |
673 | 673 | } |
674 | 674 | |
675 | - $dt = $bound . '_dt'; |
|
676 | - if ( ! $event->$dt instanceof Carbon ) { |
|
675 | + $dt = $bound.'_dt'; |
|
676 | + if ( ! $event->$dt instanceof Carbon) { |
|
677 | 677 | return ''; |
678 | 678 | } |
679 | - $event_dt = $event->$dt->setTimezone( $event->timezone ); |
|
679 | + $event_dt = $event->$dt->setTimezone($event->timezone); |
|
680 | 680 | |
681 | - $attr = array_merge( array( |
|
681 | + $attr = array_merge(array( |
|
682 | 682 | 'format' => '', |
683 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
683 | + ), (array) shortcode_parse_atts($attr)); |
|
684 | 684 | |
685 | - $format = ltrim( strstr( $tag, '-' ), '-' ); |
|
685 | + $format = ltrim(strstr($tag, '-'), '-'); |
|
686 | 686 | $dt_format = ''; |
687 | - if ( ! empty( $attr['format'] ) ) { |
|
688 | - $dt_format = esc_attr( wp_strip_all_tags( $attr['format'] ) ); |
|
689 | - } elseif ( 'date' == $format ) { |
|
687 | + if ( ! empty($attr['format'])) { |
|
688 | + $dt_format = esc_attr(wp_strip_all_tags($attr['format'])); |
|
689 | + } elseif ('date' == $format) { |
|
690 | 690 | $dt_format = $this->calendar->date_format; |
691 | - } elseif ( 'time' == $format ) { |
|
691 | + } elseif ('time' == $format) { |
|
692 | 692 | $dt_format = $this->calendar->time_format; |
693 | 693 | } |
694 | 694 | |
695 | - if ( 'human' == $format ) { |
|
696 | - $value = human_time_diff( $event_dt->getTimestamp(), Carbon::now( $event->timezone )->getTimestamp() ); |
|
695 | + if ('human' == $format) { |
|
696 | + $value = human_time_diff($event_dt->getTimestamp(), Carbon::now($event->timezone)->getTimestamp()); |
|
697 | 697 | |
698 | - if ( $event_dt->getTimestamp() < Carbon::now( $event->timezone )->getTimestamp() ) { |
|
699 | - $value .= ' ' . _x( 'ago', 'human date event builder code modifier', 'google-calendar-events' ); |
|
698 | + if ($event_dt->getTimestamp() < Carbon::now($event->timezone)->getTimestamp()) { |
|
699 | + $value .= ' '._x('ago', 'human date event builder code modifier', 'google-calendar-events'); |
|
700 | 700 | } else { |
701 | - $value .= ' ' . _x( 'from now', 'human date event builder code modifier', 'google-calendar-events' ); |
|
701 | + $value .= ' '._x('from now', 'human date event builder code modifier', 'google-calendar-events'); |
|
702 | 702 | } |
703 | 703 | } else { |
704 | - $value = date_i18n( $dt_format, $event_dt->getTimestamp() ); |
|
704 | + $value = date_i18n($dt_format, $event_dt->getTimestamp()); |
|
705 | 705 | } |
706 | 706 | |
707 | - return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '" ' . |
|
708 | - 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '" ' . |
|
709 | - 'data-event-format="' . $dt_format . '" ' . |
|
710 | - 'itemprop="' . $bound . 'Date" data-content="' . $event_dt->toIso8601String() . '">' . |
|
711 | - $value . |
|
707 | + return '<span class="simcal-event-'.$bound.' '.'simcal-event-'.$bound.'-'.$format.'" '. |
|
708 | + 'data-event-'.$bound.'="'.$event_dt->getTimestamp().'" '. |
|
709 | + 'data-event-format="'.$dt_format.'" '. |
|
710 | + 'itemprop="'.$bound.'Date" data-content="'.$event_dt->toIso8601String().'">'. |
|
711 | + $value. |
|
712 | 712 | '</span>'; |
713 | 713 | } |
714 | 714 | |
@@ -725,23 +725,23 @@ discard block |
||
725 | 725 | * |
726 | 726 | * @return string |
727 | 727 | */ |
728 | - private function make_link( $tag, $url, $content, $attr ) { |
|
728 | + private function make_link($tag, $url, $content, $attr) { |
|
729 | 729 | |
730 | - if ( empty( $url ) ) { |
|
730 | + if (empty($url)) { |
|
731 | 731 | return ''; |
732 | 732 | } |
733 | 733 | |
734 | - $text = empty( $content ) ? $url : $content; |
|
734 | + $text = empty($content) ? $url : $content; |
|
735 | 735 | |
736 | - $attr = array_merge( array( |
|
737 | - 'autolink' => false, // Convert url to link anchor |
|
738 | - 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
739 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
736 | + $attr = array_merge(array( |
|
737 | + 'autolink' => false, // Convert url to link anchor |
|
738 | + 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
739 | + ), (array) shortcode_parse_atts($attr)); |
|
740 | 740 | |
741 | 741 | $anchor = $tag != 'url' ? 'yes' : $attr['autolink']; |
742 | 742 | $target = $attr['newwindow'] !== false ? 'target="_blank"' : ''; |
743 | 743 | |
744 | - return $anchor !== false ? ' <a href="' . esc_url( $url ) . '" ' . $target . '>' . $text . '</a>' : ' ' . $text; |
|
744 | + return $anchor !== false ? ' <a href="'.esc_url($url).'" '.$target.'>'.$text.'</a>' : ' '.$text; |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -754,20 +754,20 @@ discard block |
||
754 | 754 | * |
755 | 755 | * @return string |
756 | 756 | */ |
757 | - private function get_attachments( $attachments ) { |
|
757 | + private function get_attachments($attachments) { |
|
758 | 758 | |
759 | - $html = '<ul class="simcal-attachments">' . "\n\t"; |
|
759 | + $html = '<ul class="simcal-attachments">'."\n\t"; |
|
760 | 760 | |
761 | - foreach ( $attachments as $attachment ) { |
|
761 | + foreach ($attachments as $attachment) { |
|
762 | 762 | $html .= '<li class="simcal-attachment">'; |
763 | - $html .= '<a href="' . $attachment['url'] . '" target="_blank">'; |
|
764 | - $html .= ! empty( $attachment['icon'] ) ? '<img src="' . $attachment['icon'] . '" />' : ''; |
|
765 | - $html .= '<span>' . $attachment['name'] . '</span>'; |
|
763 | + $html .= '<a href="'.$attachment['url'].'" target="_blank">'; |
|
764 | + $html .= ! empty($attachment['icon']) ? '<img src="'.$attachment['icon'].'" />' : ''; |
|
765 | + $html .= '<span>'.$attachment['name'].'</span>'; |
|
766 | 766 | $html .= '</a>'; |
767 | - $html .= '</li>' . "\n"; |
|
767 | + $html .= '</li>'."\n"; |
|
768 | 768 | } |
769 | 769 | |
770 | - $html .= '</ul>' . "\n"; |
|
770 | + $html .= '</ul>'."\n"; |
|
771 | 771 | |
772 | 772 | return $html; |
773 | 773 | } |
@@ -783,41 +783,41 @@ discard block |
||
783 | 783 | * |
784 | 784 | * @return string |
785 | 785 | */ |
786 | - private function get_attendees( $attendees, $attr ) { |
|
786 | + private function get_attendees($attendees, $attr) { |
|
787 | 787 | |
788 | - $attr = array_merge( array( |
|
789 | - 'photo' => 'show', // show/hide attendee photo |
|
790 | - 'email' => 'hide', // show/hide attendee email address |
|
791 | - 'rsvp' => 'hide', // show/hide rsvp response status |
|
792 | - 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
793 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
788 | + $attr = array_merge(array( |
|
789 | + 'photo' => 'show', // show/hide attendee photo |
|
790 | + 'email' => 'hide', // show/hide attendee email address |
|
791 | + 'rsvp' => 'hide', // show/hide rsvp response status |
|
792 | + 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
793 | + ), (array) shortcode_parse_atts($attr)); |
|
794 | 794 | |
795 | - $html = '<ul class="simcal-attendees" itemprop="attendees">' . "\n\t"; |
|
795 | + $html = '<ul class="simcal-attendees" itemprop="attendees">'."\n\t"; |
|
796 | 796 | |
797 | 797 | $known = 0; |
798 | 798 | $unknown = 0; |
799 | 799 | |
800 | - foreach ( $attendees as $attendee ) { |
|
800 | + foreach ($attendees as $attendee) { |
|
801 | 801 | |
802 | - if ( 'yes' == $attr['response'] && 'yes' != $attendee['response'] ) { |
|
802 | + if ('yes' == $attr['response'] && 'yes' != $attendee['response']) { |
|
803 | 803 | continue; |
804 | - } elseif ( 'no' == $attr['response'] && 'no' != $attendee['response'] ) { |
|
804 | + } elseif ('no' == $attr['response'] && 'no' != $attendee['response']) { |
|
805 | 805 | continue; |
806 | - } elseif ( 'maybe' == $attr['response'] && ! in_array( $attendee['response'], array( 'yes', 'maybe' ) ) ) { |
|
806 | + } elseif ('maybe' == $attr['response'] && ! in_array($attendee['response'], array('yes', 'maybe'))) { |
|
807 | 807 | continue; |
808 | 808 | } |
809 | 809 | |
810 | - if ( ! empty( $attendee['name'] ) ) { |
|
810 | + if ( ! empty($attendee['name'])) { |
|
811 | 811 | |
812 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $attendee['photo'] . '" itemprop="image" />' : ''; |
|
813 | - $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response( $attendee['response'] ) : ''; |
|
814 | - $guest = $photo . '<span itemprop="name">' . $attendee['name'] . $response . '</span>'; |
|
812 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$attendee['photo'].'" itemprop="image" />' : ''; |
|
813 | + $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response($attendee['response']) : ''; |
|
814 | + $guest = $photo.'<span itemprop="name">'.$attendee['name'].$response.'</span>'; |
|
815 | 815 | |
816 | - if ( ! empty( $attendee['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
817 | - $guest = sprintf( '<a href="mailto:' . $attendee['email'] . '" itemprop="email">%s</a>', $guest ); |
|
816 | + if ( ! empty($attendee['email']) && ('show' == $attr['email'])) { |
|
817 | + $guest = sprintf('<a href="mailto:'.$attendee['email'].'" itemprop="email">%s</a>', $guest); |
|
818 | 818 | } |
819 | 819 | |
820 | - $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">' . $guest . '</li>' . "\n"; |
|
820 | + $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">'.$guest.'</li>'."\n"; |
|
821 | 821 | |
822 | 822 | $known++; |
823 | 823 | |
@@ -828,21 +828,21 @@ discard block |
||
828 | 828 | } |
829 | 829 | } |
830 | 830 | |
831 | - if ( $unknown > 0 ) { |
|
832 | - if ( $known > 0 ) { |
|
831 | + if ($unknown > 0) { |
|
832 | + if ($known > 0) { |
|
833 | 833 | /* translators: One more person attending the event. */ |
834 | - $others = sprintf( _n( '1 more attendee', '%s more attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
834 | + $others = sprintf(_n('1 more attendee', '%s more attendees', $unknown, 'google-calendar-events'), $unknown); |
|
835 | 835 | } else { |
836 | 836 | /* translators: One or more persons attending the event whose name is unknown. */ |
837 | - $others = sprintf( _n( '1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
837 | + $others = sprintf(_n('1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events'), $unknown); |
|
838 | 838 | } |
839 | - $photo = $attr['photo'] !== 'hide' ? get_avatar( '', 128 ) : ''; |
|
840 | - $html .= '<li class="simcal-attendee simcal-attendee-anonymous">' . $photo . '<span>' . $others . '</span></li>' . "\n"; |
|
841 | - } elseif ( $known === 0 ) { |
|
842 | - $html .= '<li class="simcal-attendee">' . _x( 'No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events' ) . '</li>' . "\n"; |
|
839 | + $photo = $attr['photo'] !== 'hide' ? get_avatar('', 128) : ''; |
|
840 | + $html .= '<li class="simcal-attendee simcal-attendee-anonymous">'.$photo.'<span>'.$others.'</span></li>'."\n"; |
|
841 | + } elseif ($known === 0) { |
|
842 | + $html .= '<li class="simcal-attendee">'._x('No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events').'</li>'."\n"; |
|
843 | 843 | } |
844 | 844 | |
845 | - $html .= '</ul>' . "\n"; |
|
845 | + $html .= '</ul>'."\n"; |
|
846 | 846 | |
847 | 847 | return $html; |
848 | 848 | } |
@@ -856,23 +856,23 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @return string |
858 | 858 | */ |
859 | - private function get_rsvp_response( $response ) { |
|
859 | + private function get_rsvp_response($response) { |
|
860 | 860 | |
861 | - if ( 'yes' == $response ) { |
|
861 | + if ('yes' == $response) { |
|
862 | 862 | /* translators: Someone replied with 'yes' to a rsvp request. */ |
863 | - $rsvp = __( 'Attending', 'google-calendar-events' ); |
|
864 | - } elseif ( 'no' == $response ) { |
|
863 | + $rsvp = __('Attending', 'google-calendar-events'); |
|
864 | + } elseif ('no' == $response) { |
|
865 | 865 | /* translators: Someone replied with 'no' to a rsvp request. */ |
866 | - $rsvp = __( 'Not attending', 'google-calendar-events' ); |
|
867 | - } elseif ( 'maybe' == $response ) { |
|
866 | + $rsvp = __('Not attending', 'google-calendar-events'); |
|
867 | + } elseif ('maybe' == $response) { |
|
868 | 868 | /* translators: Someone replied with 'maybe' to a rsvp request. */ |
869 | - $rsvp = __( 'Maybe attending', 'google-calendar-events' ); |
|
869 | + $rsvp = __('Maybe attending', 'google-calendar-events'); |
|
870 | 870 | } else { |
871 | 871 | /* translators: Someone did not send yet a rsvp confirmation to join an event. */ |
872 | - $rsvp = __( 'Response pending', 'google-calendar-events' ); |
|
872 | + $rsvp = __('Response pending', 'google-calendar-events'); |
|
873 | 873 | } |
874 | 874 | |
875 | - return ' <small>(' . $rsvp . ')</small>'; |
|
875 | + return ' <small>('.$rsvp.')</small>'; |
|
876 | 876 | } |
877 | 877 | |
878 | 878 | /** |
@@ -886,21 +886,21 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @return string |
888 | 888 | */ |
889 | - private function get_organizer( $organizer, $attr ) { |
|
889 | + private function get_organizer($organizer, $attr) { |
|
890 | 890 | |
891 | - $attr = array_merge( array( |
|
892 | - 'photo' => 'show', // show/hide attendee photo |
|
893 | - 'email' => 'hide', // show/hide attendee email address |
|
894 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
891 | + $attr = array_merge(array( |
|
892 | + 'photo' => 'show', // show/hide attendee photo |
|
893 | + 'email' => 'hide', // show/hide attendee email address |
|
894 | + ), (array) shortcode_parse_atts($attr)); |
|
895 | 895 | |
896 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $organizer['photo'] . '" itemprop="image" />' : ''; |
|
897 | - $organizer_html = $photo . '<span itemprop="name">' . $organizer['name'] . '</span>'; |
|
896 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$organizer['photo'].'" itemprop="image" />' : ''; |
|
897 | + $organizer_html = $photo.'<span itemprop="name">'.$organizer['name'].'</span>'; |
|
898 | 898 | |
899 | - if ( ! empty( $organizer['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
900 | - $organizer_html = sprintf( '<a href="mailto:' . $organizer['email'] . '" itemprop="email">%s</a>', $organizer_html ); |
|
899 | + if ( ! empty($organizer['email']) && ('show' == $attr['email'])) { |
|
900 | + $organizer_html = sprintf('<a href="mailto:'.$organizer['email'].'" itemprop="email">%s</a>', $organizer_html); |
|
901 | 901 | } |
902 | 902 | |
903 | - return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">' . $organizer_html . '</div>'; |
|
903 | + return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">'.$organizer_html.'</div>'; |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | /** |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | // This is largely borrowed on get_shortcode_regex() from WordPress Core. |
926 | 926 | // @see /wp-includes/shortcodes.php (with some modification) |
927 | 927 | |
928 | - $tagregexp = implode( '|', array_values( $this->tags ) ); |
|
928 | + $tagregexp = implode('|', array_values($this->tags)); |
|
929 | 929 | |
930 | 930 | return '/' |
931 | 931 | . '\\[' // Opening bracket |
@@ -108,7 +108,7 @@ |
||
108 | 108 | // Google query args. |
109 | 109 | $this->google_calendar_id = $this->esc_google_calendar_id( get_post_meta( $this->post_id, '_google_calendar_id', true ) ); |
110 | 110 | $this->google_events_recurring = esc_attr( get_post_meta( $this->post_id, '_google_events_recurring', true ) ); |
111 | - // note that google_search_query is used in a URL param and not as HTML output, so don't use esc_attr() on it |
|
111 | + // note that google_search_query is used in a URL param and not as HTML output, so don't use esc_attr() on it |
|
112 | 112 | $this->google_search_query = get_post_meta( $this->post_id, '_google_events_search_query', true ); |
113 | 113 | $this->google_max_results = max( absint( get_post_meta( $this->post_id, '_google_events_max_results', true ) ), 1 ); |
114 | 114 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use SimpleCalendar\Abstracts\Feed; |
13 | 13 | use SimpleCalendar\Feeds\Admin\Google_Admin as Admin; |
14 | 14 | |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -90,35 +90,35 @@ discard block |
||
90 | 90 | * @param string|Calendar $calendar |
91 | 91 | * @param bool $load_admin |
92 | 92 | */ |
93 | - public function __construct( $calendar = '', $load_admin = true ) { |
|
93 | + public function __construct($calendar = '', $load_admin = true) { |
|
94 | 94 | |
95 | - parent::__construct( $calendar ); |
|
95 | + parent::__construct($calendar); |
|
96 | 96 | |
97 | 97 | $this->type = 'google'; |
98 | - $this->name = __( 'Google Calendar', 'google-calendar-events' ); |
|
98 | + $this->name = __('Google Calendar', 'google-calendar-events'); |
|
99 | 99 | |
100 | 100 | // Google client config. |
101 | - $settings = get_option( 'simple-calendar_settings_feeds' ); |
|
102 | - $this->google_api_key = isset( $settings['google']['api_key'] ) ? esc_attr( $settings['google']['api_key'] ) : ''; |
|
103 | - $this->google_client_scopes = array( \Google_Service_Calendar::CALENDAR_READONLY ); |
|
101 | + $settings = get_option('simple-calendar_settings_feeds'); |
|
102 | + $this->google_api_key = isset($settings['google']['api_key']) ? esc_attr($settings['google']['api_key']) : ''; |
|
103 | + $this->google_client_scopes = array(\Google_Service_Calendar::CALENDAR_READONLY); |
|
104 | 104 | $this->google_client = $this->get_client(); |
105 | 105 | |
106 | - if ( $this->post_id > 0 ) { |
|
106 | + if ($this->post_id > 0) { |
|
107 | 107 | |
108 | 108 | // Google query args. |
109 | - $this->google_calendar_id = $this->esc_google_calendar_id( get_post_meta( $this->post_id, '_google_calendar_id', true ) ); |
|
110 | - $this->google_events_recurring = esc_attr( get_post_meta( $this->post_id, '_google_events_recurring', true ) ); |
|
109 | + $this->google_calendar_id = $this->esc_google_calendar_id(get_post_meta($this->post_id, '_google_calendar_id', true)); |
|
110 | + $this->google_events_recurring = esc_attr(get_post_meta($this->post_id, '_google_events_recurring', true)); |
|
111 | 111 | // note that google_search_query is used in a URL param and not as HTML output, so don't use esc_attr() on it |
112 | - $this->google_search_query = get_post_meta( $this->post_id, '_google_events_search_query', true ); |
|
113 | - $this->google_max_results = max( absint( get_post_meta( $this->post_id, '_google_events_max_results', true ) ), 1 ); |
|
112 | + $this->google_search_query = get_post_meta($this->post_id, '_google_events_search_query', true); |
|
113 | + $this->google_max_results = max(absint(get_post_meta($this->post_id, '_google_events_max_results', true)), 1); |
|
114 | 114 | |
115 | - if ( ! is_admin() || defined( 'DOING_AJAX' ) ) { |
|
116 | - $this->events = ! empty( $this->google_api_key ) ? $this->get_events() : array(); |
|
115 | + if ( ! is_admin() || defined('DOING_AJAX')) { |
|
116 | + $this->events = ! empty($this->google_api_key) ? $this->get_events() : array(); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - if ( is_admin() && $load_admin ) { |
|
121 | - $admin = new Admin( $this, $this->google_api_key, $this->google_calendar_id ); |
|
120 | + if (is_admin() && $load_admin) { |
|
121 | + $admin = new Admin($this, $this->google_api_key, $this->google_calendar_id); |
|
122 | 122 | $this->settings = $admin->settings_fields(); |
123 | 123 | } |
124 | 124 | } |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return string |
134 | 134 | */ |
135 | - public function esc_google_calendar_id( $id ) { |
|
136 | - return base64_decode( $id ); |
|
135 | + public function esc_google_calendar_id($id) { |
|
136 | + return base64_decode($id); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -147,66 +147,66 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function get_events() { |
149 | 149 | |
150 | - $calendar = get_transient( '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type ); |
|
150 | + $calendar = get_transient('_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type); |
|
151 | 151 | |
152 | - if ( empty( $calendar ) && ! empty( $this->google_calendar_id ) ) { |
|
152 | + if (empty($calendar) && ! empty($this->google_calendar_id)) { |
|
153 | 153 | |
154 | 154 | $error = ''; |
155 | 155 | |
156 | 156 | try { |
157 | - $response = $this->make_request( $this->google_calendar_id ); |
|
158 | - } catch ( \Exception $e ) { |
|
157 | + $response = $this->make_request($this->google_calendar_id); |
|
158 | + } catch (\Exception $e) { |
|
159 | 159 | $error .= $e->getMessage(); |
160 | 160 | } |
161 | 161 | |
162 | - if ( empty( $error ) && isset( $response['events'] ) && isset( $response['timezone'] ) ) { |
|
162 | + if (empty($error) && isset($response['events']) && isset($response['timezone'])) { |
|
163 | 163 | |
164 | - $calendar = array_merge( $response, array( 'events' => array() ) ); |
|
164 | + $calendar = array_merge($response, array('events' => array())); |
|
165 | 165 | |
166 | 166 | // If no timezone has been set, use calendar feed. |
167 | - if ( 'use_calendar' == $this->timezone_setting ) { |
|
167 | + if ('use_calendar' == $this->timezone_setting) { |
|
168 | 168 | $this->timezone = $calendar['timezone']; |
169 | 169 | } |
170 | 170 | |
171 | - $source = isset( $response['title'] ) ? sanitize_text_field( $response['title'] ) : ''; |
|
171 | + $source = isset($response['title']) ? sanitize_text_field($response['title']) : ''; |
|
172 | 172 | |
173 | - if ( ! empty( $response['events'] ) && is_array( $response['events'] ) ) { |
|
174 | - foreach ( $response['events'] as $event ) { |
|
175 | - if ( $event instanceof \Google_Service_Calendar_Event ) { |
|
173 | + if ( ! empty($response['events']) && is_array($response['events'])) { |
|
174 | + foreach ($response['events'] as $event) { |
|
175 | + if ($event instanceof \Google_Service_Calendar_Event) { |
|
176 | 176 | |
177 | 177 | // Visibility and status. |
178 | 178 | // Public calendars may have private events which can't be properly accessed by simple api key method. |
179 | 179 | // Also want to skip cancelled events (single occurences deleted from repeating events) |
180 | 180 | $visibility = $event->getVisibility(); |
181 | 181 | $status = $event->getStatus(); |
182 | - if ( $this->type == 'google' && ( $visibility == 'private' || $visibility == 'confidential' || $status == 'cancelled' ) ) { |
|
182 | + if ($this->type == 'google' && ($visibility == 'private' || $visibility == 'confidential' || $status == 'cancelled')) { |
|
183 | 183 | continue; |
184 | 184 | } |
185 | 185 | |
186 | 186 | // Event title & description. |
187 | - $title = strip_tags( $event->getSummary() ); |
|
188 | - $title = sanitize_text_field( iconv( mb_detect_encoding( $title, mb_detect_order(), true ), 'UTF-8', $title ) ); |
|
189 | - $description = wp_kses_post( iconv( mb_detect_encoding( $event->getDescription(), mb_detect_order(), true ), 'UTF-8', $event->getDescription() ) ); |
|
187 | + $title = strip_tags($event->getSummary()); |
|
188 | + $title = sanitize_text_field(iconv(mb_detect_encoding($title, mb_detect_order(), true), 'UTF-8', $title)); |
|
189 | + $description = wp_kses_post(iconv(mb_detect_encoding($event->getDescription(), mb_detect_order(), true), 'UTF-8', $event->getDescription())); |
|
190 | 190 | |
191 | 191 | $whole_day = false; |
192 | 192 | |
193 | 193 | // Event start properties. |
194 | - if( 'use_calendar' == $this->timezone_setting ) { |
|
194 | + if ('use_calendar' == $this->timezone_setting) { |
|
195 | 195 | $start_timezone = ! $event->getStart()->timeZone ? $calendar['timezone'] : $event->getStart()->timeZone; |
196 | 196 | } else { |
197 | 197 | $start_timezone = $this->timezone; |
198 | 198 | } |
199 | 199 | |
200 | - if ( is_null( $event->getStart()->dateTime ) ) { |
|
200 | + if (is_null($event->getStart()->dateTime)) { |
|
201 | 201 | // Whole day event. |
202 | - $date = Carbon::parse( $event->getStart()->date ); |
|
203 | - $google_start = Carbon::createFromDate( $date->year, $date->month, $date->day, $start_timezone )->startOfDay()->addSeconds( 59 ); |
|
204 | - $google_start_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->addSeconds( 59 ); |
|
202 | + $date = Carbon::parse($event->getStart()->date); |
|
203 | + $google_start = Carbon::createFromDate($date->year, $date->month, $date->day, $start_timezone)->startOfDay()->addSeconds(59); |
|
204 | + $google_start_utc = Carbon::createFromDate($date->year, $date->month, $date->day, 'UTC')->startOfDay()->addSeconds(59); |
|
205 | 205 | $whole_day = true; |
206 | 206 | } else { |
207 | - $date = Carbon::parse( $event->getStart()->dateTime ); |
|
208 | - $google_start = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $start_timezone ); |
|
209 | - $google_start_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' ); |
|
207 | + $date = Carbon::parse($event->getStart()->dateTime); |
|
208 | + $google_start = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $start_timezone); |
|
209 | + $google_start_utc = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC'); |
|
210 | 210 | } |
211 | 211 | // Start. |
212 | 212 | $start = $google_start->getTimestamp(); |
@@ -215,24 +215,24 @@ discard block |
||
215 | 215 | |
216 | 216 | $end = $end_utc = $end_timezone = ''; |
217 | 217 | $span = 0; |
218 | - if ( false == $event->getEndTimeUnspecified() ) { |
|
218 | + if (false == $event->getEndTimeUnspecified()) { |
|
219 | 219 | |
220 | 220 | // Event end properties. |
221 | - if( 'use_calendar' == $this->timezone_setting ) { |
|
221 | + if ('use_calendar' == $this->timezone_setting) { |
|
222 | 222 | $end_timezone = ! $event->getEnd()->timeZone ? $calendar['timezone'] : $event->getEnd()->timeZone; |
223 | 223 | } else { |
224 | 224 | $end_timezone = $this->timezone; |
225 | 225 | } |
226 | 226 | |
227 | - if ( is_null( $event->getEnd()->dateTime ) ) { |
|
227 | + if (is_null($event->getEnd()->dateTime)) { |
|
228 | 228 | // Whole day event. |
229 | - $date = Carbon::parse( $event->getEnd()->date ); |
|
230 | - $google_end = Carbon::createFromDate( $date->year, $date->month, $date->day, $end_timezone )->startOfDay()->subSeconds( 59 ); |
|
231 | - $google_end_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->subSeconds( 59 ); |
|
229 | + $date = Carbon::parse($event->getEnd()->date); |
|
230 | + $google_end = Carbon::createFromDate($date->year, $date->month, $date->day, $end_timezone)->startOfDay()->subSeconds(59); |
|
231 | + $google_end_utc = Carbon::createFromDate($date->year, $date->month, $date->day, 'UTC')->startOfDay()->subSeconds(59); |
|
232 | 232 | } else { |
233 | - $date = Carbon::parse( $event->getEnd()->dateTime ); |
|
234 | - $google_end = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $end_timezone ); |
|
235 | - $google_end_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' ); |
|
233 | + $date = Carbon::parse($event->getEnd()->dateTime); |
|
234 | + $google_end = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $end_timezone); |
|
235 | + $google_end_utc = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC'); |
|
236 | 236 | } |
237 | 237 | // End. |
238 | 238 | $end = $google_end->getTimestamp(); |
@@ -240,10 +240,10 @@ discard block |
||
240 | 240 | $end_utc = $google_end_utc->getTimestamp(); |
241 | 241 | |
242 | 242 | // Count multiple days. |
243 | - $span = $google_start->setTimezone( $calendar['timezone'] )->diffInDays( $google_end->setTimezone( $calendar['timezone'] ) ); |
|
243 | + $span = $google_start->setTimezone($calendar['timezone'])->diffInDays($google_end->setTimezone($calendar['timezone'])); |
|
244 | 244 | |
245 | - if ( $span == 0 ) { |
|
246 | - if ( $google_start->toDateString() !== $google_end->toDateString() ) { |
|
245 | + if ($span == 0) { |
|
246 | + if ($google_start->toDateString() !== $google_end->toDateString()) { |
|
247 | 247 | $span = 1; |
248 | 248 | } |
249 | 249 | } |
@@ -258,19 +258,19 @@ discard block |
||
258 | 258 | // Recurring event. |
259 | 259 | $recurrence = $event->getRecurrence(); |
260 | 260 | $recurring_id = $event->getRecurringEventId(); |
261 | - if ( ! $recurrence && $recurring_id ) { |
|
261 | + if ( ! $recurrence && $recurring_id) { |
|
262 | 262 | $recurrence = true; |
263 | 263 | } |
264 | 264 | |
265 | 265 | // Event link. |
266 | - if ( 'use_calendar' == $this->timezone_setting ) { |
|
267 | - $link = add_query_arg( array( 'ctz' => $this->timezone ), $event->getHtmlLink() ); |
|
266 | + if ('use_calendar' == $this->timezone_setting) { |
|
267 | + $link = add_query_arg(array('ctz' => $this->timezone), $event->getHtmlLink()); |
|
268 | 268 | } else { |
269 | 269 | $link = $event->getHtmlLink(); |
270 | 270 | } |
271 | 271 | |
272 | 272 | // Build the event. |
273 | - $calendar['events'][ intval( $start ) ][] = array( |
|
273 | + $calendar['events'][intval($start)][] = array( |
|
274 | 274 | 'type' => 'google-calendar', |
275 | 275 | 'source' => $source, |
276 | 276 | 'title' => $title, |
@@ -297,24 +297,24 @@ discard block |
||
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - if ( ! empty( $calendar['events'] ) ) { |
|
300 | + if ( ! empty($calendar['events'])) { |
|
301 | 301 | |
302 | - ksort( $calendar['events'], SORT_NUMERIC ); |
|
302 | + ksort($calendar['events'], SORT_NUMERIC); |
|
303 | 303 | |
304 | 304 | set_transient( |
305 | - '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type, |
|
305 | + '_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type, |
|
306 | 306 | $calendar, |
307 | - max( absint( $this->cache ), 1 ) // Since a value of 0 means forever we set the minimum here to 1 if the user has set it to be 0 |
|
307 | + max(absint($this->cache), 1) // Since a value of 0 means forever we set the minimum here to 1 if the user has set it to be 0 |
|
308 | 308 | ); |
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | 312 | } else { |
313 | 313 | |
314 | - $message = __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' ); |
|
315 | - $message .= '<br><br>' . $error . '<br><br>'; |
|
316 | - $message .= __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) . '<br><br>'; |
|
317 | - $message .= __( 'Only you can see this notice.', 'google-calendar-events' ); |
|
314 | + $message = __('While trying to retrieve events, Google returned an error:', 'google-calendar-events'); |
|
315 | + $message .= '<br><br>'.$error.'<br><br>'; |
|
316 | + $message .= __('Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events').'<br><br>'; |
|
317 | + $message .= __('Only you can see this notice.', 'google-calendar-events'); |
|
318 | 318 | |
319 | 319 | return $message; |
320 | 320 | } |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | } |
323 | 323 | |
324 | 324 | // If no timezone has been set, use calendar feed. |
325 | - if ( 'use_calendar' == $this->timezone_setting && isset( $calendar['timezone'] ) ) { |
|
325 | + if ('use_calendar' == $this->timezone_setting && isset($calendar['timezone'])) { |
|
326 | 326 | $this->timezone = $calendar['timezone']; |
327 | 327 | } |
328 | 328 | |
329 | - return isset( $calendar['events'] ) ? $calendar['events'] : array(); |
|
329 | + return isset($calendar['events']) ? $calendar['events'] : array(); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -342,67 +342,67 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @throws \Exception On request failure will throw an exception from Google. |
344 | 344 | */ |
345 | - public function make_request( $id = '', $time_min = 0, $time_max = 0 ) { |
|
345 | + public function make_request($id = '', $time_min = 0, $time_max = 0) { |
|
346 | 346 | |
347 | 347 | $calendar = array(); |
348 | 348 | $google = $this->get_service(); |
349 | 349 | |
350 | - if ( ! is_null( $google ) && ! empty( $id ) ) { |
|
350 | + if ( ! is_null($google) && ! empty($id)) { |
|
351 | 351 | |
352 | 352 | // Build the request args. |
353 | 353 | $args = array(); |
354 | 354 | |
355 | 355 | // Expand recurring events. |
356 | - if ( $this->google_events_recurring == 'show' ) { |
|
356 | + if ($this->google_events_recurring == 'show') { |
|
357 | 357 | $args['singleEvents'] = true; |
358 | 358 | } |
359 | 359 | |
360 | 360 | // Query events using search terms. |
361 | - if ( ! empty( $this->google_search_query ) ) { |
|
362 | - $args['q'] = rawurlencode( $this->google_search_query ); |
|
361 | + if ( ! empty($this->google_search_query)) { |
|
362 | + $args['q'] = rawurlencode($this->google_search_query); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | // Max results to query. |
366 | - $args['maxResults'] = strval( min( absint( $this->google_max_results ), 2500 ) ); |
|
366 | + $args['maxResults'] = strval(min(absint($this->google_max_results), 2500)); |
|
367 | 367 | |
368 | 368 | // Specify a timezone. |
369 | 369 | $timezone = ''; |
370 | - if ( 'use_calendar' != get_post_meta( $this->post_id, '_feed_timezone_setting', true ) ) { |
|
370 | + if ('use_calendar' != get_post_meta($this->post_id, '_feed_timezone_setting', true)) { |
|
371 | 371 | $args['timeZone'] = $timezone = $this->timezone; |
372 | 372 | } |
373 | 373 | |
374 | 374 | // Lower bound (inclusive) for an event's end time to filter by. |
375 | - $earliest_event = intval( $this->time_min ); |
|
376 | - if ( $earliest_event > 0 ) { |
|
375 | + $earliest_event = intval($this->time_min); |
|
376 | + if ($earliest_event > 0) { |
|
377 | 377 | $timeMin = Carbon::now(); |
378 | - if ( ! empty( $timezone ) ) { |
|
379 | - $timeMin->setTimezone( $timezone ); |
|
378 | + if ( ! empty($timezone)) { |
|
379 | + $timeMin->setTimezone($timezone); |
|
380 | 380 | } |
381 | - $timeMin->setTimestamp( $earliest_event ); |
|
381 | + $timeMin->setTimestamp($earliest_event); |
|
382 | 382 | $args['timeMin'] = $timeMin->toRfc3339String(); |
383 | 383 | } |
384 | 384 | |
385 | 385 | // Upper bound (exclusive) for an event's start time to filter by. |
386 | - $latest_event = intval( $this->time_max ); |
|
387 | - if ( $latest_event > 0 ) { |
|
386 | + $latest_event = intval($this->time_max); |
|
387 | + if ($latest_event > 0) { |
|
388 | 388 | $timeMax = Carbon::now(); |
389 | - if ( ! empty( $timezone ) ) { |
|
390 | - $timeMax->setTimezone( $timezone ); |
|
389 | + if ( ! empty($timezone)) { |
|
390 | + $timeMax->setTimezone($timezone); |
|
391 | 391 | } |
392 | - $timeMax->setTimestamp( $latest_event ); |
|
392 | + $timeMax->setTimestamp($latest_event); |
|
393 | 393 | $args['timeMax'] = $timeMax->toRfc3339String(); |
394 | 394 | } |
395 | 395 | |
396 | 396 | // Query events in calendar. |
397 | - $response = $google->events->listEvents( $id, $args ); |
|
397 | + $response = $google->events->listEvents($id, $args); |
|
398 | 398 | |
399 | - if ( $response instanceof \Google_Service_Calendar_Events ) { |
|
399 | + if ($response instanceof \Google_Service_Calendar_Events) { |
|
400 | 400 | $calendar = array( |
401 | 401 | 'id' => $id, |
402 | 402 | 'title' => $response->getSummary(), |
403 | 403 | 'description' => $response->getDescription(), |
404 | 404 | 'timezone' => $response->getTimeZone(), |
405 | - 'url' => esc_url( '//www.google.com/calendar/embed?src=' . $id ), |
|
405 | + 'url' => esc_url('//www.google.com/calendar/embed?src='.$id), |
|
406 | 406 | 'events' => $response->getItems(), |
407 | 407 | ); |
408 | 408 | } |
@@ -422,10 +422,10 @@ discard block |
||
422 | 422 | private function get_client() { |
423 | 423 | |
424 | 424 | $client = new \Google_Client(); |
425 | - $client->setApplicationName( 'Simple Calendar' ); |
|
426 | - $client->setScopes( $this->google_client_scopes ); |
|
427 | - $client->setDeveloperKey( $this->google_api_key ); |
|
428 | - $client->setAccessType( 'online' ); |
|
425 | + $client->setApplicationName('Simple Calendar'); |
|
426 | + $client->setScopes($this->google_client_scopes); |
|
427 | + $client->setDeveloperKey($this->google_api_key); |
|
428 | + $client->setAccessType('online'); |
|
429 | 429 | |
430 | 430 | return $client; |
431 | 431 | } |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | * @return null|\Google_Service_Calendar |
440 | 440 | */ |
441 | 441 | protected function get_service() { |
442 | - return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar( $this->google_client ) : null; |
|
442 | + return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar($this->google_client) : null; |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | } |