Completed
Push — master ( 72dfec...61887c )
by
unknown
06:50
created
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,36 +105,36 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @param int|object|\WP_Post|Calendar $calendar
107 107
 	 */
108
-	public function __construct( $calendar ) {
108
+	public function __construct($calendar) {
109 109
 
110 110
 		$this->type  = 'default-calendar';
111
-		$this->name  = __( 'Default', 'google-calendar-events' );
112
-		$this->views = apply_filters( 'simcal_default_calendar_views', array(
113
-			'grid' => __( 'Grid', 'google-calendar-events' ),
114
-			'list' => __( 'List', 'google-calendar-events' ),
115
-		) );
111
+		$this->name  = __('Default', 'google-calendar-events');
112
+		$this->views = apply_filters('simcal_default_calendar_views', array(
113
+			'grid' => __('Grid', 'google-calendar-events'),
114
+			'list' => __('List', 'google-calendar-events'),
115
+		));
116 116
 
117
-		parent::__construct( $calendar );
117
+		parent::__construct($calendar);
118 118
 
119
-		if ( ! is_null( $this->post ) ) {
119
+		if ( ! is_null($this->post)) {
120 120
 
121
-			$this->set_properties( $this->view->get_type() );
121
+			$this->set_properties($this->view->get_type());
122 122
 
123 123
 			$id    = $this->id;
124 124
 			$theme = $this->theme;
125 125
 
126
-			add_filter( 'simcal_calendar_class', function ( $class, $post_id ) use ( $theme, $id ) {
127
-				if ( in_array( 'default-calendar', $class ) && $post_id === $id ) {
128
-					array_push( $class, 'default-calendar-' . $theme );
126
+			add_filter('simcal_calendar_class', function($class, $post_id) use ($theme, $id) {
127
+				if (in_array('default-calendar', $class) && $post_id === $id) {
128
+					array_push($class, 'default-calendar-'.$theme);
129 129
 				}
130 130
 
131 131
 				return $class;
132
-			}, 10, 2 );
132
+			}, 10, 2);
133 133
 
134 134
 		}
135 135
 
136 136
 		// Calendar settings handling.
137
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
137
+		if (is_admin() && ! defined('DOING_AJAX')) {
138 138
 			$admin          = new Default_Calendar_Admin();
139 139
 			$this->settings = $admin->settings_fields();
140 140
 		}
@@ -148,49 +148,49 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @param  $view
150 150
 	 */
151
-	private function set_properties( $view ) {
151
+	private function set_properties($view) {
152 152
 
153 153
 		// Set styles.
154
-		if ( 'dark' == get_post_meta( $this->id, '_default_calendar_style_theme', true ) ) {
154
+		if ('dark' == get_post_meta($this->id, '_default_calendar_style_theme', true)) {
155 155
 			$this->theme = 'dark';
156 156
 		}
157
-		if ( $today_color = get_post_meta( $this->id, '_default_calendar_style_today', true ) ) {
158
-			$this->today_color = esc_attr( $today_color );
157
+		if ($today_color = get_post_meta($this->id, '_default_calendar_style_today', true)) {
158
+			$this->today_color = esc_attr($today_color);
159 159
 		}
160
-		if ( $day_events_color = get_post_meta( $this->id, '_default_calendar_style_days_events', true ) ) {
161
-			$this->days_events_color = esc_attr( $day_events_color );
160
+		if ($day_events_color = get_post_meta($this->id, '_default_calendar_style_days_events', true)) {
161
+			$this->days_events_color = esc_attr($day_events_color);
162 162
 		}
163 163
 
164 164
 		// Hide too many events.
165
-		if ( 'yes' == get_post_meta( $this->id, '_default_calendar_limit_visible_events', true ) ) {
166
-			$this->events_limit = absint( get_post_meta( $this->id, '_default_calendar_visible_events', true ) );
165
+		if ('yes' == get_post_meta($this->id, '_default_calendar_limit_visible_events', true)) {
166
+			$this->events_limit = absint(get_post_meta($this->id, '_default_calendar_visible_events', true));
167 167
 		}
168 168
 
169 169
 		// Expand multiple day events.
170
-		if ( 'yes' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) || ( 'list' == $view && 'current_day_only' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) ) ) {
170
+		if ('yes' == get_post_meta($this->id, '_default_calendar_expand_multi_day_events', true) || ('list' == $view && 'current_day_only' == get_post_meta($this->id, '_default_calendar_expand_multi_day_events', true))) {
171 171
 			$this->events = $this->expand_multiple_days_events();
172 172
 		}
173 173
 
174
-		if ( 'grid' == $view ) {
174
+		if ('grid' == $view) {
175 175
 
176 176
 			// Use hover to open event bubbles.
177
-			if ( 'hover' == get_post_meta( $this->id, '_default_calendar_event_bubble_trigger', true ) ) {
177
+			if ('hover' == get_post_meta($this->id, '_default_calendar_event_bubble_trigger', true)) {
178 178
 				$this->event_bubble_trigger = 'hover';
179 179
 			}
180 180
 
181 181
 			// Trim long event titles.
182
-			if ( 'yes' == get_post_meta( $this->id, '_default_calendar_trim_titles', true ) ) {
183
-				$this->trim_titles = max( absint( get_post_meta( $this->id, '_default_calendar_trim_titles_chars', true ) ), 1 );
182
+			if ('yes' == get_post_meta($this->id, '_default_calendar_trim_titles', true)) {
183
+				$this->trim_titles = max(absint(get_post_meta($this->id, '_default_calendar_trim_titles_chars', true)), 1);
184 184
 			}
185 185
 
186 186
 		} else {
187 187
 
188 188
 			// List range.
189
-			$this->group_type = esc_attr( get_post_meta( $this->id, '_default_calendar_list_range_type', true ) );
190
-			$this->group_span = max( absint( get_post_meta( $this->id, '_default_calendar_list_range_span', true ) ), 1 );
189
+			$this->group_type = esc_attr(get_post_meta($this->id, '_default_calendar_list_range_type', true));
190
+			$this->group_span = max(absint(get_post_meta($this->id, '_default_calendar_list_range_span', true)), 1);
191 191
 
192 192
 			// Make the list look more compact.
193
-			if ( 'yes' == get_post_meta( $this->id, '_default_calendar_compact_list', true ) ) {
193
+			if ('yes' == get_post_meta($this->id, '_default_calendar_compact_list', true)) {
194 194
 				$this->compact_list = true;
195 195
 			}
196 196
 
@@ -211,19 +211,19 @@  discard block
 block discarded – undo
211 211
 		$old_events = $this->events;
212 212
 		$new_events = array();
213 213
 
214
-		if ( ! empty( $old_events ) ) {
214
+		if ( ! empty($old_events)) {
215 215
 
216
-			foreach ( $old_events as $events ) {
217
-				foreach ( $events as $event ) {
218
-					if ( $event instanceof Event ) {
219
-						if ( false !== $event->multiple_days ) {
216
+			foreach ($old_events as $events) {
217
+				foreach ($events as $event) {
218
+					if ($event instanceof Event) {
219
+						if (false !== $event->multiple_days) {
220 220
 							$days = $event->multiple_days;
221 221
 
222
-							if ( $days > 0 ) {
222
+							if ($days > 0) {
223 223
 
224
-								for ( $d = 1; $d <= $days; $d++ ) {
225
-									$current_day_ts = $event->start + ( $d * DAY_IN_SECONDS - 1 );
226
-									$new_events[ intval( $current_day_ts ) ][] = $event;
224
+								for ($d = 1; $d <= $days; $d++) {
225
+									$current_day_ts = $event->start + ($d * DAY_IN_SECONDS - 1);
226
+									$new_events[intval($current_day_ts)][] = $event;
227 227
 								}
228 228
 							}
229 229
 						}
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 		}
236 236
 
237 237
 		$events = $old_events + $new_events;
238
-		ksort( $events, SORT_NUMERIC );
238
+		ksort($events, SORT_NUMERIC);
239 239
 
240 240
 		return $events;
241 241
 	}
@@ -251,16 +251,16 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @return null|Calendar_View
253 253
 	 */
254
-	public function get_view( $view = '' ) {
254
+	public function get_view($view = '') {
255 255
 
256
-		$view = ! empty( $view ) ? $view : 'grid';
256
+		$view = ! empty($view) ? $view : 'grid';
257 257
 
258
-		do_action( 'simcal_calendar_get_view', $this->type, $view );
258
+		do_action('simcal_calendar_get_view', $this->type, $view);
259 259
 
260
-		if ( 'grid' == $view ) {
261
-			return new Views\Default_Calendar_Grid( $this );
262
-		} elseif ( 'list' == $view ) {
263
-			return new Views\Default_Calendar_List( $this );
260
+		if ('grid' == $view) {
261
+			return new Views\Default_Calendar_Grid($this);
262
+		} elseif ('list' == $view) {
263
+			return new Views\Default_Calendar_List($this);
264 264
 		}
265 265
 
266 266
 		return null;
Please login to merge, or discard this patch.