Completed
Push — master ( a00b53...3dc4d8 )
by
unknown
21:18
created
includes/admin/updater.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
 	 * @param string $_plugin_file Path to the plugin file.
63 63
 	 * @param array  $_api_data    Optional data to send with API calls.
64 64
 	 */
65
-	public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
65
+	public function __construct($_api_url, $_plugin_file, $_api_data = null) {
66 66
 
67
-		$this->api_url  = trailingslashit( $_api_url );
67
+		$this->api_url  = trailingslashit($_api_url);
68 68
 		$this->api_data = $_api_data;
69
-		$this->name     = plugin_basename( $_plugin_file );
70
-		$this->slug     = basename( $_plugin_file, '.php' );
69
+		$this->name     = plugin_basename($_plugin_file);
70
+		$this->slug     = basename($_plugin_file, '.php');
71 71
 		$this->version  = $_api_data['version'];
72 72
 
73 73
 		// Set up hooks.
74 74
 		$this->init();
75
-		add_action( 'admin_init', array( $this, 'show_changelog' ) );
75
+		add_action('admin_init', array($this, 'show_changelog'));
76 76
 	}
77 77
 
78 78
 	/**
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 	 * @return void
84 84
 	 */
85 85
 	public function init() {
86
-		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
87
-		add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
88
-		remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
89
-		add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
86
+		add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
87
+		add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3);
88
+		remove_action('after_plugin_row_'.$this->name, 'wp_plugin_update_row', 10);
89
+		add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2);
90 90
 	}
91 91
 
92 92
 	/**
@@ -103,30 +103,30 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return array|\stdClass Modified update array with custom plugin data.
105 105
 	 */
106
-	public function check_update( $_transient_data ) {
106
+	public function check_update($_transient_data) {
107 107
 
108 108
 		global $pagenow;
109 109
 
110
-		if ( ! is_object( $_transient_data ) ) {
110
+		if ( ! is_object($_transient_data)) {
111 111
 			$_transient_data = new \stdClass();
112 112
 		}
113 113
 
114
-		if ( 'plugins.php' == $pagenow && is_multisite() ) {
114
+		if ('plugins.php' == $pagenow && is_multisite()) {
115 115
 			return $_transient_data;
116 116
 		}
117 117
 
118
-		if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
118
+		if (empty($_transient_data->response) || empty($_transient_data->response[$this->name])) {
119 119
 
120
-			$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
120
+			$version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
121 121
 
122
-			if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
122
+			if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) {
123 123
 
124
-				if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
125
-					$_transient_data->response[ $this->name ] = $version_info;
124
+				if (version_compare($this->version, $version_info->new_version, '<')) {
125
+					$_transient_data->response[$this->name] = $version_info;
126 126
 				}
127 127
 
128 128
 				$_transient_data->last_checked = time();
129
-				$_transient_data->checked[ $this->name ] = $this->version;
129
+				$_transient_data->checked[$this->name] = $this->version;
130 130
 			}
131 131
 
132 132
 		}
@@ -144,81 +144,81 @@  discard block
 block discarded – undo
144 144
 	 * @param string $file
145 145
 	 * @param array  $plugin
146 146
 	 */
147
-	public function show_update_notification( $file, $plugin ) {
147
+	public function show_update_notification($file, $plugin) {
148 148
 
149
-		if ( ! current_user_can( 'update_plugins' ) ) {
149
+		if ( ! current_user_can('update_plugins')) {
150 150
 			return;
151 151
 		}
152 152
 
153
-		if ( ! is_multisite() ) {
153
+		if ( ! is_multisite()) {
154 154
 			return;
155 155
 		}
156 156
 
157
-		if ( $this->name != $file ) {
157
+		if ($this->name != $file) {
158 158
 			return;
159 159
 		}
160 160
 
161 161
 		// Remove our filter on the site transient
162
-		remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
162
+		remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10);
163 163
 
164
-		$update_cache = get_site_transient( 'update_plugins' );
164
+		$update_cache = get_site_transient('update_plugins');
165 165
 
166
-		if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
166
+		if ( ! is_object($update_cache) || empty($update_cache->response) || empty($update_cache->response[$this->name])) {
167 167
 
168
-			$cache_key    = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
169
-			$version_info = get_transient( $cache_key );
168
+			$cache_key    = md5('edd_plugin_'.sanitize_key($this->name).'_version_info');
169
+			$version_info = get_transient($cache_key);
170 170
 
171
-			if ( false === $version_info ) {
171
+			if (false === $version_info) {
172 172
 
173
-				$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
173
+				$version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
174 174
 
175
-				set_transient( $cache_key, $version_info, 3600 );
175
+				set_transient($cache_key, $version_info, 3600);
176 176
 			}
177 177
 
178
-			if ( ! is_object( $version_info ) ) {
178
+			if ( ! is_object($version_info)) {
179 179
 				return;
180 180
 			}
181 181
 
182
-			if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
183
-				$update_cache->response[ $this->name ] = $version_info;
182
+			if (version_compare($this->version, $version_info->new_version, '<')) {
183
+				$update_cache->response[$this->name] = $version_info;
184 184
 			}
185 185
 
186 186
 			$update_cache->last_checked = time();
187
-			$update_cache->checked[ $this->name ] = $this->version;
187
+			$update_cache->checked[$this->name] = $this->version;
188 188
 
189
-			set_site_transient( 'update_plugins', $update_cache );
189
+			set_site_transient('update_plugins', $update_cache);
190 190
 
191 191
 		} else {
192 192
 
193
-			$version_info = $update_cache->response[ $this->name ];
193
+			$version_info = $update_cache->response[$this->name];
194 194
 
195 195
 		}
196 196
 
197 197
 		// Restore our filter
198
-		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
198
+		add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
199 199
 
200
-		if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
200
+		if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) {
201 201
 
202 202
 			// build a plugin list row, with update notification
203
-			$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
204
-			echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
203
+			$wp_list_table = _get_list_table('WP_Plugins_List_Table');
204
+			echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">';
205 205
 
206
-			$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
206
+			$changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911');
207 207
 
208
-			if ( empty( $version_info->download_link ) ) {
208
+			if (empty($version_info->download_link)) {
209 209
 				printf(
210
-					__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'google-calendar-events' ),
211
-					esc_html( $version_info->name ),
212
-					esc_url( $changelog_link ),
213
-					esc_html( $version_info->new_version )
210
+					__('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'google-calendar-events'),
211
+					esc_html($version_info->name),
212
+					esc_url($changelog_link),
213
+					esc_html($version_info->new_version)
214 214
 				);
215 215
 			} else {
216 216
 				printf(
217
-					__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'google-calendar-events' ),
218
-					esc_html( $version_info->name ),
219
-					esc_url( $changelog_link ),
220
-					esc_html( $version_info->new_version ),
221
-					esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
217
+					__('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'google-calendar-events'),
218
+					esc_html($version_info->name),
219
+					esc_url($changelog_link),
220
+					esc_html($version_info->new_version),
221
+					esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name))
222 222
 				);
223 223
 			}
224 224
 
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @return object
240 240
 	 */
241
-	public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
241
+	public function plugins_api_filter($_data, $_action = '', $_args = null) {
242 242
 
243
-		if ( 'plugin_information' != $_action ) {
243
+		if ('plugin_information' != $_action) {
244 244
 			return $_data;
245 245
 		}
246 246
 
247
-		if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
247
+		if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) {
248 248
 			return $_data;
249 249
 		}
250 250
 
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 			),
258 258
 		);
259 259
 
260
-		$api_response = $this->api_request( 'plugin_information', $to_send );
260
+		$api_response = $this->api_request('plugin_information', $to_send);
261 261
 
262
-		if ( false !== $api_response ) {
262
+		if (false !== $api_response) {
263 263
 			$_data = $api_response;
264 264
 		}
265 265
 
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 	 * @param  string $url
277 277
 	 * @return object|array $array
278 278
 	 */
279
-	public function http_request_args( $args, $url ) {
279
+	public function http_request_args($args, $url) {
280 280
 		// If it is an https request and we are performing a package download, disable ssl verification
281
-		if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
281
+		if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) {
282 282
 			$args['sslverify'] = false;
283 283
 		}
284 284
 		return $args;
@@ -293,42 +293,42 @@  discard block
 block discarded – undo
293 293
 	 * @param  array  $_data   Parameters for the API action.
294 294
 	 * @return false|object
295 295
 	 */
296
-	private function api_request( $_action, $_data ) {
296
+	private function api_request($_action, $_data) {
297 297
 
298 298
 		global $wp_version;
299 299
 
300
-		$data = array_merge( $this->api_data, $_data );
300
+		$data = array_merge($this->api_data, $_data);
301 301
 
302
-		if ( $data['slug'] != $this->slug ) {
302
+		if ($data['slug'] != $this->slug) {
303 303
 			return;
304 304
 		}
305 305
 
306
-		if ( empty( $data['license'] ) ) {
306
+		if (empty($data['license'])) {
307 307
 			return;
308 308
 		}
309 309
 
310
-		if ( $this->api_url == home_url() ) {
310
+		if ($this->api_url == home_url()) {
311 311
 			return false; // Don't allow a plugin to ping itself
312 312
 		}
313 313
 
314 314
 		$api_params = array(
315 315
 			'edd_action' => 'get_version',
316 316
 			'license'    => $data['license'],
317
-			'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
318
-			'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
317
+			'item_name'  => isset($data['item_name']) ? $data['item_name'] : false,
318
+			'item_id'    => isset($data['item_id']) ? $data['item_id'] : false,
319 319
 			'slug'       => $data['slug'],
320 320
 			'author'     => $data['author'],
321 321
 			'url'        => home_url()
322 322
 		);
323 323
 
324
-		$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
324
+		$request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
325 325
 
326
-		if ( ! is_wp_error( $request ) ) {
327
-			$request = json_decode( wp_remote_retrieve_body( $request ) );
326
+		if ( ! is_wp_error($request)) {
327
+			$request = json_decode(wp_remote_retrieve_body($request));
328 328
 		}
329 329
 
330
-		if ( $request && isset( $request->sections ) ) {
331
-			$request->sections = maybe_unserialize( $request->sections );
330
+		if ($request && isset($request->sections)) {
331
+			$request->sections = maybe_unserialize($request->sections);
332 332
 		} else {
333 333
 			$request = false;
334 334
 		}
@@ -343,26 +343,26 @@  discard block
 block discarded – undo
343 343
 	 */
344 344
 	public function show_changelog() {
345 345
 
346
-		if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
346
+		if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) {
347 347
 			return;
348 348
 		}
349 349
 
350
-		if ( empty( $_REQUEST['plugin'] ) ) {
350
+		if (empty($_REQUEST['plugin'])) {
351 351
 			return;
352 352
 		}
353 353
 
354
-		if ( empty( $_REQUEST['slug'] ) ) {
354
+		if (empty($_REQUEST['slug'])) {
355 355
 			return;
356 356
 		}
357 357
 
358
-		if ( ! current_user_can( 'update_plugins' ) ) {
359
-			wp_die( __( 'You do not have permission to install plugin updates', 'google-calendar-events' ), __( 'Error', 'google-calendar-events' ), array( 'response' => 403 ) );
358
+		if ( ! current_user_can('update_plugins')) {
359
+			wp_die(__('You do not have permission to install plugin updates', 'google-calendar-events'), __('Error', 'google-calendar-events'), array('response' => 403));
360 360
 		}
361 361
 
362
-		$response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
362
+		$response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug']));
363 363
 
364
-		if ( $response && isset( $response->sections['changelog'] ) ) {
365
-			echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
364
+		if ($response && isset($response->sections['changelog'])) {
365
+			echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>';
366 366
 		}
367 367
 
368 368
 		exit;
Please login to merge, or discard this patch.
includes/ajax.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use SimpleCalendar\Abstracts\Calendar_View;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @since 3.0.0
26 26
 	 */
27 27
 	public function __construct() {
28
-		add_action( 'init', array( $this, 'add_callbacks' ), 100 );
28
+		add_action('init', array($this, 'add_callbacks'), 100);
29 29
 	}
30 30
 
31 31
 	/**
@@ -37,19 +37,19 @@  discard block
 block discarded – undo
37 37
 
38 38
 		$calendars = simcal_get_calendar_types();
39 39
 
40
-		foreach ( $calendars as $calendar => $views ) {
40
+		foreach ($calendars as $calendar => $views) {
41 41
 
42
-			foreach ( $views as $view ) {
42
+			foreach ($views as $view) {
43 43
 
44
-				$the_view = simcal_get_calendar_view( 0, $calendar . '-' . $view );
44
+				$the_view = simcal_get_calendar_view(0, $calendar.'-'.$view);
45 45
 
46
-				if ( $the_view instanceof Calendar_View ) {
46
+				if ($the_view instanceof Calendar_View) {
47 47
 					$the_view->add_ajax_actions();
48 48
 				}
49 49
 			}
50 50
 		}
51 51
 
52
-		do_action( 'simcal_add_ajax_callbacks' );
52
+		do_action('simcal_add_ajax_callbacks');
53 53
 	}
54 54
 
55 55
 }
Please login to merge, or discard this patch.
includes/autoload.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,11 +5,11 @@  discard block
 block discarded – undo
5 5
  * @package SimpleCalendar
6 6
  */
7 7
 
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if ( ! defined('ABSPATH')) {
9 9
 	exit;
10 10
 }
11 11
 
12
-if ( ! function_exists( 'SimpleCalendar_Autoload' ) ) {
12
+if ( ! function_exists('SimpleCalendar_Autoload')) {
13 13
 
14 14
 	/**
15 15
 	 * Plugin autoloader.
@@ -22,31 +22,31 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param $class
24 24
 	 */
25
-	function SimpleCalendar_Autoload( $class ) {
25
+	function SimpleCalendar_Autoload($class) {
26 26
 
27 27
 		// Do not load unless in plugin domain.
28 28
 		$namespace = 'SimpleCalendar';
29
-		if ( strpos( $class, $namespace ) !== 0 ) {
29
+		if (strpos($class, $namespace) !== 0) {
30 30
 			return;
31 31
 		}
32 32
 
33 33
 		// Converts Class_Name (class convention) to class-name (file convention).
34
-		$class_name = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( $class ) ) ) );
34
+		$class_name = implode('-', array_map('lcfirst', explode('_', strtolower($class))));
35 35
 
36 36
 		// Remove the root namespace.
37
-		$unprefixed = substr( $class_name, strlen( $namespace ) );
37
+		$unprefixed = substr($class_name, strlen($namespace));
38 38
 
39 39
 		// Build the file path.
40
-		$file_path = str_replace( '\\', DIRECTORY_SEPARATOR, $unprefixed );
41
-		$file      = dirname( __FILE__ ) . '/' . $file_path . '.php';
40
+		$file_path = str_replace('\\', DIRECTORY_SEPARATOR, $unprefixed);
41
+		$file      = dirname(__FILE__).'/'.$file_path.'.php';
42 42
 
43
-		if ( file_exists( $file ) ) {
43
+		if (file_exists($file)) {
44 44
 			require $file;
45 45
 		}
46 46
 
47 47
 	}
48 48
 
49 49
 	// Register the autoloader.
50
-	spl_autoload_register( 'SimpleCalendar_Autoload' );
50
+	spl_autoload_register('SimpleCalendar_Autoload');
51 51
 
52 52
 }
Please login to merge, or discard this patch.
includes/calendars/views/default-calendar-grid.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -453,10 +453,12 @@
 block discarded – undo
453 453
 					$list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>';
454 454
 				endif;
455 455
 
456
-			else :
456
+			else {
457
+				:
457 458
 
458 459
 				// Empty cell for day with no events.
459 460
 				$list_events = '<span class="simcal-no-events"></span>';
461
+			}
460 462
 
461 463
 			endif;
462 464
 
Please login to merge, or discard this patch.
Spacing   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use SimpleCalendar\Events\Event;
14 14
 use SimpleCalendar\Calendars\Default_Calendar;
15 15
 
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @param string|Calendar $calendar
57 57
 	 */
58
-	public function __construct( $calendar = '' ) {
58
+	public function __construct($calendar = '') {
59 59
 		$this->calendar = $calendar;
60 60
 	}
61 61
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return string
90 90
 	 */
91 91
 	public function get_name() {
92
-		return __( 'Grid', 'google-calendar-events' );
92
+		return __('Grid', 'google-calendar-events');
93 93
 	}
94 94
 
95 95
 	/**
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 * @since 3.0.0
99 99
 	 */
100 100
 	public function add_ajax_actions() {
101
-		add_action( 'wp_ajax_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) );
102
-		add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) );
101
+		add_action('wp_ajax_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax'));
102
+		add_action('wp_ajax_nopriv_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax'));
103 103
 	}
104 104
 
105 105
 	/**
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return array
115 115
 	 */
116
-	public function scripts( $min = '' ) {
116
+	public function scripts($min = '') {
117 117
 		return array(
118 118
 			'simcal-qtip' => array(
119
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js',
120
-				'deps'      => array( 'jquery' ),
119
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js',
120
+				'deps'      => array('jquery'),
121 121
 				'ver'       => '2.2.1',
122 122
 				'in_footer' => true,
123 123
 			),
124 124
 			'simcal-default-calendar' => array(
125
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js',
125
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js',
126 126
 				'deps'      => array(
127 127
 					'jquery',
128 128
 					'simcal-qtip',
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @return array
149 149
 	 */
150
-	public function styles( $min = '' ) {
150
+	public function styles($min = '') {
151 151
 		return array(
152 152
 			'simcal-qtip' => array(
153
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/vendor/qtip' . $min . '.css',
153
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/vendor/qtip'.$min.'.css',
154 154
 				'ver'   => '2.2.1',
155 155
 				'media' => 'all',
156 156
 			),
157 157
 			'simcal-default-calendar-grid' => array(
158
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-grid' . $min . '.css',
158
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-grid'.$min.'.css',
159 159
 				'deps'  => array(
160 160
 					'simcal-qtip',
161 161
 				),
@@ -174,16 +174,16 @@  discard block
 block discarded – undo
174 174
 
175 175
 		$calendar = $this->calendar;
176 176
 
177
-		if ( $calendar instanceof Default_Calendar ) {
177
+		if ($calendar instanceof Default_Calendar) {
178 178
 
179 179
 			?>
180 180
 			<table class="simcal-calendar-grid"
181 181
 			       data-event-bubble-trigger="<?php echo $calendar->event_bubble_trigger; ?>">
182 182
 				<thead class="simcal-calendar-head">
183 183
 					<tr>
184
-						<?php if ( ! $calendar->static ) { ?>
184
+						<?php if ( ! $calendar->static) { ?>
185 185
 							<th class="simcal-nav simcal-prev-wrapper" colspan="1">
186
-								<button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e( 'Previous Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-left"></i></button>
186
+								<button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e('Previous Month', 'google-calendar-events'); ?>"><i class="simcal-icon-left"></i></button>
187 187
 							</th>
188 188
 						<?php } ?>
189 189
 						<th colspan="<?php echo $calendar->static ? '7' : '5'; ?>"
@@ -195,26 +195,26 @@  discard block
 block discarded – undo
195 195
 
196 196
 							// Display month and year according to user date format preference.
197 197
 
198
-							$year_pos  = strcspn( $calendar->date_format, 'Y y' );
199
-							$month_pos = strcspn( $calendar->date_format, 'F M m n' );
198
+							$year_pos  = strcspn($calendar->date_format, 'Y y');
199
+							$month_pos = strcspn($calendar->date_format, 'F M m n');
200 200
 
201
-							$current = array( 'month' => 'F', 'year' => 'Y' );
201
+							$current = array('month' => 'F', 'year' => 'Y');
202 202
 
203
-							if ( $year_pos < $month_pos ) {
204
-								$current = array_reverse( $current );
203
+							if ($year_pos < $month_pos) {
204
+								$current = array_reverse($current);
205 205
 							}
206 206
 
207
-							foreach ( $current as $k => $v ) {
208
-								echo ' <span class="simcal-current-' . $k , '">' . date_i18n( $v, $calendar->start ) . '</span> ';
207
+							foreach ($current as $k => $v) {
208
+								echo ' <span class="simcal-current-'.$k, '">'.date_i18n($v, $calendar->start).'</span> ';
209 209
 							}
210 210
 
211 211
 							echo '</h3>';
212 212
 
213 213
 							?>
214 214
 						</th>
215
-						<?php if ( ! $calendar->static ) { ?>
215
+						<?php if ( ! $calendar->static) { ?>
216 216
 							<th class="simcal-nav simcal-next-wrapper" colspan="1">
217
-								<button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e( 'Next Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-right"></i></button>
217
+								<button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e('Next Month', 'google-calendar-events'); ?>"><i class="simcal-icon-right"></i></button>
218 218
 							</th>
219 219
 						<?php } ?>
220 220
 					</tr>
@@ -224,28 +224,28 @@  discard block
 block discarded – undo
224 224
 						// Print day names in short or long form for different viewport sizes.
225 225
 
226 226
 						$week_starts     = $calendar->week_starts;
227
-						$week_days_short = simcal_get_calendar_names_i18n( 'day', 'short' );
228
-						$week_days_full  = simcal_get_calendar_names_i18n( 'day', 'full' );
227
+						$week_days_short = simcal_get_calendar_names_i18n('day', 'short');
228
+						$week_days_full  = simcal_get_calendar_names_i18n('day', 'full');
229 229
 
230
-						for ( $i = $week_starts; $i <= 6; $i ++ ) :
230
+						for ($i = $week_starts; $i <= 6; $i++) :
231 231
 
232 232
 							?>
233 233
 							<th class="simcal-week-day simcal-week-day-<?php echo $i ?>"
234
-								data-screen-small="<?php echo mb_substr( $week_days_short[ $i ], 0, 1, 'UTF-8' ); ?>"
235
-							    data-screen-medium="<?php echo $week_days_short[ $i ]; ?>"
236
-							    data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th>
234
+								data-screen-small="<?php echo mb_substr($week_days_short[$i], 0, 1, 'UTF-8'); ?>"
235
+							    data-screen-medium="<?php echo $week_days_short[$i]; ?>"
236
+							    data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th>
237 237
 							<?php
238 238
 
239 239
 						endfor;
240 240
 
241
-						if ( $week_starts !== 0 ) :
242
-							for ( $i = 0; $i < $week_starts; $i ++ ) :
241
+						if ($week_starts !== 0) :
242
+							for ($i = 0; $i < $week_starts; $i++) :
243 243
 
244 244
 								?>
245 245
 								<th class="simcal-week-day simcal-week-day-<?php echo $i ?>"
246
-								    data-screen-small="<?php echo substr( $week_days_short[ $i ], 0, 1 ); ?>"
247
-								    data-screen-medium="<?php echo $week_days_short[ $i ]; ?>"
248
-								    data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th>
246
+								    data-screen-small="<?php echo substr($week_days_short[$i], 0, 1); ?>"
247
+								    data-screen-medium="<?php echo $week_days_short[$i]; ?>"
248
+								    data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th>
249 249
 								<?php
250 250
 
251 251
 							endfor;
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 					</tr>
256 256
 				</thead>
257 257
 
258
-				<?php echo $this->draw_month( date( 'n', $calendar->start ), date( 'Y', $calendar->start ) ); ?>
258
+				<?php echo $this->draw_month(date('n', $calendar->start), date('Y', $calendar->start)); ?>
259 259
 
260 260
 			</table>
261 261
 			<?php
@@ -280,82 +280,82 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @return string
282 282
 	 */
283
-	private function draw_month( $month, $year, $id = 0 ) {
283
+	private function draw_month($month, $year, $id = 0) {
284 284
 
285 285
 		$calendar = $this->calendar;
286
-		if ( empty( $calendar ) ) {
287
-			$calendar = simcal_get_calendar( intval( $id ) );
288
-			if ( ! $calendar ) {
286
+		if (empty($calendar)) {
287
+			$calendar = simcal_get_calendar(intval($id));
288
+			if ( ! $calendar) {
289 289
 				return '';
290 290
 			}
291 291
 		}
292
-		date_default_timezone_set( $calendar->timezone );
292
+		date_default_timezone_set($calendar->timezone);
293 293
 		$events = $calendar->events;
294 294
 
295 295
 		// Variables to cycle days in current month and find today in calendar.
296 296
 		$now         = $calendar->now;
297
-		$current     = Carbon::create( $year, $month, 1, 0, 0, 0, $calendar->timezone );
297
+		$current     = Carbon::create($year, $month, 1, 0, 0, 0, $calendar->timezone);
298 298
 		$current_min = $current->getTimestamp();
299 299
 		$current_max = $current->endOfDay()->getTimestamp();
300 300
 
301 301
 		// Calendar grid variables.
302 302
 		$week_starts   = $calendar->week_starts;
303
-		$week_of_year  = $current->weekOfYear;   // Relative count of the week number of the year.
304
-		$month_starts  = $current->dayOfWeek;    // Day upon which the month starts.
305
-		$days_in_month = $current->daysInMonth;  // Number of days in the given month.
303
+		$week_of_year  = $current->weekOfYear; // Relative count of the week number of the year.
304
+		$month_starts  = $current->dayOfWeek; // Day upon which the month starts.
305
+		$days_in_month = $current->daysInMonth; // Number of days in the given month.
306 306
 
307 307
 		// Set current month events timestamp boundaries.
308 308
 		$this->start = $current_min;
309 309
 		$this->end   = $current->endOfMonth()->timestamp;
310 310
 
311 311
 		// Get daily events for this month.
312
-		if ( $events && is_array( $events ) ) {
312
+		if ($events && is_array($events)) {
313 313
 
314 314
 			// Filter events within the boundaries previously set above.
315
-			$timestamps   = array_keys( $events );
316
-			$lower_bound  = array_filter( $timestamps, array( $this, 'filter_events_before' ) );
317
-			$higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) );
318
-			$filtered     = ( is_array( $events ) && is_array( $higher_bound) ) && ! empty( $events ) && ! empty( $higher_bound ) ? array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ) : array();
315
+			$timestamps   = array_keys($events);
316
+			$lower_bound  = array_filter($timestamps, array($this, 'filter_events_before'));
317
+			$higher_bound = array_filter($lower_bound, array($this, 'filter_events_after'));
318
+			$filtered     = (is_array($events) && is_array($higher_bound)) && ! empty($events) && ! empty($higher_bound) ? array_intersect_key($events, array_combine($higher_bound, $higher_bound)) : array();
319 319
 
320 320
 			// Put resulting events in an associative array, with day of the month as key for easy retrieval in calendar days loop.
321 321
 			$day_events = array();
322
-			foreach ( $filtered as $timestamp => $events_in_day ) {
323
-				foreach ( $events_in_day as $event ) {
324
-					if ( $event instanceof Event ){
325
-						$day = intval( Carbon::createFromTimestamp( $timestamp, $event->timezone )->endOfDay()->day );
326
-						$day_events[ $day ][] = $event;
322
+			foreach ($filtered as $timestamp => $events_in_day) {
323
+				foreach ($events_in_day as $event) {
324
+					if ($event instanceof Event) {
325
+						$day = intval(Carbon::createFromTimestamp($timestamp, $event->timezone)->endOfDay()->day);
326
+						$day_events[$day][] = $event;
327 327
 					}
328 328
 				}
329 329
 			}
330 330
 
331
-			ksort( $day_events, SORT_NUMERIC );
331
+			ksort($day_events, SORT_NUMERIC);
332 332
 		}
333 333
 
334 334
 		ob_start();
335 335
 
336
-		echo '<tbody class="simcal-month simcal-month-' . $month . '">' . "\n";
337
-		echo "\t" . '<tr class="simcal-week simcal-week-' . $week_of_year . '">';
336
+		echo '<tbody class="simcal-month simcal-month-'.$month.'">'."\n";
337
+		echo "\t".'<tr class="simcal-week simcal-week-'.$week_of_year.'">';
338 338
 
339 339
 		$days_in_row = 0;
340 340
 		// Week may start on an arbitrary day (sun, 0 - sat, 6).
341 341
 		$week_day = $week_starts;
342 342
 
343 343
 		// This fixes a possible bug when a month starts by Sunday (0).
344
-		if ( 0 !== $week_starts ) {
344
+		if (0 !== $week_starts) {
345 345
 			$b = $month_starts === 0 ? 7 : $month_starts;
346 346
 		} else {
347 347
 			$b = $month_starts;
348 348
 		}
349 349
 
350 350
 		// Void days in first week.
351
-		for ( $a = $week_starts; $a < $b; $a++ ) :
351
+		for ($a = $week_starts; $a < $b; $a++) :
352 352
 
353
-			$last_void_day_class = ( $a === ( $b - 1 ) ) ? 'simcal-day-void-last' : '';
353
+			$last_void_day_class = ($a === ($b - 1)) ? 'simcal-day-void-last' : '';
354 354
 
355
-			echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n";
355
+			echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n";
356 356
 
357 357
 			// Reset day of the week count (sun, 0 - sat, 6).
358
-			if ( $week_day === 6 ) {
358
+			if ($week_day === 6) {
359 359
 				$week_day = -1;
360 360
 			}
361 361
 			$week_day++;
@@ -365,91 +365,91 @@  discard block
 block discarded – undo
365 365
 		endfor;
366 366
 
367 367
 		// Actual days of the month.
368
-		for ( $day = 1; $day <= $days_in_month; $day++ ) :
368
+		for ($day = 1; $day <= $days_in_month; $day++) :
369 369
 
370 370
 			$count = 0;
371 371
 			$calendar_classes = array();
372
-			$day_classes = 'simcal-day-' . $day . ' simcal-weekday-' . $week_day;
372
+			$day_classes = 'simcal-day-'.$day.' simcal-weekday-'.$week_day;
373 373
 
374 374
 			$border_style = $bg_color = $color = '';
375 375
 
376 376
 			// Is this the present, the past or the future, Doc?
377
-			if ( $current_min <= $now && $current_max >= $now ) {
377
+			if ($current_min <= $now && $current_max >= $now) {
378 378
 				$day_classes .= ' simcal-today simcal-present simcal-day';
379
-				$the_color = new Color( $calendar->today_color );
380
-				$bg_color = '#' . $the_color->getHex();
379
+				$the_color = new Color($calendar->today_color);
380
+				$bg_color = '#'.$the_color->getHex();
381 381
 				$color = $the_color->isDark() ? '#ffffff' : '#000000';
382
-				$border_style = ' style="border: 1px solid ' . $bg_color . ';"';
383
-			} elseif ( $current_max < $now ) {
382
+				$border_style = ' style="border: 1px solid '.$bg_color.';"';
383
+			} elseif ($current_max < $now) {
384 384
 				$day_classes .= ' simcal-past simcal-day';
385
-			} elseif ( $current_min > $now ) {
385
+			} elseif ($current_min > $now) {
386 386
 				$day_classes .= ' simcal-future simcal-day';
387 387
 			}
388 388
 
389 389
 			// Print events for the current day in loop, if found any.
390
-			if ( isset( $day_events[ $day ] ) ) :
390
+			if (isset($day_events[$day])) :
391 391
 
392 392
 				$list_events = '<ul class="simcal-events">';
393 393
 
394
-				foreach ( $day_events[ $day ] as $event ) :
394
+				foreach ($day_events[$day] as $event) :
395 395
 
396 396
 					$event_classes = $event_visibility = '';
397 397
 
398
-					if ( $event instanceof Event ) :
398
+					if ($event instanceof Event) :
399 399
 
400 400
 						// Store the calendar id where the event belongs (useful in grouped calendar feeds)
401
-						$calendar_class  = 'simcal-events-calendar-' . strval( $event->calendar );
402
-						$calendar_classes[] = $calendar_class ;
401
+						$calendar_class = 'simcal-events-calendar-'.strval($event->calendar);
402
+						$calendar_classes[] = $calendar_class;
403 403
 
404 404
 						$recurring     = $event->recurrence ? 'simcal-event-recurring ' : '';
405 405
 						$has_location  = $event->venue ? 'simcal-event-has-location ' : '';
406 406
 
407
-						$event_classes  .= 'simcal-event ' . $recurring . $has_location . $calendar_class . ' simcal-tooltip';
407
+						$event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class.' simcal-tooltip';
408 408
 
409 409
 						// Toggle some events visibility if more than optional limit.
410
-						if ( ( $calendar->events_limit > -1 )  && ( $count >= $calendar->events_limit ) ) :
410
+						if (($calendar->events_limit > -1) && ($count >= $calendar->events_limit)) :
411 411
 							$event_classes    .= ' simcal-event-toggled';
412 412
 							$event_visibility  = ' style="display: none"';
413 413
 						endif;
414 414
 
415 415
 						// Event title in list.
416
-						$title = ! empty( $event->title ) ? trim( $event->title ) : __( 'Event', 'google-calendar-events' );
417
-						if ( $calendar->trim_titles >= 1 ) {
418
-							$title = strlen( $title ) > $calendar->trim_titles ? mb_substr( $title, 0, $calendar->trim_titles ) . '&hellip;' : $title;
416
+						$title = ! empty($event->title) ? trim($event->title) : __('Event', 'google-calendar-events');
417
+						if ($calendar->trim_titles >= 1) {
418
+							$title = strlen($title) > $calendar->trim_titles ? mb_substr($title, 0, $calendar->trim_titles).'&hellip;' : $title;
419 419
 						}
420 420
 
421 421
 						// Event color.
422 422
 						$bullet = '';
423 423
 						$event_color = $event->get_color();
424
-						if ( ! empty( $event_color ) ) {
425
-							$bullet = '<span style="color: ' . $event_color . ';">&#9632;</span> ';
424
+						if ( ! empty($event_color)) {
425
+							$bullet = '<span style="color: '.$event_color.';">&#9632;</span> ';
426 426
 						}
427 427
 
428 428
 						// Event contents.
429
-						$list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . ' itemprop="event" itemscope itemtype="http://schema.org/Event">' . "\n";
430
-						$list_events .= "\t\t" . '<span class="simcal-event-title">' . $bullet . $title . '</span>' . "\n";
431
-						$list_events .= "\t\t" . '<div class="simcal-event-details simcal-tooltip-content" style="display: none;">' . $calendar->get_event_html( $event ) . '</div>' . "\n";
432
-						$list_events .= "\t" . '</li>' . "\n";
429
+						$list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.' itemprop="event" itemscope itemtype="http://schema.org/Event">'."\n";
430
+						$list_events .= "\t\t".'<span class="simcal-event-title">'.$bullet.$title.'</span>'."\n";
431
+						$list_events .= "\t\t".'<div class="simcal-event-details simcal-tooltip-content" style="display: none;">'.$calendar->get_event_html($event).'</div>'."\n";
432
+						$list_events .= "\t".'</li>'."\n";
433 433
 
434
-						$count ++;
434
+						$count++;
435 435
 
436 436
 					endif;
437 437
 
438 438
 				endforeach;
439 439
 
440
-				if ( ( $current_min <= $now ) && ( $current_max >= $now ) ) {
440
+				if (($current_min <= $now) && ($current_max >= $now)) {
441 441
 					$day_classes .= ' simcal-today-has-events';
442 442
 				}
443
-				$day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events';
443
+				$day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events';
444 444
 
445
-				if ( $calendar_classes ) {
446
-					$day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) );
445
+				if ($calendar_classes) {
446
+					$day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes)));
447 447
 				}
448 448
 
449
-				$list_events .= '</ul>' . "\n";
449
+				$list_events .= '</ul>'."\n";
450 450
 
451 451
 				// Optional button to toggle hidden events in list.
452
-				if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) :
452
+				if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) :
453 453
 					$list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>';
454 454
 				endif;
455 455
 
@@ -461,49 +461,49 @@  discard block
 block discarded – undo
461 461
 			endif;
462 462
 
463 463
 			// The actual days with numbers and events in each row cell.
464
-			echo '<td class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n";
465
-
466
-			if ( $color ) {
467
-				$day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"';
468
-			} elseif ( $count > 0 ) {
469
-				$the_color = new Color( $calendar->days_events_color );
470
-				$color = ! $color ? ( $the_color->isDark() ? '#ffffff' : '#000000' ) : $color;
471
-				$bg_color = ! $bg_color ? '#' . $the_color->getHex() : $bg_color;
472
-				$day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"';
464
+			echo '<td class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n";
465
+
466
+			if ($color) {
467
+				$day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"';
468
+			} elseif ($count > 0) {
469
+				$the_color = new Color($calendar->days_events_color);
470
+				$color = ! $color ? ($the_color->isDark() ? '#ffffff' : '#000000') : $color;
471
+				$bg_color = ! $bg_color ? '#'.$the_color->getHex() : $bg_color;
472
+				$day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"';
473 473
 			} else {
474 474
 				$day_style = '';
475 475
 			}
476 476
 
477
-			echo "\t" . '<div' . $border_style . '>' . "\n";
478
-			echo "\t\t" . '<span class="simcal-day-label simcal-day-number"' . $day_style . '>' . $day . '</span>' . "\n";
479
-			echo "\t\t" . $list_events . "\n";
477
+			echo "\t".'<div'.$border_style.'>'."\n";
478
+			echo "\t\t".'<span class="simcal-day-label simcal-day-number"'.$day_style.'>'.$day.'</span>'."\n";
479
+			echo "\t\t".$list_events."\n";
480 480
 			echo "\t\t";
481 481
 			echo '<span class="simcal-events-dots" style="display: none;">';
482 482
 
483 483
 			// Event bullets for calendar mobile mode.
484
-			for( $i = 0; $i < $count; $i++ ) {
484
+			for ($i = 0; $i < $count; $i++) {
485 485
 				echo '<b> &bull; </b>';
486 486
 			}
487 487
 
488
-			echo '</span>' . "\n";
489
-			echo "\t" . '</div>' . "\n";
490
-			echo '</td>' . "\n";
488
+			echo '</span>'."\n";
489
+			echo "\t".'</div>'."\n";
490
+			echo '</td>'."\n";
491 491
 
492 492
 			// Reset day of the week count (sun, 0 - sat, 6).
493
-			if ( $week_day === 6 ) {
493
+			if ($week_day === 6) {
494 494
 				$week_day = - 1;
495 495
 			}
496 496
 			$week_day++;
497 497
 
498 498
 			// Reset count of days for this row (0-6).
499
-			if ( $days_in_row === 6 ) :
499
+			if ($days_in_row === 6) :
500 500
 
501 501
 				// Close the week row.
502 502
 				echo '</tr>';
503 503
 
504 504
 				// Open a new week row.
505
-				if ( $day < $days_in_month ) {
506
-					echo '<tr class="simcal-week simcal-week-' . $week_of_year++ . '">' . "\n";
505
+				if ($day < $days_in_month) {
506
+					echo '<tr class="simcal-week simcal-week-'.$week_of_year++.'">'."\n";
507 507
 				}
508 508
 
509 509
 				$days_in_row = -1;
@@ -512,27 +512,27 @@  discard block
 block discarded – undo
512 512
 
513 513
 			$days_in_row++;
514 514
 
515
-			$current_min = Carbon::createFromTimestamp( $current_min, $calendar->timezone )->addDay()->getTimestamp();
516
-			$current_max = Carbon::createFromTimestamp( $current_max, $calendar->timezone )->addDay()->getTimestamp();
515
+			$current_min = Carbon::createFromTimestamp($current_min, $calendar->timezone)->addDay()->getTimestamp();
516
+			$current_max = Carbon::createFromTimestamp($current_max, $calendar->timezone)->addDay()->getTimestamp();
517 517
 
518 518
 		endfor;
519 519
 
520 520
 		// Void days at the end of the month.
521
-		$remainder_days = ( 6 - $days_in_row );
521
+		$remainder_days = (6 - $days_in_row);
522 522
 
523
-		for ( $i = 0; $i <= $remainder_days; $i ++ ) {
523
+		for ($i = 0; $i <= $remainder_days; $i++) {
524 524
 
525
-			$last_void_day_class = ( $i == $remainder_days ) ? 'simcal-day-void-last' : '';
525
+			$last_void_day_class = ($i == $remainder_days) ? 'simcal-day-void-last' : '';
526 526
 
527
-			echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n";
527
+			echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n";
528 528
 
529 529
 			$week_day++;
530 530
 		}
531 531
 
532
-		echo "\t" . '</tr>' . "\n";
533
-		echo '</tbody>' . "\n";
532
+		echo "\t".'</tr>'."\n";
533
+		echo '</tbody>'."\n";
534 534
 
535
-		date_default_timezone_set( $calendar->site_timezone );
535
+		date_default_timezone_set($calendar->site_timezone);
536 536
 
537 537
 		return ob_get_clean();
538 538
 	}
@@ -544,17 +544,17 @@  discard block
 block discarded – undo
544 544
 	 */
545 545
 	public function draw_grid_ajax() {
546 546
 
547
-		if ( isset( $_POST['month'] ) && isset( $_POST['year'] ) && isset( $_POST['id'] ) ) {
547
+		if (isset($_POST['month']) && isset($_POST['year']) && isset($_POST['id'])) {
548 548
 
549
-			$month = absint( $_POST['month'] );
550
-			$year  = absint( $_POST['year'] );
551
-			$id    = absint( $_POST['id'] );
549
+			$month = absint($_POST['month']);
550
+			$year  = absint($_POST['year']);
551
+			$id    = absint($_POST['id']);
552 552
 
553
-			wp_send_json_success( $this->draw_month( $month, $year, $id ) );
553
+			wp_send_json_success($this->draw_month($month, $year, $id));
554 554
 
555 555
 		} else {
556 556
 
557
-			wp_send_json_error( 'Missing arguments in default calendar grid ajax request.' );
557
+			wp_send_json_error('Missing arguments in default calendar grid ajax request.');
558 558
 
559 559
 		}
560 560
 
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 	 *
571 571
 	 * @return bool
572 572
 	 */
573
-	private function filter_events_before( $event ) {
574
-		return intval( $event ) >= intval( $this->start );
573
+	private function filter_events_before($event) {
574
+		return intval($event) >= intval($this->start);
575 575
 	}
576 576
 
577 577
 	/**
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
 	 *
585 585
 	 * @return bool
586 586
 	 */
587
-	private function filter_events_after( $event ) {
588
-		return intval( $event ) < intval( $this->end );
587
+	private function filter_events_after($event) {
588
+		return intval($event) < intval($this->end);
589 589
 	}
590 590
 
591 591
 }
Please login to merge, or discard this patch.
includes/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   +197 added lines, -197 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,123 +430,123 @@  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 471
 				// This is where we can find out if an event is a multi-day event and if it needs to be shown.
472 472
 				// Since this is for list view we are showing the event on the day viewed if it is part of that day even when
473 473
 				// expand multi-day events are turned off.
474
-				if ( isset( $events[0][0]->multiple_days ) && $events[0][0]->multiple_days > 0 ) {
475
-					if ( 'current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true ) ) {
474
+				if (isset($events[0][0]->multiple_days) && $events[0][0]->multiple_days > 0) {
475
+					if ('current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true)) {
476 476
 
477
-						$year  = substr( $ymd, 0, 4 );
478
-						$month = substr( $ymd, 4, 2 );
479
-						$day   = substr( $ymd, 6, 2 );
477
+						$year  = substr($ymd, 0, 4);
478
+						$month = substr($ymd, 4, 2);
479
+						$day   = substr($ymd, 6, 2);
480 480
 
481
-						$temp_date = Carbon::createFromDate( $year, $month, $day );
481
+						$temp_date = Carbon::createFromDate($year, $month, $day);
482 482
 
483
-						if( ! ( $temp_date < Carbon::now()->endOfDay() ) ) {
483
+						if ( ! ($temp_date < Carbon::now()->endOfDay())) {
484 484
 							continue;
485 485
 						}
486 486
 					}
487 487
 				}
488 488
 
489
-				$day_ts = Carbon::createFromFormat( 'Ymd', $ymd, $calendar->timezone )->getTimestamp();
489
+				$day_ts = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone)->getTimestamp();
490 490
 
491
-				if ( ! $calendar->compact_list ) :
491
+				if ( ! $calendar->compact_list) :
492 492
 
493
-					$date = new Carbon( 'now', $calendar->timezone );
494
-					$date->setLocale( substr( get_locale(), 0, 2 ) );
495
-					$date->setTimestamp( $day_ts );
493
+					$date = new Carbon('now', $calendar->timezone);
494
+					$date->setLocale(substr(get_locale(), 0, 2));
495
+					$date->setTimestamp($day_ts);
496 496
 
497
-					if ( $date->isToday() ) {
498
-						$the_color = new Color( $calendar->today_color );
497
+					if ($date->isToday()) {
498
+						$the_color = new Color($calendar->today_color);
499 499
 					} else {
500
-						$the_color = new Color( $calendar->days_events_color );
500
+						$the_color = new Color($calendar->days_events_color);
501 501
 					}
502 502
 
503
-					$bg_color = '#' . $the_color->getHex();
503
+					$bg_color = '#'.$the_color->getHex();
504 504
 					$color = $the_color->isDark() ? '#ffffff' : '#000000';
505
-					$border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" ';
506
-					$bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"';
505
+					$border_style = ' style="border-bottom: 1px solid '.$bg_color.';" ';
506
+					$bg_style = ' style="background-color: '.$bg_color.'; color: '.$color.';"';
507 507
 
508
-					echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>';
509
-					echo '<span' . $bg_style .'>';
510
-					foreach ( $day_format as $format ) {
511
-						echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n( $format, $day_ts ) . '</span> ' : ' ';
508
+					echo "\t".'<dt class="simcal-day-label"'.$border_style.'>';
509
+					echo '<span'.$bg_style.'>';
510
+					foreach ($day_format as $format) {
511
+						echo $format ? '<span class="simcal-date-format" data-date-format="'.$format.'">'.date_i18n($format, $day_ts).'</span> ' : ' ';
512 512
 					}
513 513
 					echo '</span>';
514
-					echo '</dt>' . "\n";
514
+					echo '</dt>'."\n";
515 515
 
516 516
 				endif;
517 517
 
518
-				$list_events = '<ul class="simcal-events">' . "\n";
518
+				$list_events = '<ul class="simcal-events">'."\n";
519 519
 
520 520
 				$calendar_classes = array();
521
-				$day_classes = 'simcal-weekday-' . date( 'w', $day_ts );
521
+				$day_classes = 'simcal-weekday-'.date('w', $day_ts);
522 522
 
523 523
 				// Is this the present, the past or the future, Doc?
524
-				if ( $timestamp <= $now && $timestamp >= $now ) {
524
+				if ($timestamp <= $now && $timestamp >= $now) {
525 525
 					$day_classes .= ' simcal-today simcal-present simcal-day';
526
-				} elseif ( $timestamp < $now ) {
526
+				} elseif ($timestamp < $now) {
527 527
 					$day_classes .= ' simcal-past simcal-day';
528
-				} elseif ( $this->end > $now ) {
528
+				} elseif ($this->end > $now) {
529 529
 					$day_classes .= ' simcal-future simcal-day';
530 530
 				}
531 531
 
532 532
 				$count = 0;
533 533
 
534
-				foreach ( $events as $day_events ) :
535
-					foreach ( $day_events as $event ) :
536
-						if ( $event instanceof Event ) :
534
+				foreach ($events as $day_events) :
535
+					foreach ($day_events as $event) :
536
+						if ($event instanceof Event) :
537 537
 
538 538
 							$event_classes = $event_visibility = '';
539 539
 
540
-							$calendar_class     = 'simcal-events-calendar-' . strval( $event->calendar );
540
+							$calendar_class     = 'simcal-events-calendar-'.strval($event->calendar);
541 541
 							$calendar_classes[] = $calendar_class;
542 542
 
543 543
 							$recurring     = $event->recurrence ? 'simcal-event-recurring ' : '';
544 544
 							$has_location  = $event->venue ? 'simcal-event-has-location ' : '';
545 545
 
546
-							$event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class;
546
+							$event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class;
547 547
 
548 548
 							// Toggle some events visibility if more than optional limit.
549
-							if ( ( $calendar->events_limit > - 1 ) && ( $count >= $calendar->events_limit ) ) :
549
+							if (($calendar->events_limit > - 1) && ($count >= $calendar->events_limit)) :
550 550
 								$event_classes .= ' simcal-event-toggled';
551 551
 								$event_visibility = ' style="display: none"';
552 552
 							endif;
@@ -554,75 +554,75 @@  discard block
 block discarded – undo
554 554
 							$event_color = '';
555 555
 							$bullet = '';
556 556
 							$event_color = $event->get_color();
557
-							if ( ! empty( $event_color ) ) {
557
+							if ( ! empty($event_color)) {
558 558
 								$side = is_rtl() ? 'right' : 'left';
559
-								$event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"';
559
+								$event_color = ' style="border-'.$side.': 4px solid '.$event_color.'; padding-'.$side.': 8px;"';
560 560
 							}
561 561
 
562
-							$list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemprop="event" itemscope itemtype="http://schema.org/Event">' . "\n";
563
-							$list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html( $event ) . '</div>' . "\n";
564
-							$list_events .= "\t" . '</li>' . "\n";
562
+							$list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.$event_color.' itemprop="event" itemscope itemtype="http://schema.org/Event">'."\n";
563
+							$list_events .= "\t\t".'<div class="simcal-event-details">'.$calendar->get_event_html($event).'</div>'."\n";
564
+							$list_events .= "\t".'</li>'."\n";
565 565
 
566
-							$count ++;
566
+							$count++;
567 567
 
568 568
 							// Event falls within today.
569
-							if ( ( $this->end <= $now ) && ( $this->start >= $now ) ) :
569
+							if (($this->end <= $now) && ($this->start >= $now)) :
570 570
 								$day_classes .= ' simcal-today-has-events';
571 571
 							endif;
572
-							$day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events';
572
+							$day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events';
573 573
 
574
-							if ( $calendar_classes ) :
575
-								$day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) );
574
+							if ($calendar_classes) :
575
+								$day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes)));
576 576
 							endif;
577 577
 
578 578
 						endif;
579 579
 					endforeach;
580 580
 				endforeach;
581 581
 
582
-				$list_events .= '</ul>' . "\n";
582
+				$list_events .= '</ul>'."\n";
583 583
 
584 584
 				// If events visibility is limited, print the button toggle.
585
-				if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) :
585
+				if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) :
586 586
 					$list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>';
587 587
 				endif;
588 588
 
589 589
 				// Print final list of events for the current day.
590 590
 				$tag = $calendar->compact_list ? 'div' : 'dd';
591
-				echo '<'  . $tag . ' class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n";
592
-				echo "\t" . $list_events . "\n";
593
-				echo '</' . $tag . '>' . "\n";
591
+				echo '<'.$tag.' class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n";
592
+				echo "\t".$list_events."\n";
593
+				echo '</'.$tag.'>'."\n";
594 594
 
595 595
 			endforeach;
596 596
 
597 597
 		else :
598 598
 
599
-			echo "\t" . '<p>';
599
+			echo "\t".'<p>';
600 600
 
601
-			$message = get_post_meta( $calendar->id, '_no_events_message', true );
601
+			$message = get_post_meta($calendar->id, '_no_events_message', true);
602 602
 
603
-			if ( 'events' == $calendar->group_type ) {
604
-				echo ! empty( $message ) ? $message : __( 'Nothing to show.', 'google-calendar-events' );
603
+			if ('events' == $calendar->group_type) {
604
+				echo ! empty($message) ? $message : __('Nothing to show.', 'google-calendar-events');
605 605
 			} else {
606
-				if ( ! empty( $message ) ) {
606
+				if ( ! empty($message)) {
607 607
 					echo $message;
608 608
 				} else {
609
-					$from = Carbon::createFromTimestamp( $this->start, $calendar->timezone )->getTimestamp();
610
-					$to = Carbon::createFromTimestamp( $this->end, $calendar->timezone )->getTimestamp();
611
-					echo apply_filters( 'simcal_no_events_message', sprintf(
612
-						__( 'Nothing from %1$s to %2$s.', 'google-calendar-events' ),
613
-						date_i18n( $calendar->date_format, $from ),
614
-						date_i18n( $calendar->date_format, $to )
615
-					), $calendar->id, $from, $to );
609
+					$from = Carbon::createFromTimestamp($this->start, $calendar->timezone)->getTimestamp();
610
+					$to = Carbon::createFromTimestamp($this->end, $calendar->timezone)->getTimestamp();
611
+					echo apply_filters('simcal_no_events_message', sprintf(
612
+						__('Nothing from %1$s to %2$s.', 'google-calendar-events'),
613
+						date_i18n($calendar->date_format, $from),
614
+						date_i18n($calendar->date_format, $to)
615
+					), $calendar->id, $from, $to);
616 616
 				}
617 617
 			}
618 618
 
619
-			echo "\t" . '</p>' . "\n";
619
+			echo "\t".'</p>'."\n";
620 620
 
621 621
 		endif;
622 622
 
623
-		echo '</' . $block_tag . '>';
623
+		echo '</'.$block_tag.'>';
624 624
 
625
-		date_default_timezone_set( $calendar->site_timezone );
625
+		date_default_timezone_set($calendar->site_timezone);
626 626
 
627 627
 		return ob_get_clean();
628 628
 	}
@@ -634,16 +634,16 @@  discard block
 block discarded – undo
634 634
 	 */
635 635
 	public function draw_list_ajax() {
636 636
 
637
-		if ( isset( $_POST['ts'] ) && isset( $_POST['id'] ) ) {
637
+		if (isset($_POST['ts']) && isset($_POST['id'])) {
638 638
 
639
-			$ts = absint( $_POST['ts'] );
640
-			$id = absint( $_POST['id'] );
639
+			$ts = absint($_POST['ts']);
640
+			$id = absint($_POST['id']);
641 641
 
642
-			wp_send_json_success( $this->draw_list( $ts, $id ) );
642
+			wp_send_json_success($this->draw_list($ts, $id));
643 643
 
644 644
 		} else {
645 645
 
646
-			wp_send_json_error( 'Missing arguments in default calendar list ajax request.' );
646
+			wp_send_json_error('Missing arguments in default calendar list ajax request.');
647 647
 
648 648
 		}
649 649
 	}
@@ -658,8 +658,8 @@  discard block
 block discarded – undo
658 658
 	 *
659 659
 	 * @return bool
660 660
 	 */
661
-	private function filter_events_before( $event ) {
662
-		return intval( $event ) > intval( $this->start );
661
+	private function filter_events_before($event) {
662
+		return intval($event) > intval($this->start);
663 663
 	}
664 664
 
665 665
 	/**
@@ -672,8 +672,8 @@  discard block
 block discarded – undo
672 672
 	 *
673 673
 	 * @return bool
674 674
 	 */
675
-	private function filter_events_after( $event ) {
676
-		return intval( $event ) < intval( $this->end );
675
+	private function filter_events_after($event) {
676
+		return intval($event) < intval($this->end);
677 677
 	}
678 678
 
679 679
 }
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/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/installation.php 1 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.