Completed
Push — master ( a00b53...3dc4d8 )
by
unknown
21:18
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 2 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.
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 use SimpleCalendar\Abstracts\Feed;
13 13
 use SimpleCalendar\Feeds\Admin\Google_Admin as Admin;
14 14
 
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -90,34 +90,34 @@  discard block
 block discarded – undo
90 90
 	 * @param string|Calendar $calendar
91 91
 	 * @param bool $load_admin
92 92
 	 */
93
-	public function __construct( $calendar = '', $load_admin = true ) {
93
+	public function __construct($calendar = '', $load_admin = true) {
94 94
 
95
-		parent::__construct( $calendar );
95
+		parent::__construct($calendar);
96 96
 
97 97
 		$this->type = 'google';
98
-		$this->name = __( 'Google Calendar', 'google-calendar-events' );
98
+		$this->name = __('Google Calendar', 'google-calendar-events');
99 99
 
100 100
 		// Google client config.
101
-		$settings = get_option( 'simple-calendar_settings_feeds' );
102
-		$this->google_api_key = isset( $settings['google']['api_key'] ) ? esc_attr( $settings['google']['api_key'] ) : '';
103
-		$this->google_client_scopes = array( \Google_Service_Calendar::CALENDAR_READONLY );
101
+		$settings = get_option('simple-calendar_settings_feeds');
102
+		$this->google_api_key = isset($settings['google']['api_key']) ? esc_attr($settings['google']['api_key']) : '';
103
+		$this->google_client_scopes = array(\Google_Service_Calendar::CALENDAR_READONLY);
104 104
 		$this->google_client = $this->get_client();
105 105
 
106
-		if ( $this->post_id > 0 ) {
106
+		if ($this->post_id > 0) {
107 107
 
108 108
 			// Google query args.
109
-			$this->google_calendar_id       = $this->esc_google_calendar_id( get_post_meta( $this->post_id, '_google_calendar_id', true ) );
110
-			$this->google_events_recurring  = esc_attr( get_post_meta( $this->post_id, '_google_events_recurring', true ) );
111
-			$this->google_search_query      = esc_attr( get_post_meta( $this->post_id, '_google_events_search_query', true ) );
112
-			$this->google_max_results       = max( absint( get_post_meta( $this->post_id, '_google_events_max_results', true ) ), 1 );
109
+			$this->google_calendar_id       = $this->esc_google_calendar_id(get_post_meta($this->post_id, '_google_calendar_id', true));
110
+			$this->google_events_recurring  = esc_attr(get_post_meta($this->post_id, '_google_events_recurring', true));
111
+			$this->google_search_query      = esc_attr(get_post_meta($this->post_id, '_google_events_search_query', true));
112
+			$this->google_max_results       = max(absint(get_post_meta($this->post_id, '_google_events_max_results', true)), 1);
113 113
 
114
-			if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
115
-				$this->events = ! empty( $this->google_api_key ) ? $this->get_events() : array();
114
+			if ( ! is_admin() || defined('DOING_AJAX')) {
115
+				$this->events = ! empty($this->google_api_key) ? $this->get_events() : array();
116 116
 			}
117 117
 		}
118 118
 
119
-		if ( is_admin() && $load_admin ) {
120
-			$admin = new Admin( $this, $this->google_api_key, $this->google_calendar_id );
119
+		if (is_admin() && $load_admin) {
120
+			$admin = new Admin($this, $this->google_api_key, $this->google_calendar_id);
121 121
 			$this->settings = $admin->settings_fields();
122 122
 		}
123 123
 	}
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return string
133 133
 	 */
134
-	public function esc_google_calendar_id( $id ) {
135
-		return base64_decode( $id );
134
+	public function esc_google_calendar_id($id) {
135
+		return base64_decode($id);
136 136
 	}
137 137
 
138 138
 	/**
@@ -146,59 +146,59 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public function get_events() {
148 148
 
149
-		$calendar = get_transient( '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type );
149
+		$calendar = get_transient('_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type);
150 150
 
151
-		if ( empty( $calendar ) && ! empty( $this->google_calendar_id ) ) {
151
+		if (empty($calendar) && ! empty($this->google_calendar_id)) {
152 152
 
153 153
 			$error = '';
154 154
 
155 155
 			try {
156
-				$response = $this->make_request( $this->google_calendar_id );
157
-			} catch ( \Exception $e ) {
156
+				$response = $this->make_request($this->google_calendar_id);
157
+			} catch (\Exception $e) {
158 158
 				$error .= $e->getMessage();
159 159
 			}
160 160
 
161
-			if ( empty( $error ) && isset( $response['events'] ) && isset( $response['timezone'] ) ) {
161
+			if (empty($error) && isset($response['events']) && isset($response['timezone'])) {
162 162
 
163
-				$calendar = array_merge( $response, array( 'events' => array() ) );
163
+				$calendar = array_merge($response, array('events' => array()));
164 164
 
165 165
 				// If no timezone has been set, use calendar feed.
166
-				if ( 'use_calendar' == $this->timezone_setting ) {
166
+				if ('use_calendar' == $this->timezone_setting) {
167 167
 					$this->timezone = $calendar['timezone'];
168 168
 				}
169 169
 
170
-				$source = isset( $response['title'] ) ? sanitize_text_field( $response['title'] ) : '';
170
+				$source = isset($response['title']) ? sanitize_text_field($response['title']) : '';
171 171
 
172
-				if ( ! empty( $response['events'] ) && is_array( $response['events'] ) ) {
173
-					foreach ( $response['events'] as $event ) {
174
-						if ( $event instanceof \Google_Service_Calendar_Event ) {
172
+				if ( ! empty($response['events']) && is_array($response['events'])) {
173
+					foreach ($response['events'] as $event) {
174
+						if ($event instanceof \Google_Service_Calendar_Event) {
175 175
 
176 176
 							// Visibility.
177 177
 							$visibility = $event->getVisibility();
178 178
 							// Public calendars may have private events which can't be properly accessed by simple api key method.
179
-							if ( $this->type == 'google' && ( $visibility == 'private' || $visibility == 'confidential' ) ) {
179
+							if ($this->type == 'google' && ($visibility == 'private' || $visibility == 'confidential')) {
180 180
 								continue;
181 181
 							}
182 182
 
183 183
 							// Event title & description.
184
-							$title = strip_tags( $event->getSummary() );
185
-							$title = sanitize_text_field( iconv( mb_detect_encoding( $title, mb_detect_order(), true ), 'UTF-8', $title ) );
186
-							$description = wp_kses_post( iconv( mb_detect_encoding( $event->getDescription(), mb_detect_order(), true ), 'UTF-8', $event->getDescription() ) );
184
+							$title = strip_tags($event->getSummary());
185
+							$title = sanitize_text_field(iconv(mb_detect_encoding($title, mb_detect_order(), true), 'UTF-8', $title));
186
+							$description = wp_kses_post(iconv(mb_detect_encoding($event->getDescription(), mb_detect_order(), true), 'UTF-8', $event->getDescription()));
187 187
 
188 188
 							$whole_day = false;
189 189
 
190 190
 							// Event start properties.
191 191
 							$start_timezone = ! $event->getStart()->timeZone ? $calendar['timezone'] : $event->getStart()->timeZone;
192
-							if ( is_null( $event->getStart()->dateTime ) ) {
192
+							if (is_null($event->getStart()->dateTime)) {
193 193
 								// Whole day event.
194
-								$date = Carbon::parse( $event->getStart()->date );
195
-								$google_start = Carbon::createFromDate( $date->year, $date->month, $date->day, $start_timezone )->startOfDay()->addSeconds( 59 );
196
-								$google_start_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->addSeconds( 59 );
194
+								$date = Carbon::parse($event->getStart()->date);
195
+								$google_start = Carbon::createFromDate($date->year, $date->month, $date->day, $start_timezone)->startOfDay()->addSeconds(59);
196
+								$google_start_utc = Carbon::createFromDate($date->year, $date->month, $date->day, 'UTC')->startOfDay()->addSeconds(59);
197 197
 								$whole_day = true;
198 198
 							} else {
199
-								$date = Carbon::parse( $event->getStart()->dateTime );
200
-								$google_start     = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $start_timezone );
201
-								$google_start_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' );
199
+								$date = Carbon::parse($event->getStart()->dateTime);
200
+								$google_start     = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $start_timezone);
201
+								$google_start_utc = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC');
202 202
 							}
203 203
 							// Start.
204 204
 							$start = $google_start->getTimestamp();
@@ -207,19 +207,19 @@  discard block
 block discarded – undo
207 207
 
208 208
 							$end = $end_utc = $end_timezone = '';
209 209
 							$span = 0;
210
-							if ( false == $event->getEndTimeUnspecified() ) {
210
+							if (false == $event->getEndTimeUnspecified()) {
211 211
 
212 212
 								// Event end properties.
213 213
 								$end_timezone = ! $event->getEnd()->timeZone ? $calendar['timezone'] : $event->getEnd()->timeZone;
214
-								if ( is_null( $event->getEnd()->dateTime ) ) {
214
+								if (is_null($event->getEnd()->dateTime)) {
215 215
 									// Whole day event.
216
-									$date           = Carbon::parse( $event->getEnd()->date );
217
-									$google_end     = Carbon::createFromDate( $date->year, $date->month, $date->day, $end_timezone )->startOfDay()->subSeconds( 59 );
218
-									$google_end_utc = Carbon::createFromDate( $date->year, $date->month, $date->day, 'UTC' )->startOfDay()->subSeconds( 59 );
216
+									$date           = Carbon::parse($event->getEnd()->date);
217
+									$google_end     = Carbon::createFromDate($date->year, $date->month, $date->day, $end_timezone)->startOfDay()->subSeconds(59);
218
+									$google_end_utc = Carbon::createFromDate($date->year, $date->month, $date->day, 'UTC')->startOfDay()->subSeconds(59);
219 219
 								} else {
220
-									$date           = Carbon::parse( $event->getEnd()->dateTime );
221
-									$google_end     = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $end_timezone );
222
-									$google_end_utc = Carbon::create( $date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC' );
220
+									$date           = Carbon::parse($event->getEnd()->dateTime);
221
+									$google_end     = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, $end_timezone);
222
+									$google_end_utc = Carbon::create($date->year, $date->month, $date->day, $date->hour, $date->minute, $date->second, 'UTC');
223 223
 								}
224 224
 								// End.
225 225
 								$end = $google_end->getTimestamp();
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
 								$end_utc = $google_end_utc->getTimestamp();
228 228
 
229 229
 								// Count multiple days.
230
-								$span = $google_start->setTimezone( $calendar['timezone'] )->diffInDays( $google_end->setTimezone( $calendar['timezone'] ) );
230
+								$span = $google_start->setTimezone($calendar['timezone'])->diffInDays($google_end->setTimezone($calendar['timezone']));
231 231
 
232
-								if ( $span == 0 ) {
233
-									if ( $google_start->toDateString() !== $google_end->toDateString() ) {
232
+								if ($span == 0) {
233
+									if ($google_start->toDateString() !== $google_end->toDateString()) {
234 234
 										$span = 1;
235 235
 									}
236 236
 								}
@@ -245,19 +245,19 @@  discard block
 block discarded – undo
245 245
 							// Recurring event.
246 246
 							$recurrence = $event->getRecurrence();
247 247
 							$recurring_id = $event->getRecurringEventId();
248
-							if ( ! $recurrence && $recurring_id ) {
248
+							if ( ! $recurrence && $recurring_id) {
249 249
 								$recurrence = true;
250 250
 							}
251 251
 
252 252
 							// Event link.
253
-							if ( 'use_calendar' == $this->timezone_setting ) {
254
-								$link = add_query_arg( array( 'ctz' => $this->timezone ), $event->getHtmlLink() );
253
+							if ('use_calendar' == $this->timezone_setting) {
254
+								$link = add_query_arg(array('ctz' => $this->timezone), $event->getHtmlLink());
255 255
 							} else {
256 256
 								$link = $event->getHtmlLink();
257 257
 							}
258 258
 
259 259
 							// Build the event.
260
-							$calendar['events'][ intval( $start ) ][] = array(
260
+							$calendar['events'][intval($start)][] = array(
261 261
 								'type'           => 'google-calendar',
262 262
 								'source'         => $source,
263 263
 								'title'          => $title,
@@ -284,24 +284,24 @@  discard block
 block discarded – undo
284 284
 						}
285 285
 					}
286 286
 
287
-					if ( ! empty( $calendar['events'] ) ) {
287
+					if ( ! empty($calendar['events'])) {
288 288
 
289
-						ksort( $calendar['events'], SORT_NUMERIC );
289
+						ksort($calendar['events'], SORT_NUMERIC);
290 290
 
291 291
 						set_transient(
292
-							'_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type,
292
+							'_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type,
293 293
 							$calendar,
294
-							max( absint( $this->cache ), 1 ) // Since a value of 0 means forever we set the minimum here to 1 if the user has set it to be 0
294
+							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
295 295
 						);
296 296
 					}
297 297
 				}
298 298
 
299 299
 			} else {
300 300
 
301
-				$message  = __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' );
302
-				$message .= '<br><br>' . $error . '<br><br>';
303
-				$message .= __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) . '<br><br>';
304
-				$message .= __( 'Only you can see this notice.', 'google-calendar-events' );
301
+				$message  = __('While trying to retrieve events, Google returned an error:', 'google-calendar-events');
302
+				$message .= '<br><br>'.$error.'<br><br>';
303
+				$message .= __('Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events').'<br><br>';
304
+				$message .= __('Only you can see this notice.', 'google-calendar-events');
305 305
 
306 306
 				return $message;
307 307
 			}
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
 		}
310 310
 
311 311
 		// If no timezone has been set, use calendar feed.
312
-		if ( 'use_calendar' == $this->timezone_setting && isset( $calendar['timezone'] ) ) {
312
+		if ('use_calendar' == $this->timezone_setting && isset($calendar['timezone'])) {
313 313
 			$this->timezone = $calendar['timezone'];
314 314
 		}
315 315
 
316
-		return isset( $calendar['events'] ) ? $calendar['events'] : array();
316
+		return isset($calendar['events']) ? $calendar['events'] : array();
317 317
 	}
318 318
 
319 319
 	/**
@@ -329,67 +329,67 @@  discard block
 block discarded – undo
329 329
 	 *
330 330
 	 * @throws \Exception On request failure will throw an exception from Google.
331 331
 	 */
332
-	public function make_request( $id = '', $time_min = 0, $time_max = 0 ) {
332
+	public function make_request($id = '', $time_min = 0, $time_max = 0) {
333 333
 
334 334
 		$calendar = array();
335 335
 		$google = $this->get_service();
336 336
 
337
-		if ( ! is_null( $google ) && ! empty( $id ) ) {
337
+		if ( ! is_null($google) && ! empty($id)) {
338 338
 
339 339
 			// Build the request args.
340 340
 			$args = array();
341 341
 
342 342
 			// Expand recurring events.
343
-			if ( $this->google_events_recurring == 'show' ) {
343
+			if ($this->google_events_recurring == 'show') {
344 344
 				$args['singleEvents'] = true;
345 345
 			}
346 346
 
347 347
 			// Query events using search terms.
348
-			if ( ! empty( $this->google_search_query ) ) {
349
-				$args['q'] = rawurlencode( $this->google_search_query );
348
+			if ( ! empty($this->google_search_query)) {
349
+				$args['q'] = rawurlencode($this->google_search_query);
350 350
 			}
351 351
 
352 352
 			// Max results to query.
353
-			$args['maxResults'] = strval( min( absint( $this->google_max_results ), 2500 ) );
353
+			$args['maxResults'] = strval(min(absint($this->google_max_results), 2500));
354 354
 
355 355
 			// Specify a timezone.
356 356
 			$timezone = '';
357
-			if ( 'use_calendar' != get_post_meta( $this->post_id, '_feed_timezone_setting', true ) ) {
357
+			if ('use_calendar' != get_post_meta($this->post_id, '_feed_timezone_setting', true)) {
358 358
 				$args['timeZone'] = $timezone = $this->timezone;
359 359
 			}
360 360
 
361 361
 			// Lower bound (inclusive) for an event's end time to filter by.
362
-			$earliest_event = intval( $this->time_min );
363
-			if ( $earliest_event > 0 ) {
362
+			$earliest_event = intval($this->time_min);
363
+			if ($earliest_event > 0) {
364 364
 				$timeMin = Carbon::now();
365
-				if ( ! empty( $timezone ) ) {
366
-					$timeMin->setTimezone( $timezone );
365
+				if ( ! empty($timezone)) {
366
+					$timeMin->setTimezone($timezone);
367 367
 				}
368
-				$timeMin->setTimestamp( $earliest_event );
368
+				$timeMin->setTimestamp($earliest_event);
369 369
 				$args['timeMin'] = $timeMin->toRfc3339String();
370 370
 			}
371 371
 
372 372
 			// Upper bound (exclusive) for an event's start time to filter by.
373
-			$latest_event = intval( $this->time_max );
374
-			if ( $latest_event > 0 ) {
373
+			$latest_event = intval($this->time_max);
374
+			if ($latest_event > 0) {
375 375
 				$timeMax = Carbon::now();
376
-				if ( ! empty( $timezone ) ) {
377
-					$timeMax->setTimezone( $timezone );
376
+				if ( ! empty($timezone)) {
377
+					$timeMax->setTimezone($timezone);
378 378
 				}
379
-				$timeMax->setTimestamp( $latest_event );
379
+				$timeMax->setTimestamp($latest_event);
380 380
 				$args['timeMax'] = $timeMax->toRfc3339String();
381 381
 			}
382 382
 
383 383
 			// Query events in calendar.
384
-			$response = $google->events->listEvents( $id, $args );
384
+			$response = $google->events->listEvents($id, $args);
385 385
 
386
-			if ( $response instanceof \Google_Service_Calendar_Events ) {
386
+			if ($response instanceof \Google_Service_Calendar_Events) {
387 387
 				$calendar = array(
388 388
 					'id'            => $id,
389 389
 					'title'         => $response->getSummary(),
390 390
 					'description'   => $response->getDescription(),
391 391
 					'timezone'      => $response->getTimeZone(),
392
-					'url'           => esc_url( '//www.google.com/calendar/embed?src=' . $id ),
392
+					'url'           => esc_url('//www.google.com/calendar/embed?src='.$id),
393 393
 					'events'        => $response->getItems(),
394 394
 				);
395 395
 			}
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
 	private function get_client() {
410 410
 
411 411
 		$client = new \Google_Client();
412
-		$client->setApplicationName( 'Simple Calendar' );
413
-		$client->setScopes( $this->google_client_scopes );
414
-		$client->setDeveloperKey( $this->google_api_key );
415
-		$client->setAccessType( 'online' );
412
+		$client->setApplicationName('Simple Calendar');
413
+		$client->setScopes($this->google_client_scopes);
414
+		$client->setDeveloperKey($this->google_api_key);
415
+		$client->setAccessType('online');
416 416
 
417 417
 		return $client;
418 418
 	}
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	 * @return null|\Google_Service_Calendar
427 427
 	 */
428 428
 	protected function get_service() {
429
-		return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar( $this->google_client ) : null;
429
+		return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar($this->google_client) : null;
430 430
 	}
431 431
 
432 432
 }
Please login to merge, or discard this patch.
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   +24 added lines, -24 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,15 +232,15 @@  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 'add-ons' :
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 'docs' :
245 245
 				return 'http://docs.simplecalendar.io';
246 246
 			case 'github' :
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @since 3.0.0
262 262
 	 */
263 263
 	public static function update() {
264
-		$update = new Update( SIMPLE_CALENDAR_VERSION );
264
+		$update = new Update(SIMPLE_CALENDAR_VERSION);
265 265
 	}
266 266
 
267 267
 }
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/field.php 1 patch
Spacing   +60 added lines, -60 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
 
@@ -148,68 +148,68 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @param array $field Field data.
150 150
 	 */
151
-	public function __construct( $field ) {
151
+	public function __construct($field) {
152 152
 
153 153
 		// Field properties.
154
-		if ( isset( $field['title'] ) ) {
155
-			$this->title = esc_attr( $field['title'] );
154
+		if (isset($field['title'])) {
155
+			$this->title = esc_attr($field['title']);
156 156
 		}
157
-		if ( isset( $field['description'] ) ) {
158
-			$this->description = wp_kses_post( $field['description'] );
157
+		if (isset($field['description'])) {
158
+			$this->description = wp_kses_post($field['description']);
159 159
 		}
160
-		if ( isset( $field['type'] ) ) {
161
-			$this->type = esc_attr( $field['type'] );
160
+		if (isset($field['type'])) {
161
+			$this->type = esc_attr($field['type']);
162 162
 		}
163
-		if ( isset( $field['name'] ) ) {
164
-			$this->name = esc_attr( $field['name'] );
163
+		if (isset($field['name'])) {
164
+			$this->name = esc_attr($field['name']);
165 165
 		}
166
-		if ( isset( $field['id'] ) ) {
167
-			$this->id = esc_attr( $field['id'] );
166
+		if (isset($field['id'])) {
167
+			$this->id = esc_attr($field['id']);
168 168
 		}
169
-		if ( isset( $field['placeholder'] ) ) {
170
-			$this->placeholder = esc_attr( $field['placeholder'] );
169
+		if (isset($field['placeholder'])) {
170
+			$this->placeholder = esc_attr($field['placeholder']);
171 171
 		}
172
-		if ( isset( $field['options'] ) && is_array( $field['options'] ) ) {
173
-			$this->options = array_map( 'esc_attr', $field['options'] );
172
+		if (isset($field['options']) && is_array($field['options'])) {
173
+			$this->options = array_map('esc_attr', $field['options']);
174 174
 		}
175 175
 
176 176
 		// Escaping.
177
-		if ( ! empty( $field['escaping'] ) && ( is_string( $field['escaping'] ) || is_array( $field['escaping'] ) ) ) {
178
-			if ( isset( $field['default'] ) ) {
179
-				$this->default = $this->escape_callback( $field['escaping'], $field['default'] );
177
+		if ( ! empty($field['escaping']) && (is_string($field['escaping']) || is_array($field['escaping']))) {
178
+			if (isset($field['default'])) {
179
+				$this->default = $this->escape_callback($field['escaping'], $field['default']);
180 180
 			}
181
-			if ( isset( $field['value'] ) ) {
182
-				$this->value = $this->escape_callback( $field['escaping'], $field['value'] );
181
+			if (isset($field['value'])) {
182
+				$this->value = $this->escape_callback($field['escaping'], $field['value']);
183 183
 			}
184 184
 		} else {
185
-			if ( isset( $field['default'] ) ) {
186
-				$this->default = $this->escape( $field['default'] );
185
+			if (isset($field['default'])) {
186
+				$this->default = $this->escape($field['default']);
187 187
 			}
188
-			if ( isset( $field['value'] ) ) {
189
-				$this->value = $this->escape( $field['value'] );
188
+			if (isset($field['value'])) {
189
+				$this->value = $this->escape($field['value']);
190 190
 			}
191 191
 		}
192 192
 
193 193
 		// Validation.
194
-		if ( ! empty( $field['validation'] ) ) {
195
-			$this->validation = $this->validate( $field['validation'], $this->value );
194
+		if ( ! empty($field['validation'])) {
195
+			$this->validation = $this->validate($field['validation'], $this->value);
196 196
 		}
197 197
 
198 198
 		// CSS classes and styles.
199
-		$classes = isset( $field['class'] ) ? $field['class'] : '';
200
-		$this->set_class( $classes );
201
-		if ( isset( $field['style'] ) ) {
202
-			$this->set_style( $field['style'] );
199
+		$classes = isset($field['class']) ? $field['class'] : '';
200
+		$this->set_class($classes);
201
+		if (isset($field['style'])) {
202
+			$this->set_style($field['style']);
203 203
 		}
204 204
 
205 205
 		// Custom attributes.
206
-		if ( isset( $field['attributes'] ) ) {
207
-			$this->set_attributes( $field['attributes'] );
206
+		if (isset($field['attributes'])) {
207
+			$this->set_attributes($field['attributes']);
208 208
 		}
209 209
 
210 210
 		// Tooltip markup.
211
-		if ( isset( $field['tooltip'] ) ) {
212
-			$this->tooltip = ' <i class="simcal-icon-help simcal-help-tip" data-tip="' . esc_attr( $field['tooltip'] ) . '"></i> ' ;
211
+		if (isset($field['tooltip'])) {
212
+			$this->tooltip = ' <i class="simcal-icon-help simcal-help-tip" data-tip="'.esc_attr($field['tooltip']).'"></i> ';
213 213
 		}
214 214
 	}
215 215
 
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @return void
224 224
 	 */
225
-	public function set_attributes( $attributes ) {
225
+	public function set_attributes($attributes) {
226 226
 
227 227
 		$attr = '';
228 228
 
229
-		if ( ! empty( $attributes ) && is_array( $attributes ) ) {
230
-			foreach ( $attributes as $k => $v ) {
231
-				$attr .= esc_attr( $k ) . '="' . esc_attr( $v ) . '" ';
229
+		if ( ! empty($attributes) && is_array($attributes)) {
230
+			foreach ($attributes as $k => $v) {
231
+				$attr .= esc_attr($k).'="'.esc_attr($v).'" ';
232 232
 			}
233 233
 		}
234 234
 
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @return void
246 246
 	 */
247
-	public function set_style( $css ) {
247
+	public function set_style($css) {
248 248
 
249 249
 		$styles = '';
250 250
 
251
-		if ( ! empty( $css ) && is_array( $css ) ) {
252
-			foreach ( $css as $k => $v ) {
253
-				$styles .= esc_attr( $k ) . ': ' . esc_attr( $v ) . '; ';
251
+		if ( ! empty($css) && is_array($css)) {
252
+			foreach ($css as $k => $v) {
253
+				$styles .= esc_attr($k).': '.esc_attr($v).'; ';
254 254
 			}
255 255
 		}
256 256
 
@@ -266,23 +266,23 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return void
268 268
 	 */
269
-	public function set_class( $class ) {
269
+	public function set_class($class) {
270 270
 
271 271
 		$classes = '';
272 272
 		$type_class = '';
273 273
 		$error = '';
274 274
 
275
-		if ( ! empty( $class ) && is_array( $class ) ) {
276
-			$classes = implode( ' ', array_map( 'esc_attr', $class ) );
275
+		if ( ! empty($class) && is_array($class)) {
276
+			$classes = implode(' ', array_map('esc_attr', $class));
277 277
 		}
278
-		if ( ! empty( $this->type_class ) ) {
279
-			$type_class = esc_attr( $this->type_class );
278
+		if ( ! empty($this->type_class)) {
279
+			$type_class = esc_attr($this->type_class);
280 280
 		}
281
-		if ( true !== $this->validation && ! empty( $this->validation ) ) {
281
+		if (true !== $this->validation && ! empty($this->validation)) {
282 282
 			$error = 'simcal-field-error ';
283 283
 		}
284 284
 
285
-		$this->class = trim( $error . 'simcal-field ' . $type_class . ' ' . $classes );
285
+		$this->class = trim($error.'simcal-field '.$type_class.' '.$classes);
286 286
 	}
287 287
 
288 288
 	/**
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return array|string
299 299
 	 */
300
-	protected function escape( $value )  {
301
-		return ! empty( $value ) ? ( is_array( $value ) ? array_map( 'esc_attr', $value ) : esc_attr( $value ) ) : '';
300
+	protected function escape($value) {
301
+		return ! empty($value) ? (is_array($value) ? array_map('esc_attr', $value) : esc_attr($value)) : '';
302 302
 	}
303 303
 
304 304
 	/**
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @return mixed
316 316
 	 */
317
-	protected function escape_callback( $callback, $value ) {
318
-		if ( $callback && ( is_string( $callback ) || is_array( $callback ) ) ) {
319
-			return call_user_func( $callback, $value );
317
+	protected function escape_callback($callback, $value) {
318
+		if ($callback && (is_string($callback) || is_array($callback))) {
319
+			return call_user_func($callback, $value);
320 320
 		}
321
-		return esc_attr( $value );
321
+		return esc_attr($value);
322 322
 	}
323 323
 
324 324
 	/**
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 	 *
335 335
 	 * @return true|string Expected to return bool (true) if passes, message string if not.
336 336
 	 */
337
-	protected function validate( $callback, $value ) {
338
-		if ( $callback && ( is_string( $callback ) || is_array( $callback ) ) ) {
339
-			$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : '';
340
-			return call_user_func( $callback, $value, $screen );
337
+	protected function validate($callback, $value) {
338
+		if ($callback && (is_string($callback) || is_array($callback))) {
339
+			$screen = function_exists('get_current_screen') ? get_current_screen() : '';
340
+			return call_user_func($callback, $value, $screen);
341 341
 		}
342 342
 		return true;
343 343
 	}
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.