Completed
Push — master ( fce50c...06d306 )
by
unknown
02:56
created
includes/admin/fields/checkbox.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use SimpleCalendar\Abstracts\Field;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit; // Exit if accessed directly.
13 13
 }
14 14
 
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param array $field
30 30
 	 */
31
-	public function __construct( $field ) {
31
+	public function __construct($field) {
32 32
 		$this->type_class = 'simcal-field-checkboxes';
33
-		parent::__construct( $field );
33
+		parent::__construct($field);
34 34
 	}
35 35
 
36 36
 	/**
@@ -40,33 +40,33 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function html() {
42 42
 
43
-		if ( ! empty( $this->options ) && count( (array) $this->options ) > 1 ) {
43
+		if ( ! empty($this->options) && count((array) $this->options) > 1) {
44 44
 
45
-			if ( ! empty( $this->description ) ) {
46
-				echo '<p class="description">' . wp_kses_post( $this->description ) . ' ' . $this->tooltip . '</p>';
45
+			if ( ! empty($this->description)) {
46
+				echo '<p class="description">'.wp_kses_post($this->description).' '.$this->tooltip.'</p>';
47 47
 			}
48 48
 
49 49
 			?>
50
-			<fieldset class="<?php echo $this->class; ?>" <?php echo ! empty( $this->style ) ? 'style="' . $this->style . '"' : ''; ?>>
50
+			<fieldset class="<?php echo $this->class; ?>" <?php echo ! empty($this->style) ? 'style="'.$this->style.'"' : ''; ?>>
51 51
 				<?php
52 52
 
53
-				if ( ! empty( $this->title ) ) {
54
-					echo '<legend class="screen-reader-text"><span>' . $this->title . '</span></legend>';
53
+				if ( ! empty($this->title)) {
54
+					echo '<legend class="screen-reader-text"><span>'.$this->title.'</span></legend>';
55 55
 				}
56 56
 
57 57
 				?>
58 58
 				<ul>
59
-					<?php foreach ( $this->options as $option => $name ) : ?>
59
+					<?php foreach ($this->options as $option => $name) : ?>
60 60
 						<li>
61
-							<label for="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>">
61
+							<label for="<?php echo $this->id.'-'.trim(strval($option)); ?>">
62 62
 								<input name="<?php echo $this->name; ?>"
63
-								       id="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>"
63
+								       id="<?php echo $this->id.'-'.trim(strval($option)); ?>"
64 64
 								       class="simcal-field simcal-field-checkbox"
65 65
 								       type="checkbox"
66
-								       value="<?php echo trim( strval( $option ) ); ?>"
67
-										<?php checked( $this->value, 'yes', true ); ?>
66
+								       value="<?php echo trim(strval($option)); ?>"
67
+										<?php checked($this->value, 'yes', true); ?>
68 68
 									<?php echo $this->attributes; ?>
69
-									/><?php echo esc_attr( $name ); ?>
69
+									/><?php echo esc_attr($name); ?>
70 70
 							</label>
71 71
 						</li>
72 72
 					<?php endforeach; ?>
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 		} else {
78 78
 
79 79
 			?>
80
-			<span class="simcal-field-bool" <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?>>
81
-				<?php if ( ! empty( $this->title ) ) : ?>
80
+			<span class="simcal-field-bool" <?php echo $this->style ? 'style="'.$this->style.'"' : ''; ?>>
81
+				<?php if ( ! empty($this->title)) : ?>
82 82
 					<span class="screen-reader-text"><?php echo $this->title; ?></span>
83 83
 				<?php endif; ?>
84 84
 				<input name="<?php echo $this->name; ?>"
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 				       id="<?php echo $this->id; ?>"
87 87
 				       class="simcal-field simcal-field-checkbox <?php echo $this->class; ?>"
88 88
 				       value="yes"
89
-					<?php checked( $this->value, 'yes', true ); ?>
90
-					<?php echo $this->attributes; ?>/><?php _e( 'Yes', 'google-calendar-events' ); ?>
89
+					<?php checked($this->value, 'yes', true); ?>
90
+					<?php echo $this->attributes; ?>/><?php _e('Yes', 'google-calendar-events'); ?>
91 91
 			</span>
92 92
 			<?php
93 93
 
94 94
 			echo $this->tooltip;
95 95
 
96
-			if ( ! empty( $this->description ) ) {
97
-				echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>';
96
+			if ( ! empty($this->description)) {
97
+				echo '<p class="description">'.wp_kses_post($this->description).'</p>';
98 98
 			}
99 99
 
100 100
 		}
Please login to merge, or discard this patch.
includes/admin/pages.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 use SimpleCalendar\Abstracts\Field;
10 10
 use SimpleCalendar\Abstracts\Admin_Page;
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -53,20 +53,20 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @param string $page
55 55
 	 */
56
-	public function __construct( $page = 'settings' ) {
56
+	public function __construct($page = 'settings') {
57 57
 
58 58
 		$this->page = $page;
59
-		$settings_pages = ! is_null( \SimpleCalendar\plugin()->objects ) ? simcal_get_admin_pages() : '';
59
+		$settings_pages = ! is_null(\SimpleCalendar\plugin()->objects) ? simcal_get_admin_pages() : '';
60 60
 		$settings_page_tabs = array();
61
-		$tabs = isset( $settings_pages[ $page ] ) ? $settings_pages[ $page ] : false;
61
+		$tabs = isset($settings_pages[$page]) ? $settings_pages[$page] : false;
62 62
 
63
-		if ( $tabs && is_array( $tabs ) ) {
64
-			foreach ( $tabs as $tab ) {
63
+		if ($tabs && is_array($tabs)) {
64
+			foreach ($tabs as $tab) {
65 65
 
66
-				$settings_page = simcal_get_admin_page( $tab );
66
+				$settings_page = simcal_get_admin_page($tab);
67 67
 
68
-				if ( $settings_page instanceof Admin_Page ) {
69
-					$settings_page_tabs[ $settings_page->id ] = $settings_page;
68
+				if ($settings_page instanceof Admin_Page) {
69
+					$settings_page_tabs[$settings_page->id] = $settings_page;
70 70
 				}
71 71
 			}
72 72
 
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 		}
75 75
 
76 76
 		// The first tab is the default tab when opening a page.
77
-		$this->tab = isset( $tabs[0] ) ? $tabs[0] : '';
77
+		$this->tab = isset($tabs[0]) ? $tabs[0] : '';
78 78
 
79
-		do_action( 'simcal_admin_pages', $page );
79
+		do_action('simcal_admin_pages', $page);
80 80
 	}
81 81
 
82 82
 	/**
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 
92 92
 		$settings = array();
93 93
 
94
-		if ( ! empty( $this->settings ) && is_array( $this->settings ) ) {
95
-			foreach ( $this->settings as $id => $object ) {
94
+		if ( ! empty($this->settings) && is_array($this->settings)) {
95
+			foreach ($this->settings as $id => $object) {
96 96
 
97
-				if ( $object instanceof Admin_Page ) {
97
+				if ($object instanceof Admin_Page) {
98 98
 
99 99
 					$settings_page = $object->get_settings();
100 100
 
101
-					if ( isset( $settings_page[ $id ] ) ) {
102
-						$settings[ $id ] = $settings_page[ $id ];
101
+					if (isset($settings_page[$id])) {
102
+						$settings[$id] = $settings_page[$id];
103 103
 					}
104 104
 				}
105 105
 
@@ -118,48 +118,48 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @param array $settings
120 120
 	 */
121
-	public function register_settings( $settings = array() ) {
121
+	public function register_settings($settings = array()) {
122 122
 
123 123
 		$settings = $settings ? $settings : $this->get_settings();
124 124
 
125
-		if ( ! empty( $settings ) && is_array( $settings ) ) {
125
+		if ( ! empty($settings) && is_array($settings)) {
126 126
 
127
-			foreach ( $settings as $tab_id => $settings_page ) {
127
+			foreach ($settings as $tab_id => $settings_page) {
128 128
 
129
-				if ( isset( $settings_page['sections'] ) ) {
129
+				if (isset($settings_page['sections'])) {
130 130
 
131 131
 					$sections = $settings_page['sections'];
132 132
 
133
-					if ( ! empty( $sections ) && is_array( $sections ) ) {
133
+					if ( ! empty($sections) && is_array($sections)) {
134 134
 
135
-						foreach ( $sections as $section_id => $section ) {
135
+						foreach ($sections as $section_id => $section) {
136 136
 
137 137
 							add_settings_section(
138 138
 								$section_id,
139
-								isset( $section['title'] ) ? $section['title'] : '',
140
-								isset( $section['callback'] ) ? $section['callback'] : '',
141
-								'simple-calendar_' . $this->page . '_' . $tab_id
139
+								isset($section['title']) ? $section['title'] : '',
140
+								isset($section['callback']) ? $section['callback'] : '',
141
+								'simple-calendar_'.$this->page.'_'.$tab_id
142 142
 							);
143 143
 
144
-							if ( isset( $section['fields'] ) ) {
144
+							if (isset($section['fields'])) {
145 145
 
146 146
 								$fields = $section['fields'];
147 147
 
148
-								if ( ! empty( $fields ) && is_array( $fields ) ) {
148
+								if ( ! empty($fields) && is_array($fields)) {
149 149
 
150
-									foreach ( $fields as $field ) {
150
+									foreach ($fields as $field) {
151 151
 
152
-										if ( isset( $field['id'] ) && isset( $field['type'] ) ) {
152
+										if (isset($field['id']) && isset($field['type'])) {
153 153
 
154
-											$field_object = simcal_get_field( $field, $field['type'] );
154
+											$field_object = simcal_get_field($field, $field['type']);
155 155
 
156
-											if ( $field_object instanceof Field ) {
156
+											if ($field_object instanceof Field) {
157 157
 
158 158
 												add_settings_field(
159 159
 													$field['id'],
160
-													isset( $field['title'] ) ? $field['title'] : '',
161
-													array( $field_object, 'html' ),
162
-													'simple-calendar_' . $this->page . '_' . $tab_id,
160
+													isset($field['title']) ? $field['title'] : '',
161
+													array($field_object, 'html'),
162
+													'simple-calendar_'.$this->page.'_'.$tab_id,
163 163
 													$section_id
164 164
 												);
165 165
 
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 
174 174
 							} // are there fields?
175 175
 
176
-							$page = simcal_get_admin_page( $tab_id );
176
+							$page = simcal_get_admin_page($tab_id);
177 177
 
178 178
 							register_setting(
179
-								'simple-calendar_' . $this->page . '_' . $tab_id,
180
-								'simple-calendar_' . $this->page . '_' . $tab_id,
181
-								$page instanceof Admin_Page ? array( $page, 'validate' ) : ''
179
+								'simple-calendar_'.$this->page.'_'.$tab_id,
180
+								'simple-calendar_'.$this->page.'_'.$tab_id,
181
+								$page instanceof Admin_Page ? array($page, 'validate') : ''
182 182
 							);
183 183
 
184 184
 						} // loop sections
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		global $current_tab;
204 204
 
205 205
 		// Get current tab/section
206
-		$current_tab = empty( $_GET['tab'] ) ? $this->tab : sanitize_title( $_GET['tab'] );
206
+		$current_tab = empty($_GET['tab']) ? $this->tab : sanitize_title($_GET['tab']);
207 207
 		$this->tab = $current_tab;
208 208
 
209 209
 		?>
@@ -215,45 +215,45 @@  discard block
 block discarded – undo
215 215
 
216 216
 				// Include settings pages
217 217
 				$settings_pages = self::get_settings();
218
-				if ( ! empty( $settings_pages ) && is_array( $settings_pages ) ) {
218
+				if ( ! empty($settings_pages) && is_array($settings_pages)) {
219 219
 
220 220
 					echo '<h2 class="nav-tab-wrapper simcal-nav-tab-wrapper">';
221 221
 
222 222
 					// Get tabs for the settings page
223
-					if ( ! empty( $settings_pages ) && is_array( $settings_pages ) ) {
223
+					if ( ! empty($settings_pages) && is_array($settings_pages)) {
224 224
 
225
-						foreach ( $settings_pages as $id => $settings ) {
225
+						foreach ($settings_pages as $id => $settings) {
226 226
 
227
-							$tab_id    = isset( $id ) ? $id : '';
228
-							$tab_label = isset( $settings['label'] ) ? $settings['label'] : '';
229
-							$tab_link  = admin_url( 'edit.php?post_type=calendar&page=simple-calendar_' . $this->page . '&tab=' . $tab_id );
227
+							$tab_id    = isset($id) ? $id : '';
228
+							$tab_label = isset($settings['label']) ? $settings['label'] : '';
229
+							$tab_link  = admin_url('edit.php?post_type=calendar&page=simple-calendar_'.$this->page.'&tab='.$tab_id);
230 230
 
231
-							echo '<a href="' . $tab_link . '" class="nav-tab ' . ( $current_tab == $tab_id ? 'nav-tab-active' : '' ) . '">' . $tab_label . '</a>';
231
+							echo '<a href="'.$tab_link.'" class="nav-tab '.($current_tab == $tab_id ? 'nav-tab-active' : '').'">'.$tab_label.'</a>';
232 232
 						}
233 233
 
234 234
 					}
235 235
 
236
-					do_action( 'simcal_admin_page_' . $this->page . '_tabs' );
236
+					do_action('simcal_admin_page_'.$this->page.'_tabs');
237 237
 
238 238
 					echo '</h2>';
239 239
 
240 240
 					settings_errors();
241 241
 
242
-					foreach ( $settings_pages as $tab_id => $contents ) {
242
+					foreach ($settings_pages as $tab_id => $contents) {
243 243
 
244
-						if ( $tab_id === $current_tab ) {
244
+						if ($tab_id === $current_tab) {
245 245
 
246
-							echo isset( $contents['description'] ) ? '<p>' . $contents['description'] . '</p>' : '';
246
+							echo isset($contents['description']) ? '<p>'.$contents['description'].'</p>' : '';
247 247
 
248
-							do_action( 'simcal_admin_page_' .  $this->page . '_' . $current_tab . '_start' );
248
+							do_action('simcal_admin_page_'.$this->page.'_'.$current_tab.'_start');
249 249
 
250
-							settings_fields( 'simple-calendar_' . $this->page . '_' . $tab_id );
251
-							do_settings_sections( 'simple-calendar_' . $this->page . '_' . $tab_id );
250
+							settings_fields('simple-calendar_'.$this->page.'_'.$tab_id);
251
+							do_settings_sections('simple-calendar_'.$this->page.'_'.$tab_id);
252 252
 
253
-							do_action( 'simcal_admin_page_' .  $this->page . '_' . $current_tab . '_end' );
253
+							do_action('simcal_admin_page_'.$this->page.'_'.$current_tab.'_end');
254 254
 
255
-							$submit = apply_filters( 'simcal_admin_page_' . $this->page . '_' . $current_tab . '_submit', true );
256
-							if ( true === $submit ) {
255
+							$submit = apply_filters('simcal_admin_page_'.$this->page.'_'.$current_tab.'_submit', true);
256
+							if (true === $submit) {
257 257
 								submit_button();
258 258
 							}
259 259
 						}
@@ -263,17 +263,17 @@  discard block
 block discarded – undo
263 263
 				// Add option to show we ran through default settings
264 264
 				// We also run a check here for the main settings page option. This is to determine if this is a fresh install or if they already had
265 265
 				// the plugin installed. The main feed settings page would give the best idea of that since user's have to enter an API key on this page to get it working.
266
-				if ( false === get_option( 'simple-calendar_defaults' ) && false === get_option( 'simple-calendar_settings_feeds' ) ) {
266
+				if (false === get_option('simple-calendar_defaults') && false === get_option('simple-calendar_settings_feeds')) {
267 267
 
268
-					$default_advanced = array (
269
-										'assets' => array (
268
+					$default_advanced = array(
269
+										'assets' => array(
270 270
 												'always_enqueue' => 'yes',
271 271
 										),
272 272
 									);
273 273
 
274
-					update_option( 'simple-calendar_settings_advanced', $default_advanced );
274
+					update_option('simple-calendar_settings_advanced', $default_advanced);
275 275
 
276
-					add_option( 'simple-calendar_defaults', 1 );
276
+					add_option('simple-calendar_defaults', 1);
277 277
 				}
278 278
 
279 279
 
Please login to merge, or discard this patch.
includes/admin/pages/advanced.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use SimpleCalendar\Abstracts\Admin_Page;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function __construct() {
30 30
 		$this->id           = 'advanced';
31 31
 		$this->option_group = 'settings';
32
-		$this->label        = __( 'Advanced', 'google-calendar-events' );
32
+		$this->label        = __('Advanced', 'google-calendar-events');
33 33
 		//$this->description  = __( 'Advanced settings.', 'google-calendar-events' );
34 34
 		$this->sections     = $this->add_sections();
35 35
 		$this->fields       = $this->add_fields();
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 	 * @return array
44 44
 	 */
45 45
 	public function add_sections() {
46
-		return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id .'_sections', array(
46
+		return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_sections', array(
47 47
 			'assets' => array(
48
-				'title'       => __( 'Scripts and Styles', 'google-calendar-events' ),
49
-				'description' => __( 'Manage front end assets that handle the calendars appearance and user interface.', 'google-calendar-events' )
48
+				'title'       => __('Scripts and Styles', 'google-calendar-events'),
49
+				'description' => __('Manage front end assets that handle the calendars appearance and user interface.', 'google-calendar-events')
50 50
 			),
51 51
 			'installation' => array(
52
-				'title'       => __( 'Installation', 'google-calendar-events' ),
53
-				'description' => __( 'Manage your data (plugin settings and saved calendars).', 'google-calendar-events' )
52
+				'title'       => __('Installation', 'google-calendar-events'),
53
+				'description' => __('Manage your data (plugin settings and saved calendars).', 'google-calendar-events')
54 54
 			)
55
-		) );
55
+		));
56 56
 	}
57 57
 
58 58
 	/**
@@ -65,57 +65,57 @@  discard block
 block discarded – undo
65 65
 	public function add_fields() {
66 66
 
67 67
 		$fields       = array();
68
-		$this->values = get_option( 'simple-calendar_' . $this->option_group . '_' . $this->id );
68
+		$this->values = get_option('simple-calendar_'.$this->option_group.'_'.$this->id);
69 69
 
70
-		foreach ( $this->sections  as $section => $a ) :
70
+		foreach ($this->sections  as $section => $a) :
71 71
 
72
-			if ( 'assets' == $section ) {
72
+			if ('assets' == $section) {
73 73
 
74
-				$fields[ $section ] = array(
74
+				$fields[$section] = array(
75 75
 					'always_enqueue' => array(
76
-						'title'   => __( 'Always Enqueue', 'google-calendar-events' ),
77
-						'tooltip' => __( 'If ticked, this option will load all scripts on every page load.', 'google-calendar-events' ),
76
+						'title'   => __('Always Enqueue', 'google-calendar-events'),
77
+						'tooltip' => __('If ticked, this option will load all scripts on every page load.', 'google-calendar-events'),
78 78
 						'type'    => 'checkbox',
79
-						'name'    => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][always_enqueue]',
80
-						'id'      => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-always-enqueue',
81
-						'value'   => $this->get_option_value( $section, 'always_enqueue' ),
79
+						'name'    => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][always_enqueue]',
80
+						'id'      => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-always-enqueue',
81
+						'value'   => $this->get_option_value($section, 'always_enqueue'),
82 82
 					),
83 83
 					'disable_css' => array(
84
-						'title'   => __( 'Disable Styles', 'google-calendar-events' ),
85
-						'tooltip' => __( 'If ticked, this option will prevent front end stylesheet to load.', 'google-calendar-events' ),
84
+						'title'   => __('Disable Styles', 'google-calendar-events'),
85
+						'tooltip' => __('If ticked, this option will prevent front end stylesheet to load.', 'google-calendar-events'),
86 86
 						'type'    => 'checkbox',
87
-						'name'    => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][disable_css]',
88
-						'id'      => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-disable-css',
89
-						'value'   => $this->get_option_value( $section, 'disable_css' )
87
+						'name'    => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][disable_css]',
88
+						'id'      => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-disable-css',
89
+						'value'   => $this->get_option_value($section, 'disable_css')
90 90
 					),
91 91
 					'disable_js' => array(
92
-						'title'   => __( 'Disable Scripts', 'google-calendar-events' ),
93
-						'tooltip' => __( 'If ticked, this option will prevent front end JavaScript to load.', 'google-calendar-events' ),
92
+						'title'   => __('Disable Scripts', 'google-calendar-events'),
93
+						'tooltip' => __('If ticked, this option will prevent front end JavaScript to load.', 'google-calendar-events'),
94 94
 						'type'    => 'checkbox',
95
-						'name'    => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][disable_js]',
96
-						'id'      => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-disable-js',
97
-						'value'   => $this->get_option_value( $section, 'disable_js' )
95
+						'name'    => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][disable_js]',
96
+						'id'      => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-disable-js',
97
+						'value'   => $this->get_option_value($section, 'disable_js')
98 98
 					)
99 99
 				);
100 100
 
101
-			} elseif ( 'installation' == $section ) {
101
+			} elseif ('installation' == $section) {
102 102
 
103
-				$fields[ $section ] = array(
103
+				$fields[$section] = array(
104 104
 					'delete_settings' => array(
105
-						'title'   => __( 'Delete settings', 'google-calendar-events' ),
106
-						'tooltip' => __( 'Tick this option if you want to wipe this plugin settings from database when uninstalling.', 'google-calendar-events' ),
105
+						'title'   => __('Delete settings', 'google-calendar-events'),
106
+						'tooltip' => __('Tick this option if you want to wipe this plugin settings from database when uninstalling.', 'google-calendar-events'),
107 107
 						'type'    => 'checkbox',
108
-						'name'    => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][delete_settings]',
109
-						'id'      => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-delete-settings',
110
-						'value'   => $this->get_option_value( $section, 'delete_settings' ),
108
+						'name'    => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][delete_settings]',
109
+						'id'      => 'simple-calendar-'.$this->option_group.'-'.$this->id.'-'.$section.'-delete-settings',
110
+						'value'   => $this->get_option_value($section, 'delete_settings'),
111 111
 					),
112 112
 					'erase_data' => array(
113
-						'title'   => __( 'Erase calendar data', 'google-calendar-events' ),
114
-						'tooltip' => __( 'By default your data will be retained in database even after uninstall. Tick this option if you want to delete all your calendar data when uninstalling.', 'google-calendar-events' ),
113
+						'title'   => __('Erase calendar data', 'google-calendar-events'),
114
+						'tooltip' => __('By default your data will be retained in database even after uninstall. Tick this option if you want to delete all your calendar data when uninstalling.', 'google-calendar-events'),
115 115
 						'type'    => 'checkbox',
116
-						'name'    => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][erase_data]',
117
-						'id'      => 'simple-calendar_' . $this->option_group . '_' . $this->id . '-delete-data',
118
-						'value'   => $this->get_option_value( $section, 'erase_data' ),
116
+						'name'    => 'simple-calendar_'.$this->option_group.'_'.$this->id.'['.$section.'][erase_data]',
117
+						'id'      => 'simple-calendar_'.$this->option_group.'_'.$this->id.'-delete-data',
118
+						'value'   => $this->get_option_value($section, 'erase_data'),
119 119
 					)
120 120
 				);
121 121
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
 		endforeach;
125 125
 
126
-		return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id . '_fields', $fields );
126
+		return apply_filters('simcal_add_'.$this->option_group.'_'.$this->id.'_fields', $fields);
127 127
 	}
128 128
 
129 129
 }
Please login to merge, or discard this patch.
includes/calendars/default-calendar.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use SimpleCalendar\Calendars\Views;
14 14
 use SimpleCalendar\Events\Event;
15 15
 
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -105,35 +105,35 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @param int|object|\WP_Post|Calendar $calendar
107 107
 	 */
108
-	public function __construct( $calendar ) {
108
+	public function __construct($calendar) {
109 109
 
110 110
 		$this->type = 'default-calendar';
111
-		$this->name = __( 'Default', 'google-calendar-events' );
112
-		$this->views = apply_filters( 'simcal_default_calendar_views', array(
113
-			'grid' => __( 'Grid', 'google-calendar-events' ),
114
-			'list' => __( 'List', 'google-calendar-events' ),
115
-		) );
111
+		$this->name = __('Default', 'google-calendar-events');
112
+		$this->views = apply_filters('simcal_default_calendar_views', array(
113
+			'grid' => __('Grid', 'google-calendar-events'),
114
+			'list' => __('List', 'google-calendar-events'),
115
+		));
116 116
 
117
-		parent::__construct( $calendar );
117
+		parent::__construct($calendar);
118 118
 
119
-		if ( ! is_null( $this->post ) ) {
119
+		if ( ! is_null($this->post)) {
120 120
 
121
-			$this->set_properties( $this->view->get_type() );
121
+			$this->set_properties($this->view->get_type());
122 122
 
123 123
 			$id = $this->id;
124 124
 			$theme = $this->theme;
125 125
 
126
-			add_filter( 'simcal_calendar_class', function( $class, $post_id ) use ( $theme, $id ) {
127
-				if ( in_array( 'default-calendar', $class ) && $post_id === $id ) {
128
-					array_push( $class, 'default-calendar-' . $theme );
126
+			add_filter('simcal_calendar_class', function($class, $post_id) use ($theme, $id) {
127
+				if (in_array('default-calendar', $class) && $post_id === $id) {
128
+					array_push($class, 'default-calendar-'.$theme);
129 129
 				}
130 130
 				return $class;
131
-			}, 10, 2 );
131
+			}, 10, 2);
132 132
 
133 133
 		}
134 134
 
135 135
 		// Calendar settings handling.
136
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
136
+		if (is_admin() && ! defined('DOING_AJAX')) {
137 137
 			$admin = new Default_Calendar_Admin();
138 138
 			$this->settings = $admin->settings_fields();
139 139
 		}
@@ -147,49 +147,49 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @param  $view
149 149
 	 */
150
-	private function set_properties( $view ) {
150
+	private function set_properties($view) {
151 151
 
152 152
 		// Set styles.
153
-		if ( 'dark' == get_post_meta( $this->id, '_default_calendar_style_theme', true ) ) {
153
+		if ('dark' == get_post_meta($this->id, '_default_calendar_style_theme', true)) {
154 154
 			$this->theme = 'dark';
155 155
 		}
156
-		if ( $today_color = get_post_meta( $this->id, '_default_calendar_style_today', true ) ) {
157
-			$this->today_color = esc_attr( $today_color );
156
+		if ($today_color = get_post_meta($this->id, '_default_calendar_style_today', true)) {
157
+			$this->today_color = esc_attr($today_color);
158 158
 		}
159
-		if ( $day_events_color = get_post_meta( $this->id, '_default_calendar_style_days_events', true ) ) {
160
-			$this->days_events_color = esc_attr( $day_events_color );
159
+		if ($day_events_color = get_post_meta($this->id, '_default_calendar_style_days_events', true)) {
160
+			$this->days_events_color = esc_attr($day_events_color);
161 161
 		}
162 162
 
163 163
 		// Hide too many events.
164
-		if ( 'yes' == get_post_meta( $this->id, '_default_calendar_limit_visible_events', true ) ) {
165
-			$this->events_limit = absint( get_post_meta( $this->id, '_default_calendar_visible_events', true ) );
164
+		if ('yes' == get_post_meta($this->id, '_default_calendar_limit_visible_events', true)) {
165
+			$this->events_limit = absint(get_post_meta($this->id, '_default_calendar_visible_events', true));
166 166
 		}
167 167
 
168 168
 		// Expand multiple day events.
169
-		if ( 'yes' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) ) {
169
+		if ('yes' == get_post_meta($this->id, '_default_calendar_expand_multi_day_events', true)) {
170 170
 			$this->events = $this->expand_multiple_days_events();
171 171
 		}
172 172
 
173
-		if ( 'grid' == $view ) {
173
+		if ('grid' == $view) {
174 174
 
175 175
 			// Use hover to open event bubbles.
176
-			if ( 'hover' == get_post_meta( $this->id, '_default_calendar_event_bubble_trigger', true ) ) {
176
+			if ('hover' == get_post_meta($this->id, '_default_calendar_event_bubble_trigger', true)) {
177 177
 				$this->event_bubble_trigger = 'hover';
178 178
 			}
179 179
 
180 180
 			// Trim long event titles.
181
-			if ( 'yes' == get_post_meta( $this->id, '_default_calendar_trim_titles', true ) ) {
182
-				$this->trim_titles = max( absint( get_post_meta( $this->id, '_default_calendar_trim_titles_chars', true ) ), 1 );
181
+			if ('yes' == get_post_meta($this->id, '_default_calendar_trim_titles', true)) {
182
+				$this->trim_titles = max(absint(get_post_meta($this->id, '_default_calendar_trim_titles_chars', true)), 1);
183 183
 			}
184 184
 
185 185
 		} else {
186 186
 
187 187
 			// List range.
188
-			$this->group_type = esc_attr( get_post_meta( $this->id, '_default_calendar_list_range_type', true ) );
189
-			$this->group_span = max( absint( get_post_meta( $this->id, '_default_calendar_list_range_span', true ) ), 1 );
188
+			$this->group_type = esc_attr(get_post_meta($this->id, '_default_calendar_list_range_type', true));
189
+			$this->group_span = max(absint(get_post_meta($this->id, '_default_calendar_list_range_span', true)), 1);
190 190
 
191 191
 			// Make the list look more compact.
192
-			if ( 'yes' == get_post_meta( $this->id, '_default_calendar_compact_list', true ) ) {
192
+			if ('yes' == get_post_meta($this->id, '_default_calendar_compact_list', true)) {
193 193
 				$this->compact_list = true;
194 194
 			}
195 195
 
@@ -210,24 +210,24 @@  discard block
 block discarded – undo
210 210
 		$old_events = $this->events;
211 211
 		$new_events = array();
212 212
 
213
-		if ( ! empty( $old_events ) ) {
213
+		if ( ! empty($old_events)) {
214 214
 
215
-			foreach ( $old_events as $events ) {
216
-				foreach ( $events as $event ) {
217
-					if ( $event instanceof Event ) {
218
-						if ( false !== $event->multiple_days ) {
215
+			foreach ($old_events as $events) {
216
+				foreach ($events as $event) {
217
+					if ($event instanceof Event) {
218
+						if (false !== $event->multiple_days) {
219 219
 							$days = $event->multiple_days;
220 220
 
221
-							if ( $days == 1 ) {
222
-								$new_events[ intval( $event->start + ( DAY_IN_SECONDS ) - 1 ) ][] = $event;
221
+							if ($days == 1) {
222
+								$new_events[intval($event->start + (DAY_IN_SECONDS) - 1)][] = $event;
223 223
 							} else {
224 224
 
225 225
 								/*if ( ! empty( $event->whole_day ) ) {
226 226
 									$days--;
227 227
 								}*/
228 228
 
229
-								for ( $d = 1; $d <= $days; $d++ ) {
230
-									$new_events[ intval( $event->start + ( $d * DAY_IN_SECONDS ) - 1 ) ][] = $event;
229
+								for ($d = 1; $d <= $days; $d++) {
230
+									$new_events[intval($event->start + ($d * DAY_IN_SECONDS) - 1)][] = $event;
231 231
 								}
232 232
 							}
233 233
 						}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		}
240 240
 
241 241
 		$events = $old_events + $new_events;
242
-		ksort( $events, SORT_NUMERIC );
242
+		ksort($events, SORT_NUMERIC);
243 243
 		return $events;
244 244
 	}
245 245
 
@@ -254,16 +254,16 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @return null|Calendar_View
256 256
 	 */
257
-	public function get_view( $view = '' ) {
257
+	public function get_view($view = '') {
258 258
 
259
-		$view = ! empty( $view ) ? $view : 'grid';
259
+		$view = ! empty($view) ? $view : 'grid';
260 260
 
261
-		do_action( 'simcal_calendar_get_view', $this->type, $view );
261
+		do_action('simcal_calendar_get_view', $this->type, $view);
262 262
 
263
-		if ( 'grid' == $view ) {
264
-			return new Views\Default_Calendar_Grid( $this );
265
-		} elseif ( 'list' == $view ) {
266
-			return new Views\Default_Calendar_List( $this );
263
+		if ('grid' == $view) {
264
+			return new Views\Default_Calendar_Grid($this);
265
+		} elseif ('list' == $view) {
266
+			return new Views\Default_Calendar_List($this);
267 267
 		}
268 268
 
269 269
 		return null;
Please login to merge, or discard this patch.
includes/feeds/admin/google-admin.php 1 patch
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 use SimpleCalendar\Admin\Notice;
11 11
 use SimpleCalendar\Feeds\Google;
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param string $google_api_key
55 55
 	 * @param string $google_calendar_id
56 56
 	 */
57
-	public function __construct( Google $feed, $google_api_key, $google_calendar_id ) {
57
+	public function __construct(Google $feed, $google_api_key, $google_calendar_id) {
58 58
 
59 59
 		$this->feed = $feed;
60 60
 		$this->google_api_key = $google_api_key;
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 
63 63
 		$screen = simcal_is_admin_screen();
64 64
 
65
-		if ( 'calendar' == $screen ) {
66
-			$this->test_api_key_connection( $this->google_calendar_id );
67
-			add_filter( 'simcal_settings_meta_tabs_li', array( $this, 'add_settings_meta_tab_li' ), 10, 1 );
68
-			add_action( 'simcal_settings_meta_panels', array( $this, 'add_settings_meta_panel' ), 10, 1 );
65
+		if ('calendar' == $screen) {
66
+			$this->test_api_key_connection($this->google_calendar_id);
67
+			add_filter('simcal_settings_meta_tabs_li', array($this, 'add_settings_meta_tab_li'), 10, 1);
68
+			add_action('simcal_settings_meta_panels', array($this, 'add_settings_meta_panel'), 10, 1);
69 69
 		}
70 70
 
71
-		add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 );
71
+		add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1);
72 72
 	}
73 73
 
74 74
 	/**
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 	public function settings_fields() {
82 82
 		return array(
83 83
 			'name' => $this->feed->name,
84
-			'description' => __( "To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events' ) .
85
-			                 '<br/><br/>' .
86
-			                 '<em style="font-size: 14px;">' .
87
-			                 sprintf( __( '<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events' ),
88
-				                 simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'settings-link' )
89
-			                 ) .
84
+			'description' => __("To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events').
85
+			                 '<br/><br/>'.
86
+			                 '<em style="font-size: 14px;">'.
87
+			                 sprintf(__('<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events'),
88
+				                 simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'settings-link')
89
+			                 ).
90 90
 			                 '</em>',
91 91
 			'fields' => array(
92 92
 				'api_key' => array(
93 93
 					'type'       => 'standard',
94 94
 					'subtype'    => 'text',
95
-					'class'      => array( 'simcal-wide-text regular-text', 'ltr' ),
96
-					'title'      => __( 'Google API Key', 'google-calendar-events' ),
97
-					'validation' => array( $this, 'check_google_api_key' ),
95
+					'class'      => array('simcal-wide-text regular-text', 'ltr'),
96
+					'title'      => __('Google API Key', 'google-calendar-events'),
97
+					'validation' => array($this, 'check_google_api_key'),
98 98
 				),
99 99
 			),
100 100
 		);
@@ -113,27 +113,27 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return true|string
115 115
 	 */
116
-	public function check_google_api_key( $api_key = '' ) {
116
+	public function check_google_api_key($api_key = '') {
117 117
 
118 118
 		$message    = '';
119 119
 		$has_errors = false;
120 120
 
121
-		if ( empty( $api_key ) ){
121
+		if (empty($api_key)) {
122 122
 			$api_key = $this->google_api_key;
123
-			if ( empty( $api_key ) ) {
124
-				$settings = get_option( 'simple-calendar_settings_feeds' );
125
-				$api_key = isset( $settings['google']['api_key'] ) ? esc_attr( $settings['google']['api_key'] ) : '';
123
+			if (empty($api_key)) {
124
+				$settings = get_option('simple-calendar_settings_feeds');
125
+				$api_key = isset($settings['google']['api_key']) ? esc_attr($settings['google']['api_key']) : '';
126 126
 			}
127 127
 		}
128 128
 
129
-		$message = '<p class="description">' .
130
-				   sprintf( __( '<a href="%s" target="_blank">Step-by-step instructions</a> ', 'google-calendar-events' ),
131
-					   simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/google-api-key/', 'core-plugin', 'settings-link' )
132
-				   ) .
133
-				   '<br/>' .
134
-				   sprintf( __( '<a href="%s" target="_blank">Google Developers Console</a> ', 'google-calendar-events' ),
135
-					   simcal_get_url( 'gdev-console' )
136
-				   ) .
129
+		$message = '<p class="description">'.
130
+				   sprintf(__('<a href="%s" target="_blank">Step-by-step instructions</a> ', 'google-calendar-events'),
131
+					   simcal_ga_campaign_url(simcal_get_url('docs').'/google-api-key/', 'core-plugin', 'settings-link')
132
+				   ).
133
+				   '<br/>'.
134
+				   sprintf(__('<a href="%s" target="_blank">Google Developers Console</a> ', 'google-calendar-events'),
135
+					   simcal_get_url('gdev-console')
136
+				   ).
137 137
 				   '</p>';
138 138
 
139 139
 		return $message;
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return array
150 150
 	 */
151
-	public function add_settings_meta_tab_li( $tabs ) {
152
-		return array_merge( $tabs, array(
151
+	public function add_settings_meta_tab_li($tabs) {
152
+		return array_merge($tabs, array(
153 153
 			'google' => array(
154 154
 				'label'   => $this->feed->name,
155 155
 				'target'  => 'google-settings-panel',
156
-				'class'   => array( 'simcal-feed-type', 'simcal-feed-type-google' ),
156
+				'class'   => array('simcal-feed-type', 'simcal-feed-type-google'),
157 157
 				'icon'    => 'simcal-icon-google',
158 158
 			),
159
-		) );
159
+		));
160 160
 	}
161 161
 
162 162
 	/**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @param int $post_id
168 168
 	 */
169
-	public function add_settings_meta_panel( $post_id ) {
169
+	public function add_settings_meta_panel($post_id) {
170 170
 
171 171
 		$inputs = array(
172 172
 			$this->feed->type => array(
@@ -175,30 +175,30 @@  discard block
 block discarded – undo
175 175
 					'subtype'     => 'text',
176 176
 					'name'        => '_google_calendar_id',
177 177
 					'id'          => '_google_calendar_id',
178
-					'title'       => __( 'Calendar ID', 'google-calendar-events' ),
179
-					'tooltip'     => __( 'Visit your Google Calendar account, copy your public calendar ID, then paste it here.', 'google-calendar-events' ),
180
-					'placeholder' => __( 'Enter a valid Google Calendar ID from a public calendar', 'google-calendar-events' ),
181
-					'escaping'    => array( $this->feed, 'esc_google_calendar_id' ),
182
-					'validation'  => array( $this, 'test_api_key_connection' ),
178
+					'title'       => __('Calendar ID', 'google-calendar-events'),
179
+					'tooltip'     => __('Visit your Google Calendar account, copy your public calendar ID, then paste it here.', 'google-calendar-events'),
180
+					'placeholder' => __('Enter a valid Google Calendar ID from a public calendar', 'google-calendar-events'),
181
+					'escaping'    => array($this->feed, 'esc_google_calendar_id'),
182
+					'validation'  => array($this, 'test_api_key_connection'),
183 183
 				),
184 184
 				'_google_events_search_query' => array(
185 185
 					'type'        => 'standard',
186 186
 					'subtype'     => 'text',
187 187
 					'name'        => '_google_events_search_query',
188 188
 					'id'          => '_google_events_search_query',
189
-					'title'       => __( 'Search query', 'google-calendar-events' ),
190
-					'tooltip'     => __( 'Type in keywords if you only want display events that match these terms. You can use basic boolean search operators too.', 'google-calendar-events' ),
191
-					'placeholder' => __( 'Filter events to display by search terms...', 'google-calendar-events' ),
189
+					'title'       => __('Search query', 'google-calendar-events'),
190
+					'tooltip'     => __('Type in keywords if you only want display events that match these terms. You can use basic boolean search operators too.', 'google-calendar-events'),
191
+					'placeholder' => __('Filter events to display by search terms...', 'google-calendar-events'),
192 192
 				),
193 193
 				'_google_events_recurring' => array(
194 194
 					'type'    => 'select',
195 195
 					'name'    => '_google_events_recurring',
196 196
 					'id'      => '_google_events_recurring',
197
-					'title'   => __( 'Recurring events', 'google-calendar-events' ),
198
-					'tooltip' => __( 'Events that are programmed to repeat themselves periodically.', 'google-calendar-events' ),
197
+					'title'   => __('Recurring events', 'google-calendar-events'),
198
+					'tooltip' => __('Events that are programmed to repeat themselves periodically.', 'google-calendar-events'),
199 199
 					'options' => array(
200
-						'show' => __( 'Show all', 'google-calendar-events' ),
201
-						'first-only' => __( 'Only show first occurrence', 'google-calendar-events' ),
200
+						'show' => __('Show all', 'google-calendar-events'),
201
+						'first-only' => __('Only show first occurrence', 'google-calendar-events'),
202 202
 					),
203 203
 				),
204 204
 				'_google_events_max_results' => array(
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 					'subtype'     => 'number',
207 207
 					'name'        => '_google_events_max_results',
208 208
 					'id'          => '_google_events_max_results',
209
-					'title'       => __( 'Maximum Events', 'google-calendar-events' ),
210
-					'tooltip'     => __( 'Google Calendar only allows to query for a maximum amount of 2500 events from a calendar each time.', 'google-calendar-events' ),
209
+					'title'       => __('Maximum Events', 'google-calendar-events'),
210
+					'tooltip'     => __('Google Calendar only allows to query for a maximum amount of 2500 events from a calendar each time.', 'google-calendar-events'),
211 211
 					'class'       => array(
212 212
 						'simcal-field-small',
213 213
 					),
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 		<div id="google-settings-panel" class="simcal-panel">
225 225
 			<table>
226 226
 				<thead>
227
-					<tr><th colspan="2"><?php _e( 'Google Calendar settings', 'google-calendar-events' ); ?></th></tr>
227
+					<tr><th colspan="2"><?php _e('Google Calendar settings', 'google-calendar-events'); ?></th></tr>
228 228
 				</thead>
229
-				<?php Settings::print_panel_fields( $inputs, $post_id ); ?>
229
+				<?php Settings::print_panel_fields($inputs, $post_id); ?>
230 230
 			</table>
231 231
 		</div>
232 232
 		<?php
@@ -242,47 +242,47 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return true|string
244 244
 	 */
245
-	public function test_api_key_connection( $google_calendar_id ) {
245
+	public function test_api_key_connection($google_calendar_id) {
246 246
 
247 247
 		global $post;
248 248
 
249
-		$post_id = isset( $post->ID ) ? $post->ID : 0;
249
+		$post_id = isset($post->ID) ? $post->ID : 0;
250 250
 		$feed = null;
251
-		if ( $feed_type = wp_get_object_terms( $post_id, 'calendar_feed' ) ) {
252
-			$feed = sanitize_title( current( $feed_type )->name );
251
+		if ($feed_type = wp_get_object_terms($post_id, 'calendar_feed')) {
252
+			$feed = sanitize_title(current($feed_type)->name);
253 253
 		}
254 254
 
255 255
 		$message = '';
256 256
 		$error = '';
257 257
 		$has_errors = false;
258 258
 
259
-		$message .= '<p class="description">' .
259
+		$message .= '<p class="description">'.
260 260
 					sprintf(
261
-						__( 'Step 1: Set the Google Calendar you want to use as <strong>"public."</strong> <a href="%1s" target="_blank">Detailed instructions</a>', 'google-calendar-events' ) . '<br />' .
262
-						__( 'Step 2: Copy and paste your Google Calendar ID here. <a href="%2s" target="_blank">Detailed instructions</a>', 'google-calendar-events' ),
263
-						simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/make-google-calendar-public/', 'core-plugin', 'settings-link' ),
264
-						simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/find-google-calendar-id/', 'core-plugin', 'settings-link' )
265
-					) . '</p>';
261
+						__('Step 1: Set the Google Calendar you want to use as <strong>"public."</strong> <a href="%1s" target="_blank">Detailed instructions</a>', 'google-calendar-events').'<br />'.
262
+						__('Step 2: Copy and paste your Google Calendar ID here. <a href="%2s" target="_blank">Detailed instructions</a>', 'google-calendar-events'),
263
+						simcal_ga_campaign_url(simcal_get_url('docs').'/make-google-calendar-public/', 'core-plugin', 'settings-link'),
264
+						simcal_ga_campaign_url(simcal_get_url('docs').'/find-google-calendar-id/', 'core-plugin', 'settings-link')
265
+					).'</p>';
266 266
 
267
-		if ( $post_id > 0 && ! is_null( $feed ) && ! empty( $this->feed->type ) ) {
267
+		if ($post_id > 0 && ! is_null($feed) && ! empty($this->feed->type)) {
268 268
 
269
-			$no_key_notice = new Notice( array(
270
-					'id'          => array( 'calendar_' . $post_id => 'google-no-api-key' ),
269
+			$no_key_notice = new Notice(array(
270
+					'id'          => array('calendar_'.$post_id => 'google-no-api-key'),
271 271
 					'type'        => 'error',
272 272
 					'screen'      => 'calendar',
273 273
 					'post'        => $post_id,
274 274
 					'dismissable' => false,
275
-					'content'     => '<p>' .
276
-					                 '<i class="simcal-icon-warning"></i> ' .
275
+					'content'     => '<p>'.
276
+					                 '<i class="simcal-icon-warning"></i> '.
277 277
 					                 sprintf(
278
-						                 __( 'Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events' ),
279
-						                 admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds' )
280
-					                 ) .
278
+						                 __('Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events'),
279
+						                 admin_url('edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds')
280
+					                 ).
281 281
 					                 '</p>',
282 282
 				)
283 283
 			);
284 284
 
285
-			if ( empty( $this->google_api_key ) && ( $feed == $this->feed->type ) ) {
285
+			if (empty($this->google_api_key) && ($feed == $this->feed->type)) {
286 286
 
287 287
 				$has_errors = true;
288 288
 				$no_key_notice->add();
@@ -292,28 +292,28 @@  discard block
 block discarded – undo
292 292
 				$no_key_notice->remove();
293 293
 
294 294
 				try {
295
-					$this->feed->make_request( $google_calendar_id );
296
-				} catch ( \Exception $e ) {
295
+					$this->feed->make_request($google_calendar_id);
296
+				} catch (\Exception $e) {
297 297
 					$error   = $e->getMessage();
298
-					$message = ! empty( $error ) ? '<blockquote>' . $error . '</blockquote>' : '';
298
+					$message = ! empty($error) ? '<blockquote>'.$error.'</blockquote>' : '';
299 299
 				}
300 300
 
301
-				$error_notice = new Notice( array(
302
-						'id'          => array( 'calendar_' . $post_id => 'google-error-response' ),
301
+				$error_notice = new Notice(array(
302
+						'id'          => array('calendar_'.$post_id => 'google-error-response'),
303 303
 						'type'        => 'error',
304 304
 						'screen'      => 'calendar',
305 305
 						'post'        => $post_id,
306 306
 						'dismissable' => false,
307
-						'content'     => '<p>' .
308
-						                 '<i class="simcal-icon-warning"></i> ' .
309
-						                 __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' ) .
310
-						                 '<br>' . $message . '<br>' .
311
-						                 __( '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' ) .
307
+						'content'     => '<p>'.
308
+						                 '<i class="simcal-icon-warning"></i> '.
309
+						                 __('While trying to retrieve events, Google returned an error:', 'google-calendar-events').
310
+						                 '<br>'.$message.'<br>'.
311
+						                 __('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').
312 312
 						                 '</p>',
313 313
 					)
314 314
 				);
315 315
 
316
-				if ( ! empty( $error ) && ( $feed == $this->feed->type ) ) {
316
+				if ( ! empty($error) && ($feed == $this->feed->type)) {
317 317
 					$error_notice->add();
318 318
 					$has_errors = true;
319 319
 				} else {
@@ -335,21 +335,21 @@  discard block
 block discarded – undo
335 335
 	 *
336 336
 	 * @param int $post_id
337 337
 	 */
338
-	public function process_meta( $post_id ) {
338
+	public function process_meta($post_id) {
339 339
 
340
-		$calendar_id = isset( $_POST['_google_calendar_id'] ) ? base64_encode( trim( $_POST['_google_calendar_id'] ) ): '';
341
-		update_post_meta( $post_id, '_google_calendar_id', $calendar_id );
340
+		$calendar_id = isset($_POST['_google_calendar_id']) ? base64_encode(trim($_POST['_google_calendar_id'])) : '';
341
+		update_post_meta($post_id, '_google_calendar_id', $calendar_id);
342 342
 
343
-		$search_query = isset( $_POST['_google_events_search_query'] ) ? sanitize_text_field( $_POST['_google_events_search_query'] ) : '';
344
-		update_post_meta( $post_id, '_google_events_search_query', $search_query );
343
+		$search_query = isset($_POST['_google_events_search_query']) ? sanitize_text_field($_POST['_google_events_search_query']) : '';
344
+		update_post_meta($post_id, '_google_events_search_query', $search_query);
345 345
 
346
-		$recurring = isset( $_POST['_google_events_recurring'] ) ? sanitize_key( $_POST['_google_events_recurring'] ) : 'show';
347
-		update_post_meta( $post_id, '_google_events_recurring', $recurring );
346
+		$recurring = isset($_POST['_google_events_recurring']) ? sanitize_key($_POST['_google_events_recurring']) : 'show';
347
+		update_post_meta($post_id, '_google_events_recurring', $recurring);
348 348
 
349
-		$max_results = isset( $_POST['_google_events_max_results'] ) ? absint( $_POST['_google_events_max_results'] ) : '2500';
350
-		update_post_meta( $post_id, '_google_events_max_results', $max_results );
349
+		$max_results = isset($_POST['_google_events_max_results']) ? absint($_POST['_google_events_max_results']) : '2500';
350
+		update_post_meta($post_id, '_google_events_max_results', $max_results);
351 351
 
352
-		$this->test_api_key_connection( $calendar_id );
352
+		$this->test_api_key_connection($calendar_id);
353 353
 	}
354 354
 
355 355
 }
Please login to merge, or discard this patch.
includes/functions/shared.php 1 patch
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @package SimpleCalendar/Functions
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
@@ -20,17 +20,17 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function is_simple_calendar() {
22 22
 
23
-	if ( is_singular() ) {
23
+	if (is_singular()) {
24 24
 
25 25
 		global $post, $post_type;
26 26
 
27
-		if ( 'calendar' == $post_type ) {
27
+		if ('calendar' == $post_type) {
28 28
 			return true;
29 29
 		} else {
30
-			if ( false !== get_post_meta( $post->ID, '_simcal_attach_calendar_id', true ) ) {
30
+			if (false !== get_post_meta($post->ID, '_simcal_attach_calendar_id', true)) {
31 31
 				return true;
32 32
 			}
33
-			if ( has_shortcode( $post->post_content, 'calendar' ) ) {
33
+			if (has_shortcode($post->post_content, 'calendar')) {
34 34
 				return true;
35 35
 			}
36 36
 		}
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return string
48 48
  */
49
-function simcal_get_url( $url ) {
50
-	return \SimpleCalendar\plugin()->get_url( $url );
49
+function simcal_get_url($url) {
50
+	return \SimpleCalendar\plugin()->get_url($url);
51 51
 }
52 52
 
53 53
 /**
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
  *
72 72
  * @return null|\SimpleCalendar\Abstracts\Feed
73 73
  */
74
-function simcal_get_feed( $object ) {
74
+function simcal_get_feed($object) {
75 75
 	$objects = \SimpleCalendar\plugin()->objects;
76
-	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_feed( $object ) : null;
76
+	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_feed($object) : null;
77 77
 }
78 78
 
79 79
 /**
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
  *
98 98
  * @return null|\SimpleCalendar\Abstracts\Calendar
99 99
  */
100
-function simcal_get_calendar( $object ) {
100
+function simcal_get_calendar($object) {
101 101
 	$objects = \SimpleCalendar\plugin()->objects;
102
-	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar( $object ) : null;
102
+	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar($object) : null;
103 103
 }
104 104
 
105 105
 /**
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
  *
113 113
  * @return mixed
114 114
  */
115
-function simcal_get_calendar_view( $id = 0, $name = '' ) {
115
+function simcal_get_calendar_view($id = 0, $name = '') {
116 116
 	$objects = \SimpleCalendar\plugin()->objects;
117
-	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar_view( $id, $name ) : false;
117
+	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_calendar_view($id, $name) : false;
118 118
 }
119 119
 
120 120
 /**
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
  *
127 127
  * @return void
128 128
  */
129
-function simcal_print_calendar( $object ) {
129
+function simcal_print_calendar($object) {
130 130
 
131
-	$calendar = simcal_get_calendar( $object );
131
+	$calendar = simcal_get_calendar($object);
132 132
 
133
-	if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) {
133
+	if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) {
134 134
 		$calendar->html();
135 135
 	}
136 136
 }
@@ -148,21 +148,21 @@  discard block
 block discarded – undo
148 148
 
149 149
 	$vars = array(
150 150
 		'ajax_url'  => \SimpleCalendar\plugin()->ajax_url(),
151
-		'nonce'     => wp_create_nonce( 'simcal' ),
151
+		'nonce'     => wp_create_nonce('simcal'),
152 152
 		'locale'    => \SimpleCalendar\plugin()->locale,
153 153
 		'text_dir'  => is_rtl() ? 'rtl' : 'ltr',
154 154
 		'months'    => array(
155
-			'full'  => simcal_get_calendar_names_i18n( 'month', 'full' ),
156
-			'short' => simcal_get_calendar_names_i18n( 'month', 'short' ),
155
+			'full'  => simcal_get_calendar_names_i18n('month', 'full'),
156
+			'short' => simcal_get_calendar_names_i18n('month', 'short'),
157 157
 		),
158 158
 		'days'      => array(
159
-			'full'  => simcal_get_calendar_names_i18n( 'day', 'full' ),
160
-			'short' => simcal_get_calendar_names_i18n( 'day', 'short' ),
159
+			'full'  => simcal_get_calendar_names_i18n('day', 'full'),
160
+			'short' => simcal_get_calendar_names_i18n('day', 'short'),
161 161
 		),
162
-		'meridiem' => simcal_get_calendar_names_i18n( 'meridiem' ),
162
+		'meridiem' => simcal_get_calendar_names_i18n('meridiem'),
163 163
 	);
164 164
 
165
-	return array_merge( $vars, apply_filters( 'simcal_common_scripts_variables', array() ) );
165
+	return array_merge($vars, apply_filters('simcal_common_scripts_variables', array()));
166 166
 }
167 167
 
168 168
 /**
@@ -175,31 +175,31 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return array Associative array with ids as keys and feed titles as values.
177 177
  */
178
-function simcal_get_calendars( $exclude = '', $cached = true ) {
178
+function simcal_get_calendars($exclude = '', $cached = true) {
179 179
 
180
-	$calendars = get_transient( '_simple-calendar_feed_ids' );
180
+	$calendars = get_transient('_simple-calendar_feed_ids');
181 181
 
182
-	if ( ! $calendars || $cached === false ) {
182
+	if ( ! $calendars || $cached === false) {
183 183
 
184
-		$posts = get_posts( array(
184
+		$posts = get_posts(array(
185 185
 			'post_type' => 'calendar',
186 186
 			'nopaging'  => true,
187
-		) );
187
+		));
188 188
 
189 189
 		$calendars = array();
190
-		foreach ( $posts as $post ) {
191
-			$calendars[ $post->ID ] = $post->post_title;
190
+		foreach ($posts as $post) {
191
+			$calendars[$post->ID] = $post->post_title;
192 192
 		}
193
-		asort( $calendars );
193
+		asort($calendars);
194 194
 
195
-		set_transient( '_simple-calendar_feed_ids', $calendars, 604800 );
195
+		set_transient('_simple-calendar_feed_ids', $calendars, 604800);
196 196
 	}
197 197
 
198
-	if ( ! empty( $exclude ) ) {
199
-		if ( is_numeric( $exclude ) ) {
200
-			unset( $calendars[ intval( $exclude ) ] );
201
-		} elseif ( is_array( $exclude ) ) {
202
-			array_diff_key( $calendars, array_map( 'intval', array_keys( $exclude ) ) );
198
+	if ( ! empty($exclude)) {
199
+		if (is_numeric($exclude)) {
200
+			unset($calendars[intval($exclude)]);
201
+		} elseif (is_array($exclude)) {
202
+			array_diff_key($calendars, array_map('intval', array_keys($exclude)));
203 203
 		}
204 204
 	}
205 205
 
@@ -218,45 +218,45 @@  discard block
 block discarded – undo
218 218
  *
219 219
  * @return array
220 220
  */
221
-function simcal_get_calendar_names_i18n( $group, $style = 'full' ) {
221
+function simcal_get_calendar_names_i18n($group, $style = 'full') {
222 222
 
223 223
 	$names = array();
224 224
 
225
-	if ( in_array( $group, array( 'month', 'day', 'meridiem' ) ) ) {
225
+	if (in_array($group, array('month', 'day', 'meridiem'))) {
226 226
 
227 227
 		$format = '';
228 228
 		$length = 0;
229 229
 
230 230
 		$date = Carbon\Carbon::now();
231 231
 
232
-		if ( 'month' == $group ) {
233
-			$date->month( 0 )->startOfMonth();
232
+		if ('month' == $group) {
233
+			$date->month(0)->startOfMonth();
234 234
 			$format = 'short' == $style ? 'M' : 'F';
235 235
 			$length = 11;
236
-		} elseif ( 'day' == $group ) {
237
-			$date->next( 6 );
236
+		} elseif ('day' == $group) {
237
+			$date->next(6);
238 238
 			$format = 'short' == $style ? 'D' : 'l';
239 239
 			$length = 6;
240
-		} elseif ( 'meridiem' == $group ) {
240
+		} elseif ('meridiem' == $group) {
241 241
 			$date->startOfDay();
242
-			$am = $date->addHour( 1 )->getTimestamp();
243
-			$pm = $date->addHours( 13 )->getTimestamp();
242
+			$am = $date->addHour(1)->getTimestamp();
243
+			$pm = $date->addHours(13)->getTimestamp();
244 244
 			return array(
245
-				'AM' => date_i18n( 'A', $am ),
246
-				'am' => date_i18n( 'a', $am ),
247
-				'PM' => date_i18n( 'A', $pm ),
248
-				'pm' => date_i18n( 'a', $pm ),
245
+				'AM' => date_i18n('A', $am),
246
+				'am' => date_i18n('a', $am),
247
+				'PM' => date_i18n('A', $pm),
248
+				'pm' => date_i18n('a', $pm),
249 249
 			);
250 250
 		}
251 251
 
252 252
 		$i = 0;
253
-		while ( $i <= $length ) {
254
-			if ( 'month' == $group ) {
255
-				$date->addMonths( 1 );
253
+		while ($i <= $length) {
254
+			if ('month' == $group) {
255
+				$date->addMonths(1);
256 256
 			} else {
257
-				$date->addDays( 1 );
257
+				$date->addDays(1);
258 258
 			}
259
-			$names[ strval( $i ) ] = date_i18n( $format, $date->getTimestamp() );
259
+			$names[strval($i)] = date_i18n($format, $date->getTimestamp());
260 260
 			$i++;
261 261
 		}
262 262
 
@@ -274,15 +274,15 @@  discard block
 block discarded – undo
274 274
  */
275 275
 function simcal_default_event_template() {
276 276
 
277
-	$content  = '<strong>' . '[title]' . '</strong>';
277
+	$content  = '<strong>'.'[title]'.'</strong>';
278 278
 	$content .= '<p>';
279
-	$content .= '[when]' . "\n";
279
+	$content .= '[when]'."\n";
280 280
 	$content .= '[location]';
281 281
 	$content .= '</p>';
282
-	$content .= '<div>' . '[description]' . '</div>';
283
-	$content .= '<p>' . '[link newwindow="yes"]' . __( 'See more details', 'google-calendar-events' ) . '[/link]' . '</p>';
282
+	$content .= '<div>'.'[description]'.'</div>';
283
+	$content .= '<p>'.'[link newwindow="yes"]'.__('See more details', 'google-calendar-events').'[/link]'.'</p>';
284 284
 
285
-	return apply_filters( 'simcal_default_event_template', $content );
285
+	return apply_filters('simcal_default_event_template', $content);
286 286
 }
287 287
 
288 288
 /**
@@ -297,21 +297,21 @@  discard block
 block discarded – undo
297 297
  *
298 298
  * @return array
299 299
  */
300
-function simcal_get_date_format_order( $date_format ) {
300
+function simcal_get_date_format_order($date_format) {
301 301
 
302 302
 	$pos = array(
303
-		'd' => strpos( $date_format, strpbrk( $date_format, 'Dj' ) ),
304
-		'm' => strpos( $date_format, strpbrk( $date_format, 'FMmn' ) ),
305
-		'y' => strpos( $date_format, strpbrk( $date_format, 'Yy' ) ),
303
+		'd' => strpos($date_format, strpbrk($date_format, 'Dj')),
304
+		'm' => strpos($date_format, strpbrk($date_format, 'FMmn')),
305
+		'y' => strpos($date_format, strpbrk($date_format, 'Yy')),
306 306
 	);
307 307
 
308 308
 	// @TODO When one date piece is not found, perhaps fallback to ISO standard position.
309 309
 
310 310
 	$order = array();
311
-	foreach ( $pos as $k => $v ) {
312
-		$order[ $k ] = $v;
311
+	foreach ($pos as $k => $v) {
312
+		$order[$k] = $v;
313 313
 	}
314
-	ksort( $order );
314
+	ksort($order);
315 315
 
316 316
 	return $order;
317 317
 }
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
  */
328 328
 function simcal_get_wp_timezone() {
329 329
 
330
-	$timezone = get_option( 'timezone_string' );
330
+	$timezone = get_option('timezone_string');
331 331
 
332
-	if ( empty( $timezone ) ) {
333
-		$gmt = get_option( 'gmt_offset' );
334
-		$timezone = simcal_get_timezone_from_gmt_offset( $gmt );
332
+	if (empty($timezone)) {
333
+		$gmt = get_option('gmt_offset');
334
+		$timezone = simcal_get_timezone_from_gmt_offset($gmt);
335 335
 	}
336 336
 
337 337
 	return $timezone;
@@ -348,26 +348,26 @@  discard block
 block discarded – undo
348 348
  *
349 349
  * @return null|string
350 350
  */
351
-function simcal_get_timezone_from_gmt_offset( $offset ) {
351
+function simcal_get_timezone_from_gmt_offset($offset) {
352 352
 
353
-	if ( is_numeric( $offset ) ) {
353
+	if (is_numeric($offset)) {
354 354
 
355
-		if ( 0 === intval( $offset ) ) {
355
+		if (0 === intval($offset)) {
356 356
 			return 'UTC';
357 357
 		} else {
358
-			$offset = floatval( $offset ) * 3600;
358
+			$offset = floatval($offset) * 3600;
359 359
 		}
360 360
 
361
-		$timezone = timezone_name_from_abbr( null, $offset, false );
361
+		$timezone = timezone_name_from_abbr(null, $offset, false);
362 362
 		// This is buggy and might return false:
363 363
 		// @see http://php.net/manual/en/function.timezone-name-from-abbr.php#86928
364 364
 		// Therefore:
365
-		if ( false == $timezone ) {
365
+		if (false == $timezone) {
366 366
 
367 367
 			$list = timezone_abbreviations_list();
368
-			foreach ( $list as $abbr ) {
369
-				foreach ( $abbr as $city ) {
370
-					if ( $offset == $city['offset'] ) {
368
+			foreach ($list as $abbr) {
369
+				foreach ($abbr as $city) {
370
+					if ($offset == $city['offset']) {
371 371
 						return $city['timezone_id'];
372 372
 					}
373 373
 				}
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
  *
391 391
  * @return int Unix time offset
392 392
  */
393
-function simcal_get_timezone_offset( $timezone ) {
394
-	return \Carbon\Carbon::now( $timezone )->offset;
393
+function simcal_get_timezone_offset($timezone) {
394
+	return \Carbon\Carbon::now($timezone)->offset;
395 395
 }
396 396
 
397 397
 /**
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
  *
405 405
  * @return mixed|string
406 406
  */
407
-function simcal_esc_timezone( $tz, $default = 'UTC' ) {
408
-	return in_array( $tz, timezone_identifiers_list() ) ? $tz : $default;
407
+function simcal_esc_timezone($tz, $default = 'UTC') {
408
+	return in_array($tz, timezone_identifiers_list()) ? $tz : $default;
409 409
 }
410 410
 
411 411
 /**
@@ -417,57 +417,57 @@  discard block
 block discarded – undo
417 417
  *
418 418
  * @return bool
419 419
  */
420
-function simcal_delete_feed_transients( $id = '' ) {
420
+function simcal_delete_feed_transients($id = '') {
421 421
 
422
-	$grouped_ids = get_post_meta( $id, '_grouped_calendars_ids', true );
422
+	$grouped_ids = get_post_meta($id, '_grouped_calendars_ids', true);
423 423
 
424 424
 	// If there are group IDs we need to construct an array to pass along with the grouped IDs + the original $post_id
425
-	if ( is_array( $grouped_ids ) ) {
425
+	if (is_array($grouped_ids)) {
426 426
 		$temp_id = $id;
427 427
 		$id = $grouped_ids;
428 428
 		$id[] = $temp_id;
429 429
 	}
430 430
 
431
-	if ( is_numeric( $id ) ) {
432
-		$id = intval( $id ) > 0 ? absint( $id ) : simcal_get_calendars();
433
-	} elseif ( $id instanceof WP_Post ) {
431
+	if (is_numeric($id)) {
432
+		$id = intval($id) > 0 ? absint($id) : simcal_get_calendars();
433
+	} elseif ($id instanceof WP_Post) {
434 434
 		$id = $id->ID;
435
-	} elseif ( is_array( $id ) ) {
436
-		$id = array_map( 'absint', $id );
435
+	} elseif (is_array($id)) {
436
+		$id = array_map('absint', $id);
437 437
 	} else {
438
-		$id = simcal_get_calendars( '', true );
438
+		$id = simcal_get_calendars('', true);
439 439
 	}
440 440
 
441 441
 	$feed_types = simcal_get_feed_types();
442 442
 
443
-	if ( is_array( $id ) ) {
443
+	if (is_array($id)) {
444 444
 
445
-		$posts = get_posts( array(
445
+		$posts = get_posts(array(
446 446
 				'post_type' => 'calendar',
447 447
 				'fields'    => 'ids',
448 448
 				'post__in'  => $id,
449 449
 				'nopaging'  => true,
450
-		) );
450
+		));
451 451
 
452
-		foreach ( $posts as $post ) {
453
-			$calendar = simcal_get_calendar( $post );
454
-			if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) {
455
-				foreach ( $feed_types as $feed_type ) {
456
-					delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type );
452
+		foreach ($posts as $post) {
453
+			$calendar = simcal_get_calendar($post);
454
+			if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) {
455
+				foreach ($feed_types as $feed_type) {
456
+					delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type);
457 457
 				}
458 458
 			}
459 459
 		}
460 460
 
461 461
 	} else {
462 462
 
463
-		$post = get_post( $id );
464
-		$calendar = simcal_get_calendar( $post );
465
-		if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) {
466
-			foreach ( $feed_types as $feed_type ) {
467
-				delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type );
463
+		$post = get_post($id);
464
+		$calendar = simcal_get_calendar($post);
465
+		if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) {
466
+			foreach ($feed_types as $feed_type) {
467
+				delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type);
468 468
 			}
469 469
 		}
470 470
 	}
471 471
 
472
-	return delete_transient( '_simple-calendar_feed_ids' );
472
+	return delete_transient('_simple-calendar_feed_ids');
473 473
 }
474 474
\ No newline at end of file
Please login to merge, or discard this patch.
includes/functions/admin.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @package SimpleCalendar/Admin/Functions
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @return null|\SimpleCalendar\Abstracts\Admin_Page
34 34
  */
35
-function simcal_get_admin_page( $page ) {
35
+function simcal_get_admin_page($page) {
36 36
 	$objects = \SimpleCalendar\plugin()->objects;
37
-	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page( $page ) : null;
37
+	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page($page) : null;
38 38
 }
39 39
 
40 40
 /**
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
  *
48 48
  * @return null|\SimpleCalendar\Abstracts\Field
49 49
  */
50
-function simcal_get_field( $args, $name = '' ) {
50
+function simcal_get_field($args, $name = '') {
51 51
 	$objects = \SimpleCalendar\plugin()->objects;
52
-	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field( $args, $name ) : null;
52
+	return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field($args, $name) : null;
53 53
 }
54 54
 
55 55
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
  *
63 63
  * @return void
64 64
  */
65
-function simcal_print_field( $args, $name = '' ) {
65
+function simcal_print_field($args, $name = '') {
66 66
 
67
-	$field = simcal_get_field( $args, $name );
67
+	$field = simcal_get_field($args, $name);
68 68
 
69
-	if ( $field instanceof \SimpleCalendar\Abstracts\Field ) {
69
+	if ($field instanceof \SimpleCalendar\Abstracts\Field) {
70 70
 		$field->html();
71 71
 	}
72 72
 }
@@ -84,33 +84,33 @@  discard block
 block discarded – undo
84 84
  *
85 85
  * @return array|string Sanitized variable
86 86
  */
87
-function simcal_sanitize_input( $var, $func = 'sanitize_text_field'  ) {
87
+function simcal_sanitize_input($var, $func = 'sanitize_text_field') {
88 88
 
89
-	if ( is_null( $var ) ) {
89
+	if (is_null($var)) {
90 90
 		return '';
91 91
 	}
92 92
 
93
-	if ( is_bool( $var ) ) {
94
-		if ( $var === true ) {
93
+	if (is_bool($var)) {
94
+		if ($var === true) {
95 95
 			return 'yes';
96 96
 		} else {
97 97
 			return 'no';
98 98
 		}
99 99
 	}
100 100
 
101
-	if ( is_string( $var ) || is_numeric( $var ) ) {
102
-		$func = is_string( $func ) && function_exists( $func ) ? $func : 'sanitize_text_field';
103
-		return call_user_func( $func, trim( strval( $var ) ) );
101
+	if (is_string($var) || is_numeric($var)) {
102
+		$func = is_string($func) && function_exists($func) ? $func : 'sanitize_text_field';
103
+		return call_user_func($func, trim(strval($var)));
104 104
 	}
105 105
 
106
-	if ( is_object( $var ) ) {
106
+	if (is_object($var)) {
107 107
 		$var = (array) $var;
108 108
 	}
109 109
 
110
-	if ( is_array( $var ) ) {
110
+	if (is_array($var)) {
111 111
 		$array = array();
112
-		foreach ( $var as $k => $v ) {
113
-			$array[ $k ] = simcal_sanitize_input( $v );
112
+		foreach ($var as $k => $v) {
113
+			$array[$k] = simcal_sanitize_input($v);
114 114
 		}
115 115
 		return $array;
116 116
 	}
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
  */
129 129
 function simcal_is_admin_screen() {
130 130
 
131
-	$view = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
131
+	$view = function_exists('get_current_screen') ? get_current_screen() : false;
132 132
 
133
-	if ( $view instanceof WP_Screen ) {
133
+	if ($view instanceof WP_Screen) {
134 134
 
135 135
 		// Screens used by this plugin.
136 136
 		$screens = array(
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			'dashboard_page_simple-calendar_credits',
146 146
 			'dashboard_page_simple-calendar_translators',
147 147
 		);
148
-		if ( in_array( $view->id, $screens ) ) {
148
+		if (in_array($view->id, $screens)) {
149 149
 			return $view->id;
150 150
 		}
151 151
 	}
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
  *
165 165
  * @return \SimpleCalendar\Admin\Updater
166 166
  */
167
-function simcal_addon_updater( $_api_url, $_plugin_file, $_api_data = null ) {
168
-	return new \SimpleCalendar\Admin\Updater( $_api_url, $_plugin_file, $_api_data );
167
+function simcal_addon_updater($_api_url, $_plugin_file, $_api_data = null) {
168
+	return new \SimpleCalendar\Admin\Updater($_api_url, $_plugin_file, $_api_data);
169 169
 }
170 170
 
171 171
 /**
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
  *
178 178
  * @return null|string
179 179
  */
180
-function simcal_get_license_key( $addon ) {
181
-	$licenses = get_option( 'simple-calendar_settings_licenses', array() );
182
-	if ( isset( $licenses['keys'][ $addon ] ) ) {
183
-		return empty( $licenses['keys'][ $addon ] ) ? null : $licenses['keys'][ $addon ];
180
+function simcal_get_license_key($addon) {
181
+	$licenses = get_option('simple-calendar_settings_licenses', array());
182
+	if (isset($licenses['keys'][$addon])) {
183
+		return empty($licenses['keys'][$addon]) ? null : $licenses['keys'][$addon];
184 184
 	}
185 185
 	return null;
186 186
 }
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return array|string
198 198
  */
199
-function simcal_get_license_status( $addon = null ) {
200
-	$licenses = get_option( 'simple-calendar_licenses_status', array() );
201
-	return isset( $licenses[ $addon ] ) ? $licenses[ $addon ] : $licenses;
199
+function simcal_get_license_status($addon = null) {
200
+	$licenses = get_option('simple-calendar_licenses_status', array());
201
+	return isset($licenses[$addon]) ? $licenses[$addon] : $licenses;
202 202
 }
203 203
 
204 204
 /**
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
  * @since 3.0.0
220 220
  */
221 221
 function simcal_delete_admin_notices() {
222
-	delete_option( 'simple-calendar_admin_notices' );
222
+	delete_option('simple-calendar_admin_notices');
223 223
 }
224 224
 
225 225
 /**
@@ -231,22 +231,22 @@  discard block
 block discarded – undo
231 231
  *
232 232
  * @return void
233 233
  */
234
-function simcal_print_shortcode_tip( $post_id ) {
234
+function simcal_print_shortcode_tip($post_id) {
235 235
 
236 236
 	$browser = new \Browser();
237
-	if ( $browser::PLATFORM_APPLE == $browser->getPlatform() ) {
237
+	if ($browser::PLATFORM_APPLE == $browser->getPlatform()) {
238 238
 		$cmd = '&#8984;&#43;C';
239 239
 	} else {
240 240
 		$cmd = 'Ctrl&#43;C';
241 241
 	}
242 242
 
243
-	$shortcut  = sprintf( __( 'Press %s to copy.', 'google-calendar-events' ), $cmd );
244
-	$shortcode = sprintf( '[calendar id="%s"]', $post_id );
243
+	$shortcut  = sprintf(__('Press %s to copy.', 'google-calendar-events'), $cmd);
244
+	$shortcode = sprintf('[calendar id="%s"]', $post_id);
245 245
 
246
-	echo "<input readonly='readonly' " .
247
-				"class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' " .
248
-				"title='" . $shortcut . "' " .
249
-				"onclick='this.select();' value='" . $shortcode . "' />";
246
+	echo "<input readonly='readonly' ".
247
+				"class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' ".
248
+				"title='".$shortcut."' ".
249
+				"onclick='this.select();' value='".$shortcode."' />";
250 250
 }
251 251
 
252 252
 /**
@@ -261,20 +261,20 @@  discard block
 block discarded – undo
261 261
  *
262 262
  * @return  string  $url        Full Google Analytics campaign URL
263 263
  */
264
-function simcal_ga_campaign_url( $base_url, $campaign, $content, $raw = false ) {
264
+function simcal_ga_campaign_url($base_url, $campaign, $content, $raw = false) {
265 265
 
266
-	$url = add_query_arg( array(
266
+	$url = add_query_arg(array(
267 267
 		'utm_source'   => 'inside-plugin',
268 268
 		'utm_medium'   => 'link',
269 269
 		'utm_campaign' => $campaign, // i.e. 'core-plugin', 'gcal-pro'
270 270
 		'utm_content'  => $content // i.e. 'sidebar-link', 'settings-link'
271
-	), $base_url );
271
+	), $base_url);
272 272
 
273
-	if ( $raw ) {
274
-		return esc_url_raw( $url );
273
+	if ($raw) {
274
+		return esc_url_raw($url);
275 275
 	}
276 276
 
277
-	return esc_url( $url );
277
+	return esc_url($url);
278 278
 }
279 279
 
280 280
 /**
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
  */
287 287
 function simcal_newsletter_signup() {
288 288
 
289
-	if ( $screen = simcal_is_admin_screen() ) {
289
+	if ($screen = simcal_is_admin_screen()) {
290 290
 
291 291
 		global $current_user;
292 292
 		get_currentuserinfo();
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 		<div id="simcal-drip" class="<?php echo $screen; ?>">
298 298
 			<div class="signup">
299 299
 				<p>
300
-					<?php _e( "Enter your name and email and we'll send you a coupon code for 20% off our Google Calendar Pro add-on.", 'google-calendar-events' ); ?>
300
+					<?php _e("Enter your name and email and we'll send you a coupon code for 20% off our Google Calendar Pro add-on.", 'google-calendar-events'); ?>
301 301
 				</p>
302 302
 
303 303
 				<p>
304
-					<label for="simcal-drip-field-email"><?php _e( 'Your Email', 'google-calendar-events' ); ?></label><br />
304
+					<label for="simcal-drip-field-email"><?php _e('Your Email', 'google-calendar-events'); ?></label><br />
305 305
 					<input type="email"
306 306
 					       id="simcal-drip-field-email"
307 307
 					       name="fields[email]"
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 				</p>
310 310
 
311 311
 				<p>
312
-					<label for="simcal-drip-field-first_name"><?php _e( 'First Name', 'google-calendar-events' ); ?></label><br />
312
+					<label for="simcal-drip-field-first_name"><?php _e('First Name', 'google-calendar-events'); ?></label><br />
313 313
 					<input type="text"
314 314
 					       id="simcal-drip-field-first_name"
315 315
 					       name="fields[first_name]"
@@ -318,15 +318,15 @@  discard block
 block discarded – undo
318 318
 				<p class="textright">
319 319
 					<a href="#"
320 320
 					   id="simcal-drip-signup"
321
-					   class="button button-primary"><?php _e( 'Send me the coupon', 'google-calendar-events' ); ?></a>
321
+					   class="button button-primary"><?php _e('Send me the coupon', 'google-calendar-events'); ?></a>
322 322
 				</p>
323 323
 				<div class="textright">
324
-					<a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'sidebar-link' ); ?>"
325
-					   target="_blank"><?php _e( 'Just take me to GCal Pro', 'google-calendar-events' ); ?></a>
324
+					<a href="<?php echo simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'sidebar-link'); ?>"
325
+					   target="_blank"><?php _e('Just take me to GCal Pro', 'google-calendar-events'); ?></a>
326 326
 				</div>
327 327
 			</div>
328 328
 			<div class="thank-you" style="display: none;">
329
-				<?php _e( 'Thank you!', 'google-calendar-events' ); ?>
329
+				<?php _e('Thank you!', 'google-calendar-events'); ?>
330 330
 			</div>
331 331
 			<div class="clear">
332 332
 			</div>
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
 }
339 339
 
340
-if ( ! function_exists( 'mb_detect_encoding' ) ) {
340
+if ( ! function_exists('mb_detect_encoding')) {
341 341
 
342 342
 	/**
343 343
 	 * Fallback function for `mb_detect_encoding()`,
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @return bool
353 353
 	 */
354
-	function mb_detect_encoding( $string, $enc = null, $ret = null ) {
354
+	function mb_detect_encoding($string, $enc = null, $ret = null) {
355 355
 
356 356
 		static $enclist = array(
357 357
 			'UTF-8',
@@ -377,10 +377,10 @@  discard block
 block discarded – undo
377 377
 
378 378
 		$result = false;
379 379
 
380
-		foreach ( $enclist as $item ) {
381
-			$sample = iconv( $item, $item, $string );
382
-			if ( md5( $sample ) == md5( $string ) ) {
383
-				if ( $ret === null ) {
380
+		foreach ($enclist as $item) {
381
+			$sample = iconv($item, $item, $string);
382
+			if (md5($sample) == md5($string)) {
383
+				if ($ret === null) {
384 384
 					$result = $item;
385 385
 				} else {
386 386
 					$result = true;
Please login to merge, or discard this patch.
includes/calendars/views/default-calendar-grid.php 1 patch
Spacing   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use SimpleCalendar\Events\Event;
14 14
 use SimpleCalendar\Calendars\Default_Calendar;
15 15
 
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @param string|Calendar $calendar
57 57
 	 */
58
-	public function __construct( $calendar = '' ) {
58
+	public function __construct($calendar = '') {
59 59
 		$this->calendar = $calendar;
60 60
 	}
61 61
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return string
90 90
 	 */
91 91
 	public function get_name() {
92
-		return __( 'Grid', 'google-calendar-events' );
92
+		return __('Grid', 'google-calendar-events');
93 93
 	}
94 94
 
95 95
 	/**
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 * @since 3.0.0
99 99
 	 */
100 100
 	public function add_ajax_actions() {
101
-		add_action( 'wp_ajax_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) );
102
-		add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) );
101
+		add_action('wp_ajax_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax'));
102
+		add_action('wp_ajax_nopriv_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax'));
103 103
 	}
104 104
 
105 105
 	/**
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return array
115 115
 	 */
116
-	public function scripts( $min = '' ) {
116
+	public function scripts($min = '') {
117 117
 		return array(
118 118
 			'simcal-qtip' => array(
119
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js',
120
-				'deps'      => array( 'jquery' ),
119
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js',
120
+				'deps'      => array('jquery'),
121 121
 				'ver'       => '2.2.1',
122 122
 				'in_footer' => true,
123 123
 			),
124 124
 			'simcal-default-calendar' => array(
125
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js',
125
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js',
126 126
 				'deps'      => array(
127 127
 					'jquery',
128 128
 					'simcal-qtip',
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @return array
149 149
 	 */
150
-	public function styles( $min = '' ) {
150
+	public function styles($min = '') {
151 151
 		return array(
152 152
 			'simcal-qtip' => array(
153
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/vendor/qtip' . $min . '.css',
153
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/vendor/qtip'.$min.'.css',
154 154
 				'ver'   => '2.2.1',
155 155
 				'media' => 'all',
156 156
 			),
157 157
 			'simcal-default-calendar-grid' => array(
158
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-grid' . $min . '.css',
158
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-grid'.$min.'.css',
159 159
 				'deps'  => array(
160 160
 					'simcal-qtip',
161 161
 				),
@@ -174,16 +174,16 @@  discard block
 block discarded – undo
174 174
 
175 175
 		$calendar = $this->calendar;
176 176
 
177
-		if ( $calendar instanceof Default_Calendar ) {
177
+		if ($calendar instanceof Default_Calendar) {
178 178
 
179 179
 			?>
180 180
 			<table class="simcal-calendar-grid"
181 181
 			       data-event-bubble-trigger="<?php echo $calendar->event_bubble_trigger; ?>">
182 182
 				<thead class="simcal-calendar-head">
183 183
 					<tr>
184
-						<?php if ( ! $calendar->static ) { ?>
184
+						<?php if ( ! $calendar->static) { ?>
185 185
 							<th class="simcal-nav simcal-prev-wrapper" colspan="1">
186
-								<button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e( 'Previous Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-left"></i></button>
186
+								<button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e('Previous Month', 'google-calendar-events'); ?>"><i class="simcal-icon-left"></i></button>
187 187
 							</th>
188 188
 						<?php } ?>
189 189
 						<th colspan="<?php echo $calendar->static ? '7' : '5'; ?>"
@@ -195,26 +195,26 @@  discard block
 block discarded – undo
195 195
 
196 196
 							// Display month and year according to user date format preference.
197 197
 
198
-							$year_pos  = strcspn( $calendar->date_format, 'Y y' );
199
-							$month_pos = strcspn( $calendar->date_format, 'F M m n' );
198
+							$year_pos  = strcspn($calendar->date_format, 'Y y');
199
+							$month_pos = strcspn($calendar->date_format, 'F M m n');
200 200
 
201
-							$current = array( 'month' => 'F', 'year' => 'Y' );
201
+							$current = array('month' => 'F', 'year' => 'Y');
202 202
 
203
-							if ( $year_pos < $month_pos ) {
204
-								$current = array_reverse( $current );
203
+							if ($year_pos < $month_pos) {
204
+								$current = array_reverse($current);
205 205
 							}
206 206
 
207
-							foreach ( $current as $k => $v ) {
208
-								echo ' <span class="simcal-current-' . $k , '">' . date_i18n( $v, $calendar->start ) . '</span> ';
207
+							foreach ($current as $k => $v) {
208
+								echo ' <span class="simcal-current-'.$k, '">'.date_i18n($v, $calendar->start).'</span> ';
209 209
 							}
210 210
 
211 211
 							echo '</h3>';
212 212
 
213 213
 							?>
214 214
 						</th>
215
-						<?php if ( ! $calendar->static ) { ?>
215
+						<?php if ( ! $calendar->static) { ?>
216 216
 							<th class="simcal-nav simcal-next-wrapper" colspan="1">
217
-								<button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e( 'Next Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-right"></i></button>
217
+								<button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e('Next Month', 'google-calendar-events'); ?>"><i class="simcal-icon-right"></i></button>
218 218
 							</th>
219 219
 						<?php } ?>
220 220
 					</tr>
@@ -224,28 +224,28 @@  discard block
 block discarded – undo
224 224
 						// Print day names in short or long form for different viewport sizes.
225 225
 
226 226
 						$week_starts     = $calendar->week_starts;
227
-						$week_days_short = simcal_get_calendar_names_i18n( 'day', 'short' );
228
-						$week_days_full  = simcal_get_calendar_names_i18n( 'day', 'full' );
227
+						$week_days_short = simcal_get_calendar_names_i18n('day', 'short');
228
+						$week_days_full  = simcal_get_calendar_names_i18n('day', 'full');
229 229
 
230
-						for ( $i = $week_starts; $i <= 6; $i ++ ) :
230
+						for ($i = $week_starts; $i <= 6; $i++) :
231 231
 
232 232
 							?>
233 233
 							<th class="simcal-week-day simcal-week-day-<?php echo $i ?>"
234
-								data-screen-small="<?php echo mb_substr( $week_days_short[ $i ], 0, 1, 'UTF-8' ); ?>"
235
-							    data-screen-medium="<?php echo $week_days_short[ $i ]; ?>"
236
-							    data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th>
234
+								data-screen-small="<?php echo mb_substr($week_days_short[$i], 0, 1, 'UTF-8'); ?>"
235
+							    data-screen-medium="<?php echo $week_days_short[$i]; ?>"
236
+							    data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th>
237 237
 							<?php
238 238
 
239 239
 						endfor;
240 240
 
241
-						if ( $week_starts !== 0 ) :
242
-							for ( $i = 0; $i < $week_starts; $i ++ ) :
241
+						if ($week_starts !== 0) :
242
+							for ($i = 0; $i < $week_starts; $i++) :
243 243
 
244 244
 								?>
245 245
 								<th class="simcal-week-day simcal-week-day-<?php echo $i ?>"
246
-								    data-screen-small="<?php echo substr( $week_days_short[ $i ], 0, 1 ); ?>"
247
-								    data-screen-medium="<?php echo $week_days_short[ $i ]; ?>"
248
-								    data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th>
246
+								    data-screen-small="<?php echo substr($week_days_short[$i], 0, 1); ?>"
247
+								    data-screen-medium="<?php echo $week_days_short[$i]; ?>"
248
+								    data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th>
249 249
 								<?php
250 250
 
251 251
 							endfor;
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 					</tr>
256 256
 				</thead>
257 257
 
258
-				<?php echo $this->draw_month( date( 'n', $calendar->start ), date( 'Y', $calendar->start ) ); ?>
258
+				<?php echo $this->draw_month(date('n', $calendar->start), date('Y', $calendar->start)); ?>
259 259
 
260 260
 			</table>
261 261
 			<?php
@@ -280,82 +280,82 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @return string
282 282
 	 */
283
-	private function draw_month( $month, $year, $id = 0 ) {
283
+	private function draw_month($month, $year, $id = 0) {
284 284
 
285 285
 		$calendar = $this->calendar;
286
-		if ( empty( $calendar ) ) {
287
-			$calendar = simcal_get_calendar( intval( $id ) );
288
-			if ( ! $calendar ) {
286
+		if (empty($calendar)) {
287
+			$calendar = simcal_get_calendar(intval($id));
288
+			if ( ! $calendar) {
289 289
 				return '';
290 290
 			}
291 291
 		}
292
-		date_default_timezone_set( $calendar->timezone );
292
+		date_default_timezone_set($calendar->timezone);
293 293
 		$events = $calendar->events;
294 294
 
295 295
 		// Variables to cycle days in current month and find today in calendar.
296 296
 		$now         = $calendar->now;
297
-		$current     = Carbon::create( $year, $month, 1, 0, 0, 59, $calendar->timezone );
297
+		$current     = Carbon::create($year, $month, 1, 0, 0, 59, $calendar->timezone);
298 298
 		$current_min = $current->getTimestamp();
299 299
 		$current_max = $current->endOfDay()->getTimestamp();
300 300
 
301 301
 		// Calendar grid variables.
302 302
 		$week_starts   = $calendar->week_starts;
303
-		$week_of_year  = $current->weekOfYear;   // Relative count of the week number of the year.
304
-		$month_starts  = $current->dayOfWeek;    // Day upon which the month starts.
305
-		$days_in_month = $current->daysInMonth;  // Number of days in the given month.
303
+		$week_of_year  = $current->weekOfYear; // Relative count of the week number of the year.
304
+		$month_starts  = $current->dayOfWeek; // Day upon which the month starts.
305
+		$days_in_month = $current->daysInMonth; // Number of days in the given month.
306 306
 
307 307
 		// Set current month events timestamp boundaries.
308 308
 		$this->start = $current_min;
309 309
 		$this->end   = $current->endOfMonth()->timestamp;
310 310
 
311 311
 		// Get daily events for this month.
312
-		if ( $events && is_array( $events ) ) {
312
+		if ($events && is_array($events)) {
313 313
 
314 314
 			// Filter events within the boundaries previously set above.
315
-			$timestamps   = array_keys( $events );
316
-			$lower_bound  = array_filter( $timestamps, array( $this, 'filter_events_before' ) );
317
-			$higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) );
318
-			$filtered     = ( is_array( $events ) && is_array( $higher_bound) ) && ! empty( $events ) && ! empty( $higher_bound ) ? array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ) : array();
315
+			$timestamps   = array_keys($events);
316
+			$lower_bound  = array_filter($timestamps, array($this, 'filter_events_before'));
317
+			$higher_bound = array_filter($lower_bound, array($this, 'filter_events_after'));
318
+			$filtered     = (is_array($events) && is_array($higher_bound)) && ! empty($events) && ! empty($higher_bound) ? array_intersect_key($events, array_combine($higher_bound, $higher_bound)) : array();
319 319
 
320 320
 			// Put resulting events in an associative array, with day of the month as key for easy retrieval in calendar days loop.
321 321
 			$day_events = array();
322
-			foreach ( $filtered as $timestamp => $events_in_day ) {
323
-				foreach ( $events_in_day as $event ) {
324
-					if ( $event instanceof Event ){
325
-						$day = intval( Carbon::createFromTimestamp( $timestamp, $event->timezone )->endOfDay()->day );
326
-						$day_events[ $day ][] = $event;
322
+			foreach ($filtered as $timestamp => $events_in_day) {
323
+				foreach ($events_in_day as $event) {
324
+					if ($event instanceof Event) {
325
+						$day = intval(Carbon::createFromTimestamp($timestamp, $event->timezone)->endOfDay()->day);
326
+						$day_events[$day][] = $event;
327 327
 					}
328 328
 				}
329 329
 			}
330 330
 
331
-			ksort( $day_events, SORT_NUMERIC );
331
+			ksort($day_events, SORT_NUMERIC);
332 332
 		}
333 333
 
334 334
 		ob_start();
335 335
 
336
-		echo '<tbody class="simcal-month simcal-month-' . $month . '">' . "\n";
337
-		echo "\t" . '<tr class="simcal-week simcal-week-' . $week_of_year . '">';
336
+		echo '<tbody class="simcal-month simcal-month-'.$month.'">'."\n";
337
+		echo "\t".'<tr class="simcal-week simcal-week-'.$week_of_year.'">';
338 338
 
339 339
 		$days_in_row = 0;
340 340
 		// Week may start on an arbitrary day (sun, 0 - sat, 6).
341 341
 		$week_day = $week_starts;
342 342
 
343 343
 		// This fixes a possible bug when a month starts by Sunday (0).
344
-		if ( 0 !== $week_starts ) {
344
+		if (0 !== $week_starts) {
345 345
 			$b = $month_starts === 0 ? 7 : $month_starts;
346 346
 		} else {
347 347
 			$b = $month_starts;
348 348
 		}
349 349
 
350 350
 		// Void days in first week.
351
-		for ( $a = $week_starts; $a < $b; $a++ ) :
351
+		for ($a = $week_starts; $a < $b; $a++) :
352 352
 
353
-			$last_void_day_class = ( $a === ( $b - 1 ) ) ? 'simcal-day-void-last' : '';
353
+			$last_void_day_class = ($a === ($b - 1)) ? 'simcal-day-void-last' : '';
354 354
 
355
-			echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n";
355
+			echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n";
356 356
 
357 357
 			// Reset day of the week count (sun, 0 - sat, 6).
358
-			if ( $week_day === 6 ) {
358
+			if ($week_day === 6) {
359 359
 				$week_day = -1;
360 360
 			}
361 361
 			$week_day++;
@@ -365,91 +365,91 @@  discard block
 block discarded – undo
365 365
 		endfor;
366 366
 
367 367
 		// Actual days of the month.
368
-		for ( $day = 1; $day <= $days_in_month; $day++ ) :
368
+		for ($day = 1; $day <= $days_in_month; $day++) :
369 369
 
370 370
 			$count = 0;
371 371
 			$calendar_classes = array();
372
-			$day_classes = 'simcal-day-' . $day . ' simcal-weekday-' . $week_day;
372
+			$day_classes = 'simcal-day-'.$day.' simcal-weekday-'.$week_day;
373 373
 
374 374
 			$border_style = $bg_color = $color = '';
375 375
 
376 376
 			// Is this the present, the past or the future, Doc?
377
-			if ( $current_min <= $now && $current_max >= $now ) {
377
+			if ($current_min <= $now && $current_max >= $now) {
378 378
 				$day_classes .= ' simcal-today simcal-present simcal-day';
379
-				$the_color = new Color( $calendar->today_color );
380
-				$bg_color = '#' . $the_color->getHex();
379
+				$the_color = new Color($calendar->today_color);
380
+				$bg_color = '#'.$the_color->getHex();
381 381
 				$color = $the_color->isDark() ? '#ffffff' : '#000000';
382
-				$border_style = ' style="border: 1px solid ' . $bg_color . ';"';
383
-			} elseif ( $current_max < $now ) {
382
+				$border_style = ' style="border: 1px solid '.$bg_color.';"';
383
+			} elseif ($current_max < $now) {
384 384
 				$day_classes .= ' simcal-past simcal-day';
385
-			} elseif ( $current_min > $now ) {
385
+			} elseif ($current_min > $now) {
386 386
 				$day_classes .= ' simcal-future simcal-day';
387 387
 			}
388 388
 
389 389
 			// Print events for the current day in loop, if found any.
390
-			if ( isset( $day_events[ $day ] ) ) :
390
+			if (isset($day_events[$day])) :
391 391
 
392 392
 				$list_events = '<ul class="simcal-events">';
393 393
 
394
-				foreach ( $day_events[ $day ] as $event ) :
394
+				foreach ($day_events[$day] as $event) :
395 395
 
396 396
 					$event_classes = $event_visibility = '';
397 397
 
398
-					if ( $event instanceof Event ) :
398
+					if ($event instanceof Event) :
399 399
 
400 400
 						// Store the calendar id where the event belongs (useful in grouped calendar feeds)
401
-						$calendar_class  = 'simcal-events-calendar-' . strval( $event->calendar );
402
-						$calendar_classes[] = $calendar_class ;
401
+						$calendar_class = 'simcal-events-calendar-'.strval($event->calendar);
402
+						$calendar_classes[] = $calendar_class;
403 403
 
404 404
 						$recurring     = $event->recurrence ? 'simcal-event-recurring ' : '';
405 405
 						$has_location  = $event->venue ? 'simcal-event-has-location ' : '';
406 406
 
407
-						$event_classes  .= 'simcal-event ' . $recurring . $has_location . $calendar_class . ' simcal-tooltip';
407
+						$event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class.' simcal-tooltip';
408 408
 
409 409
 						// Toggle some events visibility if more than optional limit.
410
-						if ( ( $calendar->events_limit > -1 )  && ( $count >= $calendar->events_limit ) ) :
410
+						if (($calendar->events_limit > -1) && ($count >= $calendar->events_limit)) :
411 411
 							$event_classes    .= ' simcal-event-toggled';
412 412
 							$event_visibility  = ' style="display: none"';
413 413
 						endif;
414 414
 
415 415
 						// Event title in list.
416
-						$title = ! empty( $event->title ) ? trim( $event->title ) : __( 'Event', 'google-calendar-events' );
417
-						if ( $calendar->trim_titles >= 1 ) {
418
-							$title = strlen( $title ) > $calendar->trim_titles ? mb_substr( $title, 0, $calendar->trim_titles ) . '&hellip;' : $title;
416
+						$title = ! empty($event->title) ? trim($event->title) : __('Event', 'google-calendar-events');
417
+						if ($calendar->trim_titles >= 1) {
418
+							$title = strlen($title) > $calendar->trim_titles ? mb_substr($title, 0, $calendar->trim_titles).'&hellip;' : $title;
419 419
 						}
420 420
 
421 421
 						// Event color.
422 422
 						$bullet = '';
423 423
 						$event_color = $event->get_color();
424
-						if ( ! empty( $event_color ) ) {
425
-							$bullet = '<span style="color: ' . $event_color . ';">&#9632;</span> ';
424
+						if ( ! empty($event_color)) {
425
+							$bullet = '<span style="color: '.$event_color.';">&#9632;</span> ';
426 426
 						}
427 427
 
428 428
 						// Event contents.
429
-						$list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . ' itemprop="event" itemscope itemtype="http://schema.org/Event">' . "\n";
430
-						$list_events .= "\t\t" . '<span class="simcal-event-title">' . $bullet . $title . '</span>' . "\n";
431
-						$list_events .= "\t\t" . '<div class="simcal-event-details simcal-tooltip-content" style="display: none;">' . $calendar->get_event_html( $event ) . '</div>' . "\n";
432
-						$list_events .= "\t" . '</li>' . "\n";
429
+						$list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.' itemprop="event" itemscope itemtype="http://schema.org/Event">'."\n";
430
+						$list_events .= "\t\t".'<span class="simcal-event-title">'.$bullet.$title.'</span>'."\n";
431
+						$list_events .= "\t\t".'<div class="simcal-event-details simcal-tooltip-content" style="display: none;">'.$calendar->get_event_html($event).'</div>'."\n";
432
+						$list_events .= "\t".'</li>'."\n";
433 433
 
434
-						$count ++;
434
+						$count++;
435 435
 
436 436
 					endif;
437 437
 
438 438
 				endforeach;
439 439
 
440
-				if ( ( $current_min <= $now ) && ( $current_max >= $now ) ) {
440
+				if (($current_min <= $now) && ($current_max >= $now)) {
441 441
 					$day_classes .= ' simcal-today-has-events';
442 442
 				}
443
-				$day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events';
443
+				$day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events';
444 444
 
445
-				if ( $calendar_classes ) {
446
-					$day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) );
445
+				if ($calendar_classes) {
446
+					$day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes)));
447 447
 				}
448 448
 
449
-				$list_events .= '</ul>' . "\n";
449
+				$list_events .= '</ul>'."\n";
450 450
 
451 451
 				// Optional button to toggle hidden events in list.
452
-				if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) :
452
+				if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) :
453 453
 					$list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>';
454 454
 				endif;
455 455
 
@@ -461,49 +461,49 @@  discard block
 block discarded – undo
461 461
 			endif;
462 462
 
463 463
 			// The actual days with numbers and events in each row cell.
464
-			echo '<td class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n";
465
-
466
-			if ( $color ) {
467
-				$day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"';
468
-			} elseif ( $count > 0 ) {
469
-				$the_color = new Color( $calendar->days_events_color );
470
-				$color = ! $color ? ( $the_color->isDark() ? '#ffffff' : '#000000' ) : $color;
471
-				$bg_color = ! $bg_color ? '#' . $the_color->getHex() : $bg_color;
472
-				$day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"';
464
+			echo '<td class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n";
465
+
466
+			if ($color) {
467
+				$day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"';
468
+			} elseif ($count > 0) {
469
+				$the_color = new Color($calendar->days_events_color);
470
+				$color = ! $color ? ($the_color->isDark() ? '#ffffff' : '#000000') : $color;
471
+				$bg_color = ! $bg_color ? '#'.$the_color->getHex() : $bg_color;
472
+				$day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"';
473 473
 			} else {
474 474
 				$day_style = '';
475 475
 			}
476 476
 
477
-			echo "\t" . '<div' . $border_style . '>' . "\n";
478
-			echo "\t\t" . '<span class="simcal-day-label simcal-day-number"' . $day_style . '>' . $day . '</span>' . "\n";
479
-			echo "\t\t" . $list_events . "\n";
477
+			echo "\t".'<div'.$border_style.'>'."\n";
478
+			echo "\t\t".'<span class="simcal-day-label simcal-day-number"'.$day_style.'>'.$day.'</span>'."\n";
479
+			echo "\t\t".$list_events."\n";
480 480
 			echo "\t\t";
481 481
 			echo '<span class="simcal-events-dots" style="display: none;">';
482 482
 
483 483
 			// Event bullets for calendar mobile mode.
484
-			for( $i = 0; $i < $count; $i++ ) {
484
+			for ($i = 0; $i < $count; $i++) {
485 485
 				echo '<b> &bull; </b>';
486 486
 			}
487 487
 
488
-			echo '</span>' . "\n";
489
-			echo "\t" . '</div>' . "\n";
490
-			echo '</td>' . "\n";
488
+			echo '</span>'."\n";
489
+			echo "\t".'</div>'."\n";
490
+			echo '</td>'."\n";
491 491
 
492 492
 			// Reset day of the week count (sun, 0 - sat, 6).
493
-			if ( $week_day === 6 ) {
493
+			if ($week_day === 6) {
494 494
 				$week_day = - 1;
495 495
 			}
496 496
 			$week_day++;
497 497
 
498 498
 			// Reset count of days for this row (0-6).
499
-			if ( $days_in_row === 6 ) :
499
+			if ($days_in_row === 6) :
500 500
 
501 501
 				// Close the week row.
502 502
 				echo '</tr>';
503 503
 
504 504
 				// Open a new week row.
505
-				if ( $day < $days_in_month ) {
506
-					echo '<tr class="simcal-week simcal-week-' . $week_of_year++ . '">' . "\n";
505
+				if ($day < $days_in_month) {
506
+					echo '<tr class="simcal-week simcal-week-'.$week_of_year++.'">'."\n";
507 507
 				}
508 508
 
509 509
 				$days_in_row = -1;
@@ -512,27 +512,27 @@  discard block
 block discarded – undo
512 512
 
513 513
 			$days_in_row++;
514 514
 
515
-			$current_min = Carbon::createFromTimestamp( $current_min, $calendar->timezone )->addDay()->getTimestamp();
516
-			$current_max = Carbon::createFromTimestamp( $current_max, $calendar->timezone )->addDay()->getTimestamp();
515
+			$current_min = Carbon::createFromTimestamp($current_min, $calendar->timezone)->addDay()->getTimestamp();
516
+			$current_max = Carbon::createFromTimestamp($current_max, $calendar->timezone)->addDay()->getTimestamp();
517 517
 
518 518
 		endfor;
519 519
 
520 520
 		// Void days at the end of the month.
521
-		$remainder_days = ( 6 - $days_in_row );
521
+		$remainder_days = (6 - $days_in_row);
522 522
 
523
-		for ( $i = 0; $i <= $remainder_days; $i ++ ) {
523
+		for ($i = 0; $i <= $remainder_days; $i++) {
524 524
 
525
-			$last_void_day_class = ( $i == $remainder_days ) ? 'simcal-day-void-last' : '';
525
+			$last_void_day_class = ($i == $remainder_days) ? 'simcal-day-void-last' : '';
526 526
 
527
-			echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n";
527
+			echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n";
528 528
 
529 529
 			$week_day++;
530 530
 		}
531 531
 
532
-		echo "\t" . '</tr>' . "\n";
533
-		echo '</tbody>' . "\n";
532
+		echo "\t".'</tr>'."\n";
533
+		echo '</tbody>'."\n";
534 534
 
535
-		date_default_timezone_set( $calendar->site_timezone );
535
+		date_default_timezone_set($calendar->site_timezone);
536 536
 
537 537
 		return ob_get_clean();
538 538
 	}
@@ -544,17 +544,17 @@  discard block
 block discarded – undo
544 544
 	 */
545 545
 	public function draw_grid_ajax() {
546 546
 
547
-		if ( isset( $_POST['month'] ) && isset( $_POST['year'] ) && isset( $_POST['id'] ) ) {
547
+		if (isset($_POST['month']) && isset($_POST['year']) && isset($_POST['id'])) {
548 548
 
549
-			$month = absint( $_POST['month'] );
550
-			$year  = absint( $_POST['year'] );
551
-			$id    = absint( $_POST['id'] );
549
+			$month = absint($_POST['month']);
550
+			$year  = absint($_POST['year']);
551
+			$id    = absint($_POST['id']);
552 552
 
553
-			wp_send_json_success( $this->draw_month( $month, $year, $id ) );
553
+			wp_send_json_success($this->draw_month($month, $year, $id));
554 554
 
555 555
 		} else {
556 556
 
557
-			wp_send_json_error( 'Missing arguments in default calendar grid ajax request.' );
557
+			wp_send_json_error('Missing arguments in default calendar grid ajax request.');
558 558
 
559 559
 		}
560 560
 
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 	 *
571 571
 	 * @return bool
572 572
 	 */
573
-	private function filter_events_before( $event ) {
574
-		return intval( $event ) > intval( $this->start );
573
+	private function filter_events_before($event) {
574
+		return intval($event) > intval($this->start);
575 575
 	}
576 576
 
577 577
 	/**
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
 	 *
585 585
 	 * @return bool
586 586
 	 */
587
-	private function filter_events_after( $event ) {
588
-		return intval( $event ) < intval( $this->end );
587
+	private function filter_events_after($event) {
588
+		return intval($event) < intval($this->end);
589 589
 	}
590 590
 
591 591
 }
Please login to merge, or discard this patch.
includes/abstracts/calendar.php 1 patch
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 use SimpleCalendar\Events\Event_Builder;
12 12
 use SimpleCalendar\Events\Events;
13 13
 
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
 	 * @param int|object|\WP_Post|Calendar $calendar
235 235
 	 * @param string $view
236 236
 	 */
237
-	public function __construct( $calendar, $view = '' ) {
237
+	public function __construct($calendar, $view = '') {
238 238
 
239 239
 		// Set the post object.
240
-		$this->set_post_object( $calendar );
240
+		$this->set_post_object($calendar);
241 241
 
242
-		if ( ! is_null( $this->post ) ) {
242
+		if ( ! is_null($this->post)) {
243 243
 
244 244
 			// Set calendar type and events source.
245 245
 			$this->set_taxonomies();
@@ -256,23 +256,23 @@  discard block
 block discarded – undo
256 256
 			$this->set_events_template();
257 257
 
258 258
 			// Get events source data.
259
-			$feed = simcal_get_feed( $this );
260
-			if ( $feed instanceof Feed ) {
261
-				if ( ! empty( $feed->events ) ) {
262
-					if ( is_array( $feed->events ) ) {
263
-						$this->set_events( $feed->events );
264
-						if ( 'use_calendar' == get_post_meta( $this->id, '_feed_timezone_setting', true ) ) {
259
+			$feed = simcal_get_feed($this);
260
+			if ($feed instanceof Feed) {
261
+				if ( ! empty($feed->events)) {
262
+					if (is_array($feed->events)) {
263
+						$this->set_events($feed->events);
264
+						if ('use_calendar' == get_post_meta($this->id, '_feed_timezone_setting', true)) {
265 265
 							$this->timezone = $feed->timezone;
266
-							$this->set_start( $feed->timezone );
266
+							$this->set_start($feed->timezone);
267 267
 						}
268
-					} elseif ( is_string( $feed->events ) ) {
268
+					} elseif (is_string($feed->events)) {
269 269
 						$this->errors[] = $feed->events;
270 270
 					}
271 271
 				}
272 272
 			}
273 273
 
274 274
 			// Set general purpose timestamps.
275
-			$now = Carbon::now( $this->timezone );
275
+			$now = Carbon::now($this->timezone);
276 276
 			$this->now    = $now->getTimestamp();
277 277
 			$this->today  = $now->startOfDay()->getTimestamp();
278 278
 			$this->offset = $now->getOffset();
@@ -283,26 +283,26 @@  discard block
 block discarded – undo
283 283
 			$this->set_datetime_separator();
284 284
 
285 285
 			// Set earliest and latest event timestamps.
286
-			if ( $this->events && is_array( $this->events ) ) {
287
-				$this->earliest_event = intval( current( array_keys( $this->events ) ) );
288
-				$this->latest_event   = intval( key( array_slice( $this->events, -1, 1, true ) ) );
286
+			if ($this->events && is_array($this->events)) {
287
+				$this->earliest_event = intval(current(array_keys($this->events)));
288
+				$this->latest_event   = intval(key(array_slice($this->events, -1, 1, true)));
289 289
 			}
290 290
 
291 291
 			// Set calendar end.
292 292
 			$this->set_end();
293 293
 
294 294
 			// Set view.
295
-			if ( ! $view ) {
295
+			if ( ! $view) {
296 296
 
297
-				$calendar_view = get_post_meta( $this->id, '_calendar_view', true );
298
-				$calendar_view = isset( $calendar_view[ $this->type ] ) ? $calendar_view[ $this->type ] : '';
297
+				$calendar_view = get_post_meta($this->id, '_calendar_view', true);
298
+				$calendar_view = isset($calendar_view[$this->type]) ? $calendar_view[$this->type] : '';
299 299
 
300
-				$view = esc_attr( $calendar_view );
300
+				$view = esc_attr($calendar_view);
301 301
 			}
302 302
 		}
303 303
 
304 304
 		// Get view.
305
-		$this->view = $this->get_view( $view );
305
+		$this->view = $this->get_view($view);
306 306
 	}
307 307
 
308 308
 	/**
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @return bool
316 316
 	 */
317
-	public function __isset( $key ) {
318
-		return metadata_exists( 'post', $this->id, '_' . $key );
317
+	public function __isset($key) {
318
+		return metadata_exists('post', $this->id, '_'.$key);
319 319
 	}
320 320
 
321 321
 	/**
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 	 *
328 328
 	 * @return mixed
329 329
 	 */
330
-	public function __get( $key ) {
331
-		$value = get_post_meta( $this->id, '_' . $key, true );
332
-		if ( ! empty( $value ) ) {
330
+	public function __get($key) {
331
+		$value = get_post_meta($this->id, '_'.$key, true);
332
+		if ( ! empty($value)) {
333 333
 			$this->$key = $value;
334 334
 		}
335 335
 		return $value;
@@ -342,17 +342,17 @@  discard block
 block discarded – undo
342 342
 	 *
343 343
 	 * @param int|object|\WP_Post|Calendar $calendar
344 344
 	 */
345
-	public function set_post_object( $calendar ) {
346
-		if ( is_numeric( $calendar ) ) {
347
-			$this->id   = absint( $calendar );
348
-			$this->post = get_post( $this->id );
349
-		} elseif ( $calendar instanceof Calendar ) {
350
-			$this->id   = absint( $calendar->id );
345
+	public function set_post_object($calendar) {
346
+		if (is_numeric($calendar)) {
347
+			$this->id   = absint($calendar);
348
+			$this->post = get_post($this->id);
349
+		} elseif ($calendar instanceof Calendar) {
350
+			$this->id   = absint($calendar->id);
351 351
 			$this->post = $calendar->post;
352
-		} elseif ( $calendar instanceof \WP_Post ) {
353
-			$this->id   = absint( $calendar->ID );
352
+		} elseif ($calendar instanceof \WP_Post) {
353
+			$this->id   = absint($calendar->ID);
354 354
 			$this->post = $calendar;
355
-		} elseif ( isset( $calendar->id ) && isset( $calendar->post ) ) {
355
+		} elseif (isset($calendar->id) && isset($calendar->post)) {
356 356
 			$this->id   = $calendar->id;
357 357
 			$this->post = $calendar->post;
358 358
 		}
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 	 * @return string
367 367
 	 */
368 368
 	public function get_title() {
369
-		$title = isset( $this->post->post_title ) ? $this->post->post_title : '';
370
-		return apply_filters( 'simcal_calendar_title', $title );
369
+		$title = isset($this->post->post_title) ? $this->post->post_title : '';
370
+		return apply_filters('simcal_calendar_title', $title);
371 371
 	}
372 372
 
373 373
 	/**
@@ -389,16 +389,16 @@  discard block
 block discarded – undo
389 389
 	 */
390 390
 	protected function set_taxonomies() {
391 391
 		// Set calendar type.
392
-		if ( $type = wp_get_object_terms( $this->id, 'calendar_type' ) ) {
393
-			$this->type = sanitize_title( current( $type )->name );
392
+		if ($type = wp_get_object_terms($this->id, 'calendar_type')) {
393
+			$this->type = sanitize_title(current($type)->name);
394 394
 		} else {
395
-			$this->type = apply_filters( 'simcal_calendar_default_type', 'default-calendar' );
395
+			$this->type = apply_filters('simcal_calendar_default_type', 'default-calendar');
396 396
 		}
397 397
 		// Set feed type.
398
-		if ( $feed_type = wp_get_object_terms( $this->id, 'calendar_feed' ) ) {
399
-			$this->feed = sanitize_title( current( $feed_type )->name );
398
+		if ($feed_type = wp_get_object_terms($this->id, 'calendar_feed')) {
399
+			$this->feed = sanitize_title(current($feed_type)->name);
400 400
 		} else {
401
-			$this->feed = apply_filters( 'simcal_calendar_default_feed', 'google' );
401
+			$this->feed = apply_filters('simcal_calendar_default_feed', 'google');
402 402
 		}
403 403
 	}
404 404
 
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 * @return Events
411 411
 	 */
412 412
 	public function get_events() {
413
-		return new Events( $this->events, $this->timezone );
413
+		return new Events($this->events, $this->timezone);
414 414
 	}
415 415
 
416 416
 	/**
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
 	 *
421 421
 	 * @param array $array
422 422
 	 */
423
-	public function set_events( array $array ) {
423
+	public function set_events(array $array) {
424 424
 
425 425
 		$events = array();
426 426
 
427
-		if ( ! empty( $array ) ) {
428
-			foreach ( $array as $tz => $e ) {
429
-				foreach ( $e as $event ) {
430
-					$events[ $tz ][] = $event instanceof Event ? $event : new Event( $event );
427
+		if ( ! empty($array)) {
428
+			foreach ($array as $tz => $e) {
429
+				foreach ($e as $event) {
430
+					$events[$tz][] = $event instanceof Event ? $event : new Event($event);
431 431
 				}
432 432
 			}
433 433
 		}
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
 	 *
445 445
 	 * @return string
446 446
 	 */
447
-	public function set_events_template( $template = '' ) {
448
-		if ( empty( $template ) ) {
449
-			$template = isset( $this->post->post_content ) ? $this->post->post_content : '';
447
+	public function set_events_template($template = '') {
448
+		if (empty($template)) {
449
+			$template = isset($this->post->post_content) ? $this->post->post_content : '';
450 450
 		}
451
-		$this->events_template = wpautop( wp_kses_post( trim( $template ) ) );
451
+		$this->events_template = wpautop(wp_kses_post(trim($template)));
452 452
 	}
453 453
 
454 454
 	/**
@@ -458,32 +458,32 @@  discard block
 block discarded – undo
458 458
 	 *
459 459
 	 * @param string $tz Timezone.
460 460
 	 */
461
-	public function set_timezone( $tz = '' ) {
461
+	public function set_timezone($tz = '') {
462 462
 
463
-		$site_tz = esc_attr( simcal_get_wp_timezone() );
463
+		$site_tz = esc_attr(simcal_get_wp_timezone());
464 464
 
465
-		if ( empty( $tz ) ) {
465
+		if (empty($tz)) {
466 466
 
467
-			$timezone_setting = get_post_meta( $this->id, '_feed_timezone_setting', true );
467
+			$timezone_setting = get_post_meta($this->id, '_feed_timezone_setting', true);
468 468
 
469
-			if ( 'use_site' == $timezone_setting ) {
469
+			if ('use_site' == $timezone_setting) {
470 470
 				$tz = $site_tz;
471
-			} elseif ( 'use_custom' == $timezone_setting ) {
472
-				$custom_timezone = esc_attr( get_post_meta( $this->id, '_feed_timezone', true ) );
471
+			} elseif ('use_custom' == $timezone_setting) {
472
+				$custom_timezone = esc_attr(get_post_meta($this->id, '_feed_timezone', true));
473 473
 				// One may be using a non standard timezone in GMT (UTC) offset format.
474
-				if ( ( strpos( $custom_timezone, 'UTC+' ) === 0 ) || ( strpos( $custom_timezone, 'UTC-' ) === 0 ) ) {
475
-					$tz = simcal_get_timezone_from_gmt_offset( substr( $custom_timezone, 3 ) );
474
+				if ((strpos($custom_timezone, 'UTC+') === 0) || (strpos($custom_timezone, 'UTC-') === 0)) {
475
+					$tz = simcal_get_timezone_from_gmt_offset(substr($custom_timezone, 3));
476 476
 				} else {
477
-					$tz = ! empty( $custom_timezone ) ? $custom_timezone : 'UTC';
477
+					$tz = ! empty($custom_timezone) ? $custom_timezone : 'UTC';
478 478
 				}
479 479
 			}
480 480
 
481
-			$this->timezone = empty( $tz ) ? 'UTC' : $tz;
481
+			$this->timezone = empty($tz) ? 'UTC' : $tz;
482 482
 			return;
483 483
 		}
484 484
 
485 485
 		$this->site_timezone = $site_tz;
486
-		$this->timezone = simcal_esc_timezone( $tz, $this->timezone );
486
+		$this->timezone = simcal_esc_timezone($tz, $this->timezone);
487 487
 	}
488 488
 
489 489
 	/**
@@ -493,20 +493,20 @@  discard block
 block discarded – undo
493 493
 	 *
494 494
 	 * @param string $format PHP datetime format.
495 495
 	 */
496
-	public function set_date_format( $format = '' ) {
496
+	public function set_date_format($format = '') {
497 497
 
498 498
 		$date_format_custom = $date_format_default = $format;
499 499
 
500
-		if ( empty( $date_format_custom ) ) {
500
+		if (empty($date_format_custom)) {
501 501
 
502
-			$date_format_option  = esc_attr( get_post_meta( $this->id, '_calendar_date_format_setting', true ) );
503
-			$date_format_default = esc_attr( get_option( 'date_format' ) );
502
+			$date_format_option  = esc_attr(get_post_meta($this->id, '_calendar_date_format_setting', true));
503
+			$date_format_default = esc_attr(get_option('date_format'));
504 504
 			$date_format_custom  = '';
505 505
 
506
-			if ( 'use_custom' == $date_format_option ) {
507
-				$date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format', true ) );
508
-			} elseif ( 'use_custom_php' == $date_format_option ) {
509
-				$date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format_php', true ) );
506
+			if ('use_custom' == $date_format_option) {
507
+				$date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format', true));
508
+			} elseif ('use_custom_php' == $date_format_option) {
509
+				$date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format_php', true));
510 510
 			}
511 511
 		}
512 512
 
@@ -520,20 +520,20 @@  discard block
 block discarded – undo
520 520
 	 *
521 521
 	 * @param string $format PHP datetime format.
522 522
 	 */
523
-	public function set_time_format( $format = '' ) {
523
+	public function set_time_format($format = '') {
524 524
 
525 525
 		$time_format_custom = $time_format_default = $format;
526 526
 
527
-		if ( empty( $time_format_custom ) ) {
527
+		if (empty($time_format_custom)) {
528 528
 
529
-			$time_format_option  = esc_attr( get_post_meta( $this->id, '_calendar_time_format_setting', true ) );
530
-			$time_format_default = esc_attr( get_option( 'time_format' ) );
529
+			$time_format_option  = esc_attr(get_post_meta($this->id, '_calendar_time_format_setting', true));
530
+			$time_format_default = esc_attr(get_option('time_format'));
531 531
 			$time_format_custom  = '';
532 532
 
533
-			if ( 'use_custom' == $time_format_option ) {
534
-				$time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format', true ) );
535
-			} elseif ( 'use_custom_php' == $time_format_option ) {
536
-				$time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format_php', true ) );
533
+			if ('use_custom' == $time_format_option) {
534
+				$time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format', true));
535
+			} elseif ('use_custom_php' == $time_format_option) {
536
+				$time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format_php', true));
537 537
 			}
538 538
 		}
539 539
 
@@ -547,13 +547,13 @@  discard block
 block discarded – undo
547 547
 	 *
548 548
 	 * @param string $separator A UTF8 character used as separator.
549 549
 	 */
550
-	public function set_datetime_separator( $separator = '' ) {
550
+	public function set_datetime_separator($separator = '') {
551 551
 
552
-		if ( empty( $separator ) ) {
553
-			$separator = get_post_meta( $this->id, '_calendar_datetime_separator', true );
552
+		if (empty($separator)) {
553
+			$separator = get_post_meta($this->id, '_calendar_datetime_separator', true);
554 554
 		}
555 555
 
556
-		$this->datetime_separator = esc_attr( $separator );
556
+		$this->datetime_separator = esc_attr($separator);
557 557
 	}
558 558
 
559 559
 	/**
@@ -563,18 +563,18 @@  discard block
 block discarded – undo
563 563
 	 *
564 564
 	 * @param int $weekday From 0 (Sunday) to 6 (Friday).
565 565
 	 */
566
-	public function set_start_of_week( $weekday = -1 ) {
566
+	public function set_start_of_week($weekday = -1) {
567 567
 
568
-		$week_starts = is_int( $weekday ) ? $weekday : -1;
568
+		$week_starts = is_int($weekday) ? $weekday : -1;
569 569
 
570
-		if ( $week_starts < 0 || $week_starts > 6 ) {
570
+		if ($week_starts < 0 || $week_starts > 6) {
571 571
 
572
-			$week_starts_setting = get_post_meta( $this->id, '_calendar_week_starts_on_setting', true );
573
-			$week_starts         = intval( get_option( 'start_of_week' ) );
572
+			$week_starts_setting = get_post_meta($this->id, '_calendar_week_starts_on_setting', true);
573
+			$week_starts         = intval(get_option('start_of_week'));
574 574
 
575
-			if ( 'use_custom' == $week_starts_setting ) {
576
-				$week_starts_on = get_post_meta( $this->id, '_calendar_week_starts_on', true );
577
-				$week_starts    = is_numeric( $week_starts_on ) ? intval( $week_starts_on ) : $week_starts;
575
+			if ('use_custom' == $week_starts_setting) {
576
+				$week_starts_on = get_post_meta($this->id, '_calendar_week_starts_on', true);
577
+				$week_starts    = is_numeric($week_starts_on) ? intval($week_starts_on) : $week_starts;
578 578
 			}
579 579
 		}
580 580
 
@@ -588,51 +588,51 @@  discard block
 block discarded – undo
588 588
 	 *
589 589
 	 * @param int $timestamp
590 590
 	 */
591
-	public function set_start( $timestamp = 0 ) {
591
+	public function set_start($timestamp = 0) {
592 592
 
593
-		if ( is_int( $timestamp ) && $timestamp !== 0 ) {
593
+		if (is_int($timestamp) && $timestamp !== 0) {
594 594
 			$this->start = $timestamp;
595 595
 			return;
596 596
 		}
597 597
 
598
-		$this->start = Carbon::now( $this->timezone )->getTimestamp();
598
+		$this->start = Carbon::now($this->timezone)->getTimestamp();
599 599
 
600
-		$calendar_begins = esc_attr( get_post_meta( $this->id, '_calendar_begins', true ) );
601
-		$nth = max( absint( get_post_meta( $this->id, '_calendar_begins_nth' ) ), 1 );
600
+		$calendar_begins = esc_attr(get_post_meta($this->id, '_calendar_begins', true));
601
+		$nth = max(absint(get_post_meta($this->id, '_calendar_begins_nth')), 1);
602 602
 
603
-		if ( 'today' == $calendar_begins ) {
604
-			$this->start = Carbon::today( $this->timezone )->getTimestamp();
605
-		} elseif ( 'days_before' == $calendar_begins ) {
606
-			$this->start = Carbon::today( $this->timezone )->subDays( $nth )->getTimestamp();
607
-		} elseif ( 'days_after' == $calendar_begins ) {
608
-			$this->start = Carbon::today( $this->timezone )->addDays( $nth )->getTimestamp();
609
-		} elseif ( 'this_week' == $calendar_begins ) {
610
-			$week = new Carbon( 'now', $this->timezone );
611
-			$week->setWeekStartsAt( $this->week_starts );
603
+		if ('today' == $calendar_begins) {
604
+			$this->start = Carbon::today($this->timezone)->getTimestamp();
605
+		} elseif ('days_before' == $calendar_begins) {
606
+			$this->start = Carbon::today($this->timezone)->subDays($nth)->getTimestamp();
607
+		} elseif ('days_after' == $calendar_begins) {
608
+			$this->start = Carbon::today($this->timezone)->addDays($nth)->getTimestamp();
609
+		} elseif ('this_week' == $calendar_begins) {
610
+			$week = new Carbon('now', $this->timezone);
611
+			$week->setWeekStartsAt($this->week_starts);
612 612
 			$this->start = $week->startOfWeek()->getTimestamp();
613
-		} elseif ( 'weeks_before' == $calendar_begins ) {
614
-			$week = new Carbon( 'now', $this->timezone );
615
-			$week->setWeekStartsAt( $this->week_starts );
616
-			$this->start = $week->startOfWeek()->subWeeks( $nth )->getTimestamp();
617
-		} elseif ( 'weeks_after' == $calendar_begins ) {
618
-			$week = new Carbon( 'now', $this->timezone );
619
-			$week->setWeekStartsAt( $this->week_starts );
620
-			$this->start = $week->startOfWeek()->addWeeks( $nth )->getTimestamp();
621
-		} elseif ( 'this_month' == $calendar_begins ) {
622
-			$this->start = Carbon::today( $this->timezone )->startOfMonth()->getTimeStamp();
623
-		} elseif ( 'months_before' == $calendar_begins ) {
624
-			$this->start = Carbon::today( $this->timezone )->subMonths( $nth )->startOfMonth()->getTimeStamp();
625
-		} elseif ( 'months_after' == $calendar_begins ) {
626
-			$this->start = Carbon::today( $this->timezone )->addMonths( $nth )->startOfMonth()->getTimeStamp();
627
-		} elseif ( 'this_year' == $calendar_begins ) {
628
-			$this->start = Carbon::today( $this->timezone )->startOfYear()->getTimestamp();
629
-		} elseif ( 'years_before' == $calendar_begins ) {
630
-			$this->start = Carbon::today( $this->timezone )->subYears( $nth )->startOfYear()->getTimeStamp();
631
-		} elseif ( 'years_after' == $calendar_begins ) {
632
-			$this->start = Carbon::today( $this->timezone )->addYears( $nth )->startOfYear()->getTimeStamp();
633
-		} elseif ( 'custom_date' == $calendar_begins ) {
634
-			if ( $date = get_post_meta( $this->id, '_calendar_begins_custom_date', true ) ) {
635
-				$this->start = Carbon::createFromFormat( 'Y-m-d', esc_attr( $date ) )->setTimezone( $this->timezone )->getTimestamp();
613
+		} elseif ('weeks_before' == $calendar_begins) {
614
+			$week = new Carbon('now', $this->timezone);
615
+			$week->setWeekStartsAt($this->week_starts);
616
+			$this->start = $week->startOfWeek()->subWeeks($nth)->getTimestamp();
617
+		} elseif ('weeks_after' == $calendar_begins) {
618
+			$week = new Carbon('now', $this->timezone);
619
+			$week->setWeekStartsAt($this->week_starts);
620
+			$this->start = $week->startOfWeek()->addWeeks($nth)->getTimestamp();
621
+		} elseif ('this_month' == $calendar_begins) {
622
+			$this->start = Carbon::today($this->timezone)->startOfMonth()->getTimeStamp();
623
+		} elseif ('months_before' == $calendar_begins) {
624
+			$this->start = Carbon::today($this->timezone)->subMonths($nth)->startOfMonth()->getTimeStamp();
625
+		} elseif ('months_after' == $calendar_begins) {
626
+			$this->start = Carbon::today($this->timezone)->addMonths($nth)->startOfMonth()->getTimeStamp();
627
+		} elseif ('this_year' == $calendar_begins) {
628
+			$this->start = Carbon::today($this->timezone)->startOfYear()->getTimestamp();
629
+		} elseif ('years_before' == $calendar_begins) {
630
+			$this->start = Carbon::today($this->timezone)->subYears($nth)->startOfYear()->getTimeStamp();
631
+		} elseif ('years_after' == $calendar_begins) {
632
+			$this->start = Carbon::today($this->timezone)->addYears($nth)->startOfYear()->getTimeStamp();
633
+		} elseif ('custom_date' == $calendar_begins) {
634
+			if ($date = get_post_meta($this->id, '_calendar_begins_custom_date', true)) {
635
+				$this->start = Carbon::createFromFormat('Y-m-d', esc_attr($date))->setTimezone($this->timezone)->getTimestamp();
636 636
 			}
637 637
 		}
638 638
 	}
@@ -644,8 +644,8 @@  discard block
 block discarded – undo
644 644
 	 *
645 645
 	 * @param int $timestamp
646 646
 	 */
647
-	public function set_end( $timestamp = 0 ) {
648
-		$latest = is_int( $timestamp ) && $timestamp !== 0 ? $timestamp : $this->latest_event;
647
+	public function set_end($timestamp = 0) {
648
+		$latest = is_int($timestamp) && $timestamp !== 0 ? $timestamp : $this->latest_event;
649 649
 		$this->end = $latest > $this->start ? $latest : $this->start;
650 650
 	}
651 651
 
@@ -656,14 +656,14 @@  discard block
 block discarded – undo
656 656
 	 *
657 657
 	 * @param string|bool $static
658 658
 	 */
659
-	public function set_static( $static = '' ) {
659
+	public function set_static($static = '') {
660 660
 
661
-		if ( ! empty( $static ) && is_bool( $static ) ) {
661
+		if ( ! empty($static) && is_bool($static)) {
662 662
 			$this->static = $static;
663 663
 			return;
664 664
 		}
665 665
 
666
-		if ( 'yes' == get_post_meta( $this->id, '_calendar_is_static', true ) ) {
666
+		if ('yes' == get_post_meta($this->id, '_calendar_is_static', true)) {
667 667
 			$this->static = true;
668 668
 			return;
669 669
 		}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 	 *
692 692
 	 * @return Calendar_View
693 693
 	 */
694
-	abstract public function get_view( $view = '' );
694
+	abstract public function get_view($view = '');
695 695
 
696 696
 	/**
697 697
 	 * Get event HTML parsed by template.
@@ -703,11 +703,11 @@  discard block
 block discarded – undo
703 703
 	 *
704 704
 	 * @return string
705 705
 	 */
706
-	public function get_event_html( Event $event, $template = '' ) {
707
-		$event_builder = new Event_Builder( $event, $this );
706
+	public function get_event_html(Event $event, $template = '') {
707
+		$event_builder = new Event_Builder($event, $this);
708 708
 		// Use the event template to parse tags; if empty, fallback to calendar post content.
709
-		$template = empty( $template ) ? ( empty( $event->template ) ? $this->events_template : $event->template ) : $template;
710
-		return $event_builder->parse_event_template_tags( $template );
709
+		$template = empty($template) ? (empty($event->template) ? $this->events_template : $event->template) : $template;
710
+		return $event_builder->parse_event_template_tags($template);
711 711
 	}
712 712
 
713 713
 	/**
@@ -717,57 +717,57 @@  discard block
 block discarded – undo
717 717
 	 *
718 718
 	 * @param string $view The calendar view to display.
719 719
 	 */
720
-	public function html( $view = '' ) {
720
+	public function html($view = '') {
721 721
 
722
-		$view = empty( $view ) ? $this->view : $this->get_view( $view );
722
+		$view = empty($view) ? $this->view : $this->get_view($view);
723 723
 
724
-		if ( $view instanceof Calendar_View ) {
724
+		if ($view instanceof Calendar_View) {
725 725
 
726
-			if ( ! empty( $this->errors ) ) {
726
+			if ( ! empty($this->errors)) {
727 727
 
728
-				if ( current_user_can( 'manage_options' )  ) {
728
+				if (current_user_can('manage_options')) {
729 729
 					echo '<pre><code>';
730
-					foreach ( $this->errors as $error ) { echo $error; }
730
+					foreach ($this->errors as $error) { echo $error; }
731 731
 					echo '</code></pre>';
732 732
 				}
733 733
 
734 734
 			} else {
735 735
 
736 736
 				// Get a CSS class from the class name of the calendar view (minus namespace part).
737
-				$view_name  = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( get_class( $view ) ) ) ) );
738
-				$view_class = substr( $view_name, strrpos( $view_name, '\\' ) + 1 );
737
+				$view_name  = implode('-', array_map('lcfirst', explode('_', strtolower(get_class($view)))));
738
+				$view_class = substr($view_name, strrpos($view_name, '\\') + 1);
739 739
 
740
-				$calendar_class = trim( implode( ' simcal-', apply_filters( 'simcal_calendar_class', array(
740
+				$calendar_class = trim(implode(' simcal-', apply_filters('simcal_calendar_class', array(
741 741
 					'simcal-calendar',
742 742
 					$this->type,
743 743
 					$view_class,
744
-				), $this->id ) ) );
745
-
746
-				echo '<div class="' . $calendar_class . '" '
747
-									. 'data-calendar-id="'    . $this->id . '" '
748
-									. 'data-timezone="'       . $this->timezone . '" '
749
-									. 'data-offset="'         . $this->offset . '" '
750
-									. 'data-week-start="'     . $this->week_starts . '" '
751
-									. 'data-calendar-start="' . $this->start .'" '
752
-									. 'data-calendar-end="'   . $this->end . '" '
753
-									. 'data-events-first="'   . $this->earliest_event .'" '
754
-									. 'data-events-last="'    . $this->latest_event . '"'
744
+				), $this->id)));
745
+
746
+				echo '<div class="'.$calendar_class.'" '
747
+									. 'data-calendar-id="'.$this->id.'" '
748
+									. 'data-timezone="'.$this->timezone.'" '
749
+									. 'data-offset="'.$this->offset.'" '
750
+									. 'data-week-start="'.$this->week_starts.'" '
751
+									. 'data-calendar-start="'.$this->start.'" '
752
+									. 'data-calendar-end="'.$this->end.'" '
753
+									. 'data-events-first="'.$this->earliest_event.'" '
754
+									. 'data-events-last="'.$this->latest_event.'"'
755 755
 									. '>';
756 756
 
757
-				date_default_timezone_set( $this->timezone );
758
-				do_action( 'simcal_calendar_html_before', $this->id );
757
+				date_default_timezone_set($this->timezone);
758
+				do_action('simcal_calendar_html_before', $this->id);
759 759
 
760 760
 				$view->html();
761 761
 
762
-				do_action( 'simcal_calendar_html_after', $this->id );
763
-				date_default_timezone_set( $this->site_timezone );
762
+				do_action('simcal_calendar_html_after', $this->id);
763
+				date_default_timezone_set($this->site_timezone);
764 764
 
765
-				$settings = get_option( 'simple-calendar_settings_calendars' );
766
-				$poweredby = isset( $settings['poweredby']['opt_in'] ) ? $settings['poweredby']['opt_in'] : '';
765
+				$settings = get_option('simple-calendar_settings_calendars');
766
+				$poweredby = isset($settings['poweredby']['opt_in']) ? $settings['poweredby']['opt_in'] : '';
767 767
 
768
-				if ( 'yes' == $poweredby ) {
768
+				if ('yes' == $poweredby) {
769 769
 					$align = is_rtl() ? 'left' : 'right';
770
-					echo '<small class="simcal-powered simcal-align-' . $align .'">Powered by <a href="https://simplecalendar.io" target="_blank">Simple Calendar</a></small>';
770
+					echo '<small class="simcal-powered simcal-align-'.$align.'">Powered by <a href="https://simplecalendar.io" target="_blank">Simple Calendar</a></small>';
771 771
 				}
772 772
 
773 773
 				echo '</div>';
Please login to merge, or discard this patch.