Completed
Push — master ( e47c17...035b95 )
by
unknown
04:49
created
includes/calendars/default-calendar.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,6 @@
 block discarded – undo
6 6
  */
7 7
 namespace SimpleCalendar\Calendars;
8 8
 
9
-use Carbon\Carbon;
10 9
 use SimpleCalendar\Abstracts\Calendar;
11 10
 use SimpleCalendar\Abstracts\Calendar_View;
12 11
 use SimpleCalendar\Calendars\Admin\Default_Calendar_Admin;
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use SimpleCalendar\Calendars\Views;
14 14
 use SimpleCalendar\Events\Event;
15 15
 
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -105,35 +105,35 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @param int|object|\WP_Post|Calendar $calendar
107 107
 	 */
108
-	public function __construct( $calendar ) {
108
+	public function __construct($calendar) {
109 109
 
110 110
 		$this->type = 'default-calendar';
111
-		$this->name = __( 'Default', 'google-calendar-events' );
112
-		$this->views = apply_filters( 'simcal_default_calendar_views', array(
113
-			'grid' => __( 'Grid', 'google-calendar-events' ),
114
-			'list' => __( 'List', 'google-calendar-events' ),
115
-		) );
111
+		$this->name = __('Default', 'google-calendar-events');
112
+		$this->views = apply_filters('simcal_default_calendar_views', array(
113
+			'grid' => __('Grid', 'google-calendar-events'),
114
+			'list' => __('List', 'google-calendar-events'),
115
+		));
116 116
 
117
-		parent::__construct( $calendar );
117
+		parent::__construct($calendar);
118 118
 
119
-		if ( ! is_null( $this->post ) ) {
119
+		if ( ! is_null($this->post)) {
120 120
 
121
-			$this->set_properties( $this->view->get_type() );
121
+			$this->set_properties($this->view->get_type());
122 122
 
123 123
 			$id = $this->id;
124 124
 			$theme = $this->theme;
125 125
 
126
-			add_filter( 'simcal_calendar_class', function( $class, $post_id ) use ( $theme, $id ) {
127
-				if ( in_array( 'default-calendar', $class ) && $post_id === $id ) {
128
-					array_push( $class, 'default-calendar-' . $theme );
126
+			add_filter('simcal_calendar_class', function($class, $post_id) use ($theme, $id) {
127
+				if (in_array('default-calendar', $class) && $post_id === $id) {
128
+					array_push($class, 'default-calendar-'.$theme);
129 129
 				}
130 130
 				return $class;
131
-			}, 10, 2 );
131
+			}, 10, 2);
132 132
 
133 133
 		}
134 134
 
135 135
 		// Calendar settings handling.
136
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
136
+		if (is_admin() && ! defined('DOING_AJAX')) {
137 137
 			$admin = new Default_Calendar_Admin();
138 138
 			$this->settings = $admin->settings_fields();
139 139
 		}
@@ -147,49 +147,49 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @param  $view
149 149
 	 */
150
-	private function set_properties( $view ) {
150
+	private function set_properties($view) {
151 151
 
152 152
 		// Set styles.
153
-		if ( 'dark' == get_post_meta( $this->id, '_default_calendar_style_theme', true ) ) {
153
+		if ('dark' == get_post_meta($this->id, '_default_calendar_style_theme', true)) {
154 154
 			$this->theme = 'dark';
155 155
 		}
156
-		if ( $today_color = get_post_meta( $this->id, '_default_calendar_style_today', true ) ) {
157
-			$this->today_color = esc_attr( $today_color );
156
+		if ($today_color = get_post_meta($this->id, '_default_calendar_style_today', true)) {
157
+			$this->today_color = esc_attr($today_color);
158 158
 		}
159
-		if ( $day_events_color = get_post_meta( $this->id, '_default_calendar_style_days_events', true ) ) {
160
-			$this->days_events_color = esc_attr( $day_events_color );
159
+		if ($day_events_color = get_post_meta($this->id, '_default_calendar_style_days_events', true)) {
160
+			$this->days_events_color = esc_attr($day_events_color);
161 161
 		}
162 162
 
163 163
 		// Hide too many events.
164
-		if ( 'yes' == get_post_meta( $this->id, '_default_calendar_limit_visible_events', true ) ) {
165
-			$this->events_limit = absint( get_post_meta( $this->id, '_default_calendar_visible_events', true ) );
164
+		if ('yes' == get_post_meta($this->id, '_default_calendar_limit_visible_events', true)) {
165
+			$this->events_limit = absint(get_post_meta($this->id, '_default_calendar_visible_events', true));
166 166
 		}
167 167
 
168 168
 		// Expand multiple day events.
169
-		if ( 'yes' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) || ( 'list' == $view && 'current_day_only' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) ) ) {
169
+		if ('yes' == get_post_meta($this->id, '_default_calendar_expand_multi_day_events', true) || ('list' == $view && 'current_day_only' == get_post_meta($this->id, '_default_calendar_expand_multi_day_events', true))) {
170 170
 			$this->events = $this->expand_multiple_days_events();
171 171
 		}
172 172
 
173
-		if ( 'grid' == $view ) {
173
+		if ('grid' == $view) {
174 174
 
175 175
 			// Use hover to open event bubbles.
176
-			if ( 'hover' == get_post_meta( $this->id, '_default_calendar_event_bubble_trigger', true ) ) {
176
+			if ('hover' == get_post_meta($this->id, '_default_calendar_event_bubble_trigger', true)) {
177 177
 				$this->event_bubble_trigger = 'hover';
178 178
 			}
179 179
 
180 180
 			// Trim long event titles.
181
-			if ( 'yes' == get_post_meta( $this->id, '_default_calendar_trim_titles', true ) ) {
182
-				$this->trim_titles = max( absint( get_post_meta( $this->id, '_default_calendar_trim_titles_chars', true ) ), 1 );
181
+			if ('yes' == get_post_meta($this->id, '_default_calendar_trim_titles', true)) {
182
+				$this->trim_titles = max(absint(get_post_meta($this->id, '_default_calendar_trim_titles_chars', true)), 1);
183 183
 			}
184 184
 
185 185
 		} else {
186 186
 
187 187
 			// List range.
188
-			$this->group_type = esc_attr( get_post_meta( $this->id, '_default_calendar_list_range_type', true ) );
189
-			$this->group_span = max( absint( get_post_meta( $this->id, '_default_calendar_list_range_span', true ) ), 1 );
188
+			$this->group_type = esc_attr(get_post_meta($this->id, '_default_calendar_list_range_type', true));
189
+			$this->group_span = max(absint(get_post_meta($this->id, '_default_calendar_list_range_span', true)), 1);
190 190
 
191 191
 			// Make the list look more compact.
192
-			if ( 'yes' == get_post_meta( $this->id, '_default_calendar_compact_list', true ) ) {
192
+			if ('yes' == get_post_meta($this->id, '_default_calendar_compact_list', true)) {
193 193
 				$this->compact_list = true;
194 194
 			}
195 195
 
@@ -210,24 +210,24 @@  discard block
 block discarded – undo
210 210
 		$old_events = $this->events;
211 211
 		$new_events = array();
212 212
 
213
-		if ( ! empty( $old_events ) ) {
213
+		if ( ! empty($old_events)) {
214 214
 
215
-			foreach ( $old_events as $events ) {
216
-				foreach ( $events as $event ) {
217
-					if ( $event instanceof Event ) {
218
-						if ( false !== $event->multiple_days ) {
215
+			foreach ($old_events as $events) {
216
+				foreach ($events as $event) {
217
+					if ($event instanceof Event) {
218
+						if (false !== $event->multiple_days) {
219 219
 							$days = $event->multiple_days;
220 220
 
221
-							if ( $days == 1 ) {
222
-								$new_events[ intval( $event->start + ( DAY_IN_SECONDS ) - 1 ) ][] = $event;
221
+							if ($days == 1) {
222
+								$new_events[intval($event->start + (DAY_IN_SECONDS) - 1)][] = $event;
223 223
 							} else {
224 224
 
225 225
 								/*if ( ! empty( $event->whole_day ) ) {
226 226
 									$days--;
227 227
 								}*/
228 228
 
229
-								for ( $d = 1; $d <= $days; $d++ ) {
230
-									$new_events[ intval( $event->start + ( $d * DAY_IN_SECONDS ) - 1 ) ][] = $event;
229
+								for ($d = 1; $d <= $days; $d++) {
230
+									$new_events[intval($event->start + ($d * DAY_IN_SECONDS) - 1)][] = $event;
231 231
 								}
232 232
 							}
233 233
 						}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		}
240 240
 
241 241
 		$events = $old_events + $new_events;
242
-		ksort( $events, SORT_NUMERIC );
242
+		ksort($events, SORT_NUMERIC);
243 243
 		return $events;
244 244
 	}
245 245
 
@@ -254,16 +254,16 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @return null|Calendar_View
256 256
 	 */
257
-	public function get_view( $view = '' ) {
257
+	public function get_view($view = '') {
258 258
 
259
-		$view = ! empty( $view ) ? $view : 'grid';
259
+		$view = ! empty($view) ? $view : 'grid';
260 260
 
261
-		do_action( 'simcal_calendar_get_view', $this->type, $view );
261
+		do_action('simcal_calendar_get_view', $this->type, $view);
262 262
 
263
-		if ( 'grid' == $view ) {
264
-			return new Views\Default_Calendar_Grid( $this );
265
-		} elseif ( 'list' == $view ) {
266
-			return new Views\Default_Calendar_List( $this );
263
+		if ('grid' == $view) {
264
+			return new Views\Default_Calendar_Grid($this);
265
+		} elseif ('list' == $view) {
266
+			return new Views\Default_Calendar_List($this);
267 267
 		}
268 268
 
269 269
 		return null;
Please login to merge, or discard this patch.
includes/feeds/google.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,6 @@
 block discarded – undo
7 7
 namespace SimpleCalendar\Feeds;
8 8
 
9 9
 use Carbon\Carbon;
10
-use Carbon\CarbonInterval;
11 10
 use SimpleCalendar\Abstracts\Calendar;
12 11
 use SimpleCalendar\Abstracts\Feed;
13 12
 use SimpleCalendar\Feeds\Admin\Google_Admin as Admin;
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
 			// Google query args.
109 109
 			$this->google_calendar_id       = $this->esc_google_calendar_id( get_post_meta( $this->post_id, '_google_calendar_id', true ) );
110 110
 			$this->google_events_recurring  = esc_attr( get_post_meta( $this->post_id, '_google_events_recurring', true ) );
111
-            // note that google_search_query is used in a URL param and not as HTML output, so don't use esc_attr() on it
111
+			// note that google_search_query is used in a URL param and not as HTML output, so don't use esc_attr() on it
112 112
 			$this->google_search_query      = get_post_meta( $this->post_id, '_google_events_search_query', true );
113 113
 			$this->google_max_results       = max( absint( get_post_meta( $this->post_id, '_google_events_max_results', true ) ), 1 );
114 114
 
Please login to merge, or discard this patch.
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 use SimpleCalendar\Abstracts\Feed;
13 13
 use SimpleCalendar\Feeds\Admin\Google_Admin as Admin;
14 14
 
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -90,35 +90,35 @@  discard block
 block discarded – undo
90 90
 	 * @param string|Calendar $calendar
91 91
 	 * @param bool $load_admin
92 92
 	 */
93
-	public function __construct( $calendar = '', $load_admin = true ) {
93
+	public function __construct($calendar = '', $load_admin = true) {
94 94
 
95
-		parent::__construct( $calendar );
95
+		parent::__construct($calendar);
96 96
 
97 97
 		$this->type = 'google';
98
-		$this->name = __( 'Google Calendar', 'google-calendar-events' );
98
+		$this->name = __('Google Calendar', 'google-calendar-events');
99 99
 
100 100
 		// Google client config.
101
-		$settings = get_option( 'simple-calendar_settings_feeds' );
102
-		$this->google_api_key = isset( $settings['google']['api_key'] ) ? esc_attr( $settings['google']['api_key'] ) : '';
103
-		$this->google_client_scopes = array( \Google_Service_Calendar::CALENDAR_READONLY );
101
+		$settings = get_option('simple-calendar_settings_feeds');
102
+		$this->google_api_key = isset($settings['google']['api_key']) ? esc_attr($settings['google']['api_key']) : '';
103
+		$this->google_client_scopes = array(\Google_Service_Calendar::CALENDAR_READONLY);
104 104
 		$this->google_client = $this->get_client();
105 105
 
106
-		if ( $this->post_id > 0 ) {
106
+		if ($this->post_id > 0) {
107 107
 
108 108
 			// Google query args.
109
-			$this->google_calendar_id       = $this->esc_google_calendar_id( get_post_meta( $this->post_id, '_google_calendar_id', true ) );
110
-			$this->google_events_recurring  = esc_attr( get_post_meta( $this->post_id, '_google_events_recurring', true ) );
109
+			$this->google_calendar_id       = $this->esc_google_calendar_id(get_post_meta($this->post_id, '_google_calendar_id', true));
110
+			$this->google_events_recurring  = esc_attr(get_post_meta($this->post_id, '_google_events_recurring', true));
111 111
             // note that google_search_query is used in a URL param and not as HTML output, so don't use esc_attr() on it
112
-			$this->google_search_query      = get_post_meta( $this->post_id, '_google_events_search_query', true );
113
-			$this->google_max_results       = max( absint( get_post_meta( $this->post_id, '_google_events_max_results', true ) ), 1 );
112
+			$this->google_search_query      = get_post_meta($this->post_id, '_google_events_search_query', true);
113
+			$this->google_max_results       = max(absint(get_post_meta($this->post_id, '_google_events_max_results', true)), 1);
114 114
 
115
-			if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
116
-				$this->events = ! empty( $this->google_api_key ) ? $this->get_events() : array();
115
+			if ( ! is_admin() || defined('DOING_AJAX')) {
116
+				$this->events = ! empty($this->google_api_key) ? $this->get_events() : array();
117 117
 			}
118 118
 		}
119 119
 
120
-		if ( is_admin() && $load_admin ) {
121
-			$admin = new Admin( $this, $this->google_api_key, $this->google_calendar_id );
120
+		if (is_admin() && $load_admin) {
121
+			$admin = new Admin($this, $this->google_api_key, $this->google_calendar_id);
122 122
 			$this->settings = $admin->settings_fields();
123 123
 		}
124 124
 	}
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @return string
134 134
 	 */
135
-	public function esc_google_calendar_id( $id ) {
136
-		return base64_decode( $id );
135
+	public function esc_google_calendar_id($id) {
136
+		return base64_decode($id);
137 137
 	}
138 138
 
139 139
 	/**
@@ -147,85 +147,85 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function get_events() {
149 149
 
150
-		$calendar = get_transient( '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type );
150
+		$calendar = get_transient('_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type);
151 151
 
152
-		if ( empty( $calendar ) && ! empty( $this->google_calendar_id ) ) {
152
+		if (empty($calendar) && ! empty($this->google_calendar_id)) {
153 153
 
154 154
 			$error = '';
155 155
 
156 156
 			try {
157
-				$response = $this->make_request( $this->google_calendar_id );
158
-			} catch ( \Exception $e ) {
157
+				$response = $this->make_request($this->google_calendar_id);
158
+			} catch (\Exception $e) {
159 159
 				$error .= $e->getMessage();
160 160
 			}
161 161
 
162
-			if ( empty( $error ) && isset( $response['events'] ) && isset( $response['timezone'] ) ) {
162
+			if (empty($error) && isset($response['events']) && isset($response['timezone'])) {
163 163
 
164
-				$calendar = array_merge( $response, array( 'events' => array() ) );
164
+				$calendar = array_merge($response, array('events' => array()));
165 165
 
166 166
 				// If no timezone has been set, use calendar feed.
167
-				if ( 'use_calendar' == $this->timezone_setting ) {
167
+				if ('use_calendar' == $this->timezone_setting) {
168 168
 					$this->timezone = $calendar['timezone'];
169 169
 				}
170 170
 
171
-				$source = isset( $response['title'] ) ? sanitize_text_field( $response['title'] ) : '';
171
+				$source = isset($response['title']) ? sanitize_text_field($response['title']) : '';
172 172
 
173
-				if ( ! empty( $response['events'] ) && is_array( $response['events'] ) ) {
174
-					foreach ( $response['events'] as $event ) {
175
-						if ( $event instanceof \Google_Service_Calendar_Event ) {
173
+				if ( ! empty($response['events']) && is_array($response['events'])) {
174
+					foreach ($response['events'] as $event) {
175
+						if ($event instanceof \Google_Service_Calendar_Event) {
176 176
 
177 177
 							// Visibility and status.
178 178
 							// Public calendars may have private events which can't be properly accessed by simple api key method.
179 179
 							// Also want to skip cancelled events (single occurences deleted from repeating events)
180 180
 							$visibility = $event->getVisibility();
181 181
 							$status = $event->getStatus();
182
-							if ( $this->type == 'google' && ( $visibility == 'private' || $visibility == 'confidential' || $status == 'cancelled' ) ) {
182
+							if ($this->type == 'google' && ($visibility == 'private' || $visibility == 'confidential' || $status == 'cancelled')) {
183 183
 								continue;
184 184
 							}
185 185
 
186 186
 							// Event title & description.
187
-							$title = strip_tags( $event->getSummary() );
188
-							$title = sanitize_text_field( iconv( mb_detect_encoding( $title, mb_detect_order(), true ), 'UTF-8', $title ) );
189
-							$description = wp_kses_post( iconv( mb_detect_encoding( $event->getDescription(), mb_detect_order(), true ), 'UTF-8', $event->getDescription() ) );
187
+							$title = strip_tags($event->getSummary());
188
+							$title = sanitize_text_field(iconv(mb_detect_encoding($title, mb_detect_order(), true), 'UTF-8', $title));
189
+							$description = wp_kses_post(iconv(mb_detect_encoding($event->getDescription(), mb_detect_order(), true), 'UTF-8', $event->getDescription()));
190 190
 
191 191
 							$whole_day = false;
192 192
 
193 193
 							// Event start properties.
194
-							if( 'use_calendar' == $this->timezone_setting ) {
194
+							if ('use_calendar' == $this->timezone_setting) {
195 195
 								$start_timezone = ! $event->getStart()->timeZone ? $calendar['timezone'] : $event->getStart()->timeZone;
196 196
 							} else {
197 197
 								$start_timezone = $this->timezone;
198 198
 							}
199 199
 
200
-							if ( is_null( $event->getStart()->dateTime ) ) {
200
+							if (is_null($event->getStart()->dateTime)) {
201 201
 								// Whole day event.
202
-								$date = Carbon::parse( $event->getStart()->date );
203
-								$google_start = Carbon::createFromDate( $date->year, $date->month, $date->day, $start_timezone )->startOfDay()->addSeconds( 59 );
204
-								$google_start_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->addSeconds( 59 );
202
+								$date = Carbon::parse($event->getStart()->date);
203
+								$google_start = Carbon::createFromDate($date->year, $date->month, $date->day, $start_timezone)->startOfDay()->addSeconds(59);
204
+								$google_start_utc = Carbon::createFromDate($date->year, $date->month, $date->day, 'UTC')->startOfDay()->addSeconds(59);
205 205
 								$whole_day = true;
206 206
 							} else {
207
-								$date = Carbon::parse( $event->getStart()->dateTime );
207
+								$date = Carbon::parse($event->getStart()->dateTime);
208 208
 
209 209
 								// Check if there is an event level timezone
210
-								if( $event->getStart()->timeZone && 'use_calendar' == $this->timezone_setting ) {
210
+								if ($event->getStart()->timeZone && 'use_calendar' == $this->timezone_setting) {
211 211
 
212 212
 									// Get the two different times with the separate timezones so we can check the offsets next
213
-									$google_start1 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $date->timezone );
214
-									$google_start2 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $event->getStart()->timeZone );
213
+									$google_start1 = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $date->timezone);
214
+									$google_start2 = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $event->getStart()->timeZone);
215 215
 
216 216
 									// Get the offset in hours
217 217
 									$offset1 = $google_start1->offsetHours;
218 218
 									$offset2 = $google_start2->offsetHours;
219 219
 
220 220
 									// Get the difference between the two timezones
221
-									$total_offset = ( $offset2 - $offset1 );
221
+									$total_offset = ($offset2 - $offset1);
222 222
 
223 223
 									// Add the hours offset to the date hour
224 224
 									$date->hour += $total_offset;
225 225
 								}
226 226
 
227
-								$google_start = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $start_timezone );
228
-								$google_start_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' );
227
+								$google_start = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $start_timezone);
228
+								$google_start_utc = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC');
229 229
 
230 230
 								$this->timezone = $start_timezone;
231 231
 							}
@@ -236,43 +236,43 @@  discard block
 block discarded – undo
236 236
 
237 237
 							$end = $end_utc = $end_timezone = '';
238 238
 							$span = 0;
239
-							if ( false == $event->getEndTimeUnspecified() ) {
239
+							if (false == $event->getEndTimeUnspecified()) {
240 240
 
241 241
 								// Event end properties.
242
-								if( 'use_calendar' == $this->timezone_setting ) {
242
+								if ('use_calendar' == $this->timezone_setting) {
243 243
 									$end_timezone = ! $event->getEnd()->timeZone ? $calendar['timezone'] : $event->getEnd()->timeZone;
244 244
 								} else {
245 245
 									$end_timezone = $this->timezone;
246 246
 								}
247 247
 
248
-								if ( is_null( $event->getEnd()->dateTime ) ) {
248
+								if (is_null($event->getEnd()->dateTime)) {
249 249
 									// Whole day event.
250
-									$date           = Carbon::parse( $event->getEnd()->date );
251
-									$google_end     = Carbon::createFromDate( $date->year, $date->month, $date->day, $end_timezone )->startOfDay()->subSeconds( 59 );
252
-									$google_end_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->subSeconds( 59 );
250
+									$date           = Carbon::parse($event->getEnd()->date);
251
+									$google_end     = Carbon::createFromDate($date->year, $date->month, $date->day, $end_timezone)->startOfDay()->subSeconds(59);
252
+									$google_end_utc = Carbon::createFromDate($date->year, $date->month, $date->day, 'UTC')->startOfDay()->subSeconds(59);
253 253
 								} else {
254
-									$date = Carbon::parse( $event->getEnd()->dateTime );
254
+									$date = Carbon::parse($event->getEnd()->dateTime);
255 255
 
256 256
 									// Check if there is an event level timezone
257
-									if( $event->getEnd()->timeZone && 'use_calendar' == $this->timezone_setting ) {
257
+									if ($event->getEnd()->timeZone && 'use_calendar' == $this->timezone_setting) {
258 258
 
259 259
 										// Get the two different times with the separate timezones so we can check the offsets next
260
-										$google_start1 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $date->timezone );
261
-										$google_start2 = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $event->getEnd()->timeZone );
260
+										$google_start1 = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $date->timezone);
261
+										$google_start2 = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $event->getEnd()->timeZone);
262 262
 
263 263
 										// Get the offset in hours
264 264
 										$offset1 = $google_start1->offsetHours;
265 265
 										$offset2 = $google_start2->offsetHours;
266 266
 
267 267
 										// Get the difference between the two timezones
268
-										$total_offset = ( $offset2 - $offset1 );
268
+										$total_offset = ($offset2 - $offset1);
269 269
 
270 270
 										// Add the hours offset to the date hour
271 271
 										$date->hour += $total_offset;
272 272
 									}
273 273
 
274
-									$google_end     = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $end_timezone );
275
-									$google_end_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' );
274
+									$google_end     = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $end_timezone);
275
+									$google_end_utc = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC');
276 276
 								}
277 277
 								// End.
278 278
 								$end = $google_end->getTimestamp();
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 								$end_utc = $google_end_utc->getTimestamp();
281 281
 
282 282
 								// Count multiple days.
283
-								$span = $google_start->setTimezone( $calendar['timezone'] )->diffInDays( $google_end->setTimezone( $calendar['timezone'] ) );
283
+								$span = $google_start->setTimezone($calendar['timezone'])->diffInDays($google_end->setTimezone($calendar['timezone']));
284 284
 
285
-								if ( $span == 0 ) {
286
-									if ( $google_start->toDateString() !== $google_end->toDateString() ) {
285
+								if ($span == 0) {
286
+									if ($google_start->toDateString() !== $google_end->toDateString()) {
287 287
 										$span = 1;
288 288
 									}
289 289
 								}
@@ -298,19 +298,19 @@  discard block
 block discarded – undo
298 298
 							// Recurring event.
299 299
 							$recurrence = $event->getRecurrence();
300 300
 							$recurring_id = $event->getRecurringEventId();
301
-							if ( ! $recurrence && $recurring_id ) {
301
+							if ( ! $recurrence && $recurring_id) {
302 302
 								$recurrence = true;
303 303
 							}
304 304
 
305 305
 							// Event link.
306
-							if ( 'use_calendar' == $this->timezone_setting ) {
307
-								$link = add_query_arg( array( 'ctz' => $this->timezone ), $event->getHtmlLink() );
306
+							if ('use_calendar' == $this->timezone_setting) {
307
+								$link = add_query_arg(array('ctz' => $this->timezone), $event->getHtmlLink());
308 308
 							} else {
309 309
 								$link = $event->getHtmlLink();
310 310
 							}
311 311
 
312 312
 							// Build the event.
313
-							$calendar['events'][ intval( $start ) ][] = array(
313
+							$calendar['events'][intval($start)][] = array(
314 314
 								'type'           => 'google-calendar',
315 315
 								'source'         => $source,
316 316
 								'title'          => $title,
@@ -337,24 +337,24 @@  discard block
 block discarded – undo
337 337
 						}
338 338
 					}
339 339
 
340
-					if ( ! empty( $calendar['events'] ) ) {
340
+					if ( ! empty($calendar['events'])) {
341 341
 
342
-						ksort( $calendar['events'], SORT_NUMERIC );
342
+						ksort($calendar['events'], SORT_NUMERIC);
343 343
 
344 344
 						set_transient(
345
-							'_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type,
345
+							'_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type,
346 346
 							$calendar,
347
-							max( absint( $this->cache ), 1 ) // Since a value of 0 means forever we set the minimum here to 1 if the user has set it to be 0
347
+							max(absint($this->cache), 1) // Since a value of 0 means forever we set the minimum here to 1 if the user has set it to be 0
348 348
 						);
349 349
 					}
350 350
 				}
351 351
 
352 352
 			} else {
353 353
 
354
-				$message  = __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' );
355
-				$message .= '<br><br>' . $error . '<br><br>';
356
-				$message .= __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) . '<br><br>';
357
-				$message .= __( 'Only you can see this notice.', 'google-calendar-events' );
354
+				$message  = __('While trying to retrieve events, Google returned an error:', 'google-calendar-events');
355
+				$message .= '<br><br>'.$error.'<br><br>';
356
+				$message .= __('Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events').'<br><br>';
357
+				$message .= __('Only you can see this notice.', 'google-calendar-events');
358 358
 
359 359
 				return $message;
360 360
 			}
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
 		}
363 363
 
364 364
 		// If no timezone has been set, use calendar feed.
365
-		if ( 'use_calendar' == $this->timezone_setting && isset( $calendar['timezone'] ) ) {
365
+		if ('use_calendar' == $this->timezone_setting && isset($calendar['timezone'])) {
366 366
 			$this->timezone = $calendar['timezone'];
367 367
 		}
368 368
 
369
-		return isset( $calendar['events'] ) ? $calendar['events'] : array();
369
+		return isset($calendar['events']) ? $calendar['events'] : array();
370 370
 	}
371 371
 
372 372
 	/**
@@ -382,67 +382,67 @@  discard block
 block discarded – undo
382 382
 	 *
383 383
 	 * @throws \Exception On request failure will throw an exception from Google.
384 384
 	 */
385
-	public function make_request( $id = '', $time_min = 0, $time_max = 0 ) {
385
+	public function make_request($id = '', $time_min = 0, $time_max = 0) {
386 386
 
387 387
 		$calendar = array();
388 388
 		$google = $this->get_service();
389 389
 
390
-		if ( ! is_null( $google ) && ! empty( $id ) ) {
390
+		if ( ! is_null($google) && ! empty($id)) {
391 391
 
392 392
 			// Build the request args.
393 393
 			$args = array();
394 394
 
395 395
 			// Expand recurring events.
396
-			if ( $this->google_events_recurring == 'show' ) {
396
+			if ($this->google_events_recurring == 'show') {
397 397
 				$args['singleEvents'] = true;
398 398
 			}
399 399
 
400 400
 			// Query events using search terms.
401
-			if ( ! empty( $this->google_search_query ) ) {
402
-				$args['q'] = rawurlencode( $this->google_search_query );
401
+			if ( ! empty($this->google_search_query)) {
402
+				$args['q'] = rawurlencode($this->google_search_query);
403 403
 			}
404 404
 
405 405
 			// Max results to query.
406
-			$args['maxResults'] = strval( min( absint( $this->google_max_results ), 2500 ) );
406
+			$args['maxResults'] = strval(min(absint($this->google_max_results), 2500));
407 407
 
408 408
 			// Specify a timezone.
409 409
 			$timezone = '';
410
-			if ( 'use_calendar' != get_post_meta( $this->post_id, '_feed_timezone_setting', true ) ) {
410
+			if ('use_calendar' != get_post_meta($this->post_id, '_feed_timezone_setting', true)) {
411 411
 				$args['timeZone'] = $timezone = $this->timezone;
412 412
 			}
413 413
 
414 414
 			// Lower bound (inclusive) for an event's end time to filter by.
415
-			$earliest_event = intval( $this->time_min );
416
-			if ( $earliest_event > 0 ) {
415
+			$earliest_event = intval($this->time_min);
416
+			if ($earliest_event > 0) {
417 417
 				$timeMin = Carbon::now();
418
-				if ( ! empty( $timezone ) ) {
419
-					$timeMin->setTimezone( $timezone );
418
+				if ( ! empty($timezone)) {
419
+					$timeMin->setTimezone($timezone);
420 420
 				}
421
-				$timeMin->setTimestamp( $earliest_event );
421
+				$timeMin->setTimestamp($earliest_event);
422 422
 				$args['timeMin'] = $timeMin->toRfc3339String();
423 423
 			}
424 424
 
425 425
 			// Upper bound (exclusive) for an event's start time to filter by.
426
-			$latest_event = intval( $this->time_max );
427
-			if ( $latest_event > 0 ) {
426
+			$latest_event = intval($this->time_max);
427
+			if ($latest_event > 0) {
428 428
 				$timeMax = Carbon::now();
429
-				if ( ! empty( $timezone ) ) {
430
-					$timeMax->setTimezone( $timezone );
429
+				if ( ! empty($timezone)) {
430
+					$timeMax->setTimezone($timezone);
431 431
 				}
432
-				$timeMax->setTimestamp( $latest_event );
432
+				$timeMax->setTimestamp($latest_event);
433 433
 				$args['timeMax'] = $timeMax->toRfc3339String();
434 434
 			}
435 435
 
436 436
 			// Query events in calendar.
437
-			$response = $google->events->listEvents( $id, $args );
437
+			$response = $google->events->listEvents($id, $args);
438 438
 
439
-			if ( $response instanceof \Google_Service_Calendar_Events ) {
439
+			if ($response instanceof \Google_Service_Calendar_Events) {
440 440
 				$calendar = array(
441 441
 					'id'            => $id,
442 442
 					'title'         => $response->getSummary(),
443 443
 					'description'   => $response->getDescription(),
444 444
 					'timezone'      => $response->getTimeZone(),
445
-					'url'           => esc_url( '//www.google.com/calendar/embed?src=' . $id ),
445
+					'url'           => esc_url('//www.google.com/calendar/embed?src='.$id),
446 446
 					'events'        => $response->getItems(),
447 447
 				);
448 448
 			}
@@ -462,10 +462,10 @@  discard block
 block discarded – undo
462 462
 	private function get_client() {
463 463
 
464 464
 		$client = new \Google_Client();
465
-		$client->setApplicationName( 'Simple Calendar' );
466
-		$client->setScopes( $this->google_client_scopes );
467
-		$client->setDeveloperKey( $this->google_api_key );
468
-		$client->setAccessType( 'online' );
465
+		$client->setApplicationName('Simple Calendar');
466
+		$client->setScopes($this->google_client_scopes);
467
+		$client->setDeveloperKey($this->google_api_key);
468
+		$client->setAccessType('online');
469 469
 
470 470
 		return $client;
471 471
 	}
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 	 * @return null|\Google_Service_Calendar
480 480
 	 */
481 481
 	protected function get_service() {
482
-		return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar( $this->google_client ) : null;
482
+		return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar($this->google_client) : null;
483 483
 	}
484 484
 
485 485
 }
Please login to merge, or discard this patch.
includes/main.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -6,8 +6,6 @@
 block discarded – undo
6 6
  */
7 7
 namespace SimpleCalendar;
8 8
 
9
-use SimpleCalendar\Admin\License_Manager;
10
-
11 9
 if ( ! defined( 'ABSPATH' ) ) {
12 10
 	exit;
13 11
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use SimpleCalendar\Admin\License_Manager;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @return Plugin
72 72
 	 */
73 73
 	public static function get_instance() {
74
-		if ( is_null( self::$_instance ) ) {
74
+		if (is_null(self::$_instance)) {
75 75
 			self::$_instance = new self();
76 76
 		}
77 77
 		return self::$_instance;
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 	 * Cloning is forbidden.
82 82
 	 */
83 83
 	public function __clone() {
84
-		_doing_it_wrong( __FUNCTION__, 'Cloning the main instance of this plugin is forbidden.', '1.0.0' );
84
+		_doing_it_wrong(__FUNCTION__, 'Cloning the main instance of this plugin is forbidden.', '1.0.0');
85 85
 	}
86 86
 
87 87
 	/**
88 88
 	 * Unserializing instances of this class is forbidden.
89 89
 	 */
90 90
 	public function __wakeup() {
91
-		_doing_it_wrong( __FUNCTION__, 'Unserializing instances of this plugin is forbidden.', '1.0.0' );
91
+		_doing_it_wrong(__FUNCTION__, 'Unserializing instances of this plugin is forbidden.', '1.0.0');
92 92
 	}
93 93
 
94 94
 	/**
@@ -100,22 +100,22 @@  discard block
 block discarded – undo
100 100
 
101 101
 		// Load plugin.
102 102
 		require_once 'autoload.php';
103
-		$this->locale = apply_filters( 'plugin_locale', get_locale(), 'google-calendar-events' );
103
+		$this->locale = apply_filters('plugin_locale', get_locale(), 'google-calendar-events');
104 104
 		$this->load();
105 105
 
106 106
 		// Installation hooks.
107
-		register_activation_hook( SIMPLE_CALENDAR_MAIN_FILE, array( 'SimpleCalendar\Installation', 'activate' ) );
108
-		register_deactivation_hook( SIMPLE_CALENDAR_MAIN_FILE, array( 'SimpleCalendar\Installation', 'deactivate' ) );
107
+		register_activation_hook(SIMPLE_CALENDAR_MAIN_FILE, array('SimpleCalendar\Installation', 'activate'));
108
+		register_deactivation_hook(SIMPLE_CALENDAR_MAIN_FILE, array('SimpleCalendar\Installation', 'deactivate'));
109 109
 
110 110
 		// Do update call here.
111
-		add_action( 'admin_init', array( $this, 'update' ), 999 );
111
+		add_action('admin_init', array($this, 'update'), 999);
112 112
 
113 113
 		// Init hooks.
114
-		add_action( 'init', array( $this, 'init' ), 5 );
115
-		add_action( 'admin_init', array( $this, 'register_settings' ), 5 );
114
+		add_action('init', array($this, 'init'), 5);
115
+		add_action('admin_init', array($this, 'register_settings'), 5);
116 116
 
117 117
 		// Upon plugin loaded action hook.
118
-		do_action( 'simcal_loaded' );
118
+		do_action('simcal_loaded');
119 119
 	}
120 120
 
121 121
 	/**
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		new Post_Types();
133 133
 
134 134
 		// Load back end.
135
-		if ( is_admin() ) {
135
+		if (is_admin()) {
136 136
 			$this->load_admin();
137 137
 		} else {
138 138
 			// Load front end scripts and styles.
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 		// Init menus and settings.
175 175
 		new Admin\Menus();
176 176
 
177
-		if ( defined( 'DOING_AJAX' ) ) {
177
+		if (defined('DOING_AJAX')) {
178 178
 			// Admin ajax callbacks.
179 179
 			new Admin\Ajax();
180 180
 		}
@@ -188,16 +188,16 @@  discard block
 block discarded – undo
188 188
 	public function init() {
189 189
 
190 190
 		// Before init action hook.
191
-		do_action( 'before_simcal_init' );
191
+		do_action('before_simcal_init');
192 192
 
193 193
 		// Set up localization.
194
-		load_plugin_textdomain( 'google-calendar-events', false, dirname( plugin_basename( SIMPLE_CALENDAR_MAIN_FILE ) ) . '/i18n/' );
194
+		load_plugin_textdomain('google-calendar-events', false, dirname(plugin_basename(SIMPLE_CALENDAR_MAIN_FILE)).'/i18n/');
195 195
 
196 196
 		// Init objects factory.
197 197
 		$this->objects = new Objects();
198 198
 
199 199
 		// Upon init action hook.
200
-		do_action( 'simcal_init' );
200
+		do_action('simcal_init');
201 201
 	}
202 202
 
203 203
 	/**
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	 * @since 3.0.0
207 207
 	 */
208 208
 	public function register_settings() {
209
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
209
+		if (is_admin() && ! defined('DOING_AJAX')) {
210 210
 			$settings = new Admin\Pages();
211
-			$settings->register_settings( $settings->get_settings() );
211
+			$settings->register_settings($settings->get_settings());
212 212
 		}
213 213
 	}
214 214
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @return string
221 221
 	 */
222 222
 	public function ajax_url() {
223
-		return admin_url( 'admin-ajax.php', 'relative' );
223
+		return admin_url('admin-ajax.php', 'relative');
224 224
 	}
225 225
 
226 226
 	/**
@@ -232,17 +232,17 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @return string
234 234
 	 */
235
-	public function get_url( $case ) {
236
-		switch ( $case ) {
235
+	public function get_url($case) {
236
+		switch ($case) {
237 237
 			case 'codex' :
238 238
 			case 'apidocs' :
239 239
 				return 'http://codex.simplecalendar.io';
240 240
 			case 'addons' :
241
-				return self::$homepage . '/addons/';
241
+				return self::$homepage.'/addons/';
242 242
 			case 'gcal-pro' :
243
-				return self::$homepage . '/addons/google-calendar-pro/';
243
+				return self::$homepage.'/addons/google-calendar-pro/';
244 244
 			case 'fullcal' :
245
-				return self::$homepage . '/addons/full-calendar/';
245
+				return self::$homepage.'/addons/full-calendar/';
246 246
 			case 'docs' :
247 247
 				return 'http://docs.simplecalendar.io';
248 248
 			case 'github' :
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * @since 3.0.0
264 264
 	 */
265 265
 	public static function update() {
266
-		$update = new Update( SIMPLE_CALENDAR_VERSION );
266
+		$update = new Update(SIMPLE_CALENDAR_VERSION);
267 267
 	}
268 268
 
269 269
 }
Please login to merge, or discard this patch.
includes/abstracts/admin-page.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  */
7 7
 namespace SimpleCalendar\Abstracts;
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
@@ -84,27 +84,27 @@  discard block
 block discarded – undo
84 84
 
85 85
 		$settings = array();
86 86
 
87
-		$settings[ $this->id ] = array(
87
+		$settings[$this->id] = array(
88 88
 			'label'         => $this->label,
89 89
 			'description'   => $this->description,
90 90
 		);
91 91
 
92
-		if ( ! empty( $this->sections ) && is_array( $this->sections ) ) {
92
+		if ( ! empty($this->sections) && is_array($this->sections)) {
93 93
 
94
-			foreach ( $this->sections as $section => $content ) {
94
+			foreach ($this->sections as $section => $content) {
95 95
 
96
-				$settings[ $this->id ]['sections'][ $section ] = array(
97
-					'title'         => isset( $content['title'] ) ? $content['title'] : '',
98
-					'description'   => isset( $content['description'] ) ? $content['description'] : '',
99
-					'callback'      => array( $this, 'add_settings_section_callback' ),
100
-					'fields'        => isset( $this->fields[ $section ] ) ? $this->fields[ $section ] : '',
96
+				$settings[$this->id]['sections'][$section] = array(
97
+					'title'         => isset($content['title']) ? $content['title'] : '',
98
+					'description'   => isset($content['description']) ? $content['description'] : '',
99
+					'callback'      => array($this, 'add_settings_section_callback'),
100
+					'fields'        => isset($this->fields[$section]) ? $this->fields[$section] : '',
101 101
 				);
102 102
 
103 103
 			}
104 104
 
105 105
 		}
106 106
 
107
-		return apply_filters( 'simcal_get_' . $this->option_group . '_' . $this->id , $settings );
107
+		return apply_filters('simcal_get_'.$this->option_group.'_'.$this->id, $settings);
108 108
 	}
109 109
 
110 110
 	/**
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @return string
120 120
 	 */
121
-	protected function get_option_value( $section, $setting ) {
121
+	protected function get_option_value($section, $setting) {
122 122
 
123 123
 		$option = $this->values;
124 124
 
125
-		if ( ! empty( $option ) && is_array( $option ) ) {
126
-			return isset( $option[ $section ][ $setting ] ) ? $option[ $section ][ $setting ] : '';
125
+		if ( ! empty($option) && is_array($option)) {
126
+			return isset($option[$section][$setting]) ? $option[$section][$setting] : '';
127 127
 		}
128 128
 
129 129
 		return '';
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 	 *
157 157
 	 * @return string
158 158
 	 */
159
-	public function add_settings_section_callback( $section ) {
159
+	public function add_settings_section_callback($section) {
160 160
 
161
-		$callback    = isset( $section['callback'][0] ) ? $section['callback'][0] : '';
162
-		$sections    = isset( $callback->sections ) ? $callback->sections : '';
163
-		$description = isset( $sections[ $section['id'] ]['description'] ) ? $sections[ $section['id'] ]['description'] : '';
164
-		$default     = $description ? '<p>' . $description . '</p>' : '';
161
+		$callback    = isset($section['callback'][0]) ? $section['callback'][0] : '';
162
+		$sections    = isset($callback->sections) ? $callback->sections : '';
163
+		$description = isset($sections[$section['id']]['description']) ? $sections[$section['id']]['description'] : '';
164
+		$default     = $description ? '<p>'.$description.'</p>' : '';
165 165
 
166
-		echo apply_filters( 'simcal_' . $this->option_group . '_' . $this->id . '_sections_callback', $default );
166
+		echo apply_filters('simcal_'.$this->option_group.'_'.$this->id.'_sections_callback', $default);
167 167
 	}
168 168
 
169 169
 	/**
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
 	 *
178 178
 	 * @return array Sanitized settings.
179 179
 	 */
180
-	public function validate( $settings ) {
180
+	public function validate($settings) {
181 181
 
182 182
 		$sanitized = '';
183 183
 
184
-		if ( is_array( $settings ) ) {
185
-			foreach ( $settings as $k => $v ) {
186
-				$sanitized[ $k ] = simcal_sanitize_input( $v );
184
+		if (is_array($settings)) {
185
+			foreach ($settings as $k => $v) {
186
+				$sanitized[$k] = simcal_sanitize_input($v);
187 187
 			}
188 188
 		} else {
189
-			$sanitized = simcal_sanitize_input( $settings );
189
+			$sanitized = simcal_sanitize_input($settings);
190 190
 		}
191 191
 
192 192
 		return $sanitized;
Please login to merge, or discard this patch.
includes/abstracts/calendar-view.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  */
7 7
 namespace SimpleCalendar\Abstracts;
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param mixed $args
28 28
 	 */
29
-	public function __construct( $args = '' );
29
+	public function __construct($args = '');
30 30
 
31 31
 	/**
32 32
 	 * Return the parent calendar type.
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return array
77 77
 	 */
78
-	public function scripts( $min = '' );
78
+	public function scripts($min = '');
79 79
 
80 80
 	/**
81 81
 	 * Styles.
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return array
90 90
 	 */
91
-	public function styles( $min = '' );
91
+	public function styles($min = '');
92 92
 
93 93
 	/**
94 94
 	 * Print HTML.
Please login to merge, or discard this patch.
includes/abstracts/meta-box.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  */
7 7
 namespace SimpleCalendar\Abstracts;
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @return void
30 30
 	 */
31
-	public static function html( $post );
31
+	public static function html($post);
32 32
 
33 33
 	/**
34 34
 	 * Validate and save the meta box fields.
@@ -40,6 +40,6 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return void
42 42
 	 */
43
-	public static function save( $post_id, $post );
43
+	public static function save($post_id, $post);
44 44
 
45 45
 }
Please login to merge, or discard this patch.
includes/abstracts/widget.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  */
7 7
 namespace SimpleCalendar\Abstracts;
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @return void
38 38
 	 */
39
-	public function widget( $args, $instance );
39
+	public function widget($args, $instance);
40 40
 
41 41
 	/**
42 42
 	 * Update a particular instance of the widget.
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return array Settings to save or bool false to cancel saving.
54 54
 	 */
55
-	public function update( $new_instance, $old_instance );
55
+	public function update($new_instance, $old_instance);
56 56
 
57 57
 	/**
58 58
 	 * Print the settings update form.
@@ -63,6 +63,6 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return string
65 65
 	 */
66
-	public function form( $instance );
66
+	public function form($instance);
67 67
 
68 68
 }
Please login to merge, or discard this patch.
includes/admin/bulk-actions.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 namespace SimpleCalendar\Admin;
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @param string $post_type
43 43
 	 */
44
-	public function __construct( $post_type ) {
45
-		$this->bulk_action_post_type = post_type_exists( $post_type ) ? $post_type : '';
44
+	public function __construct($post_type) {
45
+		$this->bulk_action_post_type = post_type_exists($post_type) ? $post_type : '';
46 46
 	}
47 47
 
48 48
 	/**
@@ -53,16 +53,16 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @param array $args
55 55
 	 */
56
-	public function register_bulk_action( $args ) {
56
+	public function register_bulk_action($args) {
57 57
 
58 58
 		$func = array();
59
-		$func['action_name']  = isset( $args['action_name'] )  ? sanitize_key( $args['action_name'] ) : '';
60
-		$func['callback']     = isset( $args['callback'] )     ? $args['callback'] : '';
61
-		$func['menu_text']    = isset( $args['menu_text'] )    ? esc_attr( $args['menu_text'] ) : '';
62
-		$func['admin_notice'] = isset( $args['admin_notice'] ) ? esc_attr( $args['admin_notice'] ) : '';
59
+		$func['action_name']  = isset($args['action_name']) ? sanitize_key($args['action_name']) : '';
60
+		$func['callback']     = isset($args['callback']) ? $args['callback'] : '';
61
+		$func['menu_text']    = isset($args['menu_text']) ? esc_attr($args['menu_text']) : '';
62
+		$func['admin_notice'] = isset($args['admin_notice']) ? esc_attr($args['admin_notice']) : '';
63 63
 
64
-		if ( $func['action_name'] && $func['callback'] ) {
65
-			$this->actions[ $func['action_name'] ] = $func;
64
+		if ($func['action_name'] && $func['callback']) {
65
+			$this->actions[$func['action_name']] = $func;
66 66
 		}
67 67
 	}
68 68
 
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 	 * @since 3.0.0
75 75
 	 */
76 76
 	public function init() {
77
-		if ( is_admin() ) {
78
-			add_action( 'admin_footer-edit.php', array( $this, 'custom_bulk_admin_footer' ) );
79
-			add_action( 'load-edit.php',         array( $this, 'custom_bulk_action' ) );
80
-			add_action( 'admin_notices',         array( $this, 'custom_bulk_admin_notices' ) );
77
+		if (is_admin()) {
78
+			add_action('admin_footer-edit.php', array($this, 'custom_bulk_admin_footer'));
79
+			add_action('load-edit.php', array($this, 'custom_bulk_action'));
80
+			add_action('admin_notices', array($this, 'custom_bulk_admin_notices'));
81 81
 		}
82 82
 	}
83 83
 
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 		global $post_type;
92 92
 
93 93
 		// Only permit actions with defined post type.
94
-		if ( $post_type == $this->bulk_action_post_type ) {
94
+		if ($post_type == $this->bulk_action_post_type) {
95 95
 
96 96
 			?>
97 97
 			<script type="text/javascript">
98 98
 				jQuery( document ).ready( function() {
99
-					<?php foreach ( $this->actions as $action_name => $action ) : ?>
99
+					<?php foreach ($this->actions as $action_name => $action) : ?>
100 100
 						jQuery( '<option>' ).val( '<?php echo $action_name ?>' ).text( '<?php echo $action['menu_text'] ?>').appendTo( 'select[name="action"]'  );
101 101
 						jQuery( '<option>' ).val( '<?php echo $action_name ?>' ).text( '<?php echo $action['menu_text'] ?>').appendTo( 'select[name="action2"]' );
102 102
 					<?php endforeach; ?>
@@ -120,65 +120,65 @@  discard block
 block discarded – undo
120 120
 		global $typenow;
121 121
 		$post_type = $typenow;
122 122
 
123
-		if ( $post_type == $this->bulk_action_post_type ) {
123
+		if ($post_type == $this->bulk_action_post_type) {
124 124
 
125 125
 			// Get the action.
126 126
 			// Depending on your resource type this could be WP_Users_List_Table, WP_Comments_List_Table, etc.
127
-			$wp_list_table = _get_list_table( 'WP_Posts_List_Table' );
127
+			$wp_list_table = _get_list_table('WP_Posts_List_Table');
128 128
 			$action = $wp_list_table->current_action();
129 129
 
130 130
 			// Allow only defined actions.
131
-			$allowed_actions = array_keys( $this->actions );
132
-			if ( ! in_array( $action, $allowed_actions ) ) {
131
+			$allowed_actions = array_keys($this->actions);
132
+			if ( ! in_array($action, $allowed_actions)) {
133 133
 				return;
134 134
 			}
135 135
 
136 136
 			// Security check.
137
-			check_admin_referer( 'bulk-posts' );
137
+			check_admin_referer('bulk-posts');
138 138
 
139 139
 			// Make sure ids are submitted.
140 140
 			// Depending on the resource type, this may be 'media' or 'ids'.
141
-			if ( isset( $_REQUEST['post'] ) ) {
142
-				$post_ids = array_map( 'intval', $_REQUEST['post'] );
141
+			if (isset($_REQUEST['post'])) {
142
+				$post_ids = array_map('intval', $_REQUEST['post']);
143 143
 			}
144 144
 
145
-			if ( empty( $post_ids ) ) {
145
+			if (empty($post_ids)) {
146 146
 				return;
147 147
 			}
148 148
 
149 149
 			// This is based on wp-admin/edit.php.
150 150
 			$sendback = remove_query_arg(
151
-				array( 'exported', 'untrashed', 'deleted', 'ids' ),
151
+				array('exported', 'untrashed', 'deleted', 'ids'),
152 152
 				wp_get_referer()
153 153
 			);
154
-			if ( ! $sendback ) {
155
-				$sendback = admin_url( "edit.php?post_type=$post_type" );
154
+			if ( ! $sendback) {
155
+				$sendback = admin_url("edit.php?post_type=$post_type");
156 156
 			}
157 157
 
158 158
 			$pagenum  = $wp_list_table->get_pagenum();
159
-			$sendback = add_query_arg( 'paged', $pagenum, $sendback );
159
+			$sendback = add_query_arg('paged', $pagenum, $sendback);
160 160
 
161 161
 			// Check that we have anonymous function as a callback.
162
-			$anon_fns = array_filter( $this->actions[ $action ], function( $el ) {
162
+			$anon_fns = array_filter($this->actions[$action], function($el) {
163 163
 				return $el instanceof \Closure;
164 164
 			} );
165 165
 
166
-			if ( count( $anon_fns ) > 0 ) {
167
-				$this->actions[ $action ]['callback']( $post_ids );
166
+			if (count($anon_fns) > 0) {
167
+				$this->actions[$action]['callback']($post_ids);
168 168
 			} else {
169
-				call_user_func( $this->actions[ $action ]['callback'], $post_ids );
169
+				call_user_func($this->actions[$action]['callback'], $post_ids);
170 170
 			}
171 171
 
172 172
 			$sendback = add_query_arg(
173
-				array( 'success_action' => $action, 'ids' => join( ',', $post_ids ) ),
173
+				array('success_action' => $action, 'ids' => join(',', $post_ids)),
174 174
 				$sendback
175 175
 			);
176 176
 			$sendback = remove_query_arg(
177
-				array( 'action', 'paged', 'mode', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view' ),
177
+				array('action', 'paged', 'mode', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'),
178 178
 				$sendback
179 179
 			);
180 180
 
181
-			wp_redirect( $sendback );
181
+			wp_redirect($sendback);
182 182
 
183 183
 			exit;
184 184
 		}
@@ -193,31 +193,31 @@  discard block
 block discarded – undo
193 193
 
194 194
 		global $post_type, $pagenow;
195 195
 
196
-		if ( isset( $_REQUEST['ids'] ) ) {
197
-			$post_ids = explode( ',', $_REQUEST['ids'] );
196
+		if (isset($_REQUEST['ids'])) {
197
+			$post_ids = explode(',', $_REQUEST['ids']);
198 198
 		}
199 199
 
200 200
 		// Make sure ids are submitted.
201 201
 		// Depending on the resource type, this may be 'media' or 'ids'.
202
-		if ( empty( $post_ids ) ) {
202
+		if (empty($post_ids)) {
203 203
 			return;
204 204
 		}
205 205
 
206
-		$post_ids_count = is_array( $post_ids ) ? count( $post_ids ) : 1;
206
+		$post_ids_count = is_array($post_ids) ? count($post_ids) : 1;
207 207
 
208
-		if ( $pagenow == 'edit.php' && $post_type == $this->bulk_action_post_type ) {
208
+		if ($pagenow == 'edit.php' && $post_type == $this->bulk_action_post_type) {
209 209
 
210
-			if ( isset( $_REQUEST['success_action'] ) ) {
210
+			if (isset($_REQUEST['success_action'])) {
211 211
 
212 212
 				// Print notice in admin bar.
213
-				$message = $this->actions[ $_REQUEST['success_action'] ]['admin_notice'];
213
+				$message = $this->actions[$_REQUEST['success_action']]['admin_notice'];
214 214
 
215
-				if ( is_array( $message ) ) {
216
-					$message = sprintf( _n( $message['single'], $message['plural'], $post_ids_count, 'google-calendar-events' ), $post_ids_count );
215
+				if (is_array($message)) {
216
+					$message = sprintf(_n($message['single'], $message['plural'], $post_ids_count, 'google-calendar-events'), $post_ids_count);
217 217
 				}
218 218
 
219 219
 				$class = 'updated notice is-dismissible above-h2';
220
-				if ( ! empty( $message ) ) {
220
+				if ( ! empty($message)) {
221 221
 					echo "<div class=\"{$class}\"><p>{$message}</p></div>";
222 222
 				}
223 223
 			}
Please login to merge, or discard this patch.
includes/admin/fields/date-picker.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@
 block discarded – undo
95 95
 				}
96 96
 
97 97
 			} else {
98
-			    // @todo eventually if a date range picker is needed, this can be extended
98
+				// @todo eventually if a date range picker is needed, this can be extended
99 99
 			}
100 100
 
101 101
 			?>
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use SimpleCalendar\Abstracts\Field;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @param array $field
47 47
 	 */
48
-	public function __construct( $field ) {
48
+	public function __construct($field) {
49 49
 
50
-		$this->range  = isset( $field['range'] )  ? ( $field['range'] === true ? true : false ) : false;
51
-		$this->inline = isset( $field['inline'] ) ? ( $field['inline'] === true ? true : false ) : true;
50
+		$this->range  = isset($field['range']) ? ($field['range'] === true ? true : false) : false;
51
+		$this->inline = isset($field['inline']) ? ($field['inline'] === true ? true : false) : true;
52 52
 
53 53
 		$subtype = $this->range === true ? 'simcal-field-date-picker-range ' : '';
54
-		$this->type_class = 'simcal-field-date-picker ' . $subtype;
54
+		$this->type_class = 'simcal-field-date-picker '.$subtype;
55 55
 
56 56
 		$data = array(
57 57
 			'data-inline' => $this->inline === true ? 'true' : 'false',
58 58
 		);
59
-		$field['attributes'] = isset( $field['attributes'] ) ? array_merge( $field['attributes'], $data ) : $data;
59
+		$field['attributes'] = isset($field['attributes']) ? array_merge($field['attributes'], $data) : $data;
60 60
 
61
-		parent::__construct( $field );
61
+		parent::__construct($field);
62 62
 	}
63 63
 
64 64
 	/**
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function html() {
70 70
 
71
-		if ( ! empty( $this->description ) ) {
72
-			echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>';
71
+		if ( ! empty($this->description)) {
72
+			echo '<p class="description">'.wp_kses_post($this->description).'</p>';
73 73
 		}
74 74
 
75 75
 		?>
76 76
 		<div id="<?php echo $this->id; ?>"
77 77
 		     class="<?php echo $this->class; ?>"
78
-		     <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?>
78
+		     <?php echo $this->style ? 'style="'.$this->style.'"' : ''; ?>
79 79
 			 <?php echo $this->attributes ?>>
80 80
 			<?php
81 81
 
82
-			if ( false === $this->range ) {
82
+			if (false === $this->range) {
83 83
 
84 84
 				?>
85 85
 				<i class="simcal-icon-calendar"></i>
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 				       readonly="readonly" />
91 91
 				<?php
92 92
 
93
-				if ( true === $this->inline ) {
93
+				if (true === $this->inline) {
94 94
 					echo $this->tooltip;
95 95
 				}
96 96
 
Please login to merge, or discard this patch.