@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | use SimpleCalendar\Abstracts\Feed; |
12 | 12 | use SimpleCalendar\Abstracts\Field; |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -31,40 +31,40 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @param \WP_Post $post |
33 | 33 | */ |
34 | - public static function html( $post ) { |
|
34 | + public static function html($post) { |
|
35 | 35 | |
36 | 36 | // @see Meta_Boxes::save_meta_boxes() |
37 | - wp_nonce_field( 'simcal_save_data', 'simcal_meta_nonce' ); |
|
37 | + wp_nonce_field('simcal_save_data', 'simcal_meta_nonce'); |
|
38 | 38 | |
39 | 39 | ?> |
40 | 40 | <div class="simcal-panels-wrap"> |
41 | 41 | |
42 | 42 | <span class="simcal-box-handle"> |
43 | - <?php self::settings_handle( $post ); ?> |
|
43 | + <?php self::settings_handle($post); ?> |
|
44 | 44 | </span> |
45 | 45 | |
46 | 46 | <ul class="simcal-tabs"> |
47 | - <?php self::settings_tabs( $post ); ?> |
|
48 | - <?php do_action( 'simcal_settings_meta_tabs' ); ?> |
|
47 | + <?php self::settings_tabs($post); ?> |
|
48 | + <?php do_action('simcal_settings_meta_tabs'); ?> |
|
49 | 49 | </ul> |
50 | 50 | |
51 | 51 | <div class="simcal-panels"> |
52 | 52 | <div id="events-settings-panel" class="simcal-panel"> |
53 | - <?php self::events_settings_panel( $post ); ?> |
|
54 | - <?php do_action( 'simcal_settings_meta_events_panel', $post->ID ); ?> |
|
53 | + <?php self::events_settings_panel($post); ?> |
|
54 | + <?php do_action('simcal_settings_meta_events_panel', $post->ID); ?> |
|
55 | 55 | </div> |
56 | 56 | <div id="calendar-settings-panel" class="simcal-panel"> |
57 | - <?php do_action( 'simcal_settings_meta_calendar_panel', $post->ID ); ?> |
|
58 | - <?php self::calendar_settings_panel( $post ); ?> |
|
57 | + <?php do_action('simcal_settings_meta_calendar_panel', $post->ID); ?> |
|
58 | + <?php self::calendar_settings_panel($post); ?> |
|
59 | 59 | </div> |
60 | 60 | <?php |
61 | 61 | // Hook for additional settings panels. |
62 | - do_action( 'simcal_settings_meta_panels', $post->ID ); |
|
62 | + do_action('simcal_settings_meta_panels', $post->ID); |
|
63 | 63 | // Thus advanced panel is always the last one: |
64 | 64 | ?> |
65 | 65 | <div id="advanced-settings-panel" class="simcal-panel"> |
66 | - <?php self::advanced_settings_panel( $post ) ?> |
|
67 | - <?php do_action( 'simcal_settings_meta_advanced_panel', $post->ID ); ?> |
|
66 | + <?php self::advanced_settings_panel($post) ?> |
|
67 | + <?php do_action('simcal_settings_meta_advanced_panel', $post->ID); ?> |
|
68 | 68 | </div> |
69 | 69 | </div> |
70 | 70 | |
@@ -84,45 +84,45 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param \WP_Post $post |
86 | 86 | */ |
87 | - private static function settings_handle( $post ) { |
|
87 | + private static function settings_handle($post) { |
|
88 | 88 | |
89 | 89 | $feed_options = $calendar_options = $calendar_views = array(); |
90 | 90 | |
91 | 91 | $feed_types = simcal_get_feed_types(); |
92 | - foreach ( $feed_types as $feed_type ) { |
|
92 | + foreach ($feed_types as $feed_type) { |
|
93 | 93 | |
94 | - $feed = simcal_get_feed( $feed_type ); |
|
94 | + $feed = simcal_get_feed($feed_type); |
|
95 | 95 | |
96 | - if ( $feed instanceof Feed ) { |
|
97 | - $feed_options[ $feed_type ] = $feed->name; |
|
96 | + if ($feed instanceof Feed) { |
|
97 | + $feed_options[$feed_type] = $feed->name; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | $calendar_types = simcal_get_calendar_types(); |
102 | - foreach ( $calendar_types as $calendar_type => $views ) { |
|
102 | + foreach ($calendar_types as $calendar_type => $views) { |
|
103 | 103 | |
104 | - $calendar = simcal_get_calendar( $calendar_type ); |
|
104 | + $calendar = simcal_get_calendar($calendar_type); |
|
105 | 105 | |
106 | - if ( $calendar instanceof Calendar ) { |
|
107 | - $calendar_options[ $calendar_type ] = $calendar->name; |
|
108 | - $calendar_views[ $calendar_type ] = $calendar->views; |
|
106 | + if ($calendar instanceof Calendar) { |
|
107 | + $calendar_options[$calendar_type] = $calendar->name; |
|
108 | + $calendar_views[$calendar_type] = $calendar->views; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - if ( $feed_options ) { |
|
112 | + if ($feed_options) { |
|
113 | 113 | |
114 | - if ( $feed_types = wp_get_object_terms( $post->ID, 'calendar_feed' ) ) { |
|
115 | - $feed_type = sanitize_title( current( $feed_types )->name ); |
|
114 | + if ($feed_types = wp_get_object_terms($post->ID, 'calendar_feed')) { |
|
115 | + $feed_type = sanitize_title(current($feed_types)->name); |
|
116 | 116 | } else { |
117 | - $feed_type = apply_filters( 'simcal_default_feed_type', 'google' ); |
|
117 | + $feed_type = apply_filters('simcal_default_feed_type', 'google'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | ?> |
121 | - <label for="_feed_type"><span><?php _e( 'Event Source', 'google-calendar-events' ); ?></span> |
|
121 | + <label for="_feed_type"><span><?php _e('Event Source', 'google-calendar-events'); ?></span> |
|
122 | 122 | <select name="_feed_type" id="_feed_type"> |
123 | - <optgroup label="<?php _ex( 'Get events from', 'From which calendar source to load events from', 'google-calendar-events' ) ?>"> |
|
124 | - <?php foreach ( $feed_options as $feed => $name ) { ?> |
|
125 | - <option value="<?php echo $feed; ?>" <?php selected( $feed, $feed_type, true ); ?>><?php echo $name; ?></option> |
|
123 | + <optgroup label="<?php _ex('Get events from', 'From which calendar source to load events from', 'google-calendar-events') ?>"> |
|
124 | + <?php foreach ($feed_options as $feed => $name) { ?> |
|
125 | + <option value="<?php echo $feed; ?>" <?php selected($feed, $feed_type, true); ?>><?php echo $name; ?></option> |
|
126 | 126 | <?php } ?> |
127 | 127 | </optgroup> |
128 | 128 | </select> |
@@ -131,40 +131,40 @@ discard block |
||
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | - if ( $calendar_options ) { |
|
134 | + if ($calendar_options) { |
|
135 | 135 | |
136 | - if ( $calendar_types = wp_get_object_terms( $post->ID, 'calendar_type' ) ) { |
|
137 | - $calendar_type = sanitize_title( current( $calendar_types )->name ); |
|
136 | + if ($calendar_types = wp_get_object_terms($post->ID, 'calendar_type')) { |
|
137 | + $calendar_type = sanitize_title(current($calendar_types)->name); |
|
138 | 138 | } else { |
139 | - $calendar_type = apply_filters( 'simcal_default_calendar_type', 'default-calendar' ); |
|
139 | + $calendar_type = apply_filters('simcal_default_calendar_type', 'default-calendar'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | ?> |
143 | - <label for="_calendar_type"><span><?php _e( 'Calendar Type', 'google-calendar-events' ); ?></span> |
|
143 | + <label for="_calendar_type"><span><?php _e('Calendar Type', 'google-calendar-events'); ?></span> |
|
144 | 144 | <select name="_calendar_type" id="_calendar_type"> |
145 | - <optgroup label="<?php _e( 'Calendar to use', 'google-calendar-events' ); ?>"> |
|
146 | - <?php foreach ( $calendar_options as $calendar => $name ) { ?> |
|
147 | - <option value="<?php echo $calendar; ?>" <?php selected( $calendar, $calendar_type, true ); ?>><?php echo $name; ?></option> |
|
145 | + <optgroup label="<?php _e('Calendar to use', 'google-calendar-events'); ?>"> |
|
146 | + <?php foreach ($calendar_options as $calendar => $name) { ?> |
|
147 | + <option value="<?php echo $calendar; ?>" <?php selected($calendar, $calendar_type, true); ?>><?php echo $name; ?></option> |
|
148 | 148 | <?php } ?> |
149 | 149 | </optgroup> |
150 | 150 | </select> |
151 | 151 | </label> |
152 | 152 | <?php |
153 | 153 | |
154 | - if ( $calendar_views ) { |
|
154 | + if ($calendar_views) { |
|
155 | 155 | |
156 | - $calendar_view = get_post_meta( $post->ID, '_calendar_view', true ); |
|
156 | + $calendar_view = get_post_meta($post->ID, '_calendar_view', true); |
|
157 | 157 | |
158 | - foreach ( $calendar_views as $calendar => $views ) { |
|
158 | + foreach ($calendar_views as $calendar => $views) { |
|
159 | 159 | |
160 | - $calendar_type_view = isset( $calendar_view[ $calendar ] ) ? $calendar_view[ $calendar ] : ''; |
|
160 | + $calendar_type_view = isset($calendar_view[$calendar]) ? $calendar_view[$calendar] : ''; |
|
161 | 161 | |
162 | 162 | ?> |
163 | - <label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e( 'View', 'google-calendar-events' ); ?></span> |
|
163 | + <label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e('View', 'google-calendar-events'); ?></span> |
|
164 | 164 | <select name="_calendar_view[<?php echo $calendar; ?>]" id="_calendar_view_<?php echo $calendar; ?>"> |
165 | - <optgroup label="<?php _e( 'View to display', 'google-calendar-events' ); ?>"> |
|
166 | - <?php foreach ( $views as $view => $name ) { ?> |
|
167 | - <option value="<?php echo $view; ?>" <?php selected( $view, $calendar_type_view, true ); ?>><?php echo $name; ?></option> |
|
165 | + <optgroup label="<?php _e('View to display', 'google-calendar-events'); ?>"> |
|
166 | + <?php foreach ($views as $view => $name) { ?> |
|
167 | + <option value="<?php echo $view; ?>" <?php selected($view, $calendar_type_view, true); ?>><?php echo $name; ?></option> |
|
168 | 168 | <?php } ?> |
169 | 169 | </optgroup> |
170 | 170 | </select> |
@@ -184,42 +184,42 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @param \WP_Post $post |
186 | 186 | */ |
187 | - private static function settings_tabs( $post ) { |
|
187 | + private static function settings_tabs($post) { |
|
188 | 188 | |
189 | 189 | // Hook to add more tabs. |
190 | - $tabs = apply_filters( 'simcal_settings_meta_tabs_li', array( |
|
190 | + $tabs = apply_filters('simcal_settings_meta_tabs_li', array( |
|
191 | 191 | 'events' => array( |
192 | - 'label' => __( 'Events', 'google-calendar-events' ), |
|
192 | + 'label' => __('Events', 'google-calendar-events'), |
|
193 | 193 | 'target' => 'events-settings-panel', |
194 | - 'class' => array( 'active' ), |
|
194 | + 'class' => array('active'), |
|
195 | 195 | 'icon' => 'simcal-icon-event', |
196 | 196 | ), |
197 | 197 | 'calendar' => array( |
198 | - 'label' => __( 'Appearance', 'google-calendar-events' ), |
|
198 | + 'label' => __('Appearance', 'google-calendar-events'), |
|
199 | 199 | 'target' => 'calendar-settings-panel', |
200 | 200 | 'class' => array(), |
201 | 201 | 'icon' => 'simcal-icon-calendar', |
202 | 202 | ), |
203 | - ), $post->ID ); |
|
203 | + ), $post->ID); |
|
204 | 204 | |
205 | 205 | // Always keep advanced tab as the last one. |
206 | 206 | $tabs['advanced'] = array( |
207 | - 'label' => __( 'Advanced', 'google-calendar-events' ), |
|
207 | + 'label' => __('Advanced', 'google-calendar-events'), |
|
208 | 208 | 'target' => 'advanced-settings-panel', |
209 | 209 | 'class' => array(), |
210 | 210 | 'icon' => 'simcal-icon-settings', |
211 | 211 | ); |
212 | 212 | |
213 | 213 | // Output the tabs as list items. |
214 | - foreach ( $tabs as $key => $tab ) { |
|
214 | + foreach ($tabs as $key => $tab) { |
|
215 | 215 | |
216 | - if ( isset( $tab['target'] ) && isset( $tab['label'] ) ) { |
|
216 | + if (isset($tab['target']) && isset($tab['label'])) { |
|
217 | 217 | |
218 | 218 | $icon = $tab['icon'] ? $tab['icon'] : 'simcal-icon-panel'; |
219 | 219 | $class = $tab['class'] ? $tab['class'] : array(); |
220 | 220 | |
221 | - echo '<li class="' . $key . '-settings ' . $key . '-tab ' . implode( ' ', $class ) . '" data-tab="' . $key . '">'; |
|
222 | - echo '<a href="#' . $tab['target'] . '"><i class="' . $icon . '" ></i> <span>' . esc_html( $tab['label'] ) . '</span></a>'; |
|
221 | + echo '<li class="'.$key.'-settings '.$key.'-tab '.implode(' ', $class).'" data-tab="'.$key.'">'; |
|
222 | + echo '<a href="#'.$tab['target'].'"><i class="'.$icon.'" ></i> <span>'.esc_html($tab['label']).'</span></a>'; |
|
223 | 223 | echo '</li>'; |
224 | 224 | } |
225 | 225 | } |
@@ -233,22 +233,22 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @param \WP_Post $post |
235 | 235 | */ |
236 | - private static function events_settings_panel( $post ) { |
|
236 | + private static function events_settings_panel($post) { |
|
237 | 237 | |
238 | 238 | ?> |
239 | 239 | <table> |
240 | 240 | <thead> |
241 | - <tr><th colspan="2"><?php _e( 'Event Settings', 'google-calendar-events' ); ?></th></tr> |
|
241 | + <tr><th colspan="2"><?php _e('Event Settings', 'google-calendar-events'); ?></th></tr> |
|
242 | 242 | </thead> |
243 | 243 | <tbody class="simcal-panel-section simcal-panel-section-events-range"> |
244 | 244 | <tr class="simcal-panel-field"> |
245 | - <th><label for="_calendar_begins"><?php _e( 'Calendar Start', 'google-calendar-events' ); ?></label></th> |
|
245 | + <th><label for="_calendar_begins"><?php _e('Calendar Start', 'google-calendar-events'); ?></label></th> |
|
246 | 246 | <td> |
247 | 247 | <?php |
248 | 248 | |
249 | - $calendar_begins = esc_attr( get_post_meta( $post->ID, '_calendar_begins', true ) ); |
|
250 | - $calendar_begins_nth = max( absint( get_post_meta( $post->ID, '_calendar_begins_nth', true ) ), 1 ); |
|
251 | - $calendar_begins_nth_show = in_array( $calendar_begins, array( |
|
249 | + $calendar_begins = esc_attr(get_post_meta($post->ID, '_calendar_begins', true)); |
|
250 | + $calendar_begins_nth = max(absint(get_post_meta($post->ID, '_calendar_begins_nth', true)), 1); |
|
251 | + $calendar_begins_nth_show = in_array($calendar_begins, array( |
|
252 | 252 | 'days_before', |
253 | 253 | 'days_after', |
254 | 254 | 'weeks_before', |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | 'months_after', |
258 | 258 | 'years_before', |
259 | 259 | 'years_after', |
260 | - ) ); |
|
260 | + )); |
|
261 | 261 | |
262 | - simcal_print_field( array( |
|
262 | + simcal_print_field(array( |
|
263 | 263 | 'type' => 'standard', |
264 | 264 | 'subtype' => 'number', |
265 | 265 | 'name' => '_calendar_begins_nth', |
266 | 266 | 'id' => '_calendar_begins_nth', |
267 | - 'value' => strval( $calendar_begins_nth ), |
|
267 | + 'value' => strval($calendar_begins_nth), |
|
268 | 268 | 'attributes' => array( |
269 | 269 | 'min' => '1', |
270 | 270 | ), |
@@ -272,97 +272,97 @@ discard block |
||
272 | 272 | 'simcal-field-inline', |
273 | 273 | 'simcal-field-tiny', |
274 | 274 | ), |
275 | - 'style' => ! $calendar_begins_nth_show ? array( 'display' => 'none' ) : '', |
|
276 | - ) ); |
|
275 | + 'style' => ! $calendar_begins_nth_show ? array('display' => 'none') : '', |
|
276 | + )); |
|
277 | 277 | |
278 | 278 | ?> |
279 | 279 | <select name="_calendar_begins" |
280 | 280 | id="_calendar_begins" |
281 | 281 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
282 | - <optgroup label="<?php _e( 'Days', 'google-calendar-events' ); ?>"> |
|
282 | + <optgroup label="<?php _e('Days', 'google-calendar-events'); ?>"> |
|
283 | 283 | <option value="today" |
284 | 284 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
285 | - <?php selected( 'today', $calendar_begins, true ); ?>><?php _e( 'Today', 'google-calendar-events' ); ?></option> |
|
285 | + <?php selected('today', $calendar_begins, true); ?>><?php _e('Today', 'google-calendar-events'); ?></option> |
|
286 | 286 | <option value="now" |
287 | 287 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
288 | - <?php selected( 'now', $calendar_begins, true ); ?>><?php _e( 'Now', 'google-calendar-events' ); ?></option> |
|
288 | + <?php selected('now', $calendar_begins, true); ?>><?php _e('Now', 'google-calendar-events'); ?></option> |
|
289 | 289 | <option value="days_before" |
290 | 290 | data-hide-field="_calendar_begins_custom_date" |
291 | - data-show-field="_calendar_begins_nth" <?php selected( 'days_before', $calendar_begins, true ); ?>><?php _e( 'Day(s) before today', 'google-calendar-events' ); ?></option> |
|
291 | + data-show-field="_calendar_begins_nth" <?php selected('days_before', $calendar_begins, true); ?>><?php _e('Day(s) before today', 'google-calendar-events'); ?></option> |
|
292 | 292 | <option value="days_after" |
293 | 293 | data-hide-field="_calendar_begins_custom_date" |
294 | - data-show-field="_calendar_begins_nth" <?php selected( 'days_after', $calendar_begins, true ); ?>><?php _e( 'Day(s) after today', 'google-calendar-events' ); ?></option> |
|
294 | + data-show-field="_calendar_begins_nth" <?php selected('days_after', $calendar_begins, true); ?>><?php _e('Day(s) after today', 'google-calendar-events'); ?></option> |
|
295 | 295 | </optgroup> |
296 | - <optgroup label="<?php _e( 'Weeks', 'google-calendar-events' ); ?>"> |
|
296 | + <optgroup label="<?php _e('Weeks', 'google-calendar-events'); ?>"> |
|
297 | 297 | <option value="this_week" |
298 | 298 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
299 | - <?php selected( 'this_week', $calendar_begins, true ); ?>><?php _e( 'This week', 'google-calendar-events' ); ?></option> |
|
299 | + <?php selected('this_week', $calendar_begins, true); ?>><?php _e('This week', 'google-calendar-events'); ?></option> |
|
300 | 300 | <option value="weeks_before" |
301 | 301 | data-hide-field="_calendar_begins_custom_date" |
302 | - data-show-field="_calendar_begins_nth" <?php selected( 'weeks_before', $calendar_begins, true ); ?>><?php _e( 'Week(s) before current', 'google-calendar-events' ); ?></option> |
|
302 | + data-show-field="_calendar_begins_nth" <?php selected('weeks_before', $calendar_begins, true); ?>><?php _e('Week(s) before current', 'google-calendar-events'); ?></option> |
|
303 | 303 | <option value="weeks_after" |
304 | 304 | data-hide-field="_calendar_begins_custom_date" |
305 | - data-show-field="_calendar_begins_nth" <?php selected( 'weeks_after', $calendar_begins, true ); ?>><?php _e( 'Week(s) after current', 'google-calendar-events' ); ?></option> |
|
305 | + data-show-field="_calendar_begins_nth" <?php selected('weeks_after', $calendar_begins, true); ?>><?php _e('Week(s) after current', 'google-calendar-events'); ?></option> |
|
306 | 306 | </optgroup> |
307 | - <optgroup label="<?php _e( 'Months', 'google-calendar-events' ); ?>"> |
|
307 | + <optgroup label="<?php _e('Months', 'google-calendar-events'); ?>"> |
|
308 | 308 | <option value="this_month" |
309 | 309 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
310 | - <?php selected( 'this_month', $calendar_begins, true ); ?>><?php _e( 'This month', 'google-calendar-events' ); ?></option> |
|
310 | + <?php selected('this_month', $calendar_begins, true); ?>><?php _e('This month', 'google-calendar-events'); ?></option> |
|
311 | 311 | <option value="months_before" |
312 | 312 | data-hide-field="_calendar_begins_custom_date" |
313 | - data-show-field="_calendar_begins_nth" <?php selected( 'months_before', $calendar_begins, true ); ?>><?php _e( 'Month(s) before current', 'google-calendar-events' ); ?></option> |
|
313 | + data-show-field="_calendar_begins_nth" <?php selected('months_before', $calendar_begins, true); ?>><?php _e('Month(s) before current', 'google-calendar-events'); ?></option> |
|
314 | 314 | <option value="months_after" |
315 | 315 | data-hide-field="_calendar_begins_custom_date" |
316 | - data-show-field="_calendar_begins_nth" <?php selected( 'months_after', $calendar_begins, true ); ?>><?php _e( 'Month(s) after current', 'google-calendar-events' ); ?></option> |
|
316 | + data-show-field="_calendar_begins_nth" <?php selected('months_after', $calendar_begins, true); ?>><?php _e('Month(s) after current', 'google-calendar-events'); ?></option> |
|
317 | 317 | </optgroup> |
318 | - <optgroup label="<?php _e( 'Years', 'google-calendar-events' ); ?>"> |
|
318 | + <optgroup label="<?php _e('Years', 'google-calendar-events'); ?>"> |
|
319 | 319 | <option value="this_year" |
320 | 320 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
321 | - <?php selected( 'this_year', $calendar_begins, true ); ?>><?php _e( 'This year', 'google-calendar-events' ); ?></option> |
|
321 | + <?php selected('this_year', $calendar_begins, true); ?>><?php _e('This year', 'google-calendar-events'); ?></option> |
|
322 | 322 | <option value="years_before" |
323 | - data-show-field="_calendar_begins_nth" <?php selected( 'years_before', $calendar_begins, true ); ?>><?php _e( 'Year(s) before current', 'google-calendar-events' ); ?></option> |
|
323 | + data-show-field="_calendar_begins_nth" <?php selected('years_before', $calendar_begins, true); ?>><?php _e('Year(s) before current', 'google-calendar-events'); ?></option> |
|
324 | 324 | <option value="years_after" |
325 | 325 | data-hide-field="_calendar_begins_custom_date" |
326 | - data-show-field="_calendar_begins_nth" <?php selected( 'years_after', $calendar_begins, true ); ?>><?php _e( 'Year(s) after current', 'google-calendar-events' ); ?></option> |
|
326 | + data-show-field="_calendar_begins_nth" <?php selected('years_after', $calendar_begins, true); ?>><?php _e('Year(s) after current', 'google-calendar-events'); ?></option> |
|
327 | 327 | </optgroup> |
328 | - <optgroup label="<?php _e( 'Other', 'google-calendar-events' ); ?>"> |
|
328 | + <optgroup label="<?php _e('Other', 'google-calendar-events'); ?>"> |
|
329 | 329 | <option value="custom_date" |
330 | 330 | data-hide-field="_calendar_begins_nth" |
331 | - data-show-field="_calendar_begins_custom_date" <?php selected( 'custom_date', $calendar_begins, true ); ?>><?php _e( 'Specific date', 'google-calendar-events' ); ?></option> |
|
331 | + data-show-field="_calendar_begins_custom_date" <?php selected('custom_date', $calendar_begins, true); ?>><?php _e('Specific date', 'google-calendar-events'); ?></option> |
|
332 | 332 | </optgroup> |
333 | 333 | </select> |
334 | 334 | <?php |
335 | 335 | |
336 | - simcal_print_field( array( |
|
336 | + simcal_print_field(array( |
|
337 | 337 | 'type' => 'date-picker', |
338 | 338 | 'name' => '_calendar_begins_custom_date', |
339 | 339 | 'id' => '_calendar_begins_custom_date', |
340 | - 'value' => get_post_meta( $post->ID, '_calendar_begins_custom_date', true ), |
|
340 | + 'value' => get_post_meta($post->ID, '_calendar_begins_custom_date', true), |
|
341 | 341 | 'class' => array( |
342 | 342 | 'simcal-field-inline', |
343 | 343 | ), |
344 | - 'style' => 'custom_date' != $calendar_begins ? array( 'display' => 'none' ) : '', |
|
345 | - ) ); |
|
344 | + 'style' => 'custom_date' != $calendar_begins ? array('display' => 'none') : '', |
|
345 | + )); |
|
346 | 346 | |
347 | 347 | ?> |
348 | 348 | <i class="simcal-icon-help simcal-help-tip" |
349 | - data-tip="<?php _e( 'The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events' ); ?>"></i> |
|
349 | + data-tip="<?php _e('The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events'); ?>"></i> |
|
350 | 350 | </td> |
351 | 351 | </tr> |
352 | 352 | <tr class="simcal-panel-field"> |
353 | - <th><label for="_feed_earliest_event_date"><?php _e( 'Earliest Event', 'google-calendar-events' ); ?></label></th> |
|
353 | + <th><label for="_feed_earliest_event_date"><?php _e('Earliest Event', 'google-calendar-events'); ?></label></th> |
|
354 | 354 | <td> |
355 | 355 | <?php |
356 | 356 | |
357 | - $earliest_event_saved = get_post_meta( $post->ID, '_feed_earliest_event_date', true ); |
|
358 | - $earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr( $earliest_event_saved ); |
|
357 | + $earliest_event_saved = get_post_meta($post->ID, '_feed_earliest_event_date', true); |
|
358 | + $earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr($earliest_event_saved); |
|
359 | 359 | |
360 | - simcal_print_field( array( |
|
360 | + simcal_print_field(array( |
|
361 | 361 | 'type' => 'standard', |
362 | 362 | 'subtype' => 'number', |
363 | 363 | 'name' => '_feed_earliest_event_date_range', |
364 | 364 | 'id' => '_feed_earliest_event_date_range', |
365 | - 'value' => strval( max( absint( get_post_meta( $post->ID, '_feed_earliest_event_date_range', true ) ), 1 ) ), |
|
365 | + 'value' => strval(max(absint(get_post_meta($post->ID, '_feed_earliest_event_date_range', true)), 1)), |
|
366 | 366 | 'attributes' => array( |
367 | 367 | 'min' => '1', |
368 | 368 | ), |
@@ -370,37 +370,37 @@ discard block |
||
370 | 370 | 'simcal-field-inline', |
371 | 371 | 'simcal-field-tiny', |
372 | 372 | ), |
373 | - 'style' => ( 'now' != $earliest_event ) && ( 'today' != $earliest_event ) ? array( 'display' => 'none' ) : '', |
|
374 | - ) ); |
|
373 | + 'style' => ('now' != $earliest_event) && ('today' != $earliest_event) ? array('display' => 'none') : '', |
|
374 | + )); |
|
375 | 375 | |
376 | 376 | ?> |
377 | 377 | <select name="_feed_earliest_event_date" |
378 | 378 | id="_feed_earliest_event_date" |
379 | 379 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
380 | - <option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Same as start date', 'google-calendar-events' ); ?></option> |
|
381 | - <option value="days_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'days_before', $earliest_event, true ); ?>><?php _e( 'Day(s) before start date', 'google-calendar-events' ); ?></option> |
|
382 | - <option value="weeks_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'weeks_before', $earliest_event, true ); ?>><?php _e( 'Week(s) before start date', 'google-calendar-events' ); ?></option> |
|
383 | - <option value="months_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'months_before', $earliest_event, true ); ?>><?php _e( 'Month(s) before start date', 'google-calendar-events' ); ?></option> |
|
384 | - <option value="years_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'years_before', $earliest_event, true ); ?>><?php _e( 'Year(s) before start date', 'google-calendar-events' ); ?></option> |
|
380 | + <option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Same as start date', 'google-calendar-events'); ?></option> |
|
381 | + <option value="days_before" data-show-field="_feed_earliest_event_date_range" <?php selected('days_before', $earliest_event, true); ?>><?php _e('Day(s) before start date', 'google-calendar-events'); ?></option> |
|
382 | + <option value="weeks_before" data-show-field="_feed_earliest_event_date_range" <?php selected('weeks_before', $earliest_event, true); ?>><?php _e('Week(s) before start date', 'google-calendar-events'); ?></option> |
|
383 | + <option value="months_before" data-show-field="_feed_earliest_event_date_range" <?php selected('months_before', $earliest_event, true); ?>><?php _e('Month(s) before start date', 'google-calendar-events'); ?></option> |
|
384 | + <option value="years_before" data-show-field="_feed_earliest_event_date_range" <?php selected('years_before', $earliest_event, true); ?>><?php _e('Year(s) before start date', 'google-calendar-events'); ?></option> |
|
385 | 385 | </select> |
386 | 386 | <i class="simcal-icon-help simcal-help-tip" |
387 | - data-tip="<?php _e( 'Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events' ); ?>"></i> |
|
387 | + data-tip="<?php _e('Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events'); ?>"></i> |
|
388 | 388 | </td> |
389 | 389 | </tr> |
390 | 390 | <tr class="simcal-panel-field"> |
391 | - <th><label for="_feed_latest_event_date"><?php _e( 'Latest Event', 'google-calendar-events' ); ?></label></th> |
|
391 | + <th><label for="_feed_latest_event_date"><?php _e('Latest Event', 'google-calendar-events'); ?></label></th> |
|
392 | 392 | <td> |
393 | 393 | <?php |
394 | 394 | |
395 | - $latest_event_saved = get_post_meta( $post->ID, '_feed_latest_event_date', true ); |
|
396 | - $latest_event = false == $latest_event_saved ? 'years_after' : esc_attr( $latest_event_saved ); |
|
395 | + $latest_event_saved = get_post_meta($post->ID, '_feed_latest_event_date', true); |
|
396 | + $latest_event = false == $latest_event_saved ? 'years_after' : esc_attr($latest_event_saved); |
|
397 | 397 | |
398 | - simcal_print_field( array( |
|
398 | + simcal_print_field(array( |
|
399 | 399 | 'type' => 'standard', |
400 | 400 | 'subtype' => 'number', |
401 | 401 | 'name' => '_feed_latest_event_date_range', |
402 | 402 | 'id' => '_feed_latest_event_date_range', |
403 | - 'value' => strval( max( absint( get_post_meta( $post->ID, '_feed_latest_event_date_range', true ) ), 1 ) ), |
|
403 | + 'value' => strval(max(absint(get_post_meta($post->ID, '_feed_latest_event_date_range', true)), 1)), |
|
404 | 404 | 'attributes' => array( |
405 | 405 | 'min' => '1', |
406 | 406 | ), |
@@ -408,21 +408,21 @@ discard block |
||
408 | 408 | 'simcal-field-inline', |
409 | 409 | 'simcal-field-tiny', |
410 | 410 | ), |
411 | - 'style' => 'indefinite' != $latest_event ? array( 'display' => 'none' ) : '', |
|
412 | - ) ); |
|
411 | + 'style' => 'indefinite' != $latest_event ? array('display' => 'none') : '', |
|
412 | + )); |
|
413 | 413 | |
414 | 414 | ?> |
415 | 415 | <select name="_feed_latest_event_date" |
416 | 416 | id="_feed_latest_event_date" |
417 | 417 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
418 | - <option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Day end of start date', 'google-calendar-events' ); ?></option> |
|
419 | - <option value="days_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'days_after', $latest_event, true ); ?>><?php _e( 'Day(s) after start date', 'google-calendar-events' ); ?></option> |
|
420 | - <option value="weeks_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'weeks_after', $latest_event, true ); ?>><?php _e( 'Weeks(s) after start date', 'google-calendar-events' ); ?></option> |
|
421 | - <option value="months_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'months_after', $latest_event, true ); ?>><?php _e( 'Month(s) after start date', 'google-calendar-events' ); ?></option> |
|
422 | - <option value="years_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'years_after', $latest_event, true ); ?>><?php _e( 'Year(s) after start date', 'google-calendar-events' ); ?></option> |
|
418 | + <option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Day end of start date', 'google-calendar-events'); ?></option> |
|
419 | + <option value="days_after" data-show-field="_feed_latest_event_date_range" <?php selected('days_after', $latest_event, true); ?>><?php _e('Day(s) after start date', 'google-calendar-events'); ?></option> |
|
420 | + <option value="weeks_after" data-show-field="_feed_latest_event_date_range" <?php selected('weeks_after', $latest_event, true); ?>><?php _e('Weeks(s) after start date', 'google-calendar-events'); ?></option> |
|
421 | + <option value="months_after" data-show-field="_feed_latest_event_date_range" <?php selected('months_after', $latest_event, true); ?>><?php _e('Month(s) after start date', 'google-calendar-events'); ?></option> |
|
422 | + <option value="years_after" data-show-field="_feed_latest_event_date_range" <?php selected('years_after', $latest_event, true); ?>><?php _e('Year(s) after start date', 'google-calendar-events'); ?></option> |
|
423 | 423 | </select> |
424 | 424 | <i class="simcal-icon-help simcal-help-tip" |
425 | - data-tip="<?php _e( 'Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events' ); ?>"></i> |
|
425 | + data-tip="<?php _e('Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events'); ?>"></i> |
|
426 | 426 | </td> |
427 | 427 | </tr> |
428 | 428 | </tbody> |
@@ -439,88 +439,88 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @param \WP_Post $post |
441 | 441 | */ |
442 | - private static function calendar_settings_panel( $post ) { |
|
442 | + private static function calendar_settings_panel($post) { |
|
443 | 443 | |
444 | 444 | ?> |
445 | 445 | <table> |
446 | 446 | <thead> |
447 | - <tr><th colspan="2"><?php _e( 'Miscellaneous', 'google-calendar-events' ); ?></th></tr> |
|
447 | + <tr><th colspan="2"><?php _e('Miscellaneous', 'google-calendar-events'); ?></th></tr> |
|
448 | 448 | </thead> |
449 | 449 | <tbody class="simcal-panel-section"> |
450 | 450 | <tr class="simcal-panel-field"> |
451 | - <th><label for="_calendar_is_static"><?php _e( 'Static Calendar', 'google-calendar-events' ); ?></label></th> |
|
451 | + <th><label for="_calendar_is_static"><?php _e('Static Calendar', 'google-calendar-events'); ?></label></th> |
|
452 | 452 | <td> |
453 | 453 | <?php |
454 | 454 | |
455 | - $fixed = get_post_meta( $post->ID, '_calendar_is_static', true ); |
|
455 | + $fixed = get_post_meta($post->ID, '_calendar_is_static', true); |
|
456 | 456 | |
457 | - simcal_print_field( array( |
|
457 | + simcal_print_field(array( |
|
458 | 458 | 'type' => 'checkbox', |
459 | 459 | 'name' => '_calendar_is_static', |
460 | 460 | 'id' => '_calendar_is_static', |
461 | - 'tooltip' => __( 'Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events' ), |
|
461 | + 'tooltip' => __('Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events'), |
|
462 | 462 | 'value' => 'yes' == $fixed ? 'yes' : 'no', |
463 | - 'text' => __( 'Yes (hide navigation arrows)', 'google-calendar-events' ), |
|
464 | - ) ); |
|
463 | + 'text' => __('Yes (hide navigation arrows)', 'google-calendar-events'), |
|
464 | + )); |
|
465 | 465 | |
466 | 466 | ?> |
467 | 467 | </td> |
468 | 468 | </tr> |
469 | 469 | <tr class="simcal-panel-field"> |
470 | - <th><label for="_no_events_message"><?php _e( 'No Events Message', 'google-calendar-events' ); ?></label></th> |
|
470 | + <th><label for="_no_events_message"><?php _e('No Events Message', 'google-calendar-events'); ?></label></th> |
|
471 | 471 | <td> |
472 | 472 | <?php |
473 | 473 | |
474 | - simcal_print_field( array( |
|
474 | + simcal_print_field(array( |
|
475 | 475 | 'type' => 'textarea', |
476 | 476 | 'name' => '_no_events_message', |
477 | 477 | 'id' => '_no_events_message', |
478 | - 'tooltip' => __( 'Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events' ), |
|
479 | - 'value' => get_post_meta( $post->ID, '_no_events_message', true ), |
|
480 | - 'placeholder' => __( 'There are no upcoming events.', 'google-calendar-events' ), |
|
481 | - ) ); |
|
478 | + 'tooltip' => __('Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events'), |
|
479 | + 'value' => get_post_meta($post->ID, '_no_events_message', true), |
|
480 | + 'placeholder' => __('There are no upcoming events.', 'google-calendar-events'), |
|
481 | + )); |
|
482 | 482 | |
483 | 483 | ?> |
484 | 484 | </td> |
485 | 485 | </tr> |
486 | 486 | <tr class="simcal-panel-field"> |
487 | - <th><label for="_event_formatting"><?php _e( 'Event Formatting', 'google-calendar-events' ); ?></label></th> |
|
487 | + <th><label for="_event_formatting"><?php _e('Event Formatting', 'google-calendar-events'); ?></label></th> |
|
488 | 488 | <td> |
489 | 489 | <?php |
490 | 490 | |
491 | - $event_formatting = get_post_meta( $post->ID, '_event_formatting', true ); |
|
491 | + $event_formatting = get_post_meta($post->ID, '_event_formatting', true); |
|
492 | 492 | |
493 | - simcal_print_field( array( |
|
493 | + simcal_print_field(array( |
|
494 | 494 | 'type' => 'select', |
495 | 495 | 'name' => '_event_formatting', |
496 | 496 | 'id' => '_event_formatting', |
497 | - 'tooltip' => __( 'How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events' ), |
|
497 | + 'tooltip' => __('How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events'), |
|
498 | 498 | 'value' => $event_formatting, |
499 | 499 | 'default' => 'preserve_linebreaks', |
500 | 500 | 'options' => array( |
501 | - 'preserve_linebreaks' => __( 'Preserve line breaks, auto paragraphs (default)', 'google-calendar-events' ), |
|
502 | - 'no_linebreaks' => __( 'No line breaks, auto paragraphs', 'google-calendar-events' ), |
|
503 | - 'none' => __( 'No line breaks, no auto paragraphs', 'google-calendar-events' ), |
|
501 | + 'preserve_linebreaks' => __('Preserve line breaks, auto paragraphs (default)', 'google-calendar-events'), |
|
502 | + 'no_linebreaks' => __('No line breaks, auto paragraphs', 'google-calendar-events'), |
|
503 | + 'none' => __('No line breaks, no auto paragraphs', 'google-calendar-events'), |
|
504 | 504 | ), |
505 | - ) ); |
|
505 | + )); |
|
506 | 506 | |
507 | 507 | ?> |
508 | 508 | </td> |
509 | 509 | </tr> |
510 | 510 | <tr class="simcal-panel-field"> |
511 | - <th><label for="_poweredby"><?php _e( 'Powered By', 'google-calendar-events' ); ?></label></th> |
|
511 | + <th><label for="_poweredby"><?php _e('Powered By', 'google-calendar-events'); ?></label></th> |
|
512 | 512 | <td> |
513 | 513 | <?php |
514 | 514 | |
515 | - $poweredby = get_post_meta( $post->ID, '_poweredby', true ); |
|
515 | + $poweredby = get_post_meta($post->ID, '_poweredby', true); |
|
516 | 516 | |
517 | - simcal_print_field( array( |
|
517 | + simcal_print_field(array( |
|
518 | 518 | 'type' => 'checkbox', |
519 | 519 | 'name' => '_poweredby', |
520 | 520 | 'id' => '_poweredby', |
521 | 521 | 'value' => 'yes' == $poweredby ? 'yes' : 'no', |
522 | - 'text' => __( 'Yes, Simple Calendar rocks! Show some love with a little link below this calendar.', 'google-calendar-events' ), |
|
523 | - ) ); |
|
522 | + 'text' => __('Yes, Simple Calendar rocks! Show some love with a little link below this calendar.', 'google-calendar-events'), |
|
523 | + )); |
|
524 | 524 | |
525 | 525 | ?> |
526 | 526 | </td> |
@@ -539,28 +539,28 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @param \WP_Post $post |
541 | 541 | */ |
542 | - private static function advanced_settings_panel( $post ) { |
|
542 | + private static function advanced_settings_panel($post) { |
|
543 | 543 | |
544 | 544 | ?> |
545 | 545 | <table> |
546 | 546 | <thead> |
547 | - <tr><th colspan="2"><?php _e( 'Date and Time', 'google-calendar-events' ); ?></th></tr> |
|
547 | + <tr><th colspan="2"><?php _e('Date and Time', 'google-calendar-events'); ?></th></tr> |
|
548 | 548 | </thead> |
549 | 549 | <tbody class="simcal-panel-section simcal-panel-datetime-formatting"> |
550 | 550 | <tr class="simcal-panel-field"> |
551 | - <th><label for="_calendar_timezone_setting"><?php _e( 'Timezone', 'google-calendar-events' ); ?></label></th> |
|
551 | + <th><label for="_calendar_timezone_setting"><?php _e('Timezone', 'google-calendar-events'); ?></label></th> |
|
552 | 552 | <td> |
553 | 553 | <?php |
554 | 554 | |
555 | 555 | $timezone_wordpress = simcal_get_wp_timezone(); |
556 | 556 | $timezone_default = $timezone_wordpress ? $timezone_wordpress : 'UTC'; |
557 | - $timezone_setting = esc_attr( get_post_meta( $post->ID, '_feed_timezone_setting', true ) ); |
|
558 | - $timezone = esc_attr( get_post_meta( $post->ID, '_feed_timezone', true ) ); |
|
557 | + $timezone_setting = esc_attr(get_post_meta($post->ID, '_feed_timezone_setting', true)); |
|
558 | + $timezone = esc_attr(get_post_meta($post->ID, '_feed_timezone', true)); |
|
559 | 559 | $timezone = $timezone ? $timezone : $timezone_default; |
560 | - $show_use_calendar = isset( simcal_get_feed( $post )->type ); |
|
560 | + $show_use_calendar = isset(simcal_get_feed($post)->type); |
|
561 | 561 | |
562 | - if ( $show_use_calendar ) { |
|
563 | - $show_use_calendar = ( simcal_get_feed( $post )->type !== 'grouped-calendars' ? 1 : 0 ); |
|
562 | + if ($show_use_calendar) { |
|
563 | + $show_use_calendar = (simcal_get_feed($post)->type !== 'grouped-calendars' ? 1 : 0); |
|
564 | 564 | } else { |
565 | 565 | $show_use_calendar = true; |
566 | 566 | } |
@@ -570,58 +570,58 @@ discard block |
||
570 | 570 | id="_feed_timezone_setting" |
571 | 571 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other" |
572 | 572 | data-show-field-on-choice="true"> |
573 | - <option value="use_site" <?php selected( 'use_site', $timezone_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', $timezone_default ); ?></option> |
|
574 | - <?php if ( $show_use_calendar ) { ?> |
|
575 | - <option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected( 'use_calendar', $timezone_setting, true ); ?>><?php _ex( 'Event source default', 'Use the calendar default setting', 'google-calendar-events' ); ?></option> |
|
573 | + <option value="use_site" <?php selected('use_site', $timezone_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', $timezone_default); ?></option> |
|
574 | + <?php if ($show_use_calendar) { ?> |
|
575 | + <option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected('use_calendar', $timezone_setting, true); ?>><?php _ex('Event source default', 'Use the calendar default setting', 'google-calendar-events'); ?></option> |
|
576 | 576 | <?php } ?> |
577 | - <option value="use_custom" data-show-field="_feed_timezone" <?php selected( 'use_custom', $timezone_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
577 | + <option value="use_custom" data-show-field="_feed_timezone" <?php selected('use_custom', $timezone_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
578 | 578 | </select> |
579 | 579 | <select name="_feed_timezone" |
580 | 580 | id="_feed_timezone" |
581 | 581 | class="simcal-field simcal-field-select simcal-field-inline" |
582 | 582 | <?php echo 'use_custom' != $timezone_setting ? 'style="display: none;"' : ''; ?>> |
583 | - <?php echo wp_timezone_choice( $timezone ); ?> |
|
583 | + <?php echo wp_timezone_choice($timezone); ?> |
|
584 | 584 | </select> |
585 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Using a different timezone may alter the date and time display of your calendar events. We recommended using the site default timezone.', 'google-calendar-events' ); ?>"></i> |
|
585 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Using a different timezone may alter the date and time display of your calendar events. We recommended using the site default timezone.', 'google-calendar-events'); ?>"></i> |
|
586 | 586 | <p id="_use_calendar_warning" style="display: none;" class="simcal-field"> |
587 | - <span class="attention"><?php _e( 'Warning', 'google-calendar-events' ); ?>:</span> |
|
588 | - <?php _e( 'Setting this to <code>Event source default</code> can at times cause unexpected results. Please test thoroughly.', 'google-calendar-events' ); ?> |
|
589 | - <a href="http://docs.simplecalendar.io/timezone-settings/" target="_blank"><?php _e( 'See details.', 'google-calendar-events' ); ?></a> |
|
587 | + <span class="attention"><?php _e('Warning', 'google-calendar-events'); ?>:</span> |
|
588 | + <?php _e('Setting this to <code>Event source default</code> can at times cause unexpected results. Please test thoroughly.', 'google-calendar-events'); ?> |
|
589 | + <a href="http://docs.simplecalendar.io/timezone-settings/" target="_blank"><?php _e('See details.', 'google-calendar-events'); ?></a> |
|
590 | 590 | </p> |
591 | 591 | </td> |
592 | 592 | </tr> |
593 | 593 | <tr class="simcal-panel-field"> |
594 | - <th><label for="_calendar_date_format_setting"><?php _e( 'Date Format', 'google-calendar-events' ); ?></label></th> |
|
594 | + <th><label for="_calendar_date_format_setting"><?php _e('Date Format', 'google-calendar-events'); ?></label></th> |
|
595 | 595 | <td> |
596 | 596 | <?php |
597 | 597 | |
598 | - $date_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_setting', true ) ); |
|
599 | - $date_format_default = esc_attr( get_option( 'date_format' ) ); |
|
600 | - $date_format = esc_attr( get_post_meta( $post->ID, '_calendar_date_format', true ) ); |
|
601 | - $date_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_php', true ) ); |
|
598 | + $date_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_date_format_setting', true)); |
|
599 | + $date_format_default = esc_attr(get_option('date_format')); |
|
600 | + $date_format = esc_attr(get_post_meta($post->ID, '_calendar_date_format', true)); |
|
601 | + $date_format_php = esc_attr(get_post_meta($post->ID, '_calendar_date_format_php', true)); |
|
602 | 602 | $date_format_php = $date_format_php ? $date_format_php : $date_format_default; |
603 | 603 | |
604 | 604 | ?> |
605 | 605 | <select name="_calendar_date_format_setting" |
606 | 606 | id="_calendar_date_format_setting" |
607 | 607 | class="simcal-field simcal-field-select simcal-field-show-other"> |
608 | - <option value="use_site" data-show-field="_calendar_date_format_default" <?php selected( 'use_site', $date_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option> |
|
609 | - <option value="use_custom" data-show-field="_calendar_date_format" <?php selected( 'use_custom', $date_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
610 | - <option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected( 'use_custom_php', $date_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option> |
|
608 | + <option value="use_site" data-show-field="_calendar_date_format_default" <?php selected('use_site', $date_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option> |
|
609 | + <option value="use_custom" data-show-field="_calendar_date_format" <?php selected('use_custom', $date_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
610 | + <option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected('use_custom_php', $date_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option> |
|
611 | 611 | </select> |
612 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i> |
|
612 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i> |
|
613 | 613 | <p id="_calendar_date_format_default" style="<?php echo $date_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
614 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
615 | - <code><?php echo date_i18n( $date_format_default, time() ); ?></code> |
|
614 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
615 | + <code><?php echo date_i18n($date_format_default, time()); ?></code> |
|
616 | 616 | </p> |
617 | - <?php simcal_print_field( array( |
|
617 | + <?php simcal_print_field(array( |
|
618 | 618 | 'type' => 'datetime-format', |
619 | 619 | 'subtype' => 'date', |
620 | 620 | 'name' => '_calendar_date_format', |
621 | 621 | 'id' => '_calendar_date_format', |
622 | 622 | 'value' => $date_format, |
623 | - 'style' => $date_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
624 | - ) ); ?> |
|
623 | + 'style' => $date_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
624 | + )); ?> |
|
625 | 625 | <div class="simcal-field-datetime-format-php" id="_calendar_date_format_php_field" style="<?php echo $date_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
626 | 626 | <br> |
627 | 627 | <label for="_calendar_date_format_php"> |
@@ -630,70 +630,70 @@ discard block |
||
630 | 630 | id="_calendar_date_format_php" |
631 | 631 | class="simcal-field simcal-field-text simcal-field-small" |
632 | 632 | value="<?php echo $date_format_php; ?>" /> |
633 | - <?php printf( __( 'Enter a date format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?> |
|
633 | + <?php printf(__('Enter a date format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> |
|
634 | 634 | </label> |
635 | 635 | <p> |
636 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
637 | - <code><?php echo date_i18n( $date_format_php, time() ); ?></code> |
|
636 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
637 | + <code><?php echo date_i18n($date_format_php, time()); ?></code> |
|
638 | 638 | </p> |
639 | 639 | </div> |
640 | 640 | </td> |
641 | 641 | </tr> |
642 | 642 | <tr class="simcal-panel-field"> |
643 | - <th><label for="_calendar_datetime_separator"><?php _e( 'Separator', 'google-calendar-events' ); ?></label></th> |
|
643 | + <th><label for="_calendar_datetime_separator"><?php _e('Separator', 'google-calendar-events'); ?></label></th> |
|
644 | 644 | <td> |
645 | 645 | <?php |
646 | 646 | |
647 | - $separator = get_post_meta( $post->ID, '_calendar_datetime_separator', true ); |
|
647 | + $separator = get_post_meta($post->ID, '_calendar_datetime_separator', true); |
|
648 | 648 | $separator = false == $separator ? '@' : $separator; |
649 | 649 | |
650 | - simcal_print_field( array( |
|
650 | + simcal_print_field(array( |
|
651 | 651 | 'type' => 'standard', |
652 | 652 | 'subtype' => 'text', |
653 | 653 | 'name' => '_calendar_datetime_separator', |
654 | 654 | 'id' => '_calendar_datetime_separator', |
655 | 655 | 'value' => $separator, |
656 | - 'tooltip' => __( 'Used to divide date and time when both are shown.', 'google-calendar-events' ), |
|
656 | + 'tooltip' => __('Used to divide date and time when both are shown.', 'google-calendar-events'), |
|
657 | 657 | 'class' => array( |
658 | 658 | 'simcal-field-tiny', |
659 | 659 | ), |
660 | - ) ); |
|
660 | + )); |
|
661 | 661 | |
662 | 662 | ?> |
663 | 663 | </td> |
664 | 664 | </tr> |
665 | 665 | <tr class="simcal-panel-field"> |
666 | - <th><label for="_calendar_time_format_setting"><?php _e( 'Time Format', 'google-calendar-events' ); ?></label></th> |
|
666 | + <th><label for="_calendar_time_format_setting"><?php _e('Time Format', 'google-calendar-events'); ?></label></th> |
|
667 | 667 | <td> |
668 | 668 | <?php |
669 | 669 | |
670 | - $time_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_setting', true ) ); |
|
671 | - $time_format_default = esc_attr( get_option( 'time_format' ) ); |
|
672 | - $time_format = esc_attr( get_post_meta( $post->ID, '_calendar_time_format', true ) ); |
|
673 | - $time_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_php', true ) ); |
|
670 | + $time_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_time_format_setting', true)); |
|
671 | + $time_format_default = esc_attr(get_option('time_format')); |
|
672 | + $time_format = esc_attr(get_post_meta($post->ID, '_calendar_time_format', true)); |
|
673 | + $time_format_php = esc_attr(get_post_meta($post->ID, '_calendar_time_format_php', true)); |
|
674 | 674 | $time_format_php = $time_format_php ? $time_format_php : $time_format_default; |
675 | 675 | |
676 | 676 | ?> |
677 | 677 | <select name="_calendar_time_format_setting" |
678 | 678 | id="_calendar_time_format_setting" |
679 | 679 | class="simcal-field simcal-field-select simcal-field-show-other"> |
680 | - <option value="use_site" data-show-field="_calendar_time_format_default" <?php selected( 'use_site', $time_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option> |
|
681 | - <option value="use_custom" data-show-field="_calendar_time_format" <?php selected( 'use_custom', $time_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
682 | - <option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected( 'use_custom_php', $time_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option> |
|
680 | + <option value="use_site" data-show-field="_calendar_time_format_default" <?php selected('use_site', $time_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option> |
|
681 | + <option value="use_custom" data-show-field="_calendar_time_format" <?php selected('use_custom', $time_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
682 | + <option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected('use_custom_php', $time_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option> |
|
683 | 683 | </select> |
684 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i> |
|
684 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i> |
|
685 | 685 | <p id="_calendar_time_format_default" style="<?php echo $time_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
686 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
687 | - <code><?php echo date_i18n( $time_format_default, time() ); ?></code> |
|
686 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
687 | + <code><?php echo date_i18n($time_format_default, time()); ?></code> |
|
688 | 688 | </p> |
689 | - <?php simcal_print_field( array( |
|
689 | + <?php simcal_print_field(array( |
|
690 | 690 | 'type' => 'datetime-format', |
691 | 691 | 'subtype' => 'time', |
692 | 692 | 'name' => '_calendar_time_format', |
693 | 693 | 'id' => '_calendar_time_format', |
694 | 694 | 'value' => $time_format, |
695 | - 'style' => $time_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
696 | - ) ); ?> |
|
695 | + 'style' => $time_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
696 | + )); ?> |
|
697 | 697 | <div class="simcal-field-datetime-format-php" id="_calendar_time_format_php_field" style="<?php echo $time_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
698 | 698 | <br> |
699 | 699 | <label for="_calendar_date_format_php"> |
@@ -702,24 +702,24 @@ discard block |
||
702 | 702 | id="_calendar_time_format_php" |
703 | 703 | class="simcal-field simcal-field-text simcal-field-small" |
704 | 704 | value="<?php echo $time_format_php; ?>"/> |
705 | - <?php printf( __( 'Enter a time format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?> |
|
705 | + <?php printf(__('Enter a time format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> |
|
706 | 706 | </label> |
707 | 707 | <p> |
708 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
709 | - <code><?php echo date_i18n( $time_format_php, time() ); ?></code> |
|
708 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
709 | + <code><?php echo date_i18n($time_format_php, time()); ?></code> |
|
710 | 710 | </p> |
711 | 711 | </div> |
712 | 712 | </td> |
713 | 713 | </tr> |
714 | 714 | <tr class="simcal-panel-field"> |
715 | - <th><label for="_calendar_week_starts_on_setting"><?php _e( 'Week Starts On', 'google-calendar-events' ); ?></label></th> |
|
715 | + <th><label for="_calendar_week_starts_on_setting"><?php _e('Week Starts On', 'google-calendar-events'); ?></label></th> |
|
716 | 716 | <td> |
717 | 717 | <?php |
718 | 718 | |
719 | - $week_starts_setting = esc_attr( get_post_meta( $post->ID, '_calendar_week_starts_on_setting', true ) ); |
|
720 | - $week_starts_default = esc_attr( get_option( 'start_of_week' ) ); |
|
721 | - $week_starts = intval( get_post_meta( $post->ID, '_calendar_week_starts_on', true ) ); |
|
722 | - $week_starts = is_numeric( $week_starts ) ? strval( $week_starts ) : $week_starts_default; |
|
719 | + $week_starts_setting = esc_attr(get_post_meta($post->ID, '_calendar_week_starts_on_setting', true)); |
|
720 | + $week_starts_default = esc_attr(get_option('start_of_week')); |
|
721 | + $week_starts = intval(get_post_meta($post->ID, '_calendar_week_starts_on', true)); |
|
722 | + $week_starts = is_numeric($week_starts) ? strval($week_starts) : $week_starts_default; |
|
723 | 723 | |
724 | 724 | ?> |
725 | 725 | <select |
@@ -727,40 +727,40 @@ discard block |
||
727 | 727 | id="_calendar_week_starts_on_setting" |
728 | 728 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next" |
729 | 729 | data-show-next-if-value="use_custom"> |
730 | - <option value="use_site" <?php selected( 'use_site', $week_starts_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', date_i18n( 'l', strtotime( "Sunday + $week_starts_default Days" ) ) ); ?></option> |
|
731 | - <option value="use_custom" <?php selected( 'use_custom', $week_starts_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
730 | + <option value="use_site" <?php selected('use_site', $week_starts_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', date_i18n('l', strtotime("Sunday + $week_starts_default Days"))); ?></option> |
|
731 | + <option value="use_custom" <?php selected('use_custom', $week_starts_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
732 | 732 | </select> |
733 | 733 | <select |
734 | 734 | name="_calendar_week_starts_on" |
735 | 735 | id="_calendar_week_starts_on" |
736 | 736 | class="simcal-field simcal-field-select simcal-field-inline" |
737 | 737 | <?php echo 'use_custom' != $week_starts_setting ? 'style="display: none;"' : ''; ?>> |
738 | - <?php $day_names = simcal_get_calendar_names_i18n( 'day', 'full' ); ?> |
|
739 | - <?php for ( $i = 0; $i <= 6; $i++ ) : ?> |
|
740 | - <option value="<?php echo $i; ?>" <?php selected( $i, $week_starts, true ); ?>><?php echo $day_names[ $i ]; ?></option> |
|
738 | + <?php $day_names = simcal_get_calendar_names_i18n('day', 'full'); ?> |
|
739 | + <?php for ($i = 0; $i <= 6; $i++) : ?> |
|
740 | + <option value="<?php echo $i; ?>" <?php selected($i, $week_starts, true); ?>><?php echo $day_names[$i]; ?></option> |
|
741 | 741 | <?php endfor; ?> |
742 | 742 | </select> |
743 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events' ); ?>"></i> |
|
743 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events'); ?>"></i> |
|
744 | 744 | </td> |
745 | 745 | </tr> |
746 | 746 | </tbody> |
747 | 747 | </table> |
748 | 748 | <table> |
749 | 749 | <thead> |
750 | - <tr><th colspan="2"><?php _e( 'Cache', 'google-calendar-events' ); ?></th></tr> |
|
750 | + <tr><th colspan="2"><?php _e('Cache', 'google-calendar-events'); ?></th></tr> |
|
751 | 751 | </thead> |
752 | 752 | <tbody class="simcal-panel-section simcal-panel-section-cache"> |
753 | 753 | <?php |
754 | 754 | |
755 | - $cache_freq = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_amount', true ) ); |
|
756 | - $cache_unit = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_unit', true ) ); |
|
755 | + $cache_freq = esc_attr(get_post_meta($post->ID, '_feed_cache_user_amount', true)); |
|
756 | + $cache_unit = esc_attr(get_post_meta($post->ID, '_feed_cache_user_unit', true)); |
|
757 | 757 | |
758 | - $cache_freq = intval( $cache_freq ) && $cache_freq >= 0 ? $cache_freq : 2; |
|
758 | + $cache_freq = intval($cache_freq) && $cache_freq >= 0 ? $cache_freq : 2; |
|
759 | 759 | $cache_unit = $cache_unit ? $cache_unit : '3600'; |
760 | 760 | |
761 | 761 | ?> |
762 | 762 | <tr class="simcal-panel-field"> |
763 | - <th><label for="_feed_cache_user_amount"><?php _ex( 'Refresh Interval', 'Cache maximum interval', 'google-calendar-events' ); ?></label></th> |
|
763 | + <th><label for="_feed_cache_user_amount"><?php _ex('Refresh Interval', 'Cache maximum interval', 'google-calendar-events'); ?></label></th> |
|
764 | 764 | <td> |
765 | 765 | <input type="number" |
766 | 766 | name="_feed_cache_user_amount" |
@@ -771,12 +771,12 @@ discard block |
||
771 | 771 | <select name="_feed_cache_user_unit" |
772 | 772 | id="_feed_cache_user_unit" |
773 | 773 | class="simcal-field simcalfield-select simcal-field-inline"> |
774 | - <option value="60" <?php selected( '60', $cache_unit, true ); ?>><?php _e( 'Minute(s)', 'google-calendar-events' ); ?></option> |
|
775 | - <option value="3600" <?php selected( '3600', $cache_unit, true ); ?>><?php _e( 'Hour(s)', 'google-calendar-events' ); ?></option> |
|
776 | - <option value="86400" <?php selected( '86400', $cache_unit, true ); ?>><?php _e( 'Day(s)', 'google-calendar-events' ); ?></option> |
|
777 | - <option value="604800" <?php selected( '604800', $cache_unit, true ); ?>><?php _e( 'Week(s)', 'google-calendar-events' ); ?></option> |
|
774 | + <option value="60" <?php selected('60', $cache_unit, true); ?>><?php _e('Minute(s)', 'google-calendar-events'); ?></option> |
|
775 | + <option value="3600" <?php selected('3600', $cache_unit, true); ?>><?php _e('Hour(s)', 'google-calendar-events'); ?></option> |
|
776 | + <option value="86400" <?php selected('86400', $cache_unit, true); ?>><?php _e('Day(s)', 'google-calendar-events'); ?></option> |
|
777 | + <option value="604800" <?php selected('604800', $cache_unit, true); ?>><?php _e('Week(s)', 'google-calendar-events'); ?></option> |
|
778 | 778 | </select> |
779 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events' ); ?>"></i> |
|
779 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events'); ?>"></i> |
|
780 | 780 | </td> |
781 | 781 | </tr> |
782 | 782 | </tbody> |
@@ -795,21 +795,21 @@ discard block |
||
795 | 795 | * |
796 | 796 | * @return void |
797 | 797 | */ |
798 | - public static function print_panel_fields( $array, $post_id ) { |
|
798 | + public static function print_panel_fields($array, $post_id) { |
|
799 | 799 | |
800 | - foreach ( $array as $section => $fields ) : |
|
800 | + foreach ($array as $section => $fields) : |
|
801 | 801 | |
802 | - if ( $fields && is_array( $fields ) ) : |
|
802 | + if ($fields && is_array($fields)) : |
|
803 | 803 | |
804 | 804 | ?> |
805 | - <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr( $section ); ?>"> |
|
806 | - <?php foreach ( $fields as $key => $field ) : |
|
805 | + <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr($section); ?>"> |
|
806 | + <?php foreach ($fields as $key => $field) : |
|
807 | 807 | |
808 | - $value = get_post_meta( $post_id, $key, true ); |
|
809 | - $field['value'] = $value ? $value : ( isset( $field['default'] ) ? $field['default'] : '' ); |
|
810 | - $the_field = simcal_get_field( $field ); ?> |
|
808 | + $value = get_post_meta($post_id, $key, true); |
|
809 | + $field['value'] = $value ? $value : (isset($field['default']) ? $field['default'] : ''); |
|
810 | + $the_field = simcal_get_field($field); ?> |
|
811 | 811 | |
812 | - <?php if ( $the_field instanceof Field ) : ?> |
|
812 | + <?php if ($the_field instanceof Field) : ?> |
|
813 | 813 | <tr class="simcal-panel-field"> |
814 | 814 | <th><label for="<?php echo $the_field->id ?>"><?php echo $the_field->title; ?></label></th> |
815 | 815 | <td><?php $the_field->html(); ?></td> |
@@ -836,30 +836,30 @@ discard block |
||
836 | 836 | * |
837 | 837 | * @return void |
838 | 838 | */ |
839 | - public static function save( $post_id, $post ) { |
|
839 | + public static function save($post_id, $post) { |
|
840 | 840 | |
841 | 841 | /* ====================== * |
842 | 842 | * Calendar type and view * |
843 | 843 | * ====================== */ |
844 | 844 | |
845 | 845 | // Unlink existing terms for feed type and calendar type. |
846 | - wp_delete_object_term_relationships( $post_id, array( |
|
846 | + wp_delete_object_term_relationships($post_id, array( |
|
847 | 847 | 'calendar_feed', |
848 | 848 | 'calendar_type', |
849 | - ) ); |
|
849 | + )); |
|
850 | 850 | |
851 | 851 | // Set the feed type as term. |
852 | - $feed_type = isset( $_POST['_feed_type'] ) ? sanitize_title( stripslashes( $_POST['_feed_type'] ) ) : apply_filters( 'simcal_default_feed_type', 'google' ); |
|
853 | - wp_set_object_terms( $post_id, $feed_type, 'calendar_feed' ); |
|
852 | + $feed_type = isset($_POST['_feed_type']) ? sanitize_title(stripslashes($_POST['_feed_type'])) : apply_filters('simcal_default_feed_type', 'google'); |
|
853 | + wp_set_object_terms($post_id, $feed_type, 'calendar_feed'); |
|
854 | 854 | |
855 | 855 | // Set the calendar type as a term. |
856 | - $calendar_type = isset( $_POST['_calendar_type'] ) ? sanitize_title( stripslashes( $_POST['_calendar_type'] ) ) : apply_filters( 'simcal_default_calendar_type', 'default-calendar' ); |
|
857 | - wp_set_object_terms( $post_id, $calendar_type, 'calendar_type' ); |
|
856 | + $calendar_type = isset($_POST['_calendar_type']) ? sanitize_title(stripslashes($_POST['_calendar_type'])) : apply_filters('simcal_default_calendar_type', 'default-calendar'); |
|
857 | + wp_set_object_terms($post_id, $calendar_type, 'calendar_type'); |
|
858 | 858 | // Set the calendar type view as post meta. |
859 | - $calendar_view = isset( $_POST['_calendar_view'] ) ? $_POST['_calendar_view'] : ''; |
|
860 | - if ( $calendar_view && is_array( $calendar_view ) ) { |
|
861 | - $views = array_map( 'sanitize_title', $calendar_view ); |
|
862 | - update_post_meta( $post_id, '_calendar_view', $views ); |
|
859 | + $calendar_view = isset($_POST['_calendar_view']) ? $_POST['_calendar_view'] : ''; |
|
860 | + if ($calendar_view && is_array($calendar_view)) { |
|
861 | + $views = array_map('sanitize_title', $calendar_view); |
|
862 | + update_post_meta($post_id, '_calendar_view', $views); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | /* ===================== * |
@@ -867,106 +867,106 @@ discard block |
||
867 | 867 | * ===================== */ |
868 | 868 | |
869 | 869 | // Calendar opening. |
870 | - $calendar_begins = isset( $_POST['_calendar_begins'] ) ? sanitize_key( $_POST['_calendar_begins'] ) : 'this_month'; |
|
871 | - update_post_meta( $post_id, '_calendar_begins', $calendar_begins ); |
|
872 | - $calendar_begins_nth = isset( $_POST['_calendar_begins_nth'] ) ? absint( $_POST['_calendar_begins_nth'] ) : 2; |
|
873 | - update_post_meta( $post_id, '_calendar_begins_nth', $calendar_begins_nth ); |
|
874 | - $calendar_begins_custom_date = isset( $_POST['_calendar_begins_custom_date'] ) ? sanitize_title( $_POST['_calendar_begins_custom_date'] ) : ''; |
|
875 | - update_post_meta( $post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date ); |
|
870 | + $calendar_begins = isset($_POST['_calendar_begins']) ? sanitize_key($_POST['_calendar_begins']) : 'this_month'; |
|
871 | + update_post_meta($post_id, '_calendar_begins', $calendar_begins); |
|
872 | + $calendar_begins_nth = isset($_POST['_calendar_begins_nth']) ? absint($_POST['_calendar_begins_nth']) : 2; |
|
873 | + update_post_meta($post_id, '_calendar_begins_nth', $calendar_begins_nth); |
|
874 | + $calendar_begins_custom_date = isset($_POST['_calendar_begins_custom_date']) ? sanitize_title($_POST['_calendar_begins_custom_date']) : ''; |
|
875 | + update_post_meta($post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date); |
|
876 | 876 | |
877 | 877 | // Feed earliest events date. |
878 | - $earliest_events = isset( $_POST['_feed_earliest_event_date'] ) ? sanitize_key( $_POST['_feed_earliest_event_date'] ) : ''; |
|
879 | - update_post_meta( $post_id, '_feed_earliest_event_date', $earliest_events ); |
|
880 | - $earliest_events_range = isset( $_POST['_feed_earliest_event_date_range'] ) ? max( absint( $_POST['_feed_earliest_event_date_range'] ), 1 ) : 1; |
|
881 | - update_post_meta( $post_id, '_feed_earliest_event_date_range', $earliest_events_range ); |
|
878 | + $earliest_events = isset($_POST['_feed_earliest_event_date']) ? sanitize_key($_POST['_feed_earliest_event_date']) : ''; |
|
879 | + update_post_meta($post_id, '_feed_earliest_event_date', $earliest_events); |
|
880 | + $earliest_events_range = isset($_POST['_feed_earliest_event_date_range']) ? max(absint($_POST['_feed_earliest_event_date_range']), 1) : 1; |
|
881 | + update_post_meta($post_id, '_feed_earliest_event_date_range', $earliest_events_range); |
|
882 | 882 | |
883 | 883 | // Feed latest events date. |
884 | - $latest_events = isset( $_POST['_feed_latest_event_date'] ) ? sanitize_key( $_POST['_feed_latest_event_date'] ) : ''; |
|
885 | - update_post_meta( $post_id, '_feed_latest_event_date', $latest_events ); |
|
886 | - $latest_events_range = isset( $_POST['_feed_latest_event_date_range'] ) ? max( absint( $_POST['_feed_latest_event_date_range'] ), 1 ) : 1; |
|
887 | - update_post_meta( $post_id, '_feed_latest_event_date_range', $latest_events_range ); |
|
884 | + $latest_events = isset($_POST['_feed_latest_event_date']) ? sanitize_key($_POST['_feed_latest_event_date']) : ''; |
|
885 | + update_post_meta($post_id, '_feed_latest_event_date', $latest_events); |
|
886 | + $latest_events_range = isset($_POST['_feed_latest_event_date_range']) ? max(absint($_POST['_feed_latest_event_date_range']), 1) : 1; |
|
887 | + update_post_meta($post_id, '_feed_latest_event_date_range', $latest_events_range); |
|
888 | 888 | |
889 | 889 | /* ======================= * |
890 | 890 | * Calendar settings panel * |
891 | 891 | * ======================= */ |
892 | 892 | |
893 | 893 | // Static calendar. |
894 | - $static = isset( $_POST['_calendar_is_static'] ) ? 'yes' : 'no'; |
|
895 | - update_post_meta( $post_id, '_calendar_is_static', $static ); |
|
894 | + $static = isset($_POST['_calendar_is_static']) ? 'yes' : 'no'; |
|
895 | + update_post_meta($post_id, '_calendar_is_static', $static); |
|
896 | 896 | |
897 | 897 | // No events message. |
898 | - $message = isset( $_POST['_no_events_message'] ) ? wp_kses_post( $_POST['_no_events_message'] ) : ''; |
|
899 | - update_post_meta( $post_id, '_no_events_message', $message ); |
|
898 | + $message = isset($_POST['_no_events_message']) ? wp_kses_post($_POST['_no_events_message']) : ''; |
|
899 | + update_post_meta($post_id, '_no_events_message', $message); |
|
900 | 900 | |
901 | 901 | // _event_formatting |
902 | - $event_formatting = isset( $_POST['_event_formatting'] ) ? sanitize_key( $_POST['_event_formatting'] ) : 'preserve_linebreaks'; |
|
903 | - update_post_meta( $post_id, '_event_formatting', $event_formatting ); |
|
902 | + $event_formatting = isset($_POST['_event_formatting']) ? sanitize_key($_POST['_event_formatting']) : 'preserve_linebreaks'; |
|
903 | + update_post_meta($post_id, '_event_formatting', $event_formatting); |
|
904 | 904 | |
905 | 905 | // Powered by option |
906 | - $poweredby = isset( $_POST['_poweredby'] ) ? 'yes' : 'no'; |
|
907 | - update_post_meta( $post_id, '_poweredby', $poweredby ); |
|
906 | + $poweredby = isset($_POST['_poweredby']) ? 'yes' : 'no'; |
|
907 | + update_post_meta($post_id, '_poweredby', $poweredby); |
|
908 | 908 | |
909 | 909 | /* ======================= * |
910 | 910 | * Advanced settings panel * |
911 | 911 | * ======================= */ |
912 | 912 | |
913 | 913 | // Timezone. |
914 | - $feed_timezone_setting = isset( $_POST['_feed_timezone_setting'] ) ? sanitize_key( $_POST['_feed_timezone_setting'] ) : 'use_calendar'; |
|
915 | - update_post_meta( $post_id, '_feed_timezone_setting', $feed_timezone_setting ); |
|
914 | + $feed_timezone_setting = isset($_POST['_feed_timezone_setting']) ? sanitize_key($_POST['_feed_timezone_setting']) : 'use_calendar'; |
|
915 | + update_post_meta($post_id, '_feed_timezone_setting', $feed_timezone_setting); |
|
916 | 916 | $default_timezone = simcal_get_wp_timezone(); |
917 | 917 | $feed_timezone = $default_timezone ? $default_timezone : 'UTC'; |
918 | - $feed_timezone = isset( $_POST['_feed_timezone'] ) ? sanitize_text_field( $_POST['_feed_timezone'] ) : $feed_timezone; |
|
919 | - update_post_meta( $post_id, '_feed_timezone', $feed_timezone ); |
|
918 | + $feed_timezone = isset($_POST['_feed_timezone']) ? sanitize_text_field($_POST['_feed_timezone']) : $feed_timezone; |
|
919 | + update_post_meta($post_id, '_feed_timezone', $feed_timezone); |
|
920 | 920 | |
921 | 921 | // Date format. |
922 | - $date_format_setting = isset( $_POST['_calendar_date_format_setting'] ) ? sanitize_key( $_POST['_calendar_date_format_setting'] ) : 'use_site'; |
|
923 | - update_post_meta( $post_id, '_calendar_date_format_setting', $date_format_setting ); |
|
924 | - $date_format = isset( $_POST['_calendar_date_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format'] ) ) : get_option( 'date_format' ); |
|
925 | - update_post_meta( $post_id, '_calendar_date_format', $date_format ); |
|
926 | - $date_format_php = isset( $_POST['_calendar_date_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format_php'] ) ) : get_option( 'date_format' ); |
|
927 | - update_post_meta( $post_id, '_calendar_date_format_php', $date_format_php ); |
|
922 | + $date_format_setting = isset($_POST['_calendar_date_format_setting']) ? sanitize_key($_POST['_calendar_date_format_setting']) : 'use_site'; |
|
923 | + update_post_meta($post_id, '_calendar_date_format_setting', $date_format_setting); |
|
924 | + $date_format = isset($_POST['_calendar_date_format']) ? sanitize_text_field(trim($_POST['_calendar_date_format'])) : get_option('date_format'); |
|
925 | + update_post_meta($post_id, '_calendar_date_format', $date_format); |
|
926 | + $date_format_php = isset($_POST['_calendar_date_format_php']) ? sanitize_text_field(trim($_POST['_calendar_date_format_php'])) : get_option('date_format'); |
|
927 | + update_post_meta($post_id, '_calendar_date_format_php', $date_format_php); |
|
928 | 928 | |
929 | 929 | // Time format. |
930 | - $time_format_setting = isset( $_POST['_calendar_time_format_setting'] ) ? sanitize_key( $_POST['_calendar_time_format_setting'] ) : 'use_site'; |
|
931 | - update_post_meta( $post_id, '_calendar_time_format_setting', $time_format_setting ); |
|
932 | - $time_format = isset( $_POST['_calendar_time_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format'] ) ) : get_option( 'time_format' ); |
|
933 | - update_post_meta( $post_id, '_calendar_time_format', $time_format ); |
|
934 | - $time_format_php = isset( $_POST['_calendar_time_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format_php'] ) ) : get_option( 'time_format' ); |
|
935 | - update_post_meta( $post_id, '_calendar_time_format_php', $time_format_php ); |
|
930 | + $time_format_setting = isset($_POST['_calendar_time_format_setting']) ? sanitize_key($_POST['_calendar_time_format_setting']) : 'use_site'; |
|
931 | + update_post_meta($post_id, '_calendar_time_format_setting', $time_format_setting); |
|
932 | + $time_format = isset($_POST['_calendar_time_format']) ? sanitize_text_field(trim($_POST['_calendar_time_format'])) : get_option('time_format'); |
|
933 | + update_post_meta($post_id, '_calendar_time_format', $time_format); |
|
934 | + $time_format_php = isset($_POST['_calendar_time_format_php']) ? sanitize_text_field(trim($_POST['_calendar_time_format_php'])) : get_option('time_format'); |
|
935 | + update_post_meta($post_id, '_calendar_time_format_php', $time_format_php); |
|
936 | 936 | |
937 | 937 | // Date-time separator. |
938 | - $datetime_separator = isset( $_POST['_calendar_datetime_separator'] ) ? sanitize_text_field( $_POST['_calendar_datetime_separator'] ) : ' '; |
|
939 | - update_post_meta( $post_id, '_calendar_datetime_separator', $datetime_separator ); |
|
938 | + $datetime_separator = isset($_POST['_calendar_datetime_separator']) ? sanitize_text_field($_POST['_calendar_datetime_separator']) : ' '; |
|
939 | + update_post_meta($post_id, '_calendar_datetime_separator', $datetime_separator); |
|
940 | 940 | |
941 | 941 | // Week start. |
942 | - $week_start_setting = isset( $_POST['_calendar_week_starts_on_setting'] ) ? sanitize_key( $_POST['_calendar_week_starts_on_setting'] ) : 'use_site'; |
|
943 | - update_post_meta( $post_id, '_calendar_week_starts_on_setting', $week_start_setting ); |
|
944 | - $week_start = isset( $_POST['_calendar_week_starts_on'] ) ? intval( $_POST['_calendar_week_starts_on'] ) : get_option( 'start_of_week' ); |
|
945 | - update_post_meta( $post_id, '_calendar_week_starts_on', $week_start ); |
|
942 | + $week_start_setting = isset($_POST['_calendar_week_starts_on_setting']) ? sanitize_key($_POST['_calendar_week_starts_on_setting']) : 'use_site'; |
|
943 | + update_post_meta($post_id, '_calendar_week_starts_on_setting', $week_start_setting); |
|
944 | + $week_start = isset($_POST['_calendar_week_starts_on']) ? intval($_POST['_calendar_week_starts_on']) : get_option('start_of_week'); |
|
945 | + update_post_meta($post_id, '_calendar_week_starts_on', $week_start); |
|
946 | 946 | |
947 | 947 | // Cache interval. |
948 | 948 | $cache = 7200; |
949 | - if ( isset( $_POST['_feed_cache_user_amount'] ) && isset( $_POST['_feed_cache_user_unit'] ) ) { |
|
950 | - $amount = is_numeric( $_POST['_feed_cache_user_amount'] ) || $_POST['_feed_cache_user_amount'] == 0 ? absint( $_POST['_feed_cache_user_amount'] ) : 1; |
|
951 | - $unit = is_numeric( $_POST['_feed_cache_user_unit'] ) ? absint( $_POST['_feed_cache_user_unit'] ) : 3600; |
|
952 | - update_post_meta( $post_id, '_feed_cache_user_amount', $amount ); |
|
953 | - update_post_meta( $post_id, '_feed_cache_user_unit', $unit ); |
|
954 | - $cache = ( ( $amount * $unit ) > 0 ) ? $amount * $unit : 1; |
|
949 | + if (isset($_POST['_feed_cache_user_amount']) && isset($_POST['_feed_cache_user_unit'])) { |
|
950 | + $amount = is_numeric($_POST['_feed_cache_user_amount']) || $_POST['_feed_cache_user_amount'] == 0 ? absint($_POST['_feed_cache_user_amount']) : 1; |
|
951 | + $unit = is_numeric($_POST['_feed_cache_user_unit']) ? absint($_POST['_feed_cache_user_unit']) : 3600; |
|
952 | + update_post_meta($post_id, '_feed_cache_user_amount', $amount); |
|
953 | + update_post_meta($post_id, '_feed_cache_user_unit', $unit); |
|
954 | + $cache = (($amount * $unit) > 0) ? $amount * $unit : 1; |
|
955 | 955 | } |
956 | - update_post_meta( $post_id, '_feed_cache', $cache ); |
|
956 | + update_post_meta($post_id, '_feed_cache', $cache); |
|
957 | 957 | |
958 | 958 | /* ============= * |
959 | 959 | * Miscellaneous * |
960 | 960 | * ============= */ |
961 | 961 | |
962 | 962 | // Update version. |
963 | - update_post_meta( $post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION ); |
|
963 | + update_post_meta($post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION); |
|
964 | 964 | |
965 | 965 | // Action hook. |
966 | - do_action( 'simcal_process_settings_meta', $post_id ); |
|
966 | + do_action('simcal_process_settings_meta', $post_id); |
|
967 | 967 | |
968 | 968 | // Clear cache. |
969 | - simcal_delete_feed_transients( $post_id ); |
|
969 | + simcal_delete_feed_transients($post_id); |
|
970 | 970 | } |
971 | 971 | |
972 | 972 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use Carbon\Carbon; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -239,35 +239,35 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @param array $event |
241 | 241 | */ |
242 | - public function __construct( array $event ) { |
|
242 | + public function __construct(array $event) { |
|
243 | 243 | |
244 | 244 | /* ================= * |
245 | 245 | * Event Identifiers * |
246 | 246 | * ================= */ |
247 | 247 | |
248 | 248 | // Event unique id. |
249 | - if ( ! empty( $event['uid'] ) ) { |
|
250 | - $this->uid = esc_attr( $event['uid'] ); |
|
249 | + if ( ! empty($event['uid'])) { |
|
250 | + $this->uid = esc_attr($event['uid']); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | // iCal ID |
254 | - if ( ! empty( $event['ical_id'] ) ) { |
|
255 | - $this->ical_id = esc_attr( $event['ical_id'] ); |
|
254 | + if ( ! empty($event['ical_id'])) { |
|
255 | + $this->ical_id = esc_attr($event['ical_id']); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | // Event source. |
259 | - if ( ! empty( $event['source'] ) ) { |
|
260 | - $this->source = esc_attr( $event['source'] ); |
|
259 | + if ( ! empty($event['source'])) { |
|
260 | + $this->source = esc_attr($event['source']); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | // Event parent calendar id. |
264 | - if ( ! empty( $event['calendar'] ) ) { |
|
265 | - $this->calendar = max( intval( $event['calendar'] ), 0 ); |
|
264 | + if ( ! empty($event['calendar'])) { |
|
265 | + $this->calendar = max(intval($event['calendar']), 0); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | // Event parent calendar timezone. |
269 | - if ( ! empty( $event['timezone'] ) ) { |
|
270 | - $this->timezone = esc_attr( $event['timezone'] ); |
|
269 | + if ( ! empty($event['timezone'])) { |
|
270 | + $this->timezone = esc_attr($event['timezone']); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /* ============= * |
@@ -275,23 +275,23 @@ discard block |
||
275 | 275 | * ============= */ |
276 | 276 | |
277 | 277 | // Event title. |
278 | - if ( ! empty( $event['title'] ) ) { |
|
279 | - $this->title = esc_html( $event['title'] ); |
|
278 | + if ( ! empty($event['title'])) { |
|
279 | + $this->title = esc_html($event['title']); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | // Event description. |
283 | - if ( ! empty( $event['description'] ) ) { |
|
284 | - $this->description = wp_kses_post( $event['description'] ); |
|
283 | + if ( ! empty($event['description'])) { |
|
284 | + $this->description = wp_kses_post($event['description']); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // Event link URL. |
288 | - if ( ! empty( $event['link'] ) ) { |
|
289 | - $this->link = esc_url_raw( $event['link'] ); |
|
288 | + if ( ! empty($event['link'])) { |
|
289 | + $this->link = esc_url_raw($event['link']); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | // Event visibility. |
293 | - if ( ! empty( $event['visibility'] ) ) { |
|
294 | - $this->visibility = esc_attr( $event['visibility'] ); |
|
293 | + if ( ! empty($event['visibility'])) { |
|
294 | + $this->visibility = esc_attr($event['visibility']); |
|
295 | 295 | $this->public = $this->visibility == 'public' ? true : false; |
296 | 296 | } |
297 | 297 | |
@@ -299,34 +299,34 @@ discard block |
||
299 | 299 | * Event Start * |
300 | 300 | * =========== */ |
301 | 301 | |
302 | - if ( ! empty( $event['start'] ) ) { |
|
303 | - $this->start = is_numeric( $event['start'] ) ? intval( $event['start'] ) : 0; |
|
304 | - if ( ! empty( $event['start_utc'] ) ) { |
|
305 | - $this->start_utc = is_numeric( $event['start_utc'] ) ? intval( $event['start_utc'] ) : 0; |
|
302 | + if ( ! empty($event['start'])) { |
|
303 | + $this->start = is_numeric($event['start']) ? intval($event['start']) : 0; |
|
304 | + if ( ! empty($event['start_utc'])) { |
|
305 | + $this->start_utc = is_numeric($event['start_utc']) ? intval($event['start_utc']) : 0; |
|
306 | 306 | } |
307 | - if ( ! empty( $event['start_timezone'] ) ) { |
|
308 | - $this->start_timezone = esc_attr( $event['start_timezone'] ); |
|
307 | + if ( ! empty($event['start_timezone'])) { |
|
308 | + $this->start_timezone = esc_attr($event['start_timezone']); |
|
309 | 309 | } |
310 | - $this->start_dt = Carbon::createFromTimestamp( $this->start, $this->start_timezone ); |
|
311 | - $start_location = isset( $event['start_location'] ) ? $event['start_location'] : ''; |
|
312 | - $this->start_location = $this->esc_location( $start_location ); |
|
310 | + $this->start_dt = Carbon::createFromTimestamp($this->start, $this->start_timezone); |
|
311 | + $start_location = isset($event['start_location']) ? $event['start_location'] : ''; |
|
312 | + $this->start_location = $this->esc_location($start_location); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /* ========= * |
316 | 316 | * Event End * |
317 | 317 | * ========= */ |
318 | 318 | |
319 | - if ( ! empty( $event['end'] ) ) { |
|
320 | - $this->end = is_numeric( $event['end'] ) ? intval( $event['end'] ): false; |
|
321 | - if ( ! empty( $event['end_utc'] ) ) { |
|
322 | - $this->end_utc = is_numeric( $event['end_utc'] ) ? intval( $event['end_utc'] ) : false; |
|
319 | + if ( ! empty($event['end'])) { |
|
320 | + $this->end = is_numeric($event['end']) ? intval($event['end']) : false; |
|
321 | + if ( ! empty($event['end_utc'])) { |
|
322 | + $this->end_utc = is_numeric($event['end_utc']) ? intval($event['end_utc']) : false; |
|
323 | 323 | } |
324 | - if ( ! empty( $event['end_timezone'] ) ) { |
|
325 | - $this->end_timezone = esc_attr( $event['end_timezone'] ); |
|
324 | + if ( ! empty($event['end_timezone'])) { |
|
325 | + $this->end_timezone = esc_attr($event['end_timezone']); |
|
326 | 326 | } |
327 | - $this->end_dt = Carbon::createFromTimestamp( $this->end, $this->end_timezone ); |
|
328 | - $end_location = isset( $event['end_location'] ) ? $event['end_location'] : ''; |
|
329 | - $this->end_location = $this->esc_location( $end_location ); |
|
327 | + $this->end_dt = Carbon::createFromTimestamp($this->end, $this->end_timezone); |
|
328 | + $end_location = isset($event['end_location']) ? $event['end_location'] : ''; |
|
329 | + $this->end_location = $this->esc_location($end_location); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /* ================== * |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | * ================== */ |
335 | 335 | |
336 | 336 | // Whole day event. |
337 | - if ( ! empty( $event['whole_day'] ) ) { |
|
338 | - $this->whole_day = true === $event['whole_day'] ? true: false; |
|
337 | + if ( ! empty($event['whole_day'])) { |
|
338 | + $this->whole_day = true === $event['whole_day'] ? true : false; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | // Multi day event. |
342 | - if ( ! empty( $event['multiple_days'] ) ) { |
|
343 | - $this->multiple_days = max( absint( $event['multiple_days'] ), 1 ); |
|
342 | + if ( ! empty($event['multiple_days'])) { |
|
343 | + $this->multiple_days = max(absint($event['multiple_days']), 1); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | // Event recurrence. |
347 | - if ( isset( $event['recurrence'] ) ) { |
|
348 | - $this->recurrence = ! empty( $event['recurrence'] ) ? $event['recurrence'] : false; |
|
347 | + if (isset($event['recurrence'])) { |
|
348 | + $this->recurrence = ! empty($event['recurrence']) ? $event['recurrence'] : false; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /* ========== * |
@@ -353,18 +353,18 @@ discard block |
||
353 | 353 | * ========== */ |
354 | 354 | |
355 | 355 | // Event has venue(s). |
356 | - if ( $this->start_location['venue'] || $this->end_location['venue'] ) { |
|
356 | + if ($this->start_location['venue'] || $this->end_location['venue']) { |
|
357 | 357 | $this->venue = true; |
358 | 358 | } |
359 | 359 | |
360 | 360 | // Event meta. |
361 | - if ( ! empty( $event['meta'] ) ) { |
|
362 | - $this->meta = is_array( $event['meta'] ) ? $event['meta'] : array(); |
|
361 | + if ( ! empty($event['meta'])) { |
|
362 | + $this->meta = is_array($event['meta']) ? $event['meta'] : array(); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | // Event template. |
366 | - if ( ! empty( $event['template'] ) ) { |
|
367 | - $this->template = wp_kses_post( $event['template'] ); |
|
366 | + if ( ! empty($event['template'])) { |
|
367 | + $this->template = wp_kses_post($event['template']); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | } |
@@ -379,27 +379,27 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return array |
381 | 381 | */ |
382 | - private function esc_location( $var = '' ) { |
|
382 | + private function esc_location($var = '') { |
|
383 | 383 | |
384 | 384 | $location = array(); |
385 | 385 | |
386 | - if ( is_string( $var ) ) { |
|
386 | + if (is_string($var)) { |
|
387 | 387 | $var = array( |
388 | 388 | 'name' => $var, |
389 | 389 | 'address' => $var, |
390 | 390 | ); |
391 | - } elseif ( is_bool( $var ) || is_null( $var ) ) { |
|
391 | + } elseif (is_bool($var) || is_null($var)) { |
|
392 | 392 | $var = array(); |
393 | 393 | } else { |
394 | 394 | $var = (array) $var; |
395 | 395 | } |
396 | 396 | |
397 | - $location['name'] = isset( $var['name'] ) ? esc_attr( strip_tags( $var['name'] ) ) : ''; |
|
398 | - $location['address'] = isset( $var['address'] ) ? esc_attr( strip_tags( $var['address'] ) ) : ''; |
|
399 | - $location['lat'] = isset( $var['lat'] ) ? $this->esc_coordinate( $var['lat'] ) : 0; |
|
400 | - $location['lng'] = isset( $var['lng'] ) ? $this->esc_coordinate( $var['lng'] ) : 0; |
|
397 | + $location['name'] = isset($var['name']) ? esc_attr(strip_tags($var['name'])) : ''; |
|
398 | + $location['address'] = isset($var['address']) ? esc_attr(strip_tags($var['address'])) : ''; |
|
399 | + $location['lat'] = isset($var['lat']) ? $this->esc_coordinate($var['lat']) : 0; |
|
400 | + $location['lng'] = isset($var['lng']) ? $this->esc_coordinate($var['lng']) : 0; |
|
401 | 401 | |
402 | - if ( ! empty( $location['name'] ) || ! empty( $location['address'] ) ) { |
|
402 | + if ( ! empty($location['name']) || ! empty($location['address'])) { |
|
403 | 403 | $location['venue'] = true; |
404 | 404 | } else { |
405 | 405 | $location['venue'] = false; |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @return int|float |
420 | 420 | */ |
421 | - private function esc_coordinate( $latlng = 0 ) { |
|
422 | - return is_numeric( $latlng ) ? floatval( $latlng ) : 0; |
|
421 | + private function esc_coordinate($latlng = 0) { |
|
422 | + return is_numeric($latlng) ? floatval($latlng) : 0; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | * |
433 | 433 | * @return bool |
434 | 434 | */ |
435 | - public function set_timezone( $tz ) { |
|
436 | - if ( in_array( $tz, timezone_identifiers_list() ) ) { |
|
435 | + public function set_timezone($tz) { |
|
436 | + if (in_array($tz, timezone_identifiers_list())) { |
|
437 | 437 | $this->timezone = $tz; |
438 | 438 | return true; |
439 | 439 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * @return bool |
460 | 460 | */ |
461 | 461 | public function starts_today() { |
462 | - return $this->start_dt->setTimezone( $this->timezone )->isToday(); |
|
462 | + return $this->start_dt->setTimezone($this->timezone)->isToday(); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @return bool |
471 | 471 | */ |
472 | 472 | public function ends_today() { |
473 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isToday() : true; |
|
473 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isToday() : true; |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | * @return bool |
482 | 482 | */ |
483 | 483 | public function starts_tomorrow() { |
484 | - return $this->start_dt->setTimezone( $this->timezone )->isTomorrow(); |
|
484 | + return $this->start_dt->setTimezone($this->timezone)->isTomorrow(); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | * @return bool |
493 | 493 | */ |
494 | 494 | public function ends_tomorrow() { |
495 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isTomorrow() : false; |
|
495 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isTomorrow() : false; |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * @return bool |
504 | 504 | */ |
505 | 505 | public function started_yesterday() { |
506 | - return $this->start_dt->setTimezone( $this->timezone )->isYesterday(); |
|
506 | + return $this->start_dt->setTimezone($this->timezone)->isYesterday(); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | /** |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @return bool |
515 | 515 | */ |
516 | 516 | public function ended_yesterday() { |
517 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isYesterday() : false; |
|
517 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isYesterday() : false; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | * @return bool |
526 | 526 | */ |
527 | 527 | public function starts_future() { |
528 | - return $this->start_dt->setTimezone( $this->timezone )->isFuture(); |
|
528 | + return $this->start_dt->setTimezone($this->timezone)->isFuture(); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | * @return bool |
537 | 537 | */ |
538 | 538 | public function ends_future() { |
539 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isFuture() : false; |
|
539 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isFuture() : false; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * @return bool |
548 | 548 | */ |
549 | 549 | public function started_past() { |
550 | - return $this->start_dt->setTimezone( $this->timezone )->isPast(); |
|
550 | + return $this->start_dt->setTimezone($this->timezone)->isPast(); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | * @return bool |
559 | 559 | */ |
560 | 560 | public function ended_past() { |
561 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isPast() : false; |
|
561 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isPast() : false; |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | * |
571 | 571 | * @return string |
572 | 572 | */ |
573 | - public function get_color( $default = '' ) { |
|
574 | - if ( isset( $this->meta['color'] ) ) { |
|
575 | - return ! empty( $this->meta['color'] ) ? esc_attr( $this->meta['color'] ) : $default; |
|
573 | + public function get_color($default = '') { |
|
574 | + if (isset($this->meta['color'])) { |
|
575 | + return ! empty($this->meta['color']) ? esc_attr($this->meta['color']) : $default; |
|
576 | 576 | } |
577 | 577 | return $default; |
578 | 578 | } |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | * @return array |
586 | 586 | */ |
587 | 587 | public function get_attachments() { |
588 | - return isset( $this->meta['attachments'] ) ? $this->meta['attachments'] : array(); |
|
588 | + return isset($this->meta['attachments']) ? $this->meta['attachments'] : array(); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * @return array |
597 | 597 | */ |
598 | 598 | public function get_attendees() { |
599 | - return isset( $this->meta['attendees'] ) ? $this->meta['attendees'] : array(); |
|
599 | + return isset($this->meta['attendees']) ? $this->meta['attendees'] : array(); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @return array |
608 | 608 | */ |
609 | 609 | public function get_organizer() { |
610 | - return isset( $this->meta['organizer'] ) ? $this->meta['organizer'] : array(); |
|
610 | + return isset($this->meta['organizer']) ? $this->meta['organizer'] : array(); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Admin\Metaboxes as Metabox; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct() { |
46 | 46 | |
47 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
48 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
47 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
48 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
49 | 49 | $this->post_types = $settings['general']['attach_calendars_posts']; |
50 | 50 | } |
51 | 51 | |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | new Metabox\Upgrade_To_Premium(); |
56 | 56 | //new Metabox\Newsletter(); |
57 | 57 | |
58 | - do_action( 'simcal_load_meta_boxes' ); |
|
58 | + do_action('simcal_load_meta_boxes'); |
|
59 | 59 | |
60 | 60 | // Add meta boxes. |
61 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 30 ); |
|
61 | + add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 30); |
|
62 | 62 | |
63 | 63 | // Process meta boxes. |
64 | - add_action( 'simcal_save_settings_meta','\SimpleCalendar\Admin\Metaboxes\Settings::save', 10, 2 ); |
|
65 | - add_action( 'simcal_save_attach_calendar_meta','\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::save', 10, 2 ); |
|
64 | + add_action('simcal_save_settings_meta', '\SimpleCalendar\Admin\Metaboxes\Settings::save', 10, 2); |
|
65 | + add_action('simcal_save_attach_calendar_meta', '\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::save', 10, 2); |
|
66 | 66 | |
67 | 67 | // Save meta boxes data. |
68 | - add_action( 'save_post', array( $this, 'save_meta_boxes' ), 1, 2 ); |
|
68 | + add_action('save_post', array($this, 'save_meta_boxes'), 1, 2); |
|
69 | 69 | |
70 | 70 | // Uncomment this for debugging $_POST while saving a meta box. |
71 | 71 | // add_action( 'save_post', function() { echo '<pre>'; print_r( $_POST ); echo '</pre>'; die(); } ); |
@@ -80,20 +80,20 @@ discard block |
||
80 | 80 | |
81 | 81 | add_meta_box( |
82 | 82 | 'simcal-calendar-settings', |
83 | - __( 'Calendar Settings', 'google-calendar-events' ), |
|
83 | + __('Calendar Settings', 'google-calendar-events'), |
|
84 | 84 | '\SimpleCalendar\Admin\Metaboxes\Settings::html', |
85 | 85 | 'calendar', |
86 | 86 | 'normal', |
87 | 87 | 'core' |
88 | 88 | ); |
89 | 89 | |
90 | - $addons = apply_filters( 'simcal_installed_addons', array() ); |
|
91 | - if ( empty( $addons ) ) { |
|
90 | + $addons = apply_filters('simcal_installed_addons', array()); |
|
91 | + if (empty($addons)) { |
|
92 | 92 | |
93 | 93 | // Premium add-on feature list and upsell. |
94 | 94 | add_meta_box( |
95 | 95 | 'simcal-upgrade', |
96 | - __( 'Looking for more?', 'google-calendar-events' ), |
|
96 | + __('Looking for more?', 'google-calendar-events'), |
|
97 | 97 | '\SimpleCalendar\Admin\Metaboxes\Upgrade_To_Premium::html', |
98 | 98 | 'calendar', |
99 | 99 | 'side', |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | add_meta_box( |
117 | 117 | 'simcal-get-shortcode', |
118 | - __( 'Calendar Shortcode', 'google-calendar-events' ), |
|
118 | + __('Calendar Shortcode', 'google-calendar-events'), |
|
119 | 119 | '\SimpleCalendar\Admin\Metaboxes\Get_Shortcode::html', |
120 | 120 | 'calendar', |
121 | 121 | 'side', |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | ); |
124 | 124 | |
125 | 125 | // Add meta box if there are calendars. |
126 | - if ( ( true == simcal_get_calendars() ) && ! empty( $this->post_types ) ) { |
|
127 | - foreach ( $this->post_types as $post_type ) { |
|
126 | + if ((true == simcal_get_calendars()) && ! empty($this->post_types)) { |
|
127 | + foreach ($this->post_types as $post_type) { |
|
128 | 128 | add_meta_box( |
129 | 129 | 'simcal-attach-calendar', |
130 | - __( 'Attach Calendar', 'google-calendar-events' ), |
|
130 | + __('Attach Calendar', 'google-calendar-events'), |
|
131 | 131 | '\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::html', |
132 | 132 | $post_type, |
133 | 133 | 'side', |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | - do_action( 'simcal_add_meta_boxes' ); |
|
139 | + do_action('simcal_add_meta_boxes'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -149,30 +149,30 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return void |
151 | 151 | */ |
152 | - public function save_meta_boxes( $post_id, $post ) { |
|
152 | + public function save_meta_boxes($post_id, $post) { |
|
153 | 153 | |
154 | 154 | // $post_id and $post are required. |
155 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
155 | + if (empty($post_id) || empty($post) || self::$saved_meta_boxes) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Don't save meta boxes for revisions or autosaves. |
160 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
160 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 | |
164 | 164 | // Check the nonce. |
165 | - if ( empty( $_POST['simcal_meta_nonce'] ) || ! wp_verify_nonce( $_POST['simcal_meta_nonce'], 'simcal_save_data' ) ) { |
|
165 | + if (empty($_POST['simcal_meta_nonce']) || ! wp_verify_nonce($_POST['simcal_meta_nonce'], 'simcal_save_data')) { |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | |
169 | 169 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
170 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
170 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Check user has permission to edit |
175 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
175 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
176 | 176 | return; |
177 | 177 | } |
178 | 178 | |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | self::$saved_meta_boxes = true; |
186 | 186 | |
187 | 187 | // Check the post type. |
188 | - if ( 'calendar' == $post->post_type ) { |
|
189 | - do_action( 'simcal_save_settings_meta', $post_id, $post ); |
|
190 | - } elseif ( in_array( $post->post_type, $this->post_types ) ) { |
|
191 | - do_action( 'simcal_save_attach_calendar_meta', $post_id, $post ); |
|
188 | + if ('calendar' == $post->post_type) { |
|
189 | + do_action('simcal_save_settings_meta', $post_id, $post); |
|
190 | + } elseif (in_array($post->post_type, $this->post_types)) { |
|
191 | + do_action('simcal_save_attach_calendar_meta', $post_id, $post); |
|
192 | 192 | } |
193 | 193 | |
194 | - do_action( 'simcal_save_meta_boxes', $post_id, $post ); |
|
194 | + do_action('simcal_save_meta_boxes', $post_id, $post); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Meta_Box; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param \WP_Post $post |
28 | 28 | */ |
29 | - public static function html( $post ) { |
|
29 | + public static function html($post) { |
|
30 | 30 | simcal_newsletter_signup(); |
31 | 31 | } |
32 | 32 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param int $post_id |
39 | 39 | * @param \WP_Post $post |
40 | 40 | */ |
41 | - public static function save( $post_id, $post ) { |
|
41 | + public static function save($post_id, $post) { |
|
42 | 42 | // This meta box has no persistent settings. |
43 | 43 | } |
44 | 44 |
@@ -7,7 +7,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 \SimpleCalendar\Browser(); |
237 | - if ( $browser::PLATFORM_APPLE == $browser->getPlatform() ) { |
|
237 | + if ($browser::PLATFORM_APPLE == $browser->getPlatform()) { |
|
238 | 238 | $cmd = '⌘+C'; |
239 | 239 | } else { |
240 | 240 | $cmd = 'Ctrl+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 |
||
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 |
||
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 | wp_get_current_user(); |
@@ -297,11 +297,11 @@ discard block |
||
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 <strong>20% off</strong> all Pro Add-on purchases.", 'google-calendar-events' ); ?> |
|
300 | + <?php _e("Enter your name and email and we'll send you a coupon code for <strong>20% off</strong> all Pro Add-on purchases.", '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 |
||
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,17 +318,17 @@ discard block |
||
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 | - <em><?php _e( 'No spam. Unsubscribe anytime.', 'google-calendar-events' ); ?></em> |
|
324 | + <em><?php _e('No spam. Unsubscribe anytime.', 'google-calendar-events'); ?></em> |
|
325 | 325 | <br/> |
326 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'sidebar-link' ); ?>" |
|
327 | - target="_blank"><?php _e( 'Just take me the add-ons', 'google-calendar-events' ); ?></a> |
|
326 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'sidebar-link'); ?>" |
|
327 | + target="_blank"><?php _e('Just take me the add-ons', 'google-calendar-events'); ?></a> |
|
328 | 328 | </div> |
329 | 329 | </div> |
330 | 330 | <div class="thank-you" style="display: none;"> |
331 | - <?php _e( 'Thank you!', 'google-calendar-events' ); ?> |
|
331 | + <?php _e('Thank you!', 'google-calendar-events'); ?> |
|
332 | 332 | </div> |
333 | 333 | <div class="clear"> |
334 | 334 | </div> |
@@ -347,29 +347,29 @@ discard block |
||
347 | 347 | */ |
348 | 348 | function simcal_upgrade_to_premium() { |
349 | 349 | |
350 | - if ( $screen = simcal_is_admin_screen() ) { |
|
350 | + if ($screen = simcal_is_admin_screen()) { |
|
351 | 351 | ?> |
352 | 352 | <div class="main"> |
353 | 353 | <p class="heading centered"> |
354 | - <?php _e( 'Some of the features included with our premium add-ons', 'google-calendar-events' ); ?> |
|
354 | + <?php _e('Some of the features included with our premium add-ons', 'google-calendar-events'); ?> |
|
355 | 355 | </p> |
356 | 356 | |
357 | 357 | <ul> |
358 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Display color coded events', 'google-calendar-events' ); ?></li> |
|
359 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Show week & day views', 'google-calendar-events' ); ?></li> |
|
360 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Fast view switching', 'google-calendar-events' ); ?></li> |
|
361 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Event titles & start times in grid', 'google-calendar-events' ); ?></li> |
|
362 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Limit event display times', 'google-calendar-events' ); ?></li> |
|
363 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Display private calendar events', 'google-calendar-events' ); ?></li> |
|
364 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Show attendees & RSVP status', 'google-calendar-events' ); ?></li> |
|
365 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Display attachments', 'google-calendar-events' ); ?></li> |
|
366 | - <li><div class="dashicons dashicons-yes"></div> <?php _e( 'Priority email support', 'google-calendar-events' ); ?></li> |
|
358 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Display color coded events', 'google-calendar-events'); ?></li> |
|
359 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Show week & day views', 'google-calendar-events'); ?></li> |
|
360 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Fast view switching', 'google-calendar-events'); ?></li> |
|
361 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Event titles & start times in grid', 'google-calendar-events'); ?></li> |
|
362 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Limit event display times', 'google-calendar-events'); ?></li> |
|
363 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Display private calendar events', 'google-calendar-events'); ?></li> |
|
364 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Show attendees & RSVP status', 'google-calendar-events'); ?></li> |
|
365 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Display attachments', 'google-calendar-events'); ?></li> |
|
366 | + <li><div class="dashicons dashicons-yes"></div> <?php _e('Priority email support', 'google-calendar-events'); ?></li> |
|
367 | 367 | </ul> |
368 | 368 | |
369 | 369 | <div class="centered"> |
370 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'sidebar-link' ); ?>" |
|
370 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'sidebar-link'); ?>" |
|
371 | 371 | class="button-primary button-large" target="_blank"> |
372 | - <?php _e( 'Upgrade to Premium Now', 'google-calendar-events' ); ?></a> |
|
372 | + <?php _e('Upgrade to Premium Now', 'google-calendar-events'); ?></a> |
|
373 | 373 | </div> |
374 | 374 | </div> |
375 | 375 | <?php |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Carbon\Carbon; |
10 | 10 | use SimpleCalendar\Abstracts\Calendar; |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param Event $event |
55 | 55 | * @param Calendar $calendar |
56 | 56 | */ |
57 | - public function __construct( Event $event, Calendar $calendar ) { |
|
57 | + public function __construct(Event $event, Calendar $calendar) { |
|
58 | 58 | $this->event = $event; |
59 | 59 | $this->calendar = $calendar; |
60 | 60 | $this->tags = $this->get_content_tags(); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return array |
69 | 69 | */ |
70 | 70 | public function get_content_tags() { |
71 | - return array_merge( array( |
|
71 | + return array_merge(array( |
|
72 | 72 | |
73 | 73 | /* ============ * |
74 | 74 | * Content Tags * |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | 'if-not-end-location', |
215 | 215 | // Does the event has NOT an end location? |
216 | 216 | |
217 | - ), (array) $this->add_custom_event_tags() ); |
|
217 | + ), (array) $this->add_custom_event_tags()); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -226,16 +226,16 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return string |
228 | 228 | */ |
229 | - public function parse_event_template_tags( $template_tags = '' ) { |
|
229 | + public function parse_event_template_tags($template_tags = '') { |
|
230 | 230 | |
231 | 231 | // Process tags. |
232 | - $result = preg_replace_callback( $this->get_regex(), array( $this, 'process_event_content' ), $template_tags ); |
|
232 | + $result = preg_replace_callback($this->get_regex(), array($this, 'process_event_content'), $template_tags); |
|
233 | 233 | |
234 | 234 | // Removes extra consecutive <br> tags. |
235 | 235 | // TODO: Doesn't seem to work but going to remove it to allow multiple <br> tags in the editor |
236 | 236 | /*return preg_replace( '#(<br *//*?>\s*)+#i', '<br />', trim( $result ) );*/ |
237 | 237 | |
238 | - return do_shortcode( trim( $result ) ); |
|
238 | + return do_shortcode(trim($result)); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return string |
249 | 249 | */ |
250 | - public function process_event_content( $match ) { |
|
250 | + public function process_event_content($match) { |
|
251 | 251 | |
252 | - if ( $match[1] == '[' && $match[6] == ']' ) { |
|
253 | - return substr( $match[0], 1, -1 ); |
|
252 | + if ($match[1] == '[' && $match[6] == ']') { |
|
253 | + return substr($match[0], 1, -1); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | $tag = $match[2]; // Tag name without square brackets. |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | $calendar = $this->calendar; |
263 | 263 | $event = $this->event; |
264 | 264 | |
265 | - if ( ( $calendar instanceof Calendar ) && ( $event instanceof Event ) ) { |
|
265 | + if (($calendar instanceof Calendar) && ($event instanceof Event)) { |
|
266 | 266 | |
267 | - switch ( $tag ) { |
|
267 | + switch ($tag) { |
|
268 | 268 | |
269 | 269 | /* ============ * |
270 | 270 | * Content Tags * |
@@ -272,13 +272,13 @@ discard block |
||
272 | 272 | |
273 | 273 | case 'title' : |
274 | 274 | case 'event-title' : |
275 | - return $this->get_title( $event->title, $attr ); |
|
275 | + return $this->get_title($event->title, $attr); |
|
276 | 276 | |
277 | 277 | case 'description' : |
278 | - return $this->get_description( $event->description, $attr ); |
|
278 | + return $this->get_description($event->description, $attr); |
|
279 | 279 | |
280 | 280 | case 'when' : |
281 | - return $this->get_when( $event ); |
|
281 | + return $this->get_when($event); |
|
282 | 282 | |
283 | 283 | case 'end-date' : |
284 | 284 | case 'end-custom' : |
@@ -288,58 +288,58 @@ discard block |
||
288 | 288 | case 'start-date' : |
289 | 289 | case 'start-human' : |
290 | 290 | case 'start-time' : |
291 | - return $this->get_dt( $tag, $event, $attr ); |
|
291 | + return $this->get_dt($tag, $event, $attr); |
|
292 | 292 | |
293 | 293 | case 'length' : |
294 | 294 | case 'duration' : |
295 | - if ( false !== $event->end ) { |
|
295 | + if (false !== $event->end) { |
|
296 | 296 | $duration = $event->start - $event->end; |
297 | - $value = human_time_diff( $event->start, $event->end ); |
|
297 | + $value = human_time_diff($event->start, $event->end); |
|
298 | 298 | } else { |
299 | 299 | $duration = '-1'; |
300 | - $value = __( 'No end time', 'google-calendar-events' ); |
|
300 | + $value = __('No end time', 'google-calendar-events'); |
|
301 | 301 | } |
302 | 302 | |
303 | - return ' <span class="simcal-event-duration" data-event-duration="' . $duration . '">' . $value . '</span>'; |
|
303 | + return ' <span class="simcal-event-duration" data-event-duration="'.$duration.'">'.$value.'</span>'; |
|
304 | 304 | |
305 | 305 | case 'location' : |
306 | 306 | case 'start-location' : |
307 | 307 | case 'end-location' : |
308 | - $location = ( 'end-location' == $tag ) ? $event->end_location['address'] : $event->start_location['address']; |
|
309 | - $location_class = ( 'end-location' == $tag ) ? 'end' : 'start'; |
|
308 | + $location = ('end-location' == $tag) ? $event->end_location['address'] : $event->start_location['address']; |
|
309 | + $location_class = ('end-location' == $tag) ? 'end' : 'start'; |
|
310 | 310 | |
311 | 311 | // location, location.name, location.address (type PostalAddress) all required for schema data. |
312 | 312 | // Need to use event name where location data doesn't exist. |
313 | 313 | // Since we have 1 location field, use it as the name and address. |
314 | 314 | // If the location is blank, use the event title as the name and address. |
315 | 315 | // Wrap with wp_strip_all_tags(). |
316 | - $meta_location_name_and_address = empty( $location ) ? wp_strip_all_tags( $event->title ) : wp_strip_all_tags( $location ); |
|
316 | + $meta_location_name_and_address = empty($location) ? wp_strip_all_tags($event->title) : wp_strip_all_tags($location); |
|
317 | 317 | |
318 | - return ' <span class="simcal-event-address simcal-event-' . $location_class . '-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . '<meta itemprop="name" content="' . $meta_location_name_and_address . '" />' . '<meta itemprop="address" content="' . $meta_location_name_and_address . '" />' . wp_strip_all_tags( $location ) . '</span>'; |
|
318 | + return ' <span class="simcal-event-address simcal-event-'.$location_class.'-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'.'<meta itemprop="name" content="'.$meta_location_name_and_address.'" />'.'<meta itemprop="address" content="'.$meta_location_name_and_address.'" />'.wp_strip_all_tags($location).'</span>'; |
|
319 | 319 | |
320 | 320 | case 'start-location-link': |
321 | 321 | case 'end-location-link' : |
322 | 322 | case 'maps-link' : |
323 | - $location = ( 'end-location-link' == $tag ) ? $event->end_location['address'] : $event->start_location['address']; |
|
324 | - if ( ! empty( $location ) ) { |
|
325 | - $url = '//maps.google.com?q=' . urlencode( $location ); |
|
323 | + $location = ('end-location-link' == $tag) ? $event->end_location['address'] : $event->start_location['address']; |
|
324 | + if ( ! empty($location)) { |
|
325 | + $url = '//maps.google.com?q='.urlencode($location); |
|
326 | 326 | |
327 | - return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr ); |
|
327 | + return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr); |
|
328 | 328 | } |
329 | 329 | break; |
330 | 330 | |
331 | 331 | case 'link' : |
332 | 332 | case 'url' : |
333 | - $content = ( 'link' == $tag ) ? $calendar->get_event_html( $event, $partial ) : ''; |
|
333 | + $content = ('link' == $tag) ? $calendar->get_event_html($event, $partial) : ''; |
|
334 | 334 | |
335 | - return $this->make_link( $tag, $event->link, $content, $attr ); |
|
335 | + return $this->make_link($tag, $event->link, $content, $attr); |
|
336 | 336 | |
337 | 337 | case 'add-to-gcal-link'; |
338 | - $content = ( 'add-to-gcal-link' == $tag ) ? $calendar->get_event_html( $event, $partial ) : ''; |
|
339 | - if ( ! empty( $content ) ) { |
|
340 | - $url = $calendar->get_add_to_gcal_url( $event ); |
|
338 | + $content = ('add-to-gcal-link' == $tag) ? $calendar->get_event_html($event, $partial) : ''; |
|
339 | + if ( ! empty($content)) { |
|
340 | + $url = $calendar->get_add_to_gcal_url($event); |
|
341 | 341 | |
342 | - return $this->make_link( $tag, $url, $content, $attr ); |
|
342 | + return $this->make_link($tag, $url, $content, $attr); |
|
343 | 343 | } |
344 | 344 | break; |
345 | 345 | |
@@ -366,22 +366,22 @@ discard block |
||
366 | 366 | |
367 | 367 | case 'attachments' : |
368 | 368 | $attachments = $event->get_attachments(); |
369 | - if ( ! empty( $attachments ) ) { |
|
370 | - return $this->get_attachments( $attachments ); |
|
369 | + if ( ! empty($attachments)) { |
|
370 | + return $this->get_attachments($attachments); |
|
371 | 371 | } |
372 | 372 | break; |
373 | 373 | |
374 | 374 | case 'attendees' : |
375 | 375 | $attendees = $event->get_attendees(); |
376 | - if ( ! empty( $attendees ) ) { |
|
377 | - return $this->get_attendees( $attendees, $attr ); |
|
376 | + if ( ! empty($attendees)) { |
|
377 | + return $this->get_attendees($attendees, $attr); |
|
378 | 378 | } |
379 | 379 | break; |
380 | 380 | |
381 | 381 | case 'organizer' : |
382 | 382 | $organizer = $event->get_organizer(); |
383 | - if ( ! empty( $organizer ) ) { |
|
384 | - return $this->get_organizer( $organizer, $attr ); |
|
383 | + if ( ! empty($organizer)) { |
|
384 | + return $this->get_organizer($organizer, $attr); |
|
385 | 385 | } |
386 | 386 | break; |
387 | 387 | |
@@ -390,35 +390,35 @@ discard block |
||
390 | 390 | * ================ */ |
391 | 391 | |
392 | 392 | case 'if-title': |
393 | - if ( ! empty( $event->title ) ) { |
|
394 | - return $calendar->get_event_html( $event, $partial ); |
|
393 | + if ( ! empty($event->title)) { |
|
394 | + return $calendar->get_event_html($event, $partial); |
|
395 | 395 | } |
396 | 396 | break; |
397 | 397 | |
398 | 398 | case 'if-description': |
399 | - if ( ! empty( $event->description ) ) { |
|
400 | - return $calendar->get_event_html( $event, $partial ); |
|
399 | + if ( ! empty($event->description)) { |
|
400 | + return $calendar->get_event_html($event, $partial); |
|
401 | 401 | } |
402 | 402 | break; |
403 | 403 | |
404 | 404 | case 'if-now' : |
405 | 405 | case 'if-not-now' : |
406 | 406 | |
407 | - $start_dt = $event->start_dt->setTimezone( $calendar->timezone ); |
|
407 | + $start_dt = $event->start_dt->setTimezone($calendar->timezone); |
|
408 | 408 | $start = $start_dt->getTimestamp(); |
409 | 409 | |
410 | - if ( $event->end_dt instanceof Carbon ) { |
|
411 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
410 | + if ($event->end_dt instanceof Carbon) { |
|
411 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
412 | 412 | } else { |
413 | 413 | return ''; |
414 | 414 | } |
415 | 415 | |
416 | - $now = ( $start <= $calendar->now ) && ( $end >= $calendar->now ); |
|
416 | + $now = ($start <= $calendar->now) && ($end >= $calendar->now); |
|
417 | 417 | |
418 | - if ( ( 'if-now' == $tag ) && $now ) { |
|
419 | - return $calendar->get_event_html( $event, $partial ); |
|
420 | - } elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) { |
|
421 | - return $calendar->get_event_html( $event, $partial ); |
|
418 | + if (('if-now' == $tag) && $now) { |
|
419 | + return $calendar->get_event_html($event, $partial); |
|
420 | + } elseif (('if-not-now' == $tag) && (false == $now)) { |
|
421 | + return $calendar->get_event_html($event, $partial); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | break; |
@@ -426,15 +426,15 @@ discard block |
||
426 | 426 | case 'if-started' : |
427 | 427 | case 'if-not-started' : |
428 | 428 | |
429 | - $start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
429 | + $start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
430 | 430 | |
431 | - if ( 'if-started' == $tag ) { |
|
432 | - if ( $start < $calendar->now ) { |
|
433 | - return $calendar->get_event_html( $event, $partial ); |
|
431 | + if ('if-started' == $tag) { |
|
432 | + if ($start < $calendar->now) { |
|
433 | + return $calendar->get_event_html($event, $partial); |
|
434 | 434 | } |
435 | - } elseif ( 'if-not-started' == $tag ) { |
|
436 | - if ( $start > $calendar->now ) { |
|
437 | - return $calendar->get_event_html( $event, $partial ); |
|
435 | + } elseif ('if-not-started' == $tag) { |
|
436 | + if ($start > $calendar->now) { |
|
437 | + return $calendar->get_event_html($event, $partial); |
|
438 | 438 | } |
439 | 439 | } |
440 | 440 | |
@@ -443,17 +443,17 @@ discard block |
||
443 | 443 | case 'if-ended' : |
444 | 444 | case 'if-not-ended' : |
445 | 445 | |
446 | - if ( false !== $event->end ) { |
|
446 | + if (false !== $event->end) { |
|
447 | 447 | |
448 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
448 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
449 | 449 | |
450 | - if ( 'if-ended' == $tag ) { |
|
451 | - if ( $end < $calendar->now ) { |
|
452 | - return $calendar->get_event_html( $event, $partial ); |
|
450 | + if ('if-ended' == $tag) { |
|
451 | + if ($end < $calendar->now) { |
|
452 | + return $calendar->get_event_html($event, $partial); |
|
453 | 453 | } |
454 | - } elseif ( 'if-not-ended' == $tag ) { |
|
455 | - if ( $end > $calendar->now ) { |
|
456 | - return $calendar->get_event_html( $event, $partial ); |
|
454 | + } elseif ('if-not-ended' == $tag) { |
|
455 | + if ($end > $calendar->now) { |
|
456 | + return $calendar->get_event_html($event, $partial); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
@@ -462,14 +462,14 @@ discard block |
||
462 | 462 | break; |
463 | 463 | |
464 | 464 | case 'if-end-time' : |
465 | - if ( false !== $event->end ) { |
|
466 | - return $calendar->get_event_html( $event, $partial ); |
|
465 | + if (false !== $event->end) { |
|
466 | + return $calendar->get_event_html($event, $partial); |
|
467 | 467 | } |
468 | 468 | break; |
469 | 469 | |
470 | 470 | case 'if-no-end-time' : |
471 | - if ( false === $event->end ) { |
|
472 | - return $calendar->get_event_html( $event, $partial ); |
|
471 | + if (false === $event->end) { |
|
472 | + return $calendar->get_event_html($event, $partial); |
|
473 | 473 | } |
474 | 474 | break; |
475 | 475 | |
@@ -477,62 +477,62 @@ discard block |
||
477 | 477 | case 'if-whole-day' : |
478 | 478 | case 'if-not-all-day' : |
479 | 479 | case 'if-not-whole-day' : |
480 | - $bool = strstr( $tag, 'not' ) ? false : true; |
|
481 | - if ( $bool === $event->whole_day ) { |
|
482 | - return $calendar->get_event_html( $event, $partial ); |
|
480 | + $bool = strstr($tag, 'not') ? false : true; |
|
481 | + if ($bool === $event->whole_day) { |
|
482 | + return $calendar->get_event_html($event, $partial); |
|
483 | 483 | } |
484 | 484 | break; |
485 | 485 | |
486 | 486 | case 'if-recurring' : |
487 | - if ( ! empty( $event->recurrence ) ) { |
|
488 | - return $calendar->get_event_html( $event, $partial ); |
|
487 | + if ( ! empty($event->recurrence)) { |
|
488 | + return $calendar->get_event_html($event, $partial); |
|
489 | 489 | } |
490 | 490 | break; |
491 | 491 | |
492 | 492 | case 'if-not-recurring' : |
493 | - if ( false === $event->recurrence ) { |
|
494 | - return $calendar->get_event_html( $event, $partial ); |
|
493 | + if (false === $event->recurrence) { |
|
494 | + return $calendar->get_event_html($event, $partial); |
|
495 | 495 | } |
496 | 496 | break; |
497 | 497 | |
498 | 498 | case 'if-multi-day' : |
499 | - if ( false !== $event->multiple_days ) { |
|
500 | - return $calendar->get_event_html( $event, $partial ); |
|
499 | + if (false !== $event->multiple_days) { |
|
500 | + return $calendar->get_event_html($event, $partial); |
|
501 | 501 | } |
502 | 502 | break; |
503 | 503 | |
504 | 504 | case 'if-single-day' : |
505 | - if ( false === $event->multiple_days ) { |
|
506 | - return $calendar->get_event_html( $event, $partial ); |
|
505 | + if (false === $event->multiple_days) { |
|
506 | + return $calendar->get_event_html($event, $partial); |
|
507 | 507 | } |
508 | 508 | break; |
509 | 509 | |
510 | 510 | case 'if-location' : |
511 | 511 | case 'if-start-location' : |
512 | - if ( ! empty( $event->start_location['address'] ) ) { |
|
513 | - return $calendar->get_event_html( $event, $partial ); |
|
512 | + if ( ! empty($event->start_location['address'])) { |
|
513 | + return $calendar->get_event_html($event, $partial); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | return false; |
517 | 517 | |
518 | 518 | case 'if-not-location' : |
519 | 519 | case 'if-not-start-location' : |
520 | - if ( empty( $event->start_location['address'] ) ) { |
|
521 | - return $calendar->get_event_html( $event, $partial ); |
|
520 | + if (empty($event->start_location['address'])) { |
|
521 | + return $calendar->get_event_html($event, $partial); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | return ''; |
525 | 525 | |
526 | 526 | case 'if-not-end-location' : |
527 | - if ( empty( $event->end_location['address'] ) ) { |
|
528 | - return $calendar->get_event_html( $event, $partial ); |
|
527 | + if (empty($event->end_location['address'])) { |
|
528 | + return $calendar->get_event_html($event, $partial); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | return ''; |
532 | 532 | |
533 | 533 | case 'if-end-location' : |
534 | - if ( ! empty( $event->end_location['address'] ) ) { |
|
535 | - return $calendar->get_event_html( $event, $partial ); |
|
534 | + if ( ! empty($event->end_location['address'])) { |
|
535 | + return $calendar->get_event_html($event, $partial); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | return ''; |
@@ -542,12 +542,12 @@ discard block |
||
542 | 542 | * ======= */ |
543 | 543 | |
544 | 544 | default : |
545 | - $resultCustom = $this->do_custom_event_tag( $tag, $partial, $attr, $event ); |
|
546 | - if ( $resultCustom != "" ) { |
|
545 | + $resultCustom = $this->do_custom_event_tag($tag, $partial, $attr, $event); |
|
546 | + if ($resultCustom != "") { |
|
547 | 547 | return $resultCustom; |
548 | 548 | } |
549 | 549 | |
550 | - return wp_kses_post( $before . $partial . $after ); |
|
550 | + return wp_kses_post($before.$partial.$after); |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | |
@@ -565,14 +565,14 @@ discard block |
||
565 | 565 | * |
566 | 566 | * @return string |
567 | 567 | */ |
568 | - private function limit_words( $text, $limit ) { |
|
568 | + private function limit_words($text, $limit) { |
|
569 | 569 | |
570 | - $limit = max( absint( $limit ), 0 ); |
|
570 | + $limit = max(absint($limit), 0); |
|
571 | 571 | |
572 | - if ( $limit > 0 && ( str_word_count( $text, 0 ) > $limit ) ) { |
|
573 | - $words = str_word_count( $text, 2 ); |
|
574 | - $pos = array_keys( $words ); |
|
575 | - $text = trim( substr( $text, 0, $pos[ $limit ] ) ) . '…'; |
|
572 | + if ($limit > 0 && (str_word_count($text, 0) > $limit)) { |
|
573 | + $words = str_word_count($text, 2); |
|
574 | + $pos = array_keys($words); |
|
575 | + $text = trim(substr($text, 0, $pos[$limit])).'…'; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | return $text; |
@@ -589,26 +589,26 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return string |
591 | 591 | */ |
592 | - private function get_title( $title, $attr ) { |
|
592 | + private function get_title($title, $attr) { |
|
593 | 593 | |
594 | - if ( empty( $title ) ) { |
|
594 | + if (empty($title)) { |
|
595 | 595 | return ''; |
596 | 596 | } |
597 | 597 | |
598 | - $attr = array_merge( array( |
|
599 | - 'html' => '', // Parse HTML |
|
600 | - 'limit' => 0, // Trim length to amount of words |
|
601 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
598 | + $attr = array_merge(array( |
|
599 | + 'html' => '', // Parse HTML |
|
600 | + 'limit' => 0, // Trim length to amount of words |
|
601 | + ), (array) shortcode_parse_atts($attr)); |
|
602 | 602 | |
603 | - if ( ! empty( $attr['html'] ) ) { |
|
604 | - $title = wp_kses_post( $title ); |
|
603 | + if ( ! empty($attr['html'])) { |
|
604 | + $title = wp_kses_post($title); |
|
605 | 605 | $tag = 'div'; |
606 | 606 | } else { |
607 | - $title = $this->limit_words( $title, $attr['limit'] ); |
|
607 | + $title = $this->limit_words($title, $attr['limit']); |
|
608 | 608 | $tag = 'span'; |
609 | 609 | } |
610 | 610 | |
611 | - return '<' . $tag . ' class="simcal-event-title" itemprop="name">' . $title . '</' . $tag . '>'; |
|
611 | + return '<'.$tag.' class="simcal-event-title" itemprop="name">'.$title.'</'.$tag.'>'; |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
@@ -622,18 +622,18 @@ discard block |
||
622 | 622 | * |
623 | 623 | * @return string |
624 | 624 | */ |
625 | - private function get_description( $description, $attr ) { |
|
625 | + private function get_description($description, $attr) { |
|
626 | 626 | |
627 | - if ( empty( $description ) ) { |
|
627 | + if (empty($description)) { |
|
628 | 628 | return ''; |
629 | 629 | } |
630 | 630 | |
631 | - $attr = array_merge( array( |
|
632 | - 'limit' => 0, // Trim length to number of words |
|
633 | - 'html' => 'no', // Parse HTML content |
|
634 | - 'markdown' => 'no', // Parse Markdown content |
|
635 | - 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
636 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
631 | + $attr = array_merge(array( |
|
632 | + 'limit' => 0, // Trim length to number of words |
|
633 | + 'html' => 'no', // Parse HTML content |
|
634 | + 'markdown' => 'no', // Parse Markdown content |
|
635 | + 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
636 | + ), (array) shortcode_parse_atts($attr)); |
|
637 | 637 | |
638 | 638 | $allow_html = 'no' != $attr['html'] ? true : false; |
639 | 639 | $allow_md = 'no' != $attr['markdown'] ? true : false; |
@@ -641,23 +641,23 @@ discard block |
||
641 | 641 | $html = '<div class="simcal-event-description" itemprop="description">'; |
642 | 642 | |
643 | 643 | // Markdown and HTML don't play well together, use one or the other in the same tag. |
644 | - if ( $allow_html || $allow_md ) { |
|
645 | - if ( $allow_html ) { |
|
646 | - $description = wp_kses_post( $description ); |
|
647 | - } elseif ( $allow_md ) { |
|
644 | + if ($allow_html || $allow_md) { |
|
645 | + if ($allow_html) { |
|
646 | + $description = wp_kses_post($description); |
|
647 | + } elseif ($allow_md) { |
|
648 | 648 | $markdown = new \Parsedown(); |
649 | - $description = $markdown->text( wp_strip_all_tags( $description ) ); |
|
649 | + $description = $markdown->text(wp_strip_all_tags($description)); |
|
650 | 650 | } |
651 | 651 | } else { |
652 | - $description = wpautop( $description ); |
|
652 | + $description = wpautop($description); |
|
653 | 653 | } |
654 | 654 | |
655 | - $description = $this->limit_words( $description, $attr['limit'] ); |
|
655 | + $description = $this->limit_words($description, $attr['limit']); |
|
656 | 656 | |
657 | - $html .= $description . '</div>'; |
|
657 | + $html .= $description.'</div>'; |
|
658 | 658 | |
659 | - if ( 'no' != $attr['autolink'] ) { |
|
660 | - $html = ' ' . make_clickable( $html ); |
|
659 | + if ('no' != $attr['autolink']) { |
|
660 | + $html = ' '.make_clickable($html); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | return $html; |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | * |
674 | 674 | * @return string |
675 | 675 | */ |
676 | - private function get_when( Event $event ) { |
|
676 | + private function get_when(Event $event) { |
|
677 | 677 | |
678 | 678 | //$start = $event->start_dt->setTimezone( $event->timezone ); |
679 | 679 | //$end = ! is_null( $event->end_dt ) ? $event->end_dt->setTimezone( $event->timezone ) : null; |
@@ -683,41 +683,41 @@ discard block |
||
683 | 683 | $time_start = ''; |
684 | 684 | $time_end = ''; |
685 | 685 | $start_ts = $start->timestamp; |
686 | - $end_ts = ! is_null( $end ) ? $end->timestamp : null; |
|
686 | + $end_ts = ! is_null($end) ? $end->timestamp : null; |
|
687 | 687 | $start_iso = $start->toIso8601String(); |
688 | - $end_iso = ! is_null( $end ) ? $end->toIso8601String() : null;; |
|
688 | + $end_iso = ! is_null($end) ? $end->toIso8601String() : null; ; |
|
689 | 689 | |
690 | - if ( ! $event->whole_day ) { |
|
690 | + if ( ! $event->whole_day) { |
|
691 | 691 | |
692 | - $time_start = $this->calendar->datetime_separator . ' <span class="simcal-event-start simcal-event-start-time" ' . 'data-event-start="' . $start_ts . '" ' . 'data-event-format="' . $this->calendar->time_format . '" ' . 'itemprop="startDate" content="' . $start_iso . '">' . date_i18n( $this->calendar->time_format, strtotime( $start->toDateTimeString() ) ) . '</span> '; |
|
692 | + $time_start = $this->calendar->datetime_separator.' <span class="simcal-event-start simcal-event-start-time" '.'data-event-start="'.$start_ts.'" '.'data-event-format="'.$this->calendar->time_format.'" '.'itemprop="startDate" content="'.$start_iso.'">'.date_i18n($this->calendar->time_format, strtotime($start->toDateTimeString())).'</span> '; |
|
693 | 693 | |
694 | - if ( $end instanceof Carbon ) { |
|
694 | + if ($end instanceof Carbon) { |
|
695 | 695 | |
696 | - $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . 'data-event-end="' . $end_ts . '" ' . 'data-event-format="' . $this->calendar->time_format . '" ' . 'itemprop="endDate" content="' . $end_iso . '">' . date_i18n( $this->calendar->time_format, strtotime( $end->toDateTimeString() ) ) . '</span> '; |
|
696 | + $time_end = ' <span class="simcal-event-end simcal-event-end-time" '.'data-event-end="'.$end_ts.'" '.'data-event-format="'.$this->calendar->time_format.'" '.'itemprop="endDate" content="'.$end_iso.'">'.date_i18n($this->calendar->time_format, strtotime($end->toDateTimeString())).'</span> '; |
|
697 | 697 | |
698 | 698 | } |
699 | 699 | |
700 | 700 | } |
701 | 701 | |
702 | - if ( $event->multiple_days ) { |
|
702 | + if ($event->multiple_days) { |
|
703 | 703 | |
704 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . 'data-event-start="' . $start_ts . '" ' . 'data-event-format="' . $this->calendar->date_format . '" ' . 'itemprop="startDate" content="' . $start_iso . '">' . date_i18n( $this->calendar->date_format, strtotime( $start->toDateTimeString() ) ) . '</span> ' . $time_start; |
|
704 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '.'data-event-start="'.$start_ts.'" '.'data-event-format="'.$this->calendar->date_format.'" '.'itemprop="startDate" content="'.$start_iso.'">'.date_i18n($this->calendar->date_format, strtotime($start->toDateTimeString())).'</span> '.$time_start; |
|
705 | 705 | |
706 | - if ( $end instanceof Carbon ) { |
|
706 | + if ($end instanceof Carbon) { |
|
707 | 707 | |
708 | - $output .= '-' . ' <span class="simcal-event-start simcal-event-end-date" ' . 'data-event-start="' . $end_ts . '" ' . 'data-event-format="' . $this->calendar->date_format . '" ' . 'itemprop="endDate" content="' . $end_iso . '">' . date_i18n( $this->calendar->date_format, strtotime( $end->toDateTimeString() ) ) . '</span> ' . $time_end; |
|
708 | + $output .= '-'.' <span class="simcal-event-start simcal-event-end-date" '.'data-event-start="'.$end_ts.'" '.'data-event-format="'.$this->calendar->date_format.'" '.'itemprop="endDate" content="'.$end_iso.'">'.date_i18n($this->calendar->date_format, strtotime($end->toDateTimeString())).'</span> '.$time_end; |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | } else { |
712 | 712 | |
713 | - $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
|
713 | + $time_end = ! empty($time_start) && ! empty($time_end) ? ' - '.$time_end : ''; |
|
714 | 714 | |
715 | 715 | // All-day events also need startDate for schema data. |
716 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . 'data-event-start="' . $start_ts . '" ' . 'data-event-format="' . $this->calendar->date_format . '" ' . 'itemprop="startDate" content="' . $start_iso . '">' . date_i18n( $this->calendar->date_format, strtotime( $start->toDateTimeString() ) ) . '</span> ' . $time_start . $time_end; |
|
716 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '.'data-event-start="'.$start_ts.'" '.'data-event-format="'.$this->calendar->date_format.'" '.'itemprop="startDate" content="'.$start_iso.'">'.date_i18n($this->calendar->date_format, strtotime($start->toDateTimeString())).'</span> '.$time_start.$time_end; |
|
717 | 717 | |
718 | 718 | } |
719 | 719 | |
720 | - return trim( $output ); |
|
720 | + return trim($output); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | /** |
@@ -732,52 +732,52 @@ discard block |
||
732 | 732 | * |
733 | 733 | * @return string |
734 | 734 | */ |
735 | - private function get_dt( $tag, Event $event, $attr ) { |
|
735 | + private function get_dt($tag, Event $event, $attr) { |
|
736 | 736 | |
737 | - $bound = 0 === strpos( $tag, 'end' ) ? 'end' : 'start'; |
|
737 | + $bound = 0 === strpos($tag, 'end') ? 'end' : 'start'; |
|
738 | 738 | |
739 | - if ( ( 'end' == $bound ) && ( false === $event->end ) ) { |
|
739 | + if (('end' == $bound) && (false === $event->end)) { |
|
740 | 740 | return ''; |
741 | 741 | } |
742 | 742 | |
743 | - $dt = $bound . '_dt'; |
|
743 | + $dt = $bound.'_dt'; |
|
744 | 744 | |
745 | - if ( ! $event->$dt instanceof Carbon ) { |
|
745 | + if ( ! $event->$dt instanceof Carbon) { |
|
746 | 746 | return ''; |
747 | 747 | } |
748 | 748 | |
749 | 749 | $event_dt = $event->$dt; |
750 | 750 | |
751 | - $attr = array_merge( array( |
|
751 | + $attr = array_merge(array( |
|
752 | 752 | 'format' => '', |
753 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
753 | + ), (array) shortcode_parse_atts($attr)); |
|
754 | 754 | |
755 | - $format = ltrim( strstr( $tag, '-' ), '-' ); |
|
755 | + $format = ltrim(strstr($tag, '-'), '-'); |
|
756 | 756 | $dt_format = ''; |
757 | 757 | |
758 | - if ( ! empty( $attr['format'] ) ) { |
|
759 | - $dt_format = esc_attr( wp_strip_all_tags( $attr['format'] ) ); |
|
760 | - } elseif ( 'date' == $format ) { |
|
758 | + if ( ! empty($attr['format'])) { |
|
759 | + $dt_format = esc_attr(wp_strip_all_tags($attr['format'])); |
|
760 | + } elseif ('date' == $format) { |
|
761 | 761 | $dt_format = $this->calendar->date_format; |
762 | - } elseif ( 'time' == $format ) { |
|
762 | + } elseif ('time' == $format) { |
|
763 | 763 | $dt_format = $this->calendar->time_format; |
764 | 764 | } |
765 | 765 | |
766 | 766 | $dt_ts = $event_dt->timestamp; |
767 | 767 | |
768 | - if ( 'human' == $format ) { |
|
769 | - $value = human_time_diff( $dt_ts, Carbon::now( $event->timezone )->getTimestamp() ); |
|
768 | + if ('human' == $format) { |
|
769 | + $value = human_time_diff($dt_ts, Carbon::now($event->timezone)->getTimestamp()); |
|
770 | 770 | |
771 | - if ( $dt_ts < Carbon::now( $event->timezone )->getTimestamp() ) { |
|
772 | - $value .= ' ' . _x( 'ago', 'human date event builder code modifier', 'google-calendar-events' ); |
|
771 | + if ($dt_ts < Carbon::now($event->timezone)->getTimestamp()) { |
|
772 | + $value .= ' '._x('ago', 'human date event builder code modifier', 'google-calendar-events'); |
|
773 | 773 | } else { |
774 | - $value .= ' ' . _x( 'from now', 'human date event builder code modifier', 'google-calendar-events' ); |
|
774 | + $value .= ' '._x('from now', 'human date event builder code modifier', 'google-calendar-events'); |
|
775 | 775 | } |
776 | 776 | } else { |
777 | - $value = date_i18n( $dt_format, strtotime( $event_dt->toDateTimeString() ) ); |
|
777 | + $value = date_i18n($dt_format, strtotime($event_dt->toDateTimeString())); |
|
778 | 778 | } |
779 | 779 | |
780 | - return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '" ' . 'data-event-' . $bound . '="' . $dt_ts . '" ' . 'data-event-format="' . $dt_format . '" ' . 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . $value . '</span>'; |
|
780 | + return '<span class="simcal-event-'.$bound.' '.'simcal-event-'.$bound.'-'.$format.'" '.'data-event-'.$bound.'="'.$dt_ts.'" '.'data-event-format="'.$dt_format.'" '.'itemprop="'.$bound.'Date" content="'.$event_dt->toIso8601String().'">'.$value.'</span>'; |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | /** |
@@ -793,23 +793,23 @@ discard block |
||
793 | 793 | * |
794 | 794 | * @return string |
795 | 795 | */ |
796 | - private function make_link( $tag, $url, $content, $attr ) { |
|
796 | + private function make_link($tag, $url, $content, $attr) { |
|
797 | 797 | |
798 | - if ( empty( $url ) ) { |
|
798 | + if (empty($url)) { |
|
799 | 799 | return ''; |
800 | 800 | } |
801 | 801 | |
802 | - $text = empty( $content ) ? $url : $content; |
|
802 | + $text = empty($content) ? $url : $content; |
|
803 | 803 | |
804 | - $attr = array_merge( array( |
|
805 | - 'autolink' => false, // Convert url to link anchor |
|
806 | - 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
807 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
804 | + $attr = array_merge(array( |
|
805 | + 'autolink' => false, // Convert url to link anchor |
|
806 | + 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
807 | + ), (array) shortcode_parse_atts($attr)); |
|
808 | 808 | |
809 | 809 | $anchor = $tag != 'url' ? 'yes' : $attr['autolink']; |
810 | 810 | $target = $attr['newwindow'] !== false ? 'target="_blank"' : ''; |
811 | 811 | |
812 | - return $anchor !== false ? ' <a href="' . esc_url( $url ) . '" ' . $target . '>' . $text . '</a>' : ' ' . $text; |
|
812 | + return $anchor !== false ? ' <a href="'.esc_url($url).'" '.$target.'>'.$text.'</a>' : ' '.$text; |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | /** |
@@ -822,20 +822,20 @@ discard block |
||
822 | 822 | * |
823 | 823 | * @return string |
824 | 824 | */ |
825 | - private function get_attachments( $attachments ) { |
|
825 | + private function get_attachments($attachments) { |
|
826 | 826 | |
827 | - $html = '<ul class="simcal-attachments">' . "\n\t"; |
|
827 | + $html = '<ul class="simcal-attachments">'."\n\t"; |
|
828 | 828 | |
829 | - foreach ( $attachments as $attachment ) { |
|
829 | + foreach ($attachments as $attachment) { |
|
830 | 830 | $html .= '<li class="simcal-attachment">'; |
831 | - $html .= '<a href="' . $attachment['url'] . '" target="_blank">'; |
|
832 | - $html .= ! empty( $attachment['icon'] ) ? '<img src="' . $attachment['icon'] . '" />' : ''; |
|
833 | - $html .= '<span>' . $attachment['name'] . '</span>'; |
|
831 | + $html .= '<a href="'.$attachment['url'].'" target="_blank">'; |
|
832 | + $html .= ! empty($attachment['icon']) ? '<img src="'.$attachment['icon'].'" />' : ''; |
|
833 | + $html .= '<span>'.$attachment['name'].'</span>'; |
|
834 | 834 | $html .= '</a>'; |
835 | - $html .= '</li>' . "\n"; |
|
835 | + $html .= '</li>'."\n"; |
|
836 | 836 | } |
837 | 837 | |
838 | - $html .= '</ul>' . "\n"; |
|
838 | + $html .= '</ul>'."\n"; |
|
839 | 839 | |
840 | 840 | return $html; |
841 | 841 | } |
@@ -851,41 +851,41 @@ discard block |
||
851 | 851 | * |
852 | 852 | * @return string |
853 | 853 | */ |
854 | - private function get_attendees( $attendees, $attr ) { |
|
854 | + private function get_attendees($attendees, $attr) { |
|
855 | 855 | |
856 | - $attr = array_merge( array( |
|
857 | - 'photo' => 'show', // show/hide attendee photo |
|
858 | - 'email' => 'hide', // show/hide attendee email address |
|
859 | - 'rsvp' => 'hide', // show/hide rsvp response status |
|
860 | - 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
861 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
856 | + $attr = array_merge(array( |
|
857 | + 'photo' => 'show', // show/hide attendee photo |
|
858 | + 'email' => 'hide', // show/hide attendee email address |
|
859 | + 'rsvp' => 'hide', // show/hide rsvp response status |
|
860 | + 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
861 | + ), (array) shortcode_parse_atts($attr)); |
|
862 | 862 | |
863 | - $html = '<ul class="simcal-attendees" itemprop="attendees">' . "\n\t"; |
|
863 | + $html = '<ul class="simcal-attendees" itemprop="attendees">'."\n\t"; |
|
864 | 864 | |
865 | 865 | $known = 0; |
866 | 866 | $unknown = 0; |
867 | 867 | |
868 | - foreach ( $attendees as $attendee ) { |
|
868 | + foreach ($attendees as $attendee) { |
|
869 | 869 | |
870 | - if ( 'yes' == $attr['response'] && 'yes' != $attendee['response'] ) { |
|
870 | + if ('yes' == $attr['response'] && 'yes' != $attendee['response']) { |
|
871 | 871 | continue; |
872 | - } elseif ( 'no' == $attr['response'] && 'no' != $attendee['response'] ) { |
|
872 | + } elseif ('no' == $attr['response'] && 'no' != $attendee['response']) { |
|
873 | 873 | continue; |
874 | - } elseif ( 'maybe' == $attr['response'] && ! in_array( $attendee['response'], array( 'yes', 'maybe' ) ) ) { |
|
874 | + } elseif ('maybe' == $attr['response'] && ! in_array($attendee['response'], array('yes', 'maybe'))) { |
|
875 | 875 | continue; |
876 | 876 | } |
877 | 877 | |
878 | - if ( ! empty( $attendee['name'] ) ) { |
|
878 | + if ( ! empty($attendee['name'])) { |
|
879 | 879 | |
880 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $attendee['photo'] . '" itemprop="image" />' : ''; |
|
881 | - $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response( $attendee['response'] ) : ''; |
|
882 | - $guest = $photo . '<span itemprop="name">' . $attendee['name'] . $response . '</span>'; |
|
880 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$attendee['photo'].'" itemprop="image" />' : ''; |
|
881 | + $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response($attendee['response']) : ''; |
|
882 | + $guest = $photo.'<span itemprop="name">'.$attendee['name'].$response.'</span>'; |
|
883 | 883 | |
884 | - if ( ! empty( $attendee['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
885 | - $guest = sprintf( '<a href="mailto:' . $attendee['email'] . '" itemprop="email">%s</a>', $guest ); |
|
884 | + if ( ! empty($attendee['email']) && ('show' == $attr['email'])) { |
|
885 | + $guest = sprintf('<a href="mailto:'.$attendee['email'].'" itemprop="email">%s</a>', $guest); |
|
886 | 886 | } |
887 | 887 | |
888 | - $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">' . $guest . '</li>' . "\n"; |
|
888 | + $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">'.$guest.'</li>'."\n"; |
|
889 | 889 | |
890 | 890 | $known++; |
891 | 891 | |
@@ -896,21 +896,21 @@ discard block |
||
896 | 896 | } |
897 | 897 | } |
898 | 898 | |
899 | - if ( $unknown > 0 ) { |
|
900 | - if ( $known > 0 ) { |
|
899 | + if ($unknown > 0) { |
|
900 | + if ($known > 0) { |
|
901 | 901 | /* translators: One more person attending the event. */ |
902 | - $others = sprintf( _n( '1 more attendee', '%s more attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
902 | + $others = sprintf(_n('1 more attendee', '%s more attendees', $unknown, 'google-calendar-events'), $unknown); |
|
903 | 903 | } else { |
904 | 904 | /* translators: One or more persons attending the event whose name is unknown. */ |
905 | - $others = sprintf( _n( '1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
905 | + $others = sprintf(_n('1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events'), $unknown); |
|
906 | 906 | } |
907 | - $photo = $attr['photo'] !== 'hide' ? get_avatar( '', 128 ) : ''; |
|
908 | - $html .= '<li class="simcal-attendee simcal-attendee-anonymous">' . $photo . '<span>' . $others . '</span></li>' . "\n"; |
|
909 | - } elseif ( $known === 0 ) { |
|
910 | - $html .= '<li class="simcal-attendee">' . _x( 'No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events' ) . '</li>' . "\n"; |
|
907 | + $photo = $attr['photo'] !== 'hide' ? get_avatar('', 128) : ''; |
|
908 | + $html .= '<li class="simcal-attendee simcal-attendee-anonymous">'.$photo.'<span>'.$others.'</span></li>'."\n"; |
|
909 | + } elseif ($known === 0) { |
|
910 | + $html .= '<li class="simcal-attendee">'._x('No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events').'</li>'."\n"; |
|
911 | 911 | } |
912 | 912 | |
913 | - $html .= '</ul>' . "\n"; |
|
913 | + $html .= '</ul>'."\n"; |
|
914 | 914 | |
915 | 915 | return $html; |
916 | 916 | } |
@@ -924,23 +924,23 @@ discard block |
||
924 | 924 | * |
925 | 925 | * @return string |
926 | 926 | */ |
927 | - private function get_rsvp_response( $response ) { |
|
927 | + private function get_rsvp_response($response) { |
|
928 | 928 | |
929 | - if ( 'yes' == $response ) { |
|
929 | + if ('yes' == $response) { |
|
930 | 930 | /* translators: Someone replied with 'yes' to a rsvp request. */ |
931 | - $rsvp = __( 'Attending', 'google-calendar-events' ); |
|
932 | - } elseif ( 'no' == $response ) { |
|
931 | + $rsvp = __('Attending', 'google-calendar-events'); |
|
932 | + } elseif ('no' == $response) { |
|
933 | 933 | /* translators: Someone replied with 'no' to a rsvp request. */ |
934 | - $rsvp = __( 'Not attending', 'google-calendar-events' ); |
|
935 | - } elseif ( 'maybe' == $response ) { |
|
934 | + $rsvp = __('Not attending', 'google-calendar-events'); |
|
935 | + } elseif ('maybe' == $response) { |
|
936 | 936 | /* translators: Someone replied with 'maybe' to a rsvp request. */ |
937 | - $rsvp = __( 'Maybe attending', 'google-calendar-events' ); |
|
937 | + $rsvp = __('Maybe attending', 'google-calendar-events'); |
|
938 | 938 | } else { |
939 | 939 | /* translators: Someone did not send yet a rsvp confirmation to join an event. */ |
940 | - $rsvp = __( 'Response pending', 'google-calendar-events' ); |
|
940 | + $rsvp = __('Response pending', 'google-calendar-events'); |
|
941 | 941 | } |
942 | 942 | |
943 | - return ' <small>(' . $rsvp . ')</small>'; |
|
943 | + return ' <small>('.$rsvp.')</small>'; |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | /** |
@@ -954,21 +954,21 @@ discard block |
||
954 | 954 | * |
955 | 955 | * @return string |
956 | 956 | */ |
957 | - private function get_organizer( $organizer, $attr ) { |
|
957 | + private function get_organizer($organizer, $attr) { |
|
958 | 958 | |
959 | - $attr = array_merge( array( |
|
960 | - 'photo' => 'show', // show/hide attendee photo |
|
961 | - 'email' => 'hide', // show/hide attendee email address |
|
962 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
959 | + $attr = array_merge(array( |
|
960 | + 'photo' => 'show', // show/hide attendee photo |
|
961 | + 'email' => 'hide', // show/hide attendee email address |
|
962 | + ), (array) shortcode_parse_atts($attr)); |
|
963 | 963 | |
964 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $organizer['photo'] . '" itemprop="image" />' : ''; |
|
965 | - $organizer_html = $photo . '<span itemprop="name">' . $organizer['name'] . '</span>'; |
|
964 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$organizer['photo'].'" itemprop="image" />' : ''; |
|
965 | + $organizer_html = $photo.'<span itemprop="name">'.$organizer['name'].'</span>'; |
|
966 | 966 | |
967 | - if ( ! empty( $organizer['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
968 | - $organizer_html = sprintf( '<a href="mailto:' . $organizer['email'] . '" itemprop="email">%s</a>', $organizer_html ); |
|
967 | + if ( ! empty($organizer['email']) && ('show' == $attr['email'])) { |
|
968 | + $organizer_html = sprintf('<a href="mailto:'.$organizer['email'].'" itemprop="email">%s</a>', $organizer_html); |
|
969 | 969 | } |
970 | 970 | |
971 | - return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">' . $organizer_html . '</div>'; |
|
971 | + return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">'.$organizer_html.'</div>'; |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | /** |
@@ -993,38 +993,38 @@ discard block |
||
993 | 993 | // This is largely borrowed on get_shortcode_regex() from WordPress Core. |
994 | 994 | // @see /wp-includes/shortcodes.php (with some modification) |
995 | 995 | |
996 | - $tagregexp = implode( '|', array_values( $this->tags ) ); |
|
996 | + $tagregexp = implode('|', array_values($this->tags)); |
|
997 | 997 | |
998 | - return '/' . '\\[' // Opening bracket |
|
998 | + return '/'.'\\[' // Opening bracket |
|
999 | 999 | . '(\\[?)' // 1: Optional second opening bracket for escaping tags: [[tag]] |
1000 | 1000 | . "($tagregexp)" // 2: Tag name |
1001 | 1001 | . '(?![\\w-])' // Not followed by word character or hyphen |
1002 | 1002 | . '(' // 3: Unroll the loop: Inside the opening tag |
1003 | 1003 | . '[^\\]\\/]*' // Not a closing bracket or forward slash |
1004 | - . '(?:' . '\\/(?!\\])' // A forward slash not followed by a closing bracket |
|
1004 | + . '(?:'.'\\/(?!\\])' // A forward slash not followed by a closing bracket |
|
1005 | 1005 | . '[^\\]\\/]*' // Not a closing bracket or forward slash |
1006 | - . ')*?' . ')' . '(?:' . '(\\/)' // 4: Self closing tag ... |
|
1006 | + . ')*?'.')'.'(?:'.'(\\/)' // 4: Self closing tag ... |
|
1007 | 1007 | . '\\]' // ... and closing bracket |
1008 | - . '|' . '\\]' // Closing bracket |
|
1009 | - . '(?:' . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing tags |
|
1008 | + . '|'.'\\]' // Closing bracket |
|
1009 | + . '(?:'.'(' // 5: Unroll the loop: Optionally, anything between the opening and closing tags |
|
1010 | 1010 | . '[^\\[]*+' // Not an opening bracket |
1011 | - . '(?:' . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag |
|
1011 | + . '(?:'.'\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag |
|
1012 | 1012 | . '[^\\[]*+' // Not an opening bracket |
1013 | - . ')*+' . ')' . '\\[\\/\\2\\]' // Closing tag |
|
1014 | - . ')?' . ')' . '(\\]?)' // 6: Optional second closing bracket for escaping tags: [[tag]] |
|
1013 | + . ')*+'.')'.'\\[\\/\\2\\]' // Closing tag |
|
1014 | + . ')?'.')'.'(\\]?)' // 6: Optional second closing bracket for escaping tags: [[tag]] |
|
1015 | 1015 | . '/s'; |
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | //allow other plugins to register own event tags |
1019 | 1019 | private function add_custom_event_tags() { |
1020 | - $array = apply_filters( 'simcal_event_tags_add_custom', array() ); |
|
1020 | + $array = apply_filters('simcal_event_tags_add_custom', array()); |
|
1021 | 1021 | |
1022 | 1022 | return $array; |
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | //allow other plugins to replace own (registered) event tags with their value |
1026 | - private function do_custom_event_tag( $tag, $partial, $attr, $event ) { |
|
1027 | - $returnvalue = apply_filters( 'simcal_event_tags_do_custom', "", $tag, $partial, $attr, $event ); |
|
1026 | + private function do_custom_event_tag($tag, $partial, $attr, $event) { |
|
1027 | + $returnvalue = apply_filters('simcal_event_tags_do_custom', "", $tag, $partial, $attr, $event); |
|
1028 | 1028 | |
1029 | 1029 | return $returnvalue; |
1030 | 1030 | } |
@@ -11,7 +11,7 @@ discard block |
||
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 |
||
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 |
||
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 | 266 | $this->set_start(); |
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,24 +444,24 @@ discard block |
||
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 | 451 | |
452 | 452 | // TODO: Removed wpautop() call. |
453 | 453 | |
454 | - $event_formatting = get_post_meta( $this->id, '_event_formatting', true ); |
|
454 | + $event_formatting = get_post_meta($this->id, '_event_formatting', true); |
|
455 | 455 | |
456 | - switch( $event_formatting ) { |
|
456 | + switch ($event_formatting) { |
|
457 | 457 | case 'none': |
458 | - $this->events_template = wp_kses_post( trim( $template ) ); |
|
458 | + $this->events_template = wp_kses_post(trim($template)); |
|
459 | 459 | break; |
460 | 460 | case 'no_linebreaks': |
461 | - $this->events_template = wpautop( wp_kses_post( trim( $template ) ), false ); |
|
461 | + $this->events_template = wpautop(wp_kses_post(trim($template)), false); |
|
462 | 462 | break; |
463 | 463 | default: |
464 | - $this->events_template = wpautop( wp_kses_post( trim( $template ) ), true ); |
|
464 | + $this->events_template = wpautop(wp_kses_post(trim($template)), true); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | //$this->events_template = wpautop( wp_kses_post( trim( $template ) ), true ); |
@@ -474,37 +474,37 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @param string $tz Timezone. |
476 | 476 | */ |
477 | - public function set_timezone( $tz = '' ) { |
|
477 | + public function set_timezone($tz = '') { |
|
478 | 478 | |
479 | - $site_tz = esc_attr( simcal_get_wp_timezone() ); |
|
479 | + $site_tz = esc_attr(simcal_get_wp_timezone()); |
|
480 | 480 | |
481 | - if ( $this->feed === 'grouped-calendars' ) { |
|
481 | + if ($this->feed === 'grouped-calendars') { |
|
482 | 482 | $this->timezone = $site_tz; |
483 | 483 | return; |
484 | 484 | } |
485 | 485 | |
486 | - if ( empty( $tz ) ) { |
|
486 | + if (empty($tz)) { |
|
487 | 487 | |
488 | - $timezone_setting = get_post_meta( $this->id, '_feed_timezone_setting', true ); |
|
488 | + $timezone_setting = get_post_meta($this->id, '_feed_timezone_setting', true); |
|
489 | 489 | |
490 | - if ( 'use_site' == $timezone_setting ) { |
|
490 | + if ('use_site' == $timezone_setting) { |
|
491 | 491 | $tz = $site_tz; |
492 | - } elseif ( 'use_custom' == $timezone_setting ) { |
|
493 | - $custom_timezone = esc_attr( get_post_meta( $this->id, '_feed_timezone', true ) ); |
|
492 | + } elseif ('use_custom' == $timezone_setting) { |
|
493 | + $custom_timezone = esc_attr(get_post_meta($this->id, '_feed_timezone', true)); |
|
494 | 494 | // One may be using a non standard timezone in GMT (UTC) offset format. |
495 | - if ( ( strpos( $custom_timezone, 'UTC+' ) === 0 ) || ( strpos( $custom_timezone, 'UTC-' ) === 0 ) ) { |
|
496 | - $tz = simcal_get_timezone_from_gmt_offset( substr( $custom_timezone, 3 ) ); |
|
495 | + if ((strpos($custom_timezone, 'UTC+') === 0) || (strpos($custom_timezone, 'UTC-') === 0)) { |
|
496 | + $tz = simcal_get_timezone_from_gmt_offset(substr($custom_timezone, 3)); |
|
497 | 497 | } else { |
498 | - $tz = ! empty( $custom_timezone ) ? $custom_timezone : 'UTC'; |
|
498 | + $tz = ! empty($custom_timezone) ? $custom_timezone : 'UTC'; |
|
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | - $this->timezone = empty( $tz ) ? 'UTC' : $tz; |
|
502 | + $this->timezone = empty($tz) ? 'UTC' : $tz; |
|
503 | 503 | return; |
504 | 504 | } |
505 | 505 | |
506 | 506 | $this->site_timezone = $site_tz; |
507 | - $this->timezone = simcal_esc_timezone( $tz, $this->timezone ); |
|
507 | + $this->timezone = simcal_esc_timezone($tz, $this->timezone); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -514,20 +514,20 @@ discard block |
||
514 | 514 | * |
515 | 515 | * @param string $format PHP datetime format. |
516 | 516 | */ |
517 | - public function set_date_format( $format = '' ) { |
|
517 | + public function set_date_format($format = '') { |
|
518 | 518 | |
519 | 519 | $date_format_custom = $date_format_default = $format; |
520 | 520 | |
521 | - if ( empty( $date_format_custom ) ) { |
|
521 | + if (empty($date_format_custom)) { |
|
522 | 522 | |
523 | - $date_format_option = esc_attr( get_post_meta( $this->id, '_calendar_date_format_setting', true ) ); |
|
524 | - $date_format_default = esc_attr( get_option( 'date_format' ) ); |
|
523 | + $date_format_option = esc_attr(get_post_meta($this->id, '_calendar_date_format_setting', true)); |
|
524 | + $date_format_default = esc_attr(get_option('date_format')); |
|
525 | 525 | $date_format_custom = ''; |
526 | 526 | |
527 | - if ( 'use_custom' == $date_format_option ) { |
|
528 | - $date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format', true ) ); |
|
529 | - } elseif ( 'use_custom_php' == $date_format_option ) { |
|
530 | - $date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format_php', true ) ); |
|
527 | + if ('use_custom' == $date_format_option) { |
|
528 | + $date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format', true)); |
|
529 | + } elseif ('use_custom_php' == $date_format_option) { |
|
530 | + $date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format_php', true)); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
@@ -541,20 +541,20 @@ discard block |
||
541 | 541 | * |
542 | 542 | * @param string $format PHP datetime format. |
543 | 543 | */ |
544 | - public function set_time_format( $format = '' ) { |
|
544 | + public function set_time_format($format = '') { |
|
545 | 545 | |
546 | 546 | $time_format_custom = $time_format_default = $format; |
547 | 547 | |
548 | - if ( empty( $time_format_custom ) ) { |
|
548 | + if (empty($time_format_custom)) { |
|
549 | 549 | |
550 | - $time_format_option = esc_attr( get_post_meta( $this->id, '_calendar_time_format_setting', true ) ); |
|
551 | - $time_format_default = esc_attr( get_option( 'time_format' ) ); |
|
550 | + $time_format_option = esc_attr(get_post_meta($this->id, '_calendar_time_format_setting', true)); |
|
551 | + $time_format_default = esc_attr(get_option('time_format')); |
|
552 | 552 | $time_format_custom = ''; |
553 | 553 | |
554 | - if ( 'use_custom' == $time_format_option ) { |
|
555 | - $time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format', true ) ); |
|
556 | - } elseif ( 'use_custom_php' == $time_format_option ) { |
|
557 | - $time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format_php', true ) ); |
|
554 | + if ('use_custom' == $time_format_option) { |
|
555 | + $time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format', true)); |
|
556 | + } elseif ('use_custom_php' == $time_format_option) { |
|
557 | + $time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format_php', true)); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
@@ -568,13 +568,13 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @param string $separator A UTF8 character used as separator. |
570 | 570 | */ |
571 | - public function set_datetime_separator( $separator = '' ) { |
|
571 | + public function set_datetime_separator($separator = '') { |
|
572 | 572 | |
573 | - if ( empty( $separator ) ) { |
|
574 | - $separator = get_post_meta( $this->id, '_calendar_datetime_separator', true ); |
|
573 | + if (empty($separator)) { |
|
574 | + $separator = get_post_meta($this->id, '_calendar_datetime_separator', true); |
|
575 | 575 | } |
576 | 576 | |
577 | - $this->datetime_separator = esc_attr( $separator ); |
|
577 | + $this->datetime_separator = esc_attr($separator); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | /** |
@@ -584,18 +584,18 @@ discard block |
||
584 | 584 | * |
585 | 585 | * @param int $weekday From 0 (Sunday) to 6 (Friday). |
586 | 586 | */ |
587 | - public function set_start_of_week( $weekday = -1 ) { |
|
587 | + public function set_start_of_week($weekday = -1) { |
|
588 | 588 | |
589 | - $week_starts = is_int( $weekday ) ? $weekday : -1; |
|
589 | + $week_starts = is_int($weekday) ? $weekday : -1; |
|
590 | 590 | |
591 | - if ( $week_starts < 0 || $week_starts > 6 ) { |
|
591 | + if ($week_starts < 0 || $week_starts > 6) { |
|
592 | 592 | |
593 | - $week_starts_setting = get_post_meta( $this->id, '_calendar_week_starts_on_setting', true ); |
|
594 | - $week_starts = intval( get_option( 'start_of_week' ) ); |
|
593 | + $week_starts_setting = get_post_meta($this->id, '_calendar_week_starts_on_setting', true); |
|
594 | + $week_starts = intval(get_option('start_of_week')); |
|
595 | 595 | |
596 | - if ( 'use_custom' == $week_starts_setting ) { |
|
597 | - $week_starts_on = get_post_meta( $this->id, '_calendar_week_starts_on', true ); |
|
598 | - $week_starts = is_numeric( $week_starts_on ) ? intval( $week_starts_on ) : $week_starts; |
|
596 | + if ('use_custom' == $week_starts_setting) { |
|
597 | + $week_starts_on = get_post_meta($this->id, '_calendar_week_starts_on', true); |
|
598 | + $week_starts = is_numeric($week_starts_on) ? intval($week_starts_on) : $week_starts; |
|
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
@@ -609,55 +609,55 @@ discard block |
||
609 | 609 | * |
610 | 610 | * @param int $timestamp |
611 | 611 | */ |
612 | - public function set_start( $timestamp = 0 ) { |
|
612 | + public function set_start($timestamp = 0) { |
|
613 | 613 | |
614 | - if ( is_int( $timestamp ) && $timestamp !== 0 ) { |
|
614 | + if (is_int($timestamp) && $timestamp !== 0) { |
|
615 | 615 | $this->start = $timestamp; |
616 | 616 | return; |
617 | 617 | } |
618 | 618 | |
619 | - $start_dt = Carbon::now( $this->timezone ); |
|
619 | + $start_dt = Carbon::now($this->timezone); |
|
620 | 620 | |
621 | - $calendar_begins = esc_attr( get_post_meta( $this->id, '_calendar_begins', true ) ); |
|
622 | - $nth = max( absint( get_post_meta( $this->id, '_calendar_begins_nth', true ) ), 1 ); |
|
621 | + $calendar_begins = esc_attr(get_post_meta($this->id, '_calendar_begins', true)); |
|
622 | + $nth = max(absint(get_post_meta($this->id, '_calendar_begins_nth', true)), 1); |
|
623 | 623 | |
624 | 624 | // Start date/time is sometimes 1 hour too early, which puts in the previous month. |
625 | 625 | // Maybe due to daylight savings changes in different timezones? |
626 | 626 | // Adding 1 hour is hackish, but fixes this. |
627 | 627 | |
628 | - if ( 'today' == $calendar_begins ) { |
|
629 | - $start_dt = Carbon::today( $this->timezone )->addHour(); |
|
630 | - } elseif ( 'days_before' == $calendar_begins ) { |
|
631 | - $start_dt = Carbon::today( $this->timezone )->subDays( $nth )->addHour(); |
|
632 | - } elseif ( 'days_after' == $calendar_begins ) { |
|
633 | - $start_dt = Carbon::today( $this->timezone )->addDays( $nth )->addHour(); |
|
634 | - } elseif ( 'this_week' == $calendar_begins ) { |
|
635 | - $week = new Carbon( 'now', $this->timezone ); |
|
636 | - $week->setWeekStartsAt( $this->week_starts ); |
|
628 | + if ('today' == $calendar_begins) { |
|
629 | + $start_dt = Carbon::today($this->timezone)->addHour(); |
|
630 | + } elseif ('days_before' == $calendar_begins) { |
|
631 | + $start_dt = Carbon::today($this->timezone)->subDays($nth)->addHour(); |
|
632 | + } elseif ('days_after' == $calendar_begins) { |
|
633 | + $start_dt = Carbon::today($this->timezone)->addDays($nth)->addHour(); |
|
634 | + } elseif ('this_week' == $calendar_begins) { |
|
635 | + $week = new Carbon('now', $this->timezone); |
|
636 | + $week->setWeekStartsAt($this->week_starts); |
|
637 | 637 | $start_dt = $week->startOfWeek()->addHour(); |
638 | - } elseif ( 'weeks_before' == $calendar_begins ) { |
|
639 | - $week = new Carbon( 'now', $this->timezone ); |
|
640 | - $week->setWeekStartsAt( $this->week_starts ); |
|
641 | - $start_dt = $week->startOfWeek()->subWeeks( $nth )->addHour(); |
|
642 | - } elseif ( 'weeks_after' == $calendar_begins ) { |
|
643 | - $week = new Carbon( 'now', $this->timezone ); |
|
644 | - $week->setWeekStartsAt( $this->week_starts ); |
|
645 | - $start_dt = $week->startOfWeek()->addWeeks( $nth )->addHour(); |
|
646 | - } elseif ( 'this_month' == $calendar_begins ) { |
|
647 | - $start_dt = Carbon::today( $this->timezone )->startOfMonth()->addHour(); |
|
648 | - } elseif ( 'months_before' == $calendar_begins ) { |
|
649 | - $start_dt = Carbon::today( $this->timezone )->subMonths( $nth )->startOfMonth()->addHour(); |
|
650 | - } elseif ( 'months_after' == $calendar_begins ) { |
|
651 | - $start_dt = Carbon::today( $this->timezone )->addMonths( $nth )->startOfMonth()->addHour(); |
|
652 | - } elseif ( 'this_year' == $calendar_begins ) { |
|
653 | - $start_dt = Carbon::today( $this->timezone )->startOfYear()->addHour(); |
|
654 | - } elseif ( 'years_before' == $calendar_begins ) { |
|
655 | - $start_dt = Carbon::today( $this->timezone )->subYears( $nth )->startOfYear()->addHour(); |
|
656 | - } elseif ( 'years_after' == $calendar_begins ) { |
|
657 | - $start_dt = Carbon::today( $this->timezone )->addYears( $nth )->startOfYear()->addHour(); |
|
658 | - } elseif ( 'custom_date' == $calendar_begins ) { |
|
659 | - if ( $date = get_post_meta( $this->id, '_calendar_begins_custom_date', true ) ) { |
|
660 | - $start_dt = Carbon::createFromFormat( 'Y-m-d', esc_attr( $date ), $this->timezone )->setTimezone( $this->timezone )->startOfDay()->addHour(); |
|
638 | + } elseif ('weeks_before' == $calendar_begins) { |
|
639 | + $week = new Carbon('now', $this->timezone); |
|
640 | + $week->setWeekStartsAt($this->week_starts); |
|
641 | + $start_dt = $week->startOfWeek()->subWeeks($nth)->addHour(); |
|
642 | + } elseif ('weeks_after' == $calendar_begins) { |
|
643 | + $week = new Carbon('now', $this->timezone); |
|
644 | + $week->setWeekStartsAt($this->week_starts); |
|
645 | + $start_dt = $week->startOfWeek()->addWeeks($nth)->addHour(); |
|
646 | + } elseif ('this_month' == $calendar_begins) { |
|
647 | + $start_dt = Carbon::today($this->timezone)->startOfMonth()->addHour(); |
|
648 | + } elseif ('months_before' == $calendar_begins) { |
|
649 | + $start_dt = Carbon::today($this->timezone)->subMonths($nth)->startOfMonth()->addHour(); |
|
650 | + } elseif ('months_after' == $calendar_begins) { |
|
651 | + $start_dt = Carbon::today($this->timezone)->addMonths($nth)->startOfMonth()->addHour(); |
|
652 | + } elseif ('this_year' == $calendar_begins) { |
|
653 | + $start_dt = Carbon::today($this->timezone)->startOfYear()->addHour(); |
|
654 | + } elseif ('years_before' == $calendar_begins) { |
|
655 | + $start_dt = Carbon::today($this->timezone)->subYears($nth)->startOfYear()->addHour(); |
|
656 | + } elseif ('years_after' == $calendar_begins) { |
|
657 | + $start_dt = Carbon::today($this->timezone)->addYears($nth)->startOfYear()->addHour(); |
|
658 | + } elseif ('custom_date' == $calendar_begins) { |
|
659 | + if ($date = get_post_meta($this->id, '_calendar_begins_custom_date', true)) { |
|
660 | + $start_dt = Carbon::createFromFormat('Y-m-d', esc_attr($date), $this->timezone)->setTimezone($this->timezone)->startOfDay()->addHour(); |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 | |
@@ -671,8 +671,8 @@ discard block |
||
671 | 671 | * |
672 | 672 | * @param int $timestamp |
673 | 673 | */ |
674 | - public function set_end( $timestamp = 0 ) { |
|
675 | - $latest = is_int( $timestamp ) && $timestamp !== 0 ? $timestamp : $this->latest_event; |
|
674 | + public function set_end($timestamp = 0) { |
|
675 | + $latest = is_int($timestamp) && $timestamp !== 0 ? $timestamp : $this->latest_event; |
|
676 | 676 | $this->end = $latest > $this->start ? $latest : $this->start; |
677 | 677 | } |
678 | 678 | |
@@ -683,14 +683,14 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @param string|bool $static |
685 | 685 | */ |
686 | - public function set_static( $static = '' ) { |
|
686 | + public function set_static($static = '') { |
|
687 | 687 | |
688 | - if ( ! empty( $static ) && is_bool( $static ) ) { |
|
688 | + if ( ! empty($static) && is_bool($static)) { |
|
689 | 689 | $this->static = $static; |
690 | 690 | return; |
691 | 691 | } |
692 | 692 | |
693 | - if ( 'yes' == get_post_meta( $this->id, '_calendar_is_static', true ) ) { |
|
693 | + if ('yes' == get_post_meta($this->id, '_calendar_is_static', true)) { |
|
694 | 694 | $this->static = true; |
695 | 695 | return; |
696 | 696 | } |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | * |
719 | 719 | * @return Calendar_View |
720 | 720 | */ |
721 | - abstract public function get_view( $view = '' ); |
|
721 | + abstract public function get_view($view = ''); |
|
722 | 722 | |
723 | 723 | /** |
724 | 724 | * Get event HTML parsed by template. |
@@ -730,11 +730,11 @@ discard block |
||
730 | 730 | * |
731 | 731 | * @return string |
732 | 732 | */ |
733 | - public function get_event_html( Event $event, $template = '' ) { |
|
734 | - $event_builder = new Event_Builder( $event, $this ); |
|
733 | + public function get_event_html(Event $event, $template = '') { |
|
734 | + $event_builder = new Event_Builder($event, $this); |
|
735 | 735 | // Use the event template to parse tags; if empty, fallback to calendar post content. |
736 | - $template = empty( $template ) ? ( empty( $event->template ) ? $this->events_template : $event->template ) : $template; |
|
737 | - return $event_builder->parse_event_template_tags( $template ); |
|
736 | + $template = empty($template) ? (empty($event->template) ? $this->events_template : $event->template) : $template; |
|
737 | + return $event_builder->parse_event_template_tags($template); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | /** |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | * |
747 | 747 | * @return string |
748 | 748 | */ |
749 | - public function get_add_to_gcal_url( Event $event ) { |
|
749 | + public function get_add_to_gcal_url(Event $event) { |
|
750 | 750 | $base_url = 'https://calendar.google.com/calendar/render'; |
751 | 751 | // Was https://www.google.com/calendar/render |
752 | 752 | |
@@ -754,30 +754,30 @@ discard block |
||
754 | 754 | // &dates=20160504T110000/20160504T170000 |
755 | 755 | // No "Z"s tacked on to preserve source timezone. |
756 | 756 | // All day events remove time component, but need to add a full day to show up correctly. |
757 | - $is_all_day = ( true == $event->whole_day ); |
|
757 | + $is_all_day = (true == $event->whole_day); |
|
758 | 758 | $gcal_dt_format = $is_all_day ? 'Ymd' : 'Ymd\THi00'; |
759 | - $gcal_begin_dt = $event->start_dt->format( $gcal_dt_format ); |
|
759 | + $gcal_begin_dt = $event->start_dt->format($gcal_dt_format); |
|
760 | 760 | $end_dt_raw = $is_all_day ? $event->end_dt->addDay() : $event->end_dt; |
761 | - $gcal_end_dt = $end_dt_raw->format( $gcal_dt_format ); |
|
762 | - $gcal_dt_string = $gcal_begin_dt . '/' . $gcal_end_dt; |
|
761 | + $gcal_end_dt = $end_dt_raw->format($gcal_dt_format); |
|
762 | + $gcal_dt_string = $gcal_begin_dt.'/'.$gcal_end_dt; |
|
763 | 763 | |
764 | 764 | // "details" (description) should work even when blank. |
765 | 765 | // "location" (address) should work with an address, just a name or blank. |
766 | 766 | $params = array( |
767 | 767 | 'action' => 'TEMPLATE', |
768 | - 'text' => urlencode( strip_tags( $event->title ) ), |
|
768 | + 'text' => urlencode(strip_tags($event->title)), |
|
769 | 769 | 'dates' => $gcal_dt_string, |
770 | - 'details' => urlencode( $event->description ), |
|
771 | - 'location' => urlencode( $event->start_location['address'] ), |
|
770 | + 'details' => urlencode($event->description), |
|
771 | + 'location' => urlencode($event->start_location['address']), |
|
772 | 772 | 'trp' => 'false', |
773 | 773 | ); |
774 | 774 | |
775 | 775 | // "ctz" (timezone) arg should be included unless all-day OR 'UTC'. |
776 | - if ( ! $is_all_day && ( 'UTC' !== $event->timezone ) ) { |
|
777 | - $params['ctz'] = urlencode( $event->timezone ); |
|
776 | + if ( ! $is_all_day && ('UTC' !== $event->timezone)) { |
|
777 | + $params['ctz'] = urlencode($event->timezone); |
|
778 | 778 | } |
779 | 779 | |
780 | - $url = add_query_arg( $params, $base_url ); |
|
780 | + $url = add_query_arg($params, $base_url); |
|
781 | 781 | |
782 | 782 | return $url; |
783 | 783 | } |
@@ -789,56 +789,56 @@ discard block |
||
789 | 789 | * |
790 | 790 | * @param string $view The calendar view to display. |
791 | 791 | */ |
792 | - public function html( $view = '' ) { |
|
792 | + public function html($view = '') { |
|
793 | 793 | |
794 | - $view = empty( $view ) ? $this->view : $this->get_view( $view ); |
|
794 | + $view = empty($view) ? $this->view : $this->get_view($view); |
|
795 | 795 | |
796 | - if ( $view instanceof Calendar_View ) { |
|
796 | + if ($view instanceof Calendar_View) { |
|
797 | 797 | |
798 | - if ( ! empty( $this->errors ) ) { |
|
798 | + if ( ! empty($this->errors)) { |
|
799 | 799 | |
800 | - if ( current_user_can( 'manage_options' ) ) { |
|
800 | + if (current_user_can('manage_options')) { |
|
801 | 801 | echo '<pre><code>'; |
802 | - foreach ( $this->errors as $error ) { echo $error; } |
|
802 | + foreach ($this->errors as $error) { echo $error; } |
|
803 | 803 | echo '</code></pre>'; |
804 | 804 | } |
805 | 805 | |
806 | 806 | } else { |
807 | 807 | |
808 | 808 | // Get a CSS class from the class name of the calendar view (minus namespace part). |
809 | - $view_name = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( get_class( $view ) ) ) ) ); |
|
810 | - $view_class = substr( $view_name, strrpos( $view_name, '\\' ) + 1 ); |
|
809 | + $view_name = implode('-', array_map('lcfirst', explode('_', strtolower(get_class($view))))); |
|
810 | + $view_class = substr($view_name, strrpos($view_name, '\\') + 1); |
|
811 | 811 | |
812 | - $calendar_class = trim( implode( ' simcal-', apply_filters( 'simcal_calendar_class', array( |
|
812 | + $calendar_class = trim(implode(' simcal-', apply_filters('simcal_calendar_class', array( |
|
813 | 813 | 'simcal-calendar', |
814 | 814 | $this->type, |
815 | 815 | $view_class, |
816 | - ), $this->id ) ) ); |
|
817 | - |
|
818 | - echo '<div class="' . $calendar_class . '" ' |
|
819 | - . 'data-calendar-id="' . $this->id . '" ' |
|
820 | - . 'data-timezone="' . $this->timezone . '" ' |
|
821 | - . 'data-offset="' . $this->offset . '" ' |
|
822 | - . 'data-week-start="' . $this->week_starts . '" ' |
|
823 | - . 'data-calendar-start="' . $this->start .'" ' |
|
824 | - . 'data-calendar-end="' . $this->end . '" ' |
|
825 | - . 'data-events-first="' . $this->earliest_event .'" ' |
|
826 | - . 'data-events-last="' . $this->latest_event . '"' |
|
816 | + ), $this->id))); |
|
817 | + |
|
818 | + echo '<div class="'.$calendar_class.'" ' |
|
819 | + . 'data-calendar-id="'.$this->id.'" ' |
|
820 | + . 'data-timezone="'.$this->timezone.'" ' |
|
821 | + . 'data-offset="'.$this->offset.'" ' |
|
822 | + . 'data-week-start="'.$this->week_starts.'" ' |
|
823 | + . 'data-calendar-start="'.$this->start.'" ' |
|
824 | + . 'data-calendar-end="'.$this->end.'" ' |
|
825 | + . 'data-events-first="'.$this->earliest_event.'" ' |
|
826 | + . 'data-events-last="'.$this->latest_event.'"' |
|
827 | 827 | . '>'; |
828 | 828 | |
829 | - do_action( 'simcal_calendar_html_before', $this->id ); |
|
829 | + do_action('simcal_calendar_html_before', $this->id); |
|
830 | 830 | |
831 | 831 | $view->html(); |
832 | 832 | |
833 | - do_action( 'simcal_calendar_html_after', $this->id ); |
|
833 | + do_action('simcal_calendar_html_after', $this->id); |
|
834 | 834 | |
835 | 835 | //$settings = get_option( 'simple-calendar_settings_calendars' ); |
836 | - $poweredby = get_post_meta( $this->id, '_poweredby', true ); |
|
836 | + $poweredby = get_post_meta($this->id, '_poweredby', true); |
|
837 | 837 | |
838 | - if ( 'yes' == $poweredby ) { |
|
838 | + if ('yes' == $poweredby) { |
|
839 | 839 | $align = is_rtl() ? 'left' : 'right'; |
840 | - echo '<small class="simcal-powered simcal-align-' . $align .'">' . |
|
841 | - sprintf( __( 'Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events' ), simcal_get_url( 'home' ) ) . |
|
840 | + echo '<small class="simcal-powered simcal-align-'.$align.'">'. |
|
841 | + sprintf(__('Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events'), simcal_get_url('home')). |
|
842 | 842 | '</small>'; |
843 | 843 | } |
844 | 844 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Calendars\Admin; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function __construct() { |
26 | 26 | |
27 | - if ( simcal_is_admin_screen() !== false ) { |
|
28 | - add_action( 'simcal_settings_meta_calendar_panel', array( $this, 'add_settings_meta_calendar_panel' ), 10, 1 ); |
|
27 | + if (simcal_is_admin_screen() !== false) { |
|
28 | + add_action('simcal_settings_meta_calendar_panel', array($this, 'add_settings_meta_calendar_panel'), 10, 1); |
|
29 | 29 | } |
30 | - add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 ); |
|
30 | + add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -76,47 +76,47 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @param int $post_id |
78 | 78 | */ |
79 | - public function add_settings_meta_calendar_panel( $post_id ) { |
|
79 | + public function add_settings_meta_calendar_panel($post_id) { |
|
80 | 80 | |
81 | 81 | ?> |
82 | 82 | <table id="default-calendar-settings"> |
83 | 83 | <thead> |
84 | - <tr><th colspan="2"><?php _e( 'Default Calendar', 'google-calendar-events' ); ?></th></tr> |
|
84 | + <tr><th colspan="2"><?php _e('Default Calendar', 'google-calendar-events'); ?></th></tr> |
|
85 | 85 | </thead> |
86 | 86 | <tbody class="simcal-panel-section"> |
87 | 87 | |
88 | 88 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
89 | - <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Event Bubbles', 'google-calendar-events' ); ?></label></th> |
|
89 | + <th><label for="_default_calendar_event_bubbles_action"><?php _e('Event Bubbles', 'google-calendar-events'); ?></label></th> |
|
90 | 90 | <td> |
91 | 91 | <?php |
92 | 92 | |
93 | - $bubbles = get_post_meta( $post_id, '_default_calendar_event_bubble_trigger', true ); |
|
93 | + $bubbles = get_post_meta($post_id, '_default_calendar_event_bubble_trigger', true); |
|
94 | 94 | |
95 | - simcal_print_field( array( |
|
95 | + simcal_print_field(array( |
|
96 | 96 | 'type' => 'radio', |
97 | 97 | 'inline' => 'inline', |
98 | 98 | 'name' => '_default_calendar_event_bubble_trigger', |
99 | 99 | 'id' => '_default_calendar_event_bubble_trigger', |
100 | - 'tooltip' => __( 'Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events' ), |
|
100 | + 'tooltip' => __('Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events'), |
|
101 | 101 | 'value' => $bubbles ? $bubbles : 'hover', |
102 | 102 | 'default' => 'hover', |
103 | 103 | 'options' => array( |
104 | - 'click' => __( 'Click', 'google-calendar-events' ), |
|
105 | - 'hover' => __( 'Hover', 'google-calendar-events' ), |
|
104 | + 'click' => __('Click', 'google-calendar-events'), |
|
105 | + 'hover' => __('Hover', 'google-calendar-events'), |
|
106 | 106 | ), |
107 | - ) ); |
|
107 | + )); |
|
108 | 108 | |
109 | 109 | ?> |
110 | 110 | </td> |
111 | 111 | </tr> |
112 | 112 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
113 | - <th><label for="_default_calendar_trim_titles"><?php _e( 'Trim Event Titles', 'google-calendar-events' ); ?></label></th> |
|
113 | + <th><label for="_default_calendar_trim_titles"><?php _e('Trim Event Titles', 'google-calendar-events'); ?></label></th> |
|
114 | 114 | <td> |
115 | 115 | <?php |
116 | 116 | |
117 | - $trim = get_post_meta( $post_id, '_default_calendar_trim_titles', true ); |
|
117 | + $trim = get_post_meta($post_id, '_default_calendar_trim_titles', true); |
|
118 | 118 | |
119 | - simcal_print_field( array( |
|
119 | + simcal_print_field(array( |
|
120 | 120 | 'type' => 'checkbox', |
121 | 121 | 'name' => '_default_calendar_trim_titles', |
122 | 122 | 'id' => '_default_calendar_trim_titles', |
@@ -127,34 +127,34 @@ discard block |
||
127 | 127 | 'attributes' => array( |
128 | 128 | 'data-show-next-if-value' => 'yes', |
129 | 129 | ), |
130 | - ) ); |
|
130 | + )); |
|
131 | 131 | |
132 | - simcal_print_field( array( |
|
132 | + simcal_print_field(array( |
|
133 | 133 | 'type' => 'standard', |
134 | 134 | 'subtype' => 'number', |
135 | 135 | 'name' => '_default_calendar_trim_titles_chars', |
136 | 136 | 'id' => '_default_calendar_trim_titles_chars', |
137 | - 'tooltip' => __( 'Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events' ), |
|
137 | + 'tooltip' => __('Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events'), |
|
138 | 138 | 'class' => array( |
139 | 139 | 'simcal-field-tiny', |
140 | 140 | ), |
141 | - 'value' => 'yes' == $trim ? strval( max( absint( get_post_meta( $post_id, '_default_calendar_trim_titles_chars', true ) ), 1 ) ) : '20', |
|
141 | + 'value' => 'yes' == $trim ? strval(max(absint(get_post_meta($post_id, '_default_calendar_trim_titles_chars', true)), 1)) : '20', |
|
142 | 142 | 'attributes' => array( |
143 | 143 | 'min' => '1', |
144 | 144 | ), |
145 | - ) ); |
|
145 | + )); |
|
146 | 146 | |
147 | 147 | ?> |
148 | 148 | </td> |
149 | 149 | </tr> |
150 | 150 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
151 | - <th><label for="_default_calendar_list_grouped_span"><?php _e( 'Span', 'google-calendar-events' ); ?></label></th> |
|
151 | + <th><label for="_default_calendar_list_grouped_span"><?php _e('Span', 'google-calendar-events'); ?></label></th> |
|
152 | 152 | <td> |
153 | 153 | <?php |
154 | 154 | |
155 | - $list_span = max( absint( get_post_meta( $post_id, '_default_calendar_list_range_span', true ) ), 1 ); |
|
155 | + $list_span = max(absint(get_post_meta($post_id, '_default_calendar_list_range_span', true)), 1); |
|
156 | 156 | |
157 | - simcal_print_field( array( |
|
157 | + simcal_print_field(array( |
|
158 | 158 | 'type' => 'standard', |
159 | 159 | 'subtype' => 'number', |
160 | 160 | 'name' => '_default_calendar_list_range_span', |
@@ -163,78 +163,78 @@ discard block |
||
163 | 163 | 'simcal-field-tiny', |
164 | 164 | 'simcal-field-inline', |
165 | 165 | ), |
166 | - 'value' => strval( $list_span ), |
|
166 | + 'value' => strval($list_span), |
|
167 | 167 | 'attributes' => array( |
168 | 168 | 'min' => '1', |
169 | 169 | ), |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | |
172 | - $list_type = get_post_meta( $post_id, '_default_calendar_list_range_type', true ); |
|
172 | + $list_type = get_post_meta($post_id, '_default_calendar_list_range_type', true); |
|
173 | 173 | |
174 | - simcal_print_field( array( |
|
174 | + simcal_print_field(array( |
|
175 | 175 | 'type' => 'select', |
176 | 176 | 'name' => '_default_calendar_list_range_type', |
177 | 177 | 'id' => '_default_calendar_list_range_type', |
178 | - 'tooltip' => __( 'Range of events to show on each calendar page.', 'google-calendar-events' ), |
|
178 | + 'tooltip' => __('Range of events to show on each calendar page.', 'google-calendar-events'), |
|
179 | 179 | 'class' => array( |
180 | 180 | 'simcal-field-inline', |
181 | 181 | ), |
182 | 182 | 'value' => $list_type, |
183 | 183 | 'options' => array( |
184 | - 'monthly' => __( 'Month(s)', 'google-calendar-events' ), |
|
185 | - 'weekly' => __( 'Week(s)', 'google-calendar-events' ), |
|
186 | - 'daily' => __( 'Day(s)', 'google-calendar-events' ), |
|
187 | - 'events' => __( 'Event(s)', 'google-calendar-events' ), |
|
184 | + 'monthly' => __('Month(s)', 'google-calendar-events'), |
|
185 | + 'weekly' => __('Week(s)', 'google-calendar-events'), |
|
186 | + 'daily' => __('Day(s)', 'google-calendar-events'), |
|
187 | + 'events' => __('Event(s)', 'google-calendar-events'), |
|
188 | 188 | ), |
189 | - ) ); |
|
189 | + )); |
|
190 | 190 | |
191 | 191 | ?> |
192 | 192 | </td> |
193 | 193 | </tr> |
194 | 194 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
195 | - <th><label for="_default_calendar_list_header"><?php _e( 'Hide Header', 'google-calendar-events' ); ?></label></th> |
|
195 | + <th><label for="_default_calendar_list_header"><?php _e('Hide Header', 'google-calendar-events'); ?></label></th> |
|
196 | 196 | <td> |
197 | 197 | <?php |
198 | 198 | |
199 | - $header = get_post_meta( $post_id, '_default_calendar_list_header', true ); |
|
199 | + $header = get_post_meta($post_id, '_default_calendar_list_header', true); |
|
200 | 200 | |
201 | - simcal_print_field( array( |
|
201 | + simcal_print_field(array( |
|
202 | 202 | 'type' => 'checkbox', |
203 | 203 | 'name' => '_default_calendar_list_header', |
204 | 204 | 'id' => '_default_calendar_list_header', |
205 | - 'tooltip' => __( 'You can use this to hide the month header for this calendar.', 'google-calendar-events' ), |
|
205 | + 'tooltip' => __('You can use this to hide the month header for this calendar.', 'google-calendar-events'), |
|
206 | 206 | 'value' => 'yes' == $header ? 'yes' : 'no', |
207 | - ) ); |
|
207 | + )); |
|
208 | 208 | |
209 | 209 | ?> |
210 | 210 | </td> |
211 | 211 | </tr> |
212 | 212 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
213 | - <th><label for="_default_calendar_compact_list"><?php _e( 'Compact List', 'google-calendar-events' ); ?></label></th> |
|
213 | + <th><label for="_default_calendar_compact_list"><?php _e('Compact List', 'google-calendar-events'); ?></label></th> |
|
214 | 214 | <td> |
215 | 215 | <?php |
216 | 216 | |
217 | - $compact = get_post_meta( $post_id, '_default_calendar_compact_list', true ); |
|
217 | + $compact = get_post_meta($post_id, '_default_calendar_compact_list', true); |
|
218 | 218 | |
219 | - simcal_print_field( array( |
|
219 | + simcal_print_field(array( |
|
220 | 220 | 'type' => 'checkbox', |
221 | 221 | 'name' => '_default_calendar_compact_list', |
222 | 222 | 'id' => '_default_calendar_compact_list', |
223 | - 'tooltip' => __( 'Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events' ), |
|
223 | + 'tooltip' => __('Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events'), |
|
224 | 224 | 'value' => 'yes' == $compact ? 'yes' : 'no', |
225 | - ) ); |
|
225 | + )); |
|
226 | 226 | |
227 | 227 | ?> |
228 | 228 | </td> |
229 | 229 | </tr> |
230 | 230 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
231 | - <th><label for="_default_calendar_limit_visible_events"><?php _e( 'Limit Visible Events', 'google-calendar-events' ); ?></label></th> |
|
231 | + <th><label for="_default_calendar_limit_visible_events"><?php _e('Limit Visible Events', 'google-calendar-events'); ?></label></th> |
|
232 | 232 | <td> |
233 | 233 | <?php |
234 | 234 | |
235 | - $limit = get_post_meta( $post_id, '_default_calendar_limit_visible_events', true ); |
|
235 | + $limit = get_post_meta($post_id, '_default_calendar_limit_visible_events', true); |
|
236 | 236 | |
237 | - simcal_print_field( array( |
|
237 | + simcal_print_field(array( |
|
238 | 238 | 'type' => 'checkbox', |
239 | 239 | 'name' => '_default_calendar_limit_visible_events', |
240 | 240 | 'id' => '_default_calendar_limit_visible_events', |
@@ -245,17 +245,17 @@ discard block |
||
245 | 245 | 'attributes' => array( |
246 | 246 | 'data-show-next-if-value' => 'yes', |
247 | 247 | ) |
248 | - ) ); |
|
248 | + )); |
|
249 | 249 | |
250 | - $visible_events = absint( get_post_meta( $post_id, '_default_calendar_visible_events', true ) ); |
|
250 | + $visible_events = absint(get_post_meta($post_id, '_default_calendar_visible_events', true)); |
|
251 | 251 | $visible_events = $visible_events > 0 ? $visible_events : 3; |
252 | 252 | |
253 | - simcal_print_field( array( |
|
253 | + simcal_print_field(array( |
|
254 | 254 | 'type' => 'standard', |
255 | 255 | 'subtype' => 'number', |
256 | 256 | 'name' => '_default_calendar_visible_events', |
257 | 257 | 'id' => '_default_calendar_visible_events', |
258 | - 'tooltip' => __( 'Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events' ), |
|
258 | + 'tooltip' => __('Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events'), |
|
259 | 259 | 'class' => array( |
260 | 260 | 'simcal-field-tiny', |
261 | 261 | ), |
@@ -263,39 +263,39 @@ discard block |
||
263 | 263 | 'attributes' => array( |
264 | 264 | 'min' => '1', |
265 | 265 | ) |
266 | - ) ); |
|
266 | + )); |
|
267 | 267 | |
268 | 268 | ?> |
269 | 269 | </td> |
270 | 270 | </tr> |
271 | 271 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
272 | - <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Expand Multi-day Events', 'google-calendar-events' ); ?></label></th> |
|
272 | + <th><label for="_default_calendar_event_bubbles_action"><?php _e('Expand Multi-day Events', 'google-calendar-events'); ?></label></th> |
|
273 | 273 | <td> |
274 | 274 | <?php |
275 | 275 | |
276 | - $post_meta = get_post_meta( $post_id ); |
|
276 | + $post_meta = get_post_meta($post_id); |
|
277 | 277 | |
278 | - if ( ! is_array( $post_meta ) && ! empty( $post_meta ) ) { |
|
278 | + if ( ! is_array($post_meta) && ! empty($post_meta)) { |
|
279 | 279 | $multi_day_value = 'current_day_only'; |
280 | 280 | } else { |
281 | - $multi_day_value = get_post_meta( $post_id, '_default_calendar_expand_multi_day_events', true ); |
|
281 | + $multi_day_value = get_post_meta($post_id, '_default_calendar_expand_multi_day_events', true); |
|
282 | 282 | } |
283 | 283 | |
284 | - simcal_print_field( array( |
|
284 | + simcal_print_field(array( |
|
285 | 285 | 'type' => 'select', |
286 | 286 | 'name' => '_default_calendar_expand_multi_day_events', |
287 | 287 | 'id' => '_default_calendar_expand_multi_day_events', |
288 | - 'tooltip' => __( 'For events spanning multiple days, you can display them on each day of the event, ' . |
|
289 | - 'only on the first day of the event, or on all days of the event, but only up to the current day. ' . |
|
290 | - 'Third option applies to list views only.', 'google-calendar-events' ), |
|
288 | + 'tooltip' => __('For events spanning multiple days, you can display them on each day of the event, '. |
|
289 | + 'only on the first day of the event, or on all days of the event, but only up to the current day. '. |
|
290 | + 'Third option applies to list views only.', 'google-calendar-events'), |
|
291 | 291 | 'value' => $multi_day_value, |
292 | 292 | 'options' => array( |
293 | - 'yes' => __( 'Yes, display on all days of event', 'google-calendar-events' ), |
|
294 | - 'no' => __( 'No, display only on first day of event', 'google-calendar-events' ), |
|
295 | - 'current_day_only' => __( 'No, display on all days of event up to current day (list view only)', 'google-calendar-events' ), |
|
293 | + 'yes' => __('Yes, display on all days of event', 'google-calendar-events'), |
|
294 | + 'no' => __('No, display only on first day of event', 'google-calendar-events'), |
|
295 | + 'current_day_only' => __('No, display on all days of event up to current day (list view only)', 'google-calendar-events'), |
|
296 | 296 | ), |
297 | 297 | 'default' => 'yes', |
298 | - ) ); |
|
298 | + )); |
|
299 | 299 | |
300 | 300 | ?> |
301 | 301 | </td> |
@@ -304,72 +304,72 @@ discard block |
||
304 | 304 | <?php |
305 | 305 | |
306 | 306 | // TODO Defaults repeated here and in process_meta(). Need to consolidate at some point. |
307 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
308 | - $default_theme = isset( $settings['default-calendar']['theme'] ) ? $settings['default-calendar']['theme'] : 'light'; |
|
309 | - $default_today_color = isset( $settings['default-calendar']['today_color'] ) ? $settings['default-calendar']['today_color'] : '#1e73be'; |
|
310 | - $default_days_events_color = isset( $settings['default-calendar']['days_events_color'] ) ? $settings['default-calendar']['days_events_color'] : '#000000'; |
|
307 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
308 | + $default_theme = isset($settings['default-calendar']['theme']) ? $settings['default-calendar']['theme'] : 'light'; |
|
309 | + $default_today_color = isset($settings['default-calendar']['today_color']) ? $settings['default-calendar']['today_color'] : '#1e73be'; |
|
310 | + $default_days_events_color = isset($settings['default-calendar']['days_events_color']) ? $settings['default-calendar']['days_events_color'] : '#000000'; |
|
311 | 311 | |
312 | 312 | ?> |
313 | 313 | <tbody class="simcal-panel-section"> |
314 | 314 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
315 | - <th><label for="_default_calendar_style_theme"><?php _e( 'Theme', 'google-calendar-events' ); ?></label></th> |
|
315 | + <th><label for="_default_calendar_style_theme"><?php _e('Theme', 'google-calendar-events'); ?></label></th> |
|
316 | 316 | <td> |
317 | 317 | <?php |
318 | 318 | |
319 | - $saved = get_post_meta( $post_id, '_default_calendar_style_theme', true ); |
|
319 | + $saved = get_post_meta($post_id, '_default_calendar_style_theme', true); |
|
320 | 320 | $value = ! $saved ? $default_theme : $saved; |
321 | 321 | |
322 | - simcal_print_field( array( |
|
322 | + simcal_print_field(array( |
|
323 | 323 | 'type' => 'select', |
324 | 324 | 'name' => '_default_calendar_style_theme', |
325 | 325 | 'id' => '_default_calendar_style_theme', |
326 | 326 | 'value' => $value, |
327 | - 'tooltip' => __( 'Choose a calendar theme to match your site theme.', 'google-calendar-events' ), |
|
327 | + 'tooltip' => __('Choose a calendar theme to match your site theme.', 'google-calendar-events'), |
|
328 | 328 | 'options' => array( |
329 | - 'light' => __( 'Light', 'google-calendar-events' ), |
|
330 | - 'dark' => __( 'Dark', 'google-calendar-events' ), |
|
329 | + 'light' => __('Light', 'google-calendar-events'), |
|
330 | + 'dark' => __('Dark', 'google-calendar-events'), |
|
331 | 331 | ), |
332 | - ) ); |
|
332 | + )); |
|
333 | 333 | |
334 | 334 | ?> |
335 | 335 | </td> |
336 | 336 | </tr> |
337 | 337 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
338 | - <th><label for="_default_calendar_style_today"><?php _e( 'Today', 'google-calendar-events' ); ?></label></th> |
|
338 | + <th><label for="_default_calendar_style_today"><?php _e('Today', 'google-calendar-events'); ?></label></th> |
|
339 | 339 | <td> |
340 | 340 | <?php |
341 | 341 | |
342 | - $saved = get_post_meta( $post_id, '_default_calendar_style_today', true ); |
|
342 | + $saved = get_post_meta($post_id, '_default_calendar_style_today', true); |
|
343 | 343 | $value = ! $saved ? $default_today_color : $saved; |
344 | 344 | |
345 | - simcal_print_field( array( |
|
345 | + simcal_print_field(array( |
|
346 | 346 | 'type' => 'standard', |
347 | 347 | 'subtype' => 'color-picker', |
348 | 348 | 'name' => '_default_calendar_style_today', |
349 | 349 | 'id' => '_default_calendar_style_today', |
350 | 350 | 'value' => $value, |
351 | - 'tooltip' => __( "This option will set the background color for today's date. It will change the day number background and the border around the current day.", 'google-calendar-events' ), |
|
352 | - ) ); |
|
351 | + 'tooltip' => __("This option will set the background color for today's date. It will change the day number background and the border around the current day.", 'google-calendar-events'), |
|
352 | + )); |
|
353 | 353 | |
354 | 354 | ?> |
355 | 355 | </td> |
356 | 356 | </tr> |
357 | 357 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
358 | - <th><label for="_default_calendar_style_days_events"><?php _e( 'Days with Events', 'google-calendar-events' ); ?></label></th> |
|
358 | + <th><label for="_default_calendar_style_days_events"><?php _e('Days with Events', 'google-calendar-events'); ?></label></th> |
|
359 | 359 | <td> |
360 | 360 | <?php |
361 | 361 | |
362 | - $saved = get_post_meta( $post_id, '_default_calendar_style_days_events', true ); |
|
362 | + $saved = get_post_meta($post_id, '_default_calendar_style_days_events', true); |
|
363 | 363 | $value = ! $saved ? $default_days_events_color : $saved; |
364 | 364 | |
365 | - simcal_print_field( array( |
|
365 | + simcal_print_field(array( |
|
366 | 366 | 'type' => 'standard', |
367 | 367 | 'subtype' => 'color-picker', |
368 | 368 | 'name' => '_default_calendar_style_days_events', |
369 | 369 | 'id' => '_default_calendar_style_days_events', |
370 | 370 | 'value' => $value, |
371 | - 'tooltip' => __( 'This setting will modify the day number background for any days that have events on them.', 'google-calendar-events' ), |
|
372 | - ) ); |
|
371 | + 'tooltip' => __('This setting will modify the day number background for any days that have events on them.', 'google-calendar-events'), |
|
372 | + )); |
|
373 | 373 | |
374 | 374 | ?> |
375 | 375 | </td> |
@@ -391,55 +391,55 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @param int $post_id |
393 | 393 | */ |
394 | - public function process_meta( $post_id ) { |
|
394 | + public function process_meta($post_id) { |
|
395 | 395 | |
396 | 396 | // Theme. |
397 | - $theme = isset( $_POST['_default_calendar_style_theme'] ) ? sanitize_key( $_POST['_default_calendar_style_theme'] ) : 'light'; |
|
398 | - update_post_meta( $post_id, '_default_calendar_style_theme', $theme ); |
|
397 | + $theme = isset($_POST['_default_calendar_style_theme']) ? sanitize_key($_POST['_default_calendar_style_theme']) : 'light'; |
|
398 | + update_post_meta($post_id, '_default_calendar_style_theme', $theme); |
|
399 | 399 | |
400 | 400 | // Today color. |
401 | - $today_color = isset( $_POST['_default_calendar_style_today'] ) ? sanitize_text_field( $_POST['_default_calendar_style_today'] ) : '#1e73be'; |
|
402 | - update_post_meta( $post_id, '_default_calendar_style_today', $today_color ); |
|
401 | + $today_color = isset($_POST['_default_calendar_style_today']) ? sanitize_text_field($_POST['_default_calendar_style_today']) : '#1e73be'; |
|
402 | + update_post_meta($post_id, '_default_calendar_style_today', $today_color); |
|
403 | 403 | |
404 | 404 | // Days with events color. |
405 | - $days_events_color = isset( $_POST['_default_calendar_style_days_events'] ) ? sanitize_text_field( $_POST['_default_calendar_style_days_events'] ) : '#000000'; |
|
406 | - update_post_meta( $post_id, '_default_calendar_style_days_events', $days_events_color ); |
|
405 | + $days_events_color = isset($_POST['_default_calendar_style_days_events']) ? sanitize_text_field($_POST['_default_calendar_style_days_events']) : '#000000'; |
|
406 | + update_post_meta($post_id, '_default_calendar_style_days_events', $days_events_color); |
|
407 | 407 | |
408 | 408 | // List range span. |
409 | - $span = isset( $_POST['_default_calendar_list_range_span'] ) ? max( absint( $_POST['_default_calendar_list_range_span'] ), 1 ) : 1; |
|
410 | - update_post_meta( $post_id, '_default_calendar_list_range_span', $span ); |
|
409 | + $span = isset($_POST['_default_calendar_list_range_span']) ? max(absint($_POST['_default_calendar_list_range_span']), 1) : 1; |
|
410 | + update_post_meta($post_id, '_default_calendar_list_range_span', $span); |
|
411 | 411 | |
412 | 412 | // List range type. |
413 | - $group = isset( $_POST['_default_calendar_list_range_type'] ) ? sanitize_key( $_POST['_default_calendar_list_range_type'] ) : 'monthly'; |
|
414 | - update_post_meta( $post_id, '_default_calendar_list_range_type', $group ); |
|
413 | + $group = isset($_POST['_default_calendar_list_range_type']) ? sanitize_key($_POST['_default_calendar_list_range_type']) : 'monthly'; |
|
414 | + update_post_meta($post_id, '_default_calendar_list_range_type', $group); |
|
415 | 415 | |
416 | 416 | // Hide header. |
417 | - $header = isset( $_POST['_default_calendar_list_header'] ) ? 'yes' : 'no'; |
|
418 | - update_post_meta( $post_id, '_default_calendar_list_header', $header ); |
|
417 | + $header = isset($_POST['_default_calendar_list_header']) ? 'yes' : 'no'; |
|
418 | + update_post_meta($post_id, '_default_calendar_list_header', $header); |
|
419 | 419 | |
420 | 420 | // Compact list. |
421 | - $compact = isset( $_POST['_default_calendar_compact_list'] ) ? 'yes' : 'no'; |
|
422 | - update_post_meta( $post_id, '_default_calendar_compact_list', $compact ); |
|
421 | + $compact = isset($_POST['_default_calendar_compact_list']) ? 'yes' : 'no'; |
|
422 | + update_post_meta($post_id, '_default_calendar_compact_list', $compact); |
|
423 | 423 | |
424 | 424 | // Limit number of initially visible daily events. |
425 | - $limit = isset( $_POST['_default_calendar_limit_visible_events'] ) ? 'yes' : 'no'; |
|
426 | - update_post_meta( $post_id, '_default_calendar_limit_visible_events', $limit ); |
|
427 | - $number = isset( $_POST['_default_calendar_visible_events'] ) ? absint( $_POST['_default_calendar_visible_events'] ) : 3; |
|
428 | - update_post_meta( $post_id, '_default_calendar_visible_events', $number ); |
|
425 | + $limit = isset($_POST['_default_calendar_limit_visible_events']) ? 'yes' : 'no'; |
|
426 | + update_post_meta($post_id, '_default_calendar_limit_visible_events', $limit); |
|
427 | + $number = isset($_POST['_default_calendar_visible_events']) ? absint($_POST['_default_calendar_visible_events']) : 3; |
|
428 | + update_post_meta($post_id, '_default_calendar_visible_events', $number); |
|
429 | 429 | |
430 | 430 | // Grid event bubbles action. |
431 | - $bubbles = isset( $_POST['_default_calendar_event_bubble_trigger'] ) ? esc_attr( $_POST['_default_calendar_event_bubble_trigger'] ) : 'hover'; |
|
432 | - update_post_meta( $post_id, '_default_calendar_event_bubble_trigger', $bubbles ); |
|
431 | + $bubbles = isset($_POST['_default_calendar_event_bubble_trigger']) ? esc_attr($_POST['_default_calendar_event_bubble_trigger']) : 'hover'; |
|
432 | + update_post_meta($post_id, '_default_calendar_event_bubble_trigger', $bubbles); |
|
433 | 433 | |
434 | 434 | // Trim event titles characters length. |
435 | - $trim = isset( $_POST['_default_calendar_trim_titles'] ) ? 'yes' : 'no'; |
|
436 | - update_post_meta( $post_id, '_default_calendar_trim_titles', $trim ); |
|
437 | - $chars = isset( $_POST['_default_calendar_trim_titles_chars'] ) ? max( absint( $_POST['_default_calendar_trim_titles_chars'] ), 1 ) : 20; |
|
438 | - update_post_meta( $post_id, '_default_calendar_trim_titles_chars', $chars ); |
|
435 | + $trim = isset($_POST['_default_calendar_trim_titles']) ? 'yes' : 'no'; |
|
436 | + update_post_meta($post_id, '_default_calendar_trim_titles', $trim); |
|
437 | + $chars = isset($_POST['_default_calendar_trim_titles_chars']) ? max(absint($_POST['_default_calendar_trim_titles_chars']), 1) : 20; |
|
438 | + update_post_meta($post_id, '_default_calendar_trim_titles_chars', $chars); |
|
439 | 439 | |
440 | 440 | // Expand multiple day events on each day. |
441 | - $multi_day = isset( $_POST['_default_calendar_expand_multi_day_events'] ) && ! empty( $_POST['_default_calendar_expand_multi_day_events'] ) ? sanitize_key( $_POST['_default_calendar_expand_multi_day_events'] ) : 'yes'; |
|
442 | - update_post_meta( $post_id, '_default_calendar_expand_multi_day_events', $multi_day ); |
|
441 | + $multi_day = isset($_POST['_default_calendar_expand_multi_day_events']) && ! empty($_POST['_default_calendar_expand_multi_day_events']) ? sanitize_key($_POST['_default_calendar_expand_multi_day_events']) : 'yes'; |
|
442 | + update_post_meta($post_id, '_default_calendar_expand_multi_day_events', $multi_day); |
|
443 | 443 | |
444 | 444 | } |
445 | 445 |
@@ -13,7 +13,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |