Completed
Push — master ( afae5e...fce50c )
by
unknown
03:06
created
includes/functions/admin.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Admin functions
4
- *
5
- * Functions for the admin back end components only.
6
- *
7
- * @package SimpleCalendar/Admin/Functions
8
- */
3
+	 * Admin functions
4
+	 *
5
+	 * Functions for the admin back end components only.
6
+	 *
7
+	 * @package SimpleCalendar/Admin/Functions
8
+	 */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11 11
 	exit;
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 = '&#8984;&#43;C';
239 239
 	} else {
240 240
 		$cmd = 'Ctrl&#43;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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
includes/functions/shared.php 1 patch
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @package SimpleCalendar/Functions
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
@@ -20,17 +20,17 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function is_simple_calendar() {
22 22
 
23
-	if ( is_singular() ) {
23
+	if (is_singular()) {
24 24
 
25 25
 		global $post, $post_type;
26 26
 
27
-		if ( 'calendar' == $post_type ) {
27
+		if ('calendar' == $post_type) {
28 28
 			return true;
29 29
 		} else {
30
-			if ( false !== get_post_meta( $post->ID, '_simcal_attach_calendar_id', true ) ) {
30
+			if (false !== get_post_meta($post->ID, '_simcal_attach_calendar_id', true)) {
31 31
 				return true;
32 32
 			}
33
-			if ( has_shortcode( $post->post_content, 'calendar' ) ) {
33
+			if (has_shortcode($post->post_content, 'calendar')) {
34 34
 				return true;
35 35
 			}
36 36
 		}
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return string
48 48
  */
49
-function simcal_get_url( $url ) {
50
-	return \SimpleCalendar\plugin()->get_url( $url );
49
+function simcal_get_url($url) {
50
+	return \SimpleCalendar\plugin()->get_url($url);
51 51
 }
52 52
 
53 53
 /**
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
  *
72 72
  * @return null|\SimpleCalendar\Abstracts\Feed
73 73
  */
74
-function simcal_get_feed( $object ) {
74
+function simcal_get_feed($object) {
75 75
 	$objects = \SimpleCalendar\plugin()->objects;
76
-	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_feed( $object ) : null;
76
+	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_feed($object) : null;
77 77
 }
78 78
 
79 79
 /**
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
  *
98 98
  * @return null|\SimpleCalendar\Abstracts\Calendar
99 99
  */
100
-function simcal_get_calendar( $object ) {
100
+function simcal_get_calendar($object) {
101 101
 	$objects = \SimpleCalendar\plugin()->objects;
102
-	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar( $object ) : null;
102
+	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar($object) : null;
103 103
 }
104 104
 
105 105
 /**
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
  *
113 113
  * @return mixed
114 114
  */
115
-function simcal_get_calendar_view( $id = 0, $name = '' ) {
115
+function simcal_get_calendar_view($id = 0, $name = '') {
116 116
 	$objects = \SimpleCalendar\plugin()->objects;
117
-	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar_view( $id, $name ) : false;
117
+	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar_view($id, $name) : false;
118 118
 }
119 119
 
120 120
 /**
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
  *
127 127
  * @return void
128 128
  */
129
-function simcal_print_calendar( $object ) {
129
+function simcal_print_calendar($object) {
130 130
 
131
-	$calendar = simcal_get_calendar( $object );
131
+	$calendar = simcal_get_calendar($object);
132 132
 
133
-	if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) {
133
+	if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) {
134 134
 		$calendar->html();
135 135
 	}
136 136
 }
@@ -148,21 +148,21 @@  discard block
 block discarded – undo
148 148
 
149 149
 	$vars = array(
150 150
 		'ajax_url'  => \SimpleCalendar\plugin()->ajax_url(),
151
-		'nonce'     => wp_create_nonce( 'simcal' ),
151
+		'nonce'     => wp_create_nonce('simcal'),
152 152
 		'locale'    => \SimpleCalendar\plugin()->locale,
153 153
 		'text_dir'  => is_rtl() ? 'rtl' : 'ltr',
154 154
 		'months'    => array(
155
-			'full'  => simcal_get_calendar_names_i18n( 'month', 'full' ),
156
-			'short' => simcal_get_calendar_names_i18n( 'month', 'short' ),
155
+			'full'  => simcal_get_calendar_names_i18n('month', 'full'),
156
+			'short' => simcal_get_calendar_names_i18n('month', 'short'),
157 157
 		),
158 158
 		'days'      => array(
159
-			'full'  => simcal_get_calendar_names_i18n( 'day', 'full' ),
160
-			'short' => simcal_get_calendar_names_i18n( 'day', 'short' ),
159
+			'full'  => simcal_get_calendar_names_i18n('day', 'full'),
160
+			'short' => simcal_get_calendar_names_i18n('day', 'short'),
161 161
 		),
162
-		'meridiem' => simcal_get_calendar_names_i18n( 'meridiem' ),
162
+		'meridiem' => simcal_get_calendar_names_i18n('meridiem'),
163 163
 	);
164 164
 
165
-	return array_merge( $vars, apply_filters( 'simcal_common_scripts_variables', array() ) );
165
+	return array_merge($vars, apply_filters('simcal_common_scripts_variables', array()));
166 166
 }
167 167
 
168 168
 /**
@@ -175,31 +175,31 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return array Associative array with ids as keys and feed titles as values.
177 177
  */
178
-function simcal_get_calendars( $exclude = '', $cached = true ) {
178
+function simcal_get_calendars($exclude = '', $cached = true) {
179 179
 
180
-	$calendars = get_transient( '_simple-calendar_feed_ids' );
180
+	$calendars = get_transient('_simple-calendar_feed_ids');
181 181
 
182
-	if ( ! $calendars || $cached === false ) {
182
+	if ( ! $calendars || $cached === false) {
183 183
 
184
-		$posts = get_posts( array(
184
+		$posts = get_posts(array(
185 185
 			'post_type' => 'calendar',
186 186
 			'nopaging'  => true,
187
-		) );
187
+		));
188 188
 
189 189
 		$calendars = array();
190
-		foreach ( $posts as $post ) {
191
-			$calendars[ $post->ID ] = $post->post_title;
190
+		foreach ($posts as $post) {
191
+			$calendars[$post->ID] = $post->post_title;
192 192
 		}
193
-		asort( $calendars );
193
+		asort($calendars);
194 194
 
195
-		set_transient( '_simple-calendar_feed_ids', $calendars, 604800 );
195
+		set_transient('_simple-calendar_feed_ids', $calendars, 604800);
196 196
 	}
197 197
 
198
-	if ( ! empty( $exclude ) ) {
199
-		if ( is_numeric( $exclude ) ) {
200
-			unset( $calendars[ intval( $exclude ) ] );
201
-		} elseif ( is_array( $exclude ) ) {
202
-			array_diff_key( $calendars, array_map( 'intval', array_keys( $exclude ) ) );
198
+	if ( ! empty($exclude)) {
199
+		if (is_numeric($exclude)) {
200
+			unset($calendars[intval($exclude)]);
201
+		} elseif (is_array($exclude)) {
202
+			array_diff_key($calendars, array_map('intval', array_keys($exclude)));
203 203
 		}
204 204
 	}
205 205
 
@@ -218,45 +218,45 @@  discard block
 block discarded – undo
218 218
  *
219 219
  * @return array
220 220
  */
221
-function simcal_get_calendar_names_i18n( $group, $style = 'full' ) {
221
+function simcal_get_calendar_names_i18n($group, $style = 'full') {
222 222
 
223 223
 	$names = array();
224 224
 
225
-	if ( in_array( $group, array( 'month', 'day', 'meridiem' ) ) ) {
225
+	if (in_array($group, array('month', 'day', 'meridiem'))) {
226 226
 
227 227
 		$format = '';
228 228
 		$length = 0;
229 229
 
230 230
 		$date = Carbon\Carbon::now();
231 231
 
232
-		if ( 'month' == $group ) {
233
-			$date->month( 0 )->startOfMonth();
232
+		if ('month' == $group) {
233
+			$date->month(0)->startOfMonth();
234 234
 			$format = 'short' == $style ? 'M' : 'F';
235 235
 			$length = 11;
236
-		} elseif ( 'day' == $group ) {
237
-			$date->next( 6 );
236
+		} elseif ('day' == $group) {
237
+			$date->next(6);
238 238
 			$format = 'short' == $style ? 'D' : 'l';
239 239
 			$length = 6;
240
-		} elseif ( 'meridiem' == $group ) {
240
+		} elseif ('meridiem' == $group) {
241 241
 			$date->startOfDay();
242
-			$am = $date->addHour( 1 )->getTimestamp();
243
-			$pm = $date->addHours( 13 )->getTimestamp();
242
+			$am = $date->addHour(1)->getTimestamp();
243
+			$pm = $date->addHours(13)->getTimestamp();
244 244
 			return array(
245
-				'AM' => date_i18n( 'A', $am ),
246
-				'am' => date_i18n( 'a', $am ),
247
-				'PM' => date_i18n( 'A', $pm ),
248
-				'pm' => date_i18n( 'a', $pm ),
245
+				'AM' => date_i18n('A', $am),
246
+				'am' => date_i18n('a', $am),
247
+				'PM' => date_i18n('A', $pm),
248
+				'pm' => date_i18n('a', $pm),
249 249
 			);
250 250
 		}
251 251
 
252 252
 		$i = 0;
253
-		while ( $i <= $length ) {
254
-			if ( 'month' == $group ) {
255
-				$date->addMonths( 1 );
253
+		while ($i <= $length) {
254
+			if ('month' == $group) {
255
+				$date->addMonths(1);
256 256
 			} else {
257
-				$date->addDays( 1 );
257
+				$date->addDays(1);
258 258
 			}
259
-			$names[ strval( $i ) ] = date_i18n( $format, $date->getTimestamp() );
259
+			$names[strval($i)] = date_i18n($format, $date->getTimestamp());
260 260
 			$i++;
261 261
 		}
262 262
 
@@ -274,15 +274,15 @@  discard block
 block discarded – undo
274 274
  */
275 275
 function simcal_default_event_template() {
276 276
 
277
-	$content  = '<strong>' . '[title]' . '</strong>';
277
+	$content  = '<strong>'.'[title]'.'</strong>';
278 278
 	$content .= '<p>';
279
-	$content .= '[when]' . "\n";
279
+	$content .= '[when]'."\n";
280 280
 	$content .= '[location]';
281 281
 	$content .= '</p>';
282
-	$content .= '<div>' . '[description]' . '</div>';
283
-	$content .= '<p>' . '[link newwindow="yes"]' . __( 'See more details', 'google-calendar-events' ) . '[/link]' . '</p>';
282
+	$content .= '<div>'.'[description]'.'</div>';
283
+	$content .= '<p>'.'[link newwindow="yes"]'.__('See more details', 'google-calendar-events').'[/link]'.'</p>';
284 284
 
285
-	return apply_filters( 'simcal_default_event_template', $content );
285
+	return apply_filters('simcal_default_event_template', $content);
286 286
 }
287 287
 
288 288
 /**
@@ -297,21 +297,21 @@  discard block
 block discarded – undo
297 297
  *
298 298
  * @return array
299 299
  */
300
-function simcal_get_date_format_order( $date_format ) {
300
+function simcal_get_date_format_order($date_format) {
301 301
 
302 302
 	$pos = array(
303
-		'd' => strpos( $date_format, strpbrk( $date_format, 'Dj' ) ),
304
-		'm' => strpos( $date_format, strpbrk( $date_format, 'FMmn' ) ),
305
-		'y' => strpos( $date_format, strpbrk( $date_format, 'Yy' ) ),
303
+		'd' => strpos($date_format, strpbrk($date_format, 'Dj')),
304
+		'm' => strpos($date_format, strpbrk($date_format, 'FMmn')),
305
+		'y' => strpos($date_format, strpbrk($date_format, 'Yy')),
306 306
 	);
307 307
 
308 308
 	// @TODO When one date piece is not found, perhaps fallback to ISO standard position.
309 309
 
310 310
 	$order = array();
311
-	foreach ( $pos as $k => $v ) {
312
-		$order[ $k ] = $v;
311
+	foreach ($pos as $k => $v) {
312
+		$order[$k] = $v;
313 313
 	}
314
-	ksort( $order );
314
+	ksort($order);
315 315
 
316 316
 	return $order;
317 317
 }
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
  */
328 328
 function simcal_get_wp_timezone() {
329 329
 
330
-	$timezone = get_option( 'timezone_string' );
330
+	$timezone = get_option('timezone_string');
331 331
 
332
-	if ( empty( $timezone ) ) {
333
-		$gmt = get_option( 'gmt_offset' );
334
-		$timezone = simcal_get_timezone_from_gmt_offset( $gmt );
332
+	if (empty($timezone)) {
333
+		$gmt = get_option('gmt_offset');
334
+		$timezone = simcal_get_timezone_from_gmt_offset($gmt);
335 335
 	}
336 336
 
337 337
 	return $timezone;
@@ -348,26 +348,26 @@  discard block
 block discarded – undo
348 348
  *
349 349
  * @return null|string
350 350
  */
351
-function simcal_get_timezone_from_gmt_offset( $offset ) {
351
+function simcal_get_timezone_from_gmt_offset($offset) {
352 352
 
353
-	if ( is_numeric( $offset ) ) {
353
+	if (is_numeric($offset)) {
354 354
 
355
-		if ( 0 === intval( $offset ) ) {
355
+		if (0 === intval($offset)) {
356 356
 			return 'UTC';
357 357
 		} else {
358
-			$offset = floatval( $offset ) * 3600;
358
+			$offset = floatval($offset) * 3600;
359 359
 		}
360 360
 
361
-		$timezone = timezone_name_from_abbr( null, $offset, false );
361
+		$timezone = timezone_name_from_abbr(null, $offset, false);
362 362
 		// This is buggy and might return false:
363 363
 		// @see http://php.net/manual/en/function.timezone-name-from-abbr.php#86928
364 364
 		// Therefore:
365
-		if ( false == $timezone ) {
365
+		if (false == $timezone) {
366 366
 
367 367
 			$list = timezone_abbreviations_list();
368
-			foreach ( $list as $abbr ) {
369
-				foreach ( $abbr as $city ) {
370
-					if ( $offset == $city['offset'] ) {
368
+			foreach ($list as $abbr) {
369
+				foreach ($abbr as $city) {
370
+					if ($offset == $city['offset']) {
371 371
 						return $city['timezone_id'];
372 372
 					}
373 373
 				}
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
  *
391 391
  * @return int Unix time offset
392 392
  */
393
-function simcal_get_timezone_offset( $timezone ) {
394
-	return \Carbon\Carbon::now( $timezone )->offset;
393
+function simcal_get_timezone_offset($timezone) {
394
+	return \Carbon\Carbon::now($timezone)->offset;
395 395
 }
396 396
 
397 397
 /**
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
  *
405 405
  * @return mixed|string
406 406
  */
407
-function simcal_esc_timezone( $tz, $default = 'UTC' ) {
408
-	return in_array( $tz, timezone_identifiers_list() ) ? $tz : $default;
407
+function simcal_esc_timezone($tz, $default = 'UTC') {
408
+	return in_array($tz, timezone_identifiers_list()) ? $tz : $default;
409 409
 }
410 410
 
411 411
 /**
@@ -417,57 +417,57 @@  discard block
 block discarded – undo
417 417
  *
418 418
  * @return bool
419 419
  */
420
-function simcal_delete_feed_transients( $id = '' ) {
420
+function simcal_delete_feed_transients($id = '') {
421 421
 
422
-	$grouped_ids = get_post_meta( $id, '_grouped_calendars_ids', true );
422
+	$grouped_ids = get_post_meta($id, '_grouped_calendars_ids', true);
423 423
 
424 424
 	// If there are group IDs we need to construct an array to pass along with the grouped IDs + the original $post_id
425
-	if ( is_array( $grouped_ids ) ) {
425
+	if (is_array($grouped_ids)) {
426 426
 		$temp_id = $id;
427 427
 		$id = $grouped_ids;
428 428
 		$id[] = $temp_id;
429 429
 	}
430 430
 
431
-	if ( is_numeric( $id ) ) {
432
-		$id = intval( $id ) > 0 ? absint( $id ) : simcal_get_calendars();
433
-	} elseif ( $id instanceof WP_Post ) {
431
+	if (is_numeric($id)) {
432
+		$id = intval($id) > 0 ? absint($id) : simcal_get_calendars();
433
+	} elseif ($id instanceof WP_Post) {
434 434
 		$id = $id->ID;
435
-	} elseif ( is_array( $id ) ) {
436
-		$id = array_map( 'absint', $id );
435
+	} elseif (is_array($id)) {
436
+		$id = array_map('absint', $id);
437 437
 	} else {
438
-		$id = simcal_get_calendars( '', true );
438
+		$id = simcal_get_calendars('', true);
439 439
 	}
440 440
 
441 441
 	$feed_types = simcal_get_feed_types();
442 442
 
443
-	if ( is_array( $id ) ) {
443
+	if (is_array($id)) {
444 444
 
445
-		$posts = get_posts( array(
445
+		$posts = get_posts(array(
446 446
 				'post_type' => 'calendar',
447 447
 				'fields'    => 'ids',
448 448
 				'post__in'  => $id,
449 449
 				'nopaging'  => true,
450
-		) );
450
+		));
451 451
 
452
-		foreach ( $posts as $post ) {
453
-			$calendar = simcal_get_calendar( $post );
454
-			if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) {
455
-				foreach ( $feed_types as $feed_type ) {
456
-					delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type );
452
+		foreach ($posts as $post) {
453
+			$calendar = simcal_get_calendar($post);
454
+			if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) {
455
+				foreach ($feed_types as $feed_type) {
456
+					delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type);
457 457
 				}
458 458
 			}
459 459
 		}
460 460
 
461 461
 	} else {
462 462
 
463
-		$post = get_post( $id );
464
-		$calendar = simcal_get_calendar( $post );
465
-		if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) {
466
-			foreach ( $feed_types as $feed_type ) {
467
-				delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type );
463
+		$post = get_post($id);
464
+		$calendar = simcal_get_calendar($post);
465
+		if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) {
466
+			foreach ($feed_types as $feed_type) {
467
+				delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type);
468 468
 			}
469 469
 		}
470 470
 	}
471 471
 
472
-	return delete_transient( '_simple-calendar_feed_ids' );
472
+	return delete_transient('_simple-calendar_feed_ids');
473 473
 }
474 474
\ No newline at end of file
Please login to merge, or discard this patch.
includes/events/event-builder.php 1 patch
Spacing   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 use Carbon\Carbon;
10 10
 use SimpleCalendar\Abstracts\Calendar;
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param Event    $event
55 55
 	 * @param Calendar $calendar
56 56
 	 */
57
-	public function __construct( Event $event, Calendar $calendar ) {
57
+	public function __construct(Event $event, Calendar $calendar) {
58 58
 		$this->event    = $event;
59 59
 		$this->calendar = $calendar;
60 60
 		$this->tags     = $this->get_content_tags();
@@ -74,84 +74,84 @@  discard block
 block discarded – undo
74 74
 			 * Content Tags *
75 75
 			 * ============ */
76 76
 
77
-			'title',                 // The event title.
78
-			'event-title',           // @deprecated An alias for 'title' tag.
79
-			'description',           // The event description.
80
-
81
-			'when',                  // Date and time of the event.
82
-			'start-time',            // Start time of the event.
83
-			'start-date',            // Start date of the event.
84
-			'start-custom',          // @deprecated Start time in a user defined format (set by tag 'format' attribute).
85
-			'start-human',           // Start time in a human friendly format.
86
-			'end-time',              // End time of the event.
87
-			'end-date',              // End date of the event.
88
-			'end-custom',            // @deprecated End date-time in a user defined format (set by tag 'format' attribute).
89
-			'end-human',             // End date-time in a human friendly format.
90
-
91
-			'duration',              // How long the events lasts, in a human-readable format.
92
-			'length',                // @deprecated An alias of 'duration' tag.
93
-
94
-			'location',              // Alias of start-location.
95
-			'start-location',        // Location name where the event starts.
96
-			'maps-link',             // @deprecated An alias for 'start-location-link' tag.
97
-			'start-location-link',   // Link to Google Maps querying the event start location address.
98
-			'end-location',          // Location name where the event ends.
99
-			'end-location-link',     // Link to Google Maps querying the event end location address.
100
-
101
-			'link',                  // An HTML link to the event URL.
102
-			'url',                   // A string with the raw event link URL.
103
-
104
-			'calendar',              // The title of the source calendar.
105
-			'feed-title',            // @deprecated An alias of 'calendar'.
106
-
107
-			'id',                    // The event unique ID.
108
-			'uid',                   // An alias of ID.
109
-			'event-id',              // @deprecated An alias for 'id' tag.
110
-			'calendar-id',           // The calendar ID.
111
-			'feed-id',               // @deprecated An alias for 'calendar-id' tag.
112
-			'cal-id',                // @deprecated An alias for 'calendar-id' tag.
77
+			'title', // The event title.
78
+			'event-title', // @deprecated An alias for 'title' tag.
79
+			'description', // The event description.
80
+
81
+			'when', // Date and time of the event.
82
+			'start-time', // Start time of the event.
83
+			'start-date', // Start date of the event.
84
+			'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute).
85
+			'start-human', // Start time in a human friendly format.
86
+			'end-time', // End time of the event.
87
+			'end-date', // End date of the event.
88
+			'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute).
89
+			'end-human', // End date-time in a human friendly format.
90
+
91
+			'duration', // How long the events lasts, in a human-readable format.
92
+			'length', // @deprecated An alias of 'duration' tag.
93
+
94
+			'location', // Alias of start-location.
95
+			'start-location', // Location name where the event starts.
96
+			'maps-link', // @deprecated An alias for 'start-location-link' tag.
97
+			'start-location-link', // Link to Google Maps querying the event start location address.
98
+			'end-location', // Location name where the event ends.
99
+			'end-location-link', // Link to Google Maps querying the event end location address.
100
+
101
+			'link', // An HTML link to the event URL.
102
+			'url', // A string with the raw event link URL.
103
+
104
+			'calendar', // The title of the source calendar.
105
+			'feed-title', // @deprecated An alias of 'calendar'.
106
+
107
+			'id', // The event unique ID.
108
+			'uid', // An alias of ID.
109
+			'event-id', // @deprecated An alias for 'id' tag.
110
+			'calendar-id', // The calendar ID.
111
+			'feed-id', // @deprecated An alias for 'calendar-id' tag.
112
+			'cal-id', // @deprecated An alias for 'calendar-id' tag.
113 113
 
114 114
 			/* ========= *
115 115
 			 * Meta Tags *
116 116
 			 * ========= */
117 117
 
118
-			'attachments',          // List of attachments.
119
-			'attendees',            // List of attendees.
120
-			'organizer',            // Creator info.
118
+			'attachments', // List of attachments.
119
+			'attendees', // List of attendees.
120
+			'organizer', // Creator info.
121 121
 
122 122
 			/* ================ *
123 123
 			 * Conditional Tags *
124 124
 			 * ================ */
125 125
 
126
-			'if-title',              // If the event has a title.
127
-			'if-description',        // If the event has a description.
128
-
129
-			'if-now',                // If the event is taking place now.
130
-			'if-not-now',            // If the event is not taking place now (may have ended or just not started yet).
131
-			'if-started',            // If the event has started (and may as well as ended).
132
-			'if-not-started',        // If the event has NOT started yet (event could be any time in the future).
133
-			'if-ended',              // If the event has ended (event could be any time in the past).
134
-			'if-not-ended',          // If the event has NOT ended (may as well as not started yet).
135
-
136
-			'if-whole-day',          // If the event lasts the whole day.
137
-			'if-all-day',            // @deprecated Alias for 'if-whole-day'.
138
-			'if-not-whole-day',      // If the event does NOT last the whole day.
139
-			'if-not-all-day',        // @deprecated Alias for 'if-not-whole-day'.
140
-			'if-end-time',           // If the event has a set end time.
141
-			'if-no-end-time',        // If the event has NOT a set end time.
142
-
143
-			'if-multi-day',          // If the event spans multiple days.
144
-			'if-single-day',         // If the event does not span multiple days.
145
-
146
-			'if-recurring',          // If the event is a recurring event.
147
-			'if-not-recurring',      // If the event is NOT a recurring event.
148
-
149
-			'if-location',           // @deprecated Alias for 'if-start-location'.
150
-			'if-start-location',     // Does the event has a start location?
151
-			'if-end-location',       // Does the event has an end location?
152
-			'if-not-location',       // @deprecated Alias for 'if-not-start-location'.
126
+			'if-title', // If the event has a title.
127
+			'if-description', // If the event has a description.
128
+
129
+			'if-now', // If the event is taking place now.
130
+			'if-not-now', // If the event is not taking place now (may have ended or just not started yet).
131
+			'if-started', // If the event has started (and may as well as ended).
132
+			'if-not-started', // If the event has NOT started yet (event could be any time in the future).
133
+			'if-ended', // If the event has ended (event could be any time in the past).
134
+			'if-not-ended', // If the event has NOT ended (may as well as not started yet).
135
+
136
+			'if-whole-day', // If the event lasts the whole day.
137
+			'if-all-day', // @deprecated Alias for 'if-whole-day'.
138
+			'if-not-whole-day', // If the event does NOT last the whole day.
139
+			'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'.
140
+			'if-end-time', // If the event has a set end time.
141
+			'if-no-end-time', // If the event has NOT a set end time.
142
+
143
+			'if-multi-day', // If the event spans multiple days.
144
+			'if-single-day', // If the event does not span multiple days.
145
+
146
+			'if-recurring', // If the event is a recurring event.
147
+			'if-not-recurring', // If the event is NOT a recurring event.
148
+
149
+			'if-location', // @deprecated Alias for 'if-start-location'.
150
+			'if-start-location', // Does the event has a start location?
151
+			'if-end-location', // Does the event has an end location?
152
+			'if-not-location', // @deprecated Alias for 'if-not-start-location'.
153 153
 			'if-not-start-location', // Does the event has NOT a start location?
154
-			'if-not-end-location',   // Does the event has NOT an end location?
154
+			'if-not-end-location', // Does the event has NOT an end location?
155 155
 
156 156
 		);
157 157
 	}
@@ -165,17 +165,17 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @return string
167 167
 	 */
168
-	public function parse_event_template_tags( $template_tags = '' ) {
168
+	public function parse_event_template_tags($template_tags = '') {
169 169
 
170 170
 		// Process tags.
171 171
 		$result = preg_replace_callback(
172 172
 			$this->get_regex(),
173
-			array( $this, 'process_event_content' ),
173
+			array($this, 'process_event_content'),
174 174
 			$template_tags
175 175
 		);
176 176
 
177 177
 		// Removes extra consecutive <br> tags.
178
-		return preg_replace( '#(<br */?>\s*)+#i', '<br />', trim( $result ) );
178
+		return preg_replace('#(<br */?>\s*)+#i', '<br />', trim($result));
179 179
 	}
180 180
 
181 181
 	/**
@@ -187,10 +187,10 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @return string
189 189
 	 */
190
-	public function process_event_content( $match ) {
190
+	public function process_event_content($match) {
191 191
 
192
-		if ( $match[1] == '[' && $match[6] == ']' ) {
193
-			return substr( $match[0], 1, - 1 );
192
+		if ($match[1] == '[' && $match[6] == ']') {
193
+			return substr($match[0], 1, - 1);
194 194
 		}
195 195
 
196 196
 		$tag     = $match[2]; // Tag name without square brackets.
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
 		$calendar = $this->calendar;
203 203
 		$event    = $this->event;
204 204
 
205
-		if ( ( $calendar instanceof Calendar ) && ( $event instanceof Event ) ) {
205
+		if (($calendar instanceof Calendar) && ($event instanceof Event)) {
206 206
 
207
-			switch ( $tag ) {
207
+			switch ($tag) {
208 208
 
209 209
 				/* ============ *
210 210
 				 * Content Tags *
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
 
213 213
 				case 'title' :
214 214
 				case 'event-title' :
215
-					return $this->get_title( $event->title, $attr );
215
+					return $this->get_title($event->title, $attr);
216 216
 
217 217
 				case 'description' :
218
-					return $this->get_description( $event->description, $attr );
218
+					return $this->get_description($event->description, $attr);
219 219
 
220 220
 				case 'when' :
221
-					return $this->get_when( $event );
221
+					return $this->get_when($event);
222 222
 
223 223
 				case 'end-date' :
224 224
 				case 'end-custom' :
@@ -228,40 +228,40 @@  discard block
 block discarded – undo
228 228
 				case 'start-date' :
229 229
 				case 'start-human' :
230 230
 				case 'start-time' :
231
-					return $this->get_dt( $tag, $event, $attr );
231
+					return $this->get_dt($tag, $event, $attr);
232 232
 
233 233
 				case 'length' :
234 234
 				case 'duration' :
235
-					if ( false !== $event->end ) {
235
+					if (false !== $event->end) {
236 236
 						$duration = $event->start - $event->end;
237
-						$value    = human_time_diff( $event->start, $event->end );
237
+						$value    = human_time_diff($event->start, $event->end);
238 238
 					} else {
239 239
 						$duration = '-1';
240
-						$value    = __( 'No end time', 'google-calendar-events' );
240
+						$value    = __('No end time', 'google-calendar-events');
241 241
 					}
242
-					return ' <span class="simcal-event-duration" data-event-duration="' . $duration . '">' . $value . '</span>';
242
+					return ' <span class="simcal-event-duration" data-event-duration="'.$duration.'">'.$value.'</span>';
243 243
 
244 244
 				case 'location' :
245 245
 				case 'start-location' :
246 246
 				case 'end-location' :
247 247
 					$location = $tag == 'end-location' ? $event->end_location['address'] : $event->start_location['address'];
248 248
 					$location_class = $tag == 'end-location' ? 'end' : 'start';
249
-					return ' <span class="simcal-event-address simcal-event-' . $location_class . '-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . wp_strip_all_tags( $location ) . '</span>';
249
+					return ' <span class="simcal-event-address simcal-event-'.$location_class.'-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'.wp_strip_all_tags($location).'</span>';
250 250
 
251 251
 				case 'start-location-link':
252 252
 				case 'end-location-link' :
253 253
 				case 'maps-link' :
254 254
 					$location = $tag == 'end-location-link' ? $event->end_location['address'] : $event->start_location['address'];
255
-					if ( ! empty( $location ) ) {
256
-						$url = '//maps.google.com?q=' . urlencode( $location );
257
-						return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr );
255
+					if ( ! empty($location)) {
256
+						$url = '//maps.google.com?q='.urlencode($location);
257
+						return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr);
258 258
 					}
259 259
 					break;
260 260
 
261 261
 				case 'link' :
262 262
 				case 'url' :
263
-					$content = 'link' == $tag ? $calendar->get_event_html( $event, $partial ) : '';
264
-					return $this->make_link( $tag, $event->link, $content , $attr );
263
+					$content = 'link' == $tag ? $calendar->get_event_html($event, $partial) : '';
264
+					return $this->make_link($tag, $event->link, $content, $attr);
265 265
 
266 266
 				case 'calendar' :
267 267
 				case 'feed-title' :
@@ -283,22 +283,22 @@  discard block
 block discarded – undo
283 283
 
284 284
 				case 'attachments' :
285 285
 					$attachments = $event->get_attachments();
286
-					if ( ! empty( $attachments ) ) {
287
-						return $this->get_attachments( $attachments );
286
+					if ( ! empty($attachments)) {
287
+						return $this->get_attachments($attachments);
288 288
 					}
289 289
 					break;
290 290
 
291 291
 				case 'attendees' :
292 292
 					$attendees = $event->get_attendees();
293
-					if ( ! empty( $attendees ) ) {
294
-						return $this->get_attendees( $attendees, $attr );
293
+					if ( ! empty($attendees)) {
294
+						return $this->get_attendees($attendees, $attr);
295 295
 					}
296 296
 					break;
297 297
 
298 298
 				case 'organizer' :
299 299
 					$organizer = $event->get_organizer();
300
-					if ( ! empty( $organizer ) ) {
301
-						return $this->get_organizer( $organizer, $attr );
300
+					if ( ! empty($organizer)) {
301
+						return $this->get_organizer($organizer, $attr);
302 302
 					}
303 303
 					break;
304 304
 
@@ -307,35 +307,35 @@  discard block
 block discarded – undo
307 307
 				 * ================ */
308 308
 
309 309
 				case 'if-title':
310
-					if ( ! empty( $event->title ) ) {
311
-						return $calendar->get_event_html( $event, $partial );
310
+					if ( ! empty($event->title)) {
311
+						return $calendar->get_event_html($event, $partial);
312 312
 					}
313 313
 					break;
314 314
 
315 315
 				case 'if-description':
316
-					if ( ! empty( $event->description ) ) {
317
-						return $calendar->get_event_html( $event, $partial );
316
+					if ( ! empty($event->description)) {
317
+						return $calendar->get_event_html($event, $partial);
318 318
 					}
319 319
 					break;
320 320
 
321 321
 				case 'if-now' :
322 322
 				case 'if-not-now' :
323 323
 
324
-					$start_dt = $event->start_dt->setTimezone( $calendar->timezone );
324
+					$start_dt = $event->start_dt->setTimezone($calendar->timezone);
325 325
 					$start = $start_dt->getTimestamp();
326 326
 
327
-					if ( $event->end_dt instanceof Carbon ) {
328
-						$end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp();
327
+					if ($event->end_dt instanceof Carbon) {
328
+						$end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp();
329 329
 					} else {
330 330
 						return '';
331 331
 					}
332 332
 
333
-					$now = ( $start <= $calendar->now ) && ( $end >= $calendar->now );
333
+					$now = ($start <= $calendar->now) && ($end >= $calendar->now);
334 334
 
335
-					if ( ( 'if-now' == $tag ) && $now ) {
336
-						return $calendar->get_event_html( $event, $partial );
337
-					} elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) {
338
-						return $calendar->get_event_html( $event, $partial );
335
+					if (('if-now' == $tag) && $now) {
336
+						return $calendar->get_event_html($event, $partial);
337
+					} elseif (('if-not-now' == $tag) && (false == $now)) {
338
+						return $calendar->get_event_html($event, $partial);
339 339
 					}
340 340
 
341 341
 					break;
@@ -343,15 +343,15 @@  discard block
 block discarded – undo
343 343
 				case 'if-started' :
344 344
 				case 'if-not-started' :
345 345
 
346
-					$start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp();
346
+					$start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp();
347 347
 
348
-					if ( 'if-started' == $tag ) {
349
-						if ( $start < $calendar->now ) {
350
-							return $calendar->get_event_html( $event, $partial );
348
+					if ('if-started' == $tag) {
349
+						if ($start < $calendar->now) {
350
+							return $calendar->get_event_html($event, $partial);
351 351
 						}
352
-					} elseif ( 'if-not-started' == $tag ) {
353
-						if ( $start > $calendar->now ) {
354
-							return $calendar->get_event_html( $event, $partial );
352
+					} elseif ('if-not-started' == $tag) {
353
+						if ($start > $calendar->now) {
354
+							return $calendar->get_event_html($event, $partial);
355 355
 						}
356 356
 					}
357 357
 
@@ -360,17 +360,17 @@  discard block
 block discarded – undo
360 360
 				case 'if-ended' :
361 361
 				case 'if-not-ended' :
362 362
 
363
-					if ( false !== $event->end ) {
363
+					if (false !== $event->end) {
364 364
 
365
-						$end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp();
365
+						$end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp();
366 366
 
367
-						if ( 'if-ended' == $tag ) {
368
-							if ( $end < $calendar->now ) {
369
-								return $calendar->get_event_html( $event, $partial );
367
+						if ('if-ended' == $tag) {
368
+							if ($end < $calendar->now) {
369
+								return $calendar->get_event_html($event, $partial);
370 370
 							}
371
-						} elseif ( 'if-not-ended' == $tag ) {
372
-							if ( $end > $calendar->now ) {
373
-								return $calendar->get_event_html( $event, $partial );
371
+						} elseif ('if-not-ended' == $tag) {
372
+							if ($end > $calendar->now) {
373
+								return $calendar->get_event_html($event, $partial);
374 374
 							}
375 375
 						}
376 376
 
@@ -379,14 +379,14 @@  discard block
 block discarded – undo
379 379
 					break;
380 380
 
381 381
 				case 'if-end-time' :
382
-					if ( false !== $event->end ) {
383
-						return $calendar->get_event_html( $event, $partial );
382
+					if (false !== $event->end) {
383
+						return $calendar->get_event_html($event, $partial);
384 384
 					}
385 385
 					break;
386 386
 
387 387
 				case 'if-no-end-time' :
388
-					if ( false === $event->end ) {
389
-						return $calendar->get_event_html( $event, $partial );
388
+					if (false === $event->end) {
389
+						return $calendar->get_event_html($event, $partial);
390 390
 					}
391 391
 					break;
392 392
 
@@ -394,59 +394,59 @@  discard block
 block discarded – undo
394 394
 				case 'if-whole-day' :
395 395
 				case 'if-not-all-day' :
396 396
 				case 'if-not-whole-day' :
397
-					$bool = strstr( $tag, 'not' ) ? false : true;
398
-					if ( $bool === $event->whole_day ) {
399
-						return $calendar->get_event_html( $event, $partial );
397
+					$bool = strstr($tag, 'not') ? false : true;
398
+					if ($bool === $event->whole_day) {
399
+						return $calendar->get_event_html($event, $partial);
400 400
 					}
401 401
 					break;
402 402
 
403 403
 				case 'if-recurring' :
404
-					if ( ! empty( $event->recurrence ) ) {
405
-						return $calendar->get_event_html( $event, $partial );
404
+					if ( ! empty($event->recurrence)) {
405
+						return $calendar->get_event_html($event, $partial);
406 406
 					}
407 407
 					break;
408 408
 
409 409
 				case 'if-not-recurring' :
410
-					if ( false === $event->recurrence ) {
411
-						return $calendar->get_event_html( $event, $partial );
410
+					if (false === $event->recurrence) {
411
+						return $calendar->get_event_html($event, $partial);
412 412
 					}
413 413
 					break;
414 414
 
415 415
 				case 'if-multi-day' :
416
-					if ( false !== $event->multiple_days ) {
417
-						return $calendar->get_event_html( $event, $partial );
416
+					if (false !== $event->multiple_days) {
417
+						return $calendar->get_event_html($event, $partial);
418 418
 					}
419 419
 					break;
420 420
 
421 421
 				case 'if-single-day' :
422
-					if ( false === $event->multiple_days ) {
423
-						return $calendar->get_event_html( $event, $partial );
422
+					if (false === $event->multiple_days) {
423
+						return $calendar->get_event_html($event, $partial);
424 424
 					}
425 425
 					break;
426 426
 
427 427
 				case 'if-location' :
428 428
 				case 'if-start-location' :
429
-					if ( ! empty( $event->start_location['address'] ) ) {
430
-						return $calendar->get_event_html( $event, $partial );
429
+					if ( ! empty($event->start_location['address'])) {
430
+						return $calendar->get_event_html($event, $partial);
431 431
 					}
432 432
 					return false;
433 433
 
434 434
 				case 'if-not-location' :
435 435
 				case 'if-not-start-location' :
436
-					if ( empty( $event->start_location['address'] ) ) {
437
-						return $calendar->get_event_html( $event, $partial );
436
+					if (empty($event->start_location['address'])) {
437
+						return $calendar->get_event_html($event, $partial);
438 438
 					}
439 439
 					return '';
440 440
 
441 441
 				case 'if-not-end-location' :
442
-					if ( empty( $event->end_location['address'] ) ) {
443
-						return $calendar->get_event_html( $event, $partial );
442
+					if (empty($event->end_location['address'])) {
443
+						return $calendar->get_event_html($event, $partial);
444 444
 					}
445 445
 					return '';
446 446
 
447 447
 				case 'if-end-location' :
448
-					if ( ! empty( $event->end_location['address'] ) ) {
449
-						return $calendar->get_event_html( $event, $partial );
448
+					if ( ! empty($event->end_location['address'])) {
449
+						return $calendar->get_event_html($event, $partial);
450 450
 					}
451 451
 					return '';
452 452
 
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 				 * ======= */
456 456
 
457 457
 				default :
458
-					return wp_kses_post( $before . $partial . $after );
458
+					return wp_kses_post($before.$partial.$after);
459 459
 			}
460 460
 		}
461 461
 
@@ -473,14 +473,14 @@  discard block
 block discarded – undo
473 473
 	 *
474 474
 	 * @return string
475 475
 	 */
476
-	private function limit_words( $text, $limit ) {
476
+	private function limit_words($text, $limit) {
477 477
 
478
-		$limit = max( absint( $limit ), 0 );
478
+		$limit = max(absint($limit), 0);
479 479
 
480
-		if ( $limit > 0 && ( str_word_count( $text, 0 ) > $limit ) ) {
481
-			$words  = str_word_count( $text, 2 );
482
-			$pos    = array_keys( $words );
483
-			$text   = trim( substr( $text, 0, $pos[ $limit ] ) ) . '&hellip;';
480
+		if ($limit > 0 && (str_word_count($text, 0) > $limit)) {
481
+			$words  = str_word_count($text, 2);
482
+			$pos    = array_keys($words);
483
+			$text   = trim(substr($text, 0, $pos[$limit])).'&hellip;';
484 484
 		}
485 485
 
486 486
 		return $text;
@@ -497,26 +497,26 @@  discard block
 block discarded – undo
497 497
 	 *
498 498
 	 * @return string
499 499
 	 */
500
-	private function get_title( $title, $attr ) {
500
+	private function get_title($title, $attr) {
501 501
 
502
-		if ( empty( $title ) ) {
502
+		if (empty($title)) {
503 503
 			return '';
504 504
 		}
505 505
 
506
-		$attr = array_merge( array(
507
-			'html'  => '',  // Parse HTML
508
-			'limit' => 0,   // Trim length to amount of words
509
-		), (array) shortcode_parse_atts( $attr ) );
506
+		$attr = array_merge(array(
507
+			'html'  => '', // Parse HTML
508
+			'limit' => 0, // Trim length to amount of words
509
+		), (array) shortcode_parse_atts($attr));
510 510
 
511
-		if ( ! empty( $attr['html'] ) ) {
512
-			$title = wp_kses_post( $title );
511
+		if ( ! empty($attr['html'])) {
512
+			$title = wp_kses_post($title);
513 513
 			$tag = 'div';
514 514
 		} else {
515
-			$title = $this->limit_words( $title, $attr['limit'] );
515
+			$title = $this->limit_words($title, $attr['limit']);
516 516
 			$tag = 'span';
517 517
 		}
518 518
 
519
-		return '<' . $tag . ' class="simcal-event-title" itemprop="name">' . $title . '</' . $tag . '>';
519
+		return '<'.$tag.' class="simcal-event-title" itemprop="name">'.$title.'</'.$tag.'>';
520 520
 	}
521 521
 
522 522
 	/**
@@ -530,40 +530,40 @@  discard block
 block discarded – undo
530 530
 	 *
531 531
 	 * @return string
532 532
 	 */
533
-	private function get_description( $description, $attr ) {
533
+	private function get_description($description, $attr) {
534 534
 
535
-		if ( empty( $description ) ) {
535
+		if (empty($description)) {
536 536
 			return '';
537 537
 		}
538 538
 
539
-		$attr = array_merge( array(
540
-			'limit'     => 0,       // Trim length to number of words
541
-			'html'      => 'no',    // Parse HTML content
542
-			'markdown'  => 'no',    // Parse Markdown content
543
-			'autolink'  => 'no',    // Automatically convert plaintext URIs to anchors
544
-		), (array) shortcode_parse_atts( $attr ) );
539
+		$attr = array_merge(array(
540
+			'limit'     => 0, // Trim length to number of words
541
+			'html'      => 'no', // Parse HTML content
542
+			'markdown'  => 'no', // Parse Markdown content
543
+			'autolink'  => 'no', // Automatically convert plaintext URIs to anchors
544
+		), (array) shortcode_parse_atts($attr));
545 545
 
546
-		$allow_html = 'no' != $attr['html']     ? true : false;
546
+		$allow_html = 'no' != $attr['html'] ? true : false;
547 547
 		$allow_md   = 'no' != $attr['markdown'] ? true : false;
548 548
 
549 549
 		$html = '<div class="simcal-event-description" itemprop="description">';
550 550
 
551 551
 		// Markdown and HTML don't play well together, use one or the other in the same tag.
552
-		if ( $allow_html || $allow_md ) {
553
-			if ( $allow_html ) {
554
-				$html .= wp_kses_post( $description );
555
-			} elseif ( $allow_md ) {
552
+		if ($allow_html || $allow_md) {
553
+			if ($allow_html) {
554
+				$html .= wp_kses_post($description);
555
+			} elseif ($allow_md) {
556 556
 				$markdown = new \Parsedown();
557
-				$html .= $markdown->text( wp_strip_all_tags( $description ) );
557
+				$html .= $markdown->text(wp_strip_all_tags($description));
558 558
 			}
559 559
 		}
560 560
 
561
-		$html = $this->limit_words( $description, $attr['limit'] );
561
+		$html = $this->limit_words($description, $attr['limit']);
562 562
 
563 563
 		$html .= '</div>';
564 564
 
565
-		if ( 'no' != $attr['autolink'] ) {
566
-			$html = ' ' . make_clickable( $html );
565
+		if ('no' != $attr['autolink']) {
566
+			$html = ' '.make_clickable($html);
567 567
 		}
568 568
 
569 569
 		return $html;
@@ -579,74 +579,74 @@  discard block
 block discarded – undo
579 579
 	 *
580 580
 	 * @return string
581 581
 	 */
582
-	private function get_when( Event $event ) {
582
+	private function get_when(Event $event) {
583 583
 
584
-		$start = $event->start_dt->setTimezone( $event->timezone );
585
-		$end = ! is_null( $event->end_dt ) ? $event->end_dt->setTimezone( $event->timezone ) : null;
584
+		$start = $event->start_dt->setTimezone($event->timezone);
585
+		$end = ! is_null($event->end_dt) ? $event->end_dt->setTimezone($event->timezone) : null;
586 586
 
587 587
 		$time_start = '';
588 588
 		$time_end = '';
589 589
 
590
-		if ( ! $event->whole_day ) {
590
+		if ( ! $event->whole_day) {
591 591
 
592
-			$time_start = $this->calendar->datetime_separator .
593
-			              ' <span class="simcal-event-start simcal-event-start-time" ' .
594
-			              'data-event-start="' . $start->getTimestamp() . '" ' .
595
-			              'data-event-format="' . $this->calendar->time_format . '" ' .
596
-			              'itemprop="startDate" content="' . $start->toIso8601String() . '">' .
597
-			              date_i18n( $this->calendar->time_format, $start->getTimestamp() ) .
592
+			$time_start = $this->calendar->datetime_separator.
593
+			              ' <span class="simcal-event-start simcal-event-start-time" '.
594
+			              'data-event-start="'.$start->getTimestamp().'" '.
595
+			              'data-event-format="'.$this->calendar->time_format.'" '.
596
+			              'itemprop="startDate" content="'.$start->toIso8601String().'">'.
597
+			              date_i18n($this->calendar->time_format, $start->getTimestamp()).
598 598
 			              '</span> ';
599 599
 
600
-			if ( $end instanceof Carbon ) {
600
+			if ($end instanceof Carbon) {
601 601
 
602
-				$time_end = ' <span class="simcal-event-end simcal-event-end-time" ' .
603
-				            'data-event-end="' . $end->getTimestamp() . '" ' .
604
-				            'data-event-format="' . $this->calendar->time_format . '" ' .
605
-				            'itemprop="endDate" content="' . $end->toIso8601String() . '">' .
606
-				            date_i18n( $this->calendar->time_format, $end->getTimestamp() ) .
602
+				$time_end = ' <span class="simcal-event-end simcal-event-end-time" '.
603
+				            'data-event-end="'.$end->getTimestamp().'" '.
604
+				            'data-event-format="'.$this->calendar->time_format.'" '.
605
+				            'itemprop="endDate" content="'.$end->toIso8601String().'">'.
606
+				            date_i18n($this->calendar->time_format, $end->getTimestamp()).
607 607
 				            '</span> ';
608 608
 
609 609
 			}
610 610
 
611 611
 		}
612 612
 
613
-		if ( $event->multiple_days ) {
613
+		if ($event->multiple_days) {
614 614
 
615
-			$output = ' <span class="simcal-event-start simcal-event-start-date" ' .
616
-			          'data-event-start="' . $start->getTimestamp() . '" ' .
617
-			          'data-event-format="' . $this->calendar->date_format . '" ' .
618
-			          'itemprop="startDate" content="' . $start->toIso8601String() . '">' .
619
-			          date_i18n( $this->calendar->date_format, $start->getTimestamp() ) .
620
-			          '</span> ' .
615
+			$output = ' <span class="simcal-event-start simcal-event-start-date" '.
616
+			          'data-event-start="'.$start->getTimestamp().'" '.
617
+			          'data-event-format="'.$this->calendar->date_format.'" '.
618
+			          'itemprop="startDate" content="'.$start->toIso8601String().'">'.
619
+			          date_i18n($this->calendar->date_format, $start->getTimestamp()).
620
+			          '</span> '.
621 621
 			          $time_start;
622 622
 
623
-			if ( $end instanceof Carbon ) {
623
+			if ($end instanceof Carbon) {
624 624
 
625
-				$output .= '-' .
626
-				           ' <span class="simcal-event-start simcal-event-end-date" ' .
627
-				           'data-event-start="' . $end->getTimestamp() . '" ' .
628
-				           'data-event-format="' . $this->calendar->date_format . '" ' .
629
-				           'itemprop="endDate" content="' . $end->toIso8601String() . '">' .
630
-				           date_i18n( $this->calendar->date_format, $end->getTimestamp() ) .
631
-				           '</span> ' .
625
+				$output .= '-'.
626
+				           ' <span class="simcal-event-start simcal-event-end-date" '.
627
+				           'data-event-start="'.$end->getTimestamp().'" '.
628
+				           'data-event-format="'.$this->calendar->date_format.'" '.
629
+				           'itemprop="endDate" content="'.$end->toIso8601String().'">'.
630
+				           date_i18n($this->calendar->date_format, $end->getTimestamp()).
631
+				           '</span> '.
632 632
 				           $time_end;
633 633
 			}
634 634
 
635 635
 		} else {
636 636
 
637
-			$time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : '';
637
+			$time_end = ! empty($time_start) && ! empty($time_end) ? ' - '.$time_end : '';
638 638
 
639
-			$output = ' <span class="simcal-event-start simcal-event-start-date" ' .
640
-			          'data-event-start="' . $start->getTimestamp() . '" ' .
641
-			          'data-event-format="' . $this->calendar->date_format . '">' .
642
-			          date_i18n( $this->calendar->date_format, $start->getTimestamp() ) .
643
-			          '</span> ' .
644
-			          $time_start .
639
+			$output = ' <span class="simcal-event-start simcal-event-start-date" '.
640
+			          'data-event-start="'.$start->getTimestamp().'" '.
641
+			          'data-event-format="'.$this->calendar->date_format.'">'.
642
+			          date_i18n($this->calendar->date_format, $start->getTimestamp()).
643
+			          '</span> '.
644
+			          $time_start.
645 645
 			          $time_end;
646 646
 
647 647
 		}
648 648
 
649
-		return trim( $output );
649
+		return trim($output);
650 650
 	}
651 651
 
652 652
 	/**
@@ -661,44 +661,44 @@  discard block
 block discarded – undo
661 661
 	 *
662 662
 	 * @return string
663 663
 	 */
664
-	private function get_dt( $tag, Event $event, $attr ) {
664
+	private function get_dt($tag, Event $event, $attr) {
665 665
 
666
-		$bound = 0 === strpos( $tag, 'end' ) ? 'end' : 'start';
667
-		if ( ( 'end' == $bound ) && ( false === $event->end ) ) {
666
+		$bound = 0 === strpos($tag, 'end') ? 'end' : 'start';
667
+		if (('end' == $bound) && (false === $event->end)) {
668 668
 			return '';
669 669
 		}
670 670
 
671
-		$dt = $bound . '_dt';
672
-		if ( ! $event->$dt instanceof Carbon ) {
671
+		$dt = $bound.'_dt';
672
+		if ( ! $event->$dt instanceof Carbon) {
673 673
 			return '';
674 674
 		}
675
-		$event_dt = $event->$dt->setTimezone( $event->timezone );
675
+		$event_dt = $event->$dt->setTimezone($event->timezone);
676 676
 
677
-		$attr = array_merge( array(
677
+		$attr = array_merge(array(
678 678
 			'format'    => '',
679
-		), (array) shortcode_parse_atts( $attr ) );
679
+		), (array) shortcode_parse_atts($attr));
680 680
 
681
-		$format = ltrim( strstr( $tag, '-' ), '-' );
681
+		$format = ltrim(strstr($tag, '-'), '-');
682 682
 		$dt_format = '';
683
-		if ( ! empty( $attr['format'] ) ) {
684
-			$dt_format = esc_attr( wp_strip_all_tags( $attr['format'] ) );
685
-		} elseif ( 'date' == $format ) {
683
+		if ( ! empty($attr['format'])) {
684
+			$dt_format = esc_attr(wp_strip_all_tags($attr['format']));
685
+		} elseif ('date' == $format) {
686 686
 			$dt_format = $this->calendar->date_format;
687
-		} elseif ( 'time' == $format ) {
687
+		} elseif ('time' == $format) {
688 688
 			$dt_format = $this->calendar->time_format;
689 689
 		}
690 690
 
691
-		if ( 'human' == $format ) {
692
-			$value = human_time_diff( $event_dt->getTimestamp(), Carbon::now( $event->timezone )->getTimestamp() );
691
+		if ('human' == $format) {
692
+			$value = human_time_diff($event_dt->getTimestamp(), Carbon::now($event->timezone)->getTimestamp());
693 693
 		} else {
694
-			$value = date_i18n( $dt_format, $event_dt->getTimestamp() );
694
+			$value = date_i18n($dt_format, $event_dt->getTimestamp());
695 695
 		}
696 696
 
697
-		return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '"' .
698
-		       'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '"' .
699
-		       'data-event-format="' . $dt_format . '"' .
700
-		       'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' .
701
-		       $value .
697
+		return '<span class="simcal-event-'.$bound.' '.'simcal-event-'.$bound.'-'.$format.'"'.
698
+		       'data-event-'.$bound.'="'.$event_dt->getTimestamp().'"'.
699
+		       'data-event-format="'.$dt_format.'"'.
700
+		       'itemprop="'.$bound.'Date" content="'.$event_dt->toIso8601String().'">'.
701
+		       $value.
702 702
 		       '</span>';
703 703
 	}
704 704
 
@@ -715,23 +715,23 @@  discard block
 block discarded – undo
715 715
 	 *
716 716
 	 * @return string
717 717
 	 */
718
-	private function make_link( $tag, $url, $content, $attr ) {
718
+	private function make_link($tag, $url, $content, $attr) {
719 719
 
720
-		if ( empty( $url ) ) {
720
+		if (empty($url)) {
721 721
 			return '';
722 722
 		}
723 723
 
724
-		$text = empty( $content ) ? $url : $content;
724
+		$text = empty($content) ? $url : $content;
725 725
 
726
-		$attr = array_merge( array(
727
-			'autolink'  => false,   // Convert url to link anchor
728
-			'newwindow' => false,   // If autolink attribute is true, open link in new window
729
-		), (array) shortcode_parse_atts( $attr ) );
726
+		$attr = array_merge(array(
727
+			'autolink'  => false, // Convert url to link anchor
728
+			'newwindow' => false, // If autolink attribute is true, open link in new window
729
+		), (array) shortcode_parse_atts($attr));
730 730
 
731 731
 		$anchor = $tag != 'url' ? 'yes' : $attr['autolink'];
732 732
 		$target = $attr['newwindow'] !== false ? 'target="_blank"' : '';
733 733
 
734
-		return $anchor !== false ? ' <a href="' . esc_url( $url ) . '" ' . $target . '>' . $text . '</a>' : ' ' . $text;
734
+		return $anchor !== false ? ' <a href="'.esc_url($url).'" '.$target.'>'.$text.'</a>' : ' '.$text;
735 735
 	}
736 736
 
737 737
 	/**
@@ -744,20 +744,20 @@  discard block
 block discarded – undo
744 744
 	 *
745 745
 	 * @return string
746 746
 	 */
747
-	private function get_attachments( $attachments ) {
747
+	private function get_attachments($attachments) {
748 748
 
749
-		$html = '<ul class="simcal-attachments">' . "\n\t";
749
+		$html = '<ul class="simcal-attachments">'."\n\t";
750 750
 
751
-		foreach ( $attachments as $attachment ) {
751
+		foreach ($attachments as $attachment) {
752 752
 			$html .= '<li class="simcal-attachment">';
753
-			$html .= '<a href="' . $attachment['url'] . '" target="_blank">';
754
-			$html .= ! empty( $attachment['icon'] ) ? '<img src="' . $attachment['icon'] . '" />' : '';
755
-			$html .= '<span>' . $attachment['name'] . '</span>';
753
+			$html .= '<a href="'.$attachment['url'].'" target="_blank">';
754
+			$html .= ! empty($attachment['icon']) ? '<img src="'.$attachment['icon'].'" />' : '';
755
+			$html .= '<span>'.$attachment['name'].'</span>';
756 756
 			$html .= '</a>';
757
-			$html .= '</li>' . "\n";
757
+			$html .= '</li>'."\n";
758 758
 		}
759 759
 
760
-		$html .= '</ul>' . "\n";
760
+		$html .= '</ul>'."\n";
761 761
 
762 762
 		return $html;
763 763
 	}
@@ -773,41 +773,41 @@  discard block
 block discarded – undo
773 773
 	 *
774 774
 	 * @return string
775 775
 	 */
776
-	private function get_attendees( $attendees, $attr ) {
776
+	private function get_attendees($attendees, $attr) {
777 777
 
778
-		$attr = array_merge( array(
779
-			'photo'     => 'show',  // show/hide attendee photo
780
-			'email'     => 'hide',  // show/hide attendee email address
781
-			'rsvp'      => 'hide',  // show/hide rsvp response status
782
-			'response'  => '',      // filter attendees by rsvp response (yes/no/maybe)
783
-		), (array) shortcode_parse_atts( $attr ) );
778
+		$attr = array_merge(array(
779
+			'photo'     => 'show', // show/hide attendee photo
780
+			'email'     => 'hide', // show/hide attendee email address
781
+			'rsvp'      => 'hide', // show/hide rsvp response status
782
+			'response'  => '', // filter attendees by rsvp response (yes/no/maybe)
783
+		), (array) shortcode_parse_atts($attr));
784 784
 
785
-		$html = '<ul class="simcal-attendees" itemprop="attendees">' . "\n\t";
785
+		$html = '<ul class="simcal-attendees" itemprop="attendees">'."\n\t";
786 786
 
787 787
 		$known = 0;
788 788
 		$unknown = 0;
789 789
 
790
-		foreach ( $attendees as $attendee ) {
790
+		foreach ($attendees as $attendee) {
791 791
 
792
-			if ( 'yes' == $attr['response'] && 'yes' != $attendee['response'] ) {
792
+			if ('yes' == $attr['response'] && 'yes' != $attendee['response']) {
793 793
 				continue;
794
-			} elseif ( 'no' == $attr['response'] && 'no' != $attendee['response'] ) {
794
+			} elseif ('no' == $attr['response'] && 'no' != $attendee['response']) {
795 795
 				continue;
796
-			} elseif ( 'maybe' == $attr['response'] && ! in_array( $attendee['response'], array( 'yes', 'maybe' ) ) ) {
796
+			} elseif ('maybe' == $attr['response'] && ! in_array($attendee['response'], array('yes', 'maybe'))) {
797 797
 				continue;
798 798
 			}
799 799
 
800
-			if ( ! empty( $attendee['name'] ) ) {
800
+			if ( ! empty($attendee['name'])) {
801 801
 
802
-				$photo      = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $attendee['photo'] . '" itemprop="image" />' : '';
803
-				$response   = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response( $attendee['response'] ) : '';
804
-				$guest      = $photo . '<span itemprop="name">' . $attendee['name'] . $response . '</span>';
802
+				$photo      = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$attendee['photo'].'" itemprop="image" />' : '';
803
+				$response   = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response($attendee['response']) : '';
804
+				$guest      = $photo.'<span itemprop="name">'.$attendee['name'].$response.'</span>';
805 805
 
806
-				if ( ! empty( $attendee['email'] ) && ( 'show' == $attr['email'] ) ) {
807
-					$guest = sprintf( '<a href="mailto:' . $attendee['email'] . '" itemprop="email">%s</a>', $guest );
806
+				if ( ! empty($attendee['email']) && ('show' == $attr['email'])) {
807
+					$guest = sprintf('<a href="mailto:'.$attendee['email'].'" itemprop="email">%s</a>', $guest);
808 808
 				}
809 809
 
810
-				$html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">' . $guest . '</li>' . "\n";
810
+				$html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">'.$guest.'</li>'."\n";
811 811
 
812 812
 				$known++;
813 813
 
@@ -818,21 +818,21 @@  discard block
 block discarded – undo
818 818
 			}
819 819
 		}
820 820
 
821
-		if ( $unknown > 0 ) {
822
-			if ( $known > 0 ) {
821
+		if ($unknown > 0) {
822
+			if ($known > 0) {
823 823
 				/* translators: One more person attending the event. */
824
-				$others = sprintf( _n( '1 more attendee', '%s more attendees', $unknown, 'google-calendar-events' ), $unknown );
824
+				$others = sprintf(_n('1 more attendee', '%s more attendees', $unknown, 'google-calendar-events'), $unknown);
825 825
 			} else {
826 826
 				/* translators: One or more persons attending the event whose name is unknown. */
827
-				$others = sprintf( _n( '1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events' ), $unknown );
827
+				$others = sprintf(_n('1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events'), $unknown);
828 828
 			}
829
-			$photo = $attr['photo'] !== 'hide' ? get_avatar( '', 128 ) : '';
830
-			$html .= '<li class="simcal-attendee simcal-attendee-anonymous">' . $photo . '<span>' . $others . '</span></li>' . "\n";
831
-		} elseif ( $known === 0 ) {
832
-			$html .= '<li class="simcal-attendee">' . _x( 'No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events' ) . '</li>' . "\n";
829
+			$photo = $attr['photo'] !== 'hide' ? get_avatar('', 128) : '';
830
+			$html .= '<li class="simcal-attendee simcal-attendee-anonymous">'.$photo.'<span>'.$others.'</span></li>'."\n";
831
+		} elseif ($known === 0) {
832
+			$html .= '<li class="simcal-attendee">'._x('No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events').'</li>'."\n";
833 833
 		}
834 834
 
835
-		$html .= '</ul>' . "\n";
835
+		$html .= '</ul>'."\n";
836 836
 
837 837
 		return $html;
838 838
 	}
@@ -846,23 +846,23 @@  discard block
 block discarded – undo
846 846
 	 *
847 847
 	 * @return string
848 848
 	 */
849
-	private function get_rsvp_response( $response ) {
849
+	private function get_rsvp_response($response) {
850 850
 
851
-		if ( 'yes' == $response ) {
851
+		if ('yes' == $response) {
852 852
 			/* translators: Someone replied with 'yes' to a rsvp request. */
853
-			$rsvp = __( 'Attending', 'google-calendar-events' );
854
-		} elseif ( 'no' == $response ) {
853
+			$rsvp = __('Attending', 'google-calendar-events');
854
+		} elseif ('no' == $response) {
855 855
 			/* translators: Someone replied with 'no' to a rsvp request. */
856
-			$rsvp = __( 'Not attending', 'google-calendar-events' );
857
-		} elseif ( 'maybe' == $response ) {
856
+			$rsvp = __('Not attending', 'google-calendar-events');
857
+		} elseif ('maybe' == $response) {
858 858
 			/* translators: Someone replied with 'maybe' to a rsvp request. */
859
-			$rsvp = __( 'Maybe attending', 'google-calendar-events' );
859
+			$rsvp = __('Maybe attending', 'google-calendar-events');
860 860
 		} else {
861 861
 			/* translators: Someone did not send yet a rsvp confirmation to join an event. */
862
-			$rsvp = __( 'Response pending', 'google-calendar-events' );
862
+			$rsvp = __('Response pending', 'google-calendar-events');
863 863
 		}
864 864
 
865
-		return ' <small>(' . $rsvp . ')</small>';
865
+		return ' <small>('.$rsvp.')</small>';
866 866
 	}
867 867
 
868 868
 	/**
@@ -876,21 +876,21 @@  discard block
 block discarded – undo
876 876
 	 *
877 877
 	 * @return string
878 878
 	 */
879
-	private function get_organizer( $organizer, $attr ) {
879
+	private function get_organizer($organizer, $attr) {
880 880
 
881
-		$attr = array_merge( array(
882
-			'photo' => 'show',  // show/hide attendee photo
883
-			'email' => 'hide',  // show/hide attendee email address
884
-		), (array) shortcode_parse_atts( $attr ) );
881
+		$attr = array_merge(array(
882
+			'photo' => 'show', // show/hide attendee photo
883
+			'email' => 'hide', // show/hide attendee email address
884
+		), (array) shortcode_parse_atts($attr));
885 885
 
886
-		$photo           = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $organizer['photo'] . '" itemprop="image"  />' : '';
887
-		$organizer_html  = $photo . '<span itemprop="name">' . $organizer['name'] . '</span>';
886
+		$photo           = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$organizer['photo'].'" itemprop="image"  />' : '';
887
+		$organizer_html  = $photo.'<span itemprop="name">'.$organizer['name'].'</span>';
888 888
 
889
-		if ( ! empty( $organizer['email'] ) && ( 'show' == $attr['email'] ) ) {
890
-			$organizer_html = sprintf( '<a href="mailto:' . $organizer['email'] . '" itemprop="email">%s</a>', $organizer_html );
889
+		if ( ! empty($organizer['email']) && ('show' == $attr['email'])) {
890
+			$organizer_html = sprintf('<a href="mailto:'.$organizer['email'].'" itemprop="email">%s</a>', $organizer_html);
891 891
 		}
892 892
 
893
-		return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">' . $organizer_html . '</div>';
893
+		return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">'.$organizer_html.'</div>';
894 894
 	}
895 895
 
896 896
 	/**
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 		// This is largely borrowed on get_shortcode_regex() from WordPress Core.
916 916
 		// @see /wp-includes/shortcodes.php (with some modification)
917 917
 
918
-		$tagregexp = implode( '|', array_values( $this->tags ) );
918
+		$tagregexp = implode('|', array_values($this->tags));
919 919
 
920 920
 		return '/'
921 921
 		       . '\\['                              // Opening bracket
Please login to merge, or discard this patch.
includes/abstracts/calendar.php 1 patch
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>';
Please login to merge, or discard this patch.
includes/feeds/grouped-calendars.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
includes/admin/ajax.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
includes/admin/metaboxes/settings.php 1 patch
Spacing   +270 added lines, -270 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>&nbsp;&nbsp;
557
-							<code><?php echo date_i18n( $date_format_default, time() ); ?></code>
556
+							<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
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
 block discarded – undo
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>&nbsp;&nbsp;
579
-								<code><?php echo date_i18n( $date_format_php, time() ); ?></code>
578
+								<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
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>&nbsp;&nbsp;
629
-							<code><?php echo date_i18n( $time_format_default, time() ); ?></code>
628
+							<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
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
 block discarded – undo
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>&nbsp;&nbsp;
651
-								<code><?php echo date_i18n( $time_format_php, time() ); ?></code>
650
+								<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.