Completed
Push — master ( 62b222...3fdac6 )
by
unknown
07:01
created
includes/calendars/default-calendar.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@
 block discarded – undo
146 146
 	 * @since  3.0.0
147 147
 	 * @access private
148 148
 	 *
149
-	 * @param  $view
149
+	 * @param  string $view
150 150
 	 */
151 151
 	private function set_properties( $view ) {
152 152
 
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 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,36 +105,36 @@  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
 
131 131
 				return $class;
132
-			}, 10, 2 );
132
+			}, 10, 2);
133 133
 
134 134
 		}
135 135
 
136 136
 		// Calendar settings handling.
137
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
137
+		if (is_admin() && ! defined('DOING_AJAX')) {
138 138
 			$admin          = new Default_Calendar_Admin();
139 139
 			$this->settings = $admin->settings_fields();
140 140
 		}
@@ -148,49 +148,49 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @param  $view
150 150
 	 */
151
-	private function set_properties( $view ) {
151
+	private function set_properties($view) {
152 152
 
153 153
 		// Set styles.
154
-		if ( 'dark' == get_post_meta( $this->id, '_default_calendar_style_theme', true ) ) {
154
+		if ('dark' == get_post_meta($this->id, '_default_calendar_style_theme', true)) {
155 155
 			$this->theme = 'dark';
156 156
 		}
157
-		if ( $today_color = get_post_meta( $this->id, '_default_calendar_style_today', true ) ) {
158
-			$this->today_color = esc_attr( $today_color );
157
+		if ($today_color = get_post_meta($this->id, '_default_calendar_style_today', true)) {
158
+			$this->today_color = esc_attr($today_color);
159 159
 		}
160
-		if ( $day_events_color = get_post_meta( $this->id, '_default_calendar_style_days_events', true ) ) {
161
-			$this->days_events_color = esc_attr( $day_events_color );
160
+		if ($day_events_color = get_post_meta($this->id, '_default_calendar_style_days_events', true)) {
161
+			$this->days_events_color = esc_attr($day_events_color);
162 162
 		}
163 163
 
164 164
 		// Hide too many events.
165
-		if ( 'yes' == get_post_meta( $this->id, '_default_calendar_limit_visible_events', true ) ) {
166
-			$this->events_limit = absint( get_post_meta( $this->id, '_default_calendar_visible_events', true ) );
165
+		if ('yes' == get_post_meta($this->id, '_default_calendar_limit_visible_events', true)) {
166
+			$this->events_limit = absint(get_post_meta($this->id, '_default_calendar_visible_events', true));
167 167
 		}
168 168
 
169 169
 		// Expand multiple day events.
170
-		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
+		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))) {
171 171
 			$this->events = $this->expand_multiple_days_events();
172 172
 		}
173 173
 
174
-		if ( 'grid' == $view ) {
174
+		if ('grid' == $view) {
175 175
 
176 176
 			// Use hover to open event bubbles.
177
-			if ( 'hover' == get_post_meta( $this->id, '_default_calendar_event_bubble_trigger', true ) ) {
177
+			if ('hover' == get_post_meta($this->id, '_default_calendar_event_bubble_trigger', true)) {
178 178
 				$this->event_bubble_trigger = 'hover';
179 179
 			}
180 180
 
181 181
 			// Trim long event titles.
182
-			if ( 'yes' == get_post_meta( $this->id, '_default_calendar_trim_titles', true ) ) {
183
-				$this->trim_titles = max( absint( get_post_meta( $this->id, '_default_calendar_trim_titles_chars', true ) ), 1 );
182
+			if ('yes' == get_post_meta($this->id, '_default_calendar_trim_titles', true)) {
183
+				$this->trim_titles = max(absint(get_post_meta($this->id, '_default_calendar_trim_titles_chars', true)), 1);
184 184
 			}
185 185
 
186 186
 		} else {
187 187
 
188 188
 			// List range.
189
-			$this->group_type = esc_attr( get_post_meta( $this->id, '_default_calendar_list_range_type', true ) );
190
-			$this->group_span = max( absint( get_post_meta( $this->id, '_default_calendar_list_range_span', true ) ), 1 );
189
+			$this->group_type = esc_attr(get_post_meta($this->id, '_default_calendar_list_range_type', true));
190
+			$this->group_span = max(absint(get_post_meta($this->id, '_default_calendar_list_range_span', true)), 1);
191 191
 
192 192
 			// Make the list look more compact.
193
-			if ( 'yes' == get_post_meta( $this->id, '_default_calendar_compact_list', true ) ) {
193
+			if ('yes' == get_post_meta($this->id, '_default_calendar_compact_list', true)) {
194 194
 				$this->compact_list = true;
195 195
 			}
196 196
 
@@ -211,18 +211,18 @@  discard block
 block discarded – undo
211 211
 		$old_events = $this->events;
212 212
 		$new_events = array();
213 213
 
214
-		if ( ! empty( $old_events ) ) {
214
+		if ( ! empty($old_events)) {
215 215
 
216
-			foreach ( $old_events as $events ) {
217
-				foreach ( $events as $event ) {
218
-					if ( $event instanceof Event ) {
219
-						if ( false !== $event->multiple_days ) {
216
+			foreach ($old_events as $events) {
217
+				foreach ($events as $event) {
218
+					if ($event instanceof Event) {
219
+						if (false !== $event->multiple_days) {
220 220
 							$days = $event->multiple_days;
221 221
 
222
-							if ( $days > 0 ) {
222
+							if ($days > 0) {
223 223
 
224
-								for ( $d = 1; $d <= $days; $d++ ) {
225
-									$new_events[ intval( $event->start + ( $d * DAY_IN_SECONDS ) - 1 ) ][] = $event;
224
+								for ($d = 1; $d <= $days; $d++) {
225
+									$new_events[intval($event->start + ($d * DAY_IN_SECONDS) - 1)][] = $event;
226 226
 								}
227 227
 							}
228 228
 						}
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		}
235 235
 
236 236
 		$events = $old_events + $new_events;
237
-		ksort( $events, SORT_NUMERIC );
237
+		ksort($events, SORT_NUMERIC);
238 238
 
239 239
 		return $events;
240 240
 	}
@@ -250,16 +250,16 @@  discard block
 block discarded – undo
250 250
 	 *
251 251
 	 * @return null|Calendar_View
252 252
 	 */
253
-	public function get_view( $view = '' ) {
253
+	public function get_view($view = '') {
254 254
 
255
-		$view = ! empty( $view ) ? $view : 'grid';
255
+		$view = ! empty($view) ? $view : 'grid';
256 256
 
257
-		do_action( 'simcal_calendar_get_view', $this->type, $view );
257
+		do_action('simcal_calendar_get_view', $this->type, $view);
258 258
 
259
-		if ( 'grid' == $view ) {
260
-			return new Views\Default_Calendar_Grid( $this );
261
-		} elseif ( 'list' == $view ) {
262
-			return new Views\Default_Calendar_List( $this );
259
+		if ('grid' == $view) {
260
+			return new Views\Default_Calendar_Grid($this);
261
+		} elseif ('list' == $view) {
262
+			return new Views\Default_Calendar_List($this);
263 263
 		}
264 264
 
265 265
 		return null;
Please login to merge, or discard this patch.
includes/calendars/views/default-calendar-list.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
 	 *
74 74
 	 * @since 3.0.0
75 75
 	 *
76
-	 * @param string|Calendar $calendar
76
+	 * @param Default_Calendar $calendar
77 77
 	 */
78 78
 	public function __construct( $calendar = '' ) {
79 79
 		$this->calendar = $calendar;
Please login to merge, or discard this patch.
Spacing   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use SimpleCalendar\Calendars\Default_Calendar;
14 14
 use SimpleCalendar\Events\Event;
15 15
 
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @param string|Calendar $calendar
77 77
 	 */
78
-	public function __construct( $calendar = '' ) {
78
+	public function __construct($calendar = '') {
79 79
 		$this->calendar = $calendar;
80 80
 	}
81 81
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return string
110 110
 	 */
111 111
 	public function get_name() {
112
-		return __( 'List', 'google-calendar-events' );
112
+		return __('List', 'google-calendar-events');
113 113
 	}
114 114
 
115 115
 	/**
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	 * @since 3.0.0
119 119
 	 */
120 120
 	public function add_ajax_actions() {
121
-		add_action( 'wp_ajax_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) );
122
-		add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) );
121
+		add_action('wp_ajax_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax'));
122
+		add_action('wp_ajax_nopriv_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax'));
123 123
 	}
124 124
 
125 125
 	/**
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return array
135 135
 	 */
136
-	public function scripts( $min = '' ) {
136
+	public function scripts($min = '') {
137 137
 		return array(
138 138
 			'simcal-qtip' => array(
139
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js',
140
-				'deps'      => array( 'jquery' ),
139
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js',
140
+				'deps'      => array('jquery'),
141 141
 				'ver'       => '2.2.1',
142 142
 				'in_footer' => true,
143 143
 			),
144 144
 			'simcal-default-calendar' => array(
145
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js',
145
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js',
146 146
 				'deps'      => array(
147 147
 					'jquery',
148 148
 					'simcal-qtip',
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return array
169 169
 	 */
170
-	public function styles( $min = '' ) {
170
+	public function styles($min = '') {
171 171
 		return array(
172 172
 			'simcal-default-calendar-list' => array(
173
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $min . '.css',
173
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$min.'.css',
174 174
 				'ver'   => SIMPLE_CALENDAR_VERSION,
175 175
 				'media' => 'all',
176 176
 			),
@@ -186,49 +186,49 @@  discard block
 block discarded – undo
186 186
 
187 187
 		$calendar = $this->calendar;
188 188
 
189
-		if ( $calendar instanceof Default_Calendar ) {
189
+		if ($calendar instanceof Default_Calendar) {
190 190
 
191
-			$disabled = $calendar->static === true || empty( $calendar->events ) ? ' disabled="disabled"' : '';
191
+			$disabled = $calendar->static === true || empty($calendar->events) ? ' disabled="disabled"' : '';
192 192
 
193 193
 
194
-			$hide_header = get_post_meta( $this->calendar->id, '_default_calendar_list_header', true ) == 'yes' ? true : false;
195
-			$static_calendar = get_post_meta( $this->calendar->id, '_calendar_is_static', true ) == 'yes' ? true : false;
194
+			$hide_header = get_post_meta($this->calendar->id, '_default_calendar_list_header', true) == 'yes' ? true : false;
195
+			$static_calendar = get_post_meta($this->calendar->id, '_calendar_is_static', true) == 'yes' ? true : false;
196 196
 
197 197
 			$header_class = '';
198 198
 			$compact_list_class = $calendar->compact_list ? 'simcal-calendar-list-compact' : '';
199 199
 
200
-			edit_post_link( __( 'Edit Calendar', 'google-calendar-events' ), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id );
200
+			edit_post_link(__('Edit Calendar', 'google-calendar-events'), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id);
201 201
 
202
-			echo '<div class="simcal-calendar-list ' . $compact_list_class . '">';
202
+			echo '<div class="simcal-calendar-list '.$compact_list_class.'">';
203 203
 
204
-			if ( ! $hide_header && ! $static_calendar ) {
205
-				echo '<nav class="simcal-calendar-head">' . "\n";
204
+			if ( ! $hide_header && ! $static_calendar) {
205
+				echo '<nav class="simcal-calendar-head">'."\n";
206 206
 
207
-				echo "\t" . '<div class="simcal-nav">' . "\n";
208
-				echo "\t\t" . '<button class="simcal-nav-button simcal-prev" title="' . __('Previous', 'google-calendar-events') . '"' . $disabled . '>' . "\n";
209
-				echo "\t\t\t" . '<i class="simcal-icon-left"></i>' . "\n";
210
-				echo "\t\t" . '</button>' . "\n";
211
-				echo "\t" . '</div>' . "\n";
207
+				echo "\t".'<div class="simcal-nav">'."\n";
208
+				echo "\t\t".'<button class="simcal-nav-button simcal-prev" title="'.__('Previous', 'google-calendar-events').'"'.$disabled.'>'."\n";
209
+				echo "\t\t\t".'<i class="simcal-icon-left"></i>'."\n";
210
+				echo "\t\t".'</button>'."\n";
211
+				echo "\t".'</div>'."\n";
212 212
 
213
-				if ( $hide_header ) {
213
+				if ($hide_header) {
214 214
 					$header_class = 'simcal-hide-header';
215 215
 				}
216 216
 
217 217
 
218
-				echo "\t" . '<div class="simcal-nav simcal-current ' . $header_class . '" data-calendar-current="' . $calendar->start . '">' . "\n";
219
-				echo "\t\t" . '<h3 class="simcal-current-label"> </h3>' . "\n";
220
-				echo "\t" . '</div>' . "\n";
218
+				echo "\t".'<div class="simcal-nav simcal-current '.$header_class.'" data-calendar-current="'.$calendar->start.'">'."\n";
219
+				echo "\t\t".'<h3 class="simcal-current-label"> </h3>'."\n";
220
+				echo "\t".'</div>'."\n";
221 221
 
222
-				echo "\t" . '<div class="simcal-nav">';
223
-				echo "\t\t" . '<button class="simcal-nav-button simcal-next" title="' . __('Next', 'google-calendar-events') . '"' . $disabled . '>';
224
-				echo "\t\t\t" . '<i class="simcal-icon-right"></i>' . "\n";
225
-				echo "\t\t" . '</button>' . "\n";
226
-				echo "\t" . '</div>' . "\n";
222
+				echo "\t".'<div class="simcal-nav">';
223
+				echo "\t\t".'<button class="simcal-nav-button simcal-next" title="'.__('Next', 'google-calendar-events').'"'.$disabled.'>';
224
+				echo "\t\t\t".'<i class="simcal-icon-right"></i>'."\n";
225
+				echo "\t\t".'</button>'."\n";
226
+				echo "\t".'</div>'."\n";
227 227
 
228
-				echo '</nav>' . "\n";
228
+				echo '</nav>'."\n";
229 229
 			}
230 230
 
231
-			echo $this->draw_list( $calendar->start );
231
+			echo $this->draw_list($calendar->start);
232 232
 
233 233
 			echo '<div class="simcal-ajax-loader simcal-spinner-top" style="display: none;"><i class="simcal-icon-spinner simcal-icon-spin"></i></div>';
234 234
 
@@ -248,99 +248,99 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return array
250 250
 	 */
251
-	private function get_events( $timestamp ) {
251
+	private function get_events($timestamp) {
252 252
 
253 253
 		$calendar = $this->calendar;
254 254
 		$timezone = $calendar->timezone;
255 255
 
256
-		if ( ! $calendar->group_type || ! $calendar->group_span ) {
256
+		if ( ! $calendar->group_type || ! $calendar->group_span) {
257 257
 			return array();
258 258
 		}
259 259
 
260
-		$current = Carbon::createFromTimestamp( $timestamp, $timezone );
260
+		$current = Carbon::createFromTimestamp($timestamp, $timezone);
261 261
 		$prev = clone $current;
262 262
 		$next = clone $current;
263 263
 
264 264
 		$this->start = $current->getTimestamp();
265 265
 
266
-		$interval = $span = max( absint( $calendar->group_span ), 1 );
267
-
268
-		if ( 'monthly' == $calendar->group_type ) {
269
-			$this->prev = $prev->subMonths( $span )->getTimestamp();
270
-			$this->next = $next->addMonths( $span )->getTimestamp();
271
-		} elseif ( 'weekly' == $calendar->group_type ) {
272
-			$week = new Carbon( $calendar->timezone );
273
-			$week->setTimestamp( $timestamp );
274
-			$week->setWeekStartsAt( $calendar->week_starts );
275
-			$this->prev = $prev->subWeeks( $span )->getTimestamp();
276
-			$this->next = $next->addWeeks( $span )->getTimestamp();
277
-		} elseif ( 'daily' == $calendar->group_type ) {
278
-			$this->prev = $prev->subDays( $span )->getTimestamp();
279
-			$this->next = $next->addDays( $span )->getTimestamp();
266
+		$interval = $span = max(absint($calendar->group_span), 1);
267
+
268
+		if ('monthly' == $calendar->group_type) {
269
+			$this->prev = $prev->subMonths($span)->getTimestamp();
270
+			$this->next = $next->addMonths($span)->getTimestamp();
271
+		} elseif ('weekly' == $calendar->group_type) {
272
+			$week = new Carbon($calendar->timezone);
273
+			$week->setTimestamp($timestamp);
274
+			$week->setWeekStartsAt($calendar->week_starts);
275
+			$this->prev = $prev->subWeeks($span)->getTimestamp();
276
+			$this->next = $next->addWeeks($span)->getTimestamp();
277
+		} elseif ('daily' == $calendar->group_type) {
278
+			$this->prev = $prev->subDays($span)->getTimestamp();
279
+			$this->next = $next->addDays($span)->getTimestamp();
280 280
 		}
281 281
 
282 282
 		$events = $calendar->events;
283 283
 		$daily_events = $paged_events = $flattened_events = array();
284 284
 
285
-		if ( 'events' != $calendar->group_type ) {
285
+		if ('events' != $calendar->group_type) {
286 286
 
287
-			$this->end   = $this->next - 1;
287
+			$this->end = $this->next - 1;
288 288
 
289
-			$timestamps   = array_keys( $events );
290
-			$lower_bound  = array_filter( $timestamps,  array( $this, 'filter_events_before' ) );
291
-			$higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after'  ) );
289
+			$timestamps   = array_keys($events);
290
+			$lower_bound  = array_filter($timestamps, array($this, 'filter_events_before'));
291
+			$higher_bound = array_filter($lower_bound, array($this, 'filter_events_after'));
292 292
 
293
-			if ( is_array( $higher_bound ) && !empty( $higher_bound ) ) {
294
-				$filtered = array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) );
295
-				foreach ( $filtered as $timestamp => $events ) {
296
-					$paged_events[ intval( $timestamp ) ] = $events;
293
+			if (is_array($higher_bound) && ! empty($higher_bound)) {
294
+				$filtered = array_intersect_key($events, array_combine($higher_bound, $higher_bound));
295
+				foreach ($filtered as $timestamp => $events) {
296
+					$paged_events[intval($timestamp)] = $events;
297 297
 				}
298 298
 			}
299 299
 
300 300
 		} else {
301 301
 
302
-			foreach ( $events as $timestamp => $e ) {
302
+			foreach ($events as $timestamp => $e) {
303 303
 				$second = 0;
304
-				foreach ( $e as $event ) {
305
-					$flattened_events[ intval( $timestamp + $second ) ][] = $event;
304
+				foreach ($e as $event) {
305
+					$flattened_events[intval($timestamp + $second)][] = $event;
306 306
 					$second++;
307 307
 				}
308 308
 			}
309
-			ksort( $flattened_events, SORT_NUMERIC );
309
+			ksort($flattened_events, SORT_NUMERIC);
310 310
 
311
-			$keys  = array_keys( $flattened_events );
311
+			$keys = array_keys($flattened_events);
312 312
 			$current = 0;
313
-			foreach ( $keys as $timestamp ) {
314
-				if ( $timestamp < $this->start ) {
313
+			foreach ($keys as $timestamp) {
314
+				if ($timestamp < $this->start) {
315 315
 					$current++;
316 316
 				}
317 317
 			}
318 318
 
319
-			$paged_events = array_slice( $flattened_events, $current, $interval, true );
319
+			$paged_events = array_slice($flattened_events, $current, $interval, true);
320 320
 
321
-			$events_end = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $calendar->end;
321
+			$events_end = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $calendar->end;
322 322
 			$this->end  = $events_end > $calendar->end ? $calendar->end : $events_end;
323 323
 
324
-			$this->prev = isset( $keys[ $current - $interval ] ) ? $keys[ $current - $interval ] : $calendar->earliest_event;
325
-			$this->next = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $this->end;
324
+			$this->prev = isset($keys[$current - $interval]) ? $keys[$current - $interval] : $calendar->earliest_event;
325
+			$this->next = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $this->end;
326 326
 
327 327
 		}
328 328
 
329 329
 		// Put resulting events in an associative array, with Ymd date as key for easy retrieval in calendar days loop.
330
-		foreach ( $paged_events as $timestamp => $events ) {
331
-			if ( $timestamp <= $this->end ) {
332
-				$date = Carbon::createFromTimestamp( $timestamp, $calendar->timezone )->endOfDay()->format( 'Ymd' );
333
-				$daily_events[ intval( $date ) ][] = $events;
330
+		foreach ($paged_events as $timestamp => $events) {
331
+			if ($timestamp <= $this->end) {
332
+				$date = Carbon::createFromTimestamp($timestamp, $calendar->timezone)->endOfDay()->format('Ymd');
333
+				$daily_events[intval($date)][] = $events;
334 334
 			}
335 335
 		}
336
-		ksort( $daily_events, SORT_NUMERIC );
336
+		ksort($daily_events, SORT_NUMERIC);
337 337
 
338
-		if ( ! empty( $paged_events ) ) {
339
-			$first_event       = array_slice( $paged_events, 0, 1, true );
340
-			$first_event       = array_pop( $first_event );
338
+		if ( ! empty($paged_events)) {
339
+			$first_event       = array_slice($paged_events, 0, 1, true);
340
+			$first_event       = array_pop($first_event);
341 341
 			$this->first_event = $first_event[0]->start;
342 342
 
343
-			$last_event       = array_pop( $paged_events );
343
+			$last_event       = array_pop($paged_events);
344 344
 			$this->last_event = $last_event[0]->start;
345 345
 		}
346 346
 
@@ -360,84 +360,84 @@  discard block
 block discarded – undo
360 360
 	private function get_heading() {
361 361
 
362 362
 		$calendar = $this->calendar;
363
-		$start = Carbon::createFromTimestamp( $calendar->start, $calendar->timezone );
364
-		$end = Carbon::createFromTimestamp( $this->end, $calendar->timezone );
363
+		$start = Carbon::createFromTimestamp($calendar->start, $calendar->timezone);
364
+		$end = Carbon::createFromTimestamp($this->end, $calendar->timezone);
365 365
 		$date_format = $this->calendar->date_format;
366
-		$date_order  = simcal_get_date_format_order( $date_format );
366
+		$date_order  = simcal_get_date_format_order($date_format);
367 367
 
368 368
 		$st = $this->start;
369 369
 		$et = $this->end;
370 370
 
371
-		if ( $this->first_event !== 0 ) {
372
-			$start = Carbon::createFromTimestamp( $this->first_event, $calendar->timezone );
371
+		if ($this->first_event !== 0) {
372
+			$start = Carbon::createFromTimestamp($this->first_event, $calendar->timezone);
373 373
 			$st = $this->first_event;
374 374
 		}
375 375
 
376
-		if ( $this->last_event !== 0 ) {
377
-			$end = Carbon::createFromTimestamp( $this->last_event, $calendar->timezone );
376
+		if ($this->last_event !== 0) {
377
+			$end = Carbon::createFromTimestamp($this->last_event, $calendar->timezone);
378 378
 			$et = $this->last_event;
379 379
 		}
380 380
 
381
-		if ( ( $start->day == $end->day ) && ( $start->month == $end->month ) && ( $start->year == $end->year ) ) {
381
+		if (($start->day == $end->day) && ($start->month == $end->month) && ($start->year == $end->year)) {
382 382
 			// Start and end on the same day.
383 383
 			// e.g. 1 February 2020
384
-			$large = $small = date_i18n( $calendar->date_format , $st );
385
-			if ( ( $date_order['d'] !== false ) && ( $date_order['m'] !== false ) ) {
386
-				if ( $date_order['m'] > $date_order['d'] ) {
387
-					if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) {
388
-						$small = date_i18n( 'Y, d M', $st );
384
+			$large = $small = date_i18n($calendar->date_format, $st);
385
+			if (($date_order['d'] !== false) && ($date_order['m'] !== false)) {
386
+				if ($date_order['m'] > $date_order['d']) {
387
+					if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) {
388
+						$small = date_i18n('Y, d M', $st);
389 389
 					} else {
390
-						$small = date_i18n( 'd M Y', $st );
390
+						$small = date_i18n('d M Y', $st);
391 391
 					}
392 392
 				} else {
393
-					if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) {
394
-						$small = date_i18n( 'Y, M d', $st );
393
+					if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) {
394
+						$small = date_i18n('Y, M d', $st);
395 395
 					} else {
396
-						$small = date_i18n( 'M d Y', $st );
396
+						$small = date_i18n('M d Y', $st);
397 397
 					}
398 398
 				}
399 399
 			}
400
-		} elseif ( ( $start->month == $end->month ) && ( $start->year == $end->year ) ) {
400
+		} elseif (($start->month == $end->month) && ($start->year == $end->year)) {
401 401
 			// Start and end days on the same month.
402 402
 			// e.g. August 2020
403
-			if ( $date_order['y'] === false ) {
403
+			if ($date_order['y'] === false) {
404 404
 				// August.
405
-				$large = $small = date_i18n( 'F', $st );
405
+				$large = $small = date_i18n('F', $st);
406 406
 			} else {
407
-				if ( $date_order['y'] < $date_order['m'] ) {
407
+				if ($date_order['y'] < $date_order['m']) {
408 408
 					// 2020 August.
409
-					$large = date_i18n( 'Y F', $st );
410
-					$small = date_i18n( 'Y M', $st );
409
+					$large = date_i18n('Y F', $st);
410
+					$small = date_i18n('Y M', $st);
411 411
 				} else {
412 412
 					// August 2020.
413
-					$large = date_i18n( 'F Y', $st );
414
-					$small = date_i18n( 'M Y', $st );
413
+					$large = date_i18n('F Y', $st);
414
+					$small = date_i18n('M Y', $st);
415 415
 				}
416 416
 			}
417
-		} elseif ( $start->year == $end->year ) {
417
+		} elseif ($start->year == $end->year) {
418 418
 			// Start and end days on months of the same year.
419 419
 			// e.g. August - September 2020
420
-			if ( $date_order['y'] === false ) {
420
+			if ($date_order['y'] === false) {
421 421
 				// August - September.
422
-				$large = date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et );
423
-				$small = date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et );
422
+				$large = date_i18n('F', $st).' - '.date_i18n('F', $et);
423
+				$small = date_i18n('M', $st).' - '.date_i18n('M', $et);
424 424
 			} else {
425
-				if ( $date_order['y'] < $date_order['m'] ) {
425
+				if ($date_order['y'] < $date_order['m']) {
426 426
 					// 2020, August - September.
427
-					$large  = $small = date( 'Y', $st ) . ', ';
428
-					$large .= date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et );
429
-					$small .= date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et );
427
+					$large  = $small = date('Y', $st).', ';
428
+					$large .= date_i18n('F', $st).' - '.date_i18n('F', $et);
429
+					$small .= date_i18n('M', $st).' - '.date_i18n('M', $et);
430 430
 				} else {
431 431
 					// August - September, 2020.
432
-					$large  = date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et ) . ', ';
433
-					$small  = date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et ) . ' ';
434
-					$year   = date( 'Y', $st );
432
+					$large  = date_i18n('F', $st).' - '.date_i18n('F', $et).', ';
433
+					$small  = date_i18n('M', $st).' - '.date_i18n('M', $et).' ';
434
+					$year   = date('Y', $st);
435 435
 					$large .= $year;
436 436
 					$small .= $year;
437 437
 				}
438 438
 			}
439 439
 		} else {
440
-			$large = $small = date( 'Y', $st ) . ' - ' . date( 'Y', $et );
440
+			$large = $small = date('Y', $st).' - '.date('Y', $et);
441 441
 		}
442 442
 
443 443
 		return array(
@@ -459,133 +459,133 @@  discard block
 block discarded – undo
459 459
 	 *
460 460
 	 * @return string
461 461
 	 */
462
-	private function draw_list( $timestamp, $id = 0 ) {
462
+	private function draw_list($timestamp, $id = 0) {
463 463
 
464 464
 		$calendar = $this->calendar;
465 465
 
466
-		if ( empty( $calendar ) ) {
467
-			$calendar = $this->calendar = simcal_get_calendar( intval( $id ) );
468
-			if ( ! $calendar instanceof Default_Calendar ) {
466
+		if (empty($calendar)) {
467
+			$calendar = $this->calendar = simcal_get_calendar(intval($id));
468
+			if ( ! $calendar instanceof Default_Calendar) {
469 469
 				return '';
470 470
 			}
471 471
 		}
472 472
 
473
-		$feed          = simcal_get_feed( $calendar );
474
-		$feed_timezone = get_post_meta( $feed->post_id, '_feed_timezone', true );
473
+		$feed          = simcal_get_feed($calendar);
474
+		$feed_timezone = get_post_meta($feed->post_id, '_feed_timezone', true);
475 475
 
476 476
 		$now = $calendar->now;
477
-		$current_events = $this->get_events( $timestamp );
478
-		$day_format = explode( ' ', $calendar->date_format );
477
+		$current_events = $this->get_events($timestamp);
478
+		$day_format = explode(' ', $calendar->date_format);
479 479
 
480 480
 		ob_start();
481 481
 
482 482
 		// Draw the events.
483 483
 
484
-		$block_tag = $calendar->compact_list && ! empty( $current_events ) ? 'div' : 'dl';
484
+		$block_tag = $calendar->compact_list && ! empty($current_events) ? 'div' : 'dl';
485 485
 
486 486
 		$data_heading = '';
487 487
 		$heading = $this->get_heading();
488
-		foreach ( $heading as $k => $v ) {
489
-			$data_heading .= ' data-heading-' . $k . '="' . $v . '"';
488
+		foreach ($heading as $k => $v) {
489
+			$data_heading .= ' data-heading-'.$k.'="'.$v.'"';
490 490
 		}
491 491
 
492
-		echo '<' . $block_tag . ' class="simcal-events-list-container"' .
493
-			' data-prev="' . $this->prev . '"' .
494
-			' data-next="' . $this->next . '"' .
495
-			$data_heading . '>';
492
+		echo '<'.$block_tag.' class="simcal-events-list-container"'.
493
+			' data-prev="'.$this->prev.'"'.
494
+			' data-next="'.$this->next.'"'.
495
+			$data_heading.'>';
496 496
 
497
-		if ( ! empty( $current_events ) && is_array( $current_events ) ) :
497
+		if ( ! empty($current_events) && is_array($current_events)) :
498 498
 
499
-			foreach ( $current_events as $ymd => $events ) :
499
+			foreach ($current_events as $ymd => $events) :
500 500
 
501 501
 
502 502
 
503 503
 				// This is where we can find out if an event is a multi-day event and if it needs to be shown.
504 504
 				// Since this is for list view we are showing the event on the day viewed if it is part of that day even when
505 505
 				// expand multi-day events are turned off.
506
-				if ( isset( $events[0][0]->multiple_days ) && $events[0][0]->multiple_days > 0 ) {
507
-					if ( 'current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true ) ) {
506
+				if (isset($events[0][0]->multiple_days) && $events[0][0]->multiple_days > 0) {
507
+					if ('current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true)) {
508 508
 
509
-						$year  = substr( $ymd, 0, 4 );
510
-						$month = substr( $ymd, 4, 2 );
511
-						$day   = substr( $ymd, 6, 2 );
509
+						$year  = substr($ymd, 0, 4);
510
+						$month = substr($ymd, 4, 2);
511
+						$day   = substr($ymd, 6, 2);
512 512
 
513
-						$temp_date = Carbon::createFromDate( $year, $month, $day );
513
+						$temp_date = Carbon::createFromDate($year, $month, $day);
514 514
 
515
-						if( ! ( $temp_date < Carbon::now()->endOfDay() ) ) {
515
+						if ( ! ($temp_date < Carbon::now()->endOfDay())) {
516 516
 							continue;
517 517
 						}
518 518
 					}
519 519
 				}
520 520
 
521
-				$day_ts = Carbon::createFromFormat( 'Ymd', $ymd, $calendar->timezone )->startOfDay()->getTimestamp();
521
+				$day_ts = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone)->startOfDay()->getTimestamp();
522 522
 
523
-				if ( ! $calendar->compact_list ) :
523
+				if ( ! $calendar->compact_list) :
524 524
 
525
-					$date = new Carbon( 'now', $calendar->timezone );
526
-					$date->setLocale( substr( get_locale(), 0, 2 ) );
527
-					$date->setTimestamp( $day_ts );
525
+					$date = new Carbon('now', $calendar->timezone);
526
+					$date->setLocale(substr(get_locale(), 0, 2));
527
+					$date->setTimestamp($day_ts);
528 528
 
529
-					if ( $date->isToday() ) {
530
-						$the_color = new Color( $calendar->today_color );
529
+					if ($date->isToday()) {
530
+						$the_color = new Color($calendar->today_color);
531 531
 					} else {
532
-						$the_color = new Color( $calendar->days_events_color );
532
+						$the_color = new Color($calendar->days_events_color);
533 533
 					}
534 534
 
535
-					$bg_color = '#' . $the_color->getHex();
535
+					$bg_color = '#'.$the_color->getHex();
536 536
 					$color = $the_color->isDark() ? '#ffffff' : '#000000';
537
-					$border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" ';
538
-					$bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"';
537
+					$border_style = ' style="border-bottom: 1px solid '.$bg_color.';" ';
538
+					$bg_style = ' style="background-color: '.$bg_color.'; color: '.$color.';"';
539 539
 
540
-					echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>';
541
-					echo '<span' . $bg_style .'>';
542
-					foreach ( $day_format as $format ) {
543
-						echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n( $format, $day_ts ) . '</span> ' : ' ';
540
+					echo "\t".'<dt class="simcal-day-label"'.$border_style.'>';
541
+					echo '<span'.$bg_style.'>';
542
+					foreach ($day_format as $format) {
543
+						echo $format ? '<span class="simcal-date-format" data-date-format="'.$format.'">'.date_i18n($format, $day_ts).'</span> ' : ' ';
544 544
 					}
545 545
 					echo '</span>';
546
-					echo '</dt>' . "\n";
546
+					echo '</dt>'."\n";
547 547
 
548 548
 				endif;
549 549
 
550
-				$list_events = '<ul class="simcal-events">' . "\n";
550
+				$list_events = '<ul class="simcal-events">'."\n";
551 551
 
552 552
 				$calendar_classes = array();
553
-				$day_classes = 'simcal-weekday-' . date( 'w', $day_ts );
553
+				$day_classes = 'simcal-weekday-'.date('w', $day_ts);
554 554
 
555 555
 				// Is this the present, the past or the future, Doc?
556
-				if ( $timestamp <= $now && $timestamp >= $now ) {
556
+				if ($timestamp <= $now && $timestamp >= $now) {
557 557
 					$day_classes .= ' simcal-today simcal-present simcal-day';
558
-				} elseif ( $timestamp < $now ) {
558
+				} elseif ($timestamp < $now) {
559 559
 					$day_classes .= ' simcal-past simcal-day';
560
-				} elseif ( $this->end > $now ) {
560
+				} elseif ($this->end > $now) {
561 561
 					$day_classes .= ' simcal-future simcal-day';
562 562
 				}
563 563
 
564 564
 				$count = 0;
565 565
 
566
-				foreach ( $events as $day_events ) :
567
-					foreach ( $day_events as $event ) :
566
+				foreach ($events as $day_events) :
567
+					foreach ($day_events as $event) :
568 568
 
569
-						if ( $event instanceof Event ) :
569
+						if ($event instanceof Event) :
570 570
 
571
-							if ( $feed->type == 'grouped-calendars' ) {
572
-								date_default_timezone_set( $feed_timezone );
571
+							if ($feed->type == 'grouped-calendars') {
572
+								date_default_timezone_set($feed_timezone);
573 573
 							} else {
574
-								date_default_timezone_set( $event->timezone );
574
+								date_default_timezone_set($event->timezone);
575 575
 							}
576 576
 
577 577
 							$event_classes = $event_visibility = '';
578 578
 
579
-							$calendar_class     = 'simcal-events-calendar-' . strval( $event->calendar );
579
+							$calendar_class     = 'simcal-events-calendar-'.strval($event->calendar);
580 580
 							$calendar_classes[] = $calendar_class;
581 581
 
582 582
 							$recurring     = $event->recurrence ? 'simcal-event-recurring ' : '';
583 583
 							$has_location  = $event->venue ? 'simcal-event-has-location ' : '';
584 584
 
585
-							$event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class;
585
+							$event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class;
586 586
 
587 587
 							// Toggle some events visibility if more than optional limit.
588
-							if ( ( $calendar->events_limit > - 1 ) && ( $count >= $calendar->events_limit ) ) :
588
+							if (($calendar->events_limit > - 1) && ($count >= $calendar->events_limit)) :
589 589
 								$event_classes .= ' simcal-event-toggled';
590 590
 								$event_visibility = ' style="display: none"';
591 591
 							endif;
@@ -593,75 +593,75 @@  discard block
 block discarded – undo
593 593
 							$event_color = '';
594 594
 							$bullet = '';
595 595
 							$event_color = $event->get_color();
596
-							if ( ! empty( $event_color ) ) {
596
+							if ( ! empty($event_color)) {
597 597
 								$side = is_rtl() ? 'right' : 'left';
598
-								$event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"';
598
+								$event_color = ' style="border-'.$side.': 4px solid '.$event_color.'; padding-'.$side.': 8px;"';
599 599
 							}
600 600
 
601
-							$list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemscope itemtype="http://schema.org/Event" data-start="' . esc_attr( $event->start ) . '">' . "\n";
602
-							$list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html( $event ) . '</div>' . "\n";
603
-							$list_events .= "\t" . '</li>' . "\n";
601
+							$list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.$event_color.' itemscope itemtype="http://schema.org/Event" data-start="'.esc_attr($event->start).'">'."\n";
602
+							$list_events .= "\t\t".'<div class="simcal-event-details">'.$calendar->get_event_html($event).'</div>'."\n";
603
+							$list_events .= "\t".'</li>'."\n";
604 604
 
605
-							$count ++;
605
+							$count++;
606 606
 
607 607
 							// Event falls within today.
608
-							if ( ( $this->end <= $now ) && ( $this->start >= $now ) ) :
608
+							if (($this->end <= $now) && ($this->start >= $now)) :
609 609
 								$day_classes .= ' simcal-today-has-events';
610 610
 							endif;
611
-							$day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events';
611
+							$day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events';
612 612
 
613
-							if ( $calendar_classes ) :
614
-								$day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) );
613
+							if ($calendar_classes) :
614
+								$day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes)));
615 615
 							endif;
616 616
 
617 617
 						endif;
618 618
 					endforeach;
619 619
 				endforeach;
620 620
 
621
-				$list_events .= '</ul>' . "\n";
621
+				$list_events .= '</ul>'."\n";
622 622
 
623 623
 				// If events visibility is limited, print the button toggle.
624
-				if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) :
624
+				if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) :
625 625
 					$list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>';
626 626
 				endif;
627 627
 
628 628
 				// Print final list of events for the current day.
629 629
 				$tag = $calendar->compact_list ? 'div' : 'dd';
630
-				echo '<'  . $tag . ' class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n";
631
-				echo "\t" . $list_events . "\n";
632
-				echo '</' . $tag . '>' . "\n";
630
+				echo '<'.$tag.' class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n";
631
+				echo "\t".$list_events."\n";
632
+				echo '</'.$tag.'>'."\n";
633 633
 
634 634
 			endforeach;
635 635
 
636 636
 		else :
637 637
 
638
-			echo "\t" . '<p>';
638
+			echo "\t".'<p>';
639 639
 
640
-			$message = get_post_meta( $calendar->id, '_no_events_message', true );
640
+			$message = get_post_meta($calendar->id, '_no_events_message', true);
641 641
 
642
-			if ( 'events' == $calendar->group_type ) {
643
-				echo ! empty( $message ) ? $message : __( 'There are no upcoming events.', 'google-calendar-events' );
642
+			if ('events' == $calendar->group_type) {
643
+				echo ! empty($message) ? $message : __('There are no upcoming events.', 'google-calendar-events');
644 644
 			} else {
645
-				if ( ! empty( $message ) ) {
645
+				if ( ! empty($message)) {
646 646
 					echo $message;
647 647
 				} else {
648
-					$from = Carbon::createFromTimestamp( $this->start, $calendar->timezone )->getTimestamp();
649
-					$to = Carbon::createFromTimestamp( $this->end, $calendar->timezone )->getTimestamp();
650
-					echo apply_filters( 'simcal_no_events_message', sprintf(
651
-						__( 'Nothing from %1$s to %2$s.', 'google-calendar-events' ),
652
-						date_i18n( $calendar->date_format, $from ),
653
-						date_i18n( $calendar->date_format, $to )
654
-					), $calendar->id, $from, $to );
648
+					$from = Carbon::createFromTimestamp($this->start, $calendar->timezone)->getTimestamp();
649
+					$to = Carbon::createFromTimestamp($this->end, $calendar->timezone)->getTimestamp();
650
+					echo apply_filters('simcal_no_events_message', sprintf(
651
+						__('Nothing from %1$s to %2$s.', 'google-calendar-events'),
652
+						date_i18n($calendar->date_format, $from),
653
+						date_i18n($calendar->date_format, $to)
654
+					), $calendar->id, $from, $to);
655 655
 				}
656 656
 			}
657 657
 
658
-			echo "\t" . '</p>' . "\n";
658
+			echo "\t".'</p>'."\n";
659 659
 
660 660
 		endif;
661 661
 
662
-		echo '</' . $block_tag . '>';
662
+		echo '</'.$block_tag.'>';
663 663
 
664
-		date_default_timezone_set( $calendar->site_timezone );
664
+		date_default_timezone_set($calendar->site_timezone);
665 665
 
666 666
 		return ob_get_clean();
667 667
 	}
@@ -673,16 +673,16 @@  discard block
 block discarded – undo
673 673
 	 */
674 674
 	public function draw_list_ajax() {
675 675
 
676
-		if ( isset( $_POST['ts'] ) && isset( $_POST['id'] ) ) {
676
+		if (isset($_POST['ts']) && isset($_POST['id'])) {
677 677
 
678
-			$ts = absint( $_POST['ts'] );
679
-			$id = absint( $_POST['id'] );
678
+			$ts = absint($_POST['ts']);
679
+			$id = absint($_POST['id']);
680 680
 
681
-			wp_send_json_success( $this->draw_list( $ts, $id ) );
681
+			wp_send_json_success($this->draw_list($ts, $id));
682 682
 
683 683
 		} else {
684 684
 
685
-			wp_send_json_error( 'Missing arguments in default calendar list ajax request.' );
685
+			wp_send_json_error('Missing arguments in default calendar list ajax request.');
686 686
 
687 687
 		}
688 688
 	}
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
 	 *
698 698
 	 * @return bool
699 699
 	 */
700
-	private function filter_events_before( $event ) {
701
-		return intval( $event ) >= intval( $this->start );
700
+	private function filter_events_before($event) {
701
+		return intval($event) >= intval($this->start);
702 702
 	}
703 703
 
704 704
 	/**
@@ -711,8 +711,8 @@  discard block
 block discarded – undo
711 711
 	 *
712 712
 	 * @return bool
713 713
 	 */
714
-	private function filter_events_after( $event ) {
715
-		return intval( $event ) < intval( $this->end );
714
+	private function filter_events_after($event) {
715
+		return intval($event) < intval($this->end);
716 716
 	}
717 717
 
718 718
 }
Please login to merge, or discard this patch.
includes/admin/metaboxes/settings.php 1 patch
Spacing   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 use SimpleCalendar\Abstracts\Feed;
12 12
 use SimpleCalendar\Abstracts\Field;
13 13
 
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -31,40 +31,40 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param \WP_Post $post
33 33
 	 */
34
-	public static function html( $post ) {
34
+	public static function html($post) {
35 35
 
36 36
 		// @see Meta_Boxes::save_meta_boxes()
37
-		wp_nonce_field( 'simcal_save_data', 'simcal_meta_nonce' );
37
+		wp_nonce_field('simcal_save_data', 'simcal_meta_nonce');
38 38
 
39 39
 		?>
40 40
 		<div class="simcal-panels-wrap">
41 41
 
42 42
 			<span class="simcal-box-handle">
43
-				<?php self::settings_handle( $post ); ?>
43
+				<?php self::settings_handle($post); ?>
44 44
 			</span>
45 45
 
46 46
 			<ul class="simcal-tabs">
47
-				<?php self::settings_tabs( $post ); ?>
48
-				<?php do_action( 'simcal_settings_meta_tabs' ); ?>
47
+				<?php self::settings_tabs($post); ?>
48
+				<?php do_action('simcal_settings_meta_tabs'); ?>
49 49
 			</ul>
50 50
 
51 51
 			<div class="simcal-panels">
52 52
 				<div id="events-settings-panel" class="simcal-panel">
53
-					<?php self::events_settings_panel( $post ); ?>
54
-					<?php do_action( 'simcal_settings_meta_events_panel', $post->ID ); ?>
53
+					<?php self::events_settings_panel($post); ?>
54
+					<?php do_action('simcal_settings_meta_events_panel', $post->ID); ?>
55 55
 				</div>
56 56
 				<div id="calendar-settings-panel" class="simcal-panel">
57
-					<?php do_action( 'simcal_settings_meta_calendar_panel', $post->ID ); ?>
58
-					<?php self::calendar_settings_panel( $post ); ?>
57
+					<?php do_action('simcal_settings_meta_calendar_panel', $post->ID); ?>
58
+					<?php self::calendar_settings_panel($post); ?>
59 59
 				</div>
60 60
 				<?php
61 61
 				// Hook for additional settings panels.
62
-				do_action( 'simcal_settings_meta_panels', $post->ID );
62
+				do_action('simcal_settings_meta_panels', $post->ID);
63 63
 				// Thus advanced panel is always the last one:
64 64
 				?>
65 65
 				<div id="advanced-settings-panel" class="simcal-panel">
66
-					<?php self::advanced_settings_panel( $post ) ?>
67
-					<?php do_action( 'simcal_settings_meta_advanced_panel', $post->ID ); ?>
66
+					<?php self::advanced_settings_panel($post) ?>
67
+					<?php do_action('simcal_settings_meta_advanced_panel', $post->ID); ?>
68 68
 				</div>
69 69
 			</div>
70 70
 
@@ -84,45 +84,45 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @param \WP_Post $post
86 86
 	 */
87
-	private static function settings_handle( $post ) {
87
+	private static function settings_handle($post) {
88 88
 
89 89
 		$feed_options = $calendar_options = $calendar_views = array();
90 90
 
91 91
 		$feed_types = simcal_get_feed_types();
92
-		foreach ( $feed_types as $feed_type ) {
92
+		foreach ($feed_types as $feed_type) {
93 93
 
94
-			$feed = simcal_get_feed( $feed_type );
94
+			$feed = simcal_get_feed($feed_type);
95 95
 
96
-			if ( $feed instanceof Feed ) {
97
-				$feed_options[ $feed_type ] = $feed->name;
96
+			if ($feed instanceof Feed) {
97
+				$feed_options[$feed_type] = $feed->name;
98 98
 			}
99 99
 		}
100 100
 
101 101
 		$calendar_types = simcal_get_calendar_types();
102
-		foreach ( $calendar_types as $calendar_type => $views ) {
102
+		foreach ($calendar_types as $calendar_type => $views) {
103 103
 
104
-			$calendar = simcal_get_calendar( $calendar_type );
104
+			$calendar = simcal_get_calendar($calendar_type);
105 105
 
106
-			if ( $calendar instanceof Calendar ) {
107
-				$calendar_options[ $calendar_type ] = $calendar->name;
108
-				$calendar_views[ $calendar_type ]   = $calendar->views;
106
+			if ($calendar instanceof Calendar) {
107
+				$calendar_options[$calendar_type] = $calendar->name;
108
+				$calendar_views[$calendar_type]   = $calendar->views;
109 109
 			}
110 110
 		}
111 111
 
112
-		if ( $feed_options ) {
112
+		if ($feed_options) {
113 113
 
114
-			if ( $feed_types = wp_get_object_terms( $post->ID, 'calendar_feed' ) ) {
115
-				$feed_type = sanitize_title( current( $feed_types )->name );
114
+			if ($feed_types = wp_get_object_terms($post->ID, 'calendar_feed')) {
115
+				$feed_type = sanitize_title(current($feed_types)->name);
116 116
 			} else {
117
-				$feed_type = apply_filters( 'simcal_default_feed_type', 'google' );
117
+				$feed_type = apply_filters('simcal_default_feed_type', 'google');
118 118
 			}
119 119
 
120 120
 			?>
121
-			<label for="_feed_type"><span><?php _e( 'Event Source', 'google-calendar-events' ); ?></span>
121
+			<label for="_feed_type"><span><?php _e('Event Source', 'google-calendar-events'); ?></span>
122 122
 				<select name="_feed_type" id="_feed_type">
123
-					<optgroup label="<?php _ex( 'Get events from', 'From which calendar source to load events from', 'google-calendar-events' ) ?>">
124
-						<?php foreach ( $feed_options as $feed => $name ) { ?>
125
-							<option value="<?php echo $feed; ?>" <?php selected( $feed, $feed_type, true ); ?>><?php echo $name; ?></option>
123
+					<optgroup label="<?php _ex('Get events from', 'From which calendar source to load events from', 'google-calendar-events') ?>">
124
+						<?php foreach ($feed_options as $feed => $name) { ?>
125
+							<option value="<?php echo $feed; ?>" <?php selected($feed, $feed_type, true); ?>><?php echo $name; ?></option>
126 126
 						<?php } ?>
127 127
 					</optgroup>
128 128
 				</select>
@@ -131,40 +131,40 @@  discard block
 block discarded – undo
131 131
 
132 132
 		}
133 133
 
134
-		if ( $calendar_options ) {
134
+		if ($calendar_options) {
135 135
 
136
-			if ( $calendar_types = wp_get_object_terms( $post->ID, 'calendar_type' ) ) {
137
-				$calendar_type = sanitize_title( current( $calendar_types )->name );
136
+			if ($calendar_types = wp_get_object_terms($post->ID, 'calendar_type')) {
137
+				$calendar_type = sanitize_title(current($calendar_types)->name);
138 138
 			} else {
139
-				$calendar_type = apply_filters( 'simcal_default_calendar_type', 'default-calendar' );
139
+				$calendar_type = apply_filters('simcal_default_calendar_type', 'default-calendar');
140 140
 			}
141 141
 
142 142
 			?>
143
-			<label for="_calendar_type"><span><?php _e( 'Calendar Type', 'google-calendar-events' ); ?></span>
143
+			<label for="_calendar_type"><span><?php _e('Calendar Type', 'google-calendar-events'); ?></span>
144 144
 				<select name="_calendar_type" id="_calendar_type">
145
-					<optgroup label="<?php _e( 'Calendar to use', 'google-calendar-events' ); ?>">
146
-						<?php foreach ( $calendar_options as $calendar => $name ) { ?>
147
-							<option value="<?php echo $calendar; ?>" <?php selected( $calendar, $calendar_type, true ); ?>><?php echo $name; ?></option>
145
+					<optgroup label="<?php _e('Calendar to use', 'google-calendar-events'); ?>">
146
+						<?php foreach ($calendar_options as $calendar => $name) { ?>
147
+							<option value="<?php echo $calendar; ?>" <?php selected($calendar, $calendar_type, true); ?>><?php echo $name; ?></option>
148 148
 						<?php } ?>
149 149
 					</optgroup>
150 150
 				</select>
151 151
 			</label>
152 152
 			<?php
153 153
 
154
-			if ( $calendar_views ) {
154
+			if ($calendar_views) {
155 155
 
156
-				$calendar_view = get_post_meta( $post->ID, '_calendar_view', true );
156
+				$calendar_view = get_post_meta($post->ID, '_calendar_view', true);
157 157
 
158
-				foreach ( $calendar_views as $calendar => $views ) {
158
+				foreach ($calendar_views as $calendar => $views) {
159 159
 
160
-					$calendar_type_view = isset( $calendar_view[ $calendar ] ) ? $calendar_view[ $calendar ] : '';
160
+					$calendar_type_view = isset($calendar_view[$calendar]) ? $calendar_view[$calendar] : '';
161 161
 
162 162
 					?>
163
-					<label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e( 'View', 'google-calendar-events' ); ?></span>
163
+					<label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e('View', 'google-calendar-events'); ?></span>
164 164
 						<select name="_calendar_view[<?php echo $calendar; ?>]" id="_calendar_view_<?php echo $calendar; ?>">
165
-							<optgroup label="<?php _e( 'View to display', 'google-calendar-events' ); ?>">
166
-								<?php foreach ( $views as $view => $name ) { ?>
167
-									<option value="<?php echo $view; ?>" <?php selected( $view, $calendar_type_view, true ); ?>><?php echo $name; ?></option>
165
+							<optgroup label="<?php _e('View to display', 'google-calendar-events'); ?>">
166
+								<?php foreach ($views as $view => $name) { ?>
167
+									<option value="<?php echo $view; ?>" <?php selected($view, $calendar_type_view, true); ?>><?php echo $name; ?></option>
168 168
 								<?php } ?>
169 169
 							</optgroup>
170 170
 						</select>
@@ -184,42 +184,42 @@  discard block
 block discarded – undo
184 184
 	 *
185 185
 	 * @param  \WP_Post $post
186 186
 	 */
187
-	private static function settings_tabs( $post ) {
187
+	private static function settings_tabs($post) {
188 188
 
189 189
 		// Hook to add more tabs.
190
-		$tabs = apply_filters( 'simcal_settings_meta_tabs_li', array(
190
+		$tabs = apply_filters('simcal_settings_meta_tabs_li', array(
191 191
 			'events' => array(
192
-				'label'   => __( 'Events', 'google-calendar-events' ),
192
+				'label'   => __('Events', 'google-calendar-events'),
193 193
 				'target'  => 'events-settings-panel',
194
-				'class'   => array( 'active' ),
194
+				'class'   => array('active'),
195 195
 				'icon'    => 'simcal-icon-event',
196 196
 			),
197 197
 			'calendar' => array(
198
-				'label'  => __( 'Appearance', 'google-calendar-events' ),
198
+				'label'  => __('Appearance', 'google-calendar-events'),
199 199
 				'target' => 'calendar-settings-panel',
200 200
 				'class'  => array(),
201 201
 				'icon'   => 'simcal-icon-calendar',
202 202
 			),
203
-		), $post->ID );
203
+		), $post->ID);
204 204
 
205 205
 		// Always keep advanced tab as the last one.
206 206
 		$tabs['advanced'] = array(
207
-			'label'   => __( 'Advanced', 'google-calendar-events' ),
207
+			'label'   => __('Advanced', 'google-calendar-events'),
208 208
 			'target'  => 'advanced-settings-panel',
209 209
 			'class'   => array(),
210 210
 			'icon'    => 'simcal-icon-settings',
211 211
 		);
212 212
 
213 213
 		// Output the tabs as list items.
214
-		foreach ( $tabs as $key => $tab ) {
214
+		foreach ($tabs as $key => $tab) {
215 215
 
216
-			if ( isset( $tab['target'] ) && isset( $tab['label'] ) ) {
216
+			if (isset($tab['target']) && isset($tab['label'])) {
217 217
 
218 218
 				$icon  = $tab['icon'] ? $tab['icon'] : 'simcal-icon-panel';
219 219
 				$class = $tab['class'] ? $tab['class'] : array();
220 220
 
221
-				echo '<li class="' . $key . '-settings ' . $key . '-tab ' . implode( ' ', $class ) . '" data-tab="' . $key . '">';
222
-				echo    '<a href="#' . $tab['target'] . '"><i class="' . $icon . '" ></i> <span>' . esc_html( $tab['label'] ) . '</span></a>';
221
+				echo '<li class="'.$key.'-settings '.$key.'-tab '.implode(' ', $class).'" data-tab="'.$key.'">';
222
+				echo    '<a href="#'.$tab['target'].'"><i class="'.$icon.'" ></i> <span>'.esc_html($tab['label']).'</span></a>';
223 223
 				echo '</li>';
224 224
 			}
225 225
 		}
@@ -233,22 +233,22 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @param  \WP_Post $post
235 235
 	 */
236
-	private static function events_settings_panel( $post ) {
236
+	private static function events_settings_panel($post) {
237 237
 
238 238
 		?>
239 239
 		<table>
240 240
 			<thead>
241
-			<tr><th colspan="2"><?php _e( 'Event Settings', 'google-calendar-events' ); ?></th></tr>
241
+			<tr><th colspan="2"><?php _e('Event Settings', 'google-calendar-events'); ?></th></tr>
242 242
 			</thead>
243 243
 			<tbody class="simcal-panel-section simcal-panel-section-events-range">
244 244
 			<tr class="simcal-panel-field">
245
-				<th><label for="_calendar_begins"><?php _e( 'Calendar Start', 'google-calendar-events' ); ?></label></th>
245
+				<th><label for="_calendar_begins"><?php _e('Calendar Start', 'google-calendar-events'); ?></label></th>
246 246
 				<td>
247 247
 					<?php
248 248
 
249
-					$calendar_begins = esc_attr( get_post_meta( $post->ID, '_calendar_begins', true ) );
250
-					$calendar_begins_nth = max( absint( get_post_meta( $post->ID, '_calendar_begins_nth', true ) ), 1 );
251
-					$calendar_begins_nth_show = in_array( $calendar_begins, array(
249
+					$calendar_begins = esc_attr(get_post_meta($post->ID, '_calendar_begins', true));
250
+					$calendar_begins_nth = max(absint(get_post_meta($post->ID, '_calendar_begins_nth', true)), 1);
251
+					$calendar_begins_nth_show = in_array($calendar_begins, array(
252 252
 						'days_before',
253 253
 						'days_after',
254 254
 						'weeks_before',
@@ -257,14 +257,14 @@  discard block
 block discarded – undo
257 257
 						'months_after',
258 258
 						'years_before',
259 259
 						'years_after',
260
-					) );
260
+					));
261 261
 
262
-					simcal_print_field( array(
262
+					simcal_print_field(array(
263 263
 						'type'       => 'standard',
264 264
 						'subtype'    => 'number',
265 265
 						'name'       => '_calendar_begins_nth',
266 266
 						'id'         => '_calendar_begins_nth',
267
-						'value'      => strval( $calendar_begins_nth ),
267
+						'value'      => strval($calendar_begins_nth),
268 268
 						'attributes' => array(
269 269
 							'min' => '1',
270 270
 						),
@@ -272,97 +272,97 @@  discard block
 block discarded – undo
272 272
 							'simcal-field-inline',
273 273
 							'simcal-field-tiny',
274 274
 						),
275
-						'style'      => ! $calendar_begins_nth_show ? array( 'display' => 'none' ) : '',
276
-					) );
275
+						'style'      => ! $calendar_begins_nth_show ? array('display' => 'none') : '',
276
+					));
277 277
 
278 278
 					?>
279 279
 					<select name="_calendar_begins"
280 280
 							id="_calendar_begins"
281 281
 							class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other">
282
-						<optgroup label="<?php _e( 'Days', 'google-calendar-events' ); ?>">
282
+						<optgroup label="<?php _e('Days', 'google-calendar-events'); ?>">
283 283
 							<option value="today"
284 284
 									data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth"
285
-								<?php selected( 'today', $calendar_begins, true ); ?>><?php _e( 'Today', 'google-calendar-events' ); ?></option>
285
+								<?php selected('today', $calendar_begins, true); ?>><?php _e('Today', 'google-calendar-events'); ?></option>
286 286
 							<option value="now"
287 287
 									data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth"
288
-								<?php selected( 'now', $calendar_begins, true ); ?>><?php _e( 'Now', 'google-calendar-events' ); ?></option>
288
+								<?php selected('now', $calendar_begins, true); ?>><?php _e('Now', 'google-calendar-events'); ?></option>
289 289
 							<option value="days_before"
290 290
 									data-hide-field="_calendar_begins_custom_date"
291
-									data-show-field="_calendar_begins_nth" <?php selected( 'days_before', $calendar_begins, true ); ?>><?php _e( 'Day(s) before today', 'google-calendar-events' ); ?></option>
291
+									data-show-field="_calendar_begins_nth" <?php selected('days_before', $calendar_begins, true); ?>><?php _e('Day(s) before today', 'google-calendar-events'); ?></option>
292 292
 							<option value="days_after"
293 293
 									data-hide-field="_calendar_begins_custom_date"
294
-									data-show-field="_calendar_begins_nth" <?php selected( 'days_after', $calendar_begins, true ); ?>><?php _e( 'Day(s) after today', 'google-calendar-events' ); ?></option>
294
+									data-show-field="_calendar_begins_nth" <?php selected('days_after', $calendar_begins, true); ?>><?php _e('Day(s) after today', 'google-calendar-events'); ?></option>
295 295
 						</optgroup>
296
-						<optgroup label="<?php _e( 'Weeks', 'google-calendar-events' ); ?>">
296
+						<optgroup label="<?php _e('Weeks', 'google-calendar-events'); ?>">
297 297
 							<option value="this_week"
298 298
 									data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth"
299
-								<?php selected( 'this_week', $calendar_begins, true ); ?>><?php _e( 'This week', 'google-calendar-events' ); ?></option>
299
+								<?php selected('this_week', $calendar_begins, true); ?>><?php _e('This week', 'google-calendar-events'); ?></option>
300 300
 							<option value="weeks_before"
301 301
 									data-hide-field="_calendar_begins_custom_date"
302
-									data-show-field="_calendar_begins_nth" <?php selected( 'weeks_before', $calendar_begins, true ); ?>><?php _e( 'Week(s) before current', 'google-calendar-events' ); ?></option>
302
+									data-show-field="_calendar_begins_nth" <?php selected('weeks_before', $calendar_begins, true); ?>><?php _e('Week(s) before current', 'google-calendar-events'); ?></option>
303 303
 							<option value="weeks_after"
304 304
 									data-hide-field="_calendar_begins_custom_date"
305
-									data-show-field="_calendar_begins_nth" <?php selected( 'weeks_after', $calendar_begins, true ); ?>><?php _e( 'Week(s) after current', 'google-calendar-events' ); ?></option>
305
+									data-show-field="_calendar_begins_nth" <?php selected('weeks_after', $calendar_begins, true); ?>><?php _e('Week(s) after current', 'google-calendar-events'); ?></option>
306 306
 						</optgroup>
307
-						<optgroup label="<?php _e( 'Months', 'google-calendar-events' ); ?>">
307
+						<optgroup label="<?php _e('Months', 'google-calendar-events'); ?>">
308 308
 							<option value="this_month"
309 309
 									data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth"
310
-								<?php selected( 'this_month', $calendar_begins, true ); ?>><?php _e( 'This month', 'google-calendar-events' ); ?></option>
310
+								<?php selected('this_month', $calendar_begins, true); ?>><?php _e('This month', 'google-calendar-events'); ?></option>
311 311
 							<option value="months_before"
312 312
 									data-hide-field="_calendar_begins_custom_date"
313
-									data-show-field="_calendar_begins_nth" <?php selected( 'months_before', $calendar_begins, true ); ?>><?php _e( 'Month(s) before current', 'google-calendar-events' ); ?></option>
313
+									data-show-field="_calendar_begins_nth" <?php selected('months_before', $calendar_begins, true); ?>><?php _e('Month(s) before current', 'google-calendar-events'); ?></option>
314 314
 							<option value="months_after"
315 315
 									data-hide-field="_calendar_begins_custom_date"
316
-									data-show-field="_calendar_begins_nth" <?php selected( 'months_after', $calendar_begins, true ); ?>><?php _e( 'Month(s) after current', 'google-calendar-events' ); ?></option>
316
+									data-show-field="_calendar_begins_nth" <?php selected('months_after', $calendar_begins, true); ?>><?php _e('Month(s) after current', 'google-calendar-events'); ?></option>
317 317
 						</optgroup>
318
-						<optgroup label="<?php _e( 'Years', 'google-calendar-events' ); ?>">
318
+						<optgroup label="<?php _e('Years', 'google-calendar-events'); ?>">
319 319
 							<option value="this_year"
320 320
 									data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth"
321
-								<?php selected( 'this_year', $calendar_begins, true ); ?>><?php _e( 'This year', 'google-calendar-events' ); ?></option>
321
+								<?php selected('this_year', $calendar_begins, true); ?>><?php _e('This year', 'google-calendar-events'); ?></option>
322 322
 							<option value="years_before"
323
-									data-show-field="_calendar_begins_nth" <?php selected( 'years_before', $calendar_begins, true ); ?>><?php _e( 'Year(s) before current', 'google-calendar-events' ); ?></option>
323
+									data-show-field="_calendar_begins_nth" <?php selected('years_before', $calendar_begins, true); ?>><?php _e('Year(s) before current', 'google-calendar-events'); ?></option>
324 324
 							<option value="years_after"
325 325
 									data-hide-field="_calendar_begins_custom_date"
326
-									data-show-field="_calendar_begins_nth" <?php selected( 'years_after', $calendar_begins, true ); ?>><?php _e( 'Year(s) after current', 'google-calendar-events' ); ?></option>
326
+									data-show-field="_calendar_begins_nth" <?php selected('years_after', $calendar_begins, true); ?>><?php _e('Year(s) after current', 'google-calendar-events'); ?></option>
327 327
 						</optgroup>
328
-						<optgroup label="<?php _e( 'Other', 'google-calendar-events' ); ?>">
328
+						<optgroup label="<?php _e('Other', 'google-calendar-events'); ?>">
329 329
 							<option value="custom_date"
330 330
 									data-hide-field="_calendar_begins_nth"
331
-									data-show-field="_calendar_begins_custom_date" <?php selected( 'custom_date', $calendar_begins, true ); ?>><?php _e( 'Specific date', 'google-calendar-events' ); ?></option>
331
+									data-show-field="_calendar_begins_custom_date" <?php selected('custom_date', $calendar_begins, true); ?>><?php _e('Specific date', 'google-calendar-events'); ?></option>
332 332
 						</optgroup>
333 333
 					</select>
334 334
 					<?php
335 335
 
336
-					simcal_print_field( array(
336
+					simcal_print_field(array(
337 337
 						'type'    => 'date-picker',
338 338
 						'name'    => '_calendar_begins_custom_date',
339 339
 						'id'      => '_calendar_begins_custom_date',
340
-						'value'   => get_post_meta( $post->ID, '_calendar_begins_custom_date', true ),
340
+						'value'   => get_post_meta($post->ID, '_calendar_begins_custom_date', true),
341 341
 						'class' => array(
342 342
 							'simcal-field-inline',
343 343
 						),
344
-						'style'   => 'custom_date' != $calendar_begins ? array( 'display' => 'none' ) : '',
345
-					) );
344
+						'style'   => 'custom_date' != $calendar_begins ? array('display' => 'none') : '',
345
+					));
346 346
 
347 347
 					?>
348 348
 					<i class="simcal-icon-help simcal-help-tip"
349
-					   data-tip="<?php _e( 'The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events' ); ?>"></i>
349
+					   data-tip="<?php _e('The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events'); ?>"></i>
350 350
 				</td>
351 351
 			</tr>
352 352
 			<tr class="simcal-panel-field">
353
-				<th><label for="_feed_earliest_event_date"><?php _e( 'Earliest Event', 'google-calendar-events' ); ?></label></th>
353
+				<th><label for="_feed_earliest_event_date"><?php _e('Earliest Event', 'google-calendar-events'); ?></label></th>
354 354
 				<td>
355 355
 					<?php
356 356
 
357
-					$earliest_event_saved = get_post_meta( $post->ID, '_feed_earliest_event_date', true );
358
-					$earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr( $earliest_event_saved );
357
+					$earliest_event_saved = get_post_meta($post->ID, '_feed_earliest_event_date', true);
358
+					$earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr($earliest_event_saved);
359 359
 
360
-					simcal_print_field( array(
360
+					simcal_print_field(array(
361 361
 						'type'       => 'standard',
362 362
 						'subtype'    => 'number',
363 363
 						'name'       => '_feed_earliest_event_date_range',
364 364
 						'id'         => '_feed_earliest_event_date_range',
365
-						'value'      => strval( max( absint( get_post_meta( $post->ID, '_feed_earliest_event_date_range', true ) ), 1 ) ),
365
+						'value'      => strval(max(absint(get_post_meta($post->ID, '_feed_earliest_event_date_range', true)), 1)),
366 366
 						'attributes' => array(
367 367
 							'min' => '1',
368 368
 						),
@@ -370,37 +370,37 @@  discard block
 block discarded – undo
370 370
 							'simcal-field-inline',
371 371
 							'simcal-field-tiny',
372 372
 						),
373
-						'style'      => ( 'now' != $earliest_event ) && ( 'today' != $earliest_event ) ? array( 'display' => 'none' ) : '',
374
-					) );
373
+						'style'      => ('now' != $earliest_event) && ('today' != $earliest_event) ? array('display' => 'none') : '',
374
+					));
375 375
 
376 376
 					?>
377 377
 					<select name="_feed_earliest_event_date"
378 378
 							id="_feed_earliest_event_date"
379 379
 							class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other">
380
-						<option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Same as start date', 'google-calendar-events' ); ?></option>
381
-						<option value="days_before"    data-show-field="_feed_earliest_event_date_range" <?php selected( 'days_before', $earliest_event, true ); ?>><?php _e( 'Day(s) before start date', 'google-calendar-events' ); ?></option>
382
-						<option value="weeks_before"   data-show-field="_feed_earliest_event_date_range" <?php selected( 'weeks_before', $earliest_event, true ); ?>><?php _e( 'Week(s) before start date', 'google-calendar-events' ); ?></option>
383
-						<option value="months_before"  data-show-field="_feed_earliest_event_date_range" <?php selected( 'months_before', $earliest_event, true ); ?>><?php _e( 'Month(s) before start date', 'google-calendar-events' ); ?></option>
384
-						<option value="years_before"   data-show-field="_feed_earliest_event_date_range" <?php selected( 'years_before', $earliest_event, true ); ?>><?php _e( 'Year(s) before start date', 'google-calendar-events' ); ?></option>
380
+						<option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Same as start date', 'google-calendar-events'); ?></option>
381
+						<option value="days_before"    data-show-field="_feed_earliest_event_date_range" <?php selected('days_before', $earliest_event, true); ?>><?php _e('Day(s) before start date', 'google-calendar-events'); ?></option>
382
+						<option value="weeks_before"   data-show-field="_feed_earliest_event_date_range" <?php selected('weeks_before', $earliest_event, true); ?>><?php _e('Week(s) before start date', 'google-calendar-events'); ?></option>
383
+						<option value="months_before"  data-show-field="_feed_earliest_event_date_range" <?php selected('months_before', $earliest_event, true); ?>><?php _e('Month(s) before start date', 'google-calendar-events'); ?></option>
384
+						<option value="years_before"   data-show-field="_feed_earliest_event_date_range" <?php selected('years_before', $earliest_event, true); ?>><?php _e('Year(s) before start date', 'google-calendar-events'); ?></option>
385 385
 					</select>
386 386
 					<i class="simcal-icon-help simcal-help-tip"
387
-					   data-tip="<?php _e( 'Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events' ); ?>"></i>
387
+					   data-tip="<?php _e('Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events'); ?>"></i>
388 388
 				</td>
389 389
 			</tr>
390 390
 			<tr class="simcal-panel-field">
391
-				<th><label for="_feed_latest_event_date"><?php _e( 'Latest Event', 'google-calendar-events' ); ?></label></th>
391
+				<th><label for="_feed_latest_event_date"><?php _e('Latest Event', 'google-calendar-events'); ?></label></th>
392 392
 				<td>
393 393
 					<?php
394 394
 
395
-					$latest_event_saved = get_post_meta( $post->ID, '_feed_latest_event_date', true );
396
-					$latest_event = false == $latest_event_saved ? 'years_after' : esc_attr( $latest_event_saved );
395
+					$latest_event_saved = get_post_meta($post->ID, '_feed_latest_event_date', true);
396
+					$latest_event = false == $latest_event_saved ? 'years_after' : esc_attr($latest_event_saved);
397 397
 
398
-					simcal_print_field( array(
398
+					simcal_print_field(array(
399 399
 						'type'       => 'standard',
400 400
 						'subtype'    => 'number',
401 401
 						'name'       => '_feed_latest_event_date_range',
402 402
 						'id'         => '_feed_latest_event_date_range',
403
-						'value'      => strval( max( absint( get_post_meta( $post->ID, '_feed_latest_event_date_range', true ) ), 1 ) ),
403
+						'value'      => strval(max(absint(get_post_meta($post->ID, '_feed_latest_event_date_range', true)), 1)),
404 404
 						'attributes' => array(
405 405
 							'min' => '1',
406 406
 						),
@@ -408,21 +408,21 @@  discard block
 block discarded – undo
408 408
 							'simcal-field-inline',
409 409
 							'simcal-field-tiny',
410 410
 						),
411
-						'style'      => 'indefinite' != $latest_event ? array( 'display' => 'none' ) : '',
412
-					) );
411
+						'style'      => 'indefinite' != $latest_event ? array('display' => 'none') : '',
412
+					));
413 413
 
414 414
 					?>
415 415
 					<select name="_feed_latest_event_date"
416 416
 							id="_feed_latest_event_date"
417 417
 							class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other">
418
-						<option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Day end of start date', 'google-calendar-events' ); ?></option>
419
-						<option value="days_after"     data-show-field="_feed_latest_event_date_range" <?php selected( 'days_after', $latest_event, true ); ?>><?php _e( 'Day(s) after start date', 'google-calendar-events' ); ?></option>
420
-						<option value="weeks_after"    data-show-field="_feed_latest_event_date_range" <?php selected( 'weeks_after', $latest_event, true ); ?>><?php _e( 'Weeks(s) after start date', 'google-calendar-events' ); ?></option>
421
-						<option value="months_after"   data-show-field="_feed_latest_event_date_range" <?php selected( 'months_after', $latest_event, true ); ?>><?php _e( 'Month(s) after start date', 'google-calendar-events' ); ?></option>
422
-						<option value="years_after"    data-show-field="_feed_latest_event_date_range" <?php selected( 'years_after', $latest_event, true ); ?>><?php _e( 'Year(s) after start date', 'google-calendar-events' ); ?></option>
418
+						<option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Day end of start date', 'google-calendar-events'); ?></option>
419
+						<option value="days_after"     data-show-field="_feed_latest_event_date_range" <?php selected('days_after', $latest_event, true); ?>><?php _e('Day(s) after start date', 'google-calendar-events'); ?></option>
420
+						<option value="weeks_after"    data-show-field="_feed_latest_event_date_range" <?php selected('weeks_after', $latest_event, true); ?>><?php _e('Weeks(s) after start date', 'google-calendar-events'); ?></option>
421
+						<option value="months_after"   data-show-field="_feed_latest_event_date_range" <?php selected('months_after', $latest_event, true); ?>><?php _e('Month(s) after start date', 'google-calendar-events'); ?></option>
422
+						<option value="years_after"    data-show-field="_feed_latest_event_date_range" <?php selected('years_after', $latest_event, true); ?>><?php _e('Year(s) after start date', 'google-calendar-events'); ?></option>
423 423
 					</select>
424 424
 					<i class="simcal-icon-help simcal-help-tip"
425
-					   data-tip="<?php _e( 'Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events' ); ?>"></i>
425
+					   data-tip="<?php _e('Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events'); ?>"></i>
426 426
 				</td>
427 427
 			</tr>
428 428
 			</tbody>
@@ -439,88 +439,88 @@  discard block
 block discarded – undo
439 439
 	 *
440 440
 	 * @param  \WP_Post $post
441 441
 	 */
442
-	private static function calendar_settings_panel( $post ) {
442
+	private static function calendar_settings_panel($post) {
443 443
 
444 444
 		?>
445 445
 		<table>
446 446
 			<thead>
447
-			<tr><th colspan="2"><?php _e( 'Miscellaneous', 'google-calendar-events' ); ?></th></tr>
447
+			<tr><th colspan="2"><?php _e('Miscellaneous', 'google-calendar-events'); ?></th></tr>
448 448
 			</thead>
449 449
 			<tbody class="simcal-panel-section">
450 450
 			<tr class="simcal-panel-field">
451
-				<th><label for="_calendar_is_static"><?php _e( 'Static Calendar', 'google-calendar-events' ); ?></label></th>
451
+				<th><label for="_calendar_is_static"><?php _e('Static Calendar', 'google-calendar-events'); ?></label></th>
452 452
 				<td>
453 453
 					<?php
454 454
 
455
-					$fixed = get_post_meta( $post->ID, '_calendar_is_static', true );
455
+					$fixed = get_post_meta($post->ID, '_calendar_is_static', true);
456 456
 
457
-					simcal_print_field( array(
457
+					simcal_print_field(array(
458 458
 						'type'    => 'checkbox',
459 459
 						'name'    => '_calendar_is_static',
460 460
 						'id'      => '_calendar_is_static',
461
-						'tooltip' => __( 'Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events' ),
461
+						'tooltip' => __('Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events'),
462 462
 						'value'   => 'yes' == $fixed ? 'yes' : 'no',
463
-						'text'    => __( 'Yes (hide navigation arrows)', 'google-calendar-events' ),
464
-					) );
463
+						'text'    => __('Yes (hide navigation arrows)', 'google-calendar-events'),
464
+					));
465 465
 
466 466
 					?>
467 467
 				</td>
468 468
 			</tr>
469 469
 			<tr class="simcal-panel-field">
470
-				<th><label for="_no_events_message"><?php _e( 'No Events Message', 'google-calendar-events' ); ?></label></th>
470
+				<th><label for="_no_events_message"><?php _e('No Events Message', 'google-calendar-events'); ?></label></th>
471 471
 				<td>
472 472
 					<?php
473 473
 
474
-					simcal_print_field( array(
474
+					simcal_print_field(array(
475 475
 						'type'    => 'textarea',
476 476
 						'name'    => '_no_events_message',
477 477
 						'id'      => '_no_events_message',
478
-						'tooltip' => __( 'Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events' ),
479
-						'value'   => get_post_meta( $post->ID, '_no_events_message', true ),
480
-						'placeholder' => __( 'There are no upcoming events.', 'google-calendar-events' ),
481
-					) );
478
+						'tooltip' => __('Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events'),
479
+						'value'   => get_post_meta($post->ID, '_no_events_message', true),
480
+						'placeholder' => __('There are no upcoming events.', 'google-calendar-events'),
481
+					));
482 482
 
483 483
 					?>
484 484
 				</td>
485 485
 			</tr>
486 486
 			<tr class="simcal-panel-field">
487
-				<th><label for="_event_formatting"><?php _e( 'Event Formatting', 'google-calendar-events' ); ?></label></th>
487
+				<th><label for="_event_formatting"><?php _e('Event Formatting', 'google-calendar-events'); ?></label></th>
488 488
 				<td>
489 489
 					<?php
490 490
 
491
-					$event_formatting = get_post_meta( $post->ID, '_event_formatting', true );
491
+					$event_formatting = get_post_meta($post->ID, '_event_formatting', true);
492 492
 
493
-					simcal_print_field( array(
493
+					simcal_print_field(array(
494 494
 						'type'    => 'select',
495 495
 						'name'    => '_event_formatting',
496 496
 						'id'      => '_event_formatting',
497
-						'tooltip' => __( 'How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events' ),
497
+						'tooltip' => __('How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events'),
498 498
 						'value'   => $event_formatting,
499 499
 						'default' => 'preserve_linebreaks',
500 500
 						'options' => array(
501
-							'preserve_linebreaks' => __( 'Preserve line breaks, auto paragraphs (default)', 'google-calendar-events' ),
502
-							'no_linebreaks'       => __( 'No line breaks, auto paragraphs', 'google-calendar-events' ),
503
-							'none'                => __( 'No line breaks, no auto paragraphs', 'google-calendar-events' ),
501
+							'preserve_linebreaks' => __('Preserve line breaks, auto paragraphs (default)', 'google-calendar-events'),
502
+							'no_linebreaks'       => __('No line breaks, auto paragraphs', 'google-calendar-events'),
503
+							'none'                => __('No line breaks, no auto paragraphs', 'google-calendar-events'),
504 504
 						),
505
-					) );
505
+					));
506 506
 
507 507
 					?>
508 508
 				</td>
509 509
 			</tr>
510 510
 			<tr class="simcal-panel-field">
511
-				<th><label for="_poweredby"><?php _e( 'Powered By', 'google-calendar-events' ); ?></label></th>
511
+				<th><label for="_poweredby"><?php _e('Powered By', 'google-calendar-events'); ?></label></th>
512 512
 				<td>
513 513
 					<?php
514 514
 
515
-					$poweredby = get_post_meta( $post->ID, '_poweredby', true );
515
+					$poweredby = get_post_meta($post->ID, '_poweredby', true);
516 516
 
517
-					simcal_print_field( array(
517
+					simcal_print_field(array(
518 518
 						'type'    => 'checkbox',
519 519
 						'name'    => '_poweredby',
520 520
 						'id'      => '_poweredby',
521 521
 						'value'   => 'yes' == $poweredby ? 'yes' : 'no',
522
-						'text'    => __( 'Yes, Simple Calendar rocks! Show some love with a little link below this calendar.', 'google-calendar-events' ),
523
-					) );
522
+						'text'    => __('Yes, Simple Calendar rocks! Show some love with a little link below this calendar.', 'google-calendar-events'),
523
+					));
524 524
 
525 525
 					?>
526 526
 				</td>
@@ -539,28 +539,28 @@  discard block
 block discarded – undo
539 539
 	 *
540 540
 	 * @param  \WP_Post $post
541 541
 	 */
542
-	private static function advanced_settings_panel( $post ) {
542
+	private static function advanced_settings_panel($post) {
543 543
 
544 544
 		?>
545 545
 		<table>
546 546
 			<thead>
547
-			<tr><th colspan="2"><?php _e( 'Date and Time', 'google-calendar-events' ); ?></th></tr>
547
+			<tr><th colspan="2"><?php _e('Date and Time', 'google-calendar-events'); ?></th></tr>
548 548
 			</thead>
549 549
 			<tbody class="simcal-panel-section simcal-panel-datetime-formatting">
550 550
 			<tr class="simcal-panel-field">
551
-				<th><label for="_calendar_timezone_setting"><?php _e( 'Timezone', 'google-calendar-events' ); ?></label></th>
551
+				<th><label for="_calendar_timezone_setting"><?php _e('Timezone', 'google-calendar-events'); ?></label></th>
552 552
 				<td>
553 553
 					<?php
554 554
 
555 555
 					$timezone_wordpress = simcal_get_wp_timezone();
556 556
 					$timezone_default   = $timezone_wordpress ? $timezone_wordpress : 'UTC';
557
-					$timezone_setting   = esc_attr( get_post_meta( $post->ID, '_feed_timezone_setting', true ) );
558
-					$timezone           = esc_attr( get_post_meta( $post->ID, '_feed_timezone', true ) );
557
+					$timezone_setting   = esc_attr(get_post_meta($post->ID, '_feed_timezone_setting', true));
558
+					$timezone           = esc_attr(get_post_meta($post->ID, '_feed_timezone', true));
559 559
 					$timezone           = $timezone ? $timezone : $timezone_default;
560
-					$show_use_calendar  = isset( simcal_get_feed( $post )->type );
560
+					$show_use_calendar  = isset(simcal_get_feed($post)->type);
561 561
 
562
-					if ( $show_use_calendar ) {
563
-						$show_use_calendar = ( simcal_get_feed( $post )->type !== 'grouped-calendars' ? 1 : 0 );
562
+					if ($show_use_calendar) {
563
+						$show_use_calendar = (simcal_get_feed($post)->type !== 'grouped-calendars' ? 1 : 0);
564 564
 					} else {
565 565
 						$show_use_calendar = true;
566 566
 					}
@@ -570,56 +570,56 @@  discard block
 block discarded – undo
570 570
 							id="_feed_timezone_setting"
571 571
 							class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other"
572 572
 							data-show-field-on-choice="true">
573
-						<option value="use_site" <?php selected( 'use_site', $timezone_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', $timezone_default ); ?></option>
574
-						<?php if ( $show_use_calendar ) { ?>
575
-							<option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected( 'use_calendar', $timezone_setting, true ); ?>><?php _ex( 'Events source default', 'Use the calendar default setting', 'google-calendar-events' ); ?></option>
573
+						<option value="use_site" <?php selected('use_site', $timezone_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', $timezone_default); ?></option>
574
+						<?php if ($show_use_calendar) { ?>
575
+							<option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected('use_calendar', $timezone_setting, true); ?>><?php _ex('Events source default', 'Use the calendar default setting', 'google-calendar-events'); ?></option>
576 576
 						<?php } ?>
577
-						<option value="use_custom" data-show-field="_feed_timezone" <?php selected( 'use_custom', $timezone_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option>
577
+						<option value="use_custom" data-show-field="_feed_timezone" <?php selected('use_custom', $timezone_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option>
578 578
 					</select>
579 579
 					<select name="_feed_timezone"
580 580
 							id="_feed_timezone"
581 581
 							class="simcal-field simcal-field-select simcal-field-inline"
582 582
 						<?php echo 'use_custom' != $timezone_setting ? 'style="display: none;"' : ''; ?>>
583
-						<?php echo wp_timezone_choice( $timezone ); ?>
583
+						<?php echo wp_timezone_choice($timezone); ?>
584 584
 					</select>
585
-					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Using a different timezone may alter the date and time display of your calendar events. It is recommended to keep the calendar default timezone.', 'google-calendar-events' ); ?>"></i>
585
+					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Using a different timezone may alter the date and time display of your calendar events. It is recommended to keep the calendar default timezone.', 'google-calendar-events'); ?>"></i>
586 586
 					<p id="_use_calendar_warning" style="display: none;" class="simcal-field">
587
-						<?php printf( __( '<strong>Warning:</strong> Using this option can return unexpected results if you have specified <a href="%s" target="_blank">event level</a> timezones.', 'google-calendar-events' ), 'http://docs.simplecalendar.io/timezone-settings/' ); ?>
587
+						<?php printf(__('<strong>Warning:</strong> Using this option can return unexpected results if you have specified <a href="%s" target="_blank">event level</a> timezones.', 'google-calendar-events'), 'http://docs.simplecalendar.io/timezone-settings/'); ?>
588 588
 					</p>
589 589
 				</td>
590 590
 			</tr>
591 591
 			<tr class="simcal-panel-field">
592
-				<th><label for="_calendar_date_format_setting"><?php _e( 'Date Format', 'google-calendar-events' ); ?></label></th>
592
+				<th><label for="_calendar_date_format_setting"><?php _e('Date Format', 'google-calendar-events'); ?></label></th>
593 593
 				<td>
594 594
 					<?php
595 595
 
596
-					$date_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_setting', true ) );
597
-					$date_format_default = esc_attr( get_option( 'date_format' ) );
598
-					$date_format = esc_attr( get_post_meta( $post->ID, '_calendar_date_format', true ) );
599
-					$date_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_php', true ) );
596
+					$date_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_date_format_setting', true));
597
+					$date_format_default = esc_attr(get_option('date_format'));
598
+					$date_format = esc_attr(get_post_meta($post->ID, '_calendar_date_format', true));
599
+					$date_format_php = esc_attr(get_post_meta($post->ID, '_calendar_date_format_php', true));
600 600
 					$date_format_php = $date_format_php ? $date_format_php : $date_format_default;
601 601
 
602 602
 					?>
603 603
 					<select name="_calendar_date_format_setting"
604 604
 							id="_calendar_date_format_setting"
605 605
 							class="simcal-field simcal-field-select simcal-field-show-other">
606
-						<option value="use_site" data-show-field="_calendar_date_format_default" <?php selected( 'use_site', $date_format_setting, true ); ?>><?php  _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option>
607
-						<option value="use_custom" data-show-field="_calendar_date_format" <?php selected( 'use_custom', $date_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option>
608
-						<option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected( 'use_custom_php', $date_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option>
606
+						<option value="use_site" data-show-field="_calendar_date_format_default" <?php selected('use_site', $date_format_setting, true); ?>><?php  _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option>
607
+						<option value="use_custom" data-show-field="_calendar_date_format" <?php selected('use_custom', $date_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option>
608
+						<option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected('use_custom_php', $date_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option>
609 609
 					</select>
610
-					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i>
610
+					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i>
611 611
 					<p id="_calendar_date_format_default" style="<?php echo $date_format_setting != 'use_site' ? 'display: none;' : ''; ?>">
612
-						<em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em>&nbsp;&nbsp;
613
-						<code><?php echo date_i18n( $date_format_default, time() ); ?></code>
612
+						<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
613
+						<code><?php echo date_i18n($date_format_default, time()); ?></code>
614 614
 					</p>
615
-					<?php simcal_print_field( array(
615
+					<?php simcal_print_field(array(
616 616
 						'type'    => 'datetime-format',
617 617
 						'subtype' => 'date',
618 618
 						'name'    => '_calendar_date_format',
619 619
 						'id'      => '_calendar_date_format',
620 620
 						'value'   => $date_format,
621
-						'style'   => $date_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '',
622
-					) ); ?>
621
+						'style'   => $date_format_setting != 'use_custom' ? array('display' => 'none') : '',
622
+					)); ?>
623 623
 					<div class="simcal-field-datetime-format-php" id="_calendar_date_format_php_field" style="<?php echo $date_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>">
624 624
 						<br>
625 625
 						<label for="_calendar_date_format_php">
@@ -628,70 +628,70 @@  discard block
 block discarded – undo
628 628
 								   id="_calendar_date_format_php"
629 629
 								   class="simcal-field simcal-field-text simcal-field-small"
630 630
 								   value="<?php echo $date_format_php; ?>" />
631
-							<?php printf( __( 'Enter a date format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?>
631
+							<?php printf(__('Enter a date format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?>
632 632
 						</label>
633 633
 						<p>
634
-							<em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em>&nbsp;&nbsp;
635
-							<code><?php echo date_i18n( $date_format_php, time() ); ?></code>
634
+							<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
635
+							<code><?php echo date_i18n($date_format_php, time()); ?></code>
636 636
 						</p>
637 637
 					</div>
638 638
 				</td>
639 639
 			</tr>
640 640
 			<tr class="simcal-panel-field">
641
-				<th><label for="_calendar_datetime_separator"><?php _e( 'Separator', 'google-calendar-events' ); ?></label></th>
641
+				<th><label for="_calendar_datetime_separator"><?php _e('Separator', 'google-calendar-events'); ?></label></th>
642 642
 				<td>
643 643
 					<?php
644 644
 
645
-					$separator = get_post_meta( $post->ID, '_calendar_datetime_separator', true );
645
+					$separator = get_post_meta($post->ID, '_calendar_datetime_separator', true);
646 646
 					$separator = false == $separator ? '@' : $separator;
647 647
 
648
-					simcal_print_field( array(
648
+					simcal_print_field(array(
649 649
 						'type'    => 'standard',
650 650
 						'subtype' => 'text',
651 651
 						'name'    => '_calendar_datetime_separator',
652 652
 						'id'      => '_calendar_datetime_separator',
653 653
 						'value'   => $separator,
654
-						'tooltip' => __( 'Used to divide date and time when both are shown.', 'google-calendar-events' ),
654
+						'tooltip' => __('Used to divide date and time when both are shown.', 'google-calendar-events'),
655 655
 						'class'   => array(
656 656
 							'simcal-field-tiny',
657 657
 						),
658
-					) );
658
+					));
659 659
 
660 660
 					?>
661 661
 				</td>
662 662
 			</tr>
663 663
 			<tr class="simcal-panel-field">
664
-				<th><label for="_calendar_time_format_setting"><?php _e( 'Time Format', 'google-calendar-events' ); ?></label></th>
664
+				<th><label for="_calendar_time_format_setting"><?php _e('Time Format', 'google-calendar-events'); ?></label></th>
665 665
 				<td>
666 666
 					<?php
667 667
 
668
-					$time_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_setting', true ) );
669
-					$time_format_default = esc_attr( get_option( 'time_format' ) );
670
-					$time_format = esc_attr( get_post_meta( $post->ID, '_calendar_time_format', true ) );
671
-					$time_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_php', true ) );
668
+					$time_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_time_format_setting', true));
669
+					$time_format_default = esc_attr(get_option('time_format'));
670
+					$time_format = esc_attr(get_post_meta($post->ID, '_calendar_time_format', true));
671
+					$time_format_php = esc_attr(get_post_meta($post->ID, '_calendar_time_format_php', true));
672 672
 					$time_format_php = $time_format_php ? $time_format_php : $time_format_default;
673 673
 
674 674
 					?>
675 675
 					<select name="_calendar_time_format_setting"
676 676
 							id="_calendar_time_format_setting"
677 677
 							class="simcal-field simcal-field-select simcal-field-show-other">
678
-						<option value="use_site" data-show-field="_calendar_time_format_default" <?php selected( 'use_site', $time_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option>
679
-						<option value="use_custom" data-show-field="_calendar_time_format" <?php selected( 'use_custom', $time_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option>
680
-						<option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected( 'use_custom_php', $time_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option>
678
+						<option value="use_site" data-show-field="_calendar_time_format_default" <?php selected('use_site', $time_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option>
679
+						<option value="use_custom" data-show-field="_calendar_time_format" <?php selected('use_custom', $time_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option>
680
+						<option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected('use_custom_php', $time_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option>
681 681
 					</select>
682
-					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i>
682
+					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i>
683 683
 					<p id="_calendar_time_format_default" style="<?php echo $time_format_setting != 'use_site' ? 'display: none;' : ''; ?>">
684
-						<em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em>&nbsp;&nbsp;
685
-						<code><?php echo date_i18n( $time_format_default, time() ); ?></code>
684
+						<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
685
+						<code><?php echo date_i18n($time_format_default, time()); ?></code>
686 686
 					</p>
687
-					<?php simcal_print_field( array(
687
+					<?php simcal_print_field(array(
688 688
 						'type'    => 'datetime-format',
689 689
 						'subtype' => 'time',
690 690
 						'name'    => '_calendar_time_format',
691 691
 						'id'      => '_calendar_time_format',
692 692
 						'value'   => $time_format,
693
-						'style'   => $time_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '',
694
-					) ); ?>
693
+						'style'   => $time_format_setting != 'use_custom' ? array('display' => 'none') : '',
694
+					)); ?>
695 695
 					<div class="simcal-field-datetime-format-php" id="_calendar_time_format_php_field" style="<?php echo $time_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>">
696 696
 						<br>
697 697
 						<label for="_calendar_date_format_php">
@@ -700,24 +700,24 @@  discard block
 block discarded – undo
700 700
 								   id="_calendar_time_format_php"
701 701
 								   class="simcal-field simcal-field-text simcal-field-small"
702 702
 								   value="<?php echo $time_format_php; ?>"/>
703
-							<?php printf( __( 'Enter a time format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?>
703
+							<?php printf(__('Enter a time format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?>
704 704
 						</label>
705 705
 						<p>
706
-							<em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em>&nbsp;&nbsp;
707
-							<code><?php echo date_i18n( $time_format_php, time() ); ?></code>
706
+							<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
707
+							<code><?php echo date_i18n($time_format_php, time()); ?></code>
708 708
 						</p>
709 709
 					</div>
710 710
 				</td>
711 711
 			</tr>
712 712
 			<tr class="simcal-panel-field">
713
-				<th><label for="_calendar_week_starts_on_setting"><?php _e( 'Week Starts On', 'google-calendar-events' ); ?></label></th>
713
+				<th><label for="_calendar_week_starts_on_setting"><?php _e('Week Starts On', 'google-calendar-events'); ?></label></th>
714 714
 				<td>
715 715
 					<?php
716 716
 
717
-					$week_starts_setting = esc_attr( get_post_meta( $post->ID, '_calendar_week_starts_on_setting', true ) );
718
-					$week_starts_default = esc_attr( get_option( 'start_of_week' ) );
719
-					$week_starts = intval( get_post_meta( $post->ID, '_calendar_week_starts_on', true ) );
720
-					$week_starts = is_numeric( $week_starts ) ? strval( $week_starts ) : $week_starts_default;
717
+					$week_starts_setting = esc_attr(get_post_meta($post->ID, '_calendar_week_starts_on_setting', true));
718
+					$week_starts_default = esc_attr(get_option('start_of_week'));
719
+					$week_starts = intval(get_post_meta($post->ID, '_calendar_week_starts_on', true));
720
+					$week_starts = is_numeric($week_starts) ? strval($week_starts) : $week_starts_default;
721 721
 
722 722
 					?>
723 723
 					<select
@@ -725,40 +725,40 @@  discard block
 block discarded – undo
725 725
 						id="_calendar_week_starts_on_setting"
726 726
 						class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next"
727 727
 						data-show-next-if-value="use_custom">
728
-						<option value="use_site" <?php selected( 'use_site', $week_starts_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', date_i18n( 'l', strtotime( "Sunday + $week_starts_default Days" ) ) ); ?></option>
729
-						<option value="use_custom" <?php selected( 'use_custom', $week_starts_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option>
728
+						<option value="use_site" <?php selected('use_site', $week_starts_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', date_i18n('l', strtotime("Sunday + $week_starts_default Days"))); ?></option>
729
+						<option value="use_custom" <?php selected('use_custom', $week_starts_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option>
730 730
 					</select>
731 731
 					<select
732 732
 						name="_calendar_week_starts_on"
733 733
 						id="_calendar_week_starts_on"
734 734
 						class="simcal-field simcal-field-select simcal-field-inline"
735 735
 						<?php echo 'use_custom' != $week_starts_setting ? 'style="display: none;"' : ''; ?>>
736
-						<?php $day_names = simcal_get_calendar_names_i18n( 'day', 'full' ); ?>
737
-						<?php for ( $i = 0; $i <= 6; $i++ ) : ?>
738
-							<option value="<?php echo $i; ?>" <?php selected( $i, $week_starts, true ); ?>><?php echo $day_names[ $i ]; ?></option>
736
+						<?php $day_names = simcal_get_calendar_names_i18n('day', 'full'); ?>
737
+						<?php for ($i = 0; $i <= 6; $i++) : ?>
738
+							<option value="<?php echo $i; ?>" <?php selected($i, $week_starts, true); ?>><?php echo $day_names[$i]; ?></option>
739 739
 						<?php endfor; ?>
740 740
 					</select>
741
-					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events' ); ?>"></i>
741
+					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events'); ?>"></i>
742 742
 				</td>
743 743
 			</tr>
744 744
 			</tbody>
745 745
 		</table>
746 746
 		<table>
747 747
 			<thead>
748
-			<tr><th colspan="2"><?php _e( 'Cache', 'google-calendar-events' ); ?></th></tr>
748
+			<tr><th colspan="2"><?php _e('Cache', 'google-calendar-events'); ?></th></tr>
749 749
 			</thead>
750 750
 			<tbody class="simcal-panel-section simcal-panel-section-cache">
751 751
 			<?php
752 752
 
753
-			$cache_freq = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_amount', true ) );
754
-			$cache_unit = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_unit', true ) );
753
+			$cache_freq = esc_attr(get_post_meta($post->ID, '_feed_cache_user_amount', true));
754
+			$cache_unit = esc_attr(get_post_meta($post->ID, '_feed_cache_user_unit', true));
755 755
 
756
-			$cache_freq = intval( $cache_freq ) && $cache_freq >= 0 ? $cache_freq : 2;
756
+			$cache_freq = intval($cache_freq) && $cache_freq >= 0 ? $cache_freq : 2;
757 757
 			$cache_unit = $cache_unit ? $cache_unit : '3600';
758 758
 
759 759
 			?>
760 760
 			<tr class="simcal-panel-field">
761
-				<th><label for="_feed_cache_user_amount"><?php _ex( 'Refresh Interval', 'Cache maximum interval', 'google-calendar-events' ); ?></label></th>
761
+				<th><label for="_feed_cache_user_amount"><?php _ex('Refresh Interval', 'Cache maximum interval', 'google-calendar-events'); ?></label></th>
762 762
 				<td>
763 763
 					<input type="number"
764 764
 						   name="_feed_cache_user_amount"
@@ -769,12 +769,12 @@  discard block
 block discarded – undo
769 769
 					<select name="_feed_cache_user_unit"
770 770
 							id="_feed_cache_user_unit"
771 771
 							class="simcal-field simcalfield-select simcal-field-inline">
772
-						<option value="60" <?php selected( '60', $cache_unit, true ); ?>><?php _e( 'Minute(s)', 'google-calendar-events' ); ?></option>
773
-						<option value="3600" <?php selected( '3600', $cache_unit, true ); ?>><?php _e( 'Hour(s)', 'google-calendar-events' ); ?></option>
774
-						<option value="86400" <?php selected( '86400', $cache_unit, true ); ?>><?php _e( 'Day(s)', 'google-calendar-events' ); ?></option>
775
-						<option value="604800" <?php selected( '604800', $cache_unit, true ); ?>><?php _e( 'Week(s)', 'google-calendar-events' ); ?></option>
772
+						<option value="60" <?php selected('60', $cache_unit, true); ?>><?php _e('Minute(s)', 'google-calendar-events'); ?></option>
773
+						<option value="3600" <?php selected('3600', $cache_unit, true); ?>><?php _e('Hour(s)', 'google-calendar-events'); ?></option>
774
+						<option value="86400" <?php selected('86400', $cache_unit, true); ?>><?php _e('Day(s)', 'google-calendar-events'); ?></option>
775
+						<option value="604800" <?php selected('604800', $cache_unit, true); ?>><?php _e('Week(s)', 'google-calendar-events'); ?></option>
776 776
 					</select>
777
-					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events' ); ?>"></i>
777
+					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events'); ?>"></i>
778 778
 				</td>
779 779
 			</tr>
780 780
 			</tbody>
@@ -793,21 +793,21 @@  discard block
 block discarded – undo
793 793
 	 *
794 794
 	 * @return void
795 795
 	 */
796
-	public static function print_panel_fields( $array, $post_id ) {
796
+	public static function print_panel_fields($array, $post_id) {
797 797
 
798
-		foreach ( $array as $section => $fields ) :
798
+		foreach ($array as $section => $fields) :
799 799
 
800
-			if ( $fields && is_array( $fields ) ) :
800
+			if ($fields && is_array($fields)) :
801 801
 
802 802
 				?>
803
-				<tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr( $section ); ?>">
804
-				<?php foreach ( $fields as $key => $field ) :
803
+				<tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr($section); ?>">
804
+				<?php foreach ($fields as $key => $field) :
805 805
 
806
-					$value            = get_post_meta( $post_id, $key, true );
807
-					$field['value']   = $value ? $value : ( isset( $field['default'] ) ? $field['default'] : '' );
808
-					$the_field = simcal_get_field( $field ); ?>
806
+					$value            = get_post_meta($post_id, $key, true);
807
+					$field['value']   = $value ? $value : (isset($field['default']) ? $field['default'] : '');
808
+					$the_field = simcal_get_field($field); ?>
809 809
 
810
-					<?php if ( $the_field instanceof Field ) : ?>
810
+					<?php if ($the_field instanceof Field) : ?>
811 811
 					<tr class="simcal-panel-field">
812 812
 						<th><label for="<?php echo $the_field->id ?>"><?php echo $the_field->title; ?></label></th>
813 813
 						<td><?php $the_field->html(); ?></td>
@@ -834,30 +834,30 @@  discard block
 block discarded – undo
834 834
 	 *
835 835
 	 * @return void
836 836
 	 */
837
-	public static function save( $post_id, $post ) {
837
+	public static function save($post_id, $post) {
838 838
 
839 839
 		/* ====================== *
840 840
 		 * Calendar type and view *
841 841
 		 * ====================== */
842 842
 
843 843
 		// Unlink existing terms for feed type and calendar type.
844
-		wp_delete_object_term_relationships( $post_id, array(
844
+		wp_delete_object_term_relationships($post_id, array(
845 845
 			'calendar_feed',
846 846
 			'calendar_type',
847
-		) );
847
+		));
848 848
 
849 849
 		// Set the feed type as term.
850
-		$feed_type = isset( $_POST['_feed_type'] ) ? sanitize_title( stripslashes( $_POST['_feed_type'] ) ) : apply_filters( 'simcal_default_feed_type', 'google' );
851
-		wp_set_object_terms( $post_id, $feed_type, 'calendar_feed' );
850
+		$feed_type = isset($_POST['_feed_type']) ? sanitize_title(stripslashes($_POST['_feed_type'])) : apply_filters('simcal_default_feed_type', 'google');
851
+		wp_set_object_terms($post_id, $feed_type, 'calendar_feed');
852 852
 
853 853
 		// Set the calendar type as a term.
854
-		$calendar_type = isset( $_POST['_calendar_type'] ) ? sanitize_title( stripslashes( $_POST['_calendar_type'] ) ) : apply_filters( 'simcal_default_calendar_type', 'default-calendar' );
855
-		wp_set_object_terms( $post_id, $calendar_type, 'calendar_type' );
854
+		$calendar_type = isset($_POST['_calendar_type']) ? sanitize_title(stripslashes($_POST['_calendar_type'])) : apply_filters('simcal_default_calendar_type', 'default-calendar');
855
+		wp_set_object_terms($post_id, $calendar_type, 'calendar_type');
856 856
 		// Set the calendar type view as post meta.
857
-		$calendar_view = isset( $_POST['_calendar_view'] ) ? $_POST['_calendar_view'] : '';
858
-		if ( $calendar_view && is_array( $calendar_view ) ) {
859
-			$views = array_map( 'sanitize_title', $calendar_view );
860
-			update_post_meta( $post_id, '_calendar_view', $views );
857
+		$calendar_view = isset($_POST['_calendar_view']) ? $_POST['_calendar_view'] : '';
858
+		if ($calendar_view && is_array($calendar_view)) {
859
+			$views = array_map('sanitize_title', $calendar_view);
860
+			update_post_meta($post_id, '_calendar_view', $views);
861 861
 		}
862 862
 
863 863
 		/* ===================== *
@@ -865,106 +865,106 @@  discard block
 block discarded – undo
865 865
 		 * ===================== */
866 866
 
867 867
 		// Calendar opening.
868
-		$calendar_begins = isset( $_POST['_calendar_begins'] ) ? sanitize_key( $_POST['_calendar_begins'] ) : 'this_month';
869
-		update_post_meta( $post_id, '_calendar_begins', $calendar_begins );
870
-		$calendar_begins_nth = isset( $_POST['_calendar_begins_nth'] ) ? absint( $_POST['_calendar_begins_nth'] ) : 2;
871
-		update_post_meta( $post_id, '_calendar_begins_nth', $calendar_begins_nth );
872
-		$calendar_begins_custom_date = isset( $_POST['_calendar_begins_custom_date'] ) ? sanitize_title( $_POST['_calendar_begins_custom_date'] ) : '';
873
-		update_post_meta( $post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date );
868
+		$calendar_begins = isset($_POST['_calendar_begins']) ? sanitize_key($_POST['_calendar_begins']) : 'this_month';
869
+		update_post_meta($post_id, '_calendar_begins', $calendar_begins);
870
+		$calendar_begins_nth = isset($_POST['_calendar_begins_nth']) ? absint($_POST['_calendar_begins_nth']) : 2;
871
+		update_post_meta($post_id, '_calendar_begins_nth', $calendar_begins_nth);
872
+		$calendar_begins_custom_date = isset($_POST['_calendar_begins_custom_date']) ? sanitize_title($_POST['_calendar_begins_custom_date']) : '';
873
+		update_post_meta($post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date);
874 874
 
875 875
 		// Feed earliest events date.
876
-		$earliest_events = isset( $_POST['_feed_earliest_event_date'] ) ? sanitize_key( $_POST['_feed_earliest_event_date'] ) : '';
877
-		update_post_meta( $post_id, '_feed_earliest_event_date', $earliest_events );
878
-		$earliest_events_range = isset( $_POST['_feed_earliest_event_date_range'] ) ? max( absint( $_POST['_feed_earliest_event_date_range'] ), 1 ) : 1;
879
-		update_post_meta( $post_id, '_feed_earliest_event_date_range', $earliest_events_range );
876
+		$earliest_events = isset($_POST['_feed_earliest_event_date']) ? sanitize_key($_POST['_feed_earliest_event_date']) : '';
877
+		update_post_meta($post_id, '_feed_earliest_event_date', $earliest_events);
878
+		$earliest_events_range = isset($_POST['_feed_earliest_event_date_range']) ? max(absint($_POST['_feed_earliest_event_date_range']), 1) : 1;
879
+		update_post_meta($post_id, '_feed_earliest_event_date_range', $earliest_events_range);
880 880
 
881 881
 		// Feed latest events date.
882
-		$latest_events = isset( $_POST['_feed_latest_event_date'] ) ? sanitize_key( $_POST['_feed_latest_event_date'] ) : '';
883
-		update_post_meta( $post_id, '_feed_latest_event_date', $latest_events );
884
-		$latest_events_range = isset( $_POST['_feed_latest_event_date_range'] ) ? max( absint( $_POST['_feed_latest_event_date_range'] ), 1 ) : 1;
885
-		update_post_meta( $post_id, '_feed_latest_event_date_range', $latest_events_range );
882
+		$latest_events = isset($_POST['_feed_latest_event_date']) ? sanitize_key($_POST['_feed_latest_event_date']) : '';
883
+		update_post_meta($post_id, '_feed_latest_event_date', $latest_events);
884
+		$latest_events_range = isset($_POST['_feed_latest_event_date_range']) ? max(absint($_POST['_feed_latest_event_date_range']), 1) : 1;
885
+		update_post_meta($post_id, '_feed_latest_event_date_range', $latest_events_range);
886 886
 
887 887
 		/* ======================= *
888 888
 		 * Calendar settings panel *
889 889
 		 * ======================= */
890 890
 
891 891
 		// Static calendar.
892
-		$static = isset( $_POST['_calendar_is_static'] ) ? 'yes' : 'no';
893
-		update_post_meta( $post_id, '_calendar_is_static', $static );
892
+		$static = isset($_POST['_calendar_is_static']) ? 'yes' : 'no';
893
+		update_post_meta($post_id, '_calendar_is_static', $static);
894 894
 
895 895
 		// No events message.
896
-		$message = isset( $_POST['_no_events_message'] ) ? wp_kses_post( $_POST['_no_events_message'] ) : '';
897
-		update_post_meta( $post_id, '_no_events_message', $message );
896
+		$message = isset($_POST['_no_events_message']) ? wp_kses_post($_POST['_no_events_message']) : '';
897
+		update_post_meta($post_id, '_no_events_message', $message);
898 898
 
899 899
 		// _event_formatting
900
-		$event_formatting = isset( $_POST['_event_formatting'] ) ? sanitize_key( $_POST['_event_formatting'] ) : 'preserve_linebreaks';
901
-		update_post_meta( $post_id, '_event_formatting', $event_formatting );
900
+		$event_formatting = isset($_POST['_event_formatting']) ? sanitize_key($_POST['_event_formatting']) : 'preserve_linebreaks';
901
+		update_post_meta($post_id, '_event_formatting', $event_formatting);
902 902
 
903 903
 		// Powered by option
904
-		$poweredby = isset( $_POST['_poweredby'] ) ? 'yes' : 'no';
905
-		update_post_meta( $post_id, '_poweredby', $poweredby );
904
+		$poweredby = isset($_POST['_poweredby']) ? 'yes' : 'no';
905
+		update_post_meta($post_id, '_poweredby', $poweredby);
906 906
 
907 907
 		/* ======================= *
908 908
 		 * Advanced settings panel *
909 909
 		 * ======================= */
910 910
 
911 911
 		// Timezone.
912
-		$feed_timezone_setting = isset( $_POST['_feed_timezone_setting'] ) ? sanitize_key( $_POST['_feed_timezone_setting'] ) : 'use_calendar';
913
-		update_post_meta( $post_id, '_feed_timezone_setting', $feed_timezone_setting );
912
+		$feed_timezone_setting = isset($_POST['_feed_timezone_setting']) ? sanitize_key($_POST['_feed_timezone_setting']) : 'use_calendar';
913
+		update_post_meta($post_id, '_feed_timezone_setting', $feed_timezone_setting);
914 914
 		$default_timezone = simcal_get_wp_timezone();
915 915
 		$feed_timezone = $default_timezone ? $default_timezone : 'UTC';
916
-		$feed_timezone = isset( $_POST['_feed_timezone'] ) ? sanitize_text_field( $_POST['_feed_timezone'] ) : $feed_timezone;
917
-		update_post_meta( $post_id, '_feed_timezone', $feed_timezone );
916
+		$feed_timezone = isset($_POST['_feed_timezone']) ? sanitize_text_field($_POST['_feed_timezone']) : $feed_timezone;
917
+		update_post_meta($post_id, '_feed_timezone', $feed_timezone);
918 918
 
919 919
 		// Date format.
920
-		$date_format_setting = isset( $_POST['_calendar_date_format_setting'] ) ? sanitize_key( $_POST['_calendar_date_format_setting'] ) : 'use_site';
921
-		update_post_meta( $post_id, '_calendar_date_format_setting', $date_format_setting );
922
-		$date_format = isset( $_POST['_calendar_date_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format'] ) ) : get_option( 'date_format' );
923
-		update_post_meta( $post_id, '_calendar_date_format', $date_format );
924
-		$date_format_php = isset( $_POST['_calendar_date_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format_php'] ) ) : get_option( 'date_format' );
925
-		update_post_meta( $post_id, '_calendar_date_format_php', $date_format_php );
920
+		$date_format_setting = isset($_POST['_calendar_date_format_setting']) ? sanitize_key($_POST['_calendar_date_format_setting']) : 'use_site';
921
+		update_post_meta($post_id, '_calendar_date_format_setting', $date_format_setting);
922
+		$date_format = isset($_POST['_calendar_date_format']) ? sanitize_text_field(trim($_POST['_calendar_date_format'])) : get_option('date_format');
923
+		update_post_meta($post_id, '_calendar_date_format', $date_format);
924
+		$date_format_php = isset($_POST['_calendar_date_format_php']) ? sanitize_text_field(trim($_POST['_calendar_date_format_php'])) : get_option('date_format');
925
+		update_post_meta($post_id, '_calendar_date_format_php', $date_format_php);
926 926
 
927 927
 		// Time format.
928
-		$time_format_setting = isset( $_POST['_calendar_time_format_setting'] ) ? sanitize_key( $_POST['_calendar_time_format_setting'] ) : 'use_site';
929
-		update_post_meta( $post_id, '_calendar_time_format_setting', $time_format_setting );
930
-		$time_format = isset( $_POST['_calendar_time_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format'] ) ) : get_option( 'time_format' );
931
-		update_post_meta( $post_id, '_calendar_time_format', $time_format );
932
-		$time_format_php = isset( $_POST['_calendar_time_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format_php'] ) ) : get_option( 'time_format' );
933
-		update_post_meta( $post_id, '_calendar_time_format_php', $time_format_php );
928
+		$time_format_setting = isset($_POST['_calendar_time_format_setting']) ? sanitize_key($_POST['_calendar_time_format_setting']) : 'use_site';
929
+		update_post_meta($post_id, '_calendar_time_format_setting', $time_format_setting);
930
+		$time_format = isset($_POST['_calendar_time_format']) ? sanitize_text_field(trim($_POST['_calendar_time_format'])) : get_option('time_format');
931
+		update_post_meta($post_id, '_calendar_time_format', $time_format);
932
+		$time_format_php = isset($_POST['_calendar_time_format_php']) ? sanitize_text_field(trim($_POST['_calendar_time_format_php'])) : get_option('time_format');
933
+		update_post_meta($post_id, '_calendar_time_format_php', $time_format_php);
934 934
 
935 935
 		// Date-time separator.
936
-		$datetime_separator = isset( $_POST['_calendar_datetime_separator'] ) ? sanitize_text_field( $_POST['_calendar_datetime_separator'] ) : ' ';
937
-		update_post_meta( $post_id, '_calendar_datetime_separator', $datetime_separator );
936
+		$datetime_separator = isset($_POST['_calendar_datetime_separator']) ? sanitize_text_field($_POST['_calendar_datetime_separator']) : ' ';
937
+		update_post_meta($post_id, '_calendar_datetime_separator', $datetime_separator);
938 938
 
939 939
 		// Week start.
940
-		$week_start_setting = isset( $_POST['_calendar_week_starts_on_setting'] ) ? sanitize_key( $_POST['_calendar_week_starts_on_setting'] ) : 'use_site';
941
-		update_post_meta( $post_id, '_calendar_week_starts_on_setting', $week_start_setting );
942
-		$week_start = isset( $_POST['_calendar_week_starts_on'] ) ? intval( $_POST['_calendar_week_starts_on'] ) : get_option( 'start_of_week' );
943
-		update_post_meta( $post_id, '_calendar_week_starts_on', $week_start );
940
+		$week_start_setting = isset($_POST['_calendar_week_starts_on_setting']) ? sanitize_key($_POST['_calendar_week_starts_on_setting']) : 'use_site';
941
+		update_post_meta($post_id, '_calendar_week_starts_on_setting', $week_start_setting);
942
+		$week_start = isset($_POST['_calendar_week_starts_on']) ? intval($_POST['_calendar_week_starts_on']) : get_option('start_of_week');
943
+		update_post_meta($post_id, '_calendar_week_starts_on', $week_start);
944 944
 
945 945
 		// Cache interval.
946 946
 		$cache = 7200;
947
-		if ( isset( $_POST['_feed_cache_user_amount'] ) && isset( $_POST['_feed_cache_user_unit'] ) ) {
948
-			$amount = is_numeric( $_POST['_feed_cache_user_amount'] ) || $_POST['_feed_cache_user_amount'] == 0 ? absint( $_POST['_feed_cache_user_amount'] ) : 1;
949
-			$unit   = is_numeric( $_POST['_feed_cache_user_unit'] ) ? absint( $_POST['_feed_cache_user_unit'] ) : 3600;
950
-			update_post_meta( $post_id, '_feed_cache_user_amount', $amount );
951
-			update_post_meta( $post_id, '_feed_cache_user_unit', $unit );
952
-			$cache  = ( ( $amount * $unit ) > 0 ) ? $amount * $unit : 1;
947
+		if (isset($_POST['_feed_cache_user_amount']) && isset($_POST['_feed_cache_user_unit'])) {
948
+			$amount = is_numeric($_POST['_feed_cache_user_amount']) || $_POST['_feed_cache_user_amount'] == 0 ? absint($_POST['_feed_cache_user_amount']) : 1;
949
+			$unit   = is_numeric($_POST['_feed_cache_user_unit']) ? absint($_POST['_feed_cache_user_unit']) : 3600;
950
+			update_post_meta($post_id, '_feed_cache_user_amount', $amount);
951
+			update_post_meta($post_id, '_feed_cache_user_unit', $unit);
952
+			$cache  = (($amount * $unit) > 0) ? $amount * $unit : 1;
953 953
 		}
954
-		update_post_meta( $post_id, '_feed_cache', $cache );
954
+		update_post_meta($post_id, '_feed_cache', $cache);
955 955
 
956 956
 		/* ============= *
957 957
 		 * Miscellaneous *
958 958
 		 * ============= */
959 959
 
960 960
 		// Update version.
961
-		update_post_meta( $post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION );
961
+		update_post_meta($post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION);
962 962
 
963 963
 		// Action hook.
964
-		do_action( 'simcal_process_settings_meta', $post_id );
964
+		do_action('simcal_process_settings_meta', $post_id);
965 965
 
966 966
 		// Clear cache.
967
-		simcal_delete_feed_transients( $post_id );
967
+		simcal_delete_feed_transients($post_id);
968 968
 	}
969 969
 
970 970
 }
Please login to merge, or discard this patch.
includes/admin/pages/system-status.php 1 patch
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use SimpleCalendar\Abstracts\Admin_Page;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 
31 31
 		$this->id           = $tab = 'system-status';
32 32
 		$this->option_group = $page = 'tools';
33
-		$this->label        = __( 'System Report', 'google-calendar-events' );
33
+		$this->label        = __('System Report', 'google-calendar-events');
34 34
 		$this->description  = '';
35 35
 		$this->sections     = $this->add_sections();
36 36
 		$this->fields       = $this->add_fields();
37 37
 
38 38
 		// Disable the submit button for this page.
39
-		add_filter( 'simcal_admin_page_' . $page . '_' . $tab . '_submit', function() { return false; } );
39
+		add_filter('simcal_admin_page_'.$page.'_'.$tab.'_submit', function() { return false; } );
40 40
 
41 41
 		// Add html.
42
-		add_action( 'simcal_admin_page_' . $page . '_' . $tab . '_end', array( $this, 'html' ) );
42
+		add_action('simcal_admin_page_'.$page.'_'.$tab.'_end', array($this, 'html'));
43 43
 	}
44 44
 
45 45
 	/**
@@ -51,37 +51,37 @@  discard block
 block discarded – undo
51 51
 
52 52
 		?>
53 53
 		<div id="simcal-system-status-report">
54
-			<p><?php _e( 'Please copy and paste this information when contacting support:', 'google-calendar-events' ); ?> </p>
54
+			<p><?php _e('Please copy and paste this information when contacting support:', 'google-calendar-events'); ?> </p>
55 55
 			<textarea readonly="readonly" onclick="this.select();"></textarea>
56
-			<p><?php _e( 'You can also download your information as a text file to attach, or simply view it below.', 'google-calendar-events' ); ?></p>
57
-			<p><a href="#" id="simcal-system-status-report-download" class="button button-primary"><?php _e( 'Download System Report', 'google-calendar-events' ); ?></a></p>
56
+			<p><?php _e('You can also download your information as a text file to attach, or simply view it below.', 'google-calendar-events'); ?></p>
57
+			<p><a href="#" id="simcal-system-status-report-download" class="button button-primary"><?php _e('Download System Report', 'google-calendar-events'); ?></a></p>
58 58
 		</div>
59 59
 		<hr>
60 60
 		<?php
61 61
 
62 62
 		global $wpdb;
63
-		$wp_version = get_bloginfo( 'version' );
63
+		$wp_version = get_bloginfo('version');
64 64
 
65 65
 		$sections = array();
66 66
 		$panels   = array(
67 67
 			'wordpress' => array(
68
-				'label'  => __( 'WordPress Installation', 'google-calendar-events' ),
68
+				'label'  => __('WordPress Installation', 'google-calendar-events'),
69 69
 				'export' => 'WordPress Installation',
70 70
 			),
71 71
 			'theme'     => array(
72
-				'label'  => __( 'Active Theme', 'google-calendar-events' ),
72
+				'label'  => __('Active Theme', 'google-calendar-events'),
73 73
 				'export' => 'Active Theme',
74 74
 			),
75 75
 			'plugins'   => array(
76
-				'label'  => __( 'Active Plugins', 'google-calendar-events' ),
76
+				'label'  => __('Active Plugins', 'google-calendar-events'),
77 77
 				'export' => 'Active Plugins',
78 78
 			),
79 79
 			'server'    => array(
80
-				'label'  => __( 'Server Environment', 'google-calendar-events' ),
80
+				'label'  => __('Server Environment', 'google-calendar-events'),
81 81
 				'export' => 'Server Environment',
82 82
 			),
83 83
 			'client'    => array(
84
-				'label'  => __( 'Client Information', 'google-calendar-events' ),
84
+				'label'  => __('Client Information', 'google-calendar-events'),
85 85
 				'export' => 'Client Information',
86 86
 			)
87 87
 		);
@@ -98,68 +98,68 @@  discard block
 block discarded – undo
98 98
 		 * ======================
99 99
 		 */
100 100
 
101
-		$debug_mode = $script_debug = __( 'No', 'google-calendar-events' );
102
-		if ( defined( 'WP_DEBUG' ) ) {
103
-			$debug_mode = true === WP_DEBUG ? __( 'Yes', 'google-calendar-events' ) : $debug_mode;
101
+		$debug_mode = $script_debug = __('No', 'google-calendar-events');
102
+		if (defined('WP_DEBUG')) {
103
+			$debug_mode = true === WP_DEBUG ? __('Yes', 'google-calendar-events') : $debug_mode;
104 104
 		}
105
-		if ( defined( 'SCRIPT_DEBUG' ) ) {
106
-			$script_debug = true === SCRIPT_DEBUG ? __( 'Yes', 'google-calendar-events' ) : $script_debug;
105
+		if (defined('SCRIPT_DEBUG')) {
106
+			$script_debug = true === SCRIPT_DEBUG ? __('Yes', 'google-calendar-events') : $script_debug;
107 107
 		}
108 108
 
109
-		$memory = $this->let_to_num( WP_MEMORY_LIMIT );
110
-		$memory_export = size_format( $memory );
111
-		if ( $memory < 67108864 ) {
112
-			$memory = '<mark class="error">' . sprintf( __( '%1$s - It is recomendend to set memory to at least 64MB. See: <a href="%2$s" target="_blank">Increasing memory allocated to PHP</a>', 'google-calendar-events' ), $memory_export, 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) . '</mark>';
109
+		$memory = $this->let_to_num(WP_MEMORY_LIMIT);
110
+		$memory_export = size_format($memory);
111
+		if ($memory < 67108864) {
112
+			$memory = '<mark class="error">'.sprintf(__('%1$s - It is recomendend to set memory to at least 64MB. See: <a href="%2$s" target="_blank">Increasing memory allocated to PHP</a>', 'google-calendar-events'), $memory_export, 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP').'</mark>';
113 113
 		} else {
114
-			$memory = '<mark class="ok">' . $memory_export . '</mark>';
114
+			$memory = '<mark class="ok">'.$memory_export.'</mark>';
115 115
 		}
116 116
 
117
-		$permalinks = get_option( 'permalink_structure' );
118
-		$permalinks = empty( $permalinks ) ? '/?' : $permalinks;
117
+		$permalinks = get_option('permalink_structure');
118
+		$permalinks = empty($permalinks) ? '/?' : $permalinks;
119 119
 
120 120
 		$is_multisite = is_multisite();
121 121
 
122 122
 		$sections['wordpress'] = array(
123 123
 			'name'          => array(
124
-				'label'  => __( 'Site Name', 'google-calendar-events' ),
124
+				'label'  => __('Site Name', 'google-calendar-events'),
125 125
 				'label_export' => 'Site Name',
126
-				'result' => get_bloginfo( 'name' ),
126
+				'result' => get_bloginfo('name'),
127 127
 			),
128 128
 			'home_url'      => array(
129
-				'label'  => __( 'Home URL', 'google-calendar-events' ),
129
+				'label'  => __('Home URL', 'google-calendar-events'),
130 130
 				'label_export' => 'Home URL',
131 131
 				'result' => home_url(),
132 132
 			),
133 133
 			'site_url'      => array(
134
-				'label'  => __( 'Site URL', 'google-calendar-events' ),
134
+				'label'  => __('Site URL', 'google-calendar-events'),
135 135
 				'label_export' => 'Site URL',
136 136
 				'result' => site_url(),
137 137
 			),
138 138
 			'version'       => array(
139
-				'label'  => __( 'Version', 'google-calendar-events' ),
139
+				'label'  => __('Version', 'google-calendar-events'),
140 140
 				'label_export' => 'Version',
141 141
 				'result' => $wp_version,
142 142
 			),
143 143
 			'locale'        => array(
144
-				'label'  => __( 'Locale', 'google-calendar-events' ),
144
+				'label'  => __('Locale', 'google-calendar-events'),
145 145
 				'label_export' => 'Locale',
146 146
 				'result' => get_locale(),
147 147
 			),
148 148
 			'wp_timezone'   => array(
149
-				'label'  => __( 'Timezone', 'google-calendar-events' ),
149
+				'label'  => __('Timezone', 'google-calendar-events'),
150 150
 				'label_export' => 'Timezone',
151 151
 				'result' => simcal_get_wp_timezone(),
152 152
 			),
153 153
 			'multisite'     => array(
154
-				'label'  => __( 'Multisite', 'google-calendar-events' ),
154
+				'label'  => __('Multisite', 'google-calendar-events'),
155 155
 				'label_export' => 'Multisite',
156
-				'result' => $is_multisite ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ),
156
+				'result' => $is_multisite ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'),
157 157
 				'result_export' => $is_multisite ? 'Yes' : 'No'
158 158
 			),
159 159
 			'permalink'     => array(
160
-				'label'  => __( 'Permalinks', 'google-calendar-events' ),
160
+				'label'  => __('Permalinks', 'google-calendar-events'),
161 161
 				'label_export' => 'Permalinks',
162
-				'result' => '<code>' . $permalinks . '</code>',
162
+				'result' => '<code>'.$permalinks.'</code>',
163 163
 				'result_export' => $permalinks,
164 164
 			),
165 165
 			'memory_limit'  => array(
@@ -182,86 +182,86 @@  discard block
 block discarded – undo
182 182
 		 * ============
183 183
 		 */
184 184
 
185
-		include_once ABSPATH . 'wp-admin/includes/theme-install.php';
185
+		include_once ABSPATH.'wp-admin/includes/theme-install.php';
186 186
 
187
-		if ( version_compare( $wp_version, '3.4', '<' ) ) {
188
-			$active_theme  = get_theme_data( get_stylesheet_directory() . '/style.css' );
189
-			$theme_name    = '<a href="' . $active_theme['URI'] . '" target="_blank">' . $active_theme['Name'] . '</a>';
187
+		if (version_compare($wp_version, '3.4', '<')) {
188
+			$active_theme  = get_theme_data(get_stylesheet_directory().'/style.css');
189
+			$theme_name    = '<a href="'.$active_theme['URI'].'" target="_blank">'.$active_theme['Name'].'</a>';
190 190
 			$theme_version = $active_theme['Version'];
191
-			$theme_author  = '<a href="' . $active_theme['AuthorURI'] . '" target="_blank">' . $active_theme['Author'] . '</a>';
192
-			$theme_export  = $active_theme['Name'] . ' - ' . $theme_version;
191
+			$theme_author  = '<a href="'.$active_theme['AuthorURI'].'" target="_blank">'.$active_theme['Author'].'</a>';
192
+			$theme_export  = $active_theme['Name'].' - '.$theme_version;
193 193
 		} else {
194 194
 			$active_theme  = wp_get_theme();
195
-			$theme_name    = '<a href="' . $active_theme->ThemeURI . '" target="_blank">' . $active_theme->Name . '</a>';
195
+			$theme_name    = '<a href="'.$active_theme->ThemeURI.'" target="_blank">'.$active_theme->Name.'</a>';
196 196
 			$theme_version = $active_theme->Version;
197 197
 			$theme_author  = $active_theme->Author;
198
-			$theme_export  = $active_theme->Name . ' - ' . $theme_version;
198
+			$theme_export  = $active_theme->Name.' - '.$theme_version;
199 199
 		}
200 200
 
201 201
 		$theme_update_version = $theme_version;
202 202
 
203
-		$api = themes_api( 'theme_information', array(
203
+		$api = themes_api('theme_information', array(
204 204
 			'slug'   => get_template(),
205
-			'fields' => array( 'sections' => false, 'tags' => false ),
206
-		) );
207
-		if ( $api && ! is_wp_error( $api ) ) {
205
+			'fields' => array('sections' => false, 'tags' => false),
206
+		));
207
+		if ($api && ! is_wp_error($api)) {
208 208
 			$theme_update_version = $api->version;
209 209
 		}
210 210
 
211
-		if ( version_compare( $theme_version, $theme_update_version, '<' ) ) {
212
-			$theme_version = '<mark class="error">' . $theme_version . ' (' . sprintf( __( '%s is available', 'google-calendar-events' ), esc_html( $theme_update_version ) ) . ')</mark>';
211
+		if (version_compare($theme_version, $theme_update_version, '<')) {
212
+			$theme_version = '<mark class="error">'.$theme_version.' ('.sprintf(__('%s is available', 'google-calendar-events'), esc_html($theme_update_version)).')</mark>';
213 213
 		} else {
214
-			$theme_version = '<mark class="ok">' . $theme_version . '</mark>';
214
+			$theme_version = '<mark class="ok">'.$theme_version.'</mark>';
215 215
 		}
216 216
 
217 217
 		$theme  = '<dl>';
218
-		$theme .= '<dt>' . __( 'Name', 'google-calendar-events' ) . '</dt>';
219
-		$theme .= '<dd>' . $theme_name . '</dd>';
220
-		$theme .= '<dt>' . __( 'Author', 'google-calendar-events' ) . '</dt>';
221
-		$theme .= '<dd>' . $theme_author . '</dd>';
222
-		$theme .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>';
223
-		$theme .= '<dd>' . $theme_version . '</dd>';
218
+		$theme .= '<dt>'.__('Name', 'google-calendar-events').'</dt>';
219
+		$theme .= '<dd>'.$theme_name.'</dd>';
220
+		$theme .= '<dt>'.__('Author', 'google-calendar-events').'</dt>';
221
+		$theme .= '<dd>'.$theme_author.'</dd>';
222
+		$theme .= '<dt>'.__('Version', 'google-calendar-events').'</dt>';
223
+		$theme .= '<dd>'.$theme_version.'</dd>';
224 224
 		$theme .= '</dl>';
225 225
 
226 226
 		$is_child_theme = is_child_theme();
227 227
 		$parent_theme = $parent_theme_export = '-';
228 228
 
229
-		if ( $is_child_theme ) {
230
-			if ( version_compare( $wp_version, '3.4', '<' ) ) {
229
+		if ($is_child_theme) {
230
+			if (version_compare($wp_version, '3.4', '<')) {
231 231
 
232 232
 				$parent_theme = $parent_theme_export = $active_theme['Template'];
233 233
 
234 234
 			} else {
235 235
 
236
-				$parent = wp_get_theme( $active_theme->Template );
236
+				$parent = wp_get_theme($active_theme->Template);
237 237
 				$parent_theme  = '<dl>';
238
-				$parent_theme .= '<dt>' . __( 'Name', 'google-calendar-events' ) .    '</dt>';
239
-				$parent_theme .= '<dd>' . $parent->Name .          '</dd>';
240
-				$parent_theme .= '<dt>' . __( 'Author', 'google-calendar-events' ) .  '</dt>';
241
-				$parent_theme .= '<dd>' . $parent->Author .        '</dd>';
242
-				$parent_theme .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>';
243
-				$parent_theme .= '<dd>' . $parent->Version .       '</dd>';
238
+				$parent_theme .= '<dt>'.__('Name', 'google-calendar-events').'</dt>';
239
+				$parent_theme .= '<dd>'.$parent->Name.'</dd>';
240
+				$parent_theme .= '<dt>'.__('Author', 'google-calendar-events').'</dt>';
241
+				$parent_theme .= '<dd>'.$parent->Author.'</dd>';
242
+				$parent_theme .= '<dt>'.__('Version', 'google-calendar-events').'</dt>';
243
+				$parent_theme .= '<dd>'.$parent->Version.'</dd>';
244 244
 				$parent_theme .= '</dl>';
245 245
 
246
-				$parent_theme_export = strip_tags( $parent->Name ) . ' - ' .  $parent->Version;
246
+				$parent_theme_export = strip_tags($parent->Name).' - '.$parent->Version;
247 247
 			}
248 248
 		}
249 249
 
250 250
 		$sections['theme'] = array(
251 251
 			'theme'    => array(
252
-				'label'  => __( 'Theme Information', 'google-calendar-events' ),
252
+				'label'  => __('Theme Information', 'google-calendar-events'),
253 253
 				'label_export' => 'Theme',
254 254
 				'result' => $theme,
255 255
 				'result_export' => $theme_export,
256 256
 			),
257 257
 			'theme_child'   => array(
258
-				'label'  => __( 'Child Theme', 'google-calendar-events' ),
258
+				'label'  => __('Child Theme', 'google-calendar-events'),
259 259
 				'label_export' => 'Child Theme',
260
-				'result' => $is_child_theme ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ),
260
+				'result' => $is_child_theme ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'),
261 261
 				'result_export' => $is_child_theme ? 'Yes' : 'No',
262 262
 			),
263 263
 			'theme_parent'   => array(
264
-				'label'  => __( 'Parent Theme', 'google-calendar-events' ),
264
+				'label'  => __('Parent Theme', 'google-calendar-events'),
265 265
 				'label_export' => 'Parent Theme',
266 266
 				'result' => $parent_theme,
267 267
 				'result_export' => $parent_theme_export,
@@ -273,61 +273,61 @@  discard block
 block discarded – undo
273 273
 		 * ==============
274 274
 		 */
275 275
 
276
-		include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
276
+		include_once ABSPATH.'wp-admin/includes/plugin-install.php';
277 277
 
278
-		$active_plugins = (array) get_option( 'active_plugins', array() );
279
-		if ( is_multisite() ) {
280
-			$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
278
+		$active_plugins = (array) get_option('active_plugins', array());
279
+		if (is_multisite()) {
280
+			$active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
281 281
 		}
282 282
 
283
-		foreach ( $active_plugins as $plugin ) {
283
+		foreach ($active_plugins as $plugin) {
284 284
 
285
-			$plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
285
+			$plugin_data = @get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin);
286 286
 
287
-			if ( ! empty( $plugin_data['Name'] ) ) {
287
+			if ( ! empty($plugin_data['Name'])) {
288 288
 
289 289
 				$plugin_name    = $plugin_data['Title'];
290 290
 				$plugin_author  = $plugin_data['Author'];
291 291
 				$plugin_version = $plugin_update_version = $plugin_data['Version'];
292 292
 
293 293
 				// Afraid that querying many plugins may risk a timeout.
294
-				if ( count( $active_plugins ) <= 10 ) {
295
-					$api = plugins_api( 'plugin_information', array(
294
+				if (count($active_plugins) <= 10) {
295
+					$api = plugins_api('plugin_information', array(
296 296
 						'slug'   => $plugin_data['Name'],
297 297
 						'fields' => array(
298 298
 							'version' => true,
299 299
 						),
300
-					) );
301
-					if ( $api && ! is_wp_error( $api ) ) {
302
-						if ( ! empty( $api->version ) ) {
300
+					));
301
+					if ($api && ! is_wp_error($api)) {
302
+						if ( ! empty($api->version)) {
303 303
 							$plugin_update_version = $api->version;
304
-							if ( version_compare( $plugin_version, $plugin_update_version, '<' ) ) {
305
-								$plugin_version = '<mark class="error">' . $plugin_version . ' (' . sprintf( __( '%s is available', 'google-calendar-events' ), esc_html( $plugin_update_version ) ) . ')</mark>';
304
+							if (version_compare($plugin_version, $plugin_update_version, '<')) {
305
+								$plugin_version = '<mark class="error">'.$plugin_version.' ('.sprintf(__('%s is available', 'google-calendar-events'), esc_html($plugin_update_version)).')</mark>';
306 306
 							} else {
307
-								$plugin_version = '<mark class="ok">' . $plugin_version . '</mark>';
307
+								$plugin_version = '<mark class="ok">'.$plugin_version.'</mark>';
308 308
 							}
309 309
 						}
310 310
 					}
311 311
 				}
312 312
 
313 313
 				$plugin  = '<dl>';
314
-				$plugin .= '<dt>' . __( 'Author', 'google-calendar-events' ) .  '</dt>';
315
-				$plugin .= '<dd>' . $plugin_author .         '</dd>';
316
-				$plugin .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>';
317
-				$plugin .= '<dd>' . $plugin_version .        '</dd>';
314
+				$plugin .= '<dt>'.__('Author', 'google-calendar-events').'</dt>';
315
+				$plugin .= '<dd>'.$plugin_author.'</dd>';
316
+				$plugin .= '<dt>'.__('Version', 'google-calendar-events').'</dt>';
317
+				$plugin .= '<dd>'.$plugin_version.'</dd>';
318 318
 				$plugin .= '</dl>';
319 319
 
320
-				$sections['plugins'][ sanitize_key( strip_tags( $plugin_name ) ) ] = array(
320
+				$sections['plugins'][sanitize_key(strip_tags($plugin_name))] = array(
321 321
 					'label'  => $plugin_name,
322
-					'label_export' => strip_tags( $plugin_data['Title'] ),
322
+					'label_export' => strip_tags($plugin_data['Title']),
323 323
 					'result' => $plugin,
324 324
 					'result_export' => $plugin_data['Version'],
325 325
 				);
326 326
 			}
327 327
 		}
328 328
 
329
-		if ( isset( $sections['plugins'] ) ) {
330
-			rsort( $sections['plugins'] );
329
+		if (isset($sections['plugins'])) {
330
+			rsort($sections['plugins']);
331 331
 		}
332 332
 
333 333
 		/**
@@ -335,51 +335,51 @@  discard block
 block discarded – undo
335 335
 		 * ==================
336 336
 		 */
337 337
 
338
-		if ( version_compare( PHP_VERSION, '5.5.19', '<' ) ) {
339
-			$php = '<mark class="error">' . sprintf( __( '%1$s - It is recomendend to upgrade at least to PHP version 5.5.19 for security reasons. <a href="%2$s" target="_blank">Read more.</a>', 'google-calendar-events' ), PHP_VERSION, 'http://www.wpupdatephp.com/update/' ) . '</mark>';
338
+		if (version_compare(PHP_VERSION, '5.5.19', '<')) {
339
+			$php = '<mark class="error">'.sprintf(__('%1$s - It is recomendend to upgrade at least to PHP version 5.5.19 for security reasons. <a href="%2$s" target="_blank">Read more.</a>', 'google-calendar-events'), PHP_VERSION, 'http://www.wpupdatephp.com/update/').'</mark>';
340 340
 		} else {
341
-			$php = '<mark class="ok">' . PHP_VERSION . '</mark>';
341
+			$php = '<mark class="ok">'.PHP_VERSION.'</mark>';
342 342
 		}
343 343
 
344
-		if ( $wpdb->use_mysqli ) {
345
-			$mysql = @mysqli_get_server_info( $wpdb->dbh );
344
+		if ($wpdb->use_mysqli) {
345
+			$mysql = @mysqli_get_server_info($wpdb->dbh);
346 346
 		} else {
347 347
 			$mysql = @mysql_get_server_info();
348 348
 		}
349 349
 
350 350
 		$host = $_SERVER['SERVER_SOFTWARE'];
351
-		if ( defined( 'WPE_APIKEY' ) ) {
351
+		if (defined('WPE_APIKEY')) {
352 352
 			$host .= ' (WP Engine)';
353
-		} elseif ( defined( 'PAGELYBIN' ) ) {
353
+		} elseif (defined('PAGELYBIN')) {
354 354
 			$host .= ' (Pagely)';
355 355
 		}
356 356
 
357 357
 		$default_timezone = $server_timezone_export = date_default_timezone_get();
358
-		if ( 'UTC' !== $default_timezone ) {
359
-			$server_timezone = '<mark class="error">' . sprintf( __( 'Server default timezone is %s - it should be UTC', 'google-calendar-events' ), $default_timezone ) . '</mark>';
358
+		if ('UTC' !== $default_timezone) {
359
+			$server_timezone = '<mark class="error">'.sprintf(__('Server default timezone is %s - it should be UTC', 'google-calendar-events'), $default_timezone).'</mark>';
360 360
 		} else {
361 361
 			$server_timezone = '<mark class="ok">UTC</mark>';
362 362
 		}
363 363
 
364 364
 		// WP Remote POST test.
365
-		$response = wp_safe_remote_post( 'https://www.paypal.com/cgi-bin/webscr', array(
365
+		$response = wp_safe_remote_post('https://www.paypal.com/cgi-bin/webscr', array(
366 366
 			'timeout'    => 60,
367 367
 			'body'       => array(
368 368
 				'cmd'    => '_notify-validate',
369 369
 			),
370
-		) );
371
-		if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
370
+		));
371
+		if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
372 372
 			$wp_post_export = 'Yes';
373
-			$wp_post = '<mark class="ok">' . __( 'Yes', 'google-calendar-events' ) . '</mark>';
373
+			$wp_post = '<mark class="ok">'.__('Yes', 'google-calendar-events').'</mark>';
374 374
 		} else {
375 375
 			$wp_post_export = 'No';
376
-			$wp_post = '<mark class="error">' . __( 'No', 'google-calendar-events' );
377
-			if ( is_wp_error( $response ) ) {
378
-				$error = ' (' . $response->get_error_message() . ')';
376
+			$wp_post = '<mark class="error">'.__('No', 'google-calendar-events');
377
+			if (is_wp_error($response)) {
378
+				$error = ' ('.$response->get_error_message().')';
379 379
 				$wp_post .= $error;
380 380
 				$wp_post_export .= $error;
381 381
 			} else {
382
-				$error = ' (' . $response['response']['code'] . ')';
382
+				$error = ' ('.$response['response']['code'].')';
383 383
 				$wp_post .= $error;
384 384
 				$wp_post_export .= $error;
385 385
 			}
@@ -387,70 +387,70 @@  discard block
 block discarded – undo
387 387
 		}
388 388
 
389 389
 		// WP Remote GET test.
390
-		$response = wp_safe_remote_get( get_home_url( '/?p=1' ) );
391
-		if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
390
+		$response = wp_safe_remote_get(get_home_url('/?p=1'));
391
+		if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
392 392
 			$wp_get_export = 'Yes';
393
-			$wp_get = '<mark class="ok">' . __( 'Yes', 'google-calendar-events' ) . '</mark>';
393
+			$wp_get = '<mark class="ok">'.__('Yes', 'google-calendar-events').'</mark>';
394 394
 		} else {
395 395
 			$wp_get_export = 'No';
396
-			$wp_get = '<mark class="error">' . __( 'No', 'google-calendar-events' );
397
-			if ( is_wp_error( $response ) ) {
398
-				$error = ' (' . $response->get_error_message() . ')';
396
+			$wp_get = '<mark class="error">'.__('No', 'google-calendar-events');
397
+			if (is_wp_error($response)) {
398
+				$error = ' ('.$response->get_error_message().')';
399 399
 				$wp_get .= $error;
400 400
 				$wp_get_export .= $error;
401 401
 			} else {
402
-				$error = ' (' . $response['response']['code'] . ')';
402
+				$error = ' ('.$response['response']['code'].')';
403 403
 				$wp_get .= $error;
404 404
 				$wp_get_export .= $error;
405 405
 			}
406 406
 			$wp_get .= '</mark>';
407 407
 		}
408 408
 
409
-		$php_memory_limit        = ini_get( 'memory_limit' );
410
-		$php_max_upload_filesize = ini_get( 'upload_max_filesize' );
411
-		$php_post_max_size       = ini_get( 'post_max_size' );
412
-		$php_max_execution_time  = ini_get( 'max_execution_time' );
413
-		$php_max_input_vars      = ini_get( 'max_input_vars' );
409
+		$php_memory_limit        = ini_get('memory_limit');
410
+		$php_max_upload_filesize = ini_get('upload_max_filesize');
411
+		$php_post_max_size       = ini_get('post_max_size');
412
+		$php_max_execution_time  = ini_get('max_execution_time');
413
+		$php_max_input_vars      = ini_get('max_input_vars');
414 414
 
415 415
 		$curl_info = '';
416 416
 
417
-		if ( function_exists( 'curl_version' ) ) {
417
+		if (function_exists('curl_version')) {
418 418
 			$curl_info = curl_version();
419 419
 		}
420 420
 
421 421
 		$sections['server'] = array(
422 422
 			'host'                => array(
423
-				'label'  => __( 'Web Server', 'google-calendar-events' ),
423
+				'label'  => __('Web Server', 'google-calendar-events'),
424 424
 				'label_export' => 'Web Server',
425 425
 				'result' => $host,
426 426
 			),
427 427
 			'php_version'         => array(
428
-				'label'  => __( 'PHP Version', 'google-calendar-events' ),
428
+				'label'  => __('PHP Version', 'google-calendar-events'),
429 429
 				'label_export' => 'PHP Version',
430 430
 				'result' => $php,
431 431
 				'result_export' => PHP_VERSION,
432 432
 			),
433 433
 			'mysql_version'       => array(
434
-				'label'  => __( 'MySQL Version', 'google-calendar-events' ),
434
+				'label'  => __('MySQL Version', 'google-calendar-events'),
435 435
 				'label_export' => 'MySQL Version',
436
-				'result' => version_compare( $mysql, '5.5', '>' ) ? '<mark class="ok">' . $mysql . '</mark>' : $mysql,
436
+				'result' => version_compare($mysql, '5.5', '>') ? '<mark class="ok">'.$mysql.'</mark>' : $mysql,
437 437
 				'result_export' => $mysql,
438 438
 			),
439 439
 			'server_timezone'     => array(
440
-				'label'  => __( 'Server Timezone', 'google-calendar-events' ),
440
+				'label'  => __('Server Timezone', 'google-calendar-events'),
441 441
 				'label_export' => 'Server Timezone',
442 442
 				'result' => $server_timezone,
443 443
 				'result_export' => $server_timezone_export,
444 444
 			),
445 445
 			'display_errors'      => array(
446 446
 				'label'  => 'Display Errors',
447
-				'result' => ( ini_get( 'display_errors' ) ) ? __( 'Yes', 'google-calendar-events' ) . ' (' . ini_get( 'display_errors' ) . ')' : '-',
448
-				'result_export' => ( ini_get( 'display_errors' ) ) ? 'Yes' : 'No',
447
+				'result' => (ini_get('display_errors')) ? __('Yes', 'google-calendar-events').' ('.ini_get('display_errors').')' : '-',
448
+				'result_export' => (ini_get('display_errors')) ? 'Yes' : 'No',
449 449
 			),
450 450
 			'php_safe_mode'       => array(
451 451
 				'label'  => 'Safe Mode',
452
-				'result' => ( ini_get( 'safe_mode' ) ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ),
453
-				'result_export' => ( ini_get( 'safe_mode' ) ) ? 'Yes' : 'No',
452
+				'result' => (ini_get('safe_mode')) ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'),
453
+				'result_export' => (ini_get('safe_mode')) ? 'Yes' : 'No',
454 454
 			),
455 455
 			'php_memory_limit'    => array(
456 456
 				'label'  => 'Memory Limit',
@@ -474,23 +474,23 @@  discard block
 block discarded – undo
474 474
 			),
475 475
 			'fsockopen'           => array(
476 476
 				'label'  => 'fsockopen',
477
-				'result' => function_exists( 'fsockopen' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ),
478
-				'result_export' => function_exists( 'fsockopen' ) ? 'Yes' : 'No',
477
+				'result' => function_exists('fsockopen') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'),
478
+				'result_export' => function_exists('fsockopen') ? 'Yes' : 'No',
479 479
 			),
480 480
 			'curl_init'           => array(
481 481
 				'label'         => 'cURL',
482
-				'result'        => ! empty( $curl_info ) ? $curl_info['version'] . ', ' . $curl_info['ssl_version'] : __( 'No version found.', 'google-calendar-events' ),
483
-				'result_export' => ! empty( $curl_info ) ? $curl_info['version'] . ', ' . $curl_info['ssl_version'] : 'No version found.',
482
+				'result'        => ! empty($curl_info) ? $curl_info['version'].', '.$curl_info['ssl_version'] : __('No version found.', 'google-calendar-events'),
483
+				'result_export' => ! empty($curl_info) ? $curl_info['version'].', '.$curl_info['ssl_version'] : 'No version found.',
484 484
 			),
485 485
 			'soap'                => array(
486 486
 				'label'  => 'SOAP',
487
-				'result' => class_exists( 'SoapClient' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ),
488
-				'result_export' => class_exists( 'SoapClient' ) ? 'Yes' : 'No',
487
+				'result' => class_exists('SoapClient') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'),
488
+				'result_export' => class_exists('SoapClient') ? 'Yes' : 'No',
489 489
 			),
490 490
 			'suhosin'             => array(
491 491
 				'label'  => 'SUHOSIN',
492
-				'result' => extension_loaded( 'suhosin' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ),
493
-				'result_export' => extension_loaded( 'suhosin' ) ? 'Yes' : 'No',
492
+				'result' => extension_loaded('suhosin') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'),
493
+				'result_export' => extension_loaded('suhosin') ? 'Yes' : 'No',
494 494
 			),
495 495
 			'wp_remote_post'      => array(
496 496
 				'label'  => 'WP Remote POST',
@@ -512,26 +512,26 @@  discard block
 block discarded – undo
512 512
 		$user_client = new \SimpleCalendar\Browser();
513 513
 
514 514
 		$browser  = '<dl>';
515
-		$browser .= '<dt>' . __( 'Name:', 'google-calendar-events' ) .         '</dt>';
516
-		$browser .= '<dd>' . $user_client->getBrowser() .   '</dd>';
517
-		$browser .= '<dt>' . __( 'Version:', 'google-calendar-events' ) .      '</dt>';
518
-		$browser .= '<dd>' . $user_client->getVersion() .   '</dd>';
519
-		$browser .= '<dt>' . __( 'User Agent:', 'google-calendar-events' ) .   '</dt>';
520
-		$browser .= '<dd>' . $user_client->getUserAgent() . '</dd>';
521
-		$browser .= '<dt>' . __( 'Platform:', 'google-calendar-events' ) .     '</dt>';
522
-		$browser .= '<dd>' . $user_client->getPlatform() .  '</dd>';
515
+		$browser .= '<dt>'.__('Name:', 'google-calendar-events').'</dt>';
516
+		$browser .= '<dd>'.$user_client->getBrowser().'</dd>';
517
+		$browser .= '<dt>'.__('Version:', 'google-calendar-events').'</dt>';
518
+		$browser .= '<dd>'.$user_client->getVersion().'</dd>';
519
+		$browser .= '<dt>'.__('User Agent:', 'google-calendar-events').'</dt>';
520
+		$browser .= '<dd>'.$user_client->getUserAgent().'</dd>';
521
+		$browser .= '<dt>'.__('Platform:', 'google-calendar-events').'</dt>';
522
+		$browser .= '<dd>'.$user_client->getPlatform().'</dd>';
523 523
 		$browser .= '</dl>';
524 524
 
525
-		$browser_export = $user_client->getBrowser() . ' ' . $user_client->getVersion() . ' (' . $user_client->getPlatform() . ')';
525
+		$browser_export = $user_client->getBrowser().' '.$user_client->getVersion().' ('.$user_client->getPlatform().')';
526 526
 
527 527
 		$sections['client'] = array(
528 528
 			'user_ip' => array(
529
-				'label'  => __( 'IP Address', 'google-calendar-events' ),
529
+				'label'  => __('IP Address', 'google-calendar-events'),
530 530
 				'label_export' => 'IP Address',
531 531
 				'result' => $_SERVER['SERVER_ADDR'],
532 532
 			),
533 533
 			'browser' => array(
534
-				'label'  => __( 'Browser', 'google-calendar-events' ),
534
+				'label'  => __('Browser', 'google-calendar-events'),
535 535
 				'result' => $browser,
536 536
 				'result_export' => $browser_export,
537 537
 			)
@@ -542,12 +542,12 @@  discard block
 block discarded – undo
542 542
 		 * ============
543 543
 		 */
544 544
 
545
-		$panels   = apply_filters( 'simcal_system_status_report_panels', $panels );
546
-		$sections = apply_filters( 'simcal_system_status_report_sections', $sections );
545
+		$panels   = apply_filters('simcal_system_status_report_panels', $panels);
546
+		$sections = apply_filters('simcal_system_status_report_sections', $sections);
547 547
 
548
-		foreach ( $panels as $panel => $v ) :
548
+		foreach ($panels as $panel => $v) :
549 549
 
550
-			if ( isset( $sections[ $panel ] ) ) :
550
+			if (isset($sections[$panel])) :
551 551
 
552 552
 				?>
553 553
 				<table class="widefat simcal-system-status-report-panel">
@@ -557,15 +557,15 @@  discard block
 block discarded – undo
557 557
 						</tr>
558 558
 					</thead>
559 559
 					<tbody>
560
-						<?php foreach ( $sections[ $panel ] as $row => $cell ) : ?>
560
+						<?php foreach ($sections[$panel] as $row => $cell) : ?>
561 561
 							<tr>
562 562
 								<?php
563
-								$label_export  = isset( $cell['label_export']  ) ? $cell['label_export']  : $cell['label'];
564
-								$result_export = isset( $cell['result_export'] ) ? $cell['result_export'] : $cell['result'];
563
+								$label_export  = isset($cell['label_export']) ? $cell['label_export'] : $cell['label'];
564
+								$result_export = isset($cell['result_export']) ? $cell['result_export'] : $cell['result'];
565 565
 								?>
566
-								<td class="tooltip"><?php echo isset( $cell['tooltip'] ) ? ' <i class="simcal-icon-help simcal-help-tip" data-tip="' . $cell['tooltip'] . '"></i> ' : ''; ?></td>
567
-								<td class="label" data-export="<?php echo trim( $label_export ); ?>"><?php echo $cell['label']; ?></td>
568
-								<td class="result" data-export="<?php echo trim( $result_export ); ?>"><?php echo $cell['result']; ?></td>
566
+								<td class="tooltip"><?php echo isset($cell['tooltip']) ? ' <i class="simcal-icon-help simcal-help-tip" data-tip="'.$cell['tooltip'].'"></i> ' : ''; ?></td>
567
+								<td class="label" data-export="<?php echo trim($label_export); ?>"><?php echo $cell['label']; ?></td>
568
+								<td class="result" data-export="<?php echo trim($result_export); ?>"><?php echo $cell['result']; ?></td>
569 569
 							</tr>
570 570
 						<?php endforeach; ?>
571 571
 					</tbody>
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 			jQuery( '#simcal-system-status-report-download' ).on( 'click', function() {
644 644
 				var file = new Blob( [ report ], { type: 'text/plain' } );
645 645
 				jQuery( this ).attr( 'href', URL.createObjectURL( file ) );
646
-				jQuery( this ).attr( 'download', '<?php echo sanitize_title( str_replace( array( 'http://', 'https://' ), '', get_bloginfo( 'url' ) ) . '-system-report-' . date( 'Y-m-d', time() ) ); ?>' );
646
+				jQuery( this ).attr( 'download', '<?php echo sanitize_title(str_replace(array('http://', 'https://'), '', get_bloginfo('url')).'-system-report-'.date('Y-m-d', time())); ?>' );
647 647
 			} );
648 648
 
649 649
 		</script>
@@ -663,13 +663,13 @@  discard block
 block discarded – undo
663 663
 	 *
664 664
 	 * @return int|double|string
665 665
 	 */
666
-	private function let_to_num( $size ) {
666
+	private function let_to_num($size) {
667 667
 
668
-		$l   = substr( $size, -1 );
669
-		$ret = substr( $size, 0, -1 );
668
+		$l   = substr($size, -1);
669
+		$ret = substr($size, 0, -1);
670 670
 
671 671
 		// Note: do not insert break or default in this switch loop.
672
-		switch ( strtoupper( $l ) ) {
672
+		switch (strtoupper($l)) {
673 673
 			case 'P':
674 674
 				$ret *= 1024;
675 675
 				// no break
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 				$ret *= 1024;
684 684
 				// no break
685 685
 			case 'K':
686
-				$ret *= 1024;;
686
+				$ret *= 1024; ;
687 687
 				// no break
688 688
 		}
689 689
 
Please login to merge, or discard this patch.
includes/feeds/google.php 1 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->diffInDays( $google_end );
283
+								$span = $google_start->diffInDays($google_end);
284 284
 
285
-								if ( $span == 0 ) {
286
-									if ( ( $google_start->toDateString() !== $google_end->toDateString() ) && $google_end->toTimeString() != '00:00:00' ) {
285
+								if ($span == 0) {
286
+									if (($google_start->toDateString() !== $google_end->toDateString()) && $google_end->toTimeString() != '00:00:00') {
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,
@@ -338,24 +338,24 @@  discard block
 block discarded – undo
338 338
 						}
339 339
 					}
340 340
 
341
-					if ( ! empty( $calendar['events'] ) ) {
341
+					if ( ! empty($calendar['events'])) {
342 342
 
343
-						ksort( $calendar['events'], SORT_NUMERIC );
343
+						ksort($calendar['events'], SORT_NUMERIC);
344 344
 
345 345
 						set_transient(
346
-							'_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type,
346
+							'_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type,
347 347
 							$calendar,
348
-							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
+							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
349 349
 						);
350 350
 					}
351 351
 				}
352 352
 
353 353
 			} else {
354 354
 
355
-				$message  = __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' );
356
-				$message .= '<br><br>' . $error . '<br><br>';
357
-				$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>';
358
-				$message .= __( 'Only you can see this notice.', 'google-calendar-events' );
355
+				$message  = __('While trying to retrieve events, Google returned an error:', 'google-calendar-events');
356
+				$message .= '<br><br>'.$error.'<br><br>';
357
+				$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>';
358
+				$message .= __('Only you can see this notice.', 'google-calendar-events');
359 359
 
360 360
 				return $message;
361 361
 			}
@@ -363,11 +363,11 @@  discard block
 block discarded – undo
363 363
 		}
364 364
 
365 365
 		// If no timezone has been set, use calendar feed.
366
-		if ( 'use_calendar' == $this->timezone_setting && isset( $calendar['timezone'] ) ) {
366
+		if ('use_calendar' == $this->timezone_setting && isset($calendar['timezone'])) {
367 367
 			$this->timezone = $calendar['timezone'];
368 368
 		}
369 369
 
370
-		return isset( $calendar['events'] ) ? $calendar['events'] : array();
370
+		return isset($calendar['events']) ? $calendar['events'] : array();
371 371
 	}
372 372
 
373 373
 	/**
@@ -383,67 +383,67 @@  discard block
 block discarded – undo
383 383
 	 *
384 384
 	 * @throws \Exception On request failure will throw an exception from Google.
385 385
 	 */
386
-	public function make_request( $id = '', $time_min = 0, $time_max = 0 ) {
386
+	public function make_request($id = '', $time_min = 0, $time_max = 0) {
387 387
 
388 388
 		$calendar = array();
389 389
 		$google = $this->get_service();
390 390
 
391
-		if ( ! is_null( $google ) && ! empty( $id ) ) {
391
+		if ( ! is_null($google) && ! empty($id)) {
392 392
 
393 393
 			// Build the request args.
394 394
 			$args = array();
395 395
 
396 396
 			// Expand recurring events.
397
-			if ( $this->google_events_recurring == 'show' ) {
397
+			if ($this->google_events_recurring == 'show') {
398 398
 				$args['singleEvents'] = true;
399 399
 			}
400 400
 
401 401
 			// Query events using search terms.
402
-			if ( ! empty( $this->google_search_query ) ) {
403
-				$args['q'] = rawurlencode( $this->google_search_query );
402
+			if ( ! empty($this->google_search_query)) {
403
+				$args['q'] = rawurlencode($this->google_search_query);
404 404
 			}
405 405
 
406 406
 			// Max results to query.
407
-			$args['maxResults'] = strval( min( absint( $this->google_max_results ), 2500 ) );
407
+			$args['maxResults'] = strval(min(absint($this->google_max_results), 2500));
408 408
 
409 409
 			// Specify a timezone.
410 410
 			$timezone = '';
411
-			if ( 'use_calendar' != get_post_meta( $this->post_id, '_feed_timezone_setting', true ) ) {
411
+			if ('use_calendar' != get_post_meta($this->post_id, '_feed_timezone_setting', true)) {
412 412
 				$args['timeZone'] = $timezone = $this->timezone;
413 413
 			}
414 414
 
415 415
 			// Lower bound (inclusive) for an event's end time to filter by.
416
-			$earliest_event = intval( $this->time_min );
417
-			if ( $earliest_event > 0 ) {
416
+			$earliest_event = intval($this->time_min);
417
+			if ($earliest_event > 0) {
418 418
 				$timeMin = Carbon::now();
419
-				if ( ! empty( $timezone ) ) {
420
-					$timeMin->setTimezone( $timezone );
419
+				if ( ! empty($timezone)) {
420
+					$timeMin->setTimezone($timezone);
421 421
 				}
422
-				$timeMin->setTimestamp( $earliest_event );
422
+				$timeMin->setTimestamp($earliest_event);
423 423
 				$args['timeMin'] = $timeMin->toRfc3339String();
424 424
 			}
425 425
 
426 426
 			// Upper bound (exclusive) for an event's start time to filter by.
427
-			$latest_event = intval( $this->time_max );
428
-			if ( $latest_event > 0 ) {
427
+			$latest_event = intval($this->time_max);
428
+			if ($latest_event > 0) {
429 429
 				$timeMax = Carbon::now();
430
-				if ( ! empty( $timezone ) ) {
431
-					$timeMax->setTimezone( $timezone );
430
+				if ( ! empty($timezone)) {
431
+					$timeMax->setTimezone($timezone);
432 432
 				}
433
-				$timeMax->setTimestamp( $latest_event );
433
+				$timeMax->setTimestamp($latest_event);
434 434
 				$args['timeMax'] = $timeMax->toRfc3339String();
435 435
 			}
436 436
 
437 437
 			// Query events in calendar.
438
-			$response = $google->events->listEvents( $id, $args );
438
+			$response = $google->events->listEvents($id, $args);
439 439
 
440
-			if ( $response instanceof \Google_Service_Calendar_Events ) {
440
+			if ($response instanceof \Google_Service_Calendar_Events) {
441 441
 				$calendar = array(
442 442
 					'id'            => $id,
443 443
 					'title'         => $response->getSummary(),
444 444
 					'description'   => $response->getDescription(),
445 445
 					'timezone'      => $response->getTimeZone(),
446
-					'url'           => esc_url( '//www.google.com/calendar/embed?src=' . $id ),
446
+					'url'           => esc_url('//www.google.com/calendar/embed?src='.$id),
447 447
 					'events'        => $response->getItems(),
448 448
 				);
449 449
 			}
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
 	private function get_client() {
464 464
 
465 465
 		$client = new \Google_Client();
466
-		$client->setApplicationName( 'Simple Calendar' );
467
-		$client->setScopes( $this->google_client_scopes );
468
-		$client->setDeveloperKey( $this->google_api_key );
469
-		$client->setAccessType( 'online' );
466
+		$client->setApplicationName('Simple Calendar');
467
+		$client->setScopes($this->google_client_scopes);
468
+		$client->setDeveloperKey($this->google_api_key);
469
+		$client->setAccessType('online');
470 470
 
471 471
 		return $client;
472 472
 	}
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 	 * @return null|\Google_Service_Calendar
481 481
 	 */
482 482
 	protected function get_service() {
483
-		return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar( $this->google_client ) : null;
483
+		return $this->google_client instanceof \Google_Client ? new \Google_Service_Calendar($this->google_client) : null;
484 484
 	}
485 485
 
486 486
 }
Please login to merge, or discard this patch.