@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @package SimpleCalendar/Admin/Functions |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return null|\SimpleCalendar\Abstracts\Admin_Page |
34 | 34 | */ |
35 | -function simcal_get_admin_page( $page ) { |
|
35 | +function simcal_get_admin_page($page) { |
|
36 | 36 | $objects = \SimpleCalendar\plugin()->objects; |
37 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page( $page ) : null; |
|
37 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page($page) : null; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @return null|\SimpleCalendar\Abstracts\Field |
49 | 49 | */ |
50 | -function simcal_get_field( $args, $name = '' ) { |
|
50 | +function simcal_get_field($args, $name = '') { |
|
51 | 51 | $objects = \SimpleCalendar\plugin()->objects; |
52 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field( $args, $name ) : null; |
|
52 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field($args, $name) : null; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return void |
64 | 64 | */ |
65 | -function simcal_print_field( $args, $name = '' ) { |
|
65 | +function simcal_print_field($args, $name = '') { |
|
66 | 66 | |
67 | - $field = simcal_get_field( $args, $name ); |
|
67 | + $field = simcal_get_field($args, $name); |
|
68 | 68 | |
69 | - if ( $field instanceof \SimpleCalendar\Abstracts\Field ) { |
|
69 | + if ($field instanceof \SimpleCalendar\Abstracts\Field) { |
|
70 | 70 | $field->html(); |
71 | 71 | } |
72 | 72 | } |
@@ -84,33 +84,33 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return array|string Sanitized variable |
86 | 86 | */ |
87 | -function simcal_sanitize_input( $var, $func = 'sanitize_text_field' ) { |
|
87 | +function simcal_sanitize_input($var, $func = 'sanitize_text_field') { |
|
88 | 88 | |
89 | - if ( is_null( $var ) ) { |
|
89 | + if (is_null($var)) { |
|
90 | 90 | return ''; |
91 | 91 | } |
92 | 92 | |
93 | - if ( is_bool( $var ) ) { |
|
94 | - if ( $var === true ) { |
|
93 | + if (is_bool($var)) { |
|
94 | + if ($var === true) { |
|
95 | 95 | return 'yes'; |
96 | 96 | } else { |
97 | 97 | return 'no'; |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - if ( is_string( $var ) || is_numeric( $var ) ) { |
|
102 | - $func = is_string( $func ) && function_exists( $func ) ? $func : 'sanitize_text_field'; |
|
103 | - return call_user_func( $func, trim( strval( $var ) ) ); |
|
101 | + if (is_string($var) || is_numeric($var)) { |
|
102 | + $func = is_string($func) && function_exists($func) ? $func : 'sanitize_text_field'; |
|
103 | + return call_user_func($func, trim(strval($var))); |
|
104 | 104 | } |
105 | 105 | |
106 | - if ( is_object( $var ) ) { |
|
106 | + if (is_object($var)) { |
|
107 | 107 | $var = (array) $var; |
108 | 108 | } |
109 | 109 | |
110 | - if ( is_array( $var ) ) { |
|
110 | + if (is_array($var)) { |
|
111 | 111 | $array = array(); |
112 | - foreach ( $var as $k => $v ) { |
|
113 | - $array[ $k ] = simcal_sanitize_input( $v ); |
|
112 | + foreach ($var as $k => $v) { |
|
113 | + $array[$k] = simcal_sanitize_input($v); |
|
114 | 114 | } |
115 | 115 | return $array; |
116 | 116 | } |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | */ |
129 | 129 | function simcal_is_admin_screen() { |
130 | 130 | |
131 | - $view = function_exists( 'get_current_screen' ) ? get_current_screen() : false; |
|
131 | + $view = function_exists('get_current_screen') ? get_current_screen() : false; |
|
132 | 132 | |
133 | - if ( $view instanceof WP_Screen ) { |
|
133 | + if ($view instanceof WP_Screen) { |
|
134 | 134 | |
135 | 135 | // Screens used by this plugin. |
136 | 136 | $screens = array( |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'dashboard_page_simple-calendar_credits', |
146 | 146 | 'dashboard_page_simple-calendar_translators', |
147 | 147 | ); |
148 | - if ( in_array( $view->id, $screens ) ) { |
|
148 | + if (in_array($view->id, $screens)) { |
|
149 | 149 | return $view->id; |
150 | 150 | } |
151 | 151 | } |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return \SimpleCalendar\Admin\Updater |
166 | 166 | */ |
167 | -function simcal_addon_updater( $_api_url, $_plugin_file, $_api_data = null ) { |
|
168 | - return new \SimpleCalendar\Admin\Updater( $_api_url, $_plugin_file, $_api_data ); |
|
167 | +function simcal_addon_updater($_api_url, $_plugin_file, $_api_data = null) { |
|
168 | + return new \SimpleCalendar\Admin\Updater($_api_url, $_plugin_file, $_api_data); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return null|string |
179 | 179 | */ |
180 | -function simcal_get_license_key( $addon ) { |
|
181 | - $licenses = get_option( 'simple-calendar_settings_licenses', array() ); |
|
182 | - if ( isset( $licenses['keys'][ $addon ] ) ) { |
|
183 | - return empty( $licenses['keys'][ $addon ] ) ? null : $licenses['keys'][ $addon ]; |
|
180 | +function simcal_get_license_key($addon) { |
|
181 | + $licenses = get_option('simple-calendar_settings_licenses', array()); |
|
182 | + if (isset($licenses['keys'][$addon])) { |
|
183 | + return empty($licenses['keys'][$addon]) ? null : $licenses['keys'][$addon]; |
|
184 | 184 | } |
185 | 185 | return null; |
186 | 186 | } |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return array|string |
198 | 198 | */ |
199 | -function simcal_get_license_status( $addon = null ) { |
|
200 | - $licenses = get_option( 'simple-calendar_licenses_status', array() ); |
|
201 | - return isset( $licenses[ $addon ] ) ? $licenses[ $addon ] : $licenses; |
|
199 | +function simcal_get_license_status($addon = null) { |
|
200 | + $licenses = get_option('simple-calendar_licenses_status', array()); |
|
201 | + return isset($licenses[$addon]) ? $licenses[$addon] : $licenses; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @since 3.0.0 |
220 | 220 | */ |
221 | 221 | function simcal_delete_admin_notices() { |
222 | - delete_option( 'simple-calendar_admin_notices' ); |
|
222 | + delete_option('simple-calendar_admin_notices'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -231,22 +231,22 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return void |
233 | 233 | */ |
234 | -function simcal_print_shortcode_tip( $post_id ) { |
|
234 | +function simcal_print_shortcode_tip($post_id) { |
|
235 | 235 | |
236 | 236 | $browser = new \Browser(); |
237 | - if ( $browser::PLATFORM_APPLE == $browser->getPlatform() ) { |
|
237 | + if ($browser::PLATFORM_APPLE == $browser->getPlatform()) { |
|
238 | 238 | $cmd = '⌘+C'; |
239 | 239 | } else { |
240 | 240 | $cmd = 'Ctrl+C'; |
241 | 241 | } |
242 | 242 | |
243 | - $shortcut = sprintf( __( 'Press %s to copy.', 'google-calendar-events' ), $cmd ); |
|
244 | - $shortcode = sprintf( '[calendar id="%s"]', $post_id ); |
|
243 | + $shortcut = sprintf(__('Press %s to copy.', 'google-calendar-events'), $cmd); |
|
244 | + $shortcode = sprintf('[calendar id="%s"]', $post_id); |
|
245 | 245 | |
246 | - echo "<input readonly='readonly' " . |
|
247 | - "class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' " . |
|
248 | - "title='" . $shortcut . "' " . |
|
249 | - "onclick='this.select();' value='" . $shortcode . "' />"; |
|
246 | + echo "<input readonly='readonly' ". |
|
247 | + "class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' ". |
|
248 | + "title='".$shortcut."' ". |
|
249 | + "onclick='this.select();' value='".$shortcode."' />"; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -261,20 +261,20 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return string $url Full Google Analytics campaign URL |
263 | 263 | */ |
264 | -function simcal_ga_campaign_url( $base_url, $campaign, $content, $raw = false ) { |
|
264 | +function simcal_ga_campaign_url($base_url, $campaign, $content, $raw = false) { |
|
265 | 265 | |
266 | - $url = add_query_arg( array( |
|
266 | + $url = add_query_arg(array( |
|
267 | 267 | 'utm_source' => 'inside-plugin', |
268 | 268 | 'utm_medium' => 'link', |
269 | 269 | 'utm_campaign' => $campaign, // i.e. 'core-plugin', 'gcal-pro' |
270 | 270 | 'utm_content' => $content // i.e. 'sidebar-link', 'settings-link' |
271 | - ), $base_url ); |
|
271 | + ), $base_url); |
|
272 | 272 | |
273 | - if ( $raw ) { |
|
274 | - return esc_url_raw( $url ); |
|
273 | + if ($raw) { |
|
274 | + return esc_url_raw($url); |
|
275 | 275 | } |
276 | 276 | |
277 | - return esc_url( $url ); |
|
277 | + return esc_url($url); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | function simcal_newsletter_signup() { |
288 | 288 | |
289 | - if ( $screen = simcal_is_admin_screen() ) { |
|
289 | + if ($screen = simcal_is_admin_screen()) { |
|
290 | 290 | |
291 | 291 | global $current_user; |
292 | 292 | get_currentuserinfo(); |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | <div id="simcal-drip" class="<?php echo $screen; ?>"> |
298 | 298 | <div class="signup"> |
299 | 299 | <p> |
300 | - <?php _e( "Enter your name and email and we'll send you a coupon code for 20% off our Google Calendar Pro add-on.", 'google-calendar-events' ); ?> |
|
300 | + <?php _e("Enter your name and email and we'll send you a coupon code for 20% off our Google Calendar Pro add-on.", 'google-calendar-events'); ?> |
|
301 | 301 | </p> |
302 | 302 | |
303 | 303 | <p> |
304 | - <label for="simcal-drip-field-email"><?php _e( 'Your Email', 'google-calendar-events' ); ?></label><br /> |
|
304 | + <label for="simcal-drip-field-email"><?php _e('Your Email', 'google-calendar-events'); ?></label><br /> |
|
305 | 305 | <input type="email" |
306 | 306 | id="simcal-drip-field-email" |
307 | 307 | name="fields[email]" |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | </p> |
310 | 310 | |
311 | 311 | <p> |
312 | - <label for="simcal-drip-field-first_name"><?php _e( 'First Name', 'google-calendar-events' ); ?></label><br /> |
|
312 | + <label for="simcal-drip-field-first_name"><?php _e('First Name', 'google-calendar-events'); ?></label><br /> |
|
313 | 313 | <input type="text" |
314 | 314 | id="simcal-drip-field-first_name" |
315 | 315 | name="fields[first_name]" |
@@ -318,15 +318,15 @@ discard block |
||
318 | 318 | <p class="textright"> |
319 | 319 | <a href="#" |
320 | 320 | id="simcal-drip-signup" |
321 | - class="button button-primary"><?php _e( 'Send me the coupon', 'google-calendar-events' ); ?></a> |
|
321 | + class="button button-primary"><?php _e('Send me the coupon', 'google-calendar-events'); ?></a> |
|
322 | 322 | </p> |
323 | 323 | <div class="textright"> |
324 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'sidebar-link' ); ?>" |
|
325 | - target="_blank"><?php _e( 'Just take me to GCal Pro', 'google-calendar-events' ); ?></a> |
|
324 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'sidebar-link'); ?>" |
|
325 | + target="_blank"><?php _e('Just take me to GCal Pro', 'google-calendar-events'); ?></a> |
|
326 | 326 | </div> |
327 | 327 | </div> |
328 | 328 | <div class="thank-you" style="display: none;"> |
329 | - <?php _e( 'Thank you!', 'google-calendar-events' ); ?> |
|
329 | + <?php _e('Thank you!', 'google-calendar-events'); ?> |
|
330 | 330 | </div> |
331 | 331 | <div class="clear"> |
332 | 332 | </div> |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | |
338 | 338 | } |
339 | 339 | |
340 | -if ( ! function_exists( 'mb_detect_encoding' ) ) { |
|
340 | +if ( ! function_exists('mb_detect_encoding')) { |
|
341 | 341 | |
342 | 342 | /** |
343 | 343 | * Fallback function for `mb_detect_encoding()`, |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return bool |
353 | 353 | */ |
354 | - function mb_detect_encoding( $string, $enc = null, $ret = null ) { |
|
354 | + function mb_detect_encoding($string, $enc = null, $ret = null) { |
|
355 | 355 | |
356 | 356 | static $enclist = array( |
357 | 357 | 'UTF-8', |
@@ -377,10 +377,10 @@ discard block |
||
377 | 377 | |
378 | 378 | $result = false; |
379 | 379 | |
380 | - foreach ( $enclist as $item ) { |
|
381 | - $sample = iconv( $item, $item, $string ); |
|
382 | - if ( md5( $sample ) == md5( $string ) ) { |
|
383 | - if ( $ret === null ) { |
|
380 | + foreach ($enclist as $item) { |
|
381 | + $sample = iconv($item, $item, $string); |
|
382 | + if (md5($sample) == md5($string)) { |
|
383 | + if ($ret === null) { |
|
384 | 384 | $result = $item; |
385 | 385 | } else { |
386 | 386 | $result = true; |
@@ -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,11 +444,11 @@ 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 | - $this->events_template = wpautop( wp_kses_post( trim( $template ) ) ); |
|
451 | + $this->events_template = wpautop(wp_kses_post(trim($template))); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -458,32 +458,32 @@ discard block |
||
458 | 458 | * |
459 | 459 | * @param string $tz Timezone. |
460 | 460 | */ |
461 | - public function set_timezone( $tz = '' ) { |
|
461 | + public function set_timezone($tz = '') { |
|
462 | 462 | |
463 | - $site_tz = esc_attr( simcal_get_wp_timezone() ); |
|
463 | + $site_tz = esc_attr(simcal_get_wp_timezone()); |
|
464 | 464 | |
465 | - if ( empty( $tz ) ) { |
|
465 | + if (empty($tz)) { |
|
466 | 466 | |
467 | - $timezone_setting = get_post_meta( $this->id, '_feed_timezone_setting', true ); |
|
467 | + $timezone_setting = get_post_meta($this->id, '_feed_timezone_setting', true); |
|
468 | 468 | |
469 | - if ( 'use_site' == $timezone_setting ) { |
|
469 | + if ('use_site' == $timezone_setting) { |
|
470 | 470 | $tz = $site_tz; |
471 | - } elseif ( 'use_custom' == $timezone_setting ) { |
|
472 | - $custom_timezone = esc_attr( get_post_meta( $this->id, '_feed_timezone', true ) ); |
|
471 | + } elseif ('use_custom' == $timezone_setting) { |
|
472 | + $custom_timezone = esc_attr(get_post_meta($this->id, '_feed_timezone', true)); |
|
473 | 473 | // One may be using a non standard timezone in GMT (UTC) offset format. |
474 | - if ( ( strpos( $custom_timezone, 'UTC+' ) === 0 ) || ( strpos( $custom_timezone, 'UTC-' ) === 0 ) ) { |
|
475 | - $tz = simcal_get_timezone_from_gmt_offset( substr( $custom_timezone, 3 ) ); |
|
474 | + if ((strpos($custom_timezone, 'UTC+') === 0) || (strpos($custom_timezone, 'UTC-') === 0)) { |
|
475 | + $tz = simcal_get_timezone_from_gmt_offset(substr($custom_timezone, 3)); |
|
476 | 476 | } else { |
477 | - $tz = ! empty( $custom_timezone ) ? $custom_timezone : 'UTC'; |
|
477 | + $tz = ! empty($custom_timezone) ? $custom_timezone : 'UTC'; |
|
478 | 478 | } |
479 | 479 | } |
480 | 480 | |
481 | - $this->timezone = empty( $tz ) ? 'UTC' : $tz; |
|
481 | + $this->timezone = empty($tz) ? 'UTC' : $tz; |
|
482 | 482 | return; |
483 | 483 | } |
484 | 484 | |
485 | 485 | $this->site_timezone = $site_tz; |
486 | - $this->timezone = simcal_esc_timezone( $tz, $this->timezone ); |
|
486 | + $this->timezone = simcal_esc_timezone($tz, $this->timezone); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -493,20 +493,20 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @param string $format PHP datetime format. |
495 | 495 | */ |
496 | - public function set_date_format( $format = '' ) { |
|
496 | + public function set_date_format($format = '') { |
|
497 | 497 | |
498 | 498 | $date_format_custom = $date_format_default = $format; |
499 | 499 | |
500 | - if ( empty( $date_format_custom ) ) { |
|
500 | + if (empty($date_format_custom)) { |
|
501 | 501 | |
502 | - $date_format_option = esc_attr( get_post_meta( $this->id, '_calendar_date_format_setting', true ) ); |
|
503 | - $date_format_default = esc_attr( get_option( 'date_format' ) ); |
|
502 | + $date_format_option = esc_attr(get_post_meta($this->id, '_calendar_date_format_setting', true)); |
|
503 | + $date_format_default = esc_attr(get_option('date_format')); |
|
504 | 504 | $date_format_custom = ''; |
505 | 505 | |
506 | - if ( 'use_custom' == $date_format_option ) { |
|
507 | - $date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format', true ) ); |
|
508 | - } elseif ( 'use_custom_php' == $date_format_option ) { |
|
509 | - $date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format_php', true ) ); |
|
506 | + if ('use_custom' == $date_format_option) { |
|
507 | + $date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format', true)); |
|
508 | + } elseif ('use_custom_php' == $date_format_option) { |
|
509 | + $date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format_php', true)); |
|
510 | 510 | } |
511 | 511 | } |
512 | 512 | |
@@ -520,20 +520,20 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @param string $format PHP datetime format. |
522 | 522 | */ |
523 | - public function set_time_format( $format = '' ) { |
|
523 | + public function set_time_format($format = '') { |
|
524 | 524 | |
525 | 525 | $time_format_custom = $time_format_default = $format; |
526 | 526 | |
527 | - if ( empty( $time_format_custom ) ) { |
|
527 | + if (empty($time_format_custom)) { |
|
528 | 528 | |
529 | - $time_format_option = esc_attr( get_post_meta( $this->id, '_calendar_time_format_setting', true ) ); |
|
530 | - $time_format_default = esc_attr( get_option( 'time_format' ) ); |
|
529 | + $time_format_option = esc_attr(get_post_meta($this->id, '_calendar_time_format_setting', true)); |
|
530 | + $time_format_default = esc_attr(get_option('time_format')); |
|
531 | 531 | $time_format_custom = ''; |
532 | 532 | |
533 | - if ( 'use_custom' == $time_format_option ) { |
|
534 | - $time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format', true ) ); |
|
535 | - } elseif ( 'use_custom_php' == $time_format_option ) { |
|
536 | - $time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format_php', true ) ); |
|
533 | + if ('use_custom' == $time_format_option) { |
|
534 | + $time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format', true)); |
|
535 | + } elseif ('use_custom_php' == $time_format_option) { |
|
536 | + $time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format_php', true)); |
|
537 | 537 | } |
538 | 538 | } |
539 | 539 | |
@@ -547,13 +547,13 @@ discard block |
||
547 | 547 | * |
548 | 548 | * @param string $separator A UTF8 character used as separator. |
549 | 549 | */ |
550 | - public function set_datetime_separator( $separator = '' ) { |
|
550 | + public function set_datetime_separator($separator = '') { |
|
551 | 551 | |
552 | - if ( empty( $separator ) ) { |
|
553 | - $separator = get_post_meta( $this->id, '_calendar_datetime_separator', true ); |
|
552 | + if (empty($separator)) { |
|
553 | + $separator = get_post_meta($this->id, '_calendar_datetime_separator', true); |
|
554 | 554 | } |
555 | 555 | |
556 | - $this->datetime_separator = esc_attr( $separator ); |
|
556 | + $this->datetime_separator = esc_attr($separator); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
@@ -563,18 +563,18 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @param int $weekday From 0 (Sunday) to 6 (Friday). |
565 | 565 | */ |
566 | - public function set_start_of_week( $weekday = -1 ) { |
|
566 | + public function set_start_of_week($weekday = -1) { |
|
567 | 567 | |
568 | - $week_starts = is_int( $weekday ) ? $weekday : -1; |
|
568 | + $week_starts = is_int($weekday) ? $weekday : -1; |
|
569 | 569 | |
570 | - if ( $week_starts < 0 || $week_starts > 6 ) { |
|
570 | + if ($week_starts < 0 || $week_starts > 6) { |
|
571 | 571 | |
572 | - $week_starts_setting = get_post_meta( $this->id, '_calendar_week_starts_on_setting', true ); |
|
573 | - $week_starts = intval( get_option( 'start_of_week' ) ); |
|
572 | + $week_starts_setting = get_post_meta($this->id, '_calendar_week_starts_on_setting', true); |
|
573 | + $week_starts = intval(get_option('start_of_week')); |
|
574 | 574 | |
575 | - if ( 'use_custom' == $week_starts_setting ) { |
|
576 | - $week_starts_on = get_post_meta( $this->id, '_calendar_week_starts_on', true ); |
|
577 | - $week_starts = is_numeric( $week_starts_on ) ? intval( $week_starts_on ) : $week_starts; |
|
575 | + if ('use_custom' == $week_starts_setting) { |
|
576 | + $week_starts_on = get_post_meta($this->id, '_calendar_week_starts_on', true); |
|
577 | + $week_starts = is_numeric($week_starts_on) ? intval($week_starts_on) : $week_starts; |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
@@ -588,51 +588,51 @@ discard block |
||
588 | 588 | * |
589 | 589 | * @param int $timestamp |
590 | 590 | */ |
591 | - public function set_start( $timestamp = 0 ) { |
|
591 | + public function set_start($timestamp = 0) { |
|
592 | 592 | |
593 | - if ( is_int( $timestamp ) && $timestamp !== 0 ) { |
|
593 | + if (is_int($timestamp) && $timestamp !== 0) { |
|
594 | 594 | $this->start = $timestamp; |
595 | 595 | return; |
596 | 596 | } |
597 | 597 | |
598 | - $this->start = Carbon::now( $this->timezone )->getTimestamp(); |
|
598 | + $this->start = Carbon::now($this->timezone)->getTimestamp(); |
|
599 | 599 | |
600 | - $calendar_begins = esc_attr( get_post_meta( $this->id, '_calendar_begins', true ) ); |
|
601 | - $nth = max( absint( get_post_meta( $this->id, '_calendar_begins_nth' ) ), 1 ); |
|
600 | + $calendar_begins = esc_attr(get_post_meta($this->id, '_calendar_begins', true)); |
|
601 | + $nth = max(absint(get_post_meta($this->id, '_calendar_begins_nth')), 1); |
|
602 | 602 | |
603 | - if ( 'today' == $calendar_begins ) { |
|
604 | - $this->start = Carbon::today( $this->timezone )->getTimestamp(); |
|
605 | - } elseif ( 'days_before' == $calendar_begins ) { |
|
606 | - $this->start = Carbon::today( $this->timezone )->subDays( $nth )->getTimestamp(); |
|
607 | - } elseif ( 'days_after' == $calendar_begins ) { |
|
608 | - $this->start = Carbon::today( $this->timezone )->addDays( $nth )->getTimestamp(); |
|
609 | - } elseif ( 'this_week' == $calendar_begins ) { |
|
610 | - $week = new Carbon( 'now', $this->timezone ); |
|
611 | - $week->setWeekStartsAt( $this->week_starts ); |
|
603 | + if ('today' == $calendar_begins) { |
|
604 | + $this->start = Carbon::today($this->timezone)->getTimestamp(); |
|
605 | + } elseif ('days_before' == $calendar_begins) { |
|
606 | + $this->start = Carbon::today($this->timezone)->subDays($nth)->getTimestamp(); |
|
607 | + } elseif ('days_after' == $calendar_begins) { |
|
608 | + $this->start = Carbon::today($this->timezone)->addDays($nth)->getTimestamp(); |
|
609 | + } elseif ('this_week' == $calendar_begins) { |
|
610 | + $week = new Carbon('now', $this->timezone); |
|
611 | + $week->setWeekStartsAt($this->week_starts); |
|
612 | 612 | $this->start = $week->startOfWeek()->getTimestamp(); |
613 | - } elseif ( 'weeks_before' == $calendar_begins ) { |
|
614 | - $week = new Carbon( 'now', $this->timezone ); |
|
615 | - $week->setWeekStartsAt( $this->week_starts ); |
|
616 | - $this->start = $week->startOfWeek()->subWeeks( $nth )->getTimestamp(); |
|
617 | - } elseif ( 'weeks_after' == $calendar_begins ) { |
|
618 | - $week = new Carbon( 'now', $this->timezone ); |
|
619 | - $week->setWeekStartsAt( $this->week_starts ); |
|
620 | - $this->start = $week->startOfWeek()->addWeeks( $nth )->getTimestamp(); |
|
621 | - } elseif ( 'this_month' == $calendar_begins ) { |
|
622 | - $this->start = Carbon::today( $this->timezone )->startOfMonth()->getTimeStamp(); |
|
623 | - } elseif ( 'months_before' == $calendar_begins ) { |
|
624 | - $this->start = Carbon::today( $this->timezone )->subMonths( $nth )->startOfMonth()->getTimeStamp(); |
|
625 | - } elseif ( 'months_after' == $calendar_begins ) { |
|
626 | - $this->start = Carbon::today( $this->timezone )->addMonths( $nth )->startOfMonth()->getTimeStamp(); |
|
627 | - } elseif ( 'this_year' == $calendar_begins ) { |
|
628 | - $this->start = Carbon::today( $this->timezone )->startOfYear()->getTimestamp(); |
|
629 | - } elseif ( 'years_before' == $calendar_begins ) { |
|
630 | - $this->start = Carbon::today( $this->timezone )->subYears( $nth )->startOfYear()->getTimeStamp(); |
|
631 | - } elseif ( 'years_after' == $calendar_begins ) { |
|
632 | - $this->start = Carbon::today( $this->timezone )->addYears( $nth )->startOfYear()->getTimeStamp(); |
|
633 | - } elseif ( 'custom_date' == $calendar_begins ) { |
|
634 | - if ( $date = get_post_meta( $this->id, '_calendar_begins_custom_date', true ) ) { |
|
635 | - $this->start = Carbon::createFromFormat( 'Y-m-d', esc_attr( $date ) )->setTimezone( $this->timezone )->getTimestamp(); |
|
613 | + } elseif ('weeks_before' == $calendar_begins) { |
|
614 | + $week = new Carbon('now', $this->timezone); |
|
615 | + $week->setWeekStartsAt($this->week_starts); |
|
616 | + $this->start = $week->startOfWeek()->subWeeks($nth)->getTimestamp(); |
|
617 | + } elseif ('weeks_after' == $calendar_begins) { |
|
618 | + $week = new Carbon('now', $this->timezone); |
|
619 | + $week->setWeekStartsAt($this->week_starts); |
|
620 | + $this->start = $week->startOfWeek()->addWeeks($nth)->getTimestamp(); |
|
621 | + } elseif ('this_month' == $calendar_begins) { |
|
622 | + $this->start = Carbon::today($this->timezone)->startOfMonth()->getTimeStamp(); |
|
623 | + } elseif ('months_before' == $calendar_begins) { |
|
624 | + $this->start = Carbon::today($this->timezone)->subMonths($nth)->startOfMonth()->getTimeStamp(); |
|
625 | + } elseif ('months_after' == $calendar_begins) { |
|
626 | + $this->start = Carbon::today($this->timezone)->addMonths($nth)->startOfMonth()->getTimeStamp(); |
|
627 | + } elseif ('this_year' == $calendar_begins) { |
|
628 | + $this->start = Carbon::today($this->timezone)->startOfYear()->getTimestamp(); |
|
629 | + } elseif ('years_before' == $calendar_begins) { |
|
630 | + $this->start = Carbon::today($this->timezone)->subYears($nth)->startOfYear()->getTimeStamp(); |
|
631 | + } elseif ('years_after' == $calendar_begins) { |
|
632 | + $this->start = Carbon::today($this->timezone)->addYears($nth)->startOfYear()->getTimeStamp(); |
|
633 | + } elseif ('custom_date' == $calendar_begins) { |
|
634 | + if ($date = get_post_meta($this->id, '_calendar_begins_custom_date', true)) { |
|
635 | + $this->start = Carbon::createFromFormat('Y-m-d', esc_attr($date))->setTimezone($this->timezone)->getTimestamp(); |
|
636 | 636 | } |
637 | 637 | } |
638 | 638 | } |
@@ -644,8 +644,8 @@ discard block |
||
644 | 644 | * |
645 | 645 | * @param int $timestamp |
646 | 646 | */ |
647 | - public function set_end( $timestamp = 0 ) { |
|
648 | - $latest = is_int( $timestamp ) && $timestamp !== 0 ? $timestamp : $this->latest_event; |
|
647 | + public function set_end($timestamp = 0) { |
|
648 | + $latest = is_int($timestamp) && $timestamp !== 0 ? $timestamp : $this->latest_event; |
|
649 | 649 | $this->end = $latest > $this->start ? $latest : $this->start; |
650 | 650 | } |
651 | 651 | |
@@ -656,14 +656,14 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @param string|bool $static |
658 | 658 | */ |
659 | - public function set_static( $static = '' ) { |
|
659 | + public function set_static($static = '') { |
|
660 | 660 | |
661 | - if ( ! empty( $static ) && is_bool( $static ) ) { |
|
661 | + if ( ! empty($static) && is_bool($static)) { |
|
662 | 662 | $this->static = $static; |
663 | 663 | return; |
664 | 664 | } |
665 | 665 | |
666 | - if ( 'yes' == get_post_meta( $this->id, '_calendar_is_static', true ) ) { |
|
666 | + if ('yes' == get_post_meta($this->id, '_calendar_is_static', true)) { |
|
667 | 667 | $this->static = true; |
668 | 668 | return; |
669 | 669 | } |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * |
692 | 692 | * @return Calendar_View |
693 | 693 | */ |
694 | - abstract public function get_view( $view = '' ); |
|
694 | + abstract public function get_view($view = ''); |
|
695 | 695 | |
696 | 696 | /** |
697 | 697 | * Get event HTML parsed by template. |
@@ -703,11 +703,11 @@ discard block |
||
703 | 703 | * |
704 | 704 | * @return string |
705 | 705 | */ |
706 | - public function get_event_html( Event $event, $template = '' ) { |
|
707 | - $event_builder = new Event_Builder( $event, $this ); |
|
706 | + public function get_event_html(Event $event, $template = '') { |
|
707 | + $event_builder = new Event_Builder($event, $this); |
|
708 | 708 | // Use the event template to parse tags; if empty, fallback to calendar post content. |
709 | - $template = empty( $template ) ? ( empty( $event->template ) ? $this->events_template : $event->template ) : $template; |
|
710 | - return $event_builder->parse_event_template_tags( $template ); |
|
709 | + $template = empty($template) ? (empty($event->template) ? $this->events_template : $event->template) : $template; |
|
710 | + return $event_builder->parse_event_template_tags($template); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | /** |
@@ -717,57 +717,57 @@ discard block |
||
717 | 717 | * |
718 | 718 | * @param string $view The calendar view to display. |
719 | 719 | */ |
720 | - public function html( $view = '' ) { |
|
720 | + public function html($view = '') { |
|
721 | 721 | |
722 | - $view = empty( $view ) ? $this->view : $this->get_view( $view ); |
|
722 | + $view = empty($view) ? $this->view : $this->get_view($view); |
|
723 | 723 | |
724 | - if ( $view instanceof Calendar_View ) { |
|
724 | + if ($view instanceof Calendar_View) { |
|
725 | 725 | |
726 | - if ( ! empty( $this->errors ) ) { |
|
726 | + if ( ! empty($this->errors)) { |
|
727 | 727 | |
728 | - if ( current_user_can( 'manage_options' ) ) { |
|
728 | + if (current_user_can('manage_options')) { |
|
729 | 729 | echo '<pre><code>'; |
730 | - foreach ( $this->errors as $error ) { echo $error; } |
|
730 | + foreach ($this->errors as $error) { echo $error; } |
|
731 | 731 | echo '</code></pre>'; |
732 | 732 | } |
733 | 733 | |
734 | 734 | } else { |
735 | 735 | |
736 | 736 | // Get a CSS class from the class name of the calendar view (minus namespace part). |
737 | - $view_name = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( get_class( $view ) ) ) ) ); |
|
738 | - $view_class = substr( $view_name, strrpos( $view_name, '\\' ) + 1 ); |
|
737 | + $view_name = implode('-', array_map('lcfirst', explode('_', strtolower(get_class($view))))); |
|
738 | + $view_class = substr($view_name, strrpos($view_name, '\\') + 1); |
|
739 | 739 | |
740 | - $calendar_class = trim( implode( ' simcal-', apply_filters( 'simcal_calendar_class', array( |
|
740 | + $calendar_class = trim(implode(' simcal-', apply_filters('simcal_calendar_class', array( |
|
741 | 741 | 'simcal-calendar', |
742 | 742 | $this->type, |
743 | 743 | $view_class, |
744 | - ), $this->id ) ) ); |
|
745 | - |
|
746 | - echo '<div class="' . $calendar_class . '" ' |
|
747 | - . 'data-calendar-id="' . $this->id . '" ' |
|
748 | - . 'data-timezone="' . $this->timezone . '" ' |
|
749 | - . 'data-offset="' . $this->offset . '" ' |
|
750 | - . 'data-week-start="' . $this->week_starts . '" ' |
|
751 | - . 'data-calendar-start="' . $this->start .'" ' |
|
752 | - . 'data-calendar-end="' . $this->end . '" ' |
|
753 | - . 'data-events-first="' . $this->earliest_event .'" ' |
|
754 | - . 'data-events-last="' . $this->latest_event . '"' |
|
744 | + ), $this->id))); |
|
745 | + |
|
746 | + echo '<div class="'.$calendar_class.'" ' |
|
747 | + . 'data-calendar-id="'.$this->id.'" ' |
|
748 | + . 'data-timezone="'.$this->timezone.'" ' |
|
749 | + . 'data-offset="'.$this->offset.'" ' |
|
750 | + . 'data-week-start="'.$this->week_starts.'" ' |
|
751 | + . 'data-calendar-start="'.$this->start.'" ' |
|
752 | + . 'data-calendar-end="'.$this->end.'" ' |
|
753 | + . 'data-events-first="'.$this->earliest_event.'" ' |
|
754 | + . 'data-events-last="'.$this->latest_event.'"' |
|
755 | 755 | . '>'; |
756 | 756 | |
757 | - date_default_timezone_set( $this->timezone ); |
|
758 | - do_action( 'simcal_calendar_html_before', $this->id ); |
|
757 | + date_default_timezone_set($this->timezone); |
|
758 | + do_action('simcal_calendar_html_before', $this->id); |
|
759 | 759 | |
760 | 760 | $view->html(); |
761 | 761 | |
762 | - do_action( 'simcal_calendar_html_after', $this->id ); |
|
763 | - date_default_timezone_set( $this->site_timezone ); |
|
762 | + do_action('simcal_calendar_html_after', $this->id); |
|
763 | + date_default_timezone_set($this->site_timezone); |
|
764 | 764 | |
765 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
766 | - $poweredby = isset( $settings['poweredby']['opt_in'] ) ? $settings['poweredby']['opt_in'] : ''; |
|
765 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
766 | + $poweredby = isset($settings['poweredby']['opt_in']) ? $settings['poweredby']['opt_in'] : ''; |
|
767 | 767 | |
768 | - if ( 'yes' == $poweredby ) { |
|
768 | + if ('yes' == $poweredby) { |
|
769 | 769 | $align = is_rtl() ? 'left' : 'right'; |
770 | - echo '<small class="simcal-powered simcal-align-' . $align .'">Powered by <a href="https://simplecalendar.io" target="_blank">Simple Calendar</a></small>'; |
|
770 | + echo '<small class="simcal-powered simcal-align-'.$align.'">Powered by <a href="https://simplecalendar.io" target="_blank">Simple Calendar</a></small>'; |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | echo '</div>'; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use Carbon\Carbon; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -132,22 +132,22 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @param string|Calendar $calendar |
134 | 134 | */ |
135 | - public function __construct( $calendar = '' ) { |
|
135 | + public function __construct($calendar = '') { |
|
136 | 136 | |
137 | - if ( $calendar instanceof Calendar ) { |
|
137 | + if ($calendar instanceof Calendar) { |
|
138 | 138 | |
139 | - if ( isset( $calendar->id ) ) { |
|
139 | + if (isset($calendar->id)) { |
|
140 | 140 | $this->post_id = $calendar->id; |
141 | 141 | } |
142 | - if ( isset( $calendar->start ) ) { |
|
142 | + if (isset($calendar->start)) { |
|
143 | 143 | $this->calendar_start = $calendar->start; |
144 | 144 | } |
145 | - $this->week_starts = isset( $calendar->week_starts ) ? $calendar->week_starts : get_option( 'start_of_week' ); |
|
146 | - $this->events_template = ! empty( $calendar->events_template ) ? $calendar->events_template : simcal_default_event_template(); |
|
145 | + $this->week_starts = isset($calendar->week_starts) ? $calendar->week_starts : get_option('start_of_week'); |
|
146 | + $this->events_template = ! empty($calendar->events_template) ? $calendar->events_template : simcal_default_event_template(); |
|
147 | 147 | |
148 | - if ( $this->post_id > 0 ) { |
|
148 | + if ($this->post_id > 0) { |
|
149 | 149 | $this->set_cache(); |
150 | - $this->timezone_setting = get_post_meta( $this->post_id, '_feed_timezone_setting', true ); |
|
150 | + $this->timezone_setting = get_post_meta($this->post_id, '_feed_timezone_setting', true); |
|
151 | 151 | $this->timezone = $calendar->timezone; |
152 | 152 | $this->set_earliest_event(); |
153 | 153 | $this->set_latest_event(); |
@@ -173,25 +173,25 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @param int $timestamp |
175 | 175 | */ |
176 | - public function set_earliest_event( $timestamp = 0 ) { |
|
176 | + public function set_earliest_event($timestamp = 0) { |
|
177 | 177 | |
178 | - $earliest = intval( $timestamp ); |
|
178 | + $earliest = intval($timestamp); |
|
179 | 179 | |
180 | - if ( $earliest === 0 ) { |
|
180 | + if ($earliest === 0) { |
|
181 | 181 | |
182 | - $start = Carbon::createFromTimestamp( $this->calendar_start, $this->timezone ); |
|
182 | + $start = Carbon::createFromTimestamp($this->calendar_start, $this->timezone); |
|
183 | 183 | |
184 | - $earliest_date = esc_attr( get_post_meta( $this->post_id, '_feed_earliest_event_date', true ) ); |
|
185 | - $earliest_range = max( absint( get_post_meta( $this->post_id, '_feed_earliest_event_date_range', true ) ), 1 ); |
|
184 | + $earliest_date = esc_attr(get_post_meta($this->post_id, '_feed_earliest_event_date', true)); |
|
185 | + $earliest_range = max(absint(get_post_meta($this->post_id, '_feed_earliest_event_date_range', true)), 1); |
|
186 | 186 | |
187 | - if ( 'days_before' == $earliest_date ) { |
|
188 | - $earliest = $start->subDays( $earliest_range )->getTimestamp(); |
|
189 | - } elseif ( 'weeks_before' == $earliest_date ) { |
|
190 | - $earliest = $start->subWeeks( $earliest_range )->addDay()->getTimestamp(); |
|
191 | - } elseif ( 'months_before' == $earliest_date ) { |
|
192 | - $earliest = $start->subMonths( $earliest_range )->addDay()->getTimestamp(); |
|
193 | - } elseif ( 'years_before' == $earliest_date ) { |
|
194 | - $earliest = $start->subYears( $earliest_range )->addDay()->getTimestamp(); |
|
187 | + if ('days_before' == $earliest_date) { |
|
188 | + $earliest = $start->subDays($earliest_range)->getTimestamp(); |
|
189 | + } elseif ('weeks_before' == $earliest_date) { |
|
190 | + $earliest = $start->subWeeks($earliest_range)->addDay()->getTimestamp(); |
|
191 | + } elseif ('months_before' == $earliest_date) { |
|
192 | + $earliest = $start->subMonths($earliest_range)->addDay()->getTimestamp(); |
|
193 | + } elseif ('years_before' == $earliest_date) { |
|
194 | + $earliest = $start->subYears($earliest_range)->addDay()->getTimestamp(); |
|
195 | 195 | } else { |
196 | 196 | $earliest = $start->getTimestamp(); |
197 | 197 | } |
@@ -207,25 +207,25 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param int $timestamp |
209 | 209 | */ |
210 | - public function set_latest_event( $timestamp = 0 ) { |
|
210 | + public function set_latest_event($timestamp = 0) { |
|
211 | 211 | |
212 | - $latest = intval( $timestamp ); |
|
212 | + $latest = intval($timestamp); |
|
213 | 213 | |
214 | - if ( $latest === 0 ) { |
|
214 | + if ($latest === 0) { |
|
215 | 215 | |
216 | - $start = Carbon::createFromTimestamp( $this->calendar_start, $this->timezone )->endOfDay(); |
|
216 | + $start = Carbon::createFromTimestamp($this->calendar_start, $this->timezone)->endOfDay(); |
|
217 | 217 | |
218 | - $latest_date = esc_attr( get_post_meta( $this->post_id, '_feed_latest_event_date', true ) ); |
|
219 | - $latest_range = max( absint( get_post_meta( $this->post_id, '_feed_latest_event_date_range', true ) ), 1 ); |
|
218 | + $latest_date = esc_attr(get_post_meta($this->post_id, '_feed_latest_event_date', true)); |
|
219 | + $latest_range = max(absint(get_post_meta($this->post_id, '_feed_latest_event_date_range', true)), 1); |
|
220 | 220 | |
221 | - if ( 'days_after' == $latest_date ) { |
|
222 | - $latest = $start->addDays( $latest_range )->getTimestamp(); |
|
223 | - } elseif ( 'weeks_after' == $latest_date ) { |
|
224 | - $latest = $start->addWeeks( $latest_range )->subDay()->getTimestamp(); |
|
225 | - } elseif ( 'months_after' == $latest_date ) { |
|
226 | - $latest = $start->addMonths( $latest_range )->subDay()->getTimestamp(); |
|
227 | - } elseif ( 'years_after' == $latest_date ) { |
|
228 | - $latest = $start->addYears( $latest_range )->subDay()->getTimestamp(); |
|
221 | + if ('days_after' == $latest_date) { |
|
222 | + $latest = $start->addDays($latest_range)->getTimestamp(); |
|
223 | + } elseif ('weeks_after' == $latest_date) { |
|
224 | + $latest = $start->addWeeks($latest_range)->subDay()->getTimestamp(); |
|
225 | + } elseif ('months_after' == $latest_date) { |
|
226 | + $latest = $start->addMonths($latest_range)->subDay()->getTimestamp(); |
|
227 | + } elseif ('years_after' == $latest_date) { |
|
228 | + $latest = $start->addYears($latest_range)->subDay()->getTimestamp(); |
|
229 | 229 | } else { |
230 | 230 | $latest = $start->getTimestamp(); |
231 | 231 | } |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @param int $time |
244 | 244 | */ |
245 | - public function set_cache( $time = 0 ) { |
|
246 | - if ( $time === 0 || ! is_numeric( $time ) ) { |
|
247 | - $cache = get_post_meta( $this->post_id, '_feed_cache', true ); |
|
248 | - $time = is_numeric( $cache ) && $cache >= 0 ? absint( $cache ) : $this->cache; |
|
245 | + public function set_cache($time = 0) { |
|
246 | + if ($time === 0 || ! is_numeric($time)) { |
|
247 | + $cache = get_post_meta($this->post_id, '_feed_cache', true); |
|
248 | + $time = is_numeric($cache) && $cache >= 0 ? absint($cache) : $this->cache; |
|
249 | 249 | } |
250 | - $this->cache = absint( $time ); |
|
250 | + $this->cache = absint($time); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | use SimpleCalendar\Abstracts\Feed; |
11 | 11 | use SimpleCalendar\Feeds\Admin\Grouped_Calendars_Admin; |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param string|Calendar $calendar |
40 | 40 | */ |
41 | - public function __construct( $calendar = '' ) { |
|
41 | + public function __construct($calendar = '') { |
|
42 | 42 | |
43 | - parent::__construct( $calendar ); |
|
43 | + parent::__construct($calendar); |
|
44 | 44 | |
45 | 45 | $this->type = 'grouped-calendars'; |
46 | - $this->name = __( 'Grouped Calendar', 'google-calendar-events' ); |
|
46 | + $this->name = __('Grouped Calendar', 'google-calendar-events'); |
|
47 | 47 | |
48 | - if ( $this->post_id > 0 ) { |
|
48 | + if ($this->post_id > 0) { |
|
49 | 49 | $this->set_source(); |
50 | - if ( ! is_admin() || defined( 'DOING_AJAX' ) ) { |
|
50 | + if ( ! is_admin() || defined('DOING_AJAX')) { |
|
51 | 51 | $this->events = $this->get_events(); |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
56 | - new Grouped_Calendars_Admin( $this ); |
|
55 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
56 | + new Grouped_Calendars_Admin($this); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -64,38 +64,38 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param array $ids Array of calendar ids. |
66 | 66 | */ |
67 | - public function set_source( $ids = array() ) { |
|
67 | + public function set_source($ids = array()) { |
|
68 | 68 | |
69 | - $source = get_post_meta( $this->post_id, '_grouped_calendars_source', true ); |
|
69 | + $source = get_post_meta($this->post_id, '_grouped_calendars_source', true); |
|
70 | 70 | |
71 | - if ( 'ids' == $source ) { |
|
71 | + if ('ids' == $source) { |
|
72 | 72 | |
73 | - if ( empty( $ids ) ) { |
|
74 | - $ids = get_post_meta( $this->post_id, '_grouped_calendars_ids', true ); |
|
73 | + if (empty($ids)) { |
|
74 | + $ids = get_post_meta($this->post_id, '_grouped_calendars_ids', true); |
|
75 | 75 | } |
76 | 76 | |
77 | - $this->calendars_ids = ! empty( $ids ) && is_array( $ids ) ? array_map( 'absint', $ids ) : array(); |
|
77 | + $this->calendars_ids = ! empty($ids) && is_array($ids) ? array_map('absint', $ids) : array(); |
|
78 | 78 | |
79 | - } elseif ( 'category' == $source ) { |
|
79 | + } elseif ('category' == $source) { |
|
80 | 80 | |
81 | - $categories = get_post_meta( $this->post_id, '_grouped_calendars_category', true ); |
|
81 | + $categories = get_post_meta($this->post_id, '_grouped_calendars_category', true); |
|
82 | 82 | |
83 | - if ( $categories && is_array( $categories ) ) { |
|
83 | + if ($categories && is_array($categories)) { |
|
84 | 84 | |
85 | 85 | $tax_query = array( |
86 | 86 | 'taxonomy' => 'calendar_category', |
87 | 87 | 'field' => 'term_id', |
88 | - 'terms' => array_map( 'absint', $categories ), |
|
88 | + 'terms' => array_map('absint', $categories), |
|
89 | 89 | ); |
90 | 90 | |
91 | - $calendars = get_posts( array( |
|
91 | + $calendars = get_posts(array( |
|
92 | 92 | 'post_type' => 'calendar', |
93 | - 'tax_query' => array( $tax_query ), |
|
93 | + 'tax_query' => array($tax_query), |
|
94 | 94 | 'nopaging' => true, |
95 | 95 | 'fields' => 'ids', |
96 | - ) ); |
|
96 | + )); |
|
97 | 97 | |
98 | - $this->calendars_ids = ! empty( $calendars ) && is_array( $calendars ) ? $calendars : array(); |
|
98 | + $this->calendars_ids = ! empty($calendars) && is_array($calendars) ? $calendars : array(); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | } |
@@ -111,53 +111,53 @@ discard block |
||
111 | 111 | public function get_events() { |
112 | 112 | |
113 | 113 | $ids = $this->calendars_ids; |
114 | - $events = get_transient( '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type ); |
|
114 | + $events = get_transient('_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type); |
|
115 | 115 | |
116 | - if ( empty( $events ) && ! empty( $ids ) && is_array( $ids ) ) { |
|
116 | + if (empty($events) && ! empty($ids) && is_array($ids)) { |
|
117 | 117 | |
118 | 118 | $events = array(); |
119 | 119 | |
120 | - foreach ( $ids as $cal_id ) { |
|
120 | + foreach ($ids as $cal_id) { |
|
121 | 121 | |
122 | - $calendar = simcal_get_calendar( intval( $cal_id ) ); |
|
122 | + $calendar = simcal_get_calendar(intval($cal_id)); |
|
123 | 123 | |
124 | - simcal_delete_feed_transients( $cal_id ); |
|
124 | + simcal_delete_feed_transients($cal_id); |
|
125 | 125 | |
126 | - if ( $calendar instanceof Calendar ) { |
|
126 | + if ($calendar instanceof Calendar) { |
|
127 | 127 | |
128 | 128 | // Sometimes the calendars might have events at the same time from different calendars |
129 | 129 | // When merging the arrays together some of the events will be lost because the keys are the same and one will overwrite the other |
130 | 130 | // This snippet checks if the key already exists in the master events array and if it does it subtracts 1 from it to make the key unique and then unsets the original key. |
131 | - foreach( $calendar->events as $k => $v ) { |
|
132 | - if ( array_key_exists( $k, $events ) ) { |
|
133 | - $calendar->events[ $k - 1 ] = $v; |
|
134 | - unset( $k ); |
|
131 | + foreach ($calendar->events as $k => $v) { |
|
132 | + if (array_key_exists($k, $events)) { |
|
133 | + $calendar->events[$k - 1] = $v; |
|
134 | + unset($k); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - $events = is_array( $calendar->events ) ? $events + $calendar->events : $events; |
|
138 | + $events = is_array($calendar->events) ? $events + $calendar->events : $events; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | } |
142 | 142 | |
143 | - if ( ! empty( $events ) ) { |
|
143 | + if ( ! empty($events)) { |
|
144 | 144 | |
145 | 145 | // Trim events to set the earliest one as specified in feed settings. |
146 | - $earliest_event = intval( $this->time_min ); |
|
147 | - if ( $earliest_event > 0 ) { |
|
148 | - $events = $this->array_filter_key( $events, array( $this, 'filter_events_before' ) ); |
|
146 | + $earliest_event = intval($this->time_min); |
|
147 | + if ($earliest_event > 0) { |
|
148 | + $events = $this->array_filter_key($events, array($this, 'filter_events_before')); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // Trim events to set the latest one as specified in feed settings. |
152 | - $latest_event = intval( $this->time_max ); |
|
153 | - if ( $latest_event > 0 ) { |
|
154 | - $events = $this->array_filter_key( $events, array( $this, 'filter_events_after' ) ); |
|
152 | + $latest_event = intval($this->time_max); |
|
153 | + if ($latest_event > 0) { |
|
154 | + $events = $this->array_filter_key($events, array($this, 'filter_events_after')); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | set_transient( |
158 | - '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type, |
|
158 | + '_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type, |
|
159 | 159 | $events, |
160 | - absint( $this->cache ) |
|
160 | + absint($this->cache) |
|
161 | 161 | ); |
162 | 162 | } |
163 | 163 | |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - private function array_filter_key( array $array, $callback ) { |
|
183 | - $matched_keys = array_filter( array_keys( $array ), $callback ); |
|
184 | - return array_intersect_key( $array, array_flip( $matched_keys ) ); |
|
182 | + private function array_filter_key(array $array, $callback) { |
|
183 | + $matched_keys = array_filter(array_keys($array), $callback); |
|
184 | + return array_intersect_key($array, array_flip($matched_keys)); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return bool |
196 | 196 | */ |
197 | - private function filter_events_before( $event ) { |
|
198 | - if ( $this->time_min !== 0 ) { |
|
199 | - return intval( $event ) > intval( $this->time_min ); |
|
197 | + private function filter_events_before($event) { |
|
198 | + if ($this->time_min !== 0) { |
|
199 | + return intval($event) > intval($this->time_min); |
|
200 | 200 | } |
201 | 201 | return true; |
202 | 202 | } |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return bool |
213 | 213 | */ |
214 | - private function filter_events_after( $event ) { |
|
215 | - if ( $this->time_max !== 0 ) { |
|
216 | - return intval( $event ) < intval( $this->time_max ); |
|
214 | + private function filter_events_after($event) { |
|
215 | + if ($this->time_max !== 0) { |
|
216 | + return intval($event) < intval($this->time_max); |
|
217 | 217 | } |
218 | 218 | return true; |
219 | 219 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Admin; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -25,19 +25,19 @@ discard block |
||
25 | 25 | public function __construct() { |
26 | 26 | |
27 | 27 | // Set an option if the user rated the plugin. |
28 | - add_action( 'wp_ajax_simcal_rated', array( $this, 'rate_plugin' ) ); |
|
28 | + add_action('wp_ajax_simcal_rated', array($this, 'rate_plugin')); |
|
29 | 29 | |
30 | 30 | // Set an option if the user rated the plugin. |
31 | - add_action( 'wp_ajax_simcal_clear_cache', array( $this, 'clear_cache' ) ); |
|
31 | + add_action('wp_ajax_simcal_clear_cache', array($this, 'clear_cache')); |
|
32 | 32 | |
33 | 33 | // Convert a datetime format. |
34 | - add_action( 'wp_ajax_simcal_date_i18n_input_preview', array( $this, 'date_i18n' ) ); |
|
34 | + add_action('wp_ajax_simcal_date_i18n_input_preview', array($this, 'date_i18n')); |
|
35 | 35 | |
36 | 36 | // Manage an add-on license activation or deactivation. |
37 | - add_action( 'wp_ajax_simcal_manage_add_on_license', array( $this, 'manage_add_on_license' ) ); |
|
37 | + add_action('wp_ajax_simcal_manage_add_on_license', array($this, 'manage_add_on_license')); |
|
38 | 38 | |
39 | 39 | // Reset add-ons licenses. |
40 | - add_action( 'wp_ajax_simcal_reset_add_ons_licenses', array( $this, 'reset_licenses' ) ); |
|
40 | + add_action('wp_ajax_simcal_reset_add_ons_licenses', array($this, 'reset_licenses')); |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function clear_cache() { |
50 | 50 | |
51 | - $id = isset( $_POST['id'] ) ? ( is_array( $_POST['id'] ) ? array_map( 'intval', $_POST['id'] ) : intval( $_POST['id'] ) ) : ''; |
|
51 | + $id = isset($_POST['id']) ? (is_array($_POST['id']) ? array_map('intval', $_POST['id']) : intval($_POST['id'])) : ''; |
|
52 | 52 | |
53 | - if ( ! empty( $id ) ) { |
|
54 | - simcal_delete_feed_transients( $id ); |
|
53 | + if ( ! empty($id)) { |
|
54 | + simcal_delete_feed_transients($id); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @since 3.0.0 |
62 | 62 | */ |
63 | 63 | public function rate_plugin() { |
64 | - update_option( 'simple-calendar_admin_footer_text_rated', date( 'Y-m-d', time() ) ); |
|
64 | + update_option('simple-calendar_admin_footer_text_rated', date('Y-m-d', time())); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function date_i18n() { |
73 | 73 | |
74 | - $value = isset( $_POST['value'] ) ? esc_attr( $_POST['value'] ) : ' '; |
|
75 | - $timestamp = isset( $_POST['timestamp'] ) ? absint( $_POST['timestamp'] ) : time(); |
|
74 | + $value = isset($_POST['value']) ? esc_attr($_POST['value']) : ' '; |
|
75 | + $timestamp = isset($_POST['timestamp']) ? absint($_POST['timestamp']) : time(); |
|
76 | 76 | |
77 | - wp_send_json_success( date_i18n( $value, $timestamp ) ); |
|
77 | + wp_send_json_success(date_i18n($value, $timestamp)); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -86,35 +86,35 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function manage_add_on_license() { |
88 | 88 | |
89 | - $addon = isset( $_POST['add_on'] ) ? sanitize_key( $_POST['add_on'] ) : false; |
|
90 | - $action = isset( $_POST['license_action'] ) ? esc_attr( $_POST['license_action'] ) : false; |
|
91 | - $key = isset( $_POST['license_key'] ) ? esc_attr( $_POST['license_key'] ) : ''; |
|
92 | - $nonce = isset( $_POST['nonce'] ) ? esc_attr( $_POST['nonce'] ) : ''; |
|
89 | + $addon = isset($_POST['add_on']) ? sanitize_key($_POST['add_on']) : false; |
|
90 | + $action = isset($_POST['license_action']) ? esc_attr($_POST['license_action']) : false; |
|
91 | + $key = isset($_POST['license_key']) ? esc_attr($_POST['license_key']) : ''; |
|
92 | + $nonce = isset($_POST['nonce']) ? esc_attr($_POST['nonce']) : ''; |
|
93 | 93 | |
94 | 94 | // Verify that there are valid variables to process. |
95 | - if ( false === $addon || ! in_array( $action, array( 'activate_license', 'deactivate_license' ) ) ) { |
|
96 | - wp_send_json_error( __( 'Add-on unspecified or invalid action.', 'google-calendar-events' ) ); |
|
95 | + if (false === $addon || ! in_array($action, array('activate_license', 'deactivate_license'))) { |
|
96 | + wp_send_json_error(__('Add-on unspecified or invalid action.', 'google-calendar-events')); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Verify this request comes from the add-ons licenses activation settings page. |
100 | - if ( ! wp_verify_nonce( $nonce, 'simcal_license_manager' ) ) { |
|
101 | - wp_send_json_error( sprintf( __( 'An error occurred: %s', 'google-calendar-events' ), 'Nonce verification failed.' ) ); |
|
100 | + if ( ! wp_verify_nonce($nonce, 'simcal_license_manager')) { |
|
101 | + wp_send_json_error(sprintf(__('An error occurred: %s', 'google-calendar-events'), 'Nonce verification failed.')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | // Removes the prefix and converts simcal_{id_no} to {id_no}. |
105 | - $id = intval( substr( $addon, 7 ) ); |
|
105 | + $id = intval(substr($addon, 7)); |
|
106 | 106 | |
107 | 107 | // Data to send in API request. |
108 | 108 | $api_request = array( |
109 | 109 | 'edd_action' => $action, |
110 | 110 | 'license' => $key, |
111 | - 'item_id' => urlencode( $id ), |
|
111 | + 'item_id' => urlencode($id), |
|
112 | 112 | 'url' => home_url() |
113 | 113 | ); |
114 | 114 | |
115 | 115 | // Call the custom API. |
116 | 116 | $response = wp_remote_post( |
117 | - defined( 'SIMPLE_CALENDAR_STORE_URL' ) ? SIMPLE_CALENDAR_STORE_URL : simcal_get_url( 'home' ), |
|
117 | + defined('SIMPLE_CALENDAR_STORE_URL') ? SIMPLE_CALENDAR_STORE_URL : simcal_get_url('home'), |
|
118 | 118 | array( |
119 | 119 | 'timeout' => 15, |
120 | 120 | 'sslverify' => false, |
@@ -123,29 +123,29 @@ discard block |
||
123 | 123 | ); |
124 | 124 | |
125 | 125 | // Update license in db. |
126 | - $keys = get_option( 'simple-calendar_settings_licenses', array() ); |
|
127 | - $new_keys = array_merge( (array) $keys, array( 'keys' => array( $addon => $key ) ) ); |
|
128 | - update_option( 'simple-calendar_settings_licenses', $new_keys ); |
|
126 | + $keys = get_option('simple-calendar_settings_licenses', array()); |
|
127 | + $new_keys = array_merge((array) $keys, array('keys' => array($addon => $key))); |
|
128 | + update_option('simple-calendar_settings_licenses', $new_keys); |
|
129 | 129 | |
130 | 130 | // Make sure there is a response. |
131 | - if ( is_wp_error( $response ) ) { |
|
132 | - wp_send_json_error( sprintf( __( 'There was an error processing your request: %s', 'google-calendar-events' ), $response->get_error_message() ) ); |
|
131 | + if (is_wp_error($response)) { |
|
132 | + wp_send_json_error(sprintf(__('There was an error processing your request: %s', 'google-calendar-events'), $response->get_error_message())); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | // Decode the license data and save. |
136 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
136 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
137 | 137 | $status = simcal_get_license_status(); |
138 | - if ( 'deactivated' == $license_data->license ) { |
|
139 | - unset( $status[ $addon ] ); |
|
140 | - update_option( 'simple-calendar_licenses_status', $status ); |
|
141 | - wp_send_json_success( $license_data->license ); |
|
142 | - } elseif ( in_array( $license_data->license, array( 'valid', 'invalid' ) ) ) { |
|
143 | - $status[ $addon ] = $license_data->license; |
|
144 | - update_option( 'simple-calendar_licenses_status', $status ); |
|
145 | - $message = 'valid' == $license_data->license ? 'valid' : __( 'License key is invalid.', 'google-calendar-events' ); |
|
146 | - wp_send_json_success( $message ); |
|
138 | + if ('deactivated' == $license_data->license) { |
|
139 | + unset($status[$addon]); |
|
140 | + update_option('simple-calendar_licenses_status', $status); |
|
141 | + wp_send_json_success($license_data->license); |
|
142 | + } elseif (in_array($license_data->license, array('valid', 'invalid'))) { |
|
143 | + $status[$addon] = $license_data->license; |
|
144 | + update_option('simple-calendar_licenses_status', $status); |
|
145 | + $message = 'valid' == $license_data->license ? 'valid' : __('License key is invalid.', 'google-calendar-events'); |
|
146 | + wp_send_json_success($message); |
|
147 | 147 | } else { |
148 | - wp_send_json_error( '' ); |
|
148 | + wp_send_json_error(''); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function reset_licenses() { |
158 | 158 | |
159 | - $nonce = isset( $_POST['nonce'] ) ? esc_attr( $_POST['nonce'] ) : ''; |
|
159 | + $nonce = isset($_POST['nonce']) ? esc_attr($_POST['nonce']) : ''; |
|
160 | 160 | |
161 | 161 | // Verify this request comes from the add-ons licenses activation settings page. |
162 | - if ( empty ( $nonce ) || ! wp_verify_nonce( $nonce, 'simcal_license_manager' ) ) { |
|
163 | - wp_send_json_error( sprintf( __( 'An error occurred: %s', 'google-calendar-events' ), 'Nonce verification failed.' ) ); |
|
162 | + if (empty ($nonce) || ! wp_verify_nonce($nonce, 'simcal_license_manager')) { |
|
163 | + wp_send_json_error(sprintf(__('An error occurred: %s', 'google-calendar-events'), 'Nonce verification failed.')); |
|
164 | 164 | } |
165 | 165 | |
166 | - delete_option( 'simple-calendar_settings_licenses' ); |
|
167 | - delete_option( 'simple-calendar_licenses_status' ); |
|
166 | + delete_option('simple-calendar_settings_licenses'); |
|
167 | + delete_option('simple-calendar_licenses_status'); |
|
168 | 168 | |
169 | - wp_send_json_success( 'success' ); |
|
169 | + wp_send_json_success('success'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | } |
@@ -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,44 +439,44 @@ 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> |
@@ -495,23 +495,23 @@ discard block |
||
495 | 495 | * |
496 | 496 | * @param \WP_Post $post |
497 | 497 | */ |
498 | - private static function advanced_settings_panel( $post ) { |
|
498 | + private static function advanced_settings_panel($post) { |
|
499 | 499 | |
500 | 500 | ?> |
501 | 501 | <table> |
502 | 502 | <thead> |
503 | - <tr><th colspan="2"><?php _e( 'Date and Time', 'google-calendar-events' ); ?></th></tr> |
|
503 | + <tr><th colspan="2"><?php _e('Date and Time', 'google-calendar-events'); ?></th></tr> |
|
504 | 504 | </thead> |
505 | 505 | <tbody class="simcal-panel-section simcal-panel-datetime-formatting"> |
506 | 506 | <tr class="simcal-panel-field"> |
507 | - <th><label for="_calendar_timezone_setting"><?php _e( 'Timezone', 'google-calendar-events' ); ?></label></th> |
|
507 | + <th><label for="_calendar_timezone_setting"><?php _e('Timezone', 'google-calendar-events'); ?></label></th> |
|
508 | 508 | <td> |
509 | 509 | <?php |
510 | 510 | |
511 | 511 | $timezone_wordpress = simcal_get_wp_timezone(); |
512 | 512 | $timezone_default = $timezone_wordpress ? $timezone_wordpress : 'UTC'; |
513 | - $timezone_setting = esc_attr( get_post_meta( $post->ID, '_feed_timezone_setting', true ) ); |
|
514 | - $timezone = esc_attr( get_post_meta( $post->ID, '_feed_timezone', true ) ); |
|
513 | + $timezone_setting = esc_attr(get_post_meta($post->ID, '_feed_timezone_setting', true)); |
|
514 | + $timezone = esc_attr(get_post_meta($post->ID, '_feed_timezone', true)); |
|
515 | 515 | $timezone = $timezone ? $timezone : $timezone_default; |
516 | 516 | |
517 | 517 | ?> |
@@ -519,51 +519,51 @@ discard block |
||
519 | 519 | id="_feed_timezone_setting" |
520 | 520 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next" |
521 | 521 | data-show-next-if-value="use_custom"> |
522 | - <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> |
|
523 | - <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> |
|
524 | - <option value="use_custom" <?php selected( 'use_custom', $timezone_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
522 | + <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> |
|
523 | + <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> |
|
524 | + <option value="use_custom" <?php selected('use_custom', $timezone_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
525 | 525 | </select> |
526 | 526 | <select name="_feed_timezone" |
527 | 527 | id="_feed_timezone" |
528 | 528 | class="simcal-field simcal-field-select simcal-field-inline" |
529 | 529 | <?php echo 'use_custom' != $timezone_setting ? 'style="display: none;"' : ''; ?>> |
530 | - <?php echo wp_timezone_choice( $timezone ); ?> |
|
530 | + <?php echo wp_timezone_choice($timezone); ?> |
|
531 | 531 | </select> |
532 | - <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> |
|
532 | + <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> |
|
533 | 533 | </td> |
534 | 534 | </tr> |
535 | 535 | <tr class="simcal-panel-field"> |
536 | - <th><label for="_calendar_date_format_setting"><?php _e( 'Date format', 'google-calendar-events' ); ?></label></th> |
|
536 | + <th><label for="_calendar_date_format_setting"><?php _e('Date format', 'google-calendar-events'); ?></label></th> |
|
537 | 537 | <td> |
538 | 538 | <?php |
539 | 539 | |
540 | - $date_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_setting', true ) ); |
|
541 | - $date_format_default = esc_attr( get_option( 'date_format' ) ); |
|
542 | - $date_format = esc_attr( get_post_meta( $post->ID, '_calendar_date_format', true ) ); |
|
543 | - $date_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_php', true ) ); |
|
540 | + $date_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_date_format_setting', true)); |
|
541 | + $date_format_default = esc_attr(get_option('date_format')); |
|
542 | + $date_format = esc_attr(get_post_meta($post->ID, '_calendar_date_format', true)); |
|
543 | + $date_format_php = esc_attr(get_post_meta($post->ID, '_calendar_date_format_php', true)); |
|
544 | 544 | $date_format_php = $date_format_php ? $date_format_php : $date_format_default; |
545 | 545 | |
546 | 546 | ?> |
547 | 547 | <select name="_calendar_date_format_setting" |
548 | 548 | id="_calendar_date_format_setting" |
549 | 549 | class="simcal-field simcal-field-select simcal-field-show-other"> |
550 | - <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> |
|
551 | - <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> |
|
552 | - <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> |
|
550 | + <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> |
|
551 | + <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> |
|
552 | + <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> |
|
553 | 553 | </select> |
554 | - <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> |
|
554 | + <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> |
|
555 | 555 | <p id="_calendar_date_format_default" style="<?php echo $date_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
556 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
557 | - <code><?php echo date_i18n( $date_format_default, time() ); ?></code> |
|
556 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
557 | + <code><?php echo date_i18n($date_format_default, time()); ?></code> |
|
558 | 558 | </p> |
559 | - <?php simcal_print_field( array( |
|
559 | + <?php simcal_print_field(array( |
|
560 | 560 | 'type' => 'datetime-format', |
561 | 561 | 'subtype' => 'date', |
562 | 562 | 'name' => '_calendar_date_format', |
563 | 563 | 'id' => '_calendar_date_format', |
564 | 564 | 'value' => $date_format, |
565 | - 'style' => $date_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
566 | - ) ); ?> |
|
565 | + 'style' => $date_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
566 | + )); ?> |
|
567 | 567 | <div class="simcal-field-datetime-format-php" id="_calendar_date_format_php_field" style="<?php echo $date_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
568 | 568 | <br> |
569 | 569 | <label for="_calendar_date_format_php"> |
@@ -572,70 +572,70 @@ discard block |
||
572 | 572 | id="_calendar_date_format_php" |
573 | 573 | class="simcal-field simcal-field-text simcal-field-small" |
574 | 574 | value="<?php echo $date_format_php; ?>" /> |
575 | - <?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>' ); ?> |
|
575 | + <?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>'); ?> |
|
576 | 576 | </label> |
577 | 577 | <p> |
578 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
579 | - <code><?php echo date_i18n( $date_format_php, time() ); ?></code> |
|
578 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
579 | + <code><?php echo date_i18n($date_format_php, time()); ?></code> |
|
580 | 580 | </p> |
581 | 581 | </div> |
582 | 582 | </td> |
583 | 583 | </tr> |
584 | 584 | <tr class="simcal-panel-field"> |
585 | - <th><label for="_calendar_datetime_separator"><?php _e( 'Separator', 'google-calendar-events' ); ?></label></th> |
|
585 | + <th><label for="_calendar_datetime_separator"><?php _e('Separator', 'google-calendar-events'); ?></label></th> |
|
586 | 586 | <td> |
587 | 587 | <?php |
588 | 588 | |
589 | - $separator = get_post_meta( $post->ID, '_calendar_datetime_separator', true ); |
|
589 | + $separator = get_post_meta($post->ID, '_calendar_datetime_separator', true); |
|
590 | 590 | $separator = false == $separator ? '@' : $separator; |
591 | 591 | |
592 | - simcal_print_field( array( |
|
592 | + simcal_print_field(array( |
|
593 | 593 | 'type' => 'standard', |
594 | 594 | 'subtype' => 'text', |
595 | 595 | 'name' => '_calendar_datetime_separator', |
596 | 596 | 'id' => '_calendar_datetime_separator', |
597 | 597 | 'value' => $separator, |
598 | - 'tooltip' => __( 'Used to divide date and time when both are shown.', 'google-calendar-events' ), |
|
598 | + 'tooltip' => __('Used to divide date and time when both are shown.', 'google-calendar-events'), |
|
599 | 599 | 'class' => array( |
600 | 600 | 'simcal-field-tiny', |
601 | 601 | ), |
602 | - ) ); |
|
602 | + )); |
|
603 | 603 | |
604 | 604 | ?> |
605 | 605 | </td> |
606 | 606 | </tr> |
607 | 607 | <tr class="simcal-panel-field"> |
608 | - <th><label for="_calendar_time_format_setting"><?php _e( 'Time format', 'google-calendar-events' ); ?></label></th> |
|
608 | + <th><label for="_calendar_time_format_setting"><?php _e('Time format', 'google-calendar-events'); ?></label></th> |
|
609 | 609 | <td> |
610 | 610 | <?php |
611 | 611 | |
612 | - $time_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_setting', true ) ); |
|
613 | - $time_format_default = esc_attr( get_option( 'time_format' ) ); |
|
614 | - $time_format = esc_attr( get_post_meta( $post->ID, '_calendar_time_format', true ) ); |
|
615 | - $time_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_php', true ) ); |
|
612 | + $time_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_time_format_setting', true)); |
|
613 | + $time_format_default = esc_attr(get_option('time_format')); |
|
614 | + $time_format = esc_attr(get_post_meta($post->ID, '_calendar_time_format', true)); |
|
615 | + $time_format_php = esc_attr(get_post_meta($post->ID, '_calendar_time_format_php', true)); |
|
616 | 616 | $time_format_php = $time_format_php ? $time_format_php : $time_format_default; |
617 | 617 | |
618 | 618 | ?> |
619 | 619 | <select name="_calendar_time_format_setting" |
620 | 620 | id="_calendar_time_format_setting" |
621 | 621 | class="simcal-field simcal-field-select simcal-field-show-other"> |
622 | - <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> |
|
623 | - <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> |
|
624 | - <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> |
|
622 | + <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> |
|
623 | + <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> |
|
624 | + <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> |
|
625 | 625 | </select> |
626 | - <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> |
|
626 | + <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> |
|
627 | 627 | <p id="_calendar_time_format_default" style="<?php echo $time_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
628 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
629 | - <code><?php echo date_i18n( $time_format_default, time() ); ?></code> |
|
628 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
629 | + <code><?php echo date_i18n($time_format_default, time()); ?></code> |
|
630 | 630 | </p> |
631 | - <?php simcal_print_field( array( |
|
631 | + <?php simcal_print_field(array( |
|
632 | 632 | 'type' => 'datetime-format', |
633 | 633 | 'subtype' => 'time', |
634 | 634 | 'name' => '_calendar_time_format', |
635 | 635 | 'id' => '_calendar_time_format', |
636 | 636 | 'value' => $time_format, |
637 | - 'style' => $time_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
638 | - ) ); ?> |
|
637 | + 'style' => $time_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
638 | + )); ?> |
|
639 | 639 | <div class="simcal-field-datetime-format-php" id="_calendar_time_format_php_field" style="<?php echo $time_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
640 | 640 | <br> |
641 | 641 | <label for="_calendar_date_format_php"> |
@@ -644,24 +644,24 @@ discard block |
||
644 | 644 | id="_calendar_time_format_php" |
645 | 645 | class="simcal-field simcal-field-text simcal-field-small" |
646 | 646 | value="<?php echo $time_format_php; ?>"/> |
647 | - <?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>' ); ?> |
|
647 | + <?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>'); ?> |
|
648 | 648 | </label> |
649 | 649 | <p> |
650 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
651 | - <code><?php echo date_i18n( $time_format_php, time() ); ?></code> |
|
650 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
651 | + <code><?php echo date_i18n($time_format_php, time()); ?></code> |
|
652 | 652 | </p> |
653 | 653 | </div> |
654 | 654 | </td> |
655 | 655 | </tr> |
656 | 656 | <tr class="simcal-panel-field"> |
657 | - <th><label for="_calendar_week_starts_on_setting"><?php _e( 'Week starts on', 'google-calendar-events' ); ?></label></th> |
|
657 | + <th><label for="_calendar_week_starts_on_setting"><?php _e('Week starts on', 'google-calendar-events'); ?></label></th> |
|
658 | 658 | <td> |
659 | 659 | <?php |
660 | 660 | |
661 | - $week_starts_setting = esc_attr( get_post_meta( $post->ID, '_calendar_week_starts_on_setting', true ) ); |
|
662 | - $week_starts_default = esc_attr( get_option( 'start_of_week' ) ); |
|
663 | - $week_starts = intval( get_post_meta( $post->ID, '_calendar_week_starts_on', true ) ); |
|
664 | - $week_starts = is_numeric( $week_starts ) ? strval( $week_starts ) : $week_starts_default; |
|
661 | + $week_starts_setting = esc_attr(get_post_meta($post->ID, '_calendar_week_starts_on_setting', true)); |
|
662 | + $week_starts_default = esc_attr(get_option('start_of_week')); |
|
663 | + $week_starts = intval(get_post_meta($post->ID, '_calendar_week_starts_on', true)); |
|
664 | + $week_starts = is_numeric($week_starts) ? strval($week_starts) : $week_starts_default; |
|
665 | 665 | |
666 | 666 | ?> |
667 | 667 | <select |
@@ -669,39 +669,39 @@ discard block |
||
669 | 669 | id="_calendar_week_starts_on_setting" |
670 | 670 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next" |
671 | 671 | data-show-next-if-value="use_custom"> |
672 | - <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> |
|
673 | - <option value="use_custom" <?php selected( 'use_custom', $week_starts_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
672 | + <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> |
|
673 | + <option value="use_custom" <?php selected('use_custom', $week_starts_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
674 | 674 | </select> |
675 | 675 | <select |
676 | 676 | name="_calendar_week_starts_on" |
677 | 677 | id="_calendar_week_starts_on" |
678 | 678 | class="simcal-field simcal-field-select simcal-field-inline" |
679 | 679 | <?php echo 'use_custom' != $week_starts_setting ? 'style="display: none;"' : ''; ?>> |
680 | - <?php $day_names = simcal_get_calendar_names_i18n( 'day', 'full' ); ?> |
|
681 | - <?php for ( $i = 0; $i <= 6; $i++ ) : ?> |
|
682 | - <option value="<?php echo $i; ?>" <?php selected( $i, $week_starts, true ); ?>><?php echo $day_names[ $i ]; ?></option> |
|
680 | + <?php $day_names = simcal_get_calendar_names_i18n('day', 'full'); ?> |
|
681 | + <?php for ($i = 0; $i <= 6; $i++) : ?> |
|
682 | + <option value="<?php echo $i; ?>" <?php selected($i, $week_starts, true); ?>><?php echo $day_names[$i]; ?></option> |
|
683 | 683 | <?php endfor; ?> |
684 | 684 | </select> |
685 | - <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> |
|
685 | + <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> |
|
686 | 686 | </td> |
687 | 687 | </tr> |
688 | 688 | </tbody> |
689 | 689 | </table> |
690 | 690 | <table> |
691 | 691 | <thead> |
692 | - <tr><th colspan="2"><?php _e( 'Cache', 'google-calendar-events' ); ?></th></tr> |
|
692 | + <tr><th colspan="2"><?php _e('Cache', 'google-calendar-events'); ?></th></tr> |
|
693 | 693 | </thead> |
694 | 694 | <tbody class="simcal-panel-section simcal-panel-section-cache"> |
695 | 695 | <?php |
696 | 696 | |
697 | - $cache_freq = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_amount', true ) ); |
|
698 | - $cache_unit = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_unit', true ) ); |
|
697 | + $cache_freq = esc_attr(get_post_meta($post->ID, '_feed_cache_user_amount', true)); |
|
698 | + $cache_unit = esc_attr(get_post_meta($post->ID, '_feed_cache_user_unit', true)); |
|
699 | 699 | $cache_freq = $cache_freq >= 0 ? $cache_freq : '2'; |
700 | 700 | $cache_unit = $cache_unit ? $cache_unit : '3600'; |
701 | 701 | |
702 | 702 | ?> |
703 | 703 | <tr class="simcal-panel-field"> |
704 | - <th><label for="_feed_cache_user_amount"><?php _ex( 'Refresh interval', 'Cache maximum interval', 'google-calendar-events' ); ?></label></th> |
|
704 | + <th><label for="_feed_cache_user_amount"><?php _ex('Refresh interval', 'Cache maximum interval', 'google-calendar-events'); ?></label></th> |
|
705 | 705 | <td> |
706 | 706 | <input type="number" |
707 | 707 | name="_feed_cache_user_amount" |
@@ -712,12 +712,12 @@ discard block |
||
712 | 712 | <select name="_feed_cache_user_unit" |
713 | 713 | id="_feed_cache_user_unit" |
714 | 714 | class="simcal-field simcalfield-select simcal-field-inline"> |
715 | - <option value="60" <?php selected( '60', $cache_unit, true ); ?>><?php _e( 'Minute(s)', 'google-calendar-events' ); ?></option> |
|
716 | - <option value="3600" <?php selected( '3600', $cache_unit, true ); ?>><?php _e( 'Hour(s)', 'google-calendar-events' ); ?></option> |
|
717 | - <option value="86400" <?php selected( '86400', $cache_unit, true ); ?>><?php _e( 'Day(s)', 'google-calendar-events' ); ?></option> |
|
718 | - <option value="604800" <?php selected( '604800', $cache_unit, true ); ?>><?php _e( 'Week(s)', 'google-calendar-events' ); ?></option> |
|
715 | + <option value="60" <?php selected('60', $cache_unit, true); ?>><?php _e('Minute(s)', 'google-calendar-events'); ?></option> |
|
716 | + <option value="3600" <?php selected('3600', $cache_unit, true); ?>><?php _e('Hour(s)', 'google-calendar-events'); ?></option> |
|
717 | + <option value="86400" <?php selected('86400', $cache_unit, true); ?>><?php _e('Day(s)', 'google-calendar-events'); ?></option> |
|
718 | + <option value="604800" <?php selected('604800', $cache_unit, true); ?>><?php _e('Week(s)', 'google-calendar-events'); ?></option> |
|
719 | 719 | </select> |
720 | - <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> |
|
720 | + <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> |
|
721 | 721 | </td> |
722 | 722 | </tr> |
723 | 723 | </tbody> |
@@ -736,21 +736,21 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @return void |
738 | 738 | */ |
739 | - public static function print_panel_fields( $array, $post_id ) { |
|
739 | + public static function print_panel_fields($array, $post_id) { |
|
740 | 740 | |
741 | - foreach ( $array as $section => $fields ) : |
|
741 | + foreach ($array as $section => $fields) : |
|
742 | 742 | |
743 | - if ( $fields && is_array( $fields ) ) : |
|
743 | + if ($fields && is_array($fields)) : |
|
744 | 744 | |
745 | 745 | ?> |
746 | - <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr( $section ); ?>"> |
|
747 | - <?php foreach ( $fields as $key => $field ) : |
|
746 | + <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr($section); ?>"> |
|
747 | + <?php foreach ($fields as $key => $field) : |
|
748 | 748 | |
749 | - $value = get_post_meta( $post_id, $key, true ); |
|
750 | - $field['value'] = $value ? $value : ( isset( $field['default'] ) ? $field['default'] : '' ); |
|
751 | - $the_field = simcal_get_field( $field ); ?> |
|
749 | + $value = get_post_meta($post_id, $key, true); |
|
750 | + $field['value'] = $value ? $value : (isset($field['default']) ? $field['default'] : ''); |
|
751 | + $the_field = simcal_get_field($field); ?> |
|
752 | 752 | |
753 | - <?php if ( $the_field instanceof Field ) : ?> |
|
753 | + <?php if ($the_field instanceof Field) : ?> |
|
754 | 754 | <tr class="simcal-panel-field"> |
755 | 755 | <th><label for="<?php echo $the_field->id ?>"><?php echo $the_field->title; ?></label></th> |
756 | 756 | <td><?php $the_field->html(); ?></td> |
@@ -777,30 +777,30 @@ discard block |
||
777 | 777 | * |
778 | 778 | * @return void |
779 | 779 | */ |
780 | - public static function save( $post_id, $post ) { |
|
780 | + public static function save($post_id, $post) { |
|
781 | 781 | |
782 | 782 | /* ====================== * |
783 | 783 | * Calendar type and view * |
784 | 784 | * ====================== */ |
785 | 785 | |
786 | 786 | // Unlink existing terms for feed type and calendar type. |
787 | - wp_delete_object_term_relationships( $post_id, array( |
|
787 | + wp_delete_object_term_relationships($post_id, array( |
|
788 | 788 | 'calendar_feed', |
789 | 789 | 'calendar_type', |
790 | - ) ); |
|
790 | + )); |
|
791 | 791 | |
792 | 792 | // Set the feed type as term. |
793 | - $feed_type = isset( $_POST['_feed_type'] ) ? sanitize_title( stripslashes( $_POST['_feed_type'] ) ) : apply_filters( 'simcal_default_feed_type', 'google' ); |
|
794 | - wp_set_object_terms( $post_id, $feed_type, 'calendar_feed' ); |
|
793 | + $feed_type = isset($_POST['_feed_type']) ? sanitize_title(stripslashes($_POST['_feed_type'])) : apply_filters('simcal_default_feed_type', 'google'); |
|
794 | + wp_set_object_terms($post_id, $feed_type, 'calendar_feed'); |
|
795 | 795 | |
796 | 796 | // Set the calendar type as a term. |
797 | - $calendar_type = isset( $_POST['_calendar_type'] ) ? sanitize_title( stripslashes( $_POST['_calendar_type'] ) ) : apply_filters( 'simcal_default_calendar_type', 'default-calendar' ); |
|
798 | - wp_set_object_terms( $post_id, $calendar_type, 'calendar_type' ); |
|
797 | + $calendar_type = isset($_POST['_calendar_type']) ? sanitize_title(stripslashes($_POST['_calendar_type'])) : apply_filters('simcal_default_calendar_type', 'default-calendar'); |
|
798 | + wp_set_object_terms($post_id, $calendar_type, 'calendar_type'); |
|
799 | 799 | // Set the calendar type view as post meta. |
800 | - $calendar_view = isset( $_POST['_calendar_view'] ) ? $_POST['_calendar_view'] : ''; |
|
801 | - if ( $calendar_view && is_array( $calendar_view ) ) { |
|
802 | - $views = array_map( 'sanitize_title', $calendar_view ); |
|
803 | - update_post_meta( $post_id, '_calendar_view', $views ); |
|
800 | + $calendar_view = isset($_POST['_calendar_view']) ? $_POST['_calendar_view'] : ''; |
|
801 | + if ($calendar_view && is_array($calendar_view)) { |
|
802 | + $views = array_map('sanitize_title', $calendar_view); |
|
803 | + update_post_meta($post_id, '_calendar_view', $views); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | /* ===================== * |
@@ -808,98 +808,98 @@ discard block |
||
808 | 808 | * ===================== */ |
809 | 809 | |
810 | 810 | // Calendar opening. |
811 | - $calendar_begins = isset( $_POST['_calendar_begins'] ) ? sanitize_key( $_POST['_calendar_begins'] ) : 'this_month'; |
|
812 | - update_post_meta( $post_id, '_calendar_begins', $calendar_begins ); |
|
813 | - $calendar_begins_nth = isset( $_POST['_calendar_begins_nth'] ) ? absint( $_POST['_calendar_begins_nth'] ) : 2; |
|
814 | - update_post_meta( $post_id, '_calendar_begins_nth', $calendar_begins_nth ); |
|
815 | - $calendar_begins_custom_date = isset( $_POST['_calendar_begins_custom_date'] ) ? sanitize_title( $_POST['_calendar_begins_custom_date'] ) : ''; |
|
816 | - update_post_meta( $post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date ); |
|
811 | + $calendar_begins = isset($_POST['_calendar_begins']) ? sanitize_key($_POST['_calendar_begins']) : 'this_month'; |
|
812 | + update_post_meta($post_id, '_calendar_begins', $calendar_begins); |
|
813 | + $calendar_begins_nth = isset($_POST['_calendar_begins_nth']) ? absint($_POST['_calendar_begins_nth']) : 2; |
|
814 | + update_post_meta($post_id, '_calendar_begins_nth', $calendar_begins_nth); |
|
815 | + $calendar_begins_custom_date = isset($_POST['_calendar_begins_custom_date']) ? sanitize_title($_POST['_calendar_begins_custom_date']) : ''; |
|
816 | + update_post_meta($post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date); |
|
817 | 817 | |
818 | 818 | // Feed earliest events date. |
819 | - $earliest_events = isset( $_POST['_feed_earliest_event_date'] ) ? sanitize_key( $_POST['_feed_earliest_event_date'] ) : ''; |
|
820 | - update_post_meta( $post_id, '_feed_earliest_event_date', $earliest_events ); |
|
821 | - $earliest_events_range = isset( $_POST['_feed_earliest_event_date_range'] ) ? max( absint( $_POST['_feed_earliest_event_date_range'] ), 1 ) : 1; |
|
822 | - update_post_meta( $post_id, '_feed_earliest_event_date_range', $earliest_events_range ); |
|
819 | + $earliest_events = isset($_POST['_feed_earliest_event_date']) ? sanitize_key($_POST['_feed_earliest_event_date']) : ''; |
|
820 | + update_post_meta($post_id, '_feed_earliest_event_date', $earliest_events); |
|
821 | + $earliest_events_range = isset($_POST['_feed_earliest_event_date_range']) ? max(absint($_POST['_feed_earliest_event_date_range']), 1) : 1; |
|
822 | + update_post_meta($post_id, '_feed_earliest_event_date_range', $earliest_events_range); |
|
823 | 823 | |
824 | 824 | // Feed latest events date. |
825 | - $latest_events = isset( $_POST['_feed_latest_event_date'] ) ? sanitize_key( $_POST['_feed_latest_event_date'] ) : ''; |
|
826 | - update_post_meta( $post_id, '_feed_latest_event_date', $latest_events ); |
|
827 | - $latest_events_range = isset( $_POST['_feed_latest_event_date_range'] ) ? max( absint( $_POST['_feed_latest_event_date_range'] ), 1 ) : 1; |
|
828 | - update_post_meta( $post_id, '_feed_latest_event_date_range', $latest_events_range ); |
|
825 | + $latest_events = isset($_POST['_feed_latest_event_date']) ? sanitize_key($_POST['_feed_latest_event_date']) : ''; |
|
826 | + update_post_meta($post_id, '_feed_latest_event_date', $latest_events); |
|
827 | + $latest_events_range = isset($_POST['_feed_latest_event_date_range']) ? max(absint($_POST['_feed_latest_event_date_range']), 1) : 1; |
|
828 | + update_post_meta($post_id, '_feed_latest_event_date_range', $latest_events_range); |
|
829 | 829 | |
830 | 830 | /* ======================= * |
831 | 831 | * Calendar settings panel * |
832 | 832 | * ======================= */ |
833 | 833 | |
834 | 834 | // Static calendar. |
835 | - $static = isset( $_POST['_calendar_is_static'] ) ? 'yes' : 'no'; |
|
836 | - update_post_meta( $post_id, '_calendar_is_static', $static ); |
|
835 | + $static = isset($_POST['_calendar_is_static']) ? 'yes' : 'no'; |
|
836 | + update_post_meta($post_id, '_calendar_is_static', $static); |
|
837 | 837 | |
838 | 838 | // No events message. |
839 | - $message = isset( $_POST['_no_events_message'] ) ? wp_kses_post( $_POST['_no_events_message'] ) : ''; |
|
840 | - update_post_meta( $post_id, '_no_events_message', $message ); |
|
839 | + $message = isset($_POST['_no_events_message']) ? wp_kses_post($_POST['_no_events_message']) : ''; |
|
840 | + update_post_meta($post_id, '_no_events_message', $message); |
|
841 | 841 | |
842 | 842 | /* ======================= * |
843 | 843 | * Advanced settings panel * |
844 | 844 | * ======================= */ |
845 | 845 | |
846 | 846 | // Timezone. |
847 | - $feed_timezone_setting = isset( $_POST['_feed_timezone_setting'] ) ? sanitize_key( $_POST['_feed_timezone_setting'] ) : 'use_calendar'; |
|
848 | - update_post_meta( $post_id, '_feed_timezone_setting', $feed_timezone_setting ); |
|
847 | + $feed_timezone_setting = isset($_POST['_feed_timezone_setting']) ? sanitize_key($_POST['_feed_timezone_setting']) : 'use_calendar'; |
|
848 | + update_post_meta($post_id, '_feed_timezone_setting', $feed_timezone_setting); |
|
849 | 849 | $default_timezone = simcal_get_wp_timezone(); |
850 | 850 | $feed_timezone = $default_timezone ? $default_timezone : 'UTC'; |
851 | - $feed_timezone = isset( $_POST['_feed_timezone'] ) ? sanitize_text_field( $_POST['_feed_timezone'] ) : $feed_timezone; |
|
852 | - update_post_meta( $post_id, '_feed_timezone', $feed_timezone ); |
|
851 | + $feed_timezone = isset($_POST['_feed_timezone']) ? sanitize_text_field($_POST['_feed_timezone']) : $feed_timezone; |
|
852 | + update_post_meta($post_id, '_feed_timezone', $feed_timezone); |
|
853 | 853 | |
854 | 854 | // Date format. |
855 | - $date_format_setting = isset( $_POST['_calendar_date_format_setting'] ) ? sanitize_key( $_POST['_calendar_date_format_setting'] ) : 'use_site'; |
|
856 | - update_post_meta( $post_id, '_calendar_date_format_setting', $date_format_setting ); |
|
857 | - $date_format = isset( $_POST['_calendar_date_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format'] ) ) : get_option( 'date_format' ); |
|
858 | - update_post_meta( $post_id, '_calendar_date_format', $date_format ); |
|
859 | - $date_format_php = isset( $_POST['_calendar_date_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format_php'] ) ) : get_option( 'date_format' ); |
|
860 | - update_post_meta( $post_id, '_calendar_date_format_php', $date_format_php ); |
|
855 | + $date_format_setting = isset($_POST['_calendar_date_format_setting']) ? sanitize_key($_POST['_calendar_date_format_setting']) : 'use_site'; |
|
856 | + update_post_meta($post_id, '_calendar_date_format_setting', $date_format_setting); |
|
857 | + $date_format = isset($_POST['_calendar_date_format']) ? sanitize_text_field(trim($_POST['_calendar_date_format'])) : get_option('date_format'); |
|
858 | + update_post_meta($post_id, '_calendar_date_format', $date_format); |
|
859 | + $date_format_php = isset($_POST['_calendar_date_format_php']) ? sanitize_text_field(trim($_POST['_calendar_date_format_php'])) : get_option('date_format'); |
|
860 | + update_post_meta($post_id, '_calendar_date_format_php', $date_format_php); |
|
861 | 861 | |
862 | 862 | // Time format. |
863 | - $time_format_setting = isset( $_POST['_calendar_time_format_setting'] ) ? sanitize_key( $_POST['_calendar_time_format_setting'] ) : 'use_site'; |
|
864 | - update_post_meta( $post_id, '_calendar_time_format_setting', $time_format_setting ); |
|
865 | - $time_format = isset( $_POST['_calendar_time_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format'] ) ) : get_option( 'time_format' ); |
|
866 | - update_post_meta( $post_id, '_calendar_time_format', $time_format ); |
|
867 | - $time_format_php = isset( $_POST['_calendar_time_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format_php'] ) ) : get_option( 'time_format' ); |
|
868 | - update_post_meta( $post_id, '_calendar_time_format_php', $time_format_php ); |
|
863 | + $time_format_setting = isset($_POST['_calendar_time_format_setting']) ? sanitize_key($_POST['_calendar_time_format_setting']) : 'use_site'; |
|
864 | + update_post_meta($post_id, '_calendar_time_format_setting', $time_format_setting); |
|
865 | + $time_format = isset($_POST['_calendar_time_format']) ? sanitize_text_field(trim($_POST['_calendar_time_format'])) : get_option('time_format'); |
|
866 | + update_post_meta($post_id, '_calendar_time_format', $time_format); |
|
867 | + $time_format_php = isset($_POST['_calendar_time_format_php']) ? sanitize_text_field(trim($_POST['_calendar_time_format_php'])) : get_option('time_format'); |
|
868 | + update_post_meta($post_id, '_calendar_time_format_php', $time_format_php); |
|
869 | 869 | |
870 | 870 | // Date-time separator. |
871 | - $datetime_separator = isset( $_POST['_calendar_datetime_separator'] ) ? sanitize_text_field( $_POST['_calendar_datetime_separator'] ) : ' '; |
|
872 | - update_post_meta( $post_id, '_calendar_datetime_separator', $datetime_separator ); |
|
871 | + $datetime_separator = isset($_POST['_calendar_datetime_separator']) ? sanitize_text_field($_POST['_calendar_datetime_separator']) : ' '; |
|
872 | + update_post_meta($post_id, '_calendar_datetime_separator', $datetime_separator); |
|
873 | 873 | |
874 | 874 | // Week start. |
875 | - $week_start_setting = isset( $_POST['_calendar_week_starts_on_setting'] ) ? sanitize_key( $_POST['_calendar_week_starts_on_setting'] ) : 'use_site'; |
|
876 | - update_post_meta( $post_id, '_calendar_week_starts_on_setting', $week_start_setting ); |
|
877 | - $week_start = isset( $_POST['_calendar_week_starts_on'] ) ? intval( $_POST['_calendar_week_starts_on'] ) : get_option( 'start_of_week' ); |
|
878 | - update_post_meta( $post_id, '_calendar_week_starts_on', $week_start ); |
|
875 | + $week_start_setting = isset($_POST['_calendar_week_starts_on_setting']) ? sanitize_key($_POST['_calendar_week_starts_on_setting']) : 'use_site'; |
|
876 | + update_post_meta($post_id, '_calendar_week_starts_on_setting', $week_start_setting); |
|
877 | + $week_start = isset($_POST['_calendar_week_starts_on']) ? intval($_POST['_calendar_week_starts_on']) : get_option('start_of_week'); |
|
878 | + update_post_meta($post_id, '_calendar_week_starts_on', $week_start); |
|
879 | 879 | |
880 | 880 | // Cache interval. |
881 | 881 | $cache = 7200; |
882 | - if ( isset( $_POST['_feed_cache_user_amount'] ) && isset( $_POST['_feed_cache_user_unit'] ) ) { |
|
883 | - $amount = is_numeric( $_POST['_feed_cache_user_amount'] ) || $_POST['_feed_cache_user_amount'] == 0 ? absint( $_POST['_feed_cache_user_amount'] ) : 1; |
|
884 | - $unit = is_numeric( $_POST['_feed_cache_user_unit'] ) ? absint( $_POST['_feed_cache_user_unit'] ) : 3600; |
|
885 | - update_post_meta( $post_id, '_feed_cache_user_amount', $amount ); |
|
886 | - update_post_meta( $post_id, '_feed_cache_user_unit', $unit ); |
|
887 | - $cache = ( ( $amount * $unit ) > 0 ) ? $amount * $unit : 1; |
|
882 | + if (isset($_POST['_feed_cache_user_amount']) && isset($_POST['_feed_cache_user_unit'])) { |
|
883 | + $amount = is_numeric($_POST['_feed_cache_user_amount']) || $_POST['_feed_cache_user_amount'] == 0 ? absint($_POST['_feed_cache_user_amount']) : 1; |
|
884 | + $unit = is_numeric($_POST['_feed_cache_user_unit']) ? absint($_POST['_feed_cache_user_unit']) : 3600; |
|
885 | + update_post_meta($post_id, '_feed_cache_user_amount', $amount); |
|
886 | + update_post_meta($post_id, '_feed_cache_user_unit', $unit); |
|
887 | + $cache = (($amount * $unit) > 0) ? $amount * $unit : 1; |
|
888 | 888 | } |
889 | - update_post_meta( $post_id, '_feed_cache', $cache ); |
|
889 | + update_post_meta($post_id, '_feed_cache', $cache); |
|
890 | 890 | |
891 | 891 | /* ============= * |
892 | 892 | * Miscellaneous * |
893 | 893 | * ============= */ |
894 | 894 | |
895 | 895 | // Update version. |
896 | - update_post_meta( $post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION ); |
|
896 | + update_post_meta($post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION); |
|
897 | 897 | |
898 | 898 | // Action hook. |
899 | - do_action( 'simcal_process_settings_meta', $post_id ); |
|
899 | + do_action('simcal_process_settings_meta', $post_id); |
|
900 | 900 | |
901 | 901 | // Clear cache. |
902 | - simcal_delete_feed_transients( $post_id ); |
|
902 | + simcal_delete_feed_transients($post_id); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | } |
@@ -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 | |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @param string $version (optional) Current plugin version, defaults to value in plugin constant. |
65 | 65 | */ |
66 | - public function __construct( $version = SIMPLE_CALENDAR_VERSION ) { |
|
66 | + public function __construct($version = SIMPLE_CALENDAR_VERSION) { |
|
67 | 67 | // Look for previous version in current or legacy option, null for fresh install. |
68 | - $installed = get_option( 'simple-calendar_version', null ); |
|
69 | - $this->installed_ver = is_null( $installed ) ? get_option( 'gce_version', null ) : $installed; |
|
68 | + $installed = get_option('simple-calendar_version', null); |
|
69 | + $this->installed_ver = is_null($installed) ? get_option('gce_version', null) : $installed; |
|
70 | 70 | $this->new_ver = $version; |
71 | 71 | |
72 | - if ( version_compare( $this->installed_ver, $this->new_ver, '<' ) ) { |
|
72 | + if (version_compare($this->installed_ver, $this->new_ver, '<')) { |
|
73 | 73 | $this->run_updates(); |
74 | 74 | } |
75 | 75 | } |
@@ -83,18 +83,18 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function run_updates() { |
85 | 85 | |
86 | - do_action( 'simcal_before_update', $this->installed_ver ); |
|
86 | + do_action('simcal_before_update', $this->installed_ver); |
|
87 | 87 | |
88 | - if ( ! is_null( $this->installed_ver ) ) { |
|
88 | + if ( ! is_null($this->installed_ver)) { |
|
89 | 89 | |
90 | - if ( version_compare( $this->installed_ver, $this->new_ver ) === -1 ) { |
|
90 | + if (version_compare($this->installed_ver, $this->new_ver) === -1) { |
|
91 | 91 | |
92 | - $post_type = version_compare( $this->installed_ver, '3.0.0' ) === -1 ? 'gce_feed' : 'calendar'; |
|
93 | - $this->posts = $this->get_posts( $post_type ); |
|
92 | + $post_type = version_compare($this->installed_ver, '3.0.0') === -1 ? 'gce_feed' : 'calendar'; |
|
93 | + $this->posts = $this->get_posts($post_type); |
|
94 | 94 | |
95 | - foreach ( $this->update_path as $update_to ) { |
|
96 | - if ( version_compare( $this->installed_ver, $update_to, '<' ) ) { |
|
97 | - $this->update( $update_to ); |
|
95 | + foreach ($this->update_path as $update_to) { |
|
96 | + if (version_compare($this->installed_ver, $update_to, '<')) { |
|
97 | + $this->update($update_to); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -109,28 +109,28 @@ discard block |
||
109 | 109 | |
110 | 110 | } |
111 | 111 | |
112 | - do_action( 'simcal_updated', $this->new_ver ); |
|
112 | + do_action('simcal_updated', $this->new_ver); |
|
113 | 113 | |
114 | 114 | // Redirect to a welcome page if new install or major update. |
115 | - if ( is_null( $this->installed_ver ) ) { |
|
116 | - set_transient( '_simple-calendar_activation_redirect', 'fresh', 60 ); |
|
115 | + if (is_null($this->installed_ver)) { |
|
116 | + set_transient('_simple-calendar_activation_redirect', 'fresh', 60); |
|
117 | 117 | } else { |
118 | - $major_new = substr( $this->new_ver, 0, strrpos( $this->new_ver, '.' ) ); |
|
119 | - $major_old = substr( $this->installed_ver, 0, strrpos( $this->installed_ver, '.' ) ); |
|
120 | - if ( version_compare( $major_new, $major_old, '>' ) ) { |
|
121 | - set_transient( '_simple-calendar_activation_redirect', 'update', 60 ); |
|
122 | - } elseif ( $major_old == $major_new ) { |
|
123 | - $version = explode( '.', $this->new_ver ); |
|
124 | - end( $version ); |
|
125 | - if ( 0 === intval( current( $version ) ) ) { |
|
126 | - set_transient( '_simple-calendar_activation_redirect', 'update', 60 ); |
|
118 | + $major_new = substr($this->new_ver, 0, strrpos($this->new_ver, '.')); |
|
119 | + $major_old = substr($this->installed_ver, 0, strrpos($this->installed_ver, '.')); |
|
120 | + if (version_compare($major_new, $major_old, '>')) { |
|
121 | + set_transient('_simple-calendar_activation_redirect', 'update', 60); |
|
122 | + } elseif ($major_old == $major_new) { |
|
123 | + $version = explode('.', $this->new_ver); |
|
124 | + end($version); |
|
125 | + if (0 === intval(current($version))) { |
|
126 | + set_transient('_simple-calendar_activation_redirect', 'update', 60); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | 131 | $this->admin_redirects(); |
132 | 132 | |
133 | - update_option( 'simple-calendar_version', $this->new_ver ); |
|
133 | + update_option('simple-calendar_version', $this->new_ver); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -142,25 +142,25 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function admin_redirects() { |
144 | 144 | |
145 | - $transient = get_transient( '_simple-calendar_activation_redirect' ); |
|
145 | + $transient = get_transient('_simple-calendar_activation_redirect'); |
|
146 | 146 | |
147 | - if ( ! $transient || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { |
|
147 | + if ( ! $transient || is_network_admin() || isset($_GET['activate-multi']) || ! current_user_can('manage_options')) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | - delete_transient( '_simple-calendar_activation_redirect' ); |
|
151 | + delete_transient('_simple-calendar_activation_redirect'); |
|
152 | 152 | |
153 | 153 | // Do not redirect if already on welcome page screen. |
154 | - if ( ! empty( $_GET['page'] ) && in_array( $_GET['page'], array( 'simple-calendar_about' ) ) ) { |
|
154 | + if ( ! empty($_GET['page']) && in_array($_GET['page'], array('simple-calendar_about'))) { |
|
155 | 155 | return; |
156 | 156 | } |
157 | 157 | |
158 | 158 | $url = add_query_arg( |
159 | 159 | 'simcal_install', |
160 | - esc_attr( $transient ), |
|
161 | - admin_url( 'index.php?page=simple-calendar_about' ) |
|
160 | + esc_attr($transient), |
|
161 | + admin_url('index.php?page=simple-calendar_about') |
|
162 | 162 | ); |
163 | - wp_safe_redirect( $url ); |
|
163 | + wp_safe_redirect($url); |
|
164 | 164 | exit; |
165 | 165 | } |
166 | 166 | |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return array |
175 | 175 | */ |
176 | - private function get_posts( $post_type ) { |
|
176 | + private function get_posts($post_type) { |
|
177 | 177 | |
178 | 178 | $posts = array(); |
179 | 179 | |
180 | - if ( ! empty( $post_type ) ) { |
|
180 | + if ( ! empty($post_type)) { |
|
181 | 181 | |
182 | 182 | // https://core.trac.wordpress.org/ticket/18408 |
183 | - $posts = get_posts( array( |
|
183 | + $posts = get_posts(array( |
|
184 | 184 | 'post_type' => $post_type, |
185 | 185 | 'post_status' => array( |
186 | 186 | 'draft', |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'trash', |
192 | 192 | ), |
193 | 193 | 'nopaging' => true, |
194 | - ) ); |
|
194 | + )); |
|
195 | 195 | |
196 | 196 | wp_reset_postdata(); |
197 | 197 | } |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @param string $version |
210 | 210 | */ |
211 | - private function update( $version ) { |
|
211 | + private function update($version) { |
|
212 | 212 | |
213 | - $update_v = '\\' . __NAMESPACE__ . '\Updates\\Update_V' . str_replace( '.', '', $version ); |
|
213 | + $update_v = '\\'.__NAMESPACE__.'\Updates\\Update_V'.str_replace('.', '', $version); |
|
214 | 214 | |
215 | - if ( class_exists( $update_v ) ) { |
|
216 | - new $update_v( $this->posts ); |
|
215 | + if (class_exists($update_v)) { |
|
216 | + new $update_v($this->posts); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 |