Completed
Push — master ( d1a272...91e5db )
by
unknown
04:07
created
includes/calendars/views/default-calendar-list.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -576,9 +576,11 @@
 block discarded – undo
576 576
 
577 577
 			endforeach;
578 578
 
579
-		else :
579
+		else {
580
+			:
580 581
 
581 582
 			echo "\t" . '<p>';
583
+		}
582 584
 
583 585
 			$message = get_post_meta( $calendar->id, '_no_events_message', true );
584 586
 
Please login to merge, or discard this patch.
Spacing   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use SimpleCalendar\Calendars\Default_Calendar;
14 14
 use SimpleCalendar\Events\Event;
15 15
 
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @param string|Calendar $calendar
73 73
 	 */
74
-	public function __construct( $calendar = '' ) {
74
+	public function __construct($calendar = '') {
75 75
 		$this->calendar = $calendar;
76 76
 	}
77 77
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @return string
106 106
 	 */
107 107
 	public function get_name() {
108
-		return __( 'List', 'google-calendar-events' );
108
+		return __('List', 'google-calendar-events');
109 109
 	}
110 110
 
111 111
 	/**
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * @since 3.0.0
115 115
 	 */
116 116
 	public function add_ajax_actions() {
117
-		add_action( 'wp_ajax_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) );
118
-		add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) );
117
+		add_action('wp_ajax_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax'));
118
+		add_action('wp_ajax_nopriv_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax'));
119 119
 	}
120 120
 
121 121
 	/**
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return array
131 131
 	 */
132
-	public function scripts( $min = '' ) {
132
+	public function scripts($min = '') {
133 133
 		return array(
134 134
 			'simcal-qtip' => array(
135
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js',
136
-				'deps'      => array( 'jquery' ),
135
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js',
136
+				'deps'      => array('jquery'),
137 137
 				'ver'       => '2.2.1',
138 138
 				'in_footer' => true,
139 139
 			),
140 140
 			'simcal-default-calendar' => array(
141
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js',
141
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js',
142 142
 				'deps'      => array(
143 143
 					'jquery',
144 144
 					'simcal-qtip',
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @return array
165 165
 	 */
166
-	public function styles( $min = '' ) {
166
+	public function styles($min = '') {
167 167
 		return array(
168 168
 			'simcal-default-calendar-list' => array(
169
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $min . '.css',
169
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$min.'.css',
170 170
 				'ver'   => SIMPLE_CALENDAR_VERSION,
171 171
 				'media' => 'all',
172 172
 			),
@@ -182,47 +182,47 @@  discard block
 block discarded – undo
182 182
 
183 183
 		$calendar = $this->calendar;
184 184
 
185
-		if ( $calendar instanceof Default_Calendar ) {
185
+		if ($calendar instanceof Default_Calendar) {
186 186
 
187 187
 			$disabled = $calendar->static === true ? ' disabled="disabled"' : '';
188 188
 
189 189
 
190
-			$hide_header = get_post_meta( $this->calendar->id, '_default_calendar_list_header', true ) == 'yes' ? true : false;
191
-			$static_calendar = get_post_meta( $this->calendar->id, '_calendar_is_static', true ) == 'yes' ? true : false;
190
+			$hide_header = get_post_meta($this->calendar->id, '_default_calendar_list_header', true) == 'yes' ? true : false;
191
+			$static_calendar = get_post_meta($this->calendar->id, '_calendar_is_static', true) == 'yes' ? true : false;
192 192
 
193 193
 			$header_class = '';
194 194
 			$compact_list_class = $calendar->compact_list ? 'simcal-calendar-list-compact' : '';
195 195
 
196
-			echo '<div class="simcal-calendar-list ' . $compact_list_class . '">';
196
+			echo '<div class="simcal-calendar-list '.$compact_list_class.'">';
197 197
 
198
-			if ( ! $hide_header && ! $static_calendar ) {
199
-				echo '<nav class="simcal-calendar-head">' . "\n";
198
+			if ( ! $hide_header && ! $static_calendar) {
199
+				echo '<nav class="simcal-calendar-head">'."\n";
200 200
 
201
-				echo "\t" . '<div class="simcal-nav">' . "\n";
202
-				echo "\t\t" . '<button class="simcal-nav-button simcal-prev" title="' . __('Previous', 'google-calendar-events') . '"' . $disabled . '>' . "\n";
203
-				echo "\t\t\t" . '<i class="simcal-icon-left"></i>' . "\n";
204
-				echo "\t\t" . '</button>' . "\n";
205
-				echo "\t" . '</div>' . "\n";
201
+				echo "\t".'<div class="simcal-nav">'."\n";
202
+				echo "\t\t".'<button class="simcal-nav-button simcal-prev" title="'.__('Previous', 'google-calendar-events').'"'.$disabled.'>'."\n";
203
+				echo "\t\t\t".'<i class="simcal-icon-left"></i>'."\n";
204
+				echo "\t\t".'</button>'."\n";
205
+				echo "\t".'</div>'."\n";
206 206
 
207
-				if ( $hide_header ) {
207
+				if ($hide_header) {
208 208
 					$header_class = 'simcal-hide-header';
209 209
 				}
210 210
 
211 211
 
212
-				echo "\t" . '<div class="simcal-nav simcal-current ' . $header_class . '" data-calendar-current="' . $calendar->start . '">' . "\n";
213
-				echo "\t\t" . '<h3 class="simcal-current-label"> </h3>' . "\n";
214
-				echo "\t" . '</div>' . "\n";
212
+				echo "\t".'<div class="simcal-nav simcal-current '.$header_class.'" data-calendar-current="'.$calendar->start.'">'."\n";
213
+				echo "\t\t".'<h3 class="simcal-current-label"> </h3>'."\n";
214
+				echo "\t".'</div>'."\n";
215 215
 
216
-				echo "\t" . '<div class="simcal-nav">';
217
-				echo "\t\t" . '<button class="simcal-nav-button simcal-next" title="' . __('Next', 'google-calendar-events') . '"' . $disabled . '>';
218
-				echo "\t\t\t" . '<i class="simcal-icon-right"></i>' . "\n";
219
-				echo "\t\t" . '</button>' . "\n";
220
-				echo "\t" . '</div>' . "\n";
216
+				echo "\t".'<div class="simcal-nav">';
217
+				echo "\t\t".'<button class="simcal-nav-button simcal-next" title="'.__('Next', 'google-calendar-events').'"'.$disabled.'>';
218
+				echo "\t\t\t".'<i class="simcal-icon-right"></i>'."\n";
219
+				echo "\t\t".'</button>'."\n";
220
+				echo "\t".'</div>'."\n";
221 221
 
222
-				echo '</nav>' . "\n";
222
+				echo '</nav>'."\n";
223 223
 			}
224 224
 
225
-			echo $this->draw_list( $calendar->start );
225
+			echo $this->draw_list($calendar->start);
226 226
 
227 227
 			echo '<div class="simcal-ajax-loader simcal-spinner-top" style="display: none;"><i class="simcal-icon-spinner simcal-icon-spin"></i></div>';
228 228
 
@@ -241,92 +241,92 @@  discard block
 block discarded – undo
241 241
 	 *
242 242
 	 * @return array
243 243
 	 */
244
-	private function get_events( $timestamp ) {
244
+	private function get_events($timestamp) {
245 245
 
246 246
 		$calendar = $this->calendar;
247 247
 		$timezone = $calendar->timezone;
248 248
 
249
-		if ( ! $calendar->group_type || ! $calendar->group_span ) {
249
+		if ( ! $calendar->group_type || ! $calendar->group_span) {
250 250
 			return array();
251 251
 		}
252 252
 
253
-		$current = Carbon::createFromTimestamp( $timestamp, $timezone );
253
+		$current = Carbon::createFromTimestamp($timestamp, $timezone);
254 254
 		$prev = clone $current;
255 255
 		$next = clone $current;
256 256
 
257 257
 		$this->start = $current->getTimestamp();
258 258
 
259
-		$interval = $span = max( absint( $calendar->group_span ), 1 );
260
-
261
-		if ( 'monthly' == $calendar->group_type ) {
262
-			$this->prev = $prev->subMonths( $span )->getTimestamp();
263
-			$this->next = $next->addMonths( $span )->getTimestamp();
264
-		} elseif ( 'weekly' == $calendar->group_type ) {
265
-			$week = new Carbon( $calendar->timezone );
266
-			$week->setTimestamp( $timestamp );
267
-			$week->setWeekStartsAt( $calendar->week_starts );
268
-			$this->prev = $prev->subWeeks( $span )->getTimestamp();
269
-			$this->next = $next->addWeeks( $span )->getTimestamp();
270
-		} elseif ( 'daily' == $calendar->group_type ) {
271
-			$this->prev = $prev->subDays( $span )->getTimestamp();
272
-			$this->next = $next->addDays( $span )->getTimestamp();
259
+		$interval = $span = max(absint($calendar->group_span), 1);
260
+
261
+		if ('monthly' == $calendar->group_type) {
262
+			$this->prev = $prev->subMonths($span)->getTimestamp();
263
+			$this->next = $next->addMonths($span)->getTimestamp();
264
+		} elseif ('weekly' == $calendar->group_type) {
265
+			$week = new Carbon($calendar->timezone);
266
+			$week->setTimestamp($timestamp);
267
+			$week->setWeekStartsAt($calendar->week_starts);
268
+			$this->prev = $prev->subWeeks($span)->getTimestamp();
269
+			$this->next = $next->addWeeks($span)->getTimestamp();
270
+		} elseif ('daily' == $calendar->group_type) {
271
+			$this->prev = $prev->subDays($span)->getTimestamp();
272
+			$this->next = $next->addDays($span)->getTimestamp();
273 273
 		}
274 274
 
275 275
 		$events = $calendar->events;
276 276
 		$daily_events = $paged_events = $flattened_events = array();
277 277
 
278
-		if ( 'events' != $calendar->group_type ) {
278
+		if ('events' != $calendar->group_type) {
279 279
 
280
-			$this->end   = $this->next - 1;
280
+			$this->end = $this->next - 1;
281 281
 
282
-			$timestamps   = array_keys( $events );
283
-			$lower_bound  = array_filter( $timestamps,  array( $this, 'filter_events_before' ) );
284
-			$higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after'  ) );
282
+			$timestamps   = array_keys($events);
283
+			$lower_bound  = array_filter($timestamps, array($this, 'filter_events_before'));
284
+			$higher_bound = array_filter($lower_bound, array($this, 'filter_events_after'));
285 285
 
286
-			if ( is_array( $higher_bound ) && !empty( $higher_bound ) ) {
287
-				$filtered = array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) );
288
-				foreach ( $filtered as $timestamp => $events ) {
289
-					$paged_events[ intval( $timestamp ) ] = $events;
286
+			if (is_array($higher_bound) && ! empty($higher_bound)) {
287
+				$filtered = array_intersect_key($events, array_combine($higher_bound, $higher_bound));
288
+				foreach ($filtered as $timestamp => $events) {
289
+					$paged_events[intval($timestamp)] = $events;
290 290
 				}
291 291
 			}
292 292
 
293 293
 		} else {
294 294
 
295
-			foreach ( $events as $timestamp => $e ) {
295
+			foreach ($events as $timestamp => $e) {
296 296
 				$second = 0;
297
-				foreach ( $e as $event ) {
298
-					$flattened_events[ intval( $timestamp + $second ) ][] = $event;
297
+				foreach ($e as $event) {
298
+					$flattened_events[intval($timestamp + $second)][] = $event;
299 299
 					$second++;
300 300
 				}
301 301
 			}
302
-			ksort( $flattened_events, SORT_NUMERIC );
302
+			ksort($flattened_events, SORT_NUMERIC);
303 303
 
304
-			$keys  = array_keys( $flattened_events );
304
+			$keys = array_keys($flattened_events);
305 305
 			$current = 0;
306
-			foreach ( $keys as $timestamp ) {
307
-				if ( $timestamp <= $this->start ) {
306
+			foreach ($keys as $timestamp) {
307
+				if ($timestamp <= $this->start) {
308 308
 					$current++;
309 309
 				}
310 310
 			}
311 311
 
312
-			$paged_events = array_slice( $flattened_events, $current, $interval, true );
312
+			$paged_events = array_slice($flattened_events, $current, $interval, true);
313 313
 
314
-			$events_end = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $calendar->end;
314
+			$events_end = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $calendar->end;
315 315
 			$this->end  = $events_end > $calendar->end ? $calendar->end : $events_end;
316 316
 			// -1 adjusts the interval count to index count, which starts at 0.
317
-			$this->prev = isset( $keys[ $current - $interval - 1 ] ) ? $keys[ $current - $interval - 1 ] : $calendar->earliest_event;
318
-			$this->next = isset( $keys[ $current + $interval - 1 ] ) ? $keys[ $current + $interval - 1 ] : $this->end;
317
+			$this->prev = isset($keys[$current - $interval - 1]) ? $keys[$current - $interval - 1] : $calendar->earliest_event;
318
+			$this->next = isset($keys[$current + $interval - 1]) ? $keys[$current + $interval - 1] : $this->end;
319 319
 
320 320
 		}
321 321
 
322 322
 		// Put resulting events in an associative array, with Ymd date as key for easy retrieval in calendar days loop.
323
-		foreach ( $paged_events as $timestamp => $events ) {
324
-			if ( $timestamp <= $this->end ) {
325
-				$date = Carbon::createFromTimestamp( $timestamp, $calendar->timezone )->endOfDay()->format( 'Ymd' );
326
-				$daily_events[ intval( $date ) ][] = $events;
323
+		foreach ($paged_events as $timestamp => $events) {
324
+			if ($timestamp <= $this->end) {
325
+				$date = Carbon::createFromTimestamp($timestamp, $calendar->timezone)->endOfDay()->format('Ymd');
326
+				$daily_events[intval($date)][] = $events;
327 327
 			}
328 328
 		}
329
-		ksort( $daily_events, SORT_NUMERIC );
329
+		ksort($daily_events, SORT_NUMERIC);
330 330
 
331 331
 		return $daily_events;
332 332
 	}
@@ -344,71 +344,71 @@  discard block
 block discarded – undo
344 344
 	private function get_heading() {
345 345
 
346 346
 		$calendar = $this->calendar;
347
-		$start = Carbon::createFromTimestamp( $this->start, $calendar->timezone );
348
-		$end = Carbon::createFromTimestamp( $this->end, $calendar->timezone );
347
+		$start = Carbon::createFromTimestamp($this->start, $calendar->timezone);
348
+		$end = Carbon::createFromTimestamp($this->end, $calendar->timezone);
349 349
 		$date_format = $this->calendar->date_format;
350
-		$date_order  = simcal_get_date_format_order( $date_format );
350
+		$date_order  = simcal_get_date_format_order($date_format);
351 351
 
352
-		if ( ( $start->day == $end->day ) && ( $start->month == $end->month ) && ( $start->year == $end->year ) ) {
352
+		if (($start->day == $end->day) && ($start->month == $end->month) && ($start->year == $end->year)) {
353 353
 			// Start and end on the same day.
354 354
 			// e.g. 1 February 2020
355
-			$large = $small = date_i18n( $calendar->date_format , $this->start );
356
-			if ( ( $date_order['d'] !== false ) && ( $date_order['m'] !== false ) ) {
357
-				if ( $date_order['m'] > $date_order['d'] ) {
358
-					if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) {
359
-						$small = date_i18n( 'Y, d M', $this->start );
355
+			$large = $small = date_i18n($calendar->date_format, $this->start);
356
+			if (($date_order['d'] !== false) && ($date_order['m'] !== false)) {
357
+				if ($date_order['m'] > $date_order['d']) {
358
+					if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) {
359
+						$small = date_i18n('Y, d M', $this->start);
360 360
 					} else {
361
-						$small = date_i18n( 'd M Y', $this->start );
361
+						$small = date_i18n('d M Y', $this->start);
362 362
 					}
363 363
 				} else {
364
-					if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) {
365
-						$small = date_i18n( 'Y, M d', $this->start );
364
+					if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) {
365
+						$small = date_i18n('Y, M d', $this->start);
366 366
 					} else {
367
-						$small = date_i18n( 'M d Y', $this->start );
367
+						$small = date_i18n('M d Y', $this->start);
368 368
 					}
369 369
 				}
370 370
 			}
371
-		} elseif ( ( $start->month == $end->month ) && ( $start->year == $end->year ) ) {
371
+		} elseif (($start->month == $end->month) && ($start->year == $end->year)) {
372 372
 			// Start and end days on the same month.
373 373
 			// e.g. August 2020
374
-			if ( $date_order['y'] === false ) {
374
+			if ($date_order['y'] === false) {
375 375
 				// August.
376
-				$large = $small = date_i18n( 'F', $this->start );
376
+				$large = $small = date_i18n('F', $this->start);
377 377
 			} else {
378
-				if ( $date_order['y'] < $date_order['m'] ) {
378
+				if ($date_order['y'] < $date_order['m']) {
379 379
 					// 2020 August.
380
-					$large = date_i18n( 'Y F', $this->start );
381
-					$small = date_i18n( 'Y M', $this->start );
380
+					$large = date_i18n('Y F', $this->start);
381
+					$small = date_i18n('Y M', $this->start);
382 382
 				} else {
383 383
 					// August 2020.
384
-					$large = date_i18n( 'F Y', $this->start );
385
-					$small = date_i18n( 'M Y', $this->start );
384
+					$large = date_i18n('F Y', $this->start);
385
+					$small = date_i18n('M Y', $this->start);
386 386
 				}
387 387
 			}
388
-		} elseif ( $start->year == $end->year ) {
388
+		} elseif ($start->year == $end->year) {
389 389
 			// Start and end days on months of the same year.
390 390
 			// e.g. August - September 2020
391
-			if ( $date_order['y'] === false ) {
391
+			if ($date_order['y'] === false) {
392 392
 				// August - September.
393
-				$large = date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end );
394
-				$small = date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end );
393
+				$large = date_i18n('F', $this->start).' - '.date_i18n('F', $this->end);
394
+				$small = date_i18n('M', $this->start).' - '.date_i18n('M', $this->end);
395 395
 			} else {
396
-				if ( $date_order['y'] < $date_order['m'] ) {
396
+				if ($date_order['y'] < $date_order['m']) {
397 397
 					// 2020, August - September.
398
-					$large  = $small = date( 'Y', $this->start ) . ', ';
399
-					$large .= date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end );
400
-					$small .= date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end );
398
+					$large  = $small = date('Y', $this->start).', ';
399
+					$large .= date_i18n('F', $this->start).' - '.date_i18n('F', $this->end);
400
+					$small .= date_i18n('M', $this->start).' - '.date_i18n('M', $this->end);
401 401
 				} else {
402 402
 					// August - September, 2020.
403
-					$large  = date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ) . ', ';
404
-					$small  = date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ) . ' ';
405
-					$year   = date( 'Y', $this->start );
403
+					$large  = date_i18n('F', $this->start).' - '.date_i18n('F', $this->end).', ';
404
+					$small  = date_i18n('M', $this->start).' - '.date_i18n('M', $this->end).' ';
405
+					$year   = date('Y', $this->start);
406 406
 					$large .= $year;
407 407
 					$small .= $year;
408 408
 				}
409 409
 			}
410 410
 		} else {
411
-			$large = $small = date( 'Y', $this->start ) . ' - ' . date( 'Y', $this->end );
411
+			$large = $small = date('Y', $this->start).' - '.date('Y', $this->end);
412 412
 		}
413 413
 
414 414
 		return array(
@@ -430,105 +430,105 @@  discard block
 block discarded – undo
430 430
 	 *
431 431
 	 * @return string
432 432
 	 */
433
-	private function draw_list( $timestamp, $id = 0 ) {
433
+	private function draw_list($timestamp, $id = 0) {
434 434
 
435 435
 		$calendar = $this->calendar;
436 436
 
437
-		if ( empty( $calendar ) ) {
438
-			$calendar = $this->calendar = simcal_get_calendar( intval( $id ) );
439
-			if ( ! $calendar instanceof Default_Calendar ) {
437
+		if (empty($calendar)) {
438
+			$calendar = $this->calendar = simcal_get_calendar(intval($id));
439
+			if ( ! $calendar instanceof Default_Calendar) {
440 440
 				return '';
441 441
 			}
442 442
 		}
443 443
 
444
-		date_default_timezone_set( $calendar->timezone );
444
+		date_default_timezone_set($calendar->timezone);
445 445
 
446 446
 		$now = $calendar->now;
447
-		$current_events = $this->get_events( $timestamp );
448
-		$day_format = explode( ' ', $calendar->date_format );
447
+		$current_events = $this->get_events($timestamp);
448
+		$day_format = explode(' ', $calendar->date_format);
449 449
 
450 450
 		ob_start();
451 451
 
452 452
 		// Draw the events.
453 453
 
454
-		$block_tag = $calendar->compact_list && ! empty( $current_events ) ? 'div' : 'dl';
454
+		$block_tag = $calendar->compact_list && ! empty($current_events) ? 'div' : 'dl';
455 455
 
456 456
 		$data_heading = '';
457 457
 		$heading = $this->get_heading();
458
-		foreach ( $heading as $k => $v ) {
459
-			$data_heading .= ' data-heading-' . $k . '="' . $v . '"';
458
+		foreach ($heading as $k => $v) {
459
+			$data_heading .= ' data-heading-'.$k.'="'.$v.'"';
460 460
 		}
461 461
 
462
-		echo '<' . $block_tag . ' class="simcal-events-list-container"' .
463
-			' data-prev="' . $this->prev . '"' .
464
-			' data-next="' . $this->next . '"' .
465
-			$data_heading . '>';
462
+		echo '<'.$block_tag.' class="simcal-events-list-container"'.
463
+			' data-prev="'.$this->prev.'"'.
464
+			' data-next="'.$this->next.'"'.
465
+			$data_heading.'>';
466 466
 
467
-		if ( ! empty( $current_events ) && is_array( $current_events ) ) :
467
+		if ( ! empty($current_events) && is_array($current_events)) :
468 468
 
469
-			foreach ( $current_events as $ymd => $events ) :
469
+			foreach ($current_events as $ymd => $events) :
470 470
 
471
-				$day_ts = Carbon::createFromFormat( 'Ymd', $ymd, $calendar->timezone )->getTimestamp();
471
+				$day_ts = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone)->getTimestamp();
472 472
 
473
-				if ( ! $calendar->compact_list ) :
473
+				if ( ! $calendar->compact_list) :
474 474
 
475
-					$date = new Carbon( 'now', $calendar->timezone );
476
-					$date->setLocale( substr( get_locale(), 0, 2 ) );
477
-					$date->setTimestamp( $day_ts );
475
+					$date = new Carbon('now', $calendar->timezone);
476
+					$date->setLocale(substr(get_locale(), 0, 2));
477
+					$date->setTimestamp($day_ts);
478 478
 
479
-					if ( $date->isToday() ) {
480
-						$the_color = new Color( $calendar->today_color );
479
+					if ($date->isToday()) {
480
+						$the_color = new Color($calendar->today_color);
481 481
 					} else {
482
-						$the_color = new Color( $calendar->days_events_color );
482
+						$the_color = new Color($calendar->days_events_color);
483 483
 					}
484 484
 
485
-					$bg_color = '#' . $the_color->getHex();
485
+					$bg_color = '#'.$the_color->getHex();
486 486
 					$color = $the_color->isDark() ? '#ffffff' : '#000000';
487
-					$border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" ';
488
-					$bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"';
487
+					$border_style = ' style="border-bottom: 1px solid '.$bg_color.';" ';
488
+					$bg_style = ' style="background-color: '.$bg_color.'; color: '.$color.';"';
489 489
 
490
-					echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>';
491
-					echo '<span' . $bg_style .'>';
492
-					foreach ( $day_format as $format ) {
493
-						echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n( $format, $day_ts ) . '</span> ' : ' ';
490
+					echo "\t".'<dt class="simcal-day-label"'.$border_style.'>';
491
+					echo '<span'.$bg_style.'>';
492
+					foreach ($day_format as $format) {
493
+						echo $format ? '<span class="simcal-date-format" data-date-format="'.$format.'">'.date_i18n($format, $day_ts).'</span> ' : ' ';
494 494
 					}
495 495
 					echo '</span>';
496
-					echo '</dt>' . "\n";
496
+					echo '</dt>'."\n";
497 497
 
498 498
 				endif;
499 499
 
500
-				$list_events = '<ul class="simcal-events">' . "\n";
500
+				$list_events = '<ul class="simcal-events">'."\n";
501 501
 
502 502
 				$calendar_classes = array();
503
-				$day_classes = 'simcal-weekday-' . date( 'w', $day_ts );
503
+				$day_classes = 'simcal-weekday-'.date('w', $day_ts);
504 504
 
505 505
 				// Is this the present, the past or the future, Doc?
506
-				if ( $timestamp <= $now && $timestamp >= $now ) {
506
+				if ($timestamp <= $now && $timestamp >= $now) {
507 507
 					$day_classes .= ' simcal-today simcal-present simcal-day';
508
-				} elseif ( $timestamp < $now ) {
508
+				} elseif ($timestamp < $now) {
509 509
 					$day_classes .= ' simcal-past simcal-day';
510
-				} elseif ( $this->end > $now ) {
510
+				} elseif ($this->end > $now) {
511 511
 					$day_classes .= ' simcal-future simcal-day';
512 512
 				}
513 513
 
514 514
 				$count = 0;
515 515
 
516
-				foreach ( $events as $day_events ) :
517
-					foreach ( $day_events as $event ) :
518
-						if ( $event instanceof Event ) :
516
+				foreach ($events as $day_events) :
517
+					foreach ($day_events as $event) :
518
+						if ($event instanceof Event) :
519 519
 
520 520
 							$event_classes = $event_visibility = '';
521 521
 
522
-							$calendar_class     = 'simcal-events-calendar-' . strval( $event->calendar );
522
+							$calendar_class     = 'simcal-events-calendar-'.strval($event->calendar);
523 523
 							$calendar_classes[] = $calendar_class;
524 524
 
525 525
 							$recurring     = $event->recurrence ? 'simcal-event-recurring ' : '';
526 526
 							$has_location  = $event->venue ? 'simcal-event-has-location ' : '';
527 527
 
528
-							$event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class;
528
+							$event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class;
529 529
 
530 530
 							// Toggle some events visibility if more than optional limit.
531
-							if ( ( $calendar->events_limit > - 1 ) && ( $count >= $calendar->events_limit ) ) :
531
+							if (($calendar->events_limit > - 1) && ($count >= $calendar->events_limit)) :
532 532
 								$event_classes .= ' simcal-event-toggled';
533 533
 								$event_visibility = ' style="display: none"';
534 534
 							endif;
@@ -536,75 +536,75 @@  discard block
 block discarded – undo
536 536
 							$event_color = '';
537 537
 							$bullet = '';
538 538
 							$event_color = $event->get_color();
539
-							if ( ! empty( $event_color ) ) {
539
+							if ( ! empty($event_color)) {
540 540
 								$side = is_rtl() ? 'right' : 'left';
541
-								$event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"';
541
+								$event_color = ' style="border-'.$side.': 4px solid '.$event_color.'; padding-'.$side.': 8px;"';
542 542
 							}
543 543
 
544
-							$list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemprop="event" itemscope itemtype="http://schema.org/Event">' . "\n";
545
-							$list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html( $event ) . '</div>' . "\n";
546
-							$list_events .= "\t" . '</li>' . "\n";
544
+							$list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.$event_color.' itemprop="event" itemscope itemtype="http://schema.org/Event">'."\n";
545
+							$list_events .= "\t\t".'<div class="simcal-event-details">'.$calendar->get_event_html($event).'</div>'."\n";
546
+							$list_events .= "\t".'</li>'."\n";
547 547
 
548
-							$count ++;
548
+							$count++;
549 549
 
550 550
 							// Event falls within today.
551
-							if ( ( $this->end <= $now ) && ( $this->start >= $now ) ) :
551
+							if (($this->end <= $now) && ($this->start >= $now)) :
552 552
 								$day_classes .= ' simcal-today-has-events';
553 553
 							endif;
554
-							$day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events';
554
+							$day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events';
555 555
 
556
-							if ( $calendar_classes ) :
557
-								$day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) );
556
+							if ($calendar_classes) :
557
+								$day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes)));
558 558
 							endif;
559 559
 
560 560
 						endif;
561 561
 					endforeach;
562 562
 				endforeach;
563 563
 
564
-				$list_events .= '</ul>' . "\n";
564
+				$list_events .= '</ul>'."\n";
565 565
 
566 566
 				// If events visibility is limited, print the button toggle.
567
-				if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) :
567
+				if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) :
568 568
 					$list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>';
569 569
 				endif;
570 570
 
571 571
 				// Print final list of events for the current day.
572 572
 				$tag = $calendar->compact_list ? 'div' : 'dd';
573
-				echo '<'  . $tag . ' class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n";
574
-				echo "\t" . $list_events . "\n";
575
-				echo '</' . $tag . '>' . "\n";
573
+				echo '<'.$tag.' class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n";
574
+				echo "\t".$list_events."\n";
575
+				echo '</'.$tag.'>'."\n";
576 576
 
577 577
 			endforeach;
578 578
 
579 579
 		else :
580 580
 
581
-			echo "\t" . '<p>';
581
+			echo "\t".'<p>';
582 582
 
583
-			$message = get_post_meta( $calendar->id, '_no_events_message', true );
583
+			$message = get_post_meta($calendar->id, '_no_events_message', true);
584 584
 
585
-			if ( 'events' == $calendar->group_type ) {
586
-				echo ! empty( $message ) ? $message : __( 'Nothing to show.', 'google-calendar-events' );
585
+			if ('events' == $calendar->group_type) {
586
+				echo ! empty($message) ? $message : __('Nothing to show.', 'google-calendar-events');
587 587
 			} else {
588
-				if ( ! empty( $message ) ) {
588
+				if ( ! empty($message)) {
589 589
 					echo $message;
590 590
 				} else {
591
-					$from = Carbon::createFromTimestamp( $this->start, $calendar->timezone )->getTimestamp();
592
-					$to = Carbon::createFromTimestamp( $this->end, $calendar->timezone )->getTimestamp();
593
-					echo apply_filters( 'simcal_no_events_message', sprintf(
594
-						__( 'Nothing from %1$s to %2$s.', 'google-calendar-events' ),
595
-						date_i18n( $calendar->date_format, $from ),
596
-						date_i18n( $calendar->date_format, $to )
597
-					), $calendar->id, $from, $to );
591
+					$from = Carbon::createFromTimestamp($this->start, $calendar->timezone)->getTimestamp();
592
+					$to = Carbon::createFromTimestamp($this->end, $calendar->timezone)->getTimestamp();
593
+					echo apply_filters('simcal_no_events_message', sprintf(
594
+						__('Nothing from %1$s to %2$s.', 'google-calendar-events'),
595
+						date_i18n($calendar->date_format, $from),
596
+						date_i18n($calendar->date_format, $to)
597
+					), $calendar->id, $from, $to);
598 598
 				}
599 599
 			}
600 600
 
601
-			echo "\t" . '</p>' . "\n";
601
+			echo "\t".'</p>'."\n";
602 602
 
603 603
 		endif;
604 604
 
605
-		echo '</' . $block_tag . '>';
605
+		echo '</'.$block_tag.'>';
606 606
 
607
-		date_default_timezone_set( $calendar->site_timezone );
607
+		date_default_timezone_set($calendar->site_timezone);
608 608
 
609 609
 		return ob_get_clean();
610 610
 	}
@@ -616,16 +616,16 @@  discard block
 block discarded – undo
616 616
 	 */
617 617
 	public function draw_list_ajax() {
618 618
 
619
-		if ( isset( $_POST['ts'] ) && isset( $_POST['id'] ) ) {
619
+		if (isset($_POST['ts']) && isset($_POST['id'])) {
620 620
 
621
-			$ts = absint( $_POST['ts'] );
622
-			$id = absint( $_POST['id'] );
621
+			$ts = absint($_POST['ts']);
622
+			$id = absint($_POST['id']);
623 623
 
624
-			wp_send_json_success( $this->draw_list( $ts, $id ) );
624
+			wp_send_json_success($this->draw_list($ts, $id));
625 625
 
626 626
 		} else {
627 627
 
628
-			wp_send_json_error( 'Missing arguments in default calendar list ajax request.' );
628
+			wp_send_json_error('Missing arguments in default calendar list ajax request.');
629 629
 
630 630
 		}
631 631
 	}
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 	 *
641 641
 	 * @return bool
642 642
 	 */
643
-	private function filter_events_before( $event ) {
644
-		return intval( $event ) > intval( $this->start );
643
+	private function filter_events_before($event) {
644
+		return intval($event) > intval($this->start);
645 645
 	}
646 646
 
647 647
 	/**
@@ -654,8 +654,8 @@  discard block
 block discarded – undo
654 654
 	 *
655 655
 	 * @return bool
656 656
 	 */
657
-	private function filter_events_after( $event ) {
658
-		return intval( $event ) < intval( $this->end );
657
+	private function filter_events_after($event) {
658
+		return intval($event) < intval($this->end);
659 659
 	}
660 660
 
661 661
 }
Please login to merge, or discard this patch.
includes/events/event-builder.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -590,21 +590,21 @@  discard block
 block discarded – undo
590 590
 		if ( ! $event->whole_day ) {
591 591
 
592 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
-			              '</span> ';
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
+						  '</span> ';
599 599
 
600 600
 			if ( $end instanceof Carbon ) {
601 601
 
602 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
-				            '</span> ';
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
+							'</span> ';
608 608
 
609 609
 			}
610 610
 
@@ -613,23 +613,23 @@  discard block
 block discarded – undo
613 613
 		if ( $event->multiple_days ) {
614 614
 
615 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
-			          $time_start;
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
+					  $time_start;
622 622
 
623 623
 			if ( $end instanceof Carbon ) {
624 624
 
625 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
-				           $time_end;
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
+						   $time_end;
633 633
 			}
634 634
 
635 635
 		} else {
@@ -637,12 +637,12 @@  discard block
 block discarded – undo
637 637
 			$time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : '';
638 638
 
639 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
-			          $time_end;
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
+					  $time_end;
646 646
 
647 647
 		}
648 648
 
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
 		}
696 696
 
697 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
-		       '</span>';
698
+			   'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '"' .
699
+			   'data-event-format="' . $dt_format . '"' .
700
+			   'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' .
701
+			   $value .
702
+			   '</span>';
703 703
 	}
704 704
 
705 705
 	/**
@@ -918,35 +918,35 @@  discard block
 block discarded – undo
918 918
 		$tagregexp = implode( '|', array_values( $this->tags ) );
919 919
 
920 920
 		return '/'
921
-		       . '\\['                              // Opening bracket
922
-		       . '(\\[?)'                           // 1: Optional second opening bracket for escaping tags: [[tag]]
923
-		       . "($tagregexp)"                     // 2: Tag name
924
-		       . '(?![\\w-])'                       // Not followed by word character or hyphen
925
-		       . '('                                // 3: Unroll the loop: Inside the opening tag
926
-		       .     '[^\\]\\/]*'                   // Not a closing bracket or forward slash
927
-		       .     '(?:'
928
-		       .         '\\/(?!\\])'               // A forward slash not followed by a closing bracket
929
-		       .         '[^\\]\\/]*'               // Not a closing bracket or forward slash
930
-		       .     ')*?'
931
-		       . ')'
932
-		       . '(?:'
933
-		       .     '(\\/)'                        // 4: Self closing tag ...
934
-		       .     '\\]'                          // ... and closing bracket
935
-		       . '|'
936
-		       .     '\\]'                          // Closing bracket
937
-		       .     '(?:'
938
-		       .         '('                        // 5: Unroll the loop: Optionally, anything between the opening and closing tags
939
-		       .             '[^\\[]*+'             // Not an opening bracket
940
-		       .             '(?:'
941
-		       .                 '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag
942
-		       .                 '[^\\[]*+'         // Not an opening bracket
943
-		       .             ')*+'
944
-		       .         ')'
945
-		       .         '\\[\\/\\2\\]'             // Closing tag
946
-		       .     ')?'
947
-		       . ')'
948
-		       . '(\\]?)'                           // 6: Optional second closing bracket for escaping tags: [[tag]]
949
-		       . '/s';
921
+			   . '\\['                              // Opening bracket
922
+			   . '(\\[?)'                           // 1: Optional second opening bracket for escaping tags: [[tag]]
923
+			   . "($tagregexp)"                     // 2: Tag name
924
+			   . '(?![\\w-])'                       // Not followed by word character or hyphen
925
+			   . '('                                // 3: Unroll the loop: Inside the opening tag
926
+			   .     '[^\\]\\/]*'                   // Not a closing bracket or forward slash
927
+			   .     '(?:'
928
+			   .         '\\/(?!\\])'               // A forward slash not followed by a closing bracket
929
+			   .         '[^\\]\\/]*'               // Not a closing bracket or forward slash
930
+			   .     ')*?'
931
+			   . ')'
932
+			   . '(?:'
933
+			   .     '(\\/)'                        // 4: Self closing tag ...
934
+			   .     '\\]'                          // ... and closing bracket
935
+			   . '|'
936
+			   .     '\\]'                          // Closing bracket
937
+			   .     '(?:'
938
+			   .         '('                        // 5: Unroll the loop: Optionally, anything between the opening and closing tags
939
+			   .             '[^\\[]*+'             // Not an opening bracket
940
+			   .             '(?:'
941
+			   .                 '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag
942
+			   .                 '[^\\[]*+'         // Not an opening bracket
943
+			   .             ')*+'
944
+			   .         ')'
945
+			   .         '\\[\\/\\2\\]'             // Closing tag
946
+			   .     ')?'
947
+			   . ')'
948
+			   . '(\\]?)'                           // 6: Optional second closing bracket for escaping tags: [[tag]]
949
+			   . '/s';
950 950
 	}
951 951
 
952 952
 }
Please login to merge, or discard this 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/events/events.php 1 patch
Spacing   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use Carbon\Carbon;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 * @param array $e Events.
46 46
 	 * @param string|\DateTimeZone $tz Timezone.
47 47
 	 */
48
-	public function __construct( $e = array(), $tz = 'UTC' ) {
49
-		$this->set_events( $e );
50
-		$this->set_timezone( $tz );
48
+	public function __construct($e = array(), $tz = 'UTC') {
49
+		$this->set_events($e);
50
+		$this->set_timezone($tz);
51 51
 	}
52 52
 
53 53
 	/**
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return array
61 61
 	 */
62
-	public function get_events( $n = '' ) {
63
-		if ( ! empty( $n ) && ! empty( $this->events ) ) {
64
-			$length = absint( $n );
65
-			return array_slice( $this->events, 0, $length, true );
62
+	public function get_events($n = '') {
63
+		if ( ! empty($n) && ! empty($this->events)) {
64
+			$length = absint($n);
65
+			return array_slice($this->events, 0, $length, true);
66 66
 		}
67 67
 		return $this->events;
68 68
 	}
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @param array $ev Events.
76 76
 	 */
77
-	public function set_events( array $ev ) {
77
+	public function set_events(array $ev) {
78 78
 		$this->events = $ev;
79 79
 	}
80 80
 
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return Events
89 89
 	 */
90
-	public function set_timezone( $tz ) {
91
-		if ( $tz instanceof \DateTimeZone ) {
90
+	public function set_timezone($tz) {
91
+		if ($tz instanceof \DateTimeZone) {
92 92
 			$tz = $tz->getName();
93 93
 		}
94
-		$this->timezone = simcal_esc_timezone( $tz, $this->timezone );
94
+		$this->timezone = simcal_esc_timezone($tz, $this->timezone);
95 95
 		return $this;
96 96
 	}
97 97
 
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @return Events
106 106
 	 */
107
-	public function shift( $n ) {
108
-		if ( ! empty( $this->events ) ) {
109
-			$offset = intval( $n );
110
-			$length = count( $this->events );
111
-			$this->set_events( array_slice( $this->events, $offset, $length, true ) );
107
+	public function shift($n) {
108
+		if ( ! empty($this->events)) {
109
+			$offset = intval($n);
110
+			$length = count($this->events);
111
+			$this->set_events(array_slice($this->events, $offset, $length, true));
112 112
 		}
113 113
 		return $this;
114 114
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @return Events
122 122
 	 */
123 123
 	public function private_only() {
124
-		$this->set_events( $this->filter_property( 'public', 'hide' ) );
124
+		$this->set_events($this->filter_property('public', 'hide'));
125 125
 		return $this;
126 126
 	}
127 127
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @return Events
134 134
 	 */
135 135
 	public function public_only() {
136
-		$this->set_events( $this->filter_property( 'public', 'show' ) );
136
+		$this->set_events($this->filter_property('public', 'show'));
137 137
 		return $this;
138 138
 	}
139 139
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return Events
146 146
 	 */
147 147
 	public function recurring() {
148
-		$this->set_events( $this->filter_property( 'recurrence', 'show' ) );
148
+		$this->set_events($this->filter_property('recurrence', 'show'));
149 149
 		return $this;
150 150
 	}
151 151
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @return Events
158 158
 	 */
159 159
 	public function not_recurring() {
160
-		$this->set_events( $this->filter_property( 'recurrence', 'hide' ) );
160
+		$this->set_events($this->filter_property('recurrence', 'hide'));
161 161
 		return $this;
162 162
 	}
163 163
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 * @return Events
170 170
 	 */
171 171
 	public function whole_day() {
172
-		$this->set_events( $this->filter_property( 'whole_day', 'show' ) );
172
+		$this->set_events($this->filter_property('whole_day', 'show'));
173 173
 		return $this;
174 174
 	}
175 175
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @return Events
182 182
 	 */
183 183
 	public function not_whole_day() {
184
-		$this->set_events( $this->filter_property( 'whole_day', 'hide' ) );
184
+		$this->set_events($this->filter_property('whole_day', 'hide'));
185 185
 		return $this;
186 186
 	}
187 187
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @return Events
194 194
 	 */
195 195
 	public function multi_day() {
196
-		$this->set_events( $this->filter_property( 'multiple_days', 'show' ) );
196
+		$this->set_events($this->filter_property('multiple_days', 'show'));
197 197
 		return $this;
198 198
 	}
199 199
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @return Events
206 206
 	 */
207 207
 	public function single_day() {
208
-		$this->set_events( $this->filter_property( 'multiple_days', 'hide' ) );
208
+		$this->set_events($this->filter_property('multiple_days', 'hide'));
209 209
 		return $this;
210 210
 	}
211 211
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 * @return Events
218 218
 	 */
219 219
 	public function with_location() {
220
-		$this->set_events( $this->filter_property( 'venue', 'show' ) );
220
+		$this->set_events($this->filter_property('venue', 'show'));
221 221
 		return $this;
222 222
 	}
223 223
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 * @return Events
230 230
 	 */
231 231
 	public function without_location() {
232
-		$this->set_events( $this->filter_property( 'venue', 'hide' ) );
232
+		$this->set_events($this->filter_property('venue', 'hide'));
233 233
 		return $this;
234 234
 	}
235 235
 
@@ -244,18 +244,18 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @return array
246 246
 	 */
247
-	private function filter_property( $property, $toggle ) {
247
+	private function filter_property($property, $toggle) {
248 248
 		$filtered = array();
249
-		if ( ! empty( $this->events ) ) {
250
-			foreach ( $this->events as $ts => $events ) {
251
-				foreach ( $events as $event ) {
252
-					if ( 'hide' == $toggle ) {
253
-						if ( ! $event->$property ) {
254
-							$filtered[ $ts ][] = $event;
249
+		if ( ! empty($this->events)) {
250
+			foreach ($this->events as $ts => $events) {
251
+				foreach ($events as $event) {
252
+					if ('hide' == $toggle) {
253
+						if ( ! $event->$property) {
254
+							$filtered[$ts][] = $event;
255 255
 						}
256
-					} elseif ( 'show' == $toggle ) {
257
-						if ( $event->$property ) {
258
-							$filtered[ $ts ][] = $event;
256
+					} elseif ('show' == $toggle) {
257
+						if ($event->$property) {
258
+							$filtered[$ts][] = $event;
259 259
 						}
260 260
 					}
261 261
 				}
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @return Events
275 275
 	 */
276
-	public function future( $present = '' ) {
276
+	public function future($present = '') {
277 277
 		$last = $this->get_last();
278 278
 		$to = $last instanceof Event ? $last->start_utc : false;
279
-		if ( $to ) {
280
-			if ( empty( $present ) ) {
281
-				$present = Carbon::now( $this->timezone )->getTimestamp();
279
+		if ($to) {
280
+			if (empty($present)) {
281
+				$present = Carbon::now($this->timezone)->getTimestamp();
282 282
 			}
283
-			$this->set_events( $this->filter_events( intval( $present ), $to ) );
283
+			$this->set_events($this->filter_events(intval($present), $to));
284 284
 		}
285 285
 		return $this;
286 286
 	}
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @return Events
296 296
 	 */
297
-	public function past( $present = '' ) {
297
+	public function past($present = '') {
298 298
 		$first = $this->get_last();
299 299
 		$from  = $first instanceof Event ? $first->start_utc : false;
300
-		if ( $from ) {
301
-			if ( empty( $present ) ) {
302
-				$present = Carbon::now( $this->timezone )->getTimestamp();
300
+		if ($from) {
301
+			if (empty($present)) {
302
+				$present = Carbon::now($this->timezone)->getTimestamp();
303 303
 			}
304
-			$this->set_events( $this->filter_events( $from, intval( $present ) ) );
304
+			$this->set_events($this->filter_events($from, intval($present)));
305 305
 		}
306 306
 		return $this;
307 307
 	}
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @return Events
317 317
 	 */
318
-	public function after( $time ) {
319
-		$dt = $this->parse( $time );
320
-		return ! is_null( $dt ) ? $this->future( $dt->getTimestamp() ) : $this;
318
+	public function after($time) {
319
+		$dt = $this->parse($time);
320
+		return ! is_null($dt) ? $this->future($dt->getTimestamp()) : $this;
321 321
 	}
322 322
 
323 323
 	/**
@@ -329,9 +329,9 @@  discard block
 block discarded – undo
329 329
 	 *
330 330
 	 * @return Events
331 331
 	 */
332
-	public function before( $time ) {
333
-		$dt = $this->parse( $time );
334
-		return ! is_null( $dt ) ? $this->past( $dt->getTimestamp() ) : $this;
332
+	public function before($time) {
333
+		$dt = $this->parse($time);
334
+		return ! is_null($dt) ? $this->past($dt->getTimestamp()) : $this;
335 335
 	}
336 336
 
337 337
 	/**
@@ -343,10 +343,10 @@  discard block
 block discarded – undo
343 343
 	 *
344 344
 	 * @return Events
345 345
 	 */
346
-	public function from( $time ) {
347
-		$last = $this->parse( $time );
348
-		if ( ! is_null( $last ) ) {
349
-			$this->set_events( $this->filter_events( $time, $last->getTimestamp() ) );
346
+	public function from($time) {
347
+		$last = $this->parse($time);
348
+		if ( ! is_null($last)) {
349
+			$this->set_events($this->filter_events($time, $last->getTimestamp()));
350 350
 		}
351 351
 		return $this;
352 352
 	}
@@ -360,10 +360,10 @@  discard block
 block discarded – undo
360 360
 	 *
361 361
 	 * @return Events
362 362
 	 */
363
-	public function to( $time ) {
364
-		$first = $this->parse( $time );
365
-		if ( ! is_null( $first ) ) {
366
-			$this->set_events( $this->filter_events( $first->getTimestamp(), $time ) );
363
+	public function to($time) {
364
+		$first = $this->parse($time);
365
+		if ( ! is_null($first)) {
366
+			$this->set_events($this->filter_events($first->getTimestamp(), $time));
367 367
 		}
368 368
 		return $this;
369 369
 	}
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
 	 *
378 378
 	 * @return null|Carbon
379 379
 	 */
380
-	private function parse( $time ) {
381
-		if ( is_int( $time ) ) {
382
-			return Carbon::createFromTimestamp( $time, $this->timezone );
383
-		} elseif ( is_string( $time ) && ! empty( $time ) ) {
384
-			return Carbon::parse( $time, $this->timezone );
385
-		} elseif ( $time instanceof Carbon ) {
386
-			return $time->setTimezone( $this->timezone );
387
-		} elseif ( $time instanceof \DateTime ) {
388
-			return Carbon::instance( $time )->setTimezone( $this->timezone );
380
+	private function parse($time) {
381
+		if (is_int($time)) {
382
+			return Carbon::createFromTimestamp($time, $this->timezone);
383
+		} elseif (is_string($time) && ! empty($time)) {
384
+			return Carbon::parse($time, $this->timezone);
385
+		} elseif ($time instanceof Carbon) {
386
+			return $time->setTimezone($this->timezone);
387
+		} elseif ($time instanceof \DateTime) {
388
+			return Carbon::instance($time)->setTimezone($this->timezone);
389 389
 		}
390 390
 		return null;
391 391
 	}
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 * @return null|Event
399 399
 	 */
400 400
 	public function get_first() {
401
-		return array_shift( $this->events );
401
+		return array_shift($this->events);
402 402
 	}
403 403
 
404 404
 	/**
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 	 * @return null|Event
410 410
 	 */
411 411
 	public function get_last() {
412
-		return array_pop( $this->events );
412
+		return array_pop($this->events);
413 413
 	}
414 414
 
415 415
 	/**
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 	 * @return null|Event
421 421
 	 */
422 422
 	public function get_upcoming() {
423
-		return $this->get_closest( 'future' );
423
+		return $this->get_closest('future');
424 424
 	}
425 425
 
426 426
 	/**
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 	 * @return null|Event
432 432
 	 */
433 433
 	public function get_latest() {
434
-		return $this->get_closest( 'past' );
434
+		return $this->get_closest('past');
435 435
 	}
436 436
 
437 437
 	/**
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
 	 *
445 445
 	 * @return null|Event
446 446
 	 */
447
-	private function get_closest( $dir ) {
448
-		if ( 'future' == $dir ) {
449
-			return array_shift( $this->future()->get_events() );
450
-		} elseif ( 'past' == $dir ) {
451
-			return array_shift( $this->past()->get_events() );
447
+	private function get_closest($dir) {
448
+		if ('future' == $dir) {
449
+			return array_shift($this->future()->get_events());
450
+		} elseif ('past' == $dir) {
451
+			return array_shift($this->past()->get_events());
452 452
 		}
453 453
 		return null;
454 454
 	}
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
 	 *
463 463
 	 * @return array Multidimensional array with month number, week number and Event objects for each weekday.
464 464
 	 */
465
-	public function get_year( $year ) {
466
-		$y = intval( $year );
465
+	public function get_year($year) {
466
+		$y = intval($year);
467 467
 		$months = array();
468
-		for ( $m = 1; $m <= 12; $m++ ) {
469
-			$months[ strval( $m ) ] = $this->get_month( $y, $m );
468
+		for ($m = 1; $m <= 12; $m++) {
469
+			$months[strval($m)] = $this->get_month($y, $m);
470 470
 		}
471 471
 		return $months;
472 472
 	}
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
 	 *
482 482
 	 * @return array Multidimensional array with week number, day of the week and array of Event objects for each week day.
483 483
 	 */
484
-	public function get_month( $year, $month ) {
485
-		$y = intval( $year );
486
-		$m = min( max( 1, absint( $month ) ), 12 );
487
-		$days  = Carbon::createFromDate( $y, $m, 2, $this->timezone )->startOfMonth()->daysInMonth;
484
+	public function get_month($year, $month) {
485
+		$y = intval($year);
486
+		$m = min(max(1, absint($month)), 12);
487
+		$days  = Carbon::createFromDate($y, $m, 2, $this->timezone)->startOfMonth()->daysInMonth;
488 488
 		$weeks = array();
489
-		for ( $d = 1; $d < $days; $d++ ) {
490
-			$current = Carbon::createFromDate( $y, $m, $d );
489
+		for ($d = 1; $d < $days; $d++) {
490
+			$current = Carbon::createFromDate($y, $m, $d);
491 491
 			$week = $current->weekOfYear;
492 492
 			$day  = $current->dayOfWeek;
493
-			$weeks[ strval( $week ) ][ strval( $day ) ] = $this->get_day( $y, $m, $d );
493
+			$weeks[strval($week)][strval($day)] = $this->get_day($y, $m, $d);
494 494
 		}
495 495
 		return $weeks;
496 496
 	}
@@ -505,16 +505,16 @@  discard block
 block discarded – undo
505 505
 	 *
506 506
 	 * @return array Associative array with day of the week for key and array of Event objects for value.
507 507
 	 */
508
-	public function get_week( $year, $week ) {
509
-		$y = intval( $year );
510
-		$w = absint( $week );
511
-		$m = date( 'n', strtotime( strval( $y ) . '-W' . strval( $w ) ) );
512
-		$month_dt = Carbon::createFromDate( $y, $m, 2, $this->timezone );
508
+	public function get_week($year, $week) {
509
+		$y = intval($year);
510
+		$w = absint($week);
511
+		$m = date('n', strtotime(strval($y).'-W'.strval($w)));
512
+		$month_dt = Carbon::createFromDate($y, $m, 2, $this->timezone);
513 513
 		$days = array();
514
-		for ( $d = 1; $d < $month_dt->daysInMonth; $d++ ) {
515
-			$current = Carbon::createFromDate( $y, $m, $d );
516
-			if ( $w == $current->weekOfYear ) {
517
-				$days[ strval( $current->dayOfWeek ) ] = $this->get_day( $y, $m, $d );
514
+		for ($d = 1; $d < $month_dt->daysInMonth; $d++) {
515
+			$current = Carbon::createFromDate($y, $m, $d);
516
+			if ($w == $current->weekOfYear) {
517
+				$days[strval($current->dayOfWeek)] = $this->get_day($y, $m, $d);
518 518
 			}
519 519
 		}
520 520
 		return $days;
@@ -531,13 +531,13 @@  discard block
 block discarded – undo
531 531
 	 *
532 532
 	 * @return array Event objects for the day.
533 533
 	 */
534
-	public function get_day( $year, $month, $day ) {
535
-		$y = intval( $year );
536
-		$m = min( max( 1, absint( $month ) ), 12 );
537
-		$d = min( absint( $day ), 31 );
538
-		$from = Carbon::createFromDate( $y, $m, $d, $this->timezone )->startOfDay()->getTimestamp();
539
-		$to   = Carbon::createFromDate( $y, $m, $d, $this->timezone )->endOfDay()->getTimestamp();
540
-		return $this->filter_events( $from, $to );
534
+	public function get_day($year, $month, $day) {
535
+		$y = intval($year);
536
+		$m = min(max(1, absint($month)), 12);
537
+		$d = min(absint($day), 31);
538
+		$from = Carbon::createFromDate($y, $m, $d, $this->timezone)->startOfDay()->getTimestamp();
539
+		$to   = Carbon::createFromDate($y, $m, $d, $this->timezone)->endOfDay()->getTimestamp();
540
+		return $this->filter_events($from, $to);
541 541
 	}
542 542
 
543 543
 	/**
@@ -548,9 +548,9 @@  discard block
 block discarded – undo
548 548
 	 * @return array Event objects for today.
549 549
 	 */
550 550
 	public function get_today() {
551
-		$start = Carbon::today( $this->timezone )->startOfDay()->getTimestamp();
552
-		$end   = Carbon::today( $this->timezone )->endOfDay()->getTimestamp();
553
-		return $this->filter_events( $start, $end );
551
+		$start = Carbon::today($this->timezone)->startOfDay()->getTimestamp();
552
+		$end   = Carbon::today($this->timezone)->endOfDay()->getTimestamp();
553
+		return $this->filter_events($start, $end);
554 554
 	}
555 555
 
556 556
 	/**
@@ -561,9 +561,9 @@  discard block
 block discarded – undo
561 561
 	 * @return array Event objects for tomorrow.
562 562
 	 */
563 563
 	public function get_tomorrow() {
564
-		$start = Carbon::tomorrow( $this->timezone )->startOfDay()->getTimestamp();
565
-		$end   = Carbon::tomorrow( $this->timezone )->endOfDay()->getTimestamp();
566
-		return $this->filter_events( $start, $end );
564
+		$start = Carbon::tomorrow($this->timezone)->startOfDay()->getTimestamp();
565
+		$end   = Carbon::tomorrow($this->timezone)->endOfDay()->getTimestamp();
566
+		return $this->filter_events($start, $end);
567 567
 	}
568 568
 
569 569
 	/**
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
 	 * @return array Event objects for yesterday.
575 575
 	 */
576 576
 	public function get_yesterday() {
577
-		$start = Carbon::yesterday( $this->timezone )->startOfDay()->getTimestamp();
578
-		$end   = Carbon::yesterday( $this->timezone )->endOfDay()->getTimestamp();
579
-		return $this->filter_events( $start, $end );
577
+		$start = Carbon::yesterday($this->timezone)->startOfDay()->getTimestamp();
578
+		$end   = Carbon::yesterday($this->timezone)->endOfDay()->getTimestamp();
579
+		return $this->filter_events($start, $end);
580 580
 	}
581 581
 
582 582
 	/**
@@ -590,16 +590,16 @@  discard block
 block discarded – undo
590 590
 	 *
591 591
 	 * @return array Filtered array of Event objects.
592 592
 	 */
593
-	private function filter_events( $from, $to ) {
594
-		$timestamps   = array_keys( $this->events );
595
-		$lower_bound  = array_filter( $timestamps,  function( $ts ) use( $from ) {
596
-			return intval( $ts ) > intval( $from );
593
+	private function filter_events($from, $to) {
594
+		$timestamps   = array_keys($this->events);
595
+		$lower_bound  = array_filter($timestamps, function($ts) use($from) {
596
+			return intval($ts) > intval($from);
597 597
 		} );
598
-		$higher_bound = array_filter( $lower_bound, function( $ts ) use( $to ) {
599
-			return intval( $ts ) > intval( $to );
598
+		$higher_bound = array_filter($lower_bound, function($ts) use($to) {
599
+			return intval($ts) > intval($to);
600 600
 		} );
601
-		$filtered = array_combine( $higher_bound, $higher_bound );
602
-		return array_intersect_key( $this->events, $filtered );
601
+		$filtered = array_combine($higher_bound, $higher_bound);
602
+		return array_intersect_key($this->events, $filtered);
603 603
 	}
604 604
 
605 605
 }
Please login to merge, or discard this patch.
includes/feeds/admin/grouped-calendars-admin.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\Feeds\Grouped_Calendars;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -34,15 +34,15 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @param Grouped_Calendars $feed
36 36
 	 */
37
-	public function __construct( Grouped_Calendars $feed ) {
37
+	public function __construct(Grouped_Calendars $feed) {
38 38
 
39 39
 		$this->feed = $feed;
40 40
 
41
-		if ( 'calendar' == simcal_is_admin_screen() ) {
42
-			add_filter( 'simcal_settings_meta_tabs_li', array( $this, 'add_settings_meta_tab_li' ), 10, 1 );
43
-			add_action( 'simcal_settings_meta_panels', array( $this, 'add_settings_meta_panel' ), 10, 1 );
41
+		if ('calendar' == simcal_is_admin_screen()) {
42
+			add_filter('simcal_settings_meta_tabs_li', array($this, 'add_settings_meta_tab_li'), 10, 1);
43
+			add_action('simcal_settings_meta_panels', array($this, 'add_settings_meta_panel'), 10, 1);
44 44
 		}
45
-		add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 );
45
+		add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1);
46 46
 	}
47 47
 
48 48
 	/**
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return array
56 56
 	 */
57
-	public function add_settings_meta_tab_li( $tabs ) {
58
-		return array_merge( $tabs, array(
57
+	public function add_settings_meta_tab_li($tabs) {
58
+		return array_merge($tabs, array(
59 59
 			'grouped-calendars' => array(
60 60
 				'label'   => $this->feed->name,
61 61
 				'target'  => 'grouped-calendars-settings-panel',
@@ -75,40 +75,40 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @param int $post_id
77 77
 	 */
78
-	public function add_settings_meta_panel( $post_id ) {
78
+	public function add_settings_meta_panel($post_id) {
79 79
 
80 80
 		?>
81 81
 		<div id="grouped-calendars-settings-panel" class="simcal-panel">
82 82
 			<table>
83 83
 				<thead>
84
-				<tr><th colspan="2"><?php _e( 'Grouped Calendar settings', 'google-calendar-events' ); ?></th></tr>
84
+				<tr><th colspan="2"><?php _e('Grouped Calendar settings', 'google-calendar-events'); ?></th></tr>
85 85
 				</thead>
86 86
 				<tbody class="simcal-panel-section">
87 87
 				<tr class="simcal-panel-field">
88
-					<th><label for="_grouped_calendars_source"><?php _e( 'Get calendars from', 'google-calendar-events' ); ?></label></th>
88
+					<th><label for="_grouped_calendars_source"><?php _e('Get calendars from', 'google-calendar-events'); ?></label></th>
89 89
 					<td>
90 90
 						<?php
91 91
 
92
-						$source = esc_attr( get_post_meta( $post_id, '_grouped_calendars_source', true ) );
93
-						$source = empty( $source ) ? 'ids' : $source;
92
+						$source = esc_attr(get_post_meta($post_id, '_grouped_calendars_source', true));
93
+						$source = empty($source) ? 'ids' : $source;
94 94
 
95 95
 						?>
96 96
 						<select name="_grouped_calendars_source"
97 97
 						        id="_grouped_calendars_source"
98 98
 						        class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other"
99 99
 						        data-show-field-on-choice="true">
100
-							<option value="ids" data-show-field="_grouped_calendars_ids" <?php selected( 'ids', $source, true ); ?>><?php _e( 'Manual selection', 'google-calendar-events' ); ?></option>
101
-							<option value="category" data-show-field="_grouped_calendars_category" <?php selected( 'category', $source, true ); ?>><?php _e( 'Category', 'google-calendar-events' ); ?></option>
100
+							<option value="ids" data-show-field="_grouped_calendars_ids" <?php selected('ids', $source, true); ?>><?php _e('Manual selection', 'google-calendar-events'); ?></option>
101
+							<option value="category" data-show-field="_grouped_calendars_category" <?php selected('category', $source, true); ?>><?php _e('Category', 'google-calendar-events'); ?></option>
102 102
 						</select>
103
-						<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Choose from which calendar feeds you want to get events from. Choose them individually or select all those belonging to calendar feed categories.', 'google-calendar-events' ); ?>"></i>
103
+						<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Choose from which calendar feeds you want to get events from. Choose them individually or select all those belonging to calendar feed categories.', 'google-calendar-events'); ?>"></i>
104 104
 						<br><br>
105 105
 						<?php
106 106
 
107
-						$cals = simcal_get_calendars( $post_id );
108
-						$meta = get_post_meta( $post_id, '_grouped_calendars_ids', true );
109
-						$ids  = $meta && is_array( $meta ) ? implode( ',', array_map( 'absint', $meta ) ) : absint( $meta );
107
+						$cals = simcal_get_calendars($post_id);
108
+						$meta = get_post_meta($post_id, '_grouped_calendars_ids', true);
109
+						$ids  = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : absint($meta);
110 110
 
111
-						simcal_print_field( array(
111
+						simcal_print_field(array(
112 112
 							'type'        => 'select',
113 113
 							'multiselect' => 'multiselect',
114 114
 							'name'        => '_grouped_calendars_ids',
@@ -116,25 +116,25 @@  discard block
 block discarded – undo
116 116
 							'value'       => $ids !== 0 ? $ids : '',
117 117
 							'options'     => $cals,
118 118
 							'enhanced'    => 'enhanced',
119
-							'style'       => 'ids' == $source ? '' : array( 'display' => 'none' ),
119
+							'style'       => 'ids' == $source ? '' : array('display' => 'none'),
120 120
 							'attributes'  => array(
121
-								'data-noresults' => __( 'No results found.', 'google-calendar-events' ),
121
+								'data-noresults' => __('No results found.', 'google-calendar-events'),
122 122
 							),
123 123
 						));
124 124
 
125
-						$meta = get_post_meta( $post_id, '_grouped_calendars_category', true );
126
-						$category = $meta && is_array( $meta ) ? implode( ',', array_map( 'absint', $meta ) ): '';
125
+						$meta = get_post_meta($post_id, '_grouped_calendars_category', true);
126
+						$category = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : '';
127 127
 
128
-						$terms = get_terms( 'calendar_category' );
128
+						$terms = get_terms('calendar_category');
129 129
 
130
-						if ( ! empty( $terms ) ) {
130
+						if ( ! empty($terms)) {
131 131
 
132 132
 							$categories = array();
133
-							foreach ( $terms as $term ) {
134
-								$categories[ $term->term_id ] = $term->name;
133
+							foreach ($terms as $term) {
134
+								$categories[$term->term_id] = $term->name;
135 135
 							}
136 136
 
137
-							simcal_print_field( array(
137
+							simcal_print_field(array(
138 138
 								'type'        => 'select',
139 139
 								'multiselect' => 'multiselect',
140 140
 								'name'        => '_grouped_calendars_category',
@@ -142,17 +142,17 @@  discard block
 block discarded – undo
142 142
 								'value'       => $category,
143 143
 								'options'     => $categories,
144 144
 								'enhanced'    => 'enhanced',
145
-								'style'       => 'category' == $source ? '' : array( 'display' => 'none' ),
145
+								'style'       => 'category' == $source ? '' : array('display' => 'none'),
146 146
 								'attributes'  => array(
147
-									'data-noresults' => __( 'No results found.', 'google-calendar-events' ),
147
+									'data-noresults' => __('No results found.', 'google-calendar-events'),
148 148
 								),
149
-							) );
149
+							));
150 150
 
151 151
 						} else {
152 152
 
153 153
 							$style = 'category' == $source ? '' : 'display: none;';
154 154
 							$style .= ' width: 100%; max-width: 500px';
155
-							echo '<input type="text" disabled="disabled" name="_grouped_calendars_category" id="_grouped_calendars_category" style="' . $style . '" placeholder="' . __( 'There are no calendar categories yet.', 'google-calendar-events' ) . '" />';
155
+							echo '<input type="text" disabled="disabled" name="_grouped_calendars_category" id="_grouped_calendars_category" style="'.$style.'" placeholder="'.__('There are no calendar categories yet.', 'google-calendar-events').'" />';
156 156
 
157 157
 						}
158 158
 
@@ -173,16 +173,16 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @param int $post_id
175 175
 	 */
176
-	public function process_meta( $post_id ) {
176
+	public function process_meta($post_id) {
177 177
 
178
-		$source = isset( $_POST['_grouped_calendars_source'] ) ? sanitize_key( $_POST['_grouped_calendars_source'] ) : 'ids';
179
-		update_post_meta( $post_id, '_grouped_calendars_source', $source );
178
+		$source = isset($_POST['_grouped_calendars_source']) ? sanitize_key($_POST['_grouped_calendars_source']) : 'ids';
179
+		update_post_meta($post_id, '_grouped_calendars_source', $source);
180 180
 
181
-		$ids = isset( $_POST['_grouped_calendars_ids'] ) ? array_map( 'absint', $_POST['_grouped_calendars_ids'] ) : '';
182
-		update_post_meta( $post_id, '_grouped_calendars_ids', $ids );
181
+		$ids = isset($_POST['_grouped_calendars_ids']) ? array_map('absint', $_POST['_grouped_calendars_ids']) : '';
182
+		update_post_meta($post_id, '_grouped_calendars_ids', $ids);
183 183
 
184
-		$category = isset( $_POST['_grouped_calendars_category'] ) ? array_map( 'absint', $_POST['_grouped_calendars_category'] ) : '';
185
-		update_post_meta( $post_id, '_grouped_calendars_category', $category );
184
+		$category = isset($_POST['_grouped_calendars_category']) ? array_map('absint', $_POST['_grouped_calendars_category']) : '';
185
+		update_post_meta($post_id, '_grouped_calendars_category', $category);
186 186
 
187 187
 	}
188 188
 
Please login to merge, or discard this patch.
includes/functions/admin.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @package SimpleCalendar/Admin/Functions
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @return null|\SimpleCalendar\Abstracts\Admin_Page
34 34
  */
35
-function simcal_get_admin_page( $page ) {
35
+function simcal_get_admin_page($page) {
36 36
 	$objects = \SimpleCalendar\plugin()->objects;
37
-	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page( $page ) : null;
37
+	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page($page) : null;
38 38
 }
39 39
 
40 40
 /**
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
  *
48 48
  * @return null|\SimpleCalendar\Abstracts\Field
49 49
  */
50
-function simcal_get_field( $args, $name = '' ) {
50
+function simcal_get_field($args, $name = '') {
51 51
 	$objects = \SimpleCalendar\plugin()->objects;
52
-	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field( $args, $name ) : null;
52
+	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field($args, $name) : null;
53 53
 }
54 54
 
55 55
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
  *
63 63
  * @return void
64 64
  */
65
-function simcal_print_field( $args, $name = '' ) {
65
+function simcal_print_field($args, $name = '') {
66 66
 
67
-	$field = simcal_get_field( $args, $name );
67
+	$field = simcal_get_field($args, $name);
68 68
 
69
-	if ( $field instanceof \SimpleCalendar\Abstracts\Field ) {
69
+	if ($field instanceof \SimpleCalendar\Abstracts\Field) {
70 70
 		$field->html();
71 71
 	}
72 72
 }
@@ -80,50 +80,50 @@  discard block
 block discarded – undo
80 80
  *
81 81
  * @return bool
82 82
  */
83
-function simcal_delete_feed_transients( $id = '' ) {
83
+function simcal_delete_feed_transients($id = '') {
84 84
 
85
-	if ( is_numeric( $id ) ) {
86
-		$id = intval( $id ) > 0 ? absint( $id ) : simcal_get_calendars();
87
-	} elseif ( $id instanceof WP_Post ) {
85
+	if (is_numeric($id)) {
86
+		$id = intval($id) > 0 ? absint($id) : simcal_get_calendars();
87
+	} elseif ($id instanceof WP_Post) {
88 88
 		$id = $id->ID;
89
-	} elseif ( is_array( $id ) ) {
90
-		$id = array_map( 'absint', $id );
89
+	} elseif (is_array($id)) {
90
+		$id = array_map('absint', $id);
91 91
 	} else {
92
-		$id = simcal_get_calendars( '', true );
92
+		$id = simcal_get_calendars('', true);
93 93
 	}
94 94
 
95 95
 	$feed_types = simcal_get_feed_types();
96 96
 
97
-	if ( is_array( $id ) ) {
97
+	if (is_array($id)) {
98 98
 
99
-		$posts = get_posts( array(
99
+		$posts = get_posts(array(
100 100
 			'post_type' => 'calendar',
101 101
 			'fields'    => 'ids',
102 102
 			'post__in'  => $id,
103 103
 			'nopaging'  => true,
104
-		) );
104
+		));
105 105
 
106
-		foreach ( $posts as $post ) {
107
-			$calendar = simcal_get_calendar( $post );
108
-			if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) {
109
-				foreach ( $feed_types as $feed_type ) {
110
-					delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type );
106
+		foreach ($posts as $post) {
107
+			$calendar = simcal_get_calendar($post);
108
+			if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) {
109
+				foreach ($feed_types as $feed_type) {
110
+					delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type);
111 111
 				}
112 112
 			}
113 113
 		}
114 114
 
115 115
 	} else {
116 116
 
117
-		$post = get_post( $id );
118
-		$calendar = simcal_get_calendar( $post );
119
-		if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) {
120
-			foreach ( $feed_types as $feed_type ) {
121
-				delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type );
117
+		$post = get_post($id);
118
+		$calendar = simcal_get_calendar($post);
119
+		if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) {
120
+			foreach ($feed_types as $feed_type) {
121
+				delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type);
122 122
 			}
123 123
 		}
124 124
 	}
125 125
 
126
-	return delete_transient( '_simple-calendar_feed_ids' );
126
+	return delete_transient('_simple-calendar_feed_ids');
127 127
 }
128 128
 
129 129
 /**
@@ -139,33 +139,33 @@  discard block
 block discarded – undo
139 139
  *
140 140
  * @return array|string Sanitized variable
141 141
  */
142
-function simcal_sanitize_input( $var, $func = 'sanitize_text_field'  ) {
142
+function simcal_sanitize_input($var, $func = 'sanitize_text_field') {
143 143
 
144
-	if ( is_null( $var ) ) {
144
+	if (is_null($var)) {
145 145
 		return '';
146 146
 	}
147 147
 
148
-	if ( is_bool( $var ) ) {
149
-		if ( $var === true ) {
148
+	if (is_bool($var)) {
149
+		if ($var === true) {
150 150
 			return 'yes';
151 151
 		} else {
152 152
 			return 'no';
153 153
 		}
154 154
 	}
155 155
 
156
-	if ( is_string( $var ) || is_numeric( $var ) ) {
157
-		$func = is_string( $func ) && function_exists( $func ) ? $func : 'sanitize_text_field';
158
-		return call_user_func( $func, trim( strval( $var ) ) );
156
+	if (is_string($var) || is_numeric($var)) {
157
+		$func = is_string($func) && function_exists($func) ? $func : 'sanitize_text_field';
158
+		return call_user_func($func, trim(strval($var)));
159 159
 	}
160 160
 
161
-	if ( is_object( $var ) ) {
161
+	if (is_object($var)) {
162 162
 		$var = (array) $var;
163 163
 	}
164 164
 
165
-	if ( is_array( $var ) ) {
165
+	if (is_array($var)) {
166 166
 		$array = array();
167
-		foreach ( $var as $k => $v ) {
168
-			$array[ $k ] = simcal_sanitize_input( $v );
167
+		foreach ($var as $k => $v) {
168
+			$array[$k] = simcal_sanitize_input($v);
169 169
 		}
170 170
 		return $array;
171 171
 	}
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
  */
184 184
 function simcal_is_admin_screen() {
185 185
 
186
-	$view = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
186
+	$view = function_exists('get_current_screen') ? get_current_screen() : false;
187 187
 
188
-	if ( $view instanceof WP_Screen ) {
188
+	if ($view instanceof WP_Screen) {
189 189
 
190 190
 		// Screens used by this plugin.
191 191
 		$screens = array(
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			'dashboard_page_simple-calendar_credits',
201 201
 			'dashboard_page_simple-calendar_translators',
202 202
 		);
203
-		if ( in_array( $view->id, $screens ) ) {
203
+		if (in_array($view->id, $screens)) {
204 204
 			return $view->id;
205 205
 		}
206 206
 	}
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
  *
220 220
  * @return \SimpleCalendar\Admin\Updater
221 221
  */
222
-function simcal_addon_updater( $_api_url, $_plugin_file, $_api_data = null ) {
223
-	return new \SimpleCalendar\Admin\Updater( $_api_url, $_plugin_file, $_api_data );
222
+function simcal_addon_updater($_api_url, $_plugin_file, $_api_data = null) {
223
+	return new \SimpleCalendar\Admin\Updater($_api_url, $_plugin_file, $_api_data);
224 224
 }
225 225
 
226 226
 /**
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
  *
233 233
  * @return null|string
234 234
  */
235
-function simcal_get_license_key( $addon ) {
236
-	$licenses = get_option( 'simple-calendar_settings_licenses', array() );
237
-	if ( isset( $licenses['keys'][ $addon ] ) ) {
238
-		return empty( $licenses['keys'][ $addon ] ) ? null : $licenses['keys'][ $addon ];
235
+function simcal_get_license_key($addon) {
236
+	$licenses = get_option('simple-calendar_settings_licenses', array());
237
+	if (isset($licenses['keys'][$addon])) {
238
+		return empty($licenses['keys'][$addon]) ? null : $licenses['keys'][$addon];
239 239
 	}
240 240
 	return null;
241 241
 }
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
  *
252 252
  * @return array|string
253 253
  */
254
-function simcal_get_license_status( $addon = null ) {
255
-	$licenses = get_option( 'simple-calendar_licenses_status', array() );
256
-	return isset( $licenses[ $addon ] ) ? $licenses[ $addon ] : $licenses;
254
+function simcal_get_license_status($addon = null) {
255
+	$licenses = get_option('simple-calendar_licenses_status', array());
256
+	return isset($licenses[$addon]) ? $licenses[$addon] : $licenses;
257 257
 }
258 258
 
259 259
 /**
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
  * @since 3.0.0
275 275
  */
276 276
 function simcal_delete_admin_notices() {
277
-	delete_option( 'simple-calendar_admin_notices' );
277
+	delete_option('simple-calendar_admin_notices');
278 278
 }
279 279
 
280 280
 /**
@@ -286,22 +286,22 @@  discard block
 block discarded – undo
286 286
  *
287 287
  * @return void
288 288
  */
289
-function simcal_print_shortcode_tip( $post_id ) {
289
+function simcal_print_shortcode_tip($post_id) {
290 290
 
291 291
 	$browser = new \Browser();
292
-	if ( $browser::PLATFORM_APPLE == $browser->getPlatform() ) {
292
+	if ($browser::PLATFORM_APPLE == $browser->getPlatform()) {
293 293
 		$cmd = '&#8984;&#43;C';
294 294
 	} else {
295 295
 		$cmd = 'Ctrl&#43;C';
296 296
 	}
297 297
 
298
-	$shortcut  = sprintf( __( 'Press %s to copy.', 'google-calendar-events' ), $cmd );
299
-	$shortcode = sprintf( '[calendar id="%s"]', $post_id );
298
+	$shortcut  = sprintf(__('Press %s to copy.', 'google-calendar-events'), $cmd);
299
+	$shortcode = sprintf('[calendar id="%s"]', $post_id);
300 300
 
301
-	echo "<input readonly='readonly' " .
302
-				"class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' " .
303
-				"title='" . $shortcut . "' " .
304
-				"onclick='this.select();' value='" . $shortcode . "' />";
301
+	echo "<input readonly='readonly' ".
302
+				"class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' ".
303
+				"title='".$shortcut."' ".
304
+				"onclick='this.select();' value='".$shortcode."' />";
305 305
 }
306 306
 
307 307
 /**
@@ -316,20 +316,20 @@  discard block
 block discarded – undo
316 316
  *
317 317
  * @return  string  $url        Full Google Analytics campaign URL
318 318
  */
319
-function simcal_ga_campaign_url( $base_url, $campaign, $content, $raw = false ) {
319
+function simcal_ga_campaign_url($base_url, $campaign, $content, $raw = false) {
320 320
 
321
-	$url = add_query_arg( array(
321
+	$url = add_query_arg(array(
322 322
 		'utm_source'   => 'inside-plugin',
323 323
 		'utm_medium'   => 'link',
324 324
 		'utm_campaign' => $campaign, // i.e. 'core-plugin', 'gcal-pro'
325 325
 		'utm_content'  => $content // i.e. 'sidebar-link', 'settings-link'
326
-	), $base_url );
326
+	), $base_url);
327 327
 
328
-	if ( $raw ) {
329
-		return esc_url_raw( $url );
328
+	if ($raw) {
329
+		return esc_url_raw($url);
330 330
 	}
331 331
 
332
-	return esc_url( $url );
332
+	return esc_url($url);
333 333
 }
334 334
 
335 335
 /**
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
  */
342 342
 function simcal_newsletter_signup() {
343 343
 
344
-	if ( $screen = simcal_is_admin_screen() ) {
344
+	if ($screen = simcal_is_admin_screen()) {
345 345
 
346 346
 		global $current_user;
347 347
 		get_currentuserinfo();
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
 		<div id="simcal-drip" class="<?php echo $screen; ?>">
353 353
 			<div class="signup">
354 354
 				<p>
355
-					<?php _e( "Enter your name and email and we'll send you a coupon code for 20% off our Google Calendar Pro add-on.", 'google-calendar-events' ); ?>
355
+					<?php _e("Enter your name and email and we'll send you a coupon code for 20% off our Google Calendar Pro add-on.", 'google-calendar-events'); ?>
356 356
 				</p>
357 357
 
358 358
 				<p>
359
-					<label for="simcal-drip-field-email"><?php _e( 'Your Email', 'google-calendar-events' ); ?></label><br />
359
+					<label for="simcal-drip-field-email"><?php _e('Your Email', 'google-calendar-events'); ?></label><br />
360 360
 					<input type="email"
361 361
 					       id="simcal-drip-field-email"
362 362
 					       name="fields[email]"
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 				</p>
365 365
 
366 366
 				<p>
367
-					<label for="simcal-drip-field-first_name"><?php _e( 'First Name', 'google-calendar-events' ); ?></label><br />
367
+					<label for="simcal-drip-field-first_name"><?php _e('First Name', 'google-calendar-events'); ?></label><br />
368 368
 					<input type="text"
369 369
 					       id="simcal-drip-field-first_name"
370 370
 					       name="fields[first_name]"
@@ -373,15 +373,15 @@  discard block
 block discarded – undo
373 373
 				<p class="textright">
374 374
 					<a href="#"
375 375
 					   id="simcal-drip-signup"
376
-					   class="button button-primary"><?php _e( 'Send me the coupon', 'google-calendar-events' ); ?></a>
376
+					   class="button button-primary"><?php _e('Send me the coupon', 'google-calendar-events'); ?></a>
377 377
 				</p>
378 378
 				<div class="textright">
379
-					<a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'sidebar-link' ); ?>"
380
-					   target="_blank"><?php _e( 'Just take me to GCal Pro', 'google-calendar-events' ); ?></a>
379
+					<a href="<?php echo simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'sidebar-link'); ?>"
380
+					   target="_blank"><?php _e('Just take me to GCal Pro', 'google-calendar-events'); ?></a>
381 381
 				</div>
382 382
 			</div>
383 383
 			<div class="thank-you" style="display: none;">
384
-				<?php _e( 'Thank you!', 'google-calendar-events' ); ?>
384
+				<?php _e('Thank you!', 'google-calendar-events'); ?>
385 385
 			</div>
386 386
 			<div class="clear">
387 387
 			</div>
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 
393 393
 }
394 394
 
395
-if ( ! function_exists( 'mb_detect_encoding' ) ) {
395
+if ( ! function_exists('mb_detect_encoding')) {
396 396
 
397 397
 	/**
398 398
 	 * Fallback function for `mb_detect_encoding()`,
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 	 *
407 407
 	 * @return bool
408 408
 	 */
409
-	function mb_detect_encoding( $string, $enc = null, $ret = null ) {
409
+	function mb_detect_encoding($string, $enc = null, $ret = null) {
410 410
 
411 411
 		static $enclist = array(
412 412
 			'UTF-8',
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
 
433 433
 		$result = false;
434 434
 
435
-		foreach ( $enclist as $item ) {
436
-			$sample = iconv( $item, $item, $string );
437
-			if ( md5( $sample ) == md5( $string ) ) {
438
-				if ( $ret === null ) {
435
+		foreach ($enclist as $item) {
436
+			$sample = iconv($item, $item, $string);
437
+			if (md5($sample) == md5($string)) {
438
+				if ($ret === null) {
439 439
 					$result = $item;
440 440
 				} else {
441 441
 					$result = true;
Please login to merge, or discard this patch.
includes/functions/deprecated.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @deprecated
9 9
  */
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -16,18 +16,18 @@  discard block
 block discarded – undo
16 16
  * Print a calendar.
17 17
  * @deprecated Use simcal_print_calendar()
18 18
  */
19
-function gce_print_calendar( $feed_ids, $display, $args  ) {
19
+function gce_print_calendar($feed_ids, $display, $args) {
20 20
 
21 21
 	$id = 0;
22 22
 
23
-	if ( is_numeric( $feed_ids ) ) {
24
-		$id = intval( $feed_ids );
25
-	} elseif ( is_array( $feed_ids ) ) {
26
-		$id = isset( $feed_ids[0] ) ? intval( $feed_ids[0] ) : '';
23
+	if (is_numeric($feed_ids)) {
24
+		$id = intval($feed_ids);
25
+	} elseif (is_array($feed_ids)) {
26
+		$id = isset($feed_ids[0]) ? intval($feed_ids[0]) : '';
27 27
 	}
28 28
 
29
-	if ( $id > 0 ) {
30
-		simcal_print_calendar( $id );
29
+	if ($id > 0) {
30
+		simcal_print_calendar($id);
31 31
 	}
32 32
 }
33 33
 
@@ -35,16 +35,16 @@  discard block
 block discarded – undo
35 35
  * Convert date from mm/dd/yyyy to unix timestamp.
36 36
  * @deprecated Assumes a US-only time format.
37 37
  */
38
-function gce_date_unix( $date = '' ) {
39
-	if ( empty( $date ) ) {
40
-		$current_time = current_time( 'timestamp' );
41
-		$timestamp = mktime( 0, 0, 0, date( 'm', $current_time ), date( 'd', $current_time ), date( 'Y', $current_time ) );
38
+function gce_date_unix($date = '') {
39
+	if (empty($date)) {
40
+		$current_time = current_time('timestamp');
41
+		$timestamp = mktime(0, 0, 0, date('m', $current_time), date('d', $current_time), date('Y', $current_time));
42 42
 	} else {
43
-		$date = explode( '/', $date );
43
+		$date = explode('/', $date);
44 44
 		$month = $date[0];
45 45
 		$day   = $date[1];
46 46
 		$year  = $date[2];
47
-		$timestamp = mktime( 0, 0, 0, $month, $day, $year );
47
+		$timestamp = mktime(0, 0, 0, $month, $day, $year);
48 48
 	}
49 49
 	return $timestamp;
50 50
 }
Please login to merge, or discard this patch.
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/installation.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Installation
4
- *
5
- * @package SimpleCalendar
6
- */
3
+	 * Installation
4
+	 *
5
+	 * @package SimpleCalendar
6
+	 */
7 7
 namespace SimpleCalendar;
8 8
 
9 9
 use SimpleCalendar\Admin\Pages;
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use SimpleCalendar\Admin\Pages;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 		self::create_terms();
35 35
 		self::create_options();
36 36
 
37
-		do_action( 'simcal_activated' );
37
+		do_action('simcal_activated');
38 38
 	}
39 39
 
40 40
 	/**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
 		flush_rewrite_rules();
48 48
 
49
-		do_action( 'simcal_deactivated' );
49
+		do_action('simcal_deactivated');
50 50
 	}
51 51
 
52 52
 	/**
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 			)
67 67
 		);
68 68
 
69
-		foreach ( $taxonomies as $taxonomy => $terms ) {
70
-			foreach ( $terms as $term ) {
71
-				if ( ! get_term_by( 'slug', sanitize_title( $term ), $taxonomy ) ) {
72
-					wp_insert_term( $term, $taxonomy );
69
+		foreach ($taxonomies as $taxonomy => $terms) {
70
+			foreach ($terms as $term) {
71
+				if ( ! get_term_by('slug', sanitize_title($term), $taxonomy)) {
72
+					wp_insert_term($term, $taxonomy);
73 73
 				}
74 74
 			}
75 75
 		}
@@ -85,33 +85,33 @@  discard block
 block discarded – undo
85 85
 
86 86
 		$default = '';
87 87
 		$page    = 'settings';
88
-		$settings_pages  = new Pages( $page );
88
+		$settings_pages  = new Pages($page);
89 89
 		$plugin_settings = $settings_pages->get_settings();
90 90
 
91
-		if ( $plugin_settings && is_array( $plugin_settings ) ) {
91
+		if ($plugin_settings && is_array($plugin_settings)) {
92 92
 
93
-			foreach ( $plugin_settings as $id => $settings ) {
93
+			foreach ($plugin_settings as $id => $settings) {
94 94
 
95
-				$group = 'simple-calendar_' . $page . '_' . $id;
95
+				$group = 'simple-calendar_'.$page.'_'.$id;
96 96
 
97
-				if ( isset( $settings['sections'] ) ) {
97
+				if (isset($settings['sections'])) {
98 98
 
99
-					if ( $settings['sections'] && is_array( $settings['sections'] ) ) {
99
+					if ($settings['sections'] && is_array($settings['sections'])) {
100 100
 
101
-						foreach ( $settings['sections'] as $section_id => $section ) {
101
+						foreach ($settings['sections'] as $section_id => $section) {
102 102
 
103
-							if ( isset( $section['fields'] ) ) {
103
+							if (isset($section['fields'])) {
104 104
 
105
-								if ( $section['fields'] && is_array( $section['fields'] ) ) {
105
+								if ($section['fields'] && is_array($section['fields'])) {
106 106
 
107
-									foreach ( $section['fields'] as $key => $field ) {
107
+									foreach ($section['fields'] as $key => $field) {
108 108
 
109
-										if ( isset ( $field['type'] ) ) {
109
+										if (isset ($field['type'])) {
110 110
 											// Maybe an associative array.
111
-											if ( is_int( $key ) ) {
112
-												$default[ $section_id ] = self::get_field_default_value( $field );
111
+											if (is_int($key)) {
112
+												$default[$section_id] = self::get_field_default_value($field);
113 113
 											} else {
114
-												$default[ $section_id ][ $key ] = self::get_field_default_value( $field );
114
+												$default[$section_id][$key] = self::get_field_default_value($field);
115 115
 											}
116 116
 										}
117 117
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
 				} // Are there sections?
129 129
 
130
-				add_option( $group, $default, '', true );
130
+				add_option($group, $default, '', true);
131 131
 
132 132
 				// Reset before looping next settings page.
133 133
 				$default = '';
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @return mixed
149 149
 	 */
150
-	private static function get_field_default_value( $field ) {
150
+	private static function get_field_default_value($field) {
151 151
 
152
-		$saved_value   = isset( $field['value'] )   ? $field['value']   : '';
153
-		$default_value = isset( $field['default'] ) ? $field['default'] : '';
152
+		$saved_value   = isset($field['value']) ? $field['value'] : '';
153
+		$default_value = isset($field['default']) ? $field['default'] : '';
154 154
 
155
-		return ! empty( $saved_value ) ? $saved_value : $default_value;
155
+		return ! empty($saved_value) ? $saved_value : $default_value;
156 156
 	}
157 157
 
158 158
 }
Please login to merge, or discard this patch.
includes/objects.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use SimpleCalendar\Abstracts as Object;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -31,27 +31,27 @@  discard block
 block discarded – undo
31 31
 	public function __construct() {
32 32
 
33 33
 		// Add default feed type.
34
-		add_filter( 'simcal_get_feed_types', function( $feed_types ) {
35
-			return array_merge( $feed_types, array(
34
+		add_filter('simcal_get_feed_types', function($feed_types) {
35
+			return array_merge($feed_types, array(
36 36
 				'google',
37 37
 				'grouped-calendars',
38
-			) );
39
-		}, 10, 1 );
38
+			));
39
+		}, 10, 1);
40 40
 
41 41
 		// Add default calendar type.
42
-		add_filter( 'simcal_get_calendar_types', function( $calendar_types ) {
43
-			return array_merge( $calendar_types, array(
42
+		add_filter('simcal_get_calendar_types', function($calendar_types) {
43
+			return array_merge($calendar_types, array(
44 44
 				'default-calendar' => array(
45 45
 					'grid',
46 46
 					'list',
47 47
 				),
48
-			) );
49
-		}, 10, 1 );
48
+			));
49
+		}, 10, 1);
50 50
 
51 51
 		// Add default admin objects.
52
-		if ( $is_admin = is_admin() ) {
53
-			add_filter( 'simcal_get_admin_pages', function( $admin_pages ) {
54
-				return array_merge( $admin_pages, array(
52
+		if ($is_admin = is_admin()) {
53
+			add_filter('simcal_get_admin_pages', function($admin_pages) {
54
+				return array_merge($admin_pages, array(
55 55
 					'add-ons' => array(
56 56
 						'add-ons',
57 57
 					),
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 					'tools' => array(
64 64
 						'system-status',
65 65
 					),
66
-				) );
67
-			}, 10, 1 );
66
+				));
67
+			}, 10, 1);
68 68
 		}
69 69
 
70
-		do_action( 'simcal_load_objects', $is_admin );
70
+		do_action('simcal_load_objects', $is_admin);
71 71
 	}
72 72
 
73 73
 	/**
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @return array
79 79
 	 */
80 80
 	public function get_feed_types() {
81
-		$array = apply_filters( 'simcal_get_feed_types', array() );
82
-		ksort( $array );
81
+		$array = apply_filters('simcal_get_feed_types', array());
82
+		ksort($array);
83 83
 		return $array;
84 84
 	}
85 85
 
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 	 * @return array
92 92
 	 */
93 93
 	public function get_calendar_types() {
94
-		$array = apply_filters( 'simcal_get_calendar_types', array() );
95
-		ksort( $array );
94
+		$array = apply_filters('simcal_get_calendar_types', array());
95
+		ksort($array);
96 96
 		return $array;
97 97
 	}
98 98
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @return array
105 105
 	 */
106 106
 	public function get_admin_pages() {
107
-		return apply_filters( 'simcal_get_admin_pages', array() );
107
+		return apply_filters('simcal_get_admin_pages', array());
108 108
 	}
109 109
 
110 110
 	/**
@@ -118,30 +118,30 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @return null|Object\Calendar
120 120
 	 */
121
-	public function get_calendar( $object ) {
121
+	public function get_calendar($object) {
122 122
 
123
-		if ( is_string( $object ) ) {
124
-			return ! empty( $object ) ? $this->get_object( $object, 'calendar', '' ) : null;
123
+		if (is_string($object)) {
124
+			return ! empty($object) ? $this->get_object($object, 'calendar', '') : null;
125 125
 		}
126 126
 
127
-		if ( is_object( $object ) ) {
128
-			if ( $object instanceof Object\Calendar ) {
129
-				return $this->get_object( $object->type, 'feed', $object );
130
-			} elseif ( $object instanceof \WP_Post ) {
131
-				if ( $type = wp_get_object_terms( $object->ID, 'calendar_type' ) ) {
132
-					$name = sanitize_title( current( $type )->name );
133
-					return $this->get_object( $name, 'calendar', $object );
127
+		if (is_object($object)) {
128
+			if ($object instanceof Object\Calendar) {
129
+				return $this->get_object($object->type, 'feed', $object);
130
+			} elseif ($object instanceof \WP_Post) {
131
+				if ($type = wp_get_object_terms($object->ID, 'calendar_type')) {
132
+					$name = sanitize_title(current($type)->name);
133
+					return $this->get_object($name, 'calendar', $object);
134 134
 				}
135
-			} elseif ( isset( $object->type ) && isset( $object->id ) ) {
136
-				return $this->get_object( $object->type, 'calendar', $object->id );
135
+			} elseif (isset($object->type) && isset($object->id)) {
136
+				return $this->get_object($object->type, 'calendar', $object->id);
137 137
 			}
138 138
 		}
139 139
 
140
-		if ( is_int( $object ) ) {
141
-			$post = get_post( $object );
142
-			if ( $post && ( $type = wp_get_object_terms( $post->ID, 'calendar_type' ) ) ) {
143
-				$name = sanitize_title( current( $type )->name );
144
-				return $this->get_object( $name, 'calendar', $post );
140
+		if (is_int($object)) {
141
+			$post = get_post($object);
142
+			if ($post && ($type = wp_get_object_terms($post->ID, 'calendar_type'))) {
143
+				$name = sanitize_title(current($type)->name);
144
+				return $this->get_object($name, 'calendar', $post);
145 145
 			}
146 146
 		}
147 147
 
@@ -158,20 +158,20 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @return null|Object\Calendar_View
160 160
 	 */
161
-	public function get_calendar_view( $id = 0, $name = '' ) {
161
+	public function get_calendar_view($id = 0, $name = '') {
162 162
 
163
-		if ( ! $name && $id > 0 ) {
163
+		if ( ! $name && $id > 0) {
164 164
 
165
-			$calendar_view = get_post_meta( $id, '_calendar_view', true );
165
+			$calendar_view = get_post_meta($id, '_calendar_view', true);
166 166
 
167
-			if ( $terms = wp_get_object_terms( $id, 'calendar_type' ) ) {
168
-				$calendar_type = sanitize_title( current( $terms )->name );
169
-				$name = isset( $calendar_view[ $calendar_type ] ) ? $calendar_type . '-' . $calendar_view[ $calendar_type ] : '';
167
+			if ($terms = wp_get_object_terms($id, 'calendar_type')) {
168
+				$calendar_type = sanitize_title(current($terms)->name);
169
+				$name = isset($calendar_view[$calendar_type]) ? $calendar_type.'-'.$calendar_view[$calendar_type] : '';
170 170
 			}
171 171
 
172 172
 		}
173 173
 
174
-		return $name ? $this->get_object( $name, 'calendar-view', '' ) : null;
174
+		return $name ? $this->get_object($name, 'calendar-view', '') : null;
175 175
 	}
176 176
 
177 177
 	/**
@@ -185,34 +185,34 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 * @return null|Object\Feed
187 187
 	 */
188
-	public function get_feed( $object ) {
188
+	public function get_feed($object) {
189 189
 
190
-		if ( is_string( $object ) ) {
191
-			return ! empty( $object ) ? $this->get_object( $object, 'feed', '' ) : null;
190
+		if (is_string($object)) {
191
+			return ! empty($object) ? $this->get_object($object, 'feed', '') : null;
192 192
 		}
193 193
 
194
-		if ( is_object( $object ) ) {
195
-			if ( $object instanceof Object\Calendar ) {
194
+		if (is_object($object)) {
195
+			if ($object instanceof Object\Calendar) {
196 196
 				$feed_name = '';
197
-				if ( empty( $object->feed ) ) {
198
-					if ( $feed_type = wp_get_object_terms( $object->id, 'feed_type' ) ) {
199
-						$feed_name = sanitize_title( current( $feed_type )->name );
197
+				if (empty($object->feed)) {
198
+					if ($feed_type = wp_get_object_terms($object->id, 'feed_type')) {
199
+						$feed_name = sanitize_title(current($feed_type)->name);
200 200
 					}
201 201
 				} else {
202 202
 					$feed_name = $object->feed;
203 203
 				}
204
-				return $this->get_object( $feed_name, 'feed', $object );
205
-			} elseif ( $object instanceof \WP_Post ) {
206
-				$calendar = $this->get_calendar( $object );
207
-				return $this->get_object( $calendar->feed, 'feed', $calendar );
208
-			} elseif ( isset( $object->feed ) && isset( $object->id ) ) {
209
-				return $this->get_object( $object->feed, 'feed', $object );
204
+				return $this->get_object($feed_name, 'feed', $object);
205
+			} elseif ($object instanceof \WP_Post) {
206
+				$calendar = $this->get_calendar($object);
207
+				return $this->get_object($calendar->feed, 'feed', $calendar);
208
+			} elseif (isset($object->feed) && isset($object->id)) {
209
+				return $this->get_object($object->feed, 'feed', $object);
210 210
 			}
211 211
 		}
212 212
 
213
-		if ( is_int( $object ) ) {
214
-			$calendar = $this->get_calendar( $object );
215
-			return isset( $calendar->feed ) ? $this->get_object( $calendar->feed, 'feed', $calendar ) : null;
213
+		if (is_int($object)) {
214
+			$calendar = $this->get_calendar($object);
215
+			return isset($calendar->feed) ? $this->get_object($calendar->feed, 'feed', $calendar) : null;
216 216
 		}
217 217
 
218 218
 		return null;
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
 	 *
229 229
 	 * @return null|Object\Field
230 230
 	 */
231
-	public function get_field( $args, $name = '' ) {
231
+	public function get_field($args, $name = '') {
232 232
 
233
-		if ( empty( $name ) ) {
234
-			$name = isset( $args['type'] ) ? $args['type'] : false;
233
+		if (empty($name)) {
234
+			$name = isset($args['type']) ? $args['type'] : false;
235 235
 		}
236 236
 
237
-		return $name ? $this->get_object( $name, 'field', $args ) : null;
237
+		return $name ? $this->get_object($name, 'field', $args) : null;
238 238
 	}
239 239
 
240 240
 	/**
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 *
247 247
 	 * @return null|Object\Admin_Page
248 248
 	 */
249
-	public function get_admin_page( $name ) {
250
-		return $name ? $this->get_object( $name, 'admin-page' ) : null;
249
+	public function get_admin_page($name) {
250
+		return $name ? $this->get_object($name, 'admin-page') : null;
251 251
 	}
252 252
 
253 253
 	/**
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 *
263 263
 	 * @return null|Object
264 264
 	 */
265
-	private function get_object( $name, $type, $args = '' ) {
265
+	private function get_object($name, $type, $args = '') {
266 266
 
267 267
 		$types = array(
268 268
 			'admin-page',
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 			'field',
273 273
 		);
274 274
 
275
-		if ( in_array( $type, $types ) ) {
275
+		if (in_array($type, $types)) {
276 276
 
277
-			$class_name = $this->make_class_name( $name, $type );
278
-			$parent     = '\\' . __NAMESPACE__ . '\Abstracts\\' . implode( '_', array_map( 'ucfirst', explode( '-', $type ) ) );
279
-			$class      = class_exists( $class_name ) ? new $class_name( $args ) : false;
277
+			$class_name = $this->make_class_name($name, $type);
278
+			$parent     = '\\'.__NAMESPACE__.'\Abstracts\\'.implode('_', array_map('ucfirst', explode('-', $type)));
279
+			$class      = class_exists($class_name) ? new $class_name($args) : false;
280 280
 
281 281
 			return $class instanceof $parent ? $class : null;
282 282
 		}
@@ -298,25 +298,25 @@  discard block
 block discarded – undo
298 298
 	 *
299 299
 	 * @return string The class name complete with its full namespace.
300 300
 	 */
301
-	private function make_class_name( $name, $type ) {
302
-
303
-		if ( 'calendar' == $type ) {
304
-			$namespace = '\\' . __NAMESPACE__ . '\Calendars\\';
305
-		} elseif ( 'calendar-view' == $type ) {
306
-			$namespace = '\\' . __NAMESPACE__ . '\Calendars\Views\\';
307
-		} elseif ( 'feed' == $type ) {
308
-			$namespace = '\\' . __NAMESPACE__ . '\Feeds\\';
309
-		} elseif ( 'field' == $type ) {
310
-			$namespace = '\\' . __NAMESPACE__ . '\Admin\Fields\\';
311
-		} elseif ( 'admin-page' == $type ) {
312
-			$namespace = '\\' . __NAMESPACE__ . '\Admin\Pages\\';
301
+	private function make_class_name($name, $type) {
302
+
303
+		if ('calendar' == $type) {
304
+			$namespace = '\\'.__NAMESPACE__.'\Calendars\\';
305
+		} elseif ('calendar-view' == $type) {
306
+			$namespace = '\\'.__NAMESPACE__.'\Calendars\Views\\';
307
+		} elseif ('feed' == $type) {
308
+			$namespace = '\\'.__NAMESPACE__.'\Feeds\\';
309
+		} elseif ('field' == $type) {
310
+			$namespace = '\\'.__NAMESPACE__.'\Admin\Fields\\';
311
+		} elseif ('admin-page' == $type) {
312
+			$namespace = '\\'.__NAMESPACE__.'\Admin\Pages\\';
313 313
 		} else {
314 314
 			return '';
315 315
 		}
316 316
 
317
-		$class_name = implode( '_', array_map( 'ucfirst', explode( '-', $name ) ) );
317
+		$class_name = implode('_', array_map('ucfirst', explode('-', $name)));
318 318
 
319
-		return $namespace . $class_name;
319
+		return $namespace.$class_name;
320 320
 	}
321 321
 
322 322
 }
Please login to merge, or discard this patch.