Completed
Push — master ( d1a272...91e5db )
by
unknown
04:07
created
includes/functions/shared.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
- * Shared functions
4
- *
5
- * Functions shared by both back end and front end components.
6
- *
7
- * @package SimpleCalendar/Functions
8
- */
3
+	 * Shared functions
4
+	 *
5
+	 * Functions shared by both back end and front end components.
6
+	 *
7
+	 * @package SimpleCalendar/Functions
8
+	 */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11 11
 	exit;
Please login to merge, or discard this patch.
Spacing   +84 added lines, -84 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,6 +404,6 @@  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
 }
Please login to merge, or discard this patch.
includes/admin/fields/checkbox.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use SimpleCalendar\Abstracts\Field;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit; // Exit if accessed directly.
13 13
 }
14 14
 
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param array $field
30 30
 	 */
31
-	public function __construct( $field ) {
31
+	public function __construct($field) {
32 32
 		$this->type_class = 'simcal-field-checkboxes';
33
-		parent::__construct( $field );
33
+		parent::__construct($field);
34 34
 	}
35 35
 
36 36
 	/**
@@ -40,33 +40,33 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function html() {
42 42
 
43
-		if ( ! empty( $this->options ) && count( (array) $this->options ) > 1 ) {
43
+		if ( ! empty($this->options) && count((array) $this->options) > 1) {
44 44
 
45
-			if ( ! empty( $this->description ) ) {
46
-				echo '<p class="description">' . wp_kses_post( $this->description ) . ' ' . $this->tooltip . '</p>';
45
+			if ( ! empty($this->description)) {
46
+				echo '<p class="description">'.wp_kses_post($this->description).' '.$this->tooltip.'</p>';
47 47
 			}
48 48
 
49 49
 			?>
50
-			<fieldset class="<?php echo $this->class; ?>" <?php echo ! empty( $this->style ) ? 'style="' . $this->style . '"' : ''; ?>>
50
+			<fieldset class="<?php echo $this->class; ?>" <?php echo ! empty($this->style) ? 'style="'.$this->style.'"' : ''; ?>>
51 51
 				<?php
52 52
 
53
-				if ( ! empty( $this->title ) ) {
54
-					echo '<legend class="screen-reader-text"><span>' . $this->title . '</span></legend>';
53
+				if ( ! empty($this->title)) {
54
+					echo '<legend class="screen-reader-text"><span>'.$this->title.'</span></legend>';
55 55
 				}
56 56
 
57 57
 				?>
58 58
 				<ul>
59
-					<?php foreach ( $this->options as $option => $name ) : ?>
59
+					<?php foreach ($this->options as $option => $name) : ?>
60 60
 						<li>
61
-							<label for="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>">
61
+							<label for="<?php echo $this->id.'-'.trim(strval($option)); ?>">
62 62
 								<input name="<?php echo $this->name; ?>"
63
-								       id="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>"
63
+								       id="<?php echo $this->id.'-'.trim(strval($option)); ?>"
64 64
 								       class="simcal-field simcal-field-checkbox"
65 65
 								       type="checkbox"
66
-								       value="<?php echo trim( strval( $option ) ); ?>"
67
-										<?php checked( $this->value, 'yes', true ); ?>
66
+								       value="<?php echo trim(strval($option)); ?>"
67
+										<?php checked($this->value, 'yes', true); ?>
68 68
 									<?php echo $this->attributes; ?>
69
-									/><?php echo esc_attr( $name ); ?>
69
+									/><?php echo esc_attr($name); ?>
70 70
 							</label>
71 71
 						</li>
72 72
 					<?php endforeach; ?>
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 		} else {
78 78
 
79 79
 			?>
80
-			<span class="simcal-field-bool" <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?>>
81
-				<?php if ( ! empty( $this->title ) ) : ?>
80
+			<span class="simcal-field-bool" <?php echo $this->style ? 'style="'.$this->style.'"' : ''; ?>>
81
+				<?php if ( ! empty($this->title)) : ?>
82 82
 					<span class="screen-reader-text"><?php echo $this->title; ?></span>
83 83
 				<?php endif; ?>
84 84
 				<input name="<?php echo $this->name; ?>"
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 				       id="<?php echo $this->id; ?>"
87 87
 				       class="simcal-field simcal-field-checkbox <?php echo $this->class; ?>"
88 88
 				       value="yes"
89
-					<?php checked( $this->value, 'yes', true ); ?>
90
-					<?php echo $this->attributes; ?>/><?php _e( 'Yes', 'google-calendar-events' ); ?>
89
+					<?php checked($this->value, 'yes', true); ?>
90
+					<?php echo $this->attributes; ?>/><?php _e('Yes', 'google-calendar-events'); ?>
91 91
 			</span>
92 92
 			<?php
93 93
 
94 94
 			echo $this->tooltip;
95 95
 
96
-			if ( ! empty( $this->description ) ) {
97
-				echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>';
96
+			if ( ! empty($this->description)) {
97
+				echo '<p class="description">'.wp_kses_post($this->description).'</p>';
98 98
 			}
99 99
 
100 100
 		}
Please login to merge, or discard this patch.
includes/admin/pages.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 use SimpleCalendar\Abstracts\Field;
10 10
 use SimpleCalendar\Abstracts\Admin_Page;
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -53,20 +53,20 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @param string $page
55 55
 	 */
56
-	public function __construct( $page = 'settings' ) {
56
+	public function __construct($page = 'settings') {
57 57
 
58 58
 		$this->page = $page;
59
-		$settings_pages = ! is_null( \SimpleCalendar\plugin()->objects ) ? simcal_get_admin_pages() : '';
59
+		$settings_pages = ! is_null(\SimpleCalendar\plugin()->objects) ? simcal_get_admin_pages() : '';
60 60
 		$settings_page_tabs = array();
61
-		$tabs = isset( $settings_pages[ $page ] ) ? $settings_pages[ $page ] : false;
61
+		$tabs = isset($settings_pages[$page]) ? $settings_pages[$page] : false;
62 62
 
63
-		if ( $tabs && is_array( $tabs ) ) {
64
-			foreach ( $tabs as $tab ) {
63
+		if ($tabs && is_array($tabs)) {
64
+			foreach ($tabs as $tab) {
65 65
 
66
-				$settings_page = simcal_get_admin_page( $tab );
66
+				$settings_page = simcal_get_admin_page($tab);
67 67
 
68
-				if ( $settings_page instanceof Admin_Page ) {
69
-					$settings_page_tabs[ $settings_page->id ] = $settings_page;
68
+				if ($settings_page instanceof Admin_Page) {
69
+					$settings_page_tabs[$settings_page->id] = $settings_page;
70 70
 				}
71 71
 			}
72 72
 
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 		}
75 75
 
76 76
 		// The first tab is the default tab when opening a page.
77
-		$this->tab = isset( $tabs[0] ) ? $tabs[0] : '';
77
+		$this->tab = isset($tabs[0]) ? $tabs[0] : '';
78 78
 
79
-		do_action( 'simcal_admin_pages', $page );
79
+		do_action('simcal_admin_pages', $page);
80 80
 	}
81 81
 
82 82
 	/**
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 
92 92
 		$settings = array();
93 93
 
94
-		if ( ! empty( $this->settings ) && is_array( $this->settings ) ) {
95
-			foreach ( $this->settings as $id => $object ) {
94
+		if ( ! empty($this->settings) && is_array($this->settings)) {
95
+			foreach ($this->settings as $id => $object) {
96 96
 
97
-				if ( $object instanceof Admin_Page ) {
97
+				if ($object instanceof Admin_Page) {
98 98
 
99 99
 					$settings_page = $object->get_settings();
100 100
 
101
-					if ( isset( $settings_page[ $id ] ) ) {
102
-						$settings[ $id ] = $settings_page[ $id ];
101
+					if (isset($settings_page[$id])) {
102
+						$settings[$id] = $settings_page[$id];
103 103
 					}
104 104
 				}
105 105
 
@@ -118,48 +118,48 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @param array $settings
120 120
 	 */
121
-	public function register_settings( $settings = array() ) {
121
+	public function register_settings($settings = array()) {
122 122
 
123 123
 		$settings = $settings ? $settings : $this->get_settings();
124 124
 
125
-		if ( ! empty( $settings ) && is_array( $settings ) ) {
125
+		if ( ! empty($settings) && is_array($settings)) {
126 126
 
127
-			foreach ( $settings as $tab_id => $settings_page ) {
127
+			foreach ($settings as $tab_id => $settings_page) {
128 128
 
129
-				if ( isset( $settings_page['sections'] ) ) {
129
+				if (isset($settings_page['sections'])) {
130 130
 
131 131
 					$sections = $settings_page['sections'];
132 132
 
133
-					if ( ! empty( $sections ) && is_array( $sections ) ) {
133
+					if ( ! empty($sections) && is_array($sections)) {
134 134
 
135
-						foreach ( $sections as $section_id => $section ) {
135
+						foreach ($sections as $section_id => $section) {
136 136
 
137 137
 							add_settings_section(
138 138
 								$section_id,
139
-								isset( $section['title'] ) ? $section['title'] : '',
140
-								isset( $section['callback'] ) ? $section['callback'] : '',
141
-								'simple-calendar_' . $this->page . '_' . $tab_id
139
+								isset($section['title']) ? $section['title'] : '',
140
+								isset($section['callback']) ? $section['callback'] : '',
141
+								'simple-calendar_'.$this->page.'_'.$tab_id
142 142
 							);
143 143
 
144
-							if ( isset( $section['fields'] ) ) {
144
+							if (isset($section['fields'])) {
145 145
 
146 146
 								$fields = $section['fields'];
147 147
 
148
-								if ( ! empty( $fields ) && is_array( $fields ) ) {
148
+								if ( ! empty($fields) && is_array($fields)) {
149 149
 
150
-									foreach ( $fields as $field ) {
150
+									foreach ($fields as $field) {
151 151
 
152
-										if ( isset( $field['id'] ) && isset( $field['type'] ) ) {
152
+										if (isset($field['id']) && isset($field['type'])) {
153 153
 
154
-											$field_object = simcal_get_field( $field, $field['type'] );
154
+											$field_object = simcal_get_field($field, $field['type']);
155 155
 
156
-											if ( $field_object instanceof Field ) {
156
+											if ($field_object instanceof Field) {
157 157
 
158 158
 												add_settings_field(
159 159
 													$field['id'],
160
-													isset( $field['title'] ) ? $field['title'] : '',
161
-													array( $field_object, 'html' ),
162
-													'simple-calendar_' . $this->page . '_' . $tab_id,
160
+													isset($field['title']) ? $field['title'] : '',
161
+													array($field_object, 'html'),
162
+													'simple-calendar_'.$this->page.'_'.$tab_id,
163 163
 													$section_id
164 164
 												);
165 165
 
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 
174 174
 							} // are there fields?
175 175
 
176
-							$page = simcal_get_admin_page( $tab_id );
176
+							$page = simcal_get_admin_page($tab_id);
177 177
 
178 178
 							register_setting(
179
-								'simple-calendar_' . $this->page . '_' . $tab_id,
180
-								'simple-calendar_' . $this->page . '_' . $tab_id,
181
-								$page instanceof Admin_Page ? array( $page, 'validate' ) : ''
179
+								'simple-calendar_'.$this->page.'_'.$tab_id,
180
+								'simple-calendar_'.$this->page.'_'.$tab_id,
181
+								$page instanceof Admin_Page ? array($page, 'validate') : ''
182 182
 							);
183 183
 
184 184
 						} // loop sections
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		global $current_tab;
204 204
 
205 205
 		// Get current tab/section
206
-		$current_tab = empty( $_GET['tab'] ) ? $this->tab : sanitize_title( $_GET['tab'] );
206
+		$current_tab = empty($_GET['tab']) ? $this->tab : sanitize_title($_GET['tab']);
207 207
 		$this->tab = $current_tab;
208 208
 
209 209
 		?>
@@ -215,45 +215,45 @@  discard block
 block discarded – undo
215 215
 
216 216
 				// Include settings pages
217 217
 				$settings_pages = self::get_settings();
218
-				if ( ! empty( $settings_pages ) && is_array( $settings_pages ) ) {
218
+				if ( ! empty($settings_pages) && is_array($settings_pages)) {
219 219
 
220 220
 					echo '<h2 class="nav-tab-wrapper simcal-nav-tab-wrapper">';
221 221
 
222 222
 					// Get tabs for the settings page
223
-					if ( ! empty( $settings_pages ) && is_array( $settings_pages ) ) {
223
+					if ( ! empty($settings_pages) && is_array($settings_pages)) {
224 224
 
225
-						foreach ( $settings_pages as $id => $settings ) {
225
+						foreach ($settings_pages as $id => $settings) {
226 226
 
227
-							$tab_id    = isset( $id ) ? $id : '';
228
-							$tab_label = isset( $settings['label'] ) ? $settings['label'] : '';
229
-							$tab_link  = admin_url( 'edit.php?post_type=calendar&page=simple-calendar_' . $this->page . '&tab=' . $tab_id );
227
+							$tab_id    = isset($id) ? $id : '';
228
+							$tab_label = isset($settings['label']) ? $settings['label'] : '';
229
+							$tab_link  = admin_url('edit.php?post_type=calendar&page=simple-calendar_'.$this->page.'&tab='.$tab_id);
230 230
 
231
-							echo '<a href="' . $tab_link . '" class="nav-tab ' . ( $current_tab == $tab_id ? 'nav-tab-active' : '' ) . '">' . $tab_label . '</a>';
231
+							echo '<a href="'.$tab_link.'" class="nav-tab '.($current_tab == $tab_id ? 'nav-tab-active' : '').'">'.$tab_label.'</a>';
232 232
 						}
233 233
 
234 234
 					}
235 235
 
236
-					do_action( 'simcal_admin_page_' . $this->page . '_tabs' );
236
+					do_action('simcal_admin_page_'.$this->page.'_tabs');
237 237
 
238 238
 					echo '</h2>';
239 239
 
240 240
 					settings_errors();
241 241
 
242
-					foreach ( $settings_pages as $tab_id => $contents ) {
242
+					foreach ($settings_pages as $tab_id => $contents) {
243 243
 
244
-						if ( $tab_id === $current_tab ) {
244
+						if ($tab_id === $current_tab) {
245 245
 
246
-							echo isset( $contents['description'] ) ? '<p>' . $contents['description'] . '</p>' : '';
246
+							echo isset($contents['description']) ? '<p>'.$contents['description'].'</p>' : '';
247 247
 
248
-							do_action( 'simcal_admin_page_' .  $this->page . '_' . $current_tab . '_start' );
248
+							do_action('simcal_admin_page_'.$this->page.'_'.$current_tab.'_start');
249 249
 
250
-							settings_fields( 'simple-calendar_' . $this->page . '_' . $tab_id );
251
-							do_settings_sections( 'simple-calendar_' . $this->page . '_' . $tab_id );
250
+							settings_fields('simple-calendar_'.$this->page.'_'.$tab_id);
251
+							do_settings_sections('simple-calendar_'.$this->page.'_'.$tab_id);
252 252
 
253
-							do_action( 'simcal_admin_page_' .  $this->page . '_' . $current_tab . '_end' );
253
+							do_action('simcal_admin_page_'.$this->page.'_'.$current_tab.'_end');
254 254
 
255
-							$submit = apply_filters( 'simcal_admin_page_' . $this->page . '_' . $current_tab . '_submit', true );
256
-							if ( true === $submit ) {
255
+							$submit = apply_filters('simcal_admin_page_'.$this->page.'_'.$current_tab.'_submit', true);
256
+							if (true === $submit) {
257 257
 								submit_button();
258 258
 							}
259 259
 						}
@@ -263,17 +263,17 @@  discard block
 block discarded – undo
263 263
 				// Add option to show we ran through default settings
264 264
 				// We also run a check here for the main settings page option. This is to determine if this is a fresh install or if they already had
265 265
 				// the plugin installed. The main feed settings page would give the best idea of that since user's have to enter an API key on this page to get it working.
266
-				if ( false === get_option( 'simple-calendar_defaults' ) && false === get_option( 'simple-calendar_settings_feeds' ) ) {
266
+				if (false === get_option('simple-calendar_defaults') && false === get_option('simple-calendar_settings_feeds')) {
267 267
 
268
-					$default_advanced = array (
269
-										'assets' => array (
268
+					$default_advanced = array(
269
+										'assets' => array(
270 270
 												'always_enqueue' => 'yes',
271 271
 										),
272 272
 									);
273 273
 
274
-					update_option( 'simple-calendar_settings_advanced', $default_advanced );
274
+					update_option('simple-calendar_settings_advanced', $default_advanced);
275 275
 
276
-					add_option( 'simple-calendar_defaults', 1 );
276
+					add_option('simple-calendar_defaults', 1);
277 277
 				}
278 278
 
279 279
 
Please login to merge, or discard this patch.
includes/admin/pages/advanced.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use SimpleCalendar\Abstracts\Admin_Page;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function __construct() {
30 30
 		$this->id           = 'advanced';
31 31
 		$this->option_group = 'settings';
32
-		$this->label        = __( 'Advanced', 'google-calendar-events' );
32
+		$this->label        = __('Advanced', 'google-calendar-events');
33 33
 		//$this->description  = __( 'Advanced settings.', 'google-calendar-events' );
34 34
 		$this->sections     = $this->add_sections();
35 35
 		$this->fields       = $this->add_fields();
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 	 * @return array
44 44
 	 */
45 45
 	public function add_sections() {
46
-		return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id .'_sections', array(
46
+		return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_sections', array(
47 47
 			'assets' => array(
48
-				'title'       => __( 'Scripts and Styles', 'google-calendar-events' ),
49
-				'description' => __( 'Manage front end assets that handle the calendars appearance and user interface.', 'google-calendar-events' )
48
+				'title'       => __('Scripts and Styles', 'google-calendar-events'),
49
+				'description' => __('Manage front end assets that handle the calendars appearance and user interface.', 'google-calendar-events')
50 50
 			),
51 51
 			'installation' => array(
52
-				'title'       => __( 'Installation', 'google-calendar-events' ),
53
-				'description' => __( 'Manage your data (plugin settings and saved calendars).', 'google-calendar-events' )
52
+				'title'       => __('Installation', 'google-calendar-events'),
53
+				'description' => __('Manage your data (plugin settings and saved calendars).', 'google-calendar-events')
54 54
 			)
55
-		) );
55
+		));
56 56
 	}
57 57
 
58 58
 	/**
@@ -65,57 +65,57 @@  discard block
 block discarded – undo
65 65
 	public function add_fields() {
66 66
 
67 67
 		$fields       = array();
68
-		$this->values = get_option( 'simple-calendar_' . $this->option_group . '_' . $this->id );
68
+		$this->values = get_option('simple-calendar_'.$this->option_group.'_'.$this->id);
69 69
 
70
-		foreach ( $this->sections  as $section => $a ) :
70
+		foreach ($this->sections  as $section => $a) :
71 71
 
72
-			if ( 'assets' == $section ) {
72
+			if ('assets' == $section) {
73 73
 
74
-				$fields[ $section ] = array(
74
+				$fields[$section] = array(
75 75
 					'always_enqueue' => array(
76
-						'title'   => __( 'Always Enqueue', 'google-calendar-events' ),
77
-						'tooltip' => __( 'If ticked, this option will load all scripts on every page load.', 'google-calendar-events' ),
76
+						'title'   => __('Always Enqueue', 'google-calendar-events'),
77
+						'tooltip' => __('If ticked, this option will load all scripts on every page load.', 'google-calendar-events'),
78 78
 						'type'    => 'checkbox',
79
-						'name'    => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][always_enqueue]',
80
-						'id'      => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-always-enqueue',
81
-						'value'   => $this->get_option_value( $section, 'always_enqueue' ),
79
+						'name'    => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][always_enqueue]',
80
+						'id'      => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-always-enqueue',
81
+						'value'   => $this->get_option_value($section, 'always_enqueue'),
82 82
 					),
83 83
 					'disable_css' => array(
84
-						'title'   => __( 'Disable Styles', 'google-calendar-events' ),
85
-						'tooltip' => __( 'If ticked, this option will prevent front end stylesheet to load.', 'google-calendar-events' ),
84
+						'title'   => __('Disable Styles', 'google-calendar-events'),
85
+						'tooltip' => __('If ticked, this option will prevent front end stylesheet to load.', 'google-calendar-events'),
86 86
 						'type'    => 'checkbox',
87
-						'name'    => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][disable_css]',
88
-						'id'      => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-disable-css',
89
-						'value'   => $this->get_option_value( $section, 'disable_css' )
87
+						'name'    => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][disable_css]',
88
+						'id'      => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-disable-css',
89
+						'value'   => $this->get_option_value($section, 'disable_css')
90 90
 					),
91 91
 					'disable_js' => array(
92
-						'title'   => __( 'Disable Scripts', 'google-calendar-events' ),
93
-						'tooltip' => __( 'If ticked, this option will prevent front end JavaScript to load.', 'google-calendar-events' ),
92
+						'title'   => __('Disable Scripts', 'google-calendar-events'),
93
+						'tooltip' => __('If ticked, this option will prevent front end JavaScript to load.', 'google-calendar-events'),
94 94
 						'type'    => 'checkbox',
95
-						'name'    => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][disable_js]',
96
-						'id'      => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-disable-js',
97
-						'value'   => $this->get_option_value( $section, 'disable_js' )
95
+						'name'    => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][disable_js]',
96
+						'id'      => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-disable-js',
97
+						'value'   => $this->get_option_value($section, 'disable_js')
98 98
 					)
99 99
 				);
100 100
 
101
-			} elseif ( 'installation' == $section ) {
101
+			} elseif ('installation' == $section) {
102 102
 
103
-				$fields[ $section ] = array(
103
+				$fields[$section] = array(
104 104
 					'delete_settings' => array(
105
-						'title'   => __( 'Delete settings', 'google-calendar-events' ),
106
-						'tooltip' => __( 'Tick this option if you want to wipe this plugin settings from database when uninstalling.', 'google-calendar-events' ),
105
+						'title'   => __('Delete settings', 'google-calendar-events'),
106
+						'tooltip' => __('Tick this option if you want to wipe this plugin settings from database when uninstalling.', 'google-calendar-events'),
107 107
 						'type'    => 'checkbox',
108
-						'name'    => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][delete_settings]',
109
-						'id'      => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-delete-settings',
110
-						'value'   => $this->get_option_value( $section, 'delete_settings' ),
108
+						'name'    => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][delete_settings]',
109
+						'id'      => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-delete-settings',
110
+						'value'   => $this->get_option_value($section, 'delete_settings'),
111 111
 					),
112 112
 					'erase_data' => array(
113
-						'title'   => __( 'Erase calendar data', 'google-calendar-events' ),
114
-						'tooltip' => __( 'By default your data will be retained in database even after uninstall. Tick this option if you want to delete all your calendar data when uninstalling.', 'google-calendar-events' ),
113
+						'title'   => __('Erase calendar data', 'google-calendar-events'),
114
+						'tooltip' => __('By default your data will be retained in database even after uninstall. Tick this option if you want to delete all your calendar data when uninstalling.', 'google-calendar-events'),
115 115
 						'type'    => 'checkbox',
116
-						'name'    => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][erase_data]',
117
-						'id'      => 'simple-calendar_' . $this->option_group . '_' . $this->id . '-delete-data',
118
-						'value'   => $this->get_option_value( $section, 'erase_data' ),
116
+						'name'    => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][erase_data]',
117
+						'id'      => 'simple-calendar_'.$this->option_group.'_'.$this->id.'-delete-data',
118
+						'value'   => $this->get_option_value($section, 'erase_data'),
119 119
 					)
120 120
 				);
121 121
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
 		endforeach;
125 125
 
126
-		return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id . '_fields', $fields );
126
+		return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_fields', $fields);
127 127
 	}
128 128
 
129 129
 }
Please login to merge, or discard this patch.
includes/calendars/default-calendar.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use SimpleCalendar\Calendars\Views;
14 14
 use SimpleCalendar\Events\Event;
15 15
 
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -105,35 +105,35 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @param int|object|\WP_Post|Calendar $calendar
107 107
 	 */
108
-	public function __construct( $calendar ) {
108
+	public function __construct($calendar) {
109 109
 
110 110
 		$this->type = 'default-calendar';
111
-		$this->name = __( 'Default', 'google-calendar-events' );
112
-		$this->views = apply_filters( 'simcal_default_calendar_views', array(
113
-			'grid' => __( 'Grid', 'google-calendar-events' ),
114
-			'list' => __( 'List', 'google-calendar-events' ),
115
-		) );
111
+		$this->name = __('Default', 'google-calendar-events');
112
+		$this->views = apply_filters('simcal_default_calendar_views', array(
113
+			'grid' => __('Grid', 'google-calendar-events'),
114
+			'list' => __('List', 'google-calendar-events'),
115
+		));
116 116
 
117
-		parent::__construct( $calendar );
117
+		parent::__construct($calendar);
118 118
 
119
-		if ( ! is_null( $this->post ) ) {
119
+		if ( ! is_null($this->post)) {
120 120
 
121
-			$this->set_properties( $this->view->get_type() );
121
+			$this->set_properties($this->view->get_type());
122 122
 
123 123
 			$id = $this->id;
124 124
 			$theme = $this->theme;
125 125
 
126
-			add_filter( 'simcal_calendar_class', function( $class, $post_id ) use ( $theme, $id ) {
127
-				if ( in_array( 'default-calendar', $class ) && $post_id === $id ) {
128
-					array_push( $class, 'default-calendar-' . $theme );
126
+			add_filter('simcal_calendar_class', function($class, $post_id) use ($theme, $id) {
127
+				if (in_array('default-calendar', $class) && $post_id === $id) {
128
+					array_push($class, 'default-calendar-'.$theme);
129 129
 				}
130 130
 				return $class;
131
-			}, 10, 2 );
131
+			}, 10, 2);
132 132
 
133 133
 		}
134 134
 
135 135
 		// Calendar settings handling.
136
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
136
+		if (is_admin() && ! defined('DOING_AJAX')) {
137 137
 			$admin = new Default_Calendar_Admin();
138 138
 			$this->settings = $admin->settings_fields();
139 139
 		}
@@ -147,49 +147,49 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @param  $view
149 149
 	 */
150
-	private function set_properties( $view ) {
150
+	private function set_properties($view) {
151 151
 
152 152
 		// Set styles.
153
-		if ( 'dark' == get_post_meta( $this->id, '_default_calendar_style_theme', true ) ) {
153
+		if ('dark' == get_post_meta($this->id, '_default_calendar_style_theme', true)) {
154 154
 			$this->theme = 'dark';
155 155
 		}
156
-		if ( $today_color = get_post_meta( $this->id, '_default_calendar_style_today', true ) ) {
157
-			$this->today_color = esc_attr( $today_color );
156
+		if ($today_color = get_post_meta($this->id, '_default_calendar_style_today', true)) {
157
+			$this->today_color = esc_attr($today_color);
158 158
 		}
159
-		if ( $day_events_color = get_post_meta( $this->id, '_default_calendar_style_days_events', true ) ) {
160
-			$this->days_events_color = esc_attr( $day_events_color );
159
+		if ($day_events_color = get_post_meta($this->id, '_default_calendar_style_days_events', true)) {
160
+			$this->days_events_color = esc_attr($day_events_color);
161 161
 		}
162 162
 
163 163
 		// Hide too many events.
164
-		if ( 'yes' == get_post_meta( $this->id, '_default_calendar_limit_visible_events', true ) ) {
165
-			$this->events_limit = absint( get_post_meta( $this->id, '_default_calendar_visible_events', true ) );
164
+		if ('yes' == get_post_meta($this->id, '_default_calendar_limit_visible_events', true)) {
165
+			$this->events_limit = absint(get_post_meta($this->id, '_default_calendar_visible_events', true));
166 166
 		}
167 167
 
168 168
 		// Expand multiple day events.
169
-		if ( 'yes' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) ) {
169
+		if ('yes' == get_post_meta($this->id, '_default_calendar_expand_multi_day_events', true)) {
170 170
 			$this->events = $this->expand_multiple_days_events();
171 171
 		}
172 172
 
173
-		if ( 'grid' == $view ) {
173
+		if ('grid' == $view) {
174 174
 
175 175
 			// Use hover to open event bubbles.
176
-			if ( 'hover' == get_post_meta( $this->id, '_default_calendar_event_bubble_trigger', true ) ) {
176
+			if ('hover' == get_post_meta($this->id, '_default_calendar_event_bubble_trigger', true)) {
177 177
 				$this->event_bubble_trigger = 'hover';
178 178
 			}
179 179
 
180 180
 			// Trim long event titles.
181
-			if ( 'yes' == get_post_meta( $this->id, '_default_calendar_trim_titles', true ) ) {
182
-				$this->trim_titles = max( absint( get_post_meta( $this->id, '_default_calendar_trim_titles_chars', true ) ), 1 );
181
+			if ('yes' == get_post_meta($this->id, '_default_calendar_trim_titles', true)) {
182
+				$this->trim_titles = max(absint(get_post_meta($this->id, '_default_calendar_trim_titles_chars', true)), 1);
183 183
 			}
184 184
 
185 185
 		} else {
186 186
 
187 187
 			// List range.
188
-			$this->group_type = esc_attr( get_post_meta( $this->id, '_default_calendar_list_range_type', true ) );
189
-			$this->group_span = max( absint( get_post_meta( $this->id, '_default_calendar_list_range_span', true ) ), 1 );
188
+			$this->group_type = esc_attr(get_post_meta($this->id, '_default_calendar_list_range_type', true));
189
+			$this->group_span = max(absint(get_post_meta($this->id, '_default_calendar_list_range_span', true)), 1);
190 190
 
191 191
 			// Make the list look more compact.
192
-			if ( 'yes' == get_post_meta( $this->id, '_default_calendar_compact_list', true ) ) {
192
+			if ('yes' == get_post_meta($this->id, '_default_calendar_compact_list', true)) {
193 193
 				$this->compact_list = true;
194 194
 			}
195 195
 
@@ -210,24 +210,24 @@  discard block
 block discarded – undo
210 210
 		$old_events = $this->events;
211 211
 		$new_events = array();
212 212
 
213
-		if ( ! empty( $old_events ) ) {
213
+		if ( ! empty($old_events)) {
214 214
 
215
-			foreach ( $old_events as $events ) {
216
-				foreach ( $events as $event ) {
217
-					if ( $event instanceof Event ) {
218
-						if ( false !== $event->multiple_days ) {
215
+			foreach ($old_events as $events) {
216
+				foreach ($events as $event) {
217
+					if ($event instanceof Event) {
218
+						if (false !== $event->multiple_days) {
219 219
 							$days = $event->multiple_days;
220 220
 
221
-							if ( $days == 1 ) {
222
-								$new_events[ intval( $event->start + ( DAY_IN_SECONDS ) - 1 ) ][] = $event;
221
+							if ($days == 1) {
222
+								$new_events[intval($event->start + (DAY_IN_SECONDS) - 1)][] = $event;
223 223
 							} else {
224 224
 
225 225
 								/*if ( ! empty( $event->whole_day ) ) {
226 226
 									$days--;
227 227
 								}*/
228 228
 
229
-								for ( $d = 1; $d <= $days; $d++ ) {
230
-									$new_events[ intval( $event->start + ( $d * DAY_IN_SECONDS ) - 1 ) ][] = $event;
229
+								for ($d = 1; $d <= $days; $d++) {
230
+									$new_events[intval($event->start + ($d * DAY_IN_SECONDS) - 1)][] = $event;
231 231
 								}
232 232
 							}
233 233
 						}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		}
240 240
 
241 241
 		$events = $old_events + $new_events;
242
-		ksort( $events, SORT_NUMERIC );
242
+		ksort($events, SORT_NUMERIC);
243 243
 		return $events;
244 244
 	}
245 245
 
@@ -254,16 +254,16 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @return null|Calendar_View
256 256
 	 */
257
-	public function get_view( $view = '' ) {
257
+	public function get_view($view = '') {
258 258
 
259
-		$view = ! empty( $view ) ? $view : 'grid';
259
+		$view = ! empty($view) ? $view : 'grid';
260 260
 
261
-		do_action( 'simcal_calendar_get_view', $this->type, $view );
261
+		do_action('simcal_calendar_get_view', $this->type, $view);
262 262
 
263
-		if ( 'grid' == $view ) {
264
-			return new Views\Default_Calendar_Grid( $this );
265
-		} elseif ( 'list' == $view ) {
266
-			return new Views\Default_Calendar_List( $this );
263
+		if ('grid' == $view) {
264
+			return new Views\Default_Calendar_Grid($this);
265
+		} elseif ('list' == $view) {
266
+			return new Views\Default_Calendar_List($this);
267 267
 		}
268 268
 
269 269
 		return null;
Please login to merge, or discard this patch.
includes/calendars/views/default-calendar-grid.php 1 patch
Spacing   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use SimpleCalendar\Events\Event;
14 14
 use SimpleCalendar\Calendars\Default_Calendar;
15 15
 
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @param string|Calendar $calendar
57 57
 	 */
58
-	public function __construct( $calendar = '' ) {
58
+	public function __construct($calendar = '') {
59 59
 		$this->calendar = $calendar;
60 60
 	}
61 61
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return string
90 90
 	 */
91 91
 	public function get_name() {
92
-		return __( 'Grid', 'google-calendar-events' );
92
+		return __('Grid', 'google-calendar-events');
93 93
 	}
94 94
 
95 95
 	/**
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 * @since 3.0.0
99 99
 	 */
100 100
 	public function add_ajax_actions() {
101
-		add_action( 'wp_ajax_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) );
102
-		add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) );
101
+		add_action('wp_ajax_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax'));
102
+		add_action('wp_ajax_nopriv_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax'));
103 103
 	}
104 104
 
105 105
 	/**
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return array
115 115
 	 */
116
-	public function scripts( $min = '' ) {
116
+	public function scripts($min = '') {
117 117
 		return array(
118 118
 			'simcal-qtip' => array(
119
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js',
120
-				'deps'      => array( 'jquery' ),
119
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js',
120
+				'deps'      => array('jquery'),
121 121
 				'ver'       => '2.2.1',
122 122
 				'in_footer' => true,
123 123
 			),
124 124
 			'simcal-default-calendar' => array(
125
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js',
125
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js',
126 126
 				'deps'      => array(
127 127
 					'jquery',
128 128
 					'simcal-qtip',
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @return array
149 149
 	 */
150
-	public function styles( $min = '' ) {
150
+	public function styles($min = '') {
151 151
 		return array(
152 152
 			'simcal-qtip' => array(
153
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/vendor/qtip' . $min . '.css',
153
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/vendor/qtip'.$min.'.css',
154 154
 				'ver'   => '2.2.1',
155 155
 				'media' => 'all',
156 156
 			),
157 157
 			'simcal-default-calendar-grid' => array(
158
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-grid' . $min . '.css',
158
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-grid'.$min.'.css',
159 159
 				'deps'  => array(
160 160
 					'simcal-qtip',
161 161
 				),
@@ -174,16 +174,16 @@  discard block
 block discarded – undo
174 174
 
175 175
 		$calendar = $this->calendar;
176 176
 
177
-		if ( $calendar instanceof Default_Calendar ) {
177
+		if ($calendar instanceof Default_Calendar) {
178 178
 
179 179
 			?>
180 180
 			<table class="simcal-calendar-grid"
181 181
 			       data-event-bubble-trigger="<?php echo $calendar->event_bubble_trigger; ?>">
182 182
 				<thead class="simcal-calendar-head">
183 183
 					<tr>
184
-						<?php if ( ! $calendar->static ) { ?>
184
+						<?php if ( ! $calendar->static) { ?>
185 185
 							<th class="simcal-nav simcal-prev-wrapper" colspan="1">
186
-								<button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e( 'Previous Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-left"></i></button>
186
+								<button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e('Previous Month', 'google-calendar-events'); ?>"><i class="simcal-icon-left"></i></button>
187 187
 							</th>
188 188
 						<?php } ?>
189 189
 						<th colspan="<?php echo $calendar->static ? '7' : '5'; ?>"
@@ -195,26 +195,26 @@  discard block
 block discarded – undo
195 195
 
196 196
 							// Display month and year according to user date format preference.
197 197
 
198
-							$year_pos  = strcspn( $calendar->date_format, 'Y y' );
199
-							$month_pos = strcspn( $calendar->date_format, 'F M m n' );
198
+							$year_pos  = strcspn($calendar->date_format, 'Y y');
199
+							$month_pos = strcspn($calendar->date_format, 'F M m n');
200 200
 
201
-							$current = array( 'month' => 'F', 'year' => 'Y' );
201
+							$current = array('month' => 'F', 'year' => 'Y');
202 202
 
203
-							if ( $year_pos < $month_pos ) {
204
-								$current = array_reverse( $current );
203
+							if ($year_pos < $month_pos) {
204
+								$current = array_reverse($current);
205 205
 							}
206 206
 
207
-							foreach ( $current as $k => $v ) {
208
-								echo ' <span class="simcal-current-' . $k , '">' . date_i18n( $v, $calendar->start ) . '</span> ';
207
+							foreach ($current as $k => $v) {
208
+								echo ' <span class="simcal-current-'.$k, '">'.date_i18n($v, $calendar->start).'</span> ';
209 209
 							}
210 210
 
211 211
 							echo '</h3>';
212 212
 
213 213
 							?>
214 214
 						</th>
215
-						<?php if ( ! $calendar->static ) { ?>
215
+						<?php if ( ! $calendar->static) { ?>
216 216
 							<th class="simcal-nav simcal-next-wrapper" colspan="1">
217
-								<button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e( 'Next Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-right"></i></button>
217
+								<button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e('Next Month', 'google-calendar-events'); ?>"><i class="simcal-icon-right"></i></button>
218 218
 							</th>
219 219
 						<?php } ?>
220 220
 					</tr>
@@ -224,28 +224,28 @@  discard block
 block discarded – undo
224 224
 						// Print day names in short or long form for different viewport sizes.
225 225
 
226 226
 						$week_starts     = $calendar->week_starts;
227
-						$week_days_short = simcal_get_calendar_names_i18n( 'day', 'short' );
228
-						$week_days_full  = simcal_get_calendar_names_i18n( 'day', 'full' );
227
+						$week_days_short = simcal_get_calendar_names_i18n('day', 'short');
228
+						$week_days_full  = simcal_get_calendar_names_i18n('day', 'full');
229 229
 
230
-						for ( $i = $week_starts; $i <= 6; $i ++ ) :
230
+						for ($i = $week_starts; $i <= 6; $i++) :
231 231
 
232 232
 							?>
233 233
 							<th class="simcal-week-day simcal-week-day-<?php echo $i ?>"
234
-							    data-screen-small="<?php echo substr( $week_days_short[ $i ], 0, 1 ); ?>"
235
-							    data-screen-medium="<?php echo $week_days_short[ $i ]; ?>"
236
-							    data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th>
234
+							    data-screen-small="<?php echo substr($week_days_short[$i], 0, 1); ?>"
235
+							    data-screen-medium="<?php echo $week_days_short[$i]; ?>"
236
+							    data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th>
237 237
 							<?php
238 238
 
239 239
 						endfor;
240 240
 
241
-						if ( $week_starts !== 0 ) :
242
-							for ( $i = 0; $i < $week_starts; $i ++ ) :
241
+						if ($week_starts !== 0) :
242
+							for ($i = 0; $i < $week_starts; $i++) :
243 243
 
244 244
 								?>
245 245
 								<th class="simcal-week-day simcal-week-day-<?php echo $i ?>"
246
-								    data-screen-small="<?php echo substr( $week_days_short[ $i ], 0, 1 ); ?>"
247
-								    data-screen-medium="<?php echo $week_days_short[ $i ]; ?>"
248
-								    data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th>
246
+								    data-screen-small="<?php echo substr($week_days_short[$i], 0, 1); ?>"
247
+								    data-screen-medium="<?php echo $week_days_short[$i]; ?>"
248
+								    data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th>
249 249
 								<?php
250 250
 
251 251
 							endfor;
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 					</tr>
256 256
 				</thead>
257 257
 
258
-				<?php echo $this->draw_month( date( 'n', $calendar->start ), date( 'Y', $calendar->start ) ); ?>
258
+				<?php echo $this->draw_month(date('n', $calendar->start), date('Y', $calendar->start)); ?>
259 259
 
260 260
 			</table>
261 261
 			<?php
@@ -280,82 +280,82 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @return string
282 282
 	 */
283
-	private function draw_month( $month, $year, $id = 0 ) {
283
+	private function draw_month($month, $year, $id = 0) {
284 284
 
285 285
 		$calendar = $this->calendar;
286
-		if ( empty( $calendar ) ) {
287
-			$calendar = simcal_get_calendar( intval( $id ) );
288
-			if ( ! $calendar ) {
286
+		if (empty($calendar)) {
287
+			$calendar = simcal_get_calendar(intval($id));
288
+			if ( ! $calendar) {
289 289
 				return '';
290 290
 			}
291 291
 		}
292
-		date_default_timezone_set( $calendar->timezone );
292
+		date_default_timezone_set($calendar->timezone);
293 293
 		$events = $calendar->events;
294 294
 
295 295
 		// Variables to cycle days in current month and find today in calendar.
296 296
 		$now         = $calendar->now;
297
-		$current     = Carbon::create( $year, $month, 1, 0, 0, 59, $calendar->timezone );
297
+		$current     = Carbon::create($year, $month, 1, 0, 0, 59, $calendar->timezone);
298 298
 		$current_min = $current->getTimestamp();
299 299
 		$current_max = $current->endOfDay()->getTimestamp();
300 300
 
301 301
 		// Calendar grid variables.
302 302
 		$week_starts   = $calendar->week_starts;
303
-		$week_of_year  = $current->weekOfYear;   // Relative count of the week number of the year.
304
-		$month_starts  = $current->dayOfWeek;    // Day upon which the month starts.
305
-		$days_in_month = $current->daysInMonth;  // Number of days in the given month.
303
+		$week_of_year  = $current->weekOfYear; // Relative count of the week number of the year.
304
+		$month_starts  = $current->dayOfWeek; // Day upon which the month starts.
305
+		$days_in_month = $current->daysInMonth; // Number of days in the given month.
306 306
 
307 307
 		// Set current month events timestamp boundaries.
308 308
 		$this->start = $current_min;
309 309
 		$this->end   = $current->endOfMonth()->timestamp;
310 310
 
311 311
 		// Get daily events for this month.
312
-		if ( $events && is_array( $events ) ) {
312
+		if ($events && is_array($events)) {
313 313
 
314 314
 			// Filter events within the boundaries previously set above.
315
-			$timestamps   = array_keys( $events );
316
-			$lower_bound  = array_filter( $timestamps, array( $this, 'filter_events_before' ) );
317
-			$higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) );
318
-			$filtered     = ( is_array( $events ) && is_array( $higher_bound) ) && ! empty( $events ) && ! empty( $higher_bound ) ? array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ) : array();
315
+			$timestamps   = array_keys($events);
316
+			$lower_bound  = array_filter($timestamps, array($this, 'filter_events_before'));
317
+			$higher_bound = array_filter($lower_bound, array($this, 'filter_events_after'));
318
+			$filtered     = (is_array($events) && is_array($higher_bound)) && ! empty($events) && ! empty($higher_bound) ? array_intersect_key($events, array_combine($higher_bound, $higher_bound)) : array();
319 319
 
320 320
 			// Put resulting events in an associative array, with day of the month as key for easy retrieval in calendar days loop.
321 321
 			$day_events = array();
322
-			foreach ( $filtered as $timestamp => $events_in_day ) {
323
-				foreach ( $events_in_day as $event ) {
324
-					if ( $event instanceof Event ){
325
-						$day = intval( Carbon::createFromTimestamp( $timestamp, $event->timezone )->endOfDay()->day );
326
-						$day_events[ $day ][] = $event;
322
+			foreach ($filtered as $timestamp => $events_in_day) {
323
+				foreach ($events_in_day as $event) {
324
+					if ($event instanceof Event) {
325
+						$day = intval(Carbon::createFromTimestamp($timestamp, $event->timezone)->endOfDay()->day);
326
+						$day_events[$day][] = $event;
327 327
 					}
328 328
 				}
329 329
 			}
330 330
 
331
-			ksort( $day_events, SORT_NUMERIC );
331
+			ksort($day_events, SORT_NUMERIC);
332 332
 		}
333 333
 
334 334
 		ob_start();
335 335
 
336
-		echo '<tbody class="simcal-month simcal-month-' . $month . '">' . "\n";
337
-		echo "\t" . '<tr class="simcal-week simcal-week-' . $week_of_year . '">';
336
+		echo '<tbody class="simcal-month simcal-month-'.$month.'">'."\n";
337
+		echo "\t".'<tr class="simcal-week simcal-week-'.$week_of_year.'">';
338 338
 
339 339
 		$days_in_row = 0;
340 340
 		// Week may start on an arbitrary day (sun, 0 - sat, 6).
341 341
 		$week_day = $week_starts;
342 342
 
343 343
 		// This fixes a possible bug when a month starts by Sunday (0).
344
-		if ( 0 !== $week_starts ) {
344
+		if (0 !== $week_starts) {
345 345
 			$b = $month_starts === 0 ? 7 : $month_starts;
346 346
 		} else {
347 347
 			$b = $month_starts;
348 348
 		}
349 349
 
350 350
 		// Void days in first week.
351
-		for ( $a = $week_starts; $a < $b; $a++ ) :
351
+		for ($a = $week_starts; $a < $b; $a++) :
352 352
 
353
-			$last_void_day_class = ( $a === ( $b - 1 ) ) ? 'simcal-day-void-last' : '';
353
+			$last_void_day_class = ($a === ($b - 1)) ? 'simcal-day-void-last' : '';
354 354
 
355
-			echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n";
355
+			echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n";
356 356
 
357 357
 			// Reset day of the week count (sun, 0 - sat, 6).
358
-			if ( $week_day === 6 ) {
358
+			if ($week_day === 6) {
359 359
 				$week_day = -1;
360 360
 			}
361 361
 			$week_day++;
@@ -365,91 +365,91 @@  discard block
 block discarded – undo
365 365
 		endfor;
366 366
 
367 367
 		// Actual days of the month.
368
-		for ( $day = 1; $day <= $days_in_month; $day++ ) :
368
+		for ($day = 1; $day <= $days_in_month; $day++) :
369 369
 
370 370
 			$count = 0;
371 371
 			$calendar_classes = array();
372
-			$day_classes = 'simcal-day-' . $day . ' simcal-weekday-' . $week_day;
372
+			$day_classes = 'simcal-day-'.$day.' simcal-weekday-'.$week_day;
373 373
 
374 374
 			$border_style = $bg_color = $color = '';
375 375
 
376 376
 			// Is this the present, the past or the future, Doc?
377
-			if ( $current_min <= $now && $current_max >= $now ) {
377
+			if ($current_min <= $now && $current_max >= $now) {
378 378
 				$day_classes .= ' simcal-today simcal-present simcal-day';
379
-				$the_color = new Color( $calendar->today_color );
380
-				$bg_color = '#' . $the_color->getHex();
379
+				$the_color = new Color($calendar->today_color);
380
+				$bg_color = '#'.$the_color->getHex();
381 381
 				$color = $the_color->isDark() ? '#ffffff' : '#000000';
382
-				$border_style = ' style="border: 1px solid ' . $bg_color . ';"';
383
-			} elseif ( $current_max < $now ) {
382
+				$border_style = ' style="border: 1px solid '.$bg_color.';"';
383
+			} elseif ($current_max < $now) {
384 384
 				$day_classes .= ' simcal-past simcal-day';
385
-			} elseif ( $current_min > $now ) {
385
+			} elseif ($current_min > $now) {
386 386
 				$day_classes .= ' simcal-future simcal-day';
387 387
 			}
388 388
 
389 389
 			// Print events for the current day in loop, if found any.
390
-			if ( isset( $day_events[ $day ] ) ) :
390
+			if (isset($day_events[$day])) :
391 391
 
392 392
 				$list_events = '<ul class="simcal-events">';
393 393
 
394
-				foreach ( $day_events[ $day ] as $event ) :
394
+				foreach ($day_events[$day] as $event) :
395 395
 
396 396
 					$event_classes = $event_visibility = '';
397 397
 
398
-					if ( $event instanceof Event ) :
398
+					if ($event instanceof Event) :
399 399
 
400 400
 						// Store the calendar id where the event belongs (useful in grouped calendar feeds)
401
-						$calendar_class  = 'simcal-events-calendar-' . strval( $event->calendar );
402
-						$calendar_classes[] = $calendar_class ;
401
+						$calendar_class = 'simcal-events-calendar-'.strval($event->calendar);
402
+						$calendar_classes[] = $calendar_class;
403 403
 
404 404
 						$recurring     = $event->recurrence ? 'simcal-event-recurring ' : '';
405 405
 						$has_location  = $event->venue ? 'simcal-event-has-location ' : '';
406 406
 
407
-						$event_classes  .= 'simcal-event ' . $recurring . $has_location . $calendar_class . ' simcal-tooltip';
407
+						$event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class.' simcal-tooltip';
408 408
 
409 409
 						// Toggle some events visibility if more than optional limit.
410
-						if ( ( $calendar->events_limit > -1 )  && ( $count >= $calendar->events_limit ) ) :
410
+						if (($calendar->events_limit > -1) && ($count >= $calendar->events_limit)) :
411 411
 							$event_classes    .= ' simcal-event-toggled';
412 412
 							$event_visibility  = ' style="display: none"';
413 413
 						endif;
414 414
 
415 415
 						// Event title in list.
416
-						$title = ! empty( $event->title ) ? trim( $event->title ) : __( 'Event', 'google-calendar-events' );
417
-						if ( $calendar->trim_titles >= 1 ) {
418
-							$title = strlen( $title ) > $calendar->trim_titles ? substr( $title, 0, $calendar->trim_titles ) . '&hellip;' : $title;
416
+						$title = ! empty($event->title) ? trim($event->title) : __('Event', 'google-calendar-events');
417
+						if ($calendar->trim_titles >= 1) {
418
+							$title = strlen($title) > $calendar->trim_titles ? substr($title, 0, $calendar->trim_titles).'&hellip;' : $title;
419 419
 						}
420 420
 
421 421
 						// Event color.
422 422
 						$bullet = '';
423 423
 						$event_color = $event->get_color();
424
-						if ( ! empty( $event_color ) ) {
425
-							$bullet = '<span style="color: ' . $event_color . ';">&#9632;</span> ';
424
+						if ( ! empty($event_color)) {
425
+							$bullet = '<span style="color: '.$event_color.';">&#9632;</span> ';
426 426
 						}
427 427
 
428 428
 						// Event contents.
429
-						$list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . ' itemprop="event" itemscope itemtype="http://schema.org/Event">' . "\n";
430
-						$list_events .= "\t\t" . '<span class="simcal-event-title">' . $bullet . $title . '</span>' . "\n";
431
-						$list_events .= "\t\t" . '<div class="simcal-event-details simcal-tooltip-content" style="display: none;">' . $calendar->get_event_html( $event ) . '</div>' . "\n";
432
-						$list_events .= "\t" . '</li>' . "\n";
429
+						$list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.' itemprop="event" itemscope itemtype="http://schema.org/Event">'."\n";
430
+						$list_events .= "\t\t".'<span class="simcal-event-title">'.$bullet.$title.'</span>'."\n";
431
+						$list_events .= "\t\t".'<div class="simcal-event-details simcal-tooltip-content" style="display: none;">'.$calendar->get_event_html($event).'</div>'."\n";
432
+						$list_events .= "\t".'</li>'."\n";
433 433
 
434
-						$count ++;
434
+						$count++;
435 435
 
436 436
 					endif;
437 437
 
438 438
 				endforeach;
439 439
 
440
-				if ( ( $current_min <= $now ) && ( $current_max >= $now ) ) {
440
+				if (($current_min <= $now) && ($current_max >= $now)) {
441 441
 					$day_classes .= ' simcal-today-has-events';
442 442
 				}
443
-				$day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events';
443
+				$day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events';
444 444
 
445
-				if ( $calendar_classes ) {
446
-					$day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) );
445
+				if ($calendar_classes) {
446
+					$day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes)));
447 447
 				}
448 448
 
449
-				$list_events .= '</ul>' . "\n";
449
+				$list_events .= '</ul>'."\n";
450 450
 
451 451
 				// Optional button to toggle hidden events in list.
452
-				if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) :
452
+				if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) :
453 453
 					$list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>';
454 454
 				endif;
455 455
 
@@ -461,49 +461,49 @@  discard block
 block discarded – undo
461 461
 			endif;
462 462
 
463 463
 			// The actual days with numbers and events in each row cell.
464
-			echo '<td class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n";
465
-
466
-			if ( $color ) {
467
-				$day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"';
468
-			} elseif ( $count > 0 ) {
469
-				$the_color = new Color( $calendar->days_events_color );
470
-				$color = ! $color ? ( $the_color->isDark() ? '#ffffff' : '#000000' ) : $color;
471
-				$bg_color = ! $bg_color ? '#' . $the_color->getHex() : $bg_color;
472
-				$day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"';
464
+			echo '<td class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n";
465
+
466
+			if ($color) {
467
+				$day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"';
468
+			} elseif ($count > 0) {
469
+				$the_color = new Color($calendar->days_events_color);
470
+				$color = ! $color ? ($the_color->isDark() ? '#ffffff' : '#000000') : $color;
471
+				$bg_color = ! $bg_color ? '#'.$the_color->getHex() : $bg_color;
472
+				$day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"';
473 473
 			} else {
474 474
 				$day_style = '';
475 475
 			}
476 476
 
477
-			echo "\t" . '<div' . $border_style . '>' . "\n";
478
-			echo "\t\t" . '<span class="simcal-day-label simcal-day-number"' . $day_style . '>' . $day . '</span>' . "\n";
479
-			echo "\t\t" . $list_events . "\n";
477
+			echo "\t".'<div'.$border_style.'>'."\n";
478
+			echo "\t\t".'<span class="simcal-day-label simcal-day-number"'.$day_style.'>'.$day.'</span>'."\n";
479
+			echo "\t\t".$list_events."\n";
480 480
 			echo "\t\t";
481 481
 			echo '<span class="simcal-events-dots" style="display: none;">';
482 482
 
483 483
 			// Event bullets for calendar mobile mode.
484
-			for( $i = 0; $i < $count; $i++ ) {
484
+			for ($i = 0; $i < $count; $i++) {
485 485
 				echo '<b> &bull; </b>';
486 486
 			}
487 487
 
488
-			echo '</span>' . "\n";
489
-			echo "\t" . '</div>' . "\n";
490
-			echo '</td>' . "\n";
488
+			echo '</span>'."\n";
489
+			echo "\t".'</div>'."\n";
490
+			echo '</td>'."\n";
491 491
 
492 492
 			// Reset day of the week count (sun, 0 - sat, 6).
493
-			if ( $week_day === 6 ) {
493
+			if ($week_day === 6) {
494 494
 				$week_day = - 1;
495 495
 			}
496 496
 			$week_day++;
497 497
 
498 498
 			// Reset count of days for this row (0-6).
499
-			if ( $days_in_row === 6 ) :
499
+			if ($days_in_row === 6) :
500 500
 
501 501
 				// Close the week row.
502 502
 				echo '</tr>';
503 503
 
504 504
 				// Open a new week row.
505
-				if ( $day < $days_in_month ) {
506
-					echo '<tr class="simcal-week simcal-week-' . $week_of_year++ . '">' . "\n";
505
+				if ($day < $days_in_month) {
506
+					echo '<tr class="simcal-week simcal-week-'.$week_of_year++.'">'."\n";
507 507
 				}
508 508
 
509 509
 				$days_in_row = -1;
@@ -512,27 +512,27 @@  discard block
 block discarded – undo
512 512
 
513 513
 			$days_in_row++;
514 514
 
515
-			$current_min = Carbon::createFromTimestamp( $current_min, $calendar->timezone )->addDay()->getTimestamp();
516
-			$current_max = Carbon::createFromTimestamp( $current_max, $calendar->timezone )->addDay()->getTimestamp();
515
+			$current_min = Carbon::createFromTimestamp($current_min, $calendar->timezone)->addDay()->getTimestamp();
516
+			$current_max = Carbon::createFromTimestamp($current_max, $calendar->timezone)->addDay()->getTimestamp();
517 517
 
518 518
 		endfor;
519 519
 
520 520
 		// Void days at the end of the month.
521
-		$remainder_days = ( 6 - $days_in_row );
521
+		$remainder_days = (6 - $days_in_row);
522 522
 
523
-		for ( $i = 0; $i <= $remainder_days; $i ++ ) {
523
+		for ($i = 0; $i <= $remainder_days; $i++) {
524 524
 
525
-			$last_void_day_class = ( $i == $remainder_days ) ? 'simcal-day-void-last' : '';
525
+			$last_void_day_class = ($i == $remainder_days) ? 'simcal-day-void-last' : '';
526 526
 
527
-			echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n";
527
+			echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n";
528 528
 
529 529
 			$week_day++;
530 530
 		}
531 531
 
532
-		echo "\t" . '</tr>' . "\n";
533
-		echo '</tbody>' . "\n";
532
+		echo "\t".'</tr>'."\n";
533
+		echo '</tbody>'."\n";
534 534
 
535
-		date_default_timezone_set( $calendar->site_timezone );
535
+		date_default_timezone_set($calendar->site_timezone);
536 536
 
537 537
 		return ob_get_clean();
538 538
 	}
@@ -544,17 +544,17 @@  discard block
 block discarded – undo
544 544
 	 */
545 545
 	public function draw_grid_ajax() {
546 546
 
547
-		if ( isset( $_POST['month'] ) && isset( $_POST['year'] ) && isset( $_POST['id'] ) ) {
547
+		if (isset($_POST['month']) && isset($_POST['year']) && isset($_POST['id'])) {
548 548
 
549
-			$month = absint( $_POST['month'] );
550
-			$year  = absint( $_POST['year'] );
551
-			$id    = absint( $_POST['id'] );
549
+			$month = absint($_POST['month']);
550
+			$year  = absint($_POST['year']);
551
+			$id    = absint($_POST['id']);
552 552
 
553
-			wp_send_json_success( $this->draw_month( $month, $year, $id ) );
553
+			wp_send_json_success($this->draw_month($month, $year, $id));
554 554
 
555 555
 		} else {
556 556
 
557
-			wp_send_json_error( 'Missing arguments in default calendar grid ajax request.' );
557
+			wp_send_json_error('Missing arguments in default calendar grid ajax request.');
558 558
 
559 559
 		}
560 560
 
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 	 *
571 571
 	 * @return bool
572 572
 	 */
573
-	private function filter_events_before( $event ) {
574
-		return intval( $event ) > intval( $this->start );
573
+	private function filter_events_before($event) {
574
+		return intval($event) > intval($this->start);
575 575
 	}
576 576
 
577 577
 	/**
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
 	 *
585 585
 	 * @return bool
586 586
 	 */
587
-	private function filter_events_after( $event ) {
588
-		return intval( $event ) < intval( $this->end );
587
+	private function filter_events_after($event) {
588
+		return intval($event) < intval($this->end);
589 589
 	}
590 590
 
591 591
 }
Please login to merge, or discard this patch.
includes/events/event-builder.php 1 patch
Spacing   +306 added lines, -306 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,39 +228,39 @@  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
-					return ' <span class="simcal-event-address simcal-event-start-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . wp_strip_all_tags( $location ) . '</span>';
248
+					return ' <span class="simcal-event-address simcal-event-start-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'.wp_strip_all_tags($location).'</span>';
249 249
 
250 250
 				case 'start-location-link':
251 251
 				case 'end-location-link' :
252 252
 				case 'maps-link' :
253 253
 					$location = $tag == 'end-location-link' ? $event->end_location['address'] : $event->start_location['address'];
254
-					if ( ! empty( $location ) ) {
255
-						$url = '//maps.google.com?q=' . urlencode( $location );
256
-						return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr );
254
+					if ( ! empty($location)) {
255
+						$url = '//maps.google.com?q='.urlencode($location);
256
+						return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr);
257 257
 					}
258 258
 					break;
259 259
 
260 260
 				case 'link' :
261 261
 				case 'url' :
262
-					$content = 'link' == $tag ? $calendar->get_event_html( $event, $partial ) : '';
263
-					return $this->make_link( $tag, $event->link, $content , $attr );
262
+					$content = 'link' == $tag ? $calendar->get_event_html($event, $partial) : '';
263
+					return $this->make_link($tag, $event->link, $content, $attr);
264 264
 
265 265
 				case 'calendar' :
266 266
 				case 'feed-title' :
@@ -282,22 +282,22 @@  discard block
 block discarded – undo
282 282
 
283 283
 				case 'attachments' :
284 284
 					$attachments = $event->get_attachments();
285
-					if ( ! empty( $attachments ) ) {
286
-						return $this->get_attachments( $attachments );
285
+					if ( ! empty($attachments)) {
286
+						return $this->get_attachments($attachments);
287 287
 					}
288 288
 					break;
289 289
 
290 290
 				case 'attendees' :
291 291
 					$attendees = $event->get_attendees();
292
-					if ( ! empty( $attendees ) ) {
293
-						return $this->get_attendees( $attendees, $attr );
292
+					if ( ! empty($attendees)) {
293
+						return $this->get_attendees($attendees, $attr);
294 294
 					}
295 295
 					break;
296 296
 
297 297
 				case 'organizer' :
298 298
 					$organizer = $event->get_organizer();
299
-					if ( ! empty( $organizer ) ) {
300
-						return $this->get_organizer( $organizer, $attr );
299
+					if ( ! empty($organizer)) {
300
+						return $this->get_organizer($organizer, $attr);
301 301
 					}
302 302
 					break;
303 303
 
@@ -306,35 +306,35 @@  discard block
 block discarded – undo
306 306
 				 * ================ */
307 307
 
308 308
 				case 'if-title':
309
-					if ( ! empty( $event->title ) ) {
310
-						return $calendar->get_event_html( $event, $partial );
309
+					if ( ! empty($event->title)) {
310
+						return $calendar->get_event_html($event, $partial);
311 311
 					}
312 312
 					break;
313 313
 
314 314
 				case 'if-description':
315
-					if ( ! empty( $event->description ) ) {
316
-						return $calendar->get_event_html( $event, $partial );
315
+					if ( ! empty($event->description)) {
316
+						return $calendar->get_event_html($event, $partial);
317 317
 					}
318 318
 					break;
319 319
 
320 320
 				case 'if-now' :
321 321
 				case 'if-not-now' :
322 322
 
323
-					$start_dt = $event->start_dt->setTimezone( $calendar->timezone );
323
+					$start_dt = $event->start_dt->setTimezone($calendar->timezone);
324 324
 					$start = $start_dt->getTimestamp();
325 325
 
326
-					if ( $event->end_dt instanceof Carbon ) {
327
-						$end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp();
326
+					if ($event->end_dt instanceof Carbon) {
327
+						$end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp();
328 328
 					} else {
329 329
 						return '';
330 330
 					}
331 331
 
332
-					$now = ( $start <= $calendar->now ) && ( $end >= $calendar->now );
332
+					$now = ($start <= $calendar->now) && ($end >= $calendar->now);
333 333
 
334
-					if ( ( 'if-now' == $tag ) && $now ) {
335
-						return $calendar->get_event_html( $event, $partial );
336
-					} elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) {
337
-						return $calendar->get_event_html( $event, $partial );
334
+					if (('if-now' == $tag) && $now) {
335
+						return $calendar->get_event_html($event, $partial);
336
+					} elseif (('if-not-now' == $tag) && (false == $now)) {
337
+						return $calendar->get_event_html($event, $partial);
338 338
 					}
339 339
 
340 340
 					break;
@@ -342,15 +342,15 @@  discard block
 block discarded – undo
342 342
 				case 'if-started' :
343 343
 				case 'if-not-started' :
344 344
 
345
-					$start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp();
345
+					$start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp();
346 346
 
347
-					if ( 'if-started' == $tag ) {
348
-						if ( $start < $calendar->now ) {
349
-							return $calendar->get_event_html( $event, $partial );
347
+					if ('if-started' == $tag) {
348
+						if ($start < $calendar->now) {
349
+							return $calendar->get_event_html($event, $partial);
350 350
 						}
351
-					} elseif ( 'if-not-started' == $tag ) {
352
-						if ( $start > $calendar->now ) {
353
-							return $calendar->get_event_html( $event, $partial );
351
+					} elseif ('if-not-started' == $tag) {
352
+						if ($start > $calendar->now) {
353
+							return $calendar->get_event_html($event, $partial);
354 354
 						}
355 355
 					}
356 356
 
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
 				case 'if-ended' :
360 360
 				case 'if-not-ended' :
361 361
 
362
-					if ( false !== $event->end ) {
362
+					if (false !== $event->end) {
363 363
 
364
-						$end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp();
364
+						$end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp();
365 365
 
366
-						if ( 'if-ended' == $tag ) {
367
-							if ( $end < $calendar->now ) {
368
-								return $calendar->get_event_html( $event, $partial );
366
+						if ('if-ended' == $tag) {
367
+							if ($end < $calendar->now) {
368
+								return $calendar->get_event_html($event, $partial);
369 369
 							}
370
-						} elseif ( 'if-not-ended' == $tag ) {
371
-							if ( $end > $calendar->now ) {
372
-								return $calendar->get_event_html( $event, $partial );
370
+						} elseif ('if-not-ended' == $tag) {
371
+							if ($end > $calendar->now) {
372
+								return $calendar->get_event_html($event, $partial);
373 373
 							}
374 374
 						}
375 375
 
@@ -378,14 +378,14 @@  discard block
 block discarded – undo
378 378
 					break;
379 379
 
380 380
 				case 'if-end-time' :
381
-					if ( false !== $event->end ) {
382
-						return $calendar->get_event_html( $event, $partial );
381
+					if (false !== $event->end) {
382
+						return $calendar->get_event_html($event, $partial);
383 383
 					}
384 384
 					break;
385 385
 
386 386
 				case 'if-no-end-time' :
387
-					if ( false === $event->end ) {
388
-						return $calendar->get_event_html( $event, $partial );
387
+					if (false === $event->end) {
388
+						return $calendar->get_event_html($event, $partial);
389 389
 					}
390 390
 					break;
391 391
 
@@ -393,59 +393,59 @@  discard block
 block discarded – undo
393 393
 				case 'if-whole-day' :
394 394
 				case 'if-not-all-day' :
395 395
 				case 'if-not-whole-day' :
396
-					$bool = strstr( $tag, 'not' ) ? false : true;
397
-					if ( $bool === $event->whole_day ) {
398
-						return $calendar->get_event_html( $event, $partial );
396
+					$bool = strstr($tag, 'not') ? false : true;
397
+					if ($bool === $event->whole_day) {
398
+						return $calendar->get_event_html($event, $partial);
399 399
 					}
400 400
 					break;
401 401
 
402 402
 				case 'if-recurring' :
403
-					if ( ! empty( $event->recurrence ) ) {
404
-						return $calendar->get_event_html( $event, $partial );
403
+					if ( ! empty($event->recurrence)) {
404
+						return $calendar->get_event_html($event, $partial);
405 405
 					}
406 406
 					break;
407 407
 
408 408
 				case 'if-not-recurring' :
409
-					if ( false === $event->recurrence ) {
410
-						return $calendar->get_event_html( $event, $partial );
409
+					if (false === $event->recurrence) {
410
+						return $calendar->get_event_html($event, $partial);
411 411
 					}
412 412
 					break;
413 413
 
414 414
 				case 'if-multi-day' :
415
-					if ( false !== $event->multiple_days ) {
416
-						return $calendar->get_event_html( $event, $partial );
415
+					if (false !== $event->multiple_days) {
416
+						return $calendar->get_event_html($event, $partial);
417 417
 					}
418 418
 					break;
419 419
 
420 420
 				case 'if-single-day' :
421
-					if ( false === $event->multiple_days ) {
422
-						return $calendar->get_event_html( $event, $partial );
421
+					if (false === $event->multiple_days) {
422
+						return $calendar->get_event_html($event, $partial);
423 423
 					}
424 424
 					break;
425 425
 
426 426
 				case 'if-location' :
427 427
 				case 'if-start-location' :
428
-					if ( ! empty( $event->start_location['address'] ) ) {
429
-						return $calendar->get_event_html( $event, $partial );
428
+					if ( ! empty($event->start_location['address'])) {
429
+						return $calendar->get_event_html($event, $partial);
430 430
 					}
431 431
 					return false;
432 432
 
433 433
 				case 'if-not-location' :
434 434
 				case 'if-not-start-location' :
435
-					if ( empty( $event->start_location['address'] ) ) {
436
-						return $calendar->get_event_html( $event, $partial );
435
+					if (empty($event->start_location['address'])) {
436
+						return $calendar->get_event_html($event, $partial);
437 437
 					}
438 438
 					return '';
439 439
 
440 440
 				case 'if-not-end-location' :
441
-					if ( empty( $event->end_location['address'] ) ) {
442
-						return $calendar->get_event_html( $event, $partial );
441
+					if (empty($event->end_location['address'])) {
442
+						return $calendar->get_event_html($event, $partial);
443 443
 					}
444 444
 					return '';
445 445
 
446 446
 				case 'if-end-location' :
447
-					if ( ! empty( $event->end_location['address'] ) ) {
448
-						return $calendar->get_event_html( $event, $partial );
447
+					if ( ! empty($event->end_location['address'])) {
448
+						return $calendar->get_event_html($event, $partial);
449 449
 					}
450 450
 					return '';
451 451
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 				 * ======= */
455 455
 
456 456
 				default :
457
-					return wp_kses_post( $before . $partial . $after );
457
+					return wp_kses_post($before.$partial.$after);
458 458
 			}
459 459
 		}
460 460
 
@@ -472,15 +472,15 @@  discard block
 block discarded – undo
472 472
 	 *
473 473
 	 * @return string
474 474
 	 */
475
-	private function limit_words( $text, $limit ) {
475
+	private function limit_words($text, $limit) {
476 476
 
477
-		$text = wp_strip_all_tags( $text );
478
-		$limit = max( absint( $limit ), 0 );
477
+		$text = wp_strip_all_tags($text);
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
 		} else {
560
-			$html .= $this->limit_words( $description, $attr['limit'] );
560
+			$html .= $this->limit_words($description, $attr['limit']);
561 561
 		}
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/feeds/admin/google-admin.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 		return array(
83 83
 			'name' => $this->feed->name,
84 84
 			'description' => __( "To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events' ) .
85
-			                 '<br/><br/>' .
86
-			                 '<em style="font-size: 14px;">' .
87
-			                 sprintf( __( '<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events' ),
88
-				                 simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'settings-link' )
89
-			                 ) .
90
-			                 '</em>',
85
+							 '<br/><br/>' .
86
+							 '<em style="font-size: 14px;">' .
87
+							 sprintf( __( '<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events' ),
88
+								 simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'settings-link' )
89
+							 ) .
90
+							 '</em>',
91 91
 			'fields' => array(
92 92
 				'api_key' => array(
93 93
 					'type'       => 'standard',
@@ -273,12 +273,12 @@  discard block
 block discarded – undo
273 273
 					'post'        => $post_id,
274 274
 					'dismissable' => false,
275 275
 					'content'     => '<p>' .
276
-					                 '<i class="simcal-icon-warning"></i> ' .
277
-					                 sprintf(
278
-						                 __( 'Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events' ),
279
-						                 admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds' )
280
-					                 ) .
281
-					                 '</p>',
276
+									 '<i class="simcal-icon-warning"></i> ' .
277
+									 sprintf(
278
+										 __( 'Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events' ),
279
+										 admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds' )
280
+									 ) .
281
+									 '</p>',
282 282
 				)
283 283
 			);
284 284
 
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
 						'post'        => $post_id,
306 306
 						'dismissable' => false,
307 307
 						'content'     => '<p>' .
308
-						                 '<i class="simcal-icon-warning"></i> ' .
309
-						                 __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' ) .
310
-						                 '<br>' . $message . '<br>' .
311
-						                 __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) .
312
-						                 '</p>',
308
+										 '<i class="simcal-icon-warning"></i> ' .
309
+										 __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' ) .
310
+										 '<br>' . $message . '<br>' .
311
+										 __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) .
312
+										 '</p>',
313 313
 					)
314 314
 				);
315 315
 
Please login to merge, or discard this patch.
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 use SimpleCalendar\Admin\Notice;
11 11
 use SimpleCalendar\Feeds\Google;
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param string $google_api_key
55 55
 	 * @param string $google_calendar_id
56 56
 	 */
57
-	public function __construct( Google $feed, $google_api_key, $google_calendar_id ) {
57
+	public function __construct(Google $feed, $google_api_key, $google_calendar_id) {
58 58
 
59 59
 		$this->feed = $feed;
60 60
 		$this->google_api_key = $google_api_key;
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 
63 63
 		$screen = simcal_is_admin_screen();
64 64
 
65
-		if ( 'calendar' == $screen ) {
66
-			$this->test_api_key_connection( $this->google_calendar_id );
67
-			add_filter( 'simcal_settings_meta_tabs_li', array( $this, 'add_settings_meta_tab_li' ), 10, 1 );
68
-			add_action( 'simcal_settings_meta_panels', array( $this, 'add_settings_meta_panel' ), 10, 1 );
65
+		if ('calendar' == $screen) {
66
+			$this->test_api_key_connection($this->google_calendar_id);
67
+			add_filter('simcal_settings_meta_tabs_li', array($this, 'add_settings_meta_tab_li'), 10, 1);
68
+			add_action('simcal_settings_meta_panels', array($this, 'add_settings_meta_panel'), 10, 1);
69 69
 		}
70 70
 
71
-		add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 );
71
+		add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1);
72 72
 	}
73 73
 
74 74
 	/**
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 	public function settings_fields() {
82 82
 		return array(
83 83
 			'name' => $this->feed->name,
84
-			'description' => __( "To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events' ) .
85
-			                 '<br/><br/>' .
86
-			                 '<em style="font-size: 14px;">' .
87
-			                 sprintf( __( '<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events' ),
88
-				                 simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'settings-link' )
89
-			                 ) .
84
+			'description' => __("To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events').
85
+			                 '<br/><br/>'.
86
+			                 '<em style="font-size: 14px;">'.
87
+			                 sprintf(__('<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events'),
88
+				                 simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'settings-link')
89
+			                 ).
90 90
 			                 '</em>',
91 91
 			'fields' => array(
92 92
 				'api_key' => array(
93 93
 					'type'       => 'standard',
94 94
 					'subtype'    => 'text',
95
-					'class'      => array( 'simcal-wide-text regular-text', 'ltr' ),
96
-					'title'      => __( 'Google API Key', 'google-calendar-events' ),
97
-					'validation' => array( $this, 'check_google_api_key' ),
95
+					'class'      => array('simcal-wide-text regular-text', 'ltr'),
96
+					'title'      => __('Google API Key', 'google-calendar-events'),
97
+					'validation' => array($this, 'check_google_api_key'),
98 98
 				),
99 99
 			),
100 100
 		);
@@ -113,27 +113,27 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return true|string
115 115
 	 */
116
-	public function check_google_api_key( $api_key = '' ) {
116
+	public function check_google_api_key($api_key = '') {
117 117
 
118 118
 		$message    = '';
119 119
 		$has_errors = false;
120 120
 
121
-		if ( empty( $api_key ) ){
121
+		if (empty($api_key)) {
122 122
 			$api_key = $this->google_api_key;
123
-			if ( empty( $api_key ) ) {
124
-				$settings = get_option( 'simple-calendar_settings_feeds' );
125
-				$api_key = isset( $settings['google']['api_key'] ) ? esc_attr( $settings['google']['api_key'] ) : '';
123
+			if (empty($api_key)) {
124
+				$settings = get_option('simple-calendar_settings_feeds');
125
+				$api_key = isset($settings['google']['api_key']) ? esc_attr($settings['google']['api_key']) : '';
126 126
 			}
127 127
 		}
128 128
 
129
-		$message = '<p class="description">' .
130
-				   sprintf( __( '<a href="%s" target="_blank">Step-by-step instructions</a> ', 'google-calendar-events' ),
131
-					   simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/google-api-key/', 'core-plugin', 'settings-link' )
132
-				   ) .
133
-				   '<br/>' .
134
-				   sprintf( __( '<a href="%s" target="_blank">Google Developers Console</a> ', 'google-calendar-events' ),
135
-					   simcal_get_url( 'gdev-console' )
136
-				   ) .
129
+		$message = '<p class="description">'.
130
+				   sprintf(__('<a href="%s" target="_blank">Step-by-step instructions</a> ', 'google-calendar-events'),
131
+					   simcal_ga_campaign_url(simcal_get_url('docs').'/google-api-key/', 'core-plugin', 'settings-link')
132
+				   ).
133
+				   '<br/>'.
134
+				   sprintf(__('<a href="%s" target="_blank">Google Developers Console</a> ', 'google-calendar-events'),
135
+					   simcal_get_url('gdev-console')
136
+				   ).
137 137
 				   '</p>';
138 138
 
139 139
 		return $message;
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return array
150 150
 	 */
151
-	public function add_settings_meta_tab_li( $tabs ) {
152
-		return array_merge( $tabs, array(
151
+	public function add_settings_meta_tab_li($tabs) {
152
+		return array_merge($tabs, array(
153 153
 			'google' => array(
154 154
 				'label'   => $this->feed->name,
155 155
 				'target'  => 'google-settings-panel',
156
-				'class'   => array( 'simcal-feed-type', 'simcal-feed-type-google' ),
156
+				'class'   => array('simcal-feed-type', 'simcal-feed-type-google'),
157 157
 				'icon'    => 'simcal-icon-google',
158 158
 			),
159
-		) );
159
+		));
160 160
 	}
161 161
 
162 162
 	/**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @param int $post_id
168 168
 	 */
169
-	public function add_settings_meta_panel( $post_id ) {
169
+	public function add_settings_meta_panel($post_id) {
170 170
 
171 171
 		$inputs = array(
172 172
 			$this->feed->type => array(
@@ -175,30 +175,30 @@  discard block
 block discarded – undo
175 175
 					'subtype'     => 'text',
176 176
 					'name'        => '_google_calendar_id',
177 177
 					'id'          => '_google_calendar_id',
178
-					'title'       => __( 'Calendar ID', 'google-calendar-events' ),
179
-					'tooltip'     => __( 'Visit your Google Calendar account, copy your public calendar ID, then paste it here.', 'google-calendar-events' ),
180
-					'placeholder' => __( 'Enter a valid Google Calendar ID from a public calendar', 'google-calendar-events' ),
181
-					'escaping'    => array( $this->feed, 'esc_google_calendar_id' ),
182
-					'validation'  => array( $this, 'test_api_key_connection' ),
178
+					'title'       => __('Calendar ID', 'google-calendar-events'),
179
+					'tooltip'     => __('Visit your Google Calendar account, copy your public calendar ID, then paste it here.', 'google-calendar-events'),
180
+					'placeholder' => __('Enter a valid Google Calendar ID from a public calendar', 'google-calendar-events'),
181
+					'escaping'    => array($this->feed, 'esc_google_calendar_id'),
182
+					'validation'  => array($this, 'test_api_key_connection'),
183 183
 				),
184 184
 				'_google_events_search_query' => array(
185 185
 					'type'        => 'standard',
186 186
 					'subtype'     => 'text',
187 187
 					'name'        => '_google_events_search_query',
188 188
 					'id'          => '_google_events_search_query',
189
-					'title'       => __( 'Search query', 'google-calendar-events' ),
190
-					'tooltip'     => __( 'Type in keywords if you only want display events that match these terms. You can use basic boolean search operators too.', 'google-calendar-events' ),
191
-					'placeholder' => __( 'Filter events to display by search terms...', 'google-calendar-events' ),
189
+					'title'       => __('Search query', 'google-calendar-events'),
190
+					'tooltip'     => __('Type in keywords if you only want display events that match these terms. You can use basic boolean search operators too.', 'google-calendar-events'),
191
+					'placeholder' => __('Filter events to display by search terms...', 'google-calendar-events'),
192 192
 				),
193 193
 				'_google_events_recurring' => array(
194 194
 					'type'    => 'select',
195 195
 					'name'    => '_google_events_recurring',
196 196
 					'id'      => '_google_events_recurring',
197
-					'title'   => __( 'Recurring events', 'google-calendar-events' ),
198
-					'tooltip' => __( 'Events that are programmed to repeat themselves periodically.', 'google-calendar-events' ),
197
+					'title'   => __('Recurring events', 'google-calendar-events'),
198
+					'tooltip' => __('Events that are programmed to repeat themselves periodically.', 'google-calendar-events'),
199 199
 					'options' => array(
200
-						'show' => __( 'Show all', 'google-calendar-events' ),
201
-						'first-only' => __( 'Only show first occurrence', 'google-calendar-events' ),
200
+						'show' => __('Show all', 'google-calendar-events'),
201
+						'first-only' => __('Only show first occurrence', 'google-calendar-events'),
202 202
 					),
203 203
 				),
204 204
 				'_google_events_max_results' => array(
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 					'subtype'     => 'number',
207 207
 					'name'        => '_google_events_max_results',
208 208
 					'id'          => '_google_events_max_results',
209
-					'title'       => __( 'Maximum Events', 'google-calendar-events' ),
210
-					'tooltip'     => __( 'Google Calendar only allows to query for a maximum amount of 2500 events from a calendar each time.', 'google-calendar-events' ),
209
+					'title'       => __('Maximum Events', 'google-calendar-events'),
210
+					'tooltip'     => __('Google Calendar only allows to query for a maximum amount of 2500 events from a calendar each time.', 'google-calendar-events'),
211 211
 					'class'       => array(
212 212
 						'simcal-field-small',
213 213
 					),
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 		<div id="google-settings-panel" class="simcal-panel">
225 225
 			<table>
226 226
 				<thead>
227
-					<tr><th colspan="2"><?php _e( 'Google Calendar settings', 'google-calendar-events' ); ?></th></tr>
227
+					<tr><th colspan="2"><?php _e('Google Calendar settings', 'google-calendar-events'); ?></th></tr>
228 228
 				</thead>
229
-				<?php Settings::print_panel_fields( $inputs, $post_id ); ?>
229
+				<?php Settings::print_panel_fields($inputs, $post_id); ?>
230 230
 			</table>
231 231
 		</div>
232 232
 		<?php
@@ -242,47 +242,47 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return true|string
244 244
 	 */
245
-	public function test_api_key_connection( $google_calendar_id ) {
245
+	public function test_api_key_connection($google_calendar_id) {
246 246
 
247 247
 		global $post;
248 248
 
249
-		$post_id = isset( $post->ID ) ? $post->ID : 0;
249
+		$post_id = isset($post->ID) ? $post->ID : 0;
250 250
 		$feed = null;
251
-		if ( $feed_type = wp_get_object_terms( $post_id, 'calendar_feed' ) ) {
252
-			$feed = sanitize_title( current( $feed_type )->name );
251
+		if ($feed_type = wp_get_object_terms($post_id, 'calendar_feed')) {
252
+			$feed = sanitize_title(current($feed_type)->name);
253 253
 		}
254 254
 
255 255
 		$message = '';
256 256
 		$error = '';
257 257
 		$has_errors = false;
258 258
 
259
-		$message .= '<p class="description">' .
259
+		$message .= '<p class="description">'.
260 260
 					sprintf(
261
-						__( 'Step 1: Set the Google Calendar you want to use as <strong>"public."</strong> <a href="%1s" target="_blank">Detailed instructions</a>', 'google-calendar-events' ) . '<br />' .
262
-						__( 'Step 2: Copy and paste your Google Calendar ID here. <a href="%2s" target="_blank">Detailed instructions</a>', 'google-calendar-events' ),
263
-						simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/make-google-calendar-public/', 'core-plugin', 'settings-link' ),
264
-						simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/find-google-calendar-id/', 'core-plugin', 'settings-link' )
265
-					) . '</p>';
261
+						__('Step 1: Set the Google Calendar you want to use as <strong>"public."</strong> <a href="%1s" target="_blank">Detailed instructions</a>', 'google-calendar-events').'<br />'.
262
+						__('Step 2: Copy and paste your Google Calendar ID here. <a href="%2s" target="_blank">Detailed instructions</a>', 'google-calendar-events'),
263
+						simcal_ga_campaign_url(simcal_get_url('docs').'/make-google-calendar-public/', 'core-plugin', 'settings-link'),
264
+						simcal_ga_campaign_url(simcal_get_url('docs').'/find-google-calendar-id/', 'core-plugin', 'settings-link')
265
+					).'</p>';
266 266
 
267
-		if ( $post_id > 0 && ! is_null( $feed ) && ! empty( $this->feed->type ) ) {
267
+		if ($post_id > 0 && ! is_null($feed) && ! empty($this->feed->type)) {
268 268
 
269
-			$no_key_notice = new Notice( array(
270
-					'id'          => array( 'calendar_' . $post_id => 'google-no-api-key' ),
269
+			$no_key_notice = new Notice(array(
270
+					'id'          => array('calendar_'.$post_id => 'google-no-api-key'),
271 271
 					'type'        => 'error',
272 272
 					'screen'      => 'calendar',
273 273
 					'post'        => $post_id,
274 274
 					'dismissable' => false,
275
-					'content'     => '<p>' .
276
-					                 '<i class="simcal-icon-warning"></i> ' .
275
+					'content'     => '<p>'.
276
+					                 '<i class="simcal-icon-warning"></i> '.
277 277
 					                 sprintf(
278
-						                 __( 'Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events' ),
279
-						                 admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds' )
280
-					                 ) .
278
+						                 __('Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events'),
279
+						                 admin_url('edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds')
280
+					                 ).
281 281
 					                 '</p>',
282 282
 				)
283 283
 			);
284 284
 
285
-			if ( empty( $this->google_api_key ) && ( $feed == $this->feed->type ) ) {
285
+			if (empty($this->google_api_key) && ($feed == $this->feed->type)) {
286 286
 
287 287
 				$has_errors = true;
288 288
 				$no_key_notice->add();
@@ -292,28 +292,28 @@  discard block
 block discarded – undo
292 292
 				$no_key_notice->remove();
293 293
 
294 294
 				try {
295
-					$this->feed->make_request( $google_calendar_id );
296
-				} catch ( \Exception $e ) {
295
+					$this->feed->make_request($google_calendar_id);
296
+				} catch (\Exception $e) {
297 297
 					$error   = $e->getMessage();
298
-					$message = ! empty( $error ) ? '<blockquote>' . $error . '</blockquote>' : '';
298
+					$message = ! empty($error) ? '<blockquote>'.$error.'</blockquote>' : '';
299 299
 				}
300 300
 
301
-				$error_notice = new Notice( array(
302
-						'id'          => array( 'calendar_' . $post_id => 'google-error-response' ),
301
+				$error_notice = new Notice(array(
302
+						'id'          => array('calendar_'.$post_id => 'google-error-response'),
303 303
 						'type'        => 'error',
304 304
 						'screen'      => 'calendar',
305 305
 						'post'        => $post_id,
306 306
 						'dismissable' => false,
307
-						'content'     => '<p>' .
308
-						                 '<i class="simcal-icon-warning"></i> ' .
309
-						                 __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' ) .
310
-						                 '<br>' . $message . '<br>' .
311
-						                 __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) .
307
+						'content'     => '<p>'.
308
+						                 '<i class="simcal-icon-warning"></i> '.
309
+						                 __('While trying to retrieve events, Google returned an error:', 'google-calendar-events').
310
+						                 '<br>'.$message.'<br>'.
311
+						                 __('Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events').
312 312
 						                 '</p>',
313 313
 					)
314 314
 				);
315 315
 
316
-				if ( ! empty( $error ) && ( $feed == $this->feed->type ) ) {
316
+				if ( ! empty($error) && ($feed == $this->feed->type)) {
317 317
 					$error_notice->add();
318 318
 					$has_errors = true;
319 319
 				} else {
@@ -335,21 +335,21 @@  discard block
 block discarded – undo
335 335
 	 *
336 336
 	 * @param int $post_id
337 337
 	 */
338
-	public function process_meta( $post_id ) {
338
+	public function process_meta($post_id) {
339 339
 
340
-		$calendar_id = isset( $_POST['_google_calendar_id'] ) ? base64_encode( trim( $_POST['_google_calendar_id'] ) ): '';
341
-		update_post_meta( $post_id, '_google_calendar_id', $calendar_id );
340
+		$calendar_id = isset($_POST['_google_calendar_id']) ? base64_encode(trim($_POST['_google_calendar_id'])) : '';
341
+		update_post_meta($post_id, '_google_calendar_id', $calendar_id);
342 342
 
343
-		$search_query = isset( $_POST['_google_events_search_query'] ) ? sanitize_text_field( $_POST['_google_events_search_query'] ) : '';
344
-		update_post_meta( $post_id, '_google_events_search_query', $search_query );
343
+		$search_query = isset($_POST['_google_events_search_query']) ? sanitize_text_field($_POST['_google_events_search_query']) : '';
344
+		update_post_meta($post_id, '_google_events_search_query', $search_query);
345 345
 
346
-		$recurring = isset( $_POST['_google_events_recurring'] ) ? sanitize_key( $_POST['_google_events_recurring'] ) : 'show';
347
-		update_post_meta( $post_id, '_google_events_recurring', $recurring );
346
+		$recurring = isset($_POST['_google_events_recurring']) ? sanitize_key($_POST['_google_events_recurring']) : 'show';
347
+		update_post_meta($post_id, '_google_events_recurring', $recurring);
348 348
 
349
-		$max_results = isset( $_POST['_google_events_max_results'] ) ? absint( $_POST['_google_events_max_results'] ) : '2500';
350
-		update_post_meta( $post_id, '_google_events_max_results', $max_results );
349
+		$max_results = isset($_POST['_google_events_max_results']) ? absint($_POST['_google_events_max_results']) : '2500';
350
+		update_post_meta($post_id, '_google_events_max_results', $max_results);
351 351
 
352
-		$this->test_api_key_connection( $calendar_id );
352
+		$this->test_api_key_connection($calendar_id);
353 353
 	}
354 354
 
355 355
 }
Please login to merge, or discard this patch.
includes/feeds/google.php 1 patch
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 use SimpleCalendar\Abstracts\Feed;
13 13
 use SimpleCalendar\Feeds\Admin\Google_Admin as Admin;
14 14
 
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -90,34 +90,34 @@  discard block
 block discarded – undo
90 90
 	 * @param string|Calendar $calendar
91 91
 	 * @param bool $load_admin
92 92
 	 */
93
-	public function __construct( $calendar = '', $load_admin = true ) {
93
+	public function __construct($calendar = '', $load_admin = true) {
94 94
 
95
-		parent::__construct( $calendar );
95
+		parent::__construct($calendar);
96 96
 
97 97
 		$this->type = 'google';
98
-		$this->name = __( 'Google Calendar', 'google-calendar-events' );
98
+		$this->name = __('Google Calendar', 'google-calendar-events');
99 99
 
100 100
 		// Google client config.
101
-		$settings = get_option( 'simple-calendar_settings_feeds' );
102
-		$this->google_api_key = isset( $settings['google']['api_key'] ) ? esc_attr( $settings['google']['api_key'] ) : '';
103
-		$this->google_client_scopes = array( \Google_Service_Calendar::CALENDAR_READONLY );
101
+		$settings = get_option('simple-calendar_settings_feeds');
102
+		$this->google_api_key = isset($settings['google']['api_key']) ? esc_attr($settings['google']['api_key']) : '';
103
+		$this->google_client_scopes = array(\Google_Service_Calendar::CALENDAR_READONLY);
104 104
 		$this->google_client = $this->get_client();
105 105
 
106
-		if ( $this->post_id > 0 ) {
106
+		if ($this->post_id > 0) {
107 107
 
108 108
 			// Google query args.
109
-			$this->google_calendar_id       = $this->esc_google_calendar_id( get_post_meta( $this->post_id, '_google_calendar_id', true ) );
110
-			$this->google_events_recurring  = esc_attr( get_post_meta( $this->post_id, '_google_events_recurring', true ) );
111
-			$this->google_search_query      = esc_attr( get_post_meta( $this->post_id, '_google_events_search_query', true ) );
112
-			$this->google_max_results       = max( absint( get_post_meta( $this->post_id, '_google_events_max_results', true ) ), 1 );
109
+			$this->google_calendar_id       = $this->esc_google_calendar_id(get_post_meta($this->post_id, '_google_calendar_id', true));
110
+			$this->google_events_recurring  = esc_attr(get_post_meta($this->post_id, '_google_events_recurring', true));
111
+			$this->google_search_query      = esc_attr(get_post_meta($this->post_id, '_google_events_search_query', true));
112
+			$this->google_max_results       = max(absint(get_post_meta($this->post_id, '_google_events_max_results', true)), 1);
113 113
 
114
-			if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
115
-				$this->events = ! empty( $this->google_api_key ) ? $this->get_events() : array();
114
+			if ( ! is_admin() || defined('DOING_AJAX')) {
115
+				$this->events = ! empty($this->google_api_key) ? $this->get_events() : array();
116 116
 			}
117 117
 		}
118 118
 
119
-		if ( is_admin() && $load_admin ) {
120
-			$admin = new Admin( $this, $this->google_api_key, $this->google_calendar_id );
119
+		if (is_admin() && $load_admin) {
120
+			$admin = new Admin($this, $this->google_api_key, $this->google_calendar_id);
121 121
 			$this->settings = $admin->settings_fields();
122 122
 		}
123 123
 	}
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return string
133 133
 	 */
134
-	public function esc_google_calendar_id( $id ) {
135
-		return base64_decode( $id );
134
+	public function esc_google_calendar_id($id) {
135
+		return base64_decode($id);
136 136
 	}
137 137
 
138 138
 	/**
@@ -146,59 +146,59 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public function get_events() {
148 148
 
149
-		$calendar = get_transient( '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type );
149
+		$calendar = get_transient('_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type);
150 150
 
151
-		if ( empty( $calendar ) && ! empty( $this->google_calendar_id ) ) {
151
+		if (empty($calendar) && ! empty($this->google_calendar_id)) {
152 152
 
153 153
 			$error = '';
154 154
 
155 155
 			try {
156
-				$response = $this->make_request( $this->google_calendar_id );
157
-			} catch ( \Exception $e ) {
156
+				$response = $this->make_request($this->google_calendar_id);
157
+			} catch (\Exception $e) {
158 158
 				$error .= $e->getMessage();
159 159
 			}
160 160
 
161
-			if ( empty( $error ) && isset( $response['events'] ) && isset( $response['timezone'] ) ) {
161
+			if (empty($error) && isset($response['events']) && isset($response['timezone'])) {
162 162
 
163
-				$calendar = array_merge( $response, array( 'events' => array() ) );
163
+				$calendar = array_merge($response, array('events' => array()));
164 164
 
165 165
 				// If no timezone has been set, use calendar feed.
166
-				if ( 'use_calendar' == $this->timezone_setting ) {
166
+				if ('use_calendar' == $this->timezone_setting) {
167 167
 					$this->timezone = $calendar['timezone'];
168 168
 				}
169 169
 
170
-				$source = isset( $response['title'] ) ? sanitize_text_field( $response['title'] ) : '';
170
+				$source = isset($response['title']) ? sanitize_text_field($response['title']) : '';
171 171
 
172
-				if ( ! empty( $response['events'] ) && is_array( $response['events'] ) ) {
173
-					foreach ( $response['events'] as $event ) {
174
-						if ( $event instanceof \Google_Service_Calendar_Event ) {
172
+				if ( ! empty($response['events']) && is_array($response['events'])) {
173
+					foreach ($response['events'] as $event) {
174
+						if ($event instanceof \Google_Service_Calendar_Event) {
175 175
 
176 176
 							// Visibility.
177 177
 							$visibility = $event->getVisibility();
178 178
 							// Public calendars may have private events which can't be properly accessed by simple api key method.
179
-							if ( $this->type == 'google' && ( $visibility == 'private' || $visibility == 'confidential' ) ) {
179
+							if ($this->type == 'google' && ($visibility == 'private' || $visibility == 'confidential')) {
180 180
 								continue;
181 181
 							}
182 182
 
183 183
 							// Event title & description.
184
-							$title = strip_tags( $event->getSummary() );
185
-							$title = sanitize_text_field( iconv( mb_detect_encoding( $title, mb_detect_order(), true ), 'UTF-8', $title ) );
186
-							$description = wp_kses_post( iconv( mb_detect_encoding( $event->getDescription(), mb_detect_order(), true ), 'UTF-8', $event->getDescription() ) );
184
+							$title = strip_tags($event->getSummary());
185
+							$title = sanitize_text_field(iconv(mb_detect_encoding($title, mb_detect_order(), true), 'UTF-8', $title));
186
+							$description = wp_kses_post(iconv(mb_detect_encoding($event->getDescription(), mb_detect_order(), true), 'UTF-8', $event->getDescription()));
187 187
 
188 188
 							$whole_day = false;
189 189
 
190 190
 							// Event start properties.
191 191
 							$start_timezone = ! $event->getStart()->timeZone ? $calendar['timezone'] : $event->getStart()->timeZone;
192
-							if ( is_null( $event->getStart()->dateTime ) ) {
192
+							if (is_null($event->getStart()->dateTime)) {
193 193
 								// Whole day event.
194
-								$date = Carbon::parse( $event->getStart()->date );
195
-								$google_start = Carbon::createFromDate( $date->year, $date->month, $date->day, $start_timezone )->startOfDay()->addSeconds( 59 );
196
-								$google_start_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->addSeconds( 59 );
194
+								$date = Carbon::parse($event->getStart()->date);
195
+								$google_start = Carbon::createFromDate($date->year, $date->month, $date->day, $start_timezone)->startOfDay()->addSeconds(59);
196
+								$google_start_utc = Carbon::createFromDate($date->year, $date->month, $date->day, 'UTC')->startOfDay()->addSeconds(59);
197 197
 								$whole_day = true;
198 198
 							} else {
199
-								$date = Carbon::parse( $event->getStart()->dateTime );
200
-								$google_start     = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $start_timezone );
201
-								$google_start_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' );
199
+								$date = Carbon::parse($event->getStart()->dateTime);
200
+								$google_start     = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $start_timezone);
201
+								$google_start_utc = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC');
202 202
 							}
203 203
 							// Start.
204 204
 							$start = $google_start->getTimestamp();
@@ -207,19 +207,19 @@  discard block
 block discarded – undo
207 207
 
208 208
 							$end = $end_utc = $end_timezone = '';
209 209
 							$span = 0;
210
-							if ( false == $event->getEndTimeUnspecified() ) {
210
+							if (false == $event->getEndTimeUnspecified()) {
211 211
 
212 212
 								// Event end properties.
213 213
 								$end_timezone = ! $event->getEnd()->timeZone ? $calendar['timezone'] : $event->getEnd()->timeZone;
214
-								if ( is_null( $event->getEnd()->dateTime ) ) {
214
+								if (is_null($event->getEnd()->dateTime)) {
215 215
 									// Whole day event.
216
-									$date           = Carbon::parse( $event->getEnd()->date );
217
-									$google_end     = Carbon::createFromDate( $date->year, $date->month, $date->day, $end_timezone )->startOfDay()->subSeconds( 59 );
218
-									$google_end_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->subSeconds( 59 );
216
+									$date           = Carbon::parse($event->getEnd()->date);
217
+									$google_end     = Carbon::createFromDate($date->year, $date->month, $date->day, $end_timezone)->startOfDay()->subSeconds(59);
218
+									$google_end_utc = Carbon::createFromDate($date->year, $date->month, $date->day, 'UTC')->startOfDay()->subSeconds(59);
219 219
 								} else {
220
-									$date           = Carbon::parse( $event->getEnd()->dateTime );
221
-									$google_end     = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $end_timezone );
222
-									$google_end_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' );
220
+									$date           = Carbon::parse($event->getEnd()->dateTime);
221
+									$google_end     = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $end_timezone);
222
+									$google_end_utc = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC');
223 223
 								}
224 224
 								// End.
225 225
 								$end = $google_end->getTimestamp();
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
 								$end_utc = $google_end_utc->getTimestamp();
228 228
 
229 229
 								// Count multiple days.
230
-								$span = $google_start->setTimezone( $calendar['timezone'] )->diffInDays( $google_end->setTimezone( $calendar['timezone'] ) );
230
+								$span = $google_start->setTimezone($calendar['timezone'])->diffInDays($google_end->setTimezone($calendar['timezone']));
231 231
 
232
-								if ( $span == 0 ) {
233
-									if ( $google_start->toDateString() !== $google_end->toDateString() ) {
232
+								if ($span == 0) {
233
+									if ($google_start->toDateString() !== $google_end->toDateString()) {
234 234
 										$span = 1;
235 235
 									}
236 236
 								}
@@ -245,19 +245,19 @@  discard block
 block discarded – undo
245 245
 							// Recurring event.
246 246
 							$recurrence = $event->getRecurrence();
247 247
 							$recurring_id = $event->getRecurringEventId();
248
-							if ( ! $recurrence && $recurring_id ) {
248
+							if ( ! $recurrence && $recurring_id) {
249 249
 								$recurrence = true;
250 250
 							}
251 251
 
252 252
 							// Event link.
253
-							if ( 'use_calendar' == $this->timezone_setting ) {
254
-								$link = add_query_arg( array( 'ctz' => $this->timezone ), $event->getHtmlLink() );
253
+							if ('use_calendar' == $this->timezone_setting) {
254
+								$link = add_query_arg(array('ctz' => $this->timezone), $event->getHtmlLink());
255 255
 							} else {
256 256
 								$link = $event->getHtmlLink();
257 257
 							}
258 258
 
259 259
 							// Build the event.
260
-							$calendar['events'][ intval( $start ) ][] = array(
260
+							$calendar['events'][intval($start)][] = array(
261 261
 								'type'           => 'google-calendar',
262 262
 								'source'         => $source,
263 263
 								'title'          => $title,
@@ -284,24 +284,24 @@  discard block
 block discarded – undo
284 284
 						}
285 285
 					}
286 286
 
287
-					if ( ! empty( $calendar['events'] ) ) {
287
+					if ( ! empty($calendar['events'])) {
288 288
 
289
-						ksort( $calendar['events'], SORT_NUMERIC );
289
+						ksort($calendar['events'], SORT_NUMERIC);
290 290
 
291 291
 						set_transient(
292
-							'_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type,
292
+							'_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type,
293 293
 							$calendar,
294
-							max( absint( $this->cache ), 60 )
294
+							max(absint($this->cache), 60)
295 295
 						);
296 296
 					}
297 297
 				}
298 298
 
299 299
 			} else {
300 300
 
301
-				$message  = __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' );
302
-				$message .= '<br><br>' . $error . '<br><br>';
303
-				$message .= __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) . '<br><br>';
304
-				$message .= __( 'Only you can see this notice.', 'google-calendar-events' );
301
+				$message  = __('While trying to retrieve events, Google returned an error:', 'google-calendar-events');
302
+				$message .= '<br><br>'.$error.'<br><br>';
303
+				$message .= __('Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events').'<br><br>';
304
+				$message .= __('Only you can see this notice.', 'google-calendar-events');
305 305
 
306 306
 				return $message;
307 307
 			}
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
 		}
310 310
 
311 311
 		// If no timezone has been set, use calendar feed.
312
-		if ( 'use_calendar' == $this->timezone_setting && isset( $calendar['timezone'] ) ) {
312
+		if ('use_calendar' == $this->timezone_setting && isset($calendar['timezone'])) {
313 313
 			$this->timezone = $calendar['timezone'];
314 314
 		}
315 315
 
316
-		return isset( $calendar['events'] ) ? $calendar['events'] : array();
316
+		return isset($calendar['events']) ? $calendar['events'] : array();
317 317
 	}
318 318
 
319 319
 	/**
@@ -329,67 +329,67 @@  discard block
 block discarded – undo
329 329
 	 *
330 330
 	 * @throws \Exception On request failure will throw an exception from Google.
331 331
 	 */
332
-	public function make_request( $id = '', $time_min = 0, $time_max = 0 ) {
332
+	public function make_request($id = '', $time_min = 0, $time_max = 0) {
333 333
 
334 334
 		$calendar = array();
335 335
 		$google = $this->get_service();
336 336
 
337
-		if ( ! is_null( $google ) && ! empty( $id ) ) {
337
+		if ( ! is_null($google) && ! empty($id)) {
338 338
 
339 339
 			// Build the request args.
340 340
 			$args = array();
341 341
 
342 342
 			// Expand recurring events.
343
-			if ( $this->google_events_recurring == 'show' ) {
343
+			if ($this->google_events_recurring == 'show') {
344 344
 				$args['singleEvents'] = true;
345 345
 			}
346 346
 
347 347
 			// Query events using search terms.
348
-			if ( ! empty( $this->google_search_query ) ) {
349
-				$args['q'] = rawurlencode( $this->google_search_query );
348
+			if ( ! empty($this->google_search_query)) {
349
+				$args['q'] = rawurlencode($this->google_search_query);
350 350
 			}
351 351
 
352 352
 			// Max results to query.
353
-			$args['maxResults'] = strval( min( absint( $this->google_max_results ), 2500 ) );
353
+			$args['maxResults'] = strval(min(absint($this->google_max_results), 2500));
354 354
 
355 355
 			// Specify a timezone.
356 356
 			$timezone = '';
357
-			if ( 'use_calendar' != get_post_meta( $this->post_id, '_feed_timezone_setting', true ) ) {
357
+			if ('use_calendar' != get_post_meta($this->post_id, '_feed_timezone_setting', true)) {
358 358
 				$args['timeZone'] = $timezone = $this->timezone;
359 359
 			}
360 360
 
361 361
 			// Lower bound (inclusive) for an event's end time to filter by.
362
-			$earliest_event = intval( $this->time_min );
363
-			if ( $earliest_event > 0 ) {
362
+			$earliest_event = intval($this->time_min);
363
+			if ($earliest_event > 0) {
364 364
 				$timeMin = Carbon::now();
365
-				if ( ! empty( $timezone ) ) {
366
-					$timeMin->setTimezone( $timezone );
365
+				if ( ! empty($timezone)) {
366
+					$timeMin->setTimezone($timezone);
367 367
 				}
368
-				$timeMin->setTimestamp( $earliest_event );
368
+				$timeMin->setTimestamp($earliest_event);
369 369
 				$args['timeMin'] = $timeMin->toRfc3339String();
370 370
 			}
371 371
 
372 372
 			// Upper bound (exclusive) for an event's start time to filter by.
373
-			$latest_event = intval( $this->time_max );
374
-			if ( $latest_event > 0 ) {
373
+			$latest_event = intval($this->time_max);
374
+			if ($latest_event > 0) {
375 375
 				$timeMax = Carbon::now();
376
-				if ( ! empty( $timezone ) ) {
377
-					$timeMax->setTimezone( $timezone );
376
+				if ( ! empty($timezone)) {
377
+					$timeMax->setTimezone($timezone);
378 378
 				}
379
-				$timeMax->setTimestamp( $latest_event );
379
+				$timeMax->setTimestamp($latest_event);
380 380
 				$args['timeMax'] = $timeMax->toRfc3339String();
381 381
 			}
382 382
 
383 383
 			// Query events in calendar.
384
-			$response = $google->events->listEvents( $id, $args );
384
+			$response = $google->events->listEvents($id, $args);
385 385
 
386
-			if ( $response instanceof \Google_Service_Calendar_Events ) {
386
+			if ($response instanceof \Google_Service_Calendar_Events) {
387 387
 				$calendar = array(
388 388
 					'id'            => $id,
389 389
 					'title'         => $response->getSummary(),
390 390
 					'description'   => $response->getDescription(),
391 391
 					'timezone'      => $response->getTimeZone(),
392
-					'url'           => esc_url( '//www.google.com/calendar/embed?src=' . $id ),
392
+					'url'           => esc_url('//www.google.com/calendar/embed?src='.$id),
393 393
 					'events'        => $response->getItems(),
394 394
 				);
395 395
 			}
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
 	private function get_client() {
410 410
 
411 411
 		$client = new \Google_Client();
412
-		$client->setApplicationName( 'Simple Calendar' );
413
-		$client->setScopes( $this->google_client_scopes );
414
-		$client->setDeveloperKey( $this->google_api_key );
415
-		$client->setAccessType( 'online' );
412
+		$client->setApplicationName('Simple Calendar');
413
+		$client->setScopes($this->google_client_scopes);
414
+		$client->setDeveloperKey($this->google_api_key);
415
+		$client->setAccessType('online');
416 416
 
417 417
 		return $client;
418 418
 	}
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	 * @return null|\Google_Service_Calendar
427 427
 	 */
428 428
 	protected function get_service() {
429
-		return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar( $this->google_client ) : null;
429
+		return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar($this->google_client) : null;
430 430
 	}
431 431
 
432 432
 }
Please login to merge, or discard this patch.