@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | namespace SimpleCalendar\Admin; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | 38 | |
39 | - $this->install = isset( $_GET['simcal_install'] ) ? esc_attr( $_GET['simcal_install'] ) : ''; |
|
39 | + $this->install = isset($_GET['simcal_install']) ? esc_attr($_GET['simcal_install']) : ''; |
|
40 | 40 | |
41 | - add_action( 'admin_menu', array( $this, 'welcome_page_tabs' ) ); |
|
42 | - add_action( 'admin_head', array( $this, 'remove_submenu_pages' ) ); |
|
41 | + add_action('admin_menu', array($this, 'welcome_page_tabs')); |
|
42 | + add_action('admin_head', array($this, 'remove_submenu_pages')); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function welcome_page_tabs() { |
51 | 51 | |
52 | - $welcome_page_name = __( 'About Simple Calendar', 'google-calendar-events' ); |
|
53 | - $welcome_page_title = __( 'Welcome to Simple Calendar', 'google-calendar-events' ); |
|
52 | + $welcome_page_name = __('About Simple Calendar', 'google-calendar-events'); |
|
53 | + $welcome_page_title = __('Welcome to Simple Calendar', 'google-calendar-events'); |
|
54 | 54 | |
55 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : 'simple-calendar_about'; |
|
55 | + $page = isset($_GET['page']) ? $_GET['page'] : 'simple-calendar_about'; |
|
56 | 56 | |
57 | - switch ( $page ) { |
|
57 | + switch ($page) { |
|
58 | 58 | |
59 | 59 | case 'simple-calendar_about' : |
60 | 60 | $page = add_dashboard_page( |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | $welcome_page_name, |
63 | 63 | 'manage_options', |
64 | 64 | 'simple-calendar_about', |
65 | - array( $this, 'about_screen' ) |
|
65 | + array($this, 'about_screen') |
|
66 | 66 | ); |
67 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
67 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
68 | 68 | break; |
69 | 69 | |
70 | 70 | case 'simple-calendar_credits' : |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | $welcome_page_name, |
74 | 74 | 'manage_options', |
75 | 75 | 'simple-calendar_credits', |
76 | - array( $this, 'credits_screen' ) |
|
76 | + array($this, 'credits_screen') |
|
77 | 77 | ); |
78 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
78 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
79 | 79 | break; |
80 | 80 | |
81 | 81 | case 'simple-calendar_translators' : |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | $welcome_page_name, |
85 | 85 | 'manage_options', |
86 | 86 | 'simple-calendar_translators', |
87 | - array( $this, 'translators_screen' ) |
|
87 | + array($this, 'translators_screen') |
|
88 | 88 | ); |
89 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
89 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | * @since 3.0.0 |
99 | 99 | */ |
100 | 100 | public function remove_submenu_pages() { |
101 | - remove_submenu_page( 'index.php', 'simple-calendar_about' ); |
|
102 | - remove_submenu_page( 'index.php', 'simple-calendar_credits' ); |
|
103 | - remove_submenu_page( 'index.php', 'simple-calendar_translators' ); |
|
101 | + remove_submenu_page('index.php', 'simple-calendar_about'); |
|
102 | + remove_submenu_page('index.php', 'simple-calendar_credits'); |
|
103 | + remove_submenu_page('index.php', 'simple-calendar_translators'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | |
130 | 130 | ?> |
131 | 131 | <p> |
132 | - <a href="<?php echo admin_url( 'edit.php?post_type=calendar' ); ?>" |
|
132 | + <a href="<?php echo admin_url('edit.php?post_type=calendar'); ?>" |
|
133 | 133 | class="button button-primary" |
134 | - ><?php _e( 'Calendars', 'google-calendar-events' ); ?></a> |
|
135 | - <a href="<?php echo admin_url( 'admin.php?page=simple-calendar_settings' ); ?>" |
|
134 | + ><?php _e('Calendars', 'google-calendar-events'); ?></a> |
|
135 | + <a href="<?php echo admin_url('admin.php?page=simple-calendar_settings'); ?>" |
|
136 | 136 | class="button button-primary" |
137 | - ><?php _e( 'Settings', 'google-calendar-events' ); ?></a> |
|
138 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'add-ons' ), 'core-plugin', 'welcome-page' ); ?>" |
|
137 | + ><?php _e('Settings', 'google-calendar-events'); ?></a> |
|
138 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('add-ons'), 'core-plugin', 'welcome-page'); ?>" |
|
139 | 139 | class="docs button button-primary" target="_blank" |
140 | - ><?php _e( 'Add-ons', 'google-calendar-events' ); ?></a> |
|
141 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'docs' ), 'core-plugin', 'welcome-page' ); ?>" |
|
140 | + ><?php _e('Add-ons', 'google-calendar-events'); ?></a> |
|
141 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('docs'), 'core-plugin', 'welcome-page'); ?>" |
|
142 | 142 | class="docs button button-primary" target="_blank" |
143 | - ><?php _e( 'Documentation', 'google-calendar-events' ); ?></a> |
|
143 | + ><?php _e('Documentation', 'google-calendar-events'); ?></a> |
|
144 | 144 | </p> |
145 | 145 | <?php |
146 | 146 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | <h1> |
158 | 158 | <?php |
159 | 159 | /* translators: %s prints the current version of the plugin. */ |
160 | - printf( __( 'Welcome to Simple Calendar %s', 'google-calendar-events' ), SIMPLE_CALENDAR_VERSION ); |
|
160 | + printf(__('Welcome to Simple Calendar %s', 'google-calendar-events'), SIMPLE_CALENDAR_VERSION); |
|
161 | 161 | ?> |
162 | 162 | </h1> |
163 | 163 | |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | <?php |
166 | 166 | |
167 | 167 | // Difference message if updating vs fresh install. |
168 | - if ( 'update' == $this->install ) { |
|
169 | - $message = __( 'Thanks for updating to the latest version!', 'google-calendar-events' ); |
|
168 | + if ('update' == $this->install) { |
|
169 | + $message = __('Thanks for updating to the latest version!', 'google-calendar-events'); |
|
170 | 170 | } else { |
171 | - $message = __( 'Thanks for installing!', 'google-calendar-events' ); |
|
171 | + $message = __('Thanks for installing!', 'google-calendar-events'); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | echo $message; |
175 | 175 | |
176 | 176 | /* translators: %s prints the current version of the plugin. */ |
177 | - printf( ' ' . __( "Simple Calendar %s has many new display options and is much easier to configure. We think you'll really enjoy using it.", 'google-calendar-events' ), SIMPLE_CALENDAR_VERSION ); |
|
177 | + printf(' '.__("Simple Calendar %s has many new display options and is much easier to configure. We think you'll really enjoy using it.", 'google-calendar-events'), SIMPLE_CALENDAR_VERSION); |
|
178 | 178 | |
179 | 179 | ?> |
180 | 180 | </div> |
@@ -184,21 +184,21 @@ discard block |
||
184 | 184 | <?php $this->main_nav_links(); ?> |
185 | 185 | |
186 | 186 | <h2 class="nav-tab-wrapper"> |
187 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_about' ) { |
|
187 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_about') { |
|
188 | 188 | echo 'nav-tab-active'; |
189 | 189 | } ?>" |
190 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_about' ), 'index.php' ) ) ); ?>" |
|
191 | - ><?php _e( "What's New", 'google-calendar-events' ); ?></a> |
|
192 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_credits' ) { |
|
190 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_about'), 'index.php'))); ?>" |
|
191 | + ><?php _e("What's New", 'google-calendar-events'); ?></a> |
|
192 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_credits') { |
|
193 | 193 | echo 'nav-tab-active'; |
194 | 194 | } ?>" |
195 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_credits' ), 'index.php' ) ) ); ?>" |
|
196 | - ><?php _e( 'Credits', 'google-calendar-events' ); ?></a> |
|
197 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_translators' ) { |
|
195 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_credits'), 'index.php'))); ?>" |
|
196 | + ><?php _e('Credits', 'google-calendar-events'); ?></a> |
|
197 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_translators') { |
|
198 | 198 | echo 'nav-tab-active'; |
199 | 199 | } ?>" |
200 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_translators' ), 'index.php' ) ) ); ?>" |
|
201 | - ><?php _e( 'Translators', 'google-calendar-events' ); ?></a> |
|
200 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_translators'), 'index.php'))); ?>" |
|
201 | + ><?php _e('Translators', 'google-calendar-events'); ?></a> |
|
202 | 202 | </h2> |
203 | 203 | <?php |
204 | 204 | |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * @since 3.0.0 |
211 | 211 | */ |
212 | 212 | public function about_screen() { |
213 | - $welcome_image_about_path = SIMPLE_CALENDAR_ASSETS . '/images/welcome'; |
|
214 | - $welcome_gcal_pro_link = simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'welcome-page' ); |
|
213 | + $welcome_image_about_path = SIMPLE_CALENDAR_ASSETS.'/images/welcome'; |
|
214 | + $welcome_gcal_pro_link = simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'welcome-page'); |
|
215 | 215 | |
216 | 216 | ?> |
217 | 217 | <div id="simcal-welcome"> |
@@ -219,18 +219,18 @@ discard block |
||
219 | 219 | |
220 | 220 | <?php $this->intro(); ?> |
221 | 221 | |
222 | - <h3><?php _e( 'Modern calendar displays with easily updateable event text and color options.', 'google-calendar-events' ); ?></h3> |
|
223 | - <img src="<?php echo $welcome_image_about_path . '/grid-view-custom-colors.png'; ?>" /> |
|
222 | + <h3><?php _e('Modern calendar displays with easily updateable event text and color options.', 'google-calendar-events'); ?></h3> |
|
223 | + <img src="<?php echo $welcome_image_about_path.'/grid-view-custom-colors.png'; ?>" /> |
|
224 | 224 | |
225 | - <h3><?php _e( 'Mobile responsive and widget ready.', 'google-calendar-events' ); ?></h3> |
|
226 | - <img src="<?php echo $welcome_image_about_path . '/list-view-widget.png'; ?>" /> |
|
227 | - <img src="<?php echo $welcome_image_about_path . '/grid-view-widget-dark-theme.png'; ?>" /> |
|
225 | + <h3><?php _e('Mobile responsive and widget ready.', 'google-calendar-events'); ?></h3> |
|
226 | + <img src="<?php echo $welcome_image_about_path.'/list-view-widget.png'; ?>" /> |
|
227 | + <img src="<?php echo $welcome_image_about_path.'/grid-view-widget-dark-theme.png'; ?>" /> |
|
228 | 228 | |
229 | - <h3><?php _e( 'Simpler, more intuitive calendar settings.', 'google-calendar-events' ); ?></h3> |
|
230 | - <img src="<?php echo $welcome_image_about_path . '/calendar-settings-appearance.png'; ?>" /> |
|
229 | + <h3><?php _e('Simpler, more intuitive calendar settings.', 'google-calendar-events'); ?></h3> |
|
230 | + <img src="<?php echo $welcome_image_about_path.'/calendar-settings-appearance.png'; ?>" /> |
|
231 | 231 | |
232 | - <h3><?php echo sprintf( __( 'Extendible with add-ons like <a href="%s" target="_blank">Google Calendar Pro</a>.', 'google-calendar-events' ), $welcome_gcal_pro_link ); ?></h3> |
|
233 | - <a href="<?php echo $welcome_gcal_pro_link; ?>" target="_blank"><img src="<?php echo $welcome_image_about_path . '/google-calendar-pro-list-view-annotated.png'; ?>" /></a> |
|
232 | + <h3><?php echo sprintf(__('Extendible with add-ons like <a href="%s" target="_blank">Google Calendar Pro</a>.', 'google-calendar-events'), $welcome_gcal_pro_link); ?></h3> |
|
233 | + <a href="<?php echo $welcome_gcal_pro_link; ?>" target="_blank"><img src="<?php echo $welcome_image_about_path.'/google-calendar-pro-list-view-annotated.png'; ?>" /></a> |
|
234 | 234 | |
235 | 235 | <hr/> |
236 | 236 | |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | <?php |
258 | 258 | |
259 | 259 | printf( |
260 | - __( "Simple Calendar is created by a worldwide team of developers. If you'd like to contribute please visit our <a href='%s' target='_blank'>GitHub repo</a>.", 'google-calendar-events' ), |
|
261 | - simcal_get_url( 'github' ) |
|
260 | + __("Simple Calendar is created by a worldwide team of developers. If you'd like to contribute please visit our <a href='%s' target='_blank'>GitHub repo</a>.", 'google-calendar-events'), |
|
261 | + simcal_get_url('github') |
|
262 | 262 | ); |
263 | 263 | |
264 | 264 | ?> |
@@ -282,10 +282,10 @@ discard block |
||
282 | 282 | <div class="wrap about-wrap translators-wrap"> |
283 | 283 | <?php $this->intro(); ?> |
284 | 284 | <p class="about-description"> |
285 | - <?php _e( 'Simple Calendar has been kindly translated into several other languages by contributors from all over the world.', 'google-calendar-events' ); ?> |
|
285 | + <?php _e('Simple Calendar has been kindly translated into several other languages by contributors from all over the world.', 'google-calendar-events'); ?> |
|
286 | 286 | </p> |
287 | 287 | <p class="about-description"> |
288 | - <a href="https://translate.wordpress.org/projects/wp-plugins/google-calendar-events" target="_blank"><?php _e( 'Click here to help translate', 'google-calendar-events' ); ?></a> |
|
288 | + <a href="https://translate.wordpress.org/projects/wp-plugins/google-calendar-events" target="_blank"><?php _e('Click here to help translate', 'google-calendar-events'); ?></a> |
|
289 | 289 | </p> |
290 | 290 | <?php |
291 | 291 | |
@@ -314,31 +314,31 @@ discard block |
||
314 | 314 | |
315 | 315 | $contributors = $this->get_contributors(); |
316 | 316 | |
317 | - if ( empty( $contributors ) ) { |
|
317 | + if (empty($contributors)) { |
|
318 | 318 | return ''; |
319 | 319 | } |
320 | 320 | |
321 | 321 | $contributor_list = '<ul class="wp-people-group">'; |
322 | 322 | |
323 | - foreach ( $contributors as $contributor ) { |
|
323 | + foreach ($contributors as $contributor) { |
|
324 | 324 | |
325 | 325 | // Skip contributor bots |
326 | - $contributor_bots = array( 'gitter-badger' ); |
|
327 | - if ( in_array( $contributor->login, $contributor_bots ) ) { |
|
326 | + $contributor_bots = array('gitter-badger'); |
|
327 | + if (in_array($contributor->login, $contributor_bots)) { |
|
328 | 328 | continue; |
329 | 329 | } |
330 | 330 | |
331 | 331 | $contributor_list .= '<li class="wp-person">'; |
332 | 332 | $contributor_list .= sprintf( |
333 | 333 | '<a href="%s" title="%s" target="_blank">%s</a>', |
334 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
335 | - esc_html( sprintf( __( 'View %s', 'google-calendar-events' ), $contributor->login ) ), |
|
336 | - sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) ) |
|
334 | + esc_url('https://github.com/'.$contributor->login), |
|
335 | + esc_html(sprintf(__('View %s', 'google-calendar-events'), $contributor->login)), |
|
336 | + sprintf('<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url($contributor->avatar_url), esc_html($contributor->login)) |
|
337 | 337 | ); |
338 | 338 | $contributor_list .= sprintf( |
339 | 339 | '<a class="web" href="%s" target="_blank">%s</a>', |
340 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
341 | - esc_html( $contributor->login ) |
|
340 | + esc_url('https://github.com/'.$contributor->login), |
|
341 | + esc_html($contributor->login) |
|
342 | 342 | ); |
343 | 343 | $contributor_list .= '</li>'; |
344 | 344 | |
@@ -358,24 +358,24 @@ discard block |
||
358 | 358 | */ |
359 | 359 | public function get_contributors() { |
360 | 360 | |
361 | - $contributors = get_transient( '_simple-calendar_contributors' ); |
|
362 | - if ( false !== $contributors ) { |
|
361 | + $contributors = get_transient('_simple-calendar_contributors'); |
|
362 | + if (false !== $contributors) { |
|
363 | 363 | return $contributors; |
364 | 364 | } |
365 | 365 | |
366 | 366 | $response = wp_safe_remote_get( |
367 | 367 | 'https://api.github.com/repos/moonstonemedia/Simple-Calendar/contributors' |
368 | 368 | ); |
369 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
369 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
370 | 370 | return array(); |
371 | 371 | } |
372 | 372 | |
373 | - $contributors = json_decode( wp_remote_retrieve_body( $response ) ); |
|
374 | - if ( ! is_array( $contributors ) ) { |
|
373 | + $contributors = json_decode(wp_remote_retrieve_body($response)); |
|
374 | + if ( ! is_array($contributors)) { |
|
375 | 375 | return array(); |
376 | 376 | } |
377 | 377 | |
378 | - set_transient( '_simple-calendar_contributors', $contributors, HOUR_IN_SECONDS ); |
|
378 | + set_transient('_simple-calendar_contributors', $contributors, HOUR_IN_SECONDS); |
|
379 | 379 | |
380 | 380 | return $contributors; |
381 | 381 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Calendar_View; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @since 3.0.0 |
26 | 26 | */ |
27 | 27 | public function __construct() { |
28 | - add_action( 'init', array( $this, 'add_callbacks' ), 100 ); |
|
28 | + add_action('init', array($this, 'add_callbacks'), 100); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | |
38 | 38 | $calendars = simcal_get_calendar_types(); |
39 | 39 | |
40 | - foreach ( $calendars as $calendar => $views ) { |
|
40 | + foreach ($calendars as $calendar => $views) { |
|
41 | 41 | |
42 | - foreach ( $views as $view ) { |
|
42 | + foreach ($views as $view) { |
|
43 | 43 | |
44 | - $the_view = simcal_get_calendar_view( 0, $calendar . '-' . $view ); |
|
44 | + $the_view = simcal_get_calendar_view(0, $calendar.'-'.$view); |
|
45 | 45 | |
46 | - if ( $the_view instanceof Calendar_View ) { |
|
46 | + if ($the_view instanceof Calendar_View) { |
|
47 | 47 | $the_view->add_ajax_actions(); |
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - do_action( 'simcal_add_ajax_callbacks' ); |
|
52 | + do_action('simcal_add_ajax_callbacks'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Calendar_View; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -76,24 +76,24 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function __construct() { |
78 | 78 | |
79 | - $this->min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG == true ) ? '' : '.min'; |
|
79 | + $this->min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG == true) ? '' : '.min'; |
|
80 | 80 | |
81 | - $settings = get_option( 'simple-calendar_settings_advanced' ); |
|
82 | - if ( isset( $settings['assets']['disable_js'] ) ) { |
|
81 | + $settings = get_option('simple-calendar_settings_advanced'); |
|
82 | + if (isset($settings['assets']['disable_js'])) { |
|
83 | 83 | $this->disable_scripts = 'yes' == $settings['assets']['disable_js'] ? true : false; |
84 | 84 | } |
85 | 85 | |
86 | - if ( isset( $settings['assets']['disable_css'] ) ) { |
|
86 | + if (isset($settings['assets']['disable_css'])) { |
|
87 | 87 | $this->disable_styles = 'yes' == $settings['assets']['disable_css'] ? true : false; |
88 | 88 | } |
89 | 89 | |
90 | - if ( isset( $settings['assets']['always_enqueue'] ) ) { |
|
90 | + if (isset($settings['assets']['always_enqueue'])) { |
|
91 | 91 | $this->always_enqueue = 'yes' == $settings['assets']['always_enqueue'] ? true : false; |
92 | 92 | } |
93 | 93 | |
94 | - add_action( 'init', array( $this, 'register' ), 20 ); |
|
95 | - add_action( 'init', array( $this, 'enqueue' ), 40 ); |
|
96 | - add_action( 'wp_print_styles', array( $this, 'disable' ), 100 ); |
|
94 | + add_action('init', array($this, 'register'), 20); |
|
95 | + add_action('init', array($this, 'enqueue'), 40); |
|
96 | + add_action('wp_print_styles', array($this, 'disable'), 100); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @since 3.0.0 |
103 | 103 | */ |
104 | 104 | public function register() { |
105 | - do_action( 'simcal_register_assets', $this->min ); |
|
105 | + do_action('simcal_register_assets', $this->min); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -112,25 +112,25 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function enqueue() { |
114 | 114 | |
115 | - add_action( 'wp_enqueue_scripts', array( $this, 'load' ), 10 ); |
|
115 | + add_action('wp_enqueue_scripts', array($this, 'load'), 10); |
|
116 | 116 | |
117 | - do_action( 'simcal_enqueue_assets', $this->min ); |
|
117 | + do_action('simcal_enqueue_assets', $this->min); |
|
118 | 118 | |
119 | - if ( false === $this->disable_scripts ) { |
|
119 | + if (false === $this->disable_scripts) { |
|
120 | 120 | $min = $this->min; |
121 | 121 | // Improves compatibility with themes and plugins using Isotope and Masonry. |
122 | - add_action( 'wp_enqueue_scripts', |
|
123 | - function () use ( $min ) { |
|
124 | - if ( wp_script_is( 'simcal-qtip', 'enqueued' ) ) { |
|
122 | + add_action('wp_enqueue_scripts', |
|
123 | + function() use ($min) { |
|
124 | + if (wp_script_is('simcal-qtip', 'enqueued')) { |
|
125 | 125 | wp_enqueue_script( |
126 | 126 | 'simplecalendar-imagesloaded', |
127 | - SIMPLE_CALENDAR_ASSETS . 'js/vendor/imagesloaded' . $min . '.js', |
|
128 | - array( 'simcal-qtip' ), |
|
127 | + SIMPLE_CALENDAR_ASSETS.'js/vendor/imagesloaded'.$min.'.js', |
|
128 | + array('simcal-qtip'), |
|
129 | 129 | '3.1.8', |
130 | 130 | true |
131 | 131 | ); |
132 | 132 | } |
133 | - }, 1000 ); |
|
133 | + }, 1000); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -141,15 +141,15 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function load() { |
143 | 143 | |
144 | - if ( $this->always_enqueue ) { |
|
144 | + if ($this->always_enqueue) { |
|
145 | 145 | $scripts = $this->get_default_scripts(); |
146 | 146 | $styles = $this->get_default_styles(); |
147 | 147 | |
148 | - $this->scripts = apply_filters( 'simcal_front_end_scripts', $scripts, $this->min ); |
|
149 | - $this->styles = apply_filters( 'simcal_front_end_styles', $styles, $this->min ); |
|
148 | + $this->scripts = apply_filters('simcal_front_end_scripts', $scripts, $this->min); |
|
149 | + $this->styles = apply_filters('simcal_front_end_styles', $styles, $this->min); |
|
150 | 150 | |
151 | - $this->load_scripts( $this->scripts ); |
|
152 | - $this->load_styles( $this->styles ); |
|
151 | + $this->load_scripts($this->scripts); |
|
152 | + $this->load_styles($this->styles); |
|
153 | 153 | |
154 | 154 | return; |
155 | 155 | } |
@@ -158,33 +158,33 @@ discard block |
||
158 | 158 | $cal_id = array(); |
159 | 159 | $scripts = $styles = array(); |
160 | 160 | |
161 | - if ( is_singular() ) { |
|
161 | + if (is_singular()) { |
|
162 | 162 | |
163 | 163 | global $post, $post_type; |
164 | 164 | |
165 | - if ( 'calendar' == $post_type ) { |
|
165 | + if ('calendar' == $post_type) { |
|
166 | 166 | |
167 | 167 | $id = get_queried_object_id(); |
168 | 168 | |
169 | - $view = simcal_get_calendar_view( $id ); |
|
170 | - if ( $view instanceof Calendar_View ) { |
|
171 | - $scripts[] = $view->scripts( $this->min ); |
|
172 | - $styles[] = $view->styles( $this->min ); |
|
169 | + $view = simcal_get_calendar_view($id); |
|
170 | + if ($view instanceof Calendar_View) { |
|
171 | + $scripts[] = $view->scripts($this->min); |
|
172 | + $styles[] = $view->styles($this->min); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | } else { |
176 | 176 | |
177 | - $id = absint( get_post_meta( $post->ID, '_simcal_attach_calendar_id', true ) ); |
|
177 | + $id = absint(get_post_meta($post->ID, '_simcal_attach_calendar_id', true)); |
|
178 | 178 | |
179 | - if ( $id === 0 ) { |
|
179 | + if ($id === 0) { |
|
180 | 180 | |
181 | - preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER ); |
|
181 | + preg_match_all('/'.get_shortcode_regex().'/s', $post->post_content, $matches, PREG_SET_ORDER); |
|
182 | 182 | |
183 | - if ( ! empty( $matches ) && is_array( $matches ) ) { |
|
184 | - foreach ( $matches as $shortcode ) { |
|
185 | - if ( 'calendar' === $shortcode[2] || 'gcal' === $shortcode[2] ) { |
|
186 | - $atts = shortcode_parse_atts( $shortcode[3] ); |
|
187 | - $cal_id[] = isset( $atts['id'] ) ? intval( $atts['id'] ) : 0; |
|
183 | + if ( ! empty($matches) && is_array($matches)) { |
|
184 | + foreach ($matches as $shortcode) { |
|
185 | + if ('calendar' === $shortcode[2] || 'gcal' === $shortcode[2]) { |
|
186 | + $atts = shortcode_parse_atts($shortcode[3]); |
|
187 | + $cal_id[] = isset($atts['id']) ? intval($atts['id']) : 0; |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |
@@ -192,41 +192,41 @@ discard block |
||
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - foreach( $cal_id as $i ) { |
|
195 | + foreach ($cal_id as $i) { |
|
196 | 196 | |
197 | - if ( $i > 0 ) { |
|
197 | + if ($i > 0) { |
|
198 | 198 | |
199 | - $view = simcal_get_calendar_view( $i ); |
|
199 | + $view = simcal_get_calendar_view($i); |
|
200 | 200 | |
201 | - if ( $view instanceof Calendar_View ) { |
|
202 | - $scripts[] = $view->scripts( $this->min ); |
|
203 | - $styles[] = $view->styles( $this->min ); |
|
201 | + if ($view instanceof Calendar_View) { |
|
202 | + $scripts[] = $view->scripts($this->min); |
|
203 | + $styles[] = $view->styles($this->min); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | 208 | $this->get_widgets_assets(); |
209 | 209 | |
210 | - $this->scripts = apply_filters( 'simcal_front_end_scripts', $scripts, $this->min ); |
|
210 | + $this->scripts = apply_filters('simcal_front_end_scripts', $scripts, $this->min); |
|
211 | 211 | |
212 | 212 | // First check if there is a multi-dimensional array of scripts |
213 | - if ( isset( $this->scripts[0] ) ) { |
|
214 | - foreach ( $this->scripts as $script ) { |
|
215 | - $this->load_scripts ( $script ); |
|
213 | + if (isset($this->scripts[0])) { |
|
214 | + foreach ($this->scripts as $script) { |
|
215 | + $this->load_scripts($script); |
|
216 | 216 | } |
217 | 217 | } else { |
218 | - $this->load_scripts( $this->scripts ); |
|
218 | + $this->load_scripts($this->scripts); |
|
219 | 219 | } |
220 | 220 | |
221 | - $this->styles = apply_filters( 'simcal_front_end_styles', $styles, $this->min ); |
|
221 | + $this->styles = apply_filters('simcal_front_end_styles', $styles, $this->min); |
|
222 | 222 | |
223 | 223 | // First check if there is a multi-dimensional array of styles |
224 | - if ( isset( $this->styles[0] ) ) { |
|
225 | - foreach( $this->styles as $style ) { |
|
226 | - $this->load_styles( $style ); |
|
224 | + if (isset($this->styles[0])) { |
|
225 | + foreach ($this->styles as $style) { |
|
226 | + $this->load_styles($style); |
|
227 | 227 | } |
228 | 228 | } else { |
229 | - $this->load_styles( $this->styles ); |
|
229 | + $this->load_styles($this->styles); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -237,25 +237,25 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function get_widgets_assets() { |
239 | 239 | |
240 | - $widgets = get_option( 'widget_gce_widget' ); |
|
240 | + $widgets = get_option('widget_gce_widget'); |
|
241 | 241 | |
242 | - if ( ! empty( $widgets ) && is_array( $widgets ) ) { |
|
242 | + if ( ! empty($widgets) && is_array($widgets)) { |
|
243 | 243 | |
244 | - foreach ( $widgets as $settings ) { |
|
244 | + foreach ($widgets as $settings) { |
|
245 | 245 | |
246 | - if ( ! empty( $settings ) && is_array( $settings ) ) { |
|
246 | + if ( ! empty($settings) && is_array($settings)) { |
|
247 | 247 | |
248 | - if ( isset( $settings['calendar_id'] ) ) { |
|
248 | + if (isset($settings['calendar_id'])) { |
|
249 | 249 | |
250 | - $view = simcal_get_calendar_view( absint( $settings['calendar_id'] ) ); |
|
250 | + $view = simcal_get_calendar_view(absint($settings['calendar_id'])); |
|
251 | 251 | |
252 | - if ( $view instanceof Calendar_View ) { |
|
253 | - add_filter( 'simcal_front_end_scripts', function ( $scripts, $min ) use ( $view ) { |
|
254 | - return array_merge( $scripts, $view->scripts( $min ) ); |
|
255 | - }, 100, 2 ); |
|
256 | - add_filter( 'simcal_front_end_styles', function ( $styles, $min ) use ( $view ) { |
|
257 | - return array_merge( $styles, $view->styles( $min ) ); |
|
258 | - }, 100, 2 ); |
|
252 | + if ($view instanceof Calendar_View) { |
|
253 | + add_filter('simcal_front_end_scripts', function($scripts, $min) use ($view) { |
|
254 | + return array_merge($scripts, $view->scripts($min)); |
|
255 | + }, 100, 2); |
|
256 | + add_filter('simcal_front_end_styles', function($styles, $min) use ($view) { |
|
257 | + return array_merge($styles, $view->styles($min)); |
|
258 | + }, 100, 2); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | } |
@@ -272,16 +272,16 @@ discard block |
||
272 | 272 | * @since 3.0.0 |
273 | 273 | */ |
274 | 274 | public function disable() { |
275 | - if ( true === $this->disable_scripts ) { |
|
276 | - $scripts = apply_filters( 'simcal_front_end_scripts', $this->scripts, $this->min ); |
|
277 | - foreach ( $scripts as $script => $v ) { |
|
278 | - wp_dequeue_script( $script ); |
|
275 | + if (true === $this->disable_scripts) { |
|
276 | + $scripts = apply_filters('simcal_front_end_scripts', $this->scripts, $this->min); |
|
277 | + foreach ($scripts as $script => $v) { |
|
278 | + wp_dequeue_script($script); |
|
279 | 279 | } |
280 | 280 | } |
281 | - if ( true === $this->disable_styles ) { |
|
282 | - $styles = apply_filters( 'simcal_front_end_styles', $this->styles, $this->min ); |
|
283 | - foreach ( $styles as $style => $v ) { |
|
284 | - wp_dequeue_style( $style ); |
|
281 | + if (true === $this->disable_styles) { |
|
282 | + $styles = apply_filters('simcal_front_end_styles', $this->styles, $this->min); |
|
283 | + foreach ($styles as $style => $v) { |
|
284 | + wp_dequeue_style($style); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | } |
@@ -293,30 +293,30 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @param array $scripts |
295 | 295 | */ |
296 | - public function load_scripts( $scripts ) { |
|
296 | + public function load_scripts($scripts) { |
|
297 | 297 | |
298 | - if ( ! empty( $scripts ) && is_array( $scripts ) ) { |
|
298 | + if ( ! empty($scripts) && is_array($scripts)) { |
|
299 | 299 | |
300 | - foreach ( $scripts as $script => $v ) { |
|
300 | + foreach ($scripts as $script => $v) { |
|
301 | 301 | |
302 | - if ( ! empty( $v['src'] ) ) { |
|
302 | + if ( ! empty($v['src'])) { |
|
303 | 303 | |
304 | - $src = esc_url( $v['src'] ); |
|
305 | - $deps = isset( $v['deps'] ) ? $v['deps'] : array(); |
|
306 | - $ver = isset( $v['ver'] ) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
307 | - $in_footer = isset( $v['in_footer'] ) ? $v['in_footer'] : false; |
|
304 | + $src = esc_url($v['src']); |
|
305 | + $deps = isset($v['deps']) ? $v['deps'] : array(); |
|
306 | + $ver = isset($v['ver']) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
307 | + $in_footer = isset($v['in_footer']) ? $v['in_footer'] : false; |
|
308 | 308 | |
309 | - wp_enqueue_script( $script, $src, $deps, $ver, $in_footer ); |
|
309 | + wp_enqueue_script($script, $src, $deps, $ver, $in_footer); |
|
310 | 310 | |
311 | - if ( ! empty( $v['localize'] ) && is_array( $v['localize'] ) ) { |
|
312 | - foreach ( $v['localize'] as $object => $l10n ) { |
|
313 | - wp_localize_script( $script, $object, $l10n ); |
|
311 | + if ( ! empty($v['localize']) && is_array($v['localize'])) { |
|
312 | + foreach ($v['localize'] as $object => $l10n) { |
|
313 | + wp_localize_script($script, $object, $l10n); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
317 | - } elseif ( is_string( $v ) && ! empty( $v ) ) { |
|
317 | + } elseif (is_string($v) && ! empty($v)) { |
|
318 | 318 | |
319 | - wp_enqueue_script( $v ); |
|
319 | + wp_enqueue_script($v); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
@@ -330,24 +330,24 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @param array $styles |
332 | 332 | */ |
333 | - public function load_styles( $styles ) { |
|
333 | + public function load_styles($styles) { |
|
334 | 334 | |
335 | - if ( ! empty( $styles ) && is_array( $styles ) ) { |
|
335 | + if ( ! empty($styles) && is_array($styles)) { |
|
336 | 336 | |
337 | - foreach ( $styles as $style => $v ) { |
|
337 | + foreach ($styles as $style => $v) { |
|
338 | 338 | |
339 | - if ( ! empty( $v['src'] ) ) { |
|
339 | + if ( ! empty($v['src'])) { |
|
340 | 340 | |
341 | - $src = esc_url( $v['src'] ); |
|
342 | - $deps = isset( $v['deps'] ) ? $v['deps'] : array(); |
|
343 | - $ver = isset( $v['ver'] ) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
344 | - $media = isset( $v['media'] ) ? $v['media'] : 'all'; |
|
341 | + $src = esc_url($v['src']); |
|
342 | + $deps = isset($v['deps']) ? $v['deps'] : array(); |
|
343 | + $ver = isset($v['ver']) ? $v['ver'] : SIMPLE_CALENDAR_VERSION; |
|
344 | + $media = isset($v['media']) ? $v['media'] : 'all'; |
|
345 | 345 | |
346 | - wp_enqueue_style( $style, $src, $deps, $ver, $media ); |
|
346 | + wp_enqueue_style($style, $src, $deps, $ver, $media); |
|
347 | 347 | |
348 | - } elseif ( is_string( $v ) && ! empty( $v ) ) { |
|
348 | + } elseif (is_string($v) && ! empty($v)) { |
|
349 | 349 | |
350 | - wp_enqueue_style( $v ); |
|
350 | + wp_enqueue_style($v); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | } |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | public function get_default_scripts() { |
364 | 364 | return array( |
365 | 365 | 'simcal-qtip' => array( |
366 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $this->min . '.js', |
|
367 | - 'deps' => array( 'jquery' ), |
|
366 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$this->min.'.js', |
|
367 | + 'deps' => array('jquery'), |
|
368 | 368 | 'ver' => '2.2.1', |
369 | 369 | 'in_footer' => true, |
370 | 370 | ), |
371 | 371 | 'simcal-default-calendar' => array( |
372 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $this->min . '.js', |
|
372 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$this->min.'.js', |
|
373 | 373 | 'deps' => array( |
374 | 374 | 'jquery', |
375 | 375 | 'simcal-qtip', |
@@ -391,12 +391,12 @@ discard block |
||
391 | 391 | public function get_default_styles() { |
392 | 392 | return array( |
393 | 393 | 'simcal-qtip' => array( |
394 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/vendor/qtip' . $this->min . '.css', |
|
394 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/vendor/qtip'.$this->min.'.css', |
|
395 | 395 | 'ver' => '2.2.1', |
396 | 396 | 'media' => 'all', |
397 | 397 | ), |
398 | 398 | 'simcal-default-calendar-grid' => array( |
399 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-grid' . $this->min . '.css', |
|
399 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-grid'.$this->min.'.css', |
|
400 | 400 | 'deps' => array( |
401 | 401 | 'simcal-qtip', |
402 | 402 | ), |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | 'media' => 'all', |
405 | 405 | ), |
406 | 406 | 'simcal-default-calendar-list' => array( |
407 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $this->min . '.css', |
|
407 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$this->min.'.css', |
|
408 | 408 | 'deps' => array( |
409 | 409 | 'simcal-qtip', |
410 | 410 | ), |
@@ -5,11 +5,11 @@ discard block |
||
5 | 5 | * @package SimpleCalendar |
6 | 6 | */ |
7 | 7 | |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if ( ! defined('ABSPATH')) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | 11 | |
12 | -if ( ! function_exists( 'SimpleCalendar_Autoload' ) ) { |
|
12 | +if ( ! function_exists('SimpleCalendar_Autoload')) { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Plugin autoloader. |
@@ -22,31 +22,31 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param $class |
24 | 24 | */ |
25 | - function SimpleCalendar_Autoload( $class ) { |
|
25 | + function SimpleCalendar_Autoload($class) { |
|
26 | 26 | |
27 | 27 | // Do not load unless in plugin domain. |
28 | 28 | $namespace = 'SimpleCalendar'; |
29 | - if ( strpos( $class, $namespace ) !== 0 ) { |
|
29 | + if (strpos($class, $namespace) !== 0) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
33 | 33 | // Converts Class_Name (class convention) to class-name (file convention). |
34 | - $class_name = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( $class ) ) ) ); |
|
34 | + $class_name = implode('-', array_map('lcfirst', explode('_', strtolower($class)))); |
|
35 | 35 | |
36 | 36 | // Remove the root namespace. |
37 | - $unprefixed = substr( $class_name, strlen( $namespace ) ); |
|
37 | + $unprefixed = substr($class_name, strlen($namespace)); |
|
38 | 38 | |
39 | 39 | // Build the file path. |
40 | - $file_path = str_replace( '\\', DIRECTORY_SEPARATOR, $unprefixed ); |
|
41 | - $file = dirname( __FILE__ ) . '/' . $file_path . '.php'; |
|
40 | + $file_path = str_replace('\\', DIRECTORY_SEPARATOR, $unprefixed); |
|
41 | + $file = dirname(__FILE__).'/'.$file_path.'.php'; |
|
42 | 42 | |
43 | - if ( file_exists( $file ) ) { |
|
43 | + if (file_exists($file)) { |
|
44 | 44 | require $file; |
45 | 45 | } |
46 | 46 | |
47 | 47 | } |
48 | 48 | |
49 | 49 | // Register the autoloader. |
50 | - spl_autoload_register( 'SimpleCalendar_Autoload' ); |
|
50 | + spl_autoload_register('SimpleCalendar_Autoload'); |
|
51 | 51 | |
52 | 52 | } |
@@ -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,46 +76,46 @@ 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 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
88 | - <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Event bubbles', 'google-calendar-events' ); ?></label></th> |
|
88 | + <th><label for="_default_calendar_event_bubbles_action"><?php _e('Event bubbles', 'google-calendar-events'); ?></label></th> |
|
89 | 89 | <td> |
90 | 90 | <?php |
91 | 91 | |
92 | - $bubbles = get_post_meta( $post_id, '_default_calendar_event_bubble_trigger', true ); |
|
92 | + $bubbles = get_post_meta($post_id, '_default_calendar_event_bubble_trigger', true); |
|
93 | 93 | |
94 | - simcal_print_field( array( |
|
94 | + simcal_print_field(array( |
|
95 | 95 | 'type' => 'radio', |
96 | 96 | 'inline' => 'inline', |
97 | 97 | 'name' => '_default_calendar_event_bubble_trigger', |
98 | 98 | 'id' => '_default_calendar_event_bubble_trigger', |
99 | - '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' ), |
|
99 | + '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 | 100 | 'value' => $bubbles ? $bubbles : 'hover', |
101 | 101 | 'default' => 'hover', |
102 | 102 | 'options' => array( |
103 | - 'click' => __( 'Click', 'google-calendar-events' ), |
|
104 | - 'hover' => __( 'Hover', 'google-calendar-events' ), |
|
103 | + 'click' => __('Click', 'google-calendar-events'), |
|
104 | + 'hover' => __('Hover', 'google-calendar-events'), |
|
105 | 105 | ), |
106 | - ) ); |
|
106 | + )); |
|
107 | 107 | |
108 | 108 | ?> |
109 | 109 | </td> |
110 | 110 | </tr> |
111 | 111 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
112 | - <th><label for="_default_calendar_trim_titles"><?php _e( 'Trim event titles', 'google-calendar-events' ); ?></label></th> |
|
112 | + <th><label for="_default_calendar_trim_titles"><?php _e('Trim event titles', 'google-calendar-events'); ?></label></th> |
|
113 | 113 | <td> |
114 | 114 | <?php |
115 | 115 | |
116 | - $trim = get_post_meta( $post_id, '_default_calendar_trim_titles', true ); |
|
116 | + $trim = get_post_meta($post_id, '_default_calendar_trim_titles', true); |
|
117 | 117 | |
118 | - simcal_print_field( array( |
|
118 | + simcal_print_field(array( |
|
119 | 119 | 'type' => 'checkbox', |
120 | 120 | 'name' => '_default_calendar_trim_titles', |
121 | 121 | 'id' => '_default_calendar_trim_titles', |
@@ -126,34 +126,34 @@ discard block |
||
126 | 126 | 'attributes' => array( |
127 | 127 | 'data-show-next-if-value' => 'yes', |
128 | 128 | ), |
129 | - ) ); |
|
129 | + )); |
|
130 | 130 | |
131 | - simcal_print_field( array( |
|
131 | + simcal_print_field(array( |
|
132 | 132 | 'type' => 'standard', |
133 | 133 | 'subtype' => 'number', |
134 | 134 | 'name' => '_default_calendar_trim_titles_chars', |
135 | 135 | 'id' => '_default_calendar_trim_titles_chars', |
136 | - 'tooltip' => __( 'Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events' ), |
|
136 | + 'tooltip' => __('Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events'), |
|
137 | 137 | 'class' => array( |
138 | 138 | 'simcal-field-tiny', |
139 | 139 | ), |
140 | - 'value' => 'yes' == $trim ? strval( max( absint( get_post_meta( $post_id, '_default_calendar_trim_titles_chars', true ) ), 1 ) ) : '20', |
|
140 | + 'value' => 'yes' == $trim ? strval(max(absint(get_post_meta($post_id, '_default_calendar_trim_titles_chars', true)), 1)) : '20', |
|
141 | 141 | 'attributes' => array( |
142 | 142 | 'min' => '1', |
143 | 143 | ), |
144 | - ) ); |
|
144 | + )); |
|
145 | 145 | |
146 | 146 | ?> |
147 | 147 | </td> |
148 | 148 | </tr> |
149 | 149 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
150 | - <th><label for="_default_calendar_list_grouped_span"><?php _e( 'Span', 'google-calendar-events' ); ?></label></th> |
|
150 | + <th><label for="_default_calendar_list_grouped_span"><?php _e('Span', 'google-calendar-events'); ?></label></th> |
|
151 | 151 | <td> |
152 | 152 | <?php |
153 | 153 | |
154 | - $list_span = max( absint( get_post_meta( $post_id, '_default_calendar_list_range_span', true ) ), 1 ); |
|
154 | + $list_span = max(absint(get_post_meta($post_id, '_default_calendar_list_range_span', true)), 1); |
|
155 | 155 | |
156 | - simcal_print_field( array( |
|
156 | + simcal_print_field(array( |
|
157 | 157 | 'type' => 'standard', |
158 | 158 | 'subtype' => 'number', |
159 | 159 | 'name' => '_default_calendar_list_range_span', |
@@ -162,78 +162,78 @@ discard block |
||
162 | 162 | 'simcal-field-tiny', |
163 | 163 | 'simcal-field-inline', |
164 | 164 | ), |
165 | - 'value' => strval( $list_span ), |
|
165 | + 'value' => strval($list_span), |
|
166 | 166 | 'attributes' => array( |
167 | 167 | 'min' => '1', |
168 | 168 | ), |
169 | - ) ); |
|
169 | + )); |
|
170 | 170 | |
171 | - $list_type = get_post_meta( $post_id, '_default_calendar_list_range_type', true ); |
|
171 | + $list_type = get_post_meta($post_id, '_default_calendar_list_range_type', true); |
|
172 | 172 | |
173 | - simcal_print_field( array( |
|
173 | + simcal_print_field(array( |
|
174 | 174 | 'type' => 'select', |
175 | 175 | 'name' => '_default_calendar_list_range_type', |
176 | 176 | 'id' => '_default_calendar_list_range_type', |
177 | - 'tooltip' => __( 'Range of events to show on each calendar page.', 'google-calendar-events' ), |
|
177 | + 'tooltip' => __('Range of events to show on each calendar page.', 'google-calendar-events'), |
|
178 | 178 | 'class' => array( |
179 | 179 | 'simcal-field-inline', |
180 | 180 | ), |
181 | 181 | 'value' => $list_type, |
182 | 182 | 'options' => array( |
183 | - 'monthly' => __( 'Month(s)', 'google-calendar-events' ), |
|
184 | - 'weekly' => __( 'Week(s)', 'google-calendar-events' ), |
|
185 | - 'daily' => __( 'Day(s)', 'google-calendar-events' ), |
|
186 | - 'events' => __( 'Event(s)', 'google-calendar-events' ), |
|
183 | + 'monthly' => __('Month(s)', 'google-calendar-events'), |
|
184 | + 'weekly' => __('Week(s)', 'google-calendar-events'), |
|
185 | + 'daily' => __('Day(s)', 'google-calendar-events'), |
|
186 | + 'events' => __('Event(s)', 'google-calendar-events'), |
|
187 | 187 | ), |
188 | - ) ); |
|
188 | + )); |
|
189 | 189 | |
190 | 190 | ?> |
191 | 191 | </td> |
192 | 192 | </tr> |
193 | 193 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
194 | - <th><label for="_default_calendar_list_header"><?php _e( 'Hide header', 'google-calendar-events' ); ?></label></th> |
|
194 | + <th><label for="_default_calendar_list_header"><?php _e('Hide header', 'google-calendar-events'); ?></label></th> |
|
195 | 195 | <td> |
196 | 196 | <?php |
197 | 197 | |
198 | - $header = get_post_meta( $post_id, '_default_calendar_list_header', true ); |
|
198 | + $header = get_post_meta($post_id, '_default_calendar_list_header', true); |
|
199 | 199 | |
200 | - simcal_print_field( array( |
|
200 | + simcal_print_field(array( |
|
201 | 201 | 'type' => 'checkbox', |
202 | 202 | 'name' => '_default_calendar_list_header', |
203 | 203 | 'id' => '_default_calendar_list_header', |
204 | - 'tooltip' => __( 'You can use this to hide the month header for this calendar.', 'google-calendar-events' ), |
|
204 | + 'tooltip' => __('You can use this to hide the month header for this calendar.', 'google-calendar-events'), |
|
205 | 205 | 'value' => 'yes' == $header ? 'yes' : 'no', |
206 | - ) ); |
|
206 | + )); |
|
207 | 207 | |
208 | 208 | ?> |
209 | 209 | </td> |
210 | 210 | </tr> |
211 | 211 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
212 | - <th><label for="_default_calendar_compact_list"><?php _e( 'Compact list', 'google-calendar-events' ); ?></label></th> |
|
212 | + <th><label for="_default_calendar_compact_list"><?php _e('Compact list', 'google-calendar-events'); ?></label></th> |
|
213 | 213 | <td> |
214 | 214 | <?php |
215 | 215 | |
216 | - $compact = get_post_meta( $post_id, '_default_calendar_compact_list', true ); |
|
216 | + $compact = get_post_meta($post_id, '_default_calendar_compact_list', true); |
|
217 | 217 | |
218 | - simcal_print_field( array( |
|
218 | + simcal_print_field(array( |
|
219 | 219 | 'type' => 'checkbox', |
220 | 220 | 'name' => '_default_calendar_compact_list', |
221 | 221 | 'id' => '_default_calendar_compact_list', |
222 | - 'tooltip' => __( 'Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events' ), |
|
222 | + 'tooltip' => __('Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events'), |
|
223 | 223 | 'value' => 'yes' == $compact ? 'yes' : 'no', |
224 | - ) ); |
|
224 | + )); |
|
225 | 225 | |
226 | 226 | ?> |
227 | 227 | </td> |
228 | 228 | </tr> |
229 | 229 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
230 | - <th><label for="_default_calendar_limit_visible_events"><?php _e( 'Limit visible events', 'google-calendar-events' ); ?></label></th> |
|
230 | + <th><label for="_default_calendar_limit_visible_events"><?php _e('Limit visible events', 'google-calendar-events'); ?></label></th> |
|
231 | 231 | <td> |
232 | 232 | <?php |
233 | 233 | |
234 | - $limit = get_post_meta( $post_id, '_default_calendar_limit_visible_events', true ); |
|
234 | + $limit = get_post_meta($post_id, '_default_calendar_limit_visible_events', true); |
|
235 | 235 | |
236 | - simcal_print_field( array( |
|
236 | + simcal_print_field(array( |
|
237 | 237 | 'type' => 'checkbox', |
238 | 238 | 'name' => '_default_calendar_limit_visible_events', |
239 | 239 | 'id' => '_default_calendar_limit_visible_events', |
@@ -244,17 +244,17 @@ discard block |
||
244 | 244 | 'attributes' => array( |
245 | 245 | 'data-show-next-if-value' => 'yes', |
246 | 246 | ) |
247 | - ) ); |
|
247 | + )); |
|
248 | 248 | |
249 | - $visible_events = absint( get_post_meta( $post_id, '_default_calendar_visible_events', true ) ); |
|
249 | + $visible_events = absint(get_post_meta($post_id, '_default_calendar_visible_events', true)); |
|
250 | 250 | $visible_events = $visible_events > 0 ? $visible_events : 3; |
251 | 251 | |
252 | - simcal_print_field( array( |
|
252 | + simcal_print_field(array( |
|
253 | 253 | 'type' => 'standard', |
254 | 254 | 'subtype' => 'number', |
255 | 255 | 'name' => '_default_calendar_visible_events', |
256 | 256 | 'id' => '_default_calendar_visible_events', |
257 | - 'tooltip' => __( 'Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events' ), |
|
257 | + 'tooltip' => __('Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events'), |
|
258 | 258 | 'class' => array( |
259 | 259 | 'simcal-field-tiny', |
260 | 260 | ), |
@@ -262,23 +262,23 @@ discard block |
||
262 | 262 | 'attributes' => array( |
263 | 263 | 'min' => '1', |
264 | 264 | ) |
265 | - ) ); |
|
265 | + )); |
|
266 | 266 | |
267 | 267 | ?> |
268 | 268 | </td> |
269 | 269 | </tr> |
270 | 270 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
271 | - <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Expand multi day events', 'google-calendar-events' ); ?></label></th> |
|
271 | + <th><label for="_default_calendar_event_bubbles_action"><?php _e('Expand multi day events', 'google-calendar-events'); ?></label></th> |
|
272 | 272 | <td> |
273 | 273 | <?php |
274 | 274 | |
275 | - simcal_print_field( array( |
|
275 | + simcal_print_field(array( |
|
276 | 276 | 'type' => 'checkbox', |
277 | 277 | 'name' => '_default_calendar_expand_multi_day_events', |
278 | 278 | 'id' => '_default_calendar_expand_multi_day_events', |
279 | - 'tooltip' => __( 'Show events spanning multiple days on each day.', 'google-calendar-events' ), |
|
280 | - 'value' => get_post_meta( $post_id, '_default_calendar_expand_multi_day_events', true ), |
|
281 | - ) ); |
|
279 | + 'tooltip' => __('Show events spanning multiple days on each day.', 'google-calendar-events'), |
|
280 | + 'value' => get_post_meta($post_id, '_default_calendar_expand_multi_day_events', true), |
|
281 | + )); |
|
282 | 282 | |
283 | 283 | ?> |
284 | 284 | </td> |
@@ -286,70 +286,70 @@ discard block |
||
286 | 286 | </tbody> |
287 | 287 | <?php |
288 | 288 | |
289 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
290 | - $default_theme = isset( $settings['default-calendar']['theme'] ) ? $settings['default-calendar']['theme'] : 'light'; |
|
289 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
290 | + $default_theme = isset($settings['default-calendar']['theme']) ? $settings['default-calendar']['theme'] : 'light'; |
|
291 | 291 | $default_today_color = /*isset( $settings['default-calendar']['today_color'] ) ? $settings['default-calendar']['today_color'] :*/ '#1e73be'; |
292 | 292 | $default_days_events_color = /*isset( $settings['default-calendar']['days_events_color'] ) ? $settings['default-calendar']['days_events_color'] :*/ '#000000'; |
293 | 293 | |
294 | 294 | ?> |
295 | 295 | <tbody class="simcal-panel-section"> |
296 | 296 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
297 | - <th><label for="_default_calendar_style_theme"><?php _e( 'Theme', 'google-calendar-events' ); ?></label></th> |
|
297 | + <th><label for="_default_calendar_style_theme"><?php _e('Theme', 'google-calendar-events'); ?></label></th> |
|
298 | 298 | <td> |
299 | 299 | <?php |
300 | 300 | |
301 | - $saved = get_post_meta( $post_id, '_default_calendar_style_theme', true ); |
|
301 | + $saved = get_post_meta($post_id, '_default_calendar_style_theme', true); |
|
302 | 302 | $value = ! $saved ? $default_theme : $saved; |
303 | 303 | |
304 | - simcal_print_field( array( |
|
304 | + simcal_print_field(array( |
|
305 | 305 | 'type' => 'select', |
306 | 306 | 'name' => '_default_calendar_style_theme', |
307 | 307 | 'id' => '_default_calendar_style_theme', |
308 | 308 | 'value' => $value, |
309 | - 'tooltip' => __( 'Choose a calendar theme to match your site theme.', 'google-calendar-events' ), |
|
309 | + 'tooltip' => __('Choose a calendar theme to match your site theme.', 'google-calendar-events'), |
|
310 | 310 | 'options' => array( |
311 | - 'light' => __( 'Light', 'google-calendar-events' ), |
|
312 | - 'dark' => __( 'Dark', 'google-calendar-events' ), |
|
311 | + 'light' => __('Light', 'google-calendar-events'), |
|
312 | + 'dark' => __('Dark', 'google-calendar-events'), |
|
313 | 313 | ), |
314 | - ) ); |
|
314 | + )); |
|
315 | 315 | |
316 | 316 | ?> |
317 | 317 | </td> |
318 | 318 | </tr> |
319 | 319 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
320 | - <th><label for="_default_calendar_style_today"><?php _e( 'Today', 'google-calendar-events' ); ?></label></th> |
|
320 | + <th><label for="_default_calendar_style_today"><?php _e('Today', 'google-calendar-events'); ?></label></th> |
|
321 | 321 | <td> |
322 | 322 | <?php |
323 | 323 | |
324 | - $saved = get_post_meta( $post_id, '_default_calendar_style_today', true ); |
|
324 | + $saved = get_post_meta($post_id, '_default_calendar_style_today', true); |
|
325 | 325 | $value = ! $saved ? $default_today_color : $saved; |
326 | 326 | |
327 | - simcal_print_field( array( |
|
327 | + simcal_print_field(array( |
|
328 | 328 | 'type' => 'standard', |
329 | 329 | 'subtype' => 'color-picker', |
330 | 330 | 'name' => '_default_calendar_style_today', |
331 | 331 | 'id' => '_default_calendar_style_today', |
332 | 332 | 'value' => $value, |
333 | - ) ); |
|
333 | + )); |
|
334 | 334 | |
335 | 335 | ?> |
336 | 336 | </td> |
337 | 337 | </tr> |
338 | 338 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
339 | - <th><label for="_default_calendar_style_days_events"><?php _e( 'Days with events', 'google-calendar-events' ); ?></label></th> |
|
339 | + <th><label for="_default_calendar_style_days_events"><?php _e('Days with events', 'google-calendar-events'); ?></label></th> |
|
340 | 340 | <td> |
341 | 341 | <?php |
342 | 342 | |
343 | - $saved = get_post_meta( $post_id, '_default_calendar_style_days_events', true ); |
|
343 | + $saved = get_post_meta($post_id, '_default_calendar_style_days_events', true); |
|
344 | 344 | $value = ! $saved ? $default_days_events_color : $saved; |
345 | 345 | |
346 | - simcal_print_field( array( |
|
346 | + simcal_print_field(array( |
|
347 | 347 | 'type' => 'standard', |
348 | 348 | 'subtype' => 'color-picker', |
349 | 349 | 'name' => '_default_calendar_style_days_events', |
350 | 350 | 'id' => '_default_calendar_style_days_events', |
351 | 351 | 'value' => $value, |
352 | - ) ); |
|
352 | + )); |
|
353 | 353 | |
354 | 354 | ?> |
355 | 355 | </td> |
@@ -370,55 +370,55 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @param int $post_id |
372 | 372 | */ |
373 | - public function process_meta( $post_id ) { |
|
373 | + public function process_meta($post_id) { |
|
374 | 374 | |
375 | 375 | // Theme. |
376 | - $theme = isset( $_POST['_default_calendar_style_theme'] ) ? sanitize_key( $_POST['_default_calendar_style_theme'] ) : 'light'; |
|
377 | - update_post_meta( $post_id, '_default_calendar_style_theme', $theme ); |
|
376 | + $theme = isset($_POST['_default_calendar_style_theme']) ? sanitize_key($_POST['_default_calendar_style_theme']) : 'light'; |
|
377 | + update_post_meta($post_id, '_default_calendar_style_theme', $theme); |
|
378 | 378 | |
379 | 379 | // Today color. |
380 | - $today_color = isset( $_POST['_default_calendar_style_today'] ) ? sanitize_text_field( $_POST['_default_calendar_style_today'] ) : '#FF000'; |
|
381 | - update_post_meta( $post_id, '_default_calendar_style_today', $today_color ); |
|
380 | + $today_color = isset($_POST['_default_calendar_style_today']) ? sanitize_text_field($_POST['_default_calendar_style_today']) : '#FF000'; |
|
381 | + update_post_meta($post_id, '_default_calendar_style_today', $today_color); |
|
382 | 382 | |
383 | 383 | // Days with events color. |
384 | - $days_events_color = isset( $_POST['_default_calendar_style_days_events'] ) ? sanitize_text_field( $_POST['_default_calendar_style_days_events'] ) : '#000000'; |
|
385 | - update_post_meta( $post_id, '_default_calendar_style_days_events', $days_events_color ); |
|
384 | + $days_events_color = isset($_POST['_default_calendar_style_days_events']) ? sanitize_text_field($_POST['_default_calendar_style_days_events']) : '#000000'; |
|
385 | + update_post_meta($post_id, '_default_calendar_style_days_events', $days_events_color); |
|
386 | 386 | |
387 | 387 | // List range span. |
388 | - $span = isset( $_POST['_default_calendar_list_range_span'] ) ? max( absint( $_POST['_default_calendar_list_range_span'] ), 1 ) : 1; |
|
389 | - update_post_meta( $post_id, '_default_calendar_list_range_span', $span ); |
|
388 | + $span = isset($_POST['_default_calendar_list_range_span']) ? max(absint($_POST['_default_calendar_list_range_span']), 1) : 1; |
|
389 | + update_post_meta($post_id, '_default_calendar_list_range_span', $span); |
|
390 | 390 | |
391 | 391 | // List range type. |
392 | - $group = isset( $_POST['_default_calendar_list_range_type'] ) ? sanitize_key( $_POST['_default_calendar_list_range_type'] ) : 'monthly'; |
|
393 | - update_post_meta( $post_id, '_default_calendar_list_range_type', $group ); |
|
392 | + $group = isset($_POST['_default_calendar_list_range_type']) ? sanitize_key($_POST['_default_calendar_list_range_type']) : 'monthly'; |
|
393 | + update_post_meta($post_id, '_default_calendar_list_range_type', $group); |
|
394 | 394 | |
395 | 395 | // Hide header. |
396 | - $header = isset( $_POST['_default_calendar_list_header'] ) ? 'yes' : 'no'; |
|
397 | - update_post_meta( $post_id, '_default_calendar_list_header', $header ); |
|
396 | + $header = isset($_POST['_default_calendar_list_header']) ? 'yes' : 'no'; |
|
397 | + update_post_meta($post_id, '_default_calendar_list_header', $header); |
|
398 | 398 | |
399 | 399 | // Compact list. |
400 | - $compact = isset( $_POST['_default_calendar_compact_list'] ) ? 'yes' : 'no'; |
|
401 | - update_post_meta( $post_id, '_default_calendar_compact_list', $compact ); |
|
400 | + $compact = isset($_POST['_default_calendar_compact_list']) ? 'yes' : 'no'; |
|
401 | + update_post_meta($post_id, '_default_calendar_compact_list', $compact); |
|
402 | 402 | |
403 | 403 | // Limit number of initially visible daily events. |
404 | - $limit = isset( $_POST['_default_calendar_limit_visible_events'] ) ? 'yes' : 'no'; |
|
405 | - update_post_meta( $post_id, '_default_calendar_limit_visible_events', $limit ); |
|
406 | - $number = isset( $_POST['_default_calendar_visible_events'] ) ? absint( $_POST['_default_calendar_visible_events'] ) : 3; |
|
407 | - update_post_meta( $post_id, '_default_calendar_visible_events', $number ); |
|
404 | + $limit = isset($_POST['_default_calendar_limit_visible_events']) ? 'yes' : 'no'; |
|
405 | + update_post_meta($post_id, '_default_calendar_limit_visible_events', $limit); |
|
406 | + $number = isset($_POST['_default_calendar_visible_events']) ? absint($_POST['_default_calendar_visible_events']) : 3; |
|
407 | + update_post_meta($post_id, '_default_calendar_visible_events', $number); |
|
408 | 408 | |
409 | 409 | // Grid event bubbles action. |
410 | - $bubbles = isset( $_POST['_default_calendar_event_bubble_trigger'] ) ? esc_attr( $_POST['_default_calendar_event_bubble_trigger'] ) : 'hover'; |
|
411 | - update_post_meta( $post_id, '_default_calendar_event_bubble_trigger', $bubbles ); |
|
410 | + $bubbles = isset($_POST['_default_calendar_event_bubble_trigger']) ? esc_attr($_POST['_default_calendar_event_bubble_trigger']) : 'hover'; |
|
411 | + update_post_meta($post_id, '_default_calendar_event_bubble_trigger', $bubbles); |
|
412 | 412 | |
413 | 413 | // Trim event titles characters length. |
414 | - $trim = isset( $_POST['_default_calendar_trim_titles'] ) ? 'yes' : 'no'; |
|
415 | - update_post_meta( $post_id, '_default_calendar_trim_titles', $trim ); |
|
416 | - $chars = isset( $_POST['_default_calendar_trim_titles_chars'] ) ? max( absint( $_POST['_default_calendar_trim_titles_chars'] ), 1 ) : 20; |
|
417 | - update_post_meta( $post_id, '_default_calendar_trim_titles_chars', $chars ); |
|
414 | + $trim = isset($_POST['_default_calendar_trim_titles']) ? 'yes' : 'no'; |
|
415 | + update_post_meta($post_id, '_default_calendar_trim_titles', $trim); |
|
416 | + $chars = isset($_POST['_default_calendar_trim_titles_chars']) ? max(absint($_POST['_default_calendar_trim_titles_chars']), 1) : 20; |
|
417 | + update_post_meta($post_id, '_default_calendar_trim_titles_chars', $chars); |
|
418 | 418 | |
419 | 419 | // Expand multiple day events on each day. |
420 | - $multi_day = isset( $_POST['_default_calendar_expand_multi_day_events'] ) ? 'yes' : 'no'; |
|
421 | - update_post_meta( $post_id, '_default_calendar_expand_multi_day_events', $multi_day ); |
|
420 | + $multi_day = isset($_POST['_default_calendar_expand_multi_day_events']) ? 'yes' : 'no'; |
|
421 | + update_post_meta($post_id, '_default_calendar_expand_multi_day_events', $multi_day); |
|
422 | 422 | |
423 | 423 | } |
424 | 424 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | use SimpleCalendar\Events\Event; |
14 | 14 | use SimpleCalendar\Calendars\Default_Calendar; |
15 | 15 | |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param string|Calendar $calendar |
57 | 57 | */ |
58 | - public function __construct( $calendar = '' ) { |
|
58 | + public function __construct($calendar = '') { |
|
59 | 59 | $this->calendar = $calendar; |
60 | 60 | } |
61 | 61 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return string |
90 | 90 | */ |
91 | 91 | public function get_name() { |
92 | - return __( 'Grid', 'google-calendar-events' ); |
|
92 | + return __('Grid', 'google-calendar-events'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @since 3.0.0 |
99 | 99 | */ |
100 | 100 | public function add_ajax_actions() { |
101 | - add_action( 'wp_ajax_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) ); |
|
102 | - add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) ); |
|
101 | + add_action('wp_ajax_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax')); |
|
102 | + add_action('wp_ajax_nopriv_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -113,16 +113,16 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return array |
115 | 115 | */ |
116 | - public function scripts( $min = '' ) { |
|
116 | + public function scripts($min = '') { |
|
117 | 117 | return array( |
118 | 118 | 'simcal-qtip' => array( |
119 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js', |
|
120 | - 'deps' => array( 'jquery' ), |
|
119 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js', |
|
120 | + 'deps' => array('jquery'), |
|
121 | 121 | 'ver' => '2.2.1', |
122 | 122 | 'in_footer' => true, |
123 | 123 | ), |
124 | 124 | 'simcal-default-calendar' => array( |
125 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js', |
|
125 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js', |
|
126 | 126 | 'deps' => array( |
127 | 127 | 'jquery', |
128 | 128 | 'simcal-qtip', |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return array |
149 | 149 | */ |
150 | - public function styles( $min = '' ) { |
|
150 | + public function styles($min = '') { |
|
151 | 151 | return array( |
152 | 152 | 'simcal-qtip' => array( |
153 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/vendor/qtip' . $min . '.css', |
|
153 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/vendor/qtip'.$min.'.css', |
|
154 | 154 | 'ver' => '2.2.1', |
155 | 155 | 'media' => 'all', |
156 | 156 | ), |
157 | 157 | 'simcal-default-calendar-grid' => array( |
158 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-grid' . $min . '.css', |
|
158 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-grid'.$min.'.css', |
|
159 | 159 | 'deps' => array( |
160 | 160 | 'simcal-qtip', |
161 | 161 | ), |
@@ -174,16 +174,16 @@ discard block |
||
174 | 174 | |
175 | 175 | $calendar = $this->calendar; |
176 | 176 | |
177 | - if ( $calendar instanceof Default_Calendar ) { |
|
177 | + if ($calendar instanceof Default_Calendar) { |
|
178 | 178 | |
179 | 179 | ?> |
180 | 180 | <table class="simcal-calendar-grid" |
181 | 181 | data-event-bubble-trigger="<?php echo $calendar->event_bubble_trigger; ?>"> |
182 | 182 | <thead class="simcal-calendar-head"> |
183 | 183 | <tr> |
184 | - <?php if ( ! $calendar->static ) { ?> |
|
184 | + <?php if ( ! $calendar->static) { ?> |
|
185 | 185 | <th class="simcal-nav simcal-prev-wrapper" colspan="1"> |
186 | - <button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e( 'Previous Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-left"></i></button> |
|
186 | + <button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e('Previous Month', 'google-calendar-events'); ?>"><i class="simcal-icon-left"></i></button> |
|
187 | 187 | </th> |
188 | 188 | <?php } ?> |
189 | 189 | <th colspan="<?php echo $calendar->static ? '7' : '5'; ?>" |
@@ -195,26 +195,26 @@ discard block |
||
195 | 195 | |
196 | 196 | // Display month and year according to user date format preference. |
197 | 197 | |
198 | - $year_pos = strcspn( $calendar->date_format, 'Y y' ); |
|
199 | - $month_pos = strcspn( $calendar->date_format, 'F M m n' ); |
|
198 | + $year_pos = strcspn($calendar->date_format, 'Y y'); |
|
199 | + $month_pos = strcspn($calendar->date_format, 'F M m n'); |
|
200 | 200 | |
201 | - $current = array( 'month' => 'F', 'year' => 'Y' ); |
|
201 | + $current = array('month' => 'F', 'year' => 'Y'); |
|
202 | 202 | |
203 | - if ( $year_pos < $month_pos ) { |
|
204 | - $current = array_reverse( $current ); |
|
203 | + if ($year_pos < $month_pos) { |
|
204 | + $current = array_reverse($current); |
|
205 | 205 | } |
206 | 206 | |
207 | - foreach ( $current as $k => $v ) { |
|
208 | - echo ' <span class="simcal-current-' . $k , '">' . date_i18n( $v, $calendar->start ) . '</span> '; |
|
207 | + foreach ($current as $k => $v) { |
|
208 | + echo ' <span class="simcal-current-'.$k, '">'.date_i18n($v, $calendar->start).'</span> '; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | echo '</h3>'; |
212 | 212 | |
213 | 213 | ?> |
214 | 214 | </th> |
215 | - <?php if ( ! $calendar->static ) { ?> |
|
215 | + <?php if ( ! $calendar->static) { ?> |
|
216 | 216 | <th class="simcal-nav simcal-next-wrapper" colspan="1"> |
217 | - <button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e( 'Next Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-right"></i></button> |
|
217 | + <button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e('Next Month', 'google-calendar-events'); ?>"><i class="simcal-icon-right"></i></button> |
|
218 | 218 | </th> |
219 | 219 | <?php } ?> |
220 | 220 | </tr> |
@@ -224,28 +224,28 @@ discard block |
||
224 | 224 | // Print day names in short or long form for different viewport sizes. |
225 | 225 | |
226 | 226 | $week_starts = $calendar->week_starts; |
227 | - $week_days_short = simcal_get_calendar_names_i18n( 'day', 'short' ); |
|
228 | - $week_days_full = simcal_get_calendar_names_i18n( 'day', 'full' ); |
|
227 | + $week_days_short = simcal_get_calendar_names_i18n('day', 'short'); |
|
228 | + $week_days_full = simcal_get_calendar_names_i18n('day', 'full'); |
|
229 | 229 | |
230 | - for ( $i = $week_starts; $i <= 6; $i ++ ) : |
|
230 | + for ($i = $week_starts; $i <= 6; $i++) : |
|
231 | 231 | |
232 | 232 | ?> |
233 | 233 | <th class="simcal-week-day simcal-week-day-<?php echo $i ?>" |
234 | - data-screen-small="<?php echo substr( $week_days_short[ $i ], 0, 1 ); ?>" |
|
235 | - data-screen-medium="<?php echo $week_days_short[ $i ]; ?>" |
|
236 | - data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th> |
|
234 | + data-screen-small="<?php echo substr($week_days_short[$i], 0, 1); ?>" |
|
235 | + data-screen-medium="<?php echo $week_days_short[$i]; ?>" |
|
236 | + data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th> |
|
237 | 237 | <?php |
238 | 238 | |
239 | 239 | endfor; |
240 | 240 | |
241 | - if ( $week_starts !== 0 ) : |
|
242 | - for ( $i = 0; $i < $week_starts; $i ++ ) : |
|
241 | + if ($week_starts !== 0) : |
|
242 | + for ($i = 0; $i < $week_starts; $i++) : |
|
243 | 243 | |
244 | 244 | ?> |
245 | 245 | <th class="simcal-week-day simcal-week-day-<?php echo $i ?>" |
246 | - data-screen-small="<?php echo substr( $week_days_short[ $i ], 0, 1 ); ?>" |
|
247 | - data-screen-medium="<?php echo $week_days_short[ $i ]; ?>" |
|
248 | - data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th> |
|
246 | + data-screen-small="<?php echo substr($week_days_short[$i], 0, 1); ?>" |
|
247 | + data-screen-medium="<?php echo $week_days_short[$i]; ?>" |
|
248 | + data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th> |
|
249 | 249 | <?php |
250 | 250 | |
251 | 251 | endfor; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | </tr> |
256 | 256 | </thead> |
257 | 257 | |
258 | - <?php echo $this->draw_month( date( 'n', $calendar->start ), date( 'Y', $calendar->start ) ); ?> |
|
258 | + <?php echo $this->draw_month(date('n', $calendar->start), date('Y', $calendar->start)); ?> |
|
259 | 259 | |
260 | 260 | </table> |
261 | 261 | <?php |
@@ -280,82 +280,82 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return string |
282 | 282 | */ |
283 | - private function draw_month( $month, $year, $id = 0 ) { |
|
283 | + private function draw_month($month, $year, $id = 0) { |
|
284 | 284 | |
285 | 285 | $calendar = $this->calendar; |
286 | - if ( empty( $calendar ) ) { |
|
287 | - $calendar = simcal_get_calendar( intval( $id ) ); |
|
288 | - if ( ! $calendar ) { |
|
286 | + if (empty($calendar)) { |
|
287 | + $calendar = simcal_get_calendar(intval($id)); |
|
288 | + if ( ! $calendar) { |
|
289 | 289 | return ''; |
290 | 290 | } |
291 | 291 | } |
292 | - date_default_timezone_set( $calendar->timezone ); |
|
292 | + date_default_timezone_set($calendar->timezone); |
|
293 | 293 | $events = $calendar->events; |
294 | 294 | |
295 | 295 | // Variables to cycle days in current month and find today in calendar. |
296 | 296 | $now = $calendar->now; |
297 | - $current = Carbon::create( $year, $month, 1, 0, 0, 59, $calendar->timezone ); |
|
297 | + $current = Carbon::create($year, $month, 1, 0, 0, 59, $calendar->timezone); |
|
298 | 298 | $current_min = $current->getTimestamp(); |
299 | 299 | $current_max = $current->endOfDay()->getTimestamp(); |
300 | 300 | |
301 | 301 | // Calendar grid variables. |
302 | 302 | $week_starts = $calendar->week_starts; |
303 | - $week_of_year = $current->weekOfYear; // Relative count of the week number of the year. |
|
304 | - $month_starts = $current->dayOfWeek; // Day upon which the month starts. |
|
305 | - $days_in_month = $current->daysInMonth; // Number of days in the given month. |
|
303 | + $week_of_year = $current->weekOfYear; // Relative count of the week number of the year. |
|
304 | + $month_starts = $current->dayOfWeek; // Day upon which the month starts. |
|
305 | + $days_in_month = $current->daysInMonth; // Number of days in the given month. |
|
306 | 306 | |
307 | 307 | // Set current month events timestamp boundaries. |
308 | 308 | $this->start = $current_min; |
309 | 309 | $this->end = $current->endOfMonth()->timestamp; |
310 | 310 | |
311 | 311 | // Get daily events for this month. |
312 | - if ( $events && is_array( $events ) ) { |
|
312 | + if ($events && is_array($events)) { |
|
313 | 313 | |
314 | 314 | // Filter events within the boundaries previously set above. |
315 | - $timestamps = array_keys( $events ); |
|
316 | - $lower_bound = array_filter( $timestamps, array( $this, 'filter_events_before' ) ); |
|
317 | - $higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) ); |
|
318 | - $filtered = array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ); |
|
315 | + $timestamps = array_keys($events); |
|
316 | + $lower_bound = array_filter($timestamps, array($this, 'filter_events_before')); |
|
317 | + $higher_bound = array_filter($lower_bound, array($this, 'filter_events_after')); |
|
318 | + $filtered = array_intersect_key($events, array_combine($higher_bound, $higher_bound)); |
|
319 | 319 | |
320 | 320 | // Put resulting events in an associative array, with day of the month as key for easy retrieval in calendar days loop. |
321 | 321 | $day_events = array(); |
322 | - foreach ( $filtered as $timestamp => $events_in_day ) { |
|
323 | - foreach ( $events_in_day as $event ) { |
|
324 | - if ( $event instanceof Event ){ |
|
325 | - $day = intval( Carbon::createFromTimestamp( $timestamp, $event->timezone )->endOfDay()->day ); |
|
326 | - $day_events[ $day ][] = $event; |
|
322 | + foreach ($filtered as $timestamp => $events_in_day) { |
|
323 | + foreach ($events_in_day as $event) { |
|
324 | + if ($event instanceof Event) { |
|
325 | + $day = intval(Carbon::createFromTimestamp($timestamp, $event->timezone)->endOfDay()->day); |
|
326 | + $day_events[$day][] = $event; |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | - ksort( $day_events, SORT_NUMERIC ); |
|
331 | + ksort($day_events, SORT_NUMERIC); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | ob_start(); |
335 | 335 | |
336 | - echo '<tbody class="simcal-month simcal-month-' . $month . '">' . "\n"; |
|
337 | - echo "\t" . '<tr class="simcal-week simcal-week-' . $week_of_year . '">'; |
|
336 | + echo '<tbody class="simcal-month simcal-month-'.$month.'">'."\n"; |
|
337 | + echo "\t".'<tr class="simcal-week simcal-week-'.$week_of_year.'">'; |
|
338 | 338 | |
339 | 339 | $days_in_row = 0; |
340 | 340 | // Week may start on an arbitrary day (sun, 0 - sat, 6). |
341 | 341 | $week_day = $week_starts; |
342 | 342 | |
343 | 343 | // This fixes a possible bug when a month starts by Sunday (0). |
344 | - if ( 0 !== $week_starts ) { |
|
344 | + if (0 !== $week_starts) { |
|
345 | 345 | $b = $month_starts === 0 ? 7 : $month_starts; |
346 | 346 | } else { |
347 | 347 | $b = $month_starts; |
348 | 348 | } |
349 | 349 | |
350 | 350 | // Void days in first week. |
351 | - for ( $a = $week_starts; $a < $b; $a++ ) : |
|
351 | + for ($a = $week_starts; $a < $b; $a++) : |
|
352 | 352 | |
353 | - $last_void_day_class = ( $a === ( $b - 1 ) ) ? 'simcal-day-void-last' : ''; |
|
353 | + $last_void_day_class = ($a === ($b - 1)) ? 'simcal-day-void-last' : ''; |
|
354 | 354 | |
355 | - echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n"; |
|
355 | + echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n"; |
|
356 | 356 | |
357 | 357 | // Reset day of the week count (sun, 0 - sat, 6). |
358 | - if ( $week_day === 6 ) { |
|
358 | + if ($week_day === 6) { |
|
359 | 359 | $week_day = -1; |
360 | 360 | } |
361 | 361 | $week_day++; |
@@ -365,91 +365,91 @@ discard block |
||
365 | 365 | endfor; |
366 | 366 | |
367 | 367 | // Actual days of the month. |
368 | - for ( $day = 1; $day <= $days_in_month; $day++ ) : |
|
368 | + for ($day = 1; $day <= $days_in_month; $day++) : |
|
369 | 369 | |
370 | 370 | $count = 0; |
371 | 371 | $calendar_classes = array(); |
372 | - $day_classes = 'simcal-day-' . $day . ' simcal-weekday-' . $week_day; |
|
372 | + $day_classes = 'simcal-day-'.$day.' simcal-weekday-'.$week_day; |
|
373 | 373 | |
374 | 374 | $border_style = $bg_color = $color = ''; |
375 | 375 | |
376 | 376 | // Is this the present, the past or the future, Doc? |
377 | - if ( $current_min <= $now && $current_max >= $now ) { |
|
377 | + if ($current_min <= $now && $current_max >= $now) { |
|
378 | 378 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
379 | - $the_color = new Color( $calendar->today_color ); |
|
380 | - $bg_color = '#' . $the_color->getHex(); |
|
379 | + $the_color = new Color($calendar->today_color); |
|
380 | + $bg_color = '#'.$the_color->getHex(); |
|
381 | 381 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
382 | - $border_style = ' style="border: 1px solid ' . $bg_color . ';"'; |
|
383 | - } elseif ( $current_max < $now ) { |
|
382 | + $border_style = ' style="border: 1px solid '.$bg_color.';"'; |
|
383 | + } elseif ($current_max < $now) { |
|
384 | 384 | $day_classes .= ' simcal-past simcal-day'; |
385 | - } elseif ( $current_min > $now ) { |
|
385 | + } elseif ($current_min > $now) { |
|
386 | 386 | $day_classes .= ' simcal-future simcal-day'; |
387 | 387 | } |
388 | 388 | |
389 | 389 | // Print events for the current day in loop, if found any. |
390 | - if ( isset( $day_events[ $day ] ) ) : |
|
390 | + if (isset($day_events[$day])) : |
|
391 | 391 | |
392 | 392 | $list_events = '<ul class="simcal-events">'; |
393 | 393 | |
394 | - foreach ( $day_events[ $day ] as $event ) : |
|
394 | + foreach ($day_events[$day] as $event) : |
|
395 | 395 | |
396 | 396 | $event_classes = $event_visibility = ''; |
397 | 397 | |
398 | - if ( $event instanceof Event ) : |
|
398 | + if ($event instanceof Event) : |
|
399 | 399 | |
400 | 400 | // Store the calendar id where the event belongs (useful in grouped calendar feeds) |
401 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
402 | - $calendar_classes[] = $calendar_class ; |
|
401 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
402 | + $calendar_classes[] = $calendar_class; |
|
403 | 403 | |
404 | 404 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
405 | 405 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
406 | 406 | |
407 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class . ' simcal-tooltip'; |
|
407 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class.' simcal-tooltip'; |
|
408 | 408 | |
409 | 409 | // Toggle some events visibility if more than optional limit. |
410 | - if ( ( $calendar->events_limit > -1 ) && ( $count >= $calendar->events_limit ) ) : |
|
410 | + if (($calendar->events_limit > -1) && ($count >= $calendar->events_limit)) : |
|
411 | 411 | $event_classes .= ' simcal-event-toggled'; |
412 | 412 | $event_visibility = ' style="display: none"'; |
413 | 413 | endif; |
414 | 414 | |
415 | 415 | // Event title in list. |
416 | - $title = ! empty( $event->title ) ? trim( $event->title ) : __( 'Event', 'google-calendar-events' ); |
|
417 | - if ( $calendar->trim_titles >= 1 ) { |
|
418 | - $title = strlen( $title ) > $calendar->trim_titles ? substr( $title, 0, $calendar->trim_titles ) . '…' : $title; |
|
416 | + $title = ! empty($event->title) ? trim($event->title) : __('Event', 'google-calendar-events'); |
|
417 | + if ($calendar->trim_titles >= 1) { |
|
418 | + $title = strlen($title) > $calendar->trim_titles ? substr($title, 0, $calendar->trim_titles).'…' : $title; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | // Event color. |
422 | 422 | $bullet = ''; |
423 | 423 | $event_color = $event->get_color(); |
424 | - if ( ! empty( $event_color ) ) { |
|
425 | - $bullet = '<span style="color: ' . $event_color . ';">■</span> '; |
|
424 | + if ( ! empty($event_color)) { |
|
425 | + $bullet = '<span style="color: '.$event_color.';">■</span> '; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | // Event contents. |
429 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . ' itemprop="event" itemscope itemtype="http://schema.org/Event">' . "\n"; |
|
430 | - $list_events .= "\t\t" . '<span class="simcal-event-title">' . $bullet . $title . '</span>' . "\n"; |
|
431 | - $list_events .= "\t\t" . '<div class="simcal-event-details simcal-tooltip-content" style="display: none;">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
432 | - $list_events .= "\t" . '</li>' . "\n"; |
|
429 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.' itemprop="event" itemscope itemtype="http://schema.org/Event">'."\n"; |
|
430 | + $list_events .= "\t\t".'<span class="simcal-event-title">'.$bullet.$title.'</span>'."\n"; |
|
431 | + $list_events .= "\t\t".'<div class="simcal-event-details simcal-tooltip-content" style="display: none;">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
432 | + $list_events .= "\t".'</li>'."\n"; |
|
433 | 433 | |
434 | - $count ++; |
|
434 | + $count++; |
|
435 | 435 | |
436 | 436 | endif; |
437 | 437 | |
438 | 438 | endforeach; |
439 | 439 | |
440 | - if ( ( $current_min <= $now ) && ( $current_max >= $now ) ) { |
|
440 | + if (($current_min <= $now) && ($current_max >= $now)) { |
|
441 | 441 | $day_classes .= ' simcal-today-has-events'; |
442 | 442 | } |
443 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
443 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
444 | 444 | |
445 | - if ( $calendar_classes ) { |
|
446 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
445 | + if ($calendar_classes) { |
|
446 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
447 | 447 | } |
448 | 448 | |
449 | - $list_events .= '</ul>' . "\n"; |
|
449 | + $list_events .= '</ul>'."\n"; |
|
450 | 450 | |
451 | 451 | // Optional button to toggle hidden events in list. |
452 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
452 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
453 | 453 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
454 | 454 | endif; |
455 | 455 | |
@@ -461,49 +461,49 @@ discard block |
||
461 | 461 | endif; |
462 | 462 | |
463 | 463 | // The actual days with numbers and events in each row cell. |
464 | - echo '<td class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
465 | - |
|
466 | - if ( $color ) { |
|
467 | - $day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"'; |
|
468 | - } elseif ( $count > 0 ) { |
|
469 | - $the_color = new Color( $calendar->days_events_color ); |
|
470 | - $color = ! $color ? ( $the_color->isDark() ? '#ffffff' : '#000000' ) : $color; |
|
471 | - $bg_color = ! $bg_color ? '#' . $the_color->getHex() : $bg_color; |
|
472 | - $day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"'; |
|
464 | + echo '<td class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
465 | + |
|
466 | + if ($color) { |
|
467 | + $day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"'; |
|
468 | + } elseif ($count > 0) { |
|
469 | + $the_color = new Color($calendar->days_events_color); |
|
470 | + $color = ! $color ? ($the_color->isDark() ? '#ffffff' : '#000000') : $color; |
|
471 | + $bg_color = ! $bg_color ? '#'.$the_color->getHex() : $bg_color; |
|
472 | + $day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"'; |
|
473 | 473 | } else { |
474 | 474 | $day_style = ''; |
475 | 475 | } |
476 | 476 | |
477 | - echo "\t" . '<div' . $border_style . '>' . "\n"; |
|
478 | - echo "\t\t" . '<span class="simcal-day-label simcal-day-number"' . $day_style . '>' . $day . '</span>' . "\n"; |
|
479 | - echo "\t\t" . $list_events . "\n"; |
|
477 | + echo "\t".'<div'.$border_style.'>'."\n"; |
|
478 | + echo "\t\t".'<span class="simcal-day-label simcal-day-number"'.$day_style.'>'.$day.'</span>'."\n"; |
|
479 | + echo "\t\t".$list_events."\n"; |
|
480 | 480 | echo "\t\t"; |
481 | 481 | echo '<span class="simcal-events-dots" style="display: none;">'; |
482 | 482 | |
483 | 483 | // Event bullets for calendar mobile mode. |
484 | - for( $i = 0; $i < $count; $i++ ) { |
|
484 | + for ($i = 0; $i < $count; $i++) { |
|
485 | 485 | echo '<b> • </b>'; |
486 | 486 | } |
487 | 487 | |
488 | - echo '</span>' . "\n"; |
|
489 | - echo "\t" . '</div>' . "\n"; |
|
490 | - echo '</td>' . "\n"; |
|
488 | + echo '</span>'."\n"; |
|
489 | + echo "\t".'</div>'."\n"; |
|
490 | + echo '</td>'."\n"; |
|
491 | 491 | |
492 | 492 | // Reset day of the week count (sun, 0 - sat, 6). |
493 | - if ( $week_day === 6 ) { |
|
493 | + if ($week_day === 6) { |
|
494 | 494 | $week_day = - 1; |
495 | 495 | } |
496 | 496 | $week_day++; |
497 | 497 | |
498 | 498 | // Reset count of days for this row (0-6). |
499 | - if ( $days_in_row === 6 ) : |
|
499 | + if ($days_in_row === 6) : |
|
500 | 500 | |
501 | 501 | // Close the week row. |
502 | 502 | echo '</tr>'; |
503 | 503 | |
504 | 504 | // Open a new week row. |
505 | - if ( $day < $days_in_month ) { |
|
506 | - echo '<tr class="simcal-week simcal-week-' . $week_of_year++ . '">' . "\n"; |
|
505 | + if ($day < $days_in_month) { |
|
506 | + echo '<tr class="simcal-week simcal-week-'.$week_of_year++.'">'."\n"; |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | $days_in_row = -1; |
@@ -512,27 +512,27 @@ discard block |
||
512 | 512 | |
513 | 513 | $days_in_row++; |
514 | 514 | |
515 | - $current_min = Carbon::createFromTimestamp( $current_min, $calendar->timezone )->addDay()->getTimestamp(); |
|
516 | - $current_max = Carbon::createFromTimestamp( $current_max, $calendar->timezone )->addDay()->getTimestamp(); |
|
515 | + $current_min = Carbon::createFromTimestamp($current_min, $calendar->timezone)->addDay()->getTimestamp(); |
|
516 | + $current_max = Carbon::createFromTimestamp($current_max, $calendar->timezone)->addDay()->getTimestamp(); |
|
517 | 517 | |
518 | 518 | endfor; |
519 | 519 | |
520 | 520 | // Void days at the end of the month. |
521 | - $remainder_days = ( 6 - $days_in_row ); |
|
521 | + $remainder_days = (6 - $days_in_row); |
|
522 | 522 | |
523 | - for ( $i = 0; $i <= $remainder_days; $i ++ ) { |
|
523 | + for ($i = 0; $i <= $remainder_days; $i++) { |
|
524 | 524 | |
525 | - $last_void_day_class = ( $i == $remainder_days ) ? 'simcal-day-void-last' : ''; |
|
525 | + $last_void_day_class = ($i == $remainder_days) ? 'simcal-day-void-last' : ''; |
|
526 | 526 | |
527 | - echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n"; |
|
527 | + echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n"; |
|
528 | 528 | |
529 | 529 | $week_day++; |
530 | 530 | } |
531 | 531 | |
532 | - echo "\t" . '</tr>' . "\n"; |
|
533 | - echo '</tbody>' . "\n"; |
|
532 | + echo "\t".'</tr>'."\n"; |
|
533 | + echo '</tbody>'."\n"; |
|
534 | 534 | |
535 | - date_default_timezone_set( $calendar->site_timezone ); |
|
535 | + date_default_timezone_set($calendar->site_timezone); |
|
536 | 536 | |
537 | 537 | return ob_get_clean(); |
538 | 538 | } |
@@ -544,17 +544,17 @@ discard block |
||
544 | 544 | */ |
545 | 545 | public function draw_grid_ajax() { |
546 | 546 | |
547 | - if ( isset( $_POST['month'] ) && isset( $_POST['year'] ) && isset( $_POST['id'] ) ) { |
|
547 | + if (isset($_POST['month']) && isset($_POST['year']) && isset($_POST['id'])) { |
|
548 | 548 | |
549 | - $month = absint( $_POST['month'] ); |
|
550 | - $year = absint( $_POST['year'] ); |
|
551 | - $id = absint( $_POST['id'] ); |
|
549 | + $month = absint($_POST['month']); |
|
550 | + $year = absint($_POST['year']); |
|
551 | + $id = absint($_POST['id']); |
|
552 | 552 | |
553 | - wp_send_json_success( $this->draw_month( $month, $year, $id ) ); |
|
553 | + wp_send_json_success($this->draw_month($month, $year, $id)); |
|
554 | 554 | |
555 | 555 | } else { |
556 | 556 | |
557 | - wp_send_json_error( 'Missing arguments in default calendar grid ajax request.' ); |
|
557 | + wp_send_json_error('Missing arguments in default calendar grid ajax request.'); |
|
558 | 558 | |
559 | 559 | } |
560 | 560 | |
@@ -570,8 +570,8 @@ discard block |
||
570 | 570 | * |
571 | 571 | * @return bool |
572 | 572 | */ |
573 | - private function filter_events_before( $event ) { |
|
574 | - return intval( $event ) > intval( $this->start ); |
|
573 | + private function filter_events_before($event) { |
|
574 | + return intval($event) > intval($this->start); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | * |
585 | 585 | * @return bool |
586 | 586 | */ |
587 | - private function filter_events_after( $event ) { |
|
588 | - return intval( $event ) < intval( $this->end ); |
|
587 | + private function filter_events_after($event) { |
|
588 | + return intval($event) < intval($this->end); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | } |
@@ -453,10 +453,12 @@ |
||
453 | 453 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
454 | 454 | endif; |
455 | 455 | |
456 | - else : |
|
456 | + else { |
|
457 | + : |
|
457 | 458 | |
458 | 459 | // Empty cell for day with no events. |
459 | 460 | $list_events = '<span class="simcal-no-events"></span>'; |
461 | + } |
|
460 | 462 | |
461 | 463 | endif; |
462 | 464 |
@@ -576,9 +576,11 @@ |
||
576 | 576 | |
577 | 577 | endforeach; |
578 | 578 | |
579 | - else : |
|
579 | + else { |
|
580 | + : |
|
580 | 581 | |
581 | 582 | echo "\t" . '<p>'; |
583 | + } |
|
582 | 584 | |
583 | 585 | $message = get_post_meta( $calendar->id, '_no_events_message', true ); |
584 | 586 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | use SimpleCalendar\Calendars\Default_Calendar; |
14 | 14 | use SimpleCalendar\Events\Event; |
15 | 15 | |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string|Calendar $calendar |
73 | 73 | */ |
74 | - public function __construct( $calendar = '' ) { |
|
74 | + public function __construct($calendar = '') { |
|
75 | 75 | $this->calendar = $calendar; |
76 | 76 | } |
77 | 77 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return string |
106 | 106 | */ |
107 | 107 | public function get_name() { |
108 | - return __( 'List', 'google-calendar-events' ); |
|
108 | + return __('List', 'google-calendar-events'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @since 3.0.0 |
115 | 115 | */ |
116 | 116 | public function add_ajax_actions() { |
117 | - add_action( 'wp_ajax_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) ); |
|
118 | - add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) ); |
|
117 | + add_action('wp_ajax_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax')); |
|
118 | + add_action('wp_ajax_nopriv_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax')); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -129,16 +129,16 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public function scripts( $min = '' ) { |
|
132 | + public function scripts($min = '') { |
|
133 | 133 | return array( |
134 | 134 | 'simcal-qtip' => array( |
135 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js', |
|
136 | - 'deps' => array( 'jquery' ), |
|
135 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js', |
|
136 | + 'deps' => array('jquery'), |
|
137 | 137 | 'ver' => '2.2.1', |
138 | 138 | 'in_footer' => true, |
139 | 139 | ), |
140 | 140 | 'simcal-default-calendar' => array( |
141 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js', |
|
141 | + 'src' => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js', |
|
142 | 142 | 'deps' => array( |
143 | 143 | 'jquery', |
144 | 144 | 'simcal-qtip', |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array |
165 | 165 | */ |
166 | - public function styles( $min = '' ) { |
|
166 | + public function styles($min = '') { |
|
167 | 167 | return array( |
168 | 168 | 'simcal-default-calendar-list' => array( |
169 | - 'src' => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $min . '.css', |
|
169 | + 'src' => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$min.'.css', |
|
170 | 170 | 'ver' => SIMPLE_CALENDAR_VERSION, |
171 | 171 | 'media' => 'all', |
172 | 172 | ), |
@@ -182,47 +182,47 @@ discard block |
||
182 | 182 | |
183 | 183 | $calendar = $this->calendar; |
184 | 184 | |
185 | - if ( $calendar instanceof Default_Calendar ) { |
|
185 | + if ($calendar instanceof Default_Calendar) { |
|
186 | 186 | |
187 | 187 | $disabled = $calendar->static === true ? ' disabled="disabled"' : ''; |
188 | 188 | |
189 | 189 | |
190 | - $hide_header = get_post_meta( $this->calendar->id, '_default_calendar_list_header', true ) == 'yes' ? true : false; |
|
191 | - $static_calendar = get_post_meta( $this->calendar->id, '_calendar_is_static', true ) == 'yes' ? true : false; |
|
190 | + $hide_header = get_post_meta($this->calendar->id, '_default_calendar_list_header', true) == 'yes' ? true : false; |
|
191 | + $static_calendar = get_post_meta($this->calendar->id, '_calendar_is_static', true) == 'yes' ? true : false; |
|
192 | 192 | |
193 | 193 | $header_class = ''; |
194 | 194 | $compact_list_class = $calendar->compact_list ? 'simcal-calendar-list-compact' : ''; |
195 | 195 | |
196 | - echo '<div class="simcal-calendar-list ' . $compact_list_class . '">'; |
|
196 | + echo '<div class="simcal-calendar-list '.$compact_list_class.'">'; |
|
197 | 197 | |
198 | - if ( ! $hide_header && ! $static_calendar ) { |
|
199 | - echo '<nav class="simcal-calendar-head">' . "\n"; |
|
198 | + if ( ! $hide_header && ! $static_calendar) { |
|
199 | + echo '<nav class="simcal-calendar-head">'."\n"; |
|
200 | 200 | |
201 | - echo "\t" . '<div class="simcal-nav">' . "\n"; |
|
202 | - echo "\t\t" . '<button class="simcal-nav-button simcal-prev" title="' . __('Previous', 'google-calendar-events') . '"' . $disabled . '>' . "\n"; |
|
203 | - echo "\t\t\t" . '<i class="simcal-icon-left"></i>' . "\n"; |
|
204 | - echo "\t\t" . '</button>' . "\n"; |
|
205 | - echo "\t" . '</div>' . "\n"; |
|
201 | + echo "\t".'<div class="simcal-nav">'."\n"; |
|
202 | + echo "\t\t".'<button class="simcal-nav-button simcal-prev" title="'.__('Previous', 'google-calendar-events').'"'.$disabled.'>'."\n"; |
|
203 | + echo "\t\t\t".'<i class="simcal-icon-left"></i>'."\n"; |
|
204 | + echo "\t\t".'</button>'."\n"; |
|
205 | + echo "\t".'</div>'."\n"; |
|
206 | 206 | |
207 | - if ( $hide_header ) { |
|
207 | + if ($hide_header) { |
|
208 | 208 | $header_class = 'simcal-hide-header'; |
209 | 209 | } |
210 | 210 | |
211 | 211 | |
212 | - echo "\t" . '<div class="simcal-nav simcal-current ' . $header_class . '" data-calendar-current="' . $calendar->start . '">' . "\n"; |
|
213 | - echo "\t\t" . '<h3 class="simcal-current-label"> </h3>' . "\n"; |
|
214 | - echo "\t" . '</div>' . "\n"; |
|
212 | + echo "\t".'<div class="simcal-nav simcal-current '.$header_class.'" data-calendar-current="'.$calendar->start.'">'."\n"; |
|
213 | + echo "\t\t".'<h3 class="simcal-current-label"> </h3>'."\n"; |
|
214 | + echo "\t".'</div>'."\n"; |
|
215 | 215 | |
216 | - echo "\t" . '<div class="simcal-nav">'; |
|
217 | - echo "\t\t" . '<button class="simcal-nav-button simcal-next" title="' . __('Next', 'google-calendar-events') . '"' . $disabled . '>'; |
|
218 | - echo "\t\t\t" . '<i class="simcal-icon-right"></i>' . "\n"; |
|
219 | - echo "\t\t" . '</button>' . "\n"; |
|
220 | - echo "\t" . '</div>' . "\n"; |
|
216 | + echo "\t".'<div class="simcal-nav">'; |
|
217 | + echo "\t\t".'<button class="simcal-nav-button simcal-next" title="'.__('Next', 'google-calendar-events').'"'.$disabled.'>'; |
|
218 | + echo "\t\t\t".'<i class="simcal-icon-right"></i>'."\n"; |
|
219 | + echo "\t\t".'</button>'."\n"; |
|
220 | + echo "\t".'</div>'."\n"; |
|
221 | 221 | |
222 | - echo '</nav>' . "\n"; |
|
222 | + echo '</nav>'."\n"; |
|
223 | 223 | } |
224 | 224 | |
225 | - echo $this->draw_list( $calendar->start ); |
|
225 | + echo $this->draw_list($calendar->start); |
|
226 | 226 | |
227 | 227 | echo '<div class="simcal-ajax-loader simcal-spinner-top" style="display: none;"><i class="simcal-icon-spinner simcal-icon-spin"></i></div>'; |
228 | 228 | |
@@ -241,92 +241,92 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return array |
243 | 243 | */ |
244 | - private function get_events( $timestamp ) { |
|
244 | + private function get_events($timestamp) { |
|
245 | 245 | |
246 | 246 | $calendar = $this->calendar; |
247 | 247 | $timezone = $calendar->timezone; |
248 | 248 | |
249 | - if ( ! $calendar->group_type || ! $calendar->group_span ) { |
|
249 | + if ( ! $calendar->group_type || ! $calendar->group_span) { |
|
250 | 250 | return array(); |
251 | 251 | } |
252 | 252 | |
253 | - $current = Carbon::createFromTimestamp( $timestamp, $timezone ); |
|
253 | + $current = Carbon::createFromTimestamp($timestamp, $timezone); |
|
254 | 254 | $prev = clone $current; |
255 | 255 | $next = clone $current; |
256 | 256 | |
257 | 257 | $this->start = $current->getTimestamp(); |
258 | 258 | |
259 | - $interval = $span = max( absint( $calendar->group_span ), 1 ); |
|
260 | - |
|
261 | - if ( 'monthly' == $calendar->group_type ) { |
|
262 | - $this->prev = $prev->subMonths( $span )->getTimestamp(); |
|
263 | - $this->next = $next->addMonths( $span )->getTimestamp(); |
|
264 | - } elseif ( 'weekly' == $calendar->group_type ) { |
|
265 | - $week = new Carbon( $calendar->timezone ); |
|
266 | - $week->setTimestamp( $timestamp ); |
|
267 | - $week->setWeekStartsAt( $calendar->week_starts ); |
|
268 | - $this->prev = $prev->subWeeks( $span )->getTimestamp(); |
|
269 | - $this->next = $next->addWeeks( $span )->getTimestamp(); |
|
270 | - } elseif ( 'daily' == $calendar->group_type ) { |
|
271 | - $this->prev = $prev->subDays( $span )->getTimestamp(); |
|
272 | - $this->next = $next->addDays( $span )->getTimestamp(); |
|
259 | + $interval = $span = max(absint($calendar->group_span), 1); |
|
260 | + |
|
261 | + if ('monthly' == $calendar->group_type) { |
|
262 | + $this->prev = $prev->subMonths($span)->getTimestamp(); |
|
263 | + $this->next = $next->addMonths($span)->getTimestamp(); |
|
264 | + } elseif ('weekly' == $calendar->group_type) { |
|
265 | + $week = new Carbon($calendar->timezone); |
|
266 | + $week->setTimestamp($timestamp); |
|
267 | + $week->setWeekStartsAt($calendar->week_starts); |
|
268 | + $this->prev = $prev->subWeeks($span)->getTimestamp(); |
|
269 | + $this->next = $next->addWeeks($span)->getTimestamp(); |
|
270 | + } elseif ('daily' == $calendar->group_type) { |
|
271 | + $this->prev = $prev->subDays($span)->getTimestamp(); |
|
272 | + $this->next = $next->addDays($span)->getTimestamp(); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | $events = $calendar->events; |
276 | 276 | $daily_events = $paged_events = $flattened_events = array(); |
277 | 277 | |
278 | - if ( 'events' != $calendar->group_type ) { |
|
278 | + if ('events' != $calendar->group_type) { |
|
279 | 279 | |
280 | - $this->end = $this->next - 1; |
|
280 | + $this->end = $this->next - 1; |
|
281 | 281 | |
282 | - $timestamps = array_keys( $events ); |
|
283 | - $lower_bound = array_filter( $timestamps, array( $this, 'filter_events_before' ) ); |
|
284 | - $higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) ); |
|
282 | + $timestamps = array_keys($events); |
|
283 | + $lower_bound = array_filter($timestamps, array($this, 'filter_events_before')); |
|
284 | + $higher_bound = array_filter($lower_bound, array($this, 'filter_events_after')); |
|
285 | 285 | |
286 | - if ( is_array( $higher_bound ) && !empty( $higher_bound ) ) { |
|
287 | - $filtered = array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ); |
|
288 | - foreach ( $filtered as $timestamp => $events ) { |
|
289 | - $paged_events[ intval( $timestamp ) ] = $events; |
|
286 | + if (is_array($higher_bound) && ! empty($higher_bound)) { |
|
287 | + $filtered = array_intersect_key($events, array_combine($higher_bound, $higher_bound)); |
|
288 | + foreach ($filtered as $timestamp => $events) { |
|
289 | + $paged_events[intval($timestamp)] = $events; |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | 293 | } else { |
294 | 294 | |
295 | - foreach ( $events as $timestamp => $e ) { |
|
295 | + foreach ($events as $timestamp => $e) { |
|
296 | 296 | $second = 0; |
297 | - foreach ( $e as $event ) { |
|
298 | - $flattened_events[ intval( $timestamp + $second ) ][] = $event; |
|
297 | + foreach ($e as $event) { |
|
298 | + $flattened_events[intval($timestamp + $second)][] = $event; |
|
299 | 299 | $second++; |
300 | 300 | } |
301 | 301 | } |
302 | - ksort( $flattened_events, SORT_NUMERIC ); |
|
302 | + ksort($flattened_events, SORT_NUMERIC); |
|
303 | 303 | |
304 | - $keys = array_keys( $flattened_events ); |
|
304 | + $keys = array_keys($flattened_events); |
|
305 | 305 | $current = 0; |
306 | - foreach ( $keys as $timestamp ) { |
|
307 | - if ( $timestamp <= $this->start ) { |
|
306 | + foreach ($keys as $timestamp) { |
|
307 | + if ($timestamp <= $this->start) { |
|
308 | 308 | $current++; |
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | - $paged_events = array_slice( $flattened_events, $current, $interval, true ); |
|
312 | + $paged_events = array_slice($flattened_events, $current, $interval, true); |
|
313 | 313 | |
314 | - $events_end = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $calendar->end; |
|
314 | + $events_end = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $calendar->end; |
|
315 | 315 | $this->end = $events_end > $calendar->end ? $calendar->end : $events_end; |
316 | 316 | // -1 adjusts the interval count to index count, which starts at 0. |
317 | - $this->prev = isset( $keys[ $current - $interval - 1 ] ) ? $keys[ $current - $interval - 1 ] : $calendar->earliest_event; |
|
318 | - $this->next = isset( $keys[ $current + $interval - 1 ] ) ? $keys[ $current + $interval - 1 ] : $this->end; |
|
317 | + $this->prev = isset($keys[$current - $interval - 1]) ? $keys[$current - $interval - 1] : $calendar->earliest_event; |
|
318 | + $this->next = isset($keys[$current + $interval - 1]) ? $keys[$current + $interval - 1] : $this->end; |
|
319 | 319 | |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Put resulting events in an associative array, with Ymd date as key for easy retrieval in calendar days loop. |
323 | - foreach ( $paged_events as $timestamp => $events ) { |
|
324 | - if ( $timestamp <= $this->end ) { |
|
325 | - $date = Carbon::createFromTimestamp( $timestamp, $calendar->timezone )->endOfDay()->format( 'Ymd' ); |
|
326 | - $daily_events[ intval( $date ) ][] = $events; |
|
323 | + foreach ($paged_events as $timestamp => $events) { |
|
324 | + if ($timestamp <= $this->end) { |
|
325 | + $date = Carbon::createFromTimestamp($timestamp, $calendar->timezone)->endOfDay()->format('Ymd'); |
|
326 | + $daily_events[intval($date)][] = $events; |
|
327 | 327 | } |
328 | 328 | } |
329 | - ksort( $daily_events, SORT_NUMERIC ); |
|
329 | + ksort($daily_events, SORT_NUMERIC); |
|
330 | 330 | |
331 | 331 | return $daily_events; |
332 | 332 | } |
@@ -344,71 +344,71 @@ discard block |
||
344 | 344 | private function get_heading() { |
345 | 345 | |
346 | 346 | $calendar = $this->calendar; |
347 | - $start = Carbon::createFromTimestamp( $this->start, $calendar->timezone ); |
|
348 | - $end = Carbon::createFromTimestamp( $this->end, $calendar->timezone ); |
|
347 | + $start = Carbon::createFromTimestamp($this->start, $calendar->timezone); |
|
348 | + $end = Carbon::createFromTimestamp($this->end, $calendar->timezone); |
|
349 | 349 | $date_format = $this->calendar->date_format; |
350 | - $date_order = simcal_get_date_format_order( $date_format ); |
|
350 | + $date_order = simcal_get_date_format_order($date_format); |
|
351 | 351 | |
352 | - if ( ( $start->day == $end->day ) && ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
352 | + if (($start->day == $end->day) && ($start->month == $end->month) && ($start->year == $end->year)) { |
|
353 | 353 | // Start and end on the same day. |
354 | 354 | // e.g. 1 February 2020 |
355 | - $large = $small = date_i18n( $calendar->date_format , $this->start ); |
|
356 | - if ( ( $date_order['d'] !== false ) && ( $date_order['m'] !== false ) ) { |
|
357 | - if ( $date_order['m'] > $date_order['d'] ) { |
|
358 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
359 | - $small = date_i18n( 'Y, d M', $this->start ); |
|
355 | + $large = $small = date_i18n($calendar->date_format, $this->start); |
|
356 | + if (($date_order['d'] !== false) && ($date_order['m'] !== false)) { |
|
357 | + if ($date_order['m'] > $date_order['d']) { |
|
358 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
359 | + $small = date_i18n('Y, d M', $this->start); |
|
360 | 360 | } else { |
361 | - $small = date_i18n( 'd M Y', $this->start ); |
|
361 | + $small = date_i18n('d M Y', $this->start); |
|
362 | 362 | } |
363 | 363 | } else { |
364 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
365 | - $small = date_i18n( 'Y, M d', $this->start ); |
|
364 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
365 | + $small = date_i18n('Y, M d', $this->start); |
|
366 | 366 | } else { |
367 | - $small = date_i18n( 'M d Y', $this->start ); |
|
367 | + $small = date_i18n('M d Y', $this->start); |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | } |
371 | - } elseif ( ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
371 | + } elseif (($start->month == $end->month) && ($start->year == $end->year)) { |
|
372 | 372 | // Start and end days on the same month. |
373 | 373 | // e.g. August 2020 |
374 | - if ( $date_order['y'] === false ) { |
|
374 | + if ($date_order['y'] === false) { |
|
375 | 375 | // August. |
376 | - $large = $small = date_i18n( 'F', $this->start ); |
|
376 | + $large = $small = date_i18n('F', $this->start); |
|
377 | 377 | } else { |
378 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
378 | + if ($date_order['y'] < $date_order['m']) { |
|
379 | 379 | // 2020 August. |
380 | - $large = date_i18n( 'Y F', $this->start ); |
|
381 | - $small = date_i18n( 'Y M', $this->start ); |
|
380 | + $large = date_i18n('Y F', $this->start); |
|
381 | + $small = date_i18n('Y M', $this->start); |
|
382 | 382 | } else { |
383 | 383 | // August 2020. |
384 | - $large = date_i18n( 'F Y', $this->start ); |
|
385 | - $small = date_i18n( 'M Y', $this->start ); |
|
384 | + $large = date_i18n('F Y', $this->start); |
|
385 | + $small = date_i18n('M Y', $this->start); |
|
386 | 386 | } |
387 | 387 | } |
388 | - } elseif ( $start->year == $end->year ) { |
|
388 | + } elseif ($start->year == $end->year) { |
|
389 | 389 | // Start and end days on months of the same year. |
390 | 390 | // e.g. August - September 2020 |
391 | - if ( $date_order['y'] === false ) { |
|
391 | + if ($date_order['y'] === false) { |
|
392 | 392 | // August - September. |
393 | - $large = date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ); |
|
394 | - $small = date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ); |
|
393 | + $large = date_i18n('F', $this->start).' - '.date_i18n('F', $this->end); |
|
394 | + $small = date_i18n('M', $this->start).' - '.date_i18n('M', $this->end); |
|
395 | 395 | } else { |
396 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
396 | + if ($date_order['y'] < $date_order['m']) { |
|
397 | 397 | // 2020, August - September. |
398 | - $large = $small = date( 'Y', $this->start ) . ', '; |
|
399 | - $large .= date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ); |
|
400 | - $small .= date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ); |
|
398 | + $large = $small = date('Y', $this->start).', '; |
|
399 | + $large .= date_i18n('F', $this->start).' - '.date_i18n('F', $this->end); |
|
400 | + $small .= date_i18n('M', $this->start).' - '.date_i18n('M', $this->end); |
|
401 | 401 | } else { |
402 | 402 | // August - September, 2020. |
403 | - $large = date_i18n( 'F', $this->start ) . ' - ' . date_i18n( 'F', $this->end ) . ', '; |
|
404 | - $small = date_i18n( 'M', $this->start ) . ' - ' . date_i18n( 'M', $this->end ) . ' '; |
|
405 | - $year = date( 'Y', $this->start ); |
|
403 | + $large = date_i18n('F', $this->start).' - '.date_i18n('F', $this->end).', '; |
|
404 | + $small = date_i18n('M', $this->start).' - '.date_i18n('M', $this->end).' '; |
|
405 | + $year = date('Y', $this->start); |
|
406 | 406 | $large .= $year; |
407 | 407 | $small .= $year; |
408 | 408 | } |
409 | 409 | } |
410 | 410 | } else { |
411 | - $large = $small = date( 'Y', $this->start ) . ' - ' . date( 'Y', $this->end ); |
|
411 | + $large = $small = date('Y', $this->start).' - '.date('Y', $this->end); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | return array( |
@@ -430,105 +430,105 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @return string |
432 | 432 | */ |
433 | - private function draw_list( $timestamp, $id = 0 ) { |
|
433 | + private function draw_list($timestamp, $id = 0) { |
|
434 | 434 | |
435 | 435 | $calendar = $this->calendar; |
436 | 436 | |
437 | - if ( empty( $calendar ) ) { |
|
438 | - $calendar = $this->calendar = simcal_get_calendar( intval( $id ) ); |
|
439 | - if ( ! $calendar instanceof Default_Calendar ) { |
|
437 | + if (empty($calendar)) { |
|
438 | + $calendar = $this->calendar = simcal_get_calendar(intval($id)); |
|
439 | + if ( ! $calendar instanceof Default_Calendar) { |
|
440 | 440 | return ''; |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | - date_default_timezone_set( $calendar->timezone ); |
|
444 | + date_default_timezone_set($calendar->timezone); |
|
445 | 445 | |
446 | 446 | $now = $calendar->now; |
447 | - $current_events = $this->get_events( $timestamp ); |
|
448 | - $day_format = explode( ' ', $calendar->date_format ); |
|
447 | + $current_events = $this->get_events($timestamp); |
|
448 | + $day_format = explode(' ', $calendar->date_format); |
|
449 | 449 | |
450 | 450 | ob_start(); |
451 | 451 | |
452 | 452 | // Draw the events. |
453 | 453 | |
454 | - $block_tag = $calendar->compact_list && ! empty( $current_events ) ? 'div' : 'dl'; |
|
454 | + $block_tag = $calendar->compact_list && ! empty($current_events) ? 'div' : 'dl'; |
|
455 | 455 | |
456 | 456 | $data_heading = ''; |
457 | 457 | $heading = $this->get_heading(); |
458 | - foreach ( $heading as $k => $v ) { |
|
459 | - $data_heading .= ' data-heading-' . $k . '="' . $v . '"'; |
|
458 | + foreach ($heading as $k => $v) { |
|
459 | + $data_heading .= ' data-heading-'.$k.'="'.$v.'"'; |
|
460 | 460 | } |
461 | 461 | |
462 | - echo '<' . $block_tag . ' class="simcal-events-list-container"' . |
|
463 | - ' data-prev="' . $this->prev . '"' . |
|
464 | - ' data-next="' . $this->next . '"' . |
|
465 | - $data_heading . '>'; |
|
462 | + echo '<'.$block_tag.' class="simcal-events-list-container"'. |
|
463 | + ' data-prev="'.$this->prev.'"'. |
|
464 | + ' data-next="'.$this->next.'"'. |
|
465 | + $data_heading.'>'; |
|
466 | 466 | |
467 | - if ( ! empty( $current_events ) && is_array( $current_events ) ) : |
|
467 | + if ( ! empty($current_events) && is_array($current_events)) : |
|
468 | 468 | |
469 | - foreach ( $current_events as $ymd => $events ) : |
|
469 | + foreach ($current_events as $ymd => $events) : |
|
470 | 470 | |
471 | - $day_ts = Carbon::createFromFormat( 'Ymd', $ymd, $calendar->timezone )->getTimestamp(); |
|
471 | + $day_ts = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone)->getTimestamp(); |
|
472 | 472 | |
473 | - if ( ! $calendar->compact_list ) : |
|
473 | + if ( ! $calendar->compact_list) : |
|
474 | 474 | |
475 | - $date = new Carbon( 'now', $calendar->timezone ); |
|
476 | - $date->setLocale( substr( get_locale(), 0, 2 ) ); |
|
477 | - $date->setTimestamp( $day_ts ); |
|
475 | + $date = new Carbon('now', $calendar->timezone); |
|
476 | + $date->setLocale(substr(get_locale(), 0, 2)); |
|
477 | + $date->setTimestamp($day_ts); |
|
478 | 478 | |
479 | - if ( $date->isToday() ) { |
|
480 | - $the_color = new Color( $calendar->today_color ); |
|
479 | + if ($date->isToday()) { |
|
480 | + $the_color = new Color($calendar->today_color); |
|
481 | 481 | } else { |
482 | - $the_color = new Color( $calendar->days_events_color ); |
|
482 | + $the_color = new Color($calendar->days_events_color); |
|
483 | 483 | } |
484 | 484 | |
485 | - $bg_color = '#' . $the_color->getHex(); |
|
485 | + $bg_color = '#'.$the_color->getHex(); |
|
486 | 486 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
487 | - $border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" '; |
|
488 | - $bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"'; |
|
487 | + $border_style = ' style="border-bottom: 1px solid '.$bg_color.';" '; |
|
488 | + $bg_style = ' style="background-color: '.$bg_color.'; color: '.$color.';"'; |
|
489 | 489 | |
490 | - echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>'; |
|
491 | - echo '<span' . $bg_style .'>'; |
|
492 | - foreach ( $day_format as $format ) { |
|
493 | - echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n( $format, $day_ts ) . '</span> ' : ' '; |
|
490 | + echo "\t".'<dt class="simcal-day-label"'.$border_style.'>'; |
|
491 | + echo '<span'.$bg_style.'>'; |
|
492 | + foreach ($day_format as $format) { |
|
493 | + echo $format ? '<span class="simcal-date-format" data-date-format="'.$format.'">'.date_i18n($format, $day_ts).'</span> ' : ' '; |
|
494 | 494 | } |
495 | 495 | echo '</span>'; |
496 | - echo '</dt>' . "\n"; |
|
496 | + echo '</dt>'."\n"; |
|
497 | 497 | |
498 | 498 | endif; |
499 | 499 | |
500 | - $list_events = '<ul class="simcal-events">' . "\n"; |
|
500 | + $list_events = '<ul class="simcal-events">'."\n"; |
|
501 | 501 | |
502 | 502 | $calendar_classes = array(); |
503 | - $day_classes = 'simcal-weekday-' . date( 'w', $day_ts ); |
|
503 | + $day_classes = 'simcal-weekday-'.date('w', $day_ts); |
|
504 | 504 | |
505 | 505 | // Is this the present, the past or the future, Doc? |
506 | - if ( $timestamp <= $now && $timestamp >= $now ) { |
|
506 | + if ($timestamp <= $now && $timestamp >= $now) { |
|
507 | 507 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
508 | - } elseif ( $timestamp < $now ) { |
|
508 | + } elseif ($timestamp < $now) { |
|
509 | 509 | $day_classes .= ' simcal-past simcal-day'; |
510 | - } elseif ( $this->end > $now ) { |
|
510 | + } elseif ($this->end > $now) { |
|
511 | 511 | $day_classes .= ' simcal-future simcal-day'; |
512 | 512 | } |
513 | 513 | |
514 | 514 | $count = 0; |
515 | 515 | |
516 | - foreach ( $events as $day_events ) : |
|
517 | - foreach ( $day_events as $event ) : |
|
518 | - if ( $event instanceof Event ) : |
|
516 | + foreach ($events as $day_events) : |
|
517 | + foreach ($day_events as $event) : |
|
518 | + if ($event instanceof Event) : |
|
519 | 519 | |
520 | 520 | $event_classes = $event_visibility = ''; |
521 | 521 | |
522 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
522 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
523 | 523 | $calendar_classes[] = $calendar_class; |
524 | 524 | |
525 | 525 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
526 | 526 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
527 | 527 | |
528 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class; |
|
528 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class; |
|
529 | 529 | |
530 | 530 | // Toggle some events visibility if more than optional limit. |
531 | - if ( ( $calendar->events_limit > - 1 ) && ( $count >= $calendar->events_limit ) ) : |
|
531 | + if (($calendar->events_limit > - 1) && ($count >= $calendar->events_limit)) : |
|
532 | 532 | $event_classes .= ' simcal-event-toggled'; |
533 | 533 | $event_visibility = ' style="display: none"'; |
534 | 534 | endif; |
@@ -536,75 +536,75 @@ discard block |
||
536 | 536 | $event_color = ''; |
537 | 537 | $bullet = ''; |
538 | 538 | $event_color = $event->get_color(); |
539 | - if ( ! empty( $event_color ) ) { |
|
539 | + if ( ! empty($event_color)) { |
|
540 | 540 | $side = is_rtl() ? 'right' : 'left'; |
541 | - $event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"'; |
|
541 | + $event_color = ' style="border-'.$side.': 4px solid '.$event_color.'; padding-'.$side.': 8px;"'; |
|
542 | 542 | } |
543 | 543 | |
544 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemprop="event" itemscope itemtype="http://schema.org/Event">' . "\n"; |
|
545 | - $list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
546 | - $list_events .= "\t" . '</li>' . "\n"; |
|
544 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.$event_color.' itemprop="event" itemscope itemtype="http://schema.org/Event">'."\n"; |
|
545 | + $list_events .= "\t\t".'<div class="simcal-event-details">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
546 | + $list_events .= "\t".'</li>'."\n"; |
|
547 | 547 | |
548 | - $count ++; |
|
548 | + $count++; |
|
549 | 549 | |
550 | 550 | // Event falls within today. |
551 | - if ( ( $this->end <= $now ) && ( $this->start >= $now ) ) : |
|
551 | + if (($this->end <= $now) && ($this->start >= $now)) : |
|
552 | 552 | $day_classes .= ' simcal-today-has-events'; |
553 | 553 | endif; |
554 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
554 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
555 | 555 | |
556 | - if ( $calendar_classes ) : |
|
557 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
556 | + if ($calendar_classes) : |
|
557 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
558 | 558 | endif; |
559 | 559 | |
560 | 560 | endif; |
561 | 561 | endforeach; |
562 | 562 | endforeach; |
563 | 563 | |
564 | - $list_events .= '</ul>' . "\n"; |
|
564 | + $list_events .= '</ul>'."\n"; |
|
565 | 565 | |
566 | 566 | // If events visibility is limited, print the button toggle. |
567 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
567 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
568 | 568 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
569 | 569 | endif; |
570 | 570 | |
571 | 571 | // Print final list of events for the current day. |
572 | 572 | $tag = $calendar->compact_list ? 'div' : 'dd'; |
573 | - echo '<' . $tag . ' class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
574 | - echo "\t" . $list_events . "\n"; |
|
575 | - echo '</' . $tag . '>' . "\n"; |
|
573 | + echo '<'.$tag.' class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
574 | + echo "\t".$list_events."\n"; |
|
575 | + echo '</'.$tag.'>'."\n"; |
|
576 | 576 | |
577 | 577 | endforeach; |
578 | 578 | |
579 | 579 | else : |
580 | 580 | |
581 | - echo "\t" . '<p>'; |
|
581 | + echo "\t".'<p>'; |
|
582 | 582 | |
583 | - $message = get_post_meta( $calendar->id, '_no_events_message', true ); |
|
583 | + $message = get_post_meta($calendar->id, '_no_events_message', true); |
|
584 | 584 | |
585 | - if ( 'events' == $calendar->group_type ) { |
|
586 | - echo ! empty( $message ) ? $message : __( 'Nothing to show.', 'google-calendar-events' ); |
|
585 | + if ('events' == $calendar->group_type) { |
|
586 | + echo ! empty($message) ? $message : __('Nothing to show.', 'google-calendar-events'); |
|
587 | 587 | } else { |
588 | - if ( ! empty( $message ) ) { |
|
588 | + if ( ! empty($message)) { |
|
589 | 589 | echo $message; |
590 | 590 | } else { |
591 | - $from = Carbon::createFromTimestamp( $this->start, $calendar->timezone )->getTimestamp(); |
|
592 | - $to = Carbon::createFromTimestamp( $this->end, $calendar->timezone )->getTimestamp(); |
|
593 | - echo apply_filters( 'simcal_no_events_message', sprintf( |
|
594 | - __( 'Nothing from %1$s to %2$s.', 'google-calendar-events' ), |
|
595 | - date_i18n( $calendar->date_format, $from ), |
|
596 | - date_i18n( $calendar->date_format, $to ) |
|
597 | - ), $calendar->id, $from, $to ); |
|
591 | + $from = Carbon::createFromTimestamp($this->start, $calendar->timezone)->getTimestamp(); |
|
592 | + $to = Carbon::createFromTimestamp($this->end, $calendar->timezone)->getTimestamp(); |
|
593 | + echo apply_filters('simcal_no_events_message', sprintf( |
|
594 | + __('Nothing from %1$s to %2$s.', 'google-calendar-events'), |
|
595 | + date_i18n($calendar->date_format, $from), |
|
596 | + date_i18n($calendar->date_format, $to) |
|
597 | + ), $calendar->id, $from, $to); |
|
598 | 598 | } |
599 | 599 | } |
600 | 600 | |
601 | - echo "\t" . '</p>' . "\n"; |
|
601 | + echo "\t".'</p>'."\n"; |
|
602 | 602 | |
603 | 603 | endif; |
604 | 604 | |
605 | - echo '</' . $block_tag . '>'; |
|
605 | + echo '</'.$block_tag.'>'; |
|
606 | 606 | |
607 | - date_default_timezone_set( $calendar->site_timezone ); |
|
607 | + date_default_timezone_set($calendar->site_timezone); |
|
608 | 608 | |
609 | 609 | return ob_get_clean(); |
610 | 610 | } |
@@ -616,16 +616,16 @@ discard block |
||
616 | 616 | */ |
617 | 617 | public function draw_list_ajax() { |
618 | 618 | |
619 | - if ( isset( $_POST['ts'] ) && isset( $_POST['id'] ) ) { |
|
619 | + if (isset($_POST['ts']) && isset($_POST['id'])) { |
|
620 | 620 | |
621 | - $ts = absint( $_POST['ts'] ); |
|
622 | - $id = absint( $_POST['id'] ); |
|
621 | + $ts = absint($_POST['ts']); |
|
622 | + $id = absint($_POST['id']); |
|
623 | 623 | |
624 | - wp_send_json_success( $this->draw_list( $ts, $id ) ); |
|
624 | + wp_send_json_success($this->draw_list($ts, $id)); |
|
625 | 625 | |
626 | 626 | } else { |
627 | 627 | |
628 | - wp_send_json_error( 'Missing arguments in default calendar list ajax request.' ); |
|
628 | + wp_send_json_error('Missing arguments in default calendar list ajax request.'); |
|
629 | 629 | |
630 | 630 | } |
631 | 631 | } |
@@ -640,8 +640,8 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @return bool |
642 | 642 | */ |
643 | - private function filter_events_before( $event ) { |
|
644 | - return intval( $event ) > intval( $this->start ); |
|
643 | + private function filter_events_before($event) { |
|
644 | + return intval($event) > intval($this->start); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
@@ -654,8 +654,8 @@ discard block |
||
654 | 654 | * |
655 | 655 | * @return bool |
656 | 656 | */ |
657 | - private function filter_events_after( $event ) { |
|
658 | - return intval( $event ) < intval( $this->end ); |
|
657 | + private function filter_events_after($event) { |
|
658 | + return intval($event) < intval($this->end); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | } |
@@ -590,21 +590,21 @@ discard block |
||
590 | 590 | if ( ! $event->whole_day ) { |
591 | 591 | |
592 | 592 | $time_start = $this->calendar->datetime_separator . |
593 | - ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
594 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
595 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
596 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
597 | - date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
598 | - '</span> '; |
|
593 | + ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
594 | + 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
595 | + 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
596 | + 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
597 | + date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
598 | + '</span> '; |
|
599 | 599 | |
600 | 600 | if ( $end instanceof Carbon ) { |
601 | 601 | |
602 | 602 | $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . |
603 | - 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
604 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
605 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
606 | - date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
607 | - '</span> '; |
|
603 | + 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
604 | + 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
605 | + 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
606 | + date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
607 | + '</span> '; |
|
608 | 608 | |
609 | 609 | } |
610 | 610 | |
@@ -613,23 +613,23 @@ discard block |
||
613 | 613 | if ( $event->multiple_days ) { |
614 | 614 | |
615 | 615 | $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
616 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
617 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
618 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
619 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
620 | - '</span> ' . |
|
621 | - $time_start; |
|
616 | + 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
617 | + 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
618 | + 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
619 | + date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
620 | + '</span> ' . |
|
621 | + $time_start; |
|
622 | 622 | |
623 | 623 | if ( $end instanceof Carbon ) { |
624 | 624 | |
625 | 625 | $output .= '-' . |
626 | - ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
627 | - 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
628 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
629 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
630 | - date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
631 | - '</span> ' . |
|
632 | - $time_end; |
|
626 | + ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
627 | + 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
628 | + 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
629 | + 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
630 | + date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
631 | + '</span> ' . |
|
632 | + $time_end; |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | } else { |
@@ -637,12 +637,12 @@ discard block |
||
637 | 637 | $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
638 | 638 | |
639 | 639 | $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
640 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
641 | - 'data-event-format="' . $this->calendar->date_format . '">' . |
|
642 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
643 | - '</span> ' . |
|
644 | - $time_start . |
|
645 | - $time_end; |
|
640 | + 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
641 | + 'data-event-format="' . $this->calendar->date_format . '">' . |
|
642 | + date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
643 | + '</span> ' . |
|
644 | + $time_start . |
|
645 | + $time_end; |
|
646 | 646 | |
647 | 647 | } |
648 | 648 | |
@@ -695,11 +695,11 @@ discard block |
||
695 | 695 | } |
696 | 696 | |
697 | 697 | return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '"' . |
698 | - 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '"' . |
|
699 | - 'data-event-format="' . $dt_format . '"' . |
|
700 | - 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . |
|
701 | - $value . |
|
702 | - '</span>'; |
|
698 | + 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '"' . |
|
699 | + 'data-event-format="' . $dt_format . '"' . |
|
700 | + 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . |
|
701 | + $value . |
|
702 | + '</span>'; |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
@@ -918,35 +918,35 @@ discard block |
||
918 | 918 | $tagregexp = implode( '|', array_values( $this->tags ) ); |
919 | 919 | |
920 | 920 | return '/' |
921 | - . '\\[' // Opening bracket |
|
922 | - . '(\\[?)' // 1: Optional second opening bracket for escaping tags: [[tag]] |
|
923 | - . "($tagregexp)" // 2: Tag name |
|
924 | - . '(?![\\w-])' // Not followed by word character or hyphen |
|
925 | - . '(' // 3: Unroll the loop: Inside the opening tag |
|
926 | - . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
927 | - . '(?:' |
|
928 | - . '\\/(?!\\])' // A forward slash not followed by a closing bracket |
|
929 | - . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
930 | - . ')*?' |
|
931 | - . ')' |
|
932 | - . '(?:' |
|
933 | - . '(\\/)' // 4: Self closing tag ... |
|
934 | - . '\\]' // ... and closing bracket |
|
935 | - . '|' |
|
936 | - . '\\]' // Closing bracket |
|
937 | - . '(?:' |
|
938 | - . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing tags |
|
939 | - . '[^\\[]*+' // Not an opening bracket |
|
940 | - . '(?:' |
|
941 | - . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag |
|
942 | - . '[^\\[]*+' // Not an opening bracket |
|
943 | - . ')*+' |
|
944 | - . ')' |
|
945 | - . '\\[\\/\\2\\]' // Closing tag |
|
946 | - . ')?' |
|
947 | - . ')' |
|
948 | - . '(\\]?)' // 6: Optional second closing bracket for escaping tags: [[tag]] |
|
949 | - . '/s'; |
|
921 | + . '\\[' // Opening bracket |
|
922 | + . '(\\[?)' // 1: Optional second opening bracket for escaping tags: [[tag]] |
|
923 | + . "($tagregexp)" // 2: Tag name |
|
924 | + . '(?![\\w-])' // Not followed by word character or hyphen |
|
925 | + . '(' // 3: Unroll the loop: Inside the opening tag |
|
926 | + . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
927 | + . '(?:' |
|
928 | + . '\\/(?!\\])' // A forward slash not followed by a closing bracket |
|
929 | + . '[^\\]\\/]*' // Not a closing bracket or forward slash |
|
930 | + . ')*?' |
|
931 | + . ')' |
|
932 | + . '(?:' |
|
933 | + . '(\\/)' // 4: Self closing tag ... |
|
934 | + . '\\]' // ... and closing bracket |
|
935 | + . '|' |
|
936 | + . '\\]' // Closing bracket |
|
937 | + . '(?:' |
|
938 | + . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing tags |
|
939 | + . '[^\\[]*+' // Not an opening bracket |
|
940 | + . '(?:' |
|
941 | + . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag |
|
942 | + . '[^\\[]*+' // Not an opening bracket |
|
943 | + . ')*+' |
|
944 | + . ')' |
|
945 | + . '\\[\\/\\2\\]' // Closing tag |
|
946 | + . ')?' |
|
947 | + . ')' |
|
948 | + . '(\\]?)' // 6: Optional second closing bracket for escaping tags: [[tag]] |
|
949 | + . '/s'; |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | } |
@@ -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(); |
@@ -74,84 +74,84 @@ discard block |
||
74 | 74 | * Content Tags * |
75 | 75 | * ============ */ |
76 | 76 | |
77 | - 'title', // The event title. |
|
78 | - 'event-title', // @deprecated An alias for 'title' tag. |
|
79 | - 'description', // The event description. |
|
80 | - |
|
81 | - 'when', // Date and time of the event. |
|
82 | - 'start-time', // Start time of the event. |
|
83 | - 'start-date', // Start date of the event. |
|
84 | - 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
85 | - 'start-human', // Start time in a human friendly format. |
|
86 | - 'end-time', // End time of the event. |
|
87 | - 'end-date', // End date of the event. |
|
88 | - 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
89 | - 'end-human', // End date-time in a human friendly format. |
|
90 | - |
|
91 | - 'duration', // How long the events lasts, in a human-readable format. |
|
92 | - 'length', // @deprecated An alias of 'duration' tag. |
|
93 | - |
|
94 | - 'location', // Alias of start-location. |
|
95 | - 'start-location', // Location name where the event starts. |
|
96 | - 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
97 | - 'start-location-link', // Link to Google Maps querying the event start location address. |
|
98 | - 'end-location', // Location name where the event ends. |
|
99 | - 'end-location-link', // Link to Google Maps querying the event end location address. |
|
100 | - |
|
101 | - 'link', // An HTML link to the event URL. |
|
102 | - 'url', // A string with the raw event link URL. |
|
103 | - |
|
104 | - 'calendar', // The title of the source calendar. |
|
105 | - 'feed-title', // @deprecated An alias of 'calendar'. |
|
106 | - |
|
107 | - 'id', // The event unique ID. |
|
108 | - 'uid', // An alias of ID. |
|
109 | - 'event-id', // @deprecated An alias for 'id' tag. |
|
110 | - 'calendar-id', // The calendar ID. |
|
111 | - 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
112 | - 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
77 | + 'title', // The event title. |
|
78 | + 'event-title', // @deprecated An alias for 'title' tag. |
|
79 | + 'description', // The event description. |
|
80 | + |
|
81 | + 'when', // Date and time of the event. |
|
82 | + 'start-time', // Start time of the event. |
|
83 | + 'start-date', // Start date of the event. |
|
84 | + 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
85 | + 'start-human', // Start time in a human friendly format. |
|
86 | + 'end-time', // End time of the event. |
|
87 | + 'end-date', // End date of the event. |
|
88 | + 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
89 | + 'end-human', // End date-time in a human friendly format. |
|
90 | + |
|
91 | + 'duration', // How long the events lasts, in a human-readable format. |
|
92 | + 'length', // @deprecated An alias of 'duration' tag. |
|
93 | + |
|
94 | + 'location', // Alias of start-location. |
|
95 | + 'start-location', // Location name where the event starts. |
|
96 | + 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
97 | + 'start-location-link', // Link to Google Maps querying the event start location address. |
|
98 | + 'end-location', // Location name where the event ends. |
|
99 | + 'end-location-link', // Link to Google Maps querying the event end location address. |
|
100 | + |
|
101 | + 'link', // An HTML link to the event URL. |
|
102 | + 'url', // A string with the raw event link URL. |
|
103 | + |
|
104 | + 'calendar', // The title of the source calendar. |
|
105 | + 'feed-title', // @deprecated An alias of 'calendar'. |
|
106 | + |
|
107 | + 'id', // The event unique ID. |
|
108 | + 'uid', // An alias of ID. |
|
109 | + 'event-id', // @deprecated An alias for 'id' tag. |
|
110 | + 'calendar-id', // The calendar ID. |
|
111 | + 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
112 | + 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
113 | 113 | |
114 | 114 | /* ========= * |
115 | 115 | * Meta Tags * |
116 | 116 | * ========= */ |
117 | 117 | |
118 | - 'attachments', // List of attachments. |
|
119 | - 'attendees', // List of attendees. |
|
120 | - 'organizer', // Creator info. |
|
118 | + 'attachments', // List of attachments. |
|
119 | + 'attendees', // List of attendees. |
|
120 | + 'organizer', // Creator info. |
|
121 | 121 | |
122 | 122 | /* ================ * |
123 | 123 | * Conditional Tags * |
124 | 124 | * ================ */ |
125 | 125 | |
126 | - 'if-title', // If the event has a title. |
|
127 | - 'if-description', // If the event has a description. |
|
128 | - |
|
129 | - 'if-now', // If the event is taking place now. |
|
130 | - 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
131 | - 'if-started', // If the event has started (and may as well as ended). |
|
132 | - 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
133 | - 'if-ended', // If the event has ended (event could be any time in the past). |
|
134 | - 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
135 | - |
|
136 | - 'if-whole-day', // If the event lasts the whole day. |
|
137 | - 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
138 | - 'if-not-whole-day', // If the event does NOT last the whole day. |
|
139 | - 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
140 | - 'if-end-time', // If the event has a set end time. |
|
141 | - 'if-no-end-time', // If the event has NOT a set end time. |
|
142 | - |
|
143 | - 'if-multi-day', // If the event spans multiple days. |
|
144 | - 'if-single-day', // If the event does not span multiple days. |
|
145 | - |
|
146 | - 'if-recurring', // If the event is a recurring event. |
|
147 | - 'if-not-recurring', // If the event is NOT a recurring event. |
|
148 | - |
|
149 | - 'if-location', // @deprecated Alias for 'if-start-location'. |
|
150 | - 'if-start-location', // Does the event has a start location? |
|
151 | - 'if-end-location', // Does the event has an end location? |
|
152 | - 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
126 | + 'if-title', // If the event has a title. |
|
127 | + 'if-description', // If the event has a description. |
|
128 | + |
|
129 | + 'if-now', // If the event is taking place now. |
|
130 | + 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
131 | + 'if-started', // If the event has started (and may as well as ended). |
|
132 | + 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
133 | + 'if-ended', // If the event has ended (event could be any time in the past). |
|
134 | + 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
135 | + |
|
136 | + 'if-whole-day', // If the event lasts the whole day. |
|
137 | + 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
138 | + 'if-not-whole-day', // If the event does NOT last the whole day. |
|
139 | + 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
140 | + 'if-end-time', // If the event has a set end time. |
|
141 | + 'if-no-end-time', // If the event has NOT a set end time. |
|
142 | + |
|
143 | + 'if-multi-day', // If the event spans multiple days. |
|
144 | + 'if-single-day', // If the event does not span multiple days. |
|
145 | + |
|
146 | + 'if-recurring', // If the event is a recurring event. |
|
147 | + 'if-not-recurring', // If the event is NOT a recurring event. |
|
148 | + |
|
149 | + 'if-location', // @deprecated Alias for 'if-start-location'. |
|
150 | + 'if-start-location', // Does the event has a start location? |
|
151 | + 'if-end-location', // Does the event has an end location? |
|
152 | + 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
153 | 153 | 'if-not-start-location', // Does the event has NOT a start location? |
154 | - 'if-not-end-location', // Does the event has NOT an end location? |
|
154 | + 'if-not-end-location', // Does the event has NOT an end location? |
|
155 | 155 | |
156 | 156 | ); |
157 | 157 | } |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return string |
167 | 167 | */ |
168 | - public function parse_event_template_tags( $template_tags = '' ) { |
|
168 | + public function parse_event_template_tags($template_tags = '') { |
|
169 | 169 | |
170 | 170 | // Process tags. |
171 | 171 | $result = preg_replace_callback( |
172 | 172 | $this->get_regex(), |
173 | - array( $this, 'process_event_content' ), |
|
173 | + array($this, 'process_event_content'), |
|
174 | 174 | $template_tags |
175 | 175 | ); |
176 | 176 | |
177 | 177 | // Removes extra consecutive <br> tags. |
178 | - return preg_replace( '#(<br */?>\s*)+#i', '<br />', trim( $result ) ); |
|
178 | + return preg_replace('#(<br */?>\s*)+#i', '<br />', trim($result)); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string |
189 | 189 | */ |
190 | - public function process_event_content( $match ) { |
|
190 | + public function process_event_content($match) { |
|
191 | 191 | |
192 | - if ( $match[1] == '[' && $match[6] == ']' ) { |
|
193 | - return substr( $match[0], 1, - 1 ); |
|
192 | + if ($match[1] == '[' && $match[6] == ']') { |
|
193 | + return substr($match[0], 1, - 1); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | $tag = $match[2]; // Tag name without square brackets. |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | $calendar = $this->calendar; |
203 | 203 | $event = $this->event; |
204 | 204 | |
205 | - if ( ( $calendar instanceof Calendar ) && ( $event instanceof Event ) ) { |
|
205 | + if (($calendar instanceof Calendar) && ($event instanceof Event)) { |
|
206 | 206 | |
207 | - switch ( $tag ) { |
|
207 | + switch ($tag) { |
|
208 | 208 | |
209 | 209 | /* ============ * |
210 | 210 | * Content Tags * |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | |
213 | 213 | case 'title' : |
214 | 214 | case 'event-title' : |
215 | - return $this->get_title( $event->title, $attr ); |
|
215 | + return $this->get_title($event->title, $attr); |
|
216 | 216 | |
217 | 217 | case 'description' : |
218 | - return $this->get_description( $event->description, $attr ); |
|
218 | + return $this->get_description($event->description, $attr); |
|
219 | 219 | |
220 | 220 | case 'when' : |
221 | - return $this->get_when( $event ); |
|
221 | + return $this->get_when($event); |
|
222 | 222 | |
223 | 223 | case 'end-date' : |
224 | 224 | case 'end-custom' : |
@@ -228,39 +228,39 @@ discard block |
||
228 | 228 | case 'start-date' : |
229 | 229 | case 'start-human' : |
230 | 230 | case 'start-time' : |
231 | - return $this->get_dt( $tag, $event, $attr ); |
|
231 | + return $this->get_dt($tag, $event, $attr); |
|
232 | 232 | |
233 | 233 | case 'length' : |
234 | 234 | case 'duration' : |
235 | - if ( false !== $event->end ) { |
|
235 | + if (false !== $event->end) { |
|
236 | 236 | $duration = $event->start - $event->end; |
237 | - $value = human_time_diff( $event->start, $event->end ); |
|
237 | + $value = human_time_diff($event->start, $event->end); |
|
238 | 238 | } else { |
239 | 239 | $duration = '-1'; |
240 | - $value = __( 'No end time', 'google-calendar-events' ); |
|
240 | + $value = __('No end time', 'google-calendar-events'); |
|
241 | 241 | } |
242 | - return ' <span class="simcal-event-duration" data-event-duration="' . $duration . '">' . $value . '</span>'; |
|
242 | + return ' <span class="simcal-event-duration" data-event-duration="'.$duration.'">'.$value.'</span>'; |
|
243 | 243 | |
244 | 244 | case 'location' : |
245 | 245 | case 'start-location' : |
246 | 246 | case 'end-location' : |
247 | 247 | $location = $tag == 'end-location' ? $event->end_location['address'] : $event->start_location['address']; |
248 | - return ' <span class="simcal-event-address simcal-event-start-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . wp_strip_all_tags( $location ) . '</span>'; |
|
248 | + return ' <span class="simcal-event-address simcal-event-start-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'.wp_strip_all_tags($location).'</span>'; |
|
249 | 249 | |
250 | 250 | case 'start-location-link': |
251 | 251 | case 'end-location-link' : |
252 | 252 | case 'maps-link' : |
253 | 253 | $location = $tag == 'end-location-link' ? $event->end_location['address'] : $event->start_location['address']; |
254 | - if ( ! empty( $location ) ) { |
|
255 | - $url = '//maps.google.com?q=' . urlencode( $location ); |
|
256 | - return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr ); |
|
254 | + if ( ! empty($location)) { |
|
255 | + $url = '//maps.google.com?q='.urlencode($location); |
|
256 | + return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr); |
|
257 | 257 | } |
258 | 258 | break; |
259 | 259 | |
260 | 260 | case 'link' : |
261 | 261 | case 'url' : |
262 | - $content = 'link' == $tag ? $calendar->get_event_html( $event, $partial ) : ''; |
|
263 | - return $this->make_link( $tag, $event->link, $content , $attr ); |
|
262 | + $content = 'link' == $tag ? $calendar->get_event_html($event, $partial) : ''; |
|
263 | + return $this->make_link($tag, $event->link, $content, $attr); |
|
264 | 264 | |
265 | 265 | case 'calendar' : |
266 | 266 | case 'feed-title' : |
@@ -282,22 +282,22 @@ discard block |
||
282 | 282 | |
283 | 283 | case 'attachments' : |
284 | 284 | $attachments = $event->get_attachments(); |
285 | - if ( ! empty( $attachments ) ) { |
|
286 | - return $this->get_attachments( $attachments ); |
|
285 | + if ( ! empty($attachments)) { |
|
286 | + return $this->get_attachments($attachments); |
|
287 | 287 | } |
288 | 288 | break; |
289 | 289 | |
290 | 290 | case 'attendees' : |
291 | 291 | $attendees = $event->get_attendees(); |
292 | - if ( ! empty( $attendees ) ) { |
|
293 | - return $this->get_attendees( $attendees, $attr ); |
|
292 | + if ( ! empty($attendees)) { |
|
293 | + return $this->get_attendees($attendees, $attr); |
|
294 | 294 | } |
295 | 295 | break; |
296 | 296 | |
297 | 297 | case 'organizer' : |
298 | 298 | $organizer = $event->get_organizer(); |
299 | - if ( ! empty( $organizer ) ) { |
|
300 | - return $this->get_organizer( $organizer, $attr ); |
|
299 | + if ( ! empty($organizer)) { |
|
300 | + return $this->get_organizer($organizer, $attr); |
|
301 | 301 | } |
302 | 302 | break; |
303 | 303 | |
@@ -306,35 +306,35 @@ discard block |
||
306 | 306 | * ================ */ |
307 | 307 | |
308 | 308 | case 'if-title': |
309 | - if ( ! empty( $event->title ) ) { |
|
310 | - return $calendar->get_event_html( $event, $partial ); |
|
309 | + if ( ! empty($event->title)) { |
|
310 | + return $calendar->get_event_html($event, $partial); |
|
311 | 311 | } |
312 | 312 | break; |
313 | 313 | |
314 | 314 | case 'if-description': |
315 | - if ( ! empty( $event->description ) ) { |
|
316 | - return $calendar->get_event_html( $event, $partial ); |
|
315 | + if ( ! empty($event->description)) { |
|
316 | + return $calendar->get_event_html($event, $partial); |
|
317 | 317 | } |
318 | 318 | break; |
319 | 319 | |
320 | 320 | case 'if-now' : |
321 | 321 | case 'if-not-now' : |
322 | 322 | |
323 | - $start_dt = $event->start_dt->setTimezone( $calendar->timezone ); |
|
323 | + $start_dt = $event->start_dt->setTimezone($calendar->timezone); |
|
324 | 324 | $start = $start_dt->getTimestamp(); |
325 | 325 | |
326 | - if ( $event->end_dt instanceof Carbon ) { |
|
327 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
326 | + if ($event->end_dt instanceof Carbon) { |
|
327 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
328 | 328 | } else { |
329 | 329 | return ''; |
330 | 330 | } |
331 | 331 | |
332 | - $now = ( $start <= $calendar->now ) && ( $end >= $calendar->now ); |
|
332 | + $now = ($start <= $calendar->now) && ($end >= $calendar->now); |
|
333 | 333 | |
334 | - if ( ( 'if-now' == $tag ) && $now ) { |
|
335 | - return $calendar->get_event_html( $event, $partial ); |
|
336 | - } elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) { |
|
337 | - return $calendar->get_event_html( $event, $partial ); |
|
334 | + if (('if-now' == $tag) && $now) { |
|
335 | + return $calendar->get_event_html($event, $partial); |
|
336 | + } elseif (('if-not-now' == $tag) && (false == $now)) { |
|
337 | + return $calendar->get_event_html($event, $partial); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | break; |
@@ -342,15 +342,15 @@ discard block |
||
342 | 342 | case 'if-started' : |
343 | 343 | case 'if-not-started' : |
344 | 344 | |
345 | - $start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
345 | + $start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
346 | 346 | |
347 | - if ( 'if-started' == $tag ) { |
|
348 | - if ( $start < $calendar->now ) { |
|
349 | - return $calendar->get_event_html( $event, $partial ); |
|
347 | + if ('if-started' == $tag) { |
|
348 | + if ($start < $calendar->now) { |
|
349 | + return $calendar->get_event_html($event, $partial); |
|
350 | 350 | } |
351 | - } elseif ( 'if-not-started' == $tag ) { |
|
352 | - if ( $start > $calendar->now ) { |
|
353 | - return $calendar->get_event_html( $event, $partial ); |
|
351 | + } elseif ('if-not-started' == $tag) { |
|
352 | + if ($start > $calendar->now) { |
|
353 | + return $calendar->get_event_html($event, $partial); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
@@ -359,17 +359,17 @@ discard block |
||
359 | 359 | case 'if-ended' : |
360 | 360 | case 'if-not-ended' : |
361 | 361 | |
362 | - if ( false !== $event->end ) { |
|
362 | + if (false !== $event->end) { |
|
363 | 363 | |
364 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
364 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
365 | 365 | |
366 | - if ( 'if-ended' == $tag ) { |
|
367 | - if ( $end < $calendar->now ) { |
|
368 | - return $calendar->get_event_html( $event, $partial ); |
|
366 | + if ('if-ended' == $tag) { |
|
367 | + if ($end < $calendar->now) { |
|
368 | + return $calendar->get_event_html($event, $partial); |
|
369 | 369 | } |
370 | - } elseif ( 'if-not-ended' == $tag ) { |
|
371 | - if ( $end > $calendar->now ) { |
|
372 | - return $calendar->get_event_html( $event, $partial ); |
|
370 | + } elseif ('if-not-ended' == $tag) { |
|
371 | + if ($end > $calendar->now) { |
|
372 | + return $calendar->get_event_html($event, $partial); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
@@ -378,14 +378,14 @@ discard block |
||
378 | 378 | break; |
379 | 379 | |
380 | 380 | case 'if-end-time' : |
381 | - if ( false !== $event->end ) { |
|
382 | - return $calendar->get_event_html( $event, $partial ); |
|
381 | + if (false !== $event->end) { |
|
382 | + return $calendar->get_event_html($event, $partial); |
|
383 | 383 | } |
384 | 384 | break; |
385 | 385 | |
386 | 386 | case 'if-no-end-time' : |
387 | - if ( false === $event->end ) { |
|
388 | - return $calendar->get_event_html( $event, $partial ); |
|
387 | + if (false === $event->end) { |
|
388 | + return $calendar->get_event_html($event, $partial); |
|
389 | 389 | } |
390 | 390 | break; |
391 | 391 | |
@@ -393,59 +393,59 @@ discard block |
||
393 | 393 | case 'if-whole-day' : |
394 | 394 | case 'if-not-all-day' : |
395 | 395 | case 'if-not-whole-day' : |
396 | - $bool = strstr( $tag, 'not' ) ? false : true; |
|
397 | - if ( $bool === $event->whole_day ) { |
|
398 | - return $calendar->get_event_html( $event, $partial ); |
|
396 | + $bool = strstr($tag, 'not') ? false : true; |
|
397 | + if ($bool === $event->whole_day) { |
|
398 | + return $calendar->get_event_html($event, $partial); |
|
399 | 399 | } |
400 | 400 | break; |
401 | 401 | |
402 | 402 | case 'if-recurring' : |
403 | - if ( ! empty( $event->recurrence ) ) { |
|
404 | - return $calendar->get_event_html( $event, $partial ); |
|
403 | + if ( ! empty($event->recurrence)) { |
|
404 | + return $calendar->get_event_html($event, $partial); |
|
405 | 405 | } |
406 | 406 | break; |
407 | 407 | |
408 | 408 | case 'if-not-recurring' : |
409 | - if ( false === $event->recurrence ) { |
|
410 | - return $calendar->get_event_html( $event, $partial ); |
|
409 | + if (false === $event->recurrence) { |
|
410 | + return $calendar->get_event_html($event, $partial); |
|
411 | 411 | } |
412 | 412 | break; |
413 | 413 | |
414 | 414 | case 'if-multi-day' : |
415 | - if ( false !== $event->multiple_days ) { |
|
416 | - return $calendar->get_event_html( $event, $partial ); |
|
415 | + if (false !== $event->multiple_days) { |
|
416 | + return $calendar->get_event_html($event, $partial); |
|
417 | 417 | } |
418 | 418 | break; |
419 | 419 | |
420 | 420 | case 'if-single-day' : |
421 | - if ( false === $event->multiple_days ) { |
|
422 | - return $calendar->get_event_html( $event, $partial ); |
|
421 | + if (false === $event->multiple_days) { |
|
422 | + return $calendar->get_event_html($event, $partial); |
|
423 | 423 | } |
424 | 424 | break; |
425 | 425 | |
426 | 426 | case 'if-location' : |
427 | 427 | case 'if-start-location' : |
428 | - if ( ! empty( $event->start_location['address'] ) ) { |
|
429 | - return $calendar->get_event_html( $event, $partial ); |
|
428 | + if ( ! empty($event->start_location['address'])) { |
|
429 | + return $calendar->get_event_html($event, $partial); |
|
430 | 430 | } |
431 | 431 | return false; |
432 | 432 | |
433 | 433 | case 'if-not-location' : |
434 | 434 | case 'if-not-start-location' : |
435 | - if ( empty( $event->start_location['address'] ) ) { |
|
436 | - return $calendar->get_event_html( $event, $partial ); |
|
435 | + if (empty($event->start_location['address'])) { |
|
436 | + return $calendar->get_event_html($event, $partial); |
|
437 | 437 | } |
438 | 438 | return ''; |
439 | 439 | |
440 | 440 | case 'if-not-end-location' : |
441 | - if ( empty( $event->end_location['address'] ) ) { |
|
442 | - return $calendar->get_event_html( $event, $partial ); |
|
441 | + if (empty($event->end_location['address'])) { |
|
442 | + return $calendar->get_event_html($event, $partial); |
|
443 | 443 | } |
444 | 444 | return ''; |
445 | 445 | |
446 | 446 | case 'if-end-location' : |
447 | - if ( ! empty( $event->end_location['address'] ) ) { |
|
448 | - return $calendar->get_event_html( $event, $partial ); |
|
447 | + if ( ! empty($event->end_location['address'])) { |
|
448 | + return $calendar->get_event_html($event, $partial); |
|
449 | 449 | } |
450 | 450 | return ''; |
451 | 451 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * ======= */ |
455 | 455 | |
456 | 456 | default : |
457 | - return wp_kses_post( $before . $partial . $after ); |
|
457 | + return wp_kses_post($before.$partial.$after); |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
@@ -472,15 +472,15 @@ discard block |
||
472 | 472 | * |
473 | 473 | * @return string |
474 | 474 | */ |
475 | - private function limit_words( $text, $limit ) { |
|
475 | + private function limit_words($text, $limit) { |
|
476 | 476 | |
477 | - $text = wp_strip_all_tags( $text ); |
|
478 | - $limit = max( absint( $limit ), 0 ); |
|
477 | + $text = wp_strip_all_tags($text); |
|
478 | + $limit = max(absint($limit), 0); |
|
479 | 479 | |
480 | - if ( $limit > 0 && ( str_word_count( $text, 0 ) > $limit ) ) { |
|
481 | - $words = str_word_count( $text, 2 ); |
|
482 | - $pos = array_keys( $words ); |
|
483 | - $text = trim( substr( $text, 0, $pos[ $limit ] ) ) . '…'; |
|
480 | + if ($limit > 0 && (str_word_count($text, 0) > $limit)) { |
|
481 | + $words = str_word_count($text, 2); |
|
482 | + $pos = array_keys($words); |
|
483 | + $text = trim(substr($text, 0, $pos[$limit])).'…'; |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | return $text; |
@@ -497,26 +497,26 @@ discard block |
||
497 | 497 | * |
498 | 498 | * @return string |
499 | 499 | */ |
500 | - private function get_title( $title, $attr ) { |
|
500 | + private function get_title($title, $attr) { |
|
501 | 501 | |
502 | - if ( empty( $title ) ) { |
|
502 | + if (empty($title)) { |
|
503 | 503 | return ''; |
504 | 504 | } |
505 | 505 | |
506 | - $attr = array_merge( array( |
|
507 | - 'html' => '', // Parse HTML |
|
508 | - 'limit' => 0, // Trim length to amount of words |
|
509 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
506 | + $attr = array_merge(array( |
|
507 | + 'html' => '', // Parse HTML |
|
508 | + 'limit' => 0, // Trim length to amount of words |
|
509 | + ), (array) shortcode_parse_atts($attr)); |
|
510 | 510 | |
511 | - if ( ! empty( $attr['html'] ) ) { |
|
512 | - $title = wp_kses_post( $title ); |
|
511 | + if ( ! empty($attr['html'])) { |
|
512 | + $title = wp_kses_post($title); |
|
513 | 513 | $tag = 'div'; |
514 | 514 | } else { |
515 | - $title = $this->limit_words( $title, $attr['limit'] ); |
|
515 | + $title = $this->limit_words($title, $attr['limit']); |
|
516 | 516 | $tag = 'span'; |
517 | 517 | } |
518 | 518 | |
519 | - return '<' . $tag . ' class="simcal-event-title" itemprop="name">' . $title . '</' . $tag . '>'; |
|
519 | + return '<'.$tag.' class="simcal-event-title" itemprop="name">'.$title.'</'.$tag.'>'; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -530,40 +530,40 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return string |
532 | 532 | */ |
533 | - private function get_description( $description, $attr ) { |
|
533 | + private function get_description($description, $attr) { |
|
534 | 534 | |
535 | - if ( empty( $description ) ) { |
|
535 | + if (empty($description)) { |
|
536 | 536 | return ''; |
537 | 537 | } |
538 | 538 | |
539 | - $attr = array_merge( array( |
|
540 | - 'limit' => 0, // Trim length to number of words |
|
541 | - 'html' => 'no', // Parse HTML content |
|
542 | - 'markdown' => 'no', // Parse Markdown content |
|
543 | - 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
544 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
539 | + $attr = array_merge(array( |
|
540 | + 'limit' => 0, // Trim length to number of words |
|
541 | + 'html' => 'no', // Parse HTML content |
|
542 | + 'markdown' => 'no', // Parse Markdown content |
|
543 | + 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
544 | + ), (array) shortcode_parse_atts($attr)); |
|
545 | 545 | |
546 | - $allow_html = 'no' != $attr['html'] ? true : false; |
|
546 | + $allow_html = 'no' != $attr['html'] ? true : false; |
|
547 | 547 | $allow_md = 'no' != $attr['markdown'] ? true : false; |
548 | 548 | |
549 | 549 | $html = '<div class="simcal-event-description" itemprop="description">'; |
550 | 550 | |
551 | 551 | // Markdown and HTML don't play well together, use one or the other in the same tag. |
552 | - if ( $allow_html || $allow_md ) { |
|
553 | - if ( $allow_html ) { |
|
554 | - $html .= wp_kses_post( $description ); |
|
555 | - } elseif ( $allow_md ) { |
|
552 | + if ($allow_html || $allow_md) { |
|
553 | + if ($allow_html) { |
|
554 | + $html .= wp_kses_post($description); |
|
555 | + } elseif ($allow_md) { |
|
556 | 556 | $markdown = new \Parsedown(); |
557 | - $html .= $markdown->text( wp_strip_all_tags( $description ) ); |
|
557 | + $html .= $markdown->text(wp_strip_all_tags($description)); |
|
558 | 558 | } |
559 | 559 | } else { |
560 | - $html .= $this->limit_words( $description, $attr['limit'] ); |
|
560 | + $html .= $this->limit_words($description, $attr['limit']); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | $html .= '</div>'; |
564 | 564 | |
565 | - if ( 'no' != $attr['autolink'] ) { |
|
566 | - $html = ' ' . make_clickable( $html ); |
|
565 | + if ('no' != $attr['autolink']) { |
|
566 | + $html = ' '.make_clickable($html); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | return $html; |
@@ -579,74 +579,74 @@ discard block |
||
579 | 579 | * |
580 | 580 | * @return string |
581 | 581 | */ |
582 | - private function get_when( Event $event ) { |
|
582 | + private function get_when(Event $event) { |
|
583 | 583 | |
584 | - $start = $event->start_dt->setTimezone( $event->timezone ); |
|
585 | - $end = ! is_null( $event->end_dt ) ? $event->end_dt->setTimezone( $event->timezone ) : null; |
|
584 | + $start = $event->start_dt->setTimezone($event->timezone); |
|
585 | + $end = ! is_null($event->end_dt) ? $event->end_dt->setTimezone($event->timezone) : null; |
|
586 | 586 | |
587 | 587 | $time_start = ''; |
588 | 588 | $time_end = ''; |
589 | 589 | |
590 | - if ( ! $event->whole_day ) { |
|
590 | + if ( ! $event->whole_day) { |
|
591 | 591 | |
592 | - $time_start = $this->calendar->datetime_separator . |
|
593 | - ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
594 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
595 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
596 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
597 | - date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
592 | + $time_start = $this->calendar->datetime_separator. |
|
593 | + ' <span class="simcal-event-start simcal-event-start-time" '. |
|
594 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
595 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
596 | + 'itemprop="startDate" content="'.$start->toIso8601String().'">'. |
|
597 | + date_i18n($this->calendar->time_format, $start->getTimestamp()). |
|
598 | 598 | '</span> '; |
599 | 599 | |
600 | - if ( $end instanceof Carbon ) { |
|
600 | + if ($end instanceof Carbon) { |
|
601 | 601 | |
602 | - $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . |
|
603 | - 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
604 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
605 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
606 | - date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
602 | + $time_end = ' <span class="simcal-event-end simcal-event-end-time" '. |
|
603 | + 'data-event-end="'.$end->getTimestamp().'" '. |
|
604 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
605 | + 'itemprop="endDate" content="'.$end->toIso8601String().'">'. |
|
606 | + date_i18n($this->calendar->time_format, $end->getTimestamp()). |
|
607 | 607 | '</span> '; |
608 | 608 | |
609 | 609 | } |
610 | 610 | |
611 | 611 | } |
612 | 612 | |
613 | - if ( $event->multiple_days ) { |
|
613 | + if ($event->multiple_days) { |
|
614 | 614 | |
615 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
616 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
617 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
618 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
619 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
620 | - '</span> ' . |
|
615 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
616 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
617 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
618 | + 'itemprop="startDate" content="'.$start->toIso8601String().'">'. |
|
619 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
620 | + '</span> '. |
|
621 | 621 | $time_start; |
622 | 622 | |
623 | - if ( $end instanceof Carbon ) { |
|
623 | + if ($end instanceof Carbon) { |
|
624 | 624 | |
625 | - $output .= '-' . |
|
626 | - ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
627 | - 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
628 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
629 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
630 | - date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
631 | - '</span> ' . |
|
625 | + $output .= '-'. |
|
626 | + ' <span class="simcal-event-start simcal-event-end-date" '. |
|
627 | + 'data-event-start="'.$end->getTimestamp().'" '. |
|
628 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
629 | + 'itemprop="endDate" content="'.$end->toIso8601String().'">'. |
|
630 | + date_i18n($this->calendar->date_format, $end->getTimestamp()). |
|
631 | + '</span> '. |
|
632 | 632 | $time_end; |
633 | 633 | } |
634 | 634 | |
635 | 635 | } else { |
636 | 636 | |
637 | - $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
|
637 | + $time_end = ! empty($time_start) && ! empty($time_end) ? ' - '.$time_end : ''; |
|
638 | 638 | |
639 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
640 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
641 | - 'data-event-format="' . $this->calendar->date_format . '">' . |
|
642 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
643 | - '</span> ' . |
|
644 | - $time_start . |
|
639 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
640 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
641 | + 'data-event-format="'.$this->calendar->date_format.'">'. |
|
642 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
643 | + '</span> '. |
|
644 | + $time_start. |
|
645 | 645 | $time_end; |
646 | 646 | |
647 | 647 | } |
648 | 648 | |
649 | - return trim( $output ); |
|
649 | + return trim($output); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | /** |
@@ -661,44 +661,44 @@ discard block |
||
661 | 661 | * |
662 | 662 | * @return string |
663 | 663 | */ |
664 | - private function get_dt( $tag, Event $event, $attr ) { |
|
664 | + private function get_dt($tag, Event $event, $attr) { |
|
665 | 665 | |
666 | - $bound = 0 === strpos( $tag, 'end' ) ? 'end' : 'start'; |
|
667 | - if ( ( 'end' == $bound ) && ( false === $event->end ) ) { |
|
666 | + $bound = 0 === strpos($tag, 'end') ? 'end' : 'start'; |
|
667 | + if (('end' == $bound) && (false === $event->end)) { |
|
668 | 668 | return ''; |
669 | 669 | } |
670 | 670 | |
671 | - $dt = $bound . '_dt'; |
|
672 | - if ( ! $event->$dt instanceof Carbon ) { |
|
671 | + $dt = $bound.'_dt'; |
|
672 | + if ( ! $event->$dt instanceof Carbon) { |
|
673 | 673 | return ''; |
674 | 674 | } |
675 | - $event_dt = $event->$dt->setTimezone( $event->timezone ); |
|
675 | + $event_dt = $event->$dt->setTimezone($event->timezone); |
|
676 | 676 | |
677 | - $attr = array_merge( array( |
|
677 | + $attr = array_merge(array( |
|
678 | 678 | 'format' => '', |
679 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
679 | + ), (array) shortcode_parse_atts($attr)); |
|
680 | 680 | |
681 | - $format = ltrim( strstr( $tag, '-' ), '-' ); |
|
681 | + $format = ltrim(strstr($tag, '-'), '-'); |
|
682 | 682 | $dt_format = ''; |
683 | - if ( ! empty( $attr['format'] ) ) { |
|
684 | - $dt_format = esc_attr( wp_strip_all_tags( $attr['format'] ) ); |
|
685 | - } elseif ( 'date' == $format ) { |
|
683 | + if ( ! empty($attr['format'])) { |
|
684 | + $dt_format = esc_attr(wp_strip_all_tags($attr['format'])); |
|
685 | + } elseif ('date' == $format) { |
|
686 | 686 | $dt_format = $this->calendar->date_format; |
687 | - } elseif ( 'time' == $format ) { |
|
687 | + } elseif ('time' == $format) { |
|
688 | 688 | $dt_format = $this->calendar->time_format; |
689 | 689 | } |
690 | 690 | |
691 | - if ( 'human' == $format ) { |
|
692 | - $value = human_time_diff( $event_dt->getTimestamp(), Carbon::now( $event->timezone )->getTimestamp() ); |
|
691 | + if ('human' == $format) { |
|
692 | + $value = human_time_diff($event_dt->getTimestamp(), Carbon::now($event->timezone)->getTimestamp()); |
|
693 | 693 | } else { |
694 | - $value = date_i18n( $dt_format, $event_dt->getTimestamp() ); |
|
694 | + $value = date_i18n($dt_format, $event_dt->getTimestamp()); |
|
695 | 695 | } |
696 | 696 | |
697 | - return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '"' . |
|
698 | - 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '"' . |
|
699 | - 'data-event-format="' . $dt_format . '"' . |
|
700 | - 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . |
|
701 | - $value . |
|
697 | + return '<span class="simcal-event-'.$bound.' '.'simcal-event-'.$bound.'-'.$format.'"'. |
|
698 | + 'data-event-'.$bound.'="'.$event_dt->getTimestamp().'"'. |
|
699 | + 'data-event-format="'.$dt_format.'"'. |
|
700 | + 'itemprop="'.$bound.'Date" content="'.$event_dt->toIso8601String().'">'. |
|
701 | + $value. |
|
702 | 702 | '</span>'; |
703 | 703 | } |
704 | 704 | |
@@ -715,23 +715,23 @@ discard block |
||
715 | 715 | * |
716 | 716 | * @return string |
717 | 717 | */ |
718 | - private function make_link( $tag, $url, $content, $attr ) { |
|
718 | + private function make_link($tag, $url, $content, $attr) { |
|
719 | 719 | |
720 | - if ( empty( $url ) ) { |
|
720 | + if (empty($url)) { |
|
721 | 721 | return ''; |
722 | 722 | } |
723 | 723 | |
724 | - $text = empty( $content ) ? $url : $content; |
|
724 | + $text = empty($content) ? $url : $content; |
|
725 | 725 | |
726 | - $attr = array_merge( array( |
|
727 | - 'autolink' => false, // Convert url to link anchor |
|
728 | - 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
729 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
726 | + $attr = array_merge(array( |
|
727 | + 'autolink' => false, // Convert url to link anchor |
|
728 | + 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
729 | + ), (array) shortcode_parse_atts($attr)); |
|
730 | 730 | |
731 | 731 | $anchor = $tag != 'url' ? 'yes' : $attr['autolink']; |
732 | 732 | $target = $attr['newwindow'] !== false ? 'target="_blank"' : ''; |
733 | 733 | |
734 | - return $anchor !== false ? ' <a href="' . esc_url( $url ) . '" ' . $target . '>' . $text . '</a>' : ' ' . $text; |
|
734 | + return $anchor !== false ? ' <a href="'.esc_url($url).'" '.$target.'>'.$text.'</a>' : ' '.$text; |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -744,20 +744,20 @@ discard block |
||
744 | 744 | * |
745 | 745 | * @return string |
746 | 746 | */ |
747 | - private function get_attachments( $attachments ) { |
|
747 | + private function get_attachments($attachments) { |
|
748 | 748 | |
749 | - $html = '<ul class="simcal-attachments">' . "\n\t"; |
|
749 | + $html = '<ul class="simcal-attachments">'."\n\t"; |
|
750 | 750 | |
751 | - foreach ( $attachments as $attachment ) { |
|
751 | + foreach ($attachments as $attachment) { |
|
752 | 752 | $html .= '<li class="simcal-attachment">'; |
753 | - $html .= '<a href="' . $attachment['url'] . '" target="_blank">'; |
|
754 | - $html .= ! empty( $attachment['icon'] ) ? '<img src="' . $attachment['icon'] . '" />' : ''; |
|
755 | - $html .= '<span>' . $attachment['name'] . '</span>'; |
|
753 | + $html .= '<a href="'.$attachment['url'].'" target="_blank">'; |
|
754 | + $html .= ! empty($attachment['icon']) ? '<img src="'.$attachment['icon'].'" />' : ''; |
|
755 | + $html .= '<span>'.$attachment['name'].'</span>'; |
|
756 | 756 | $html .= '</a>'; |
757 | - $html .= '</li>' . "\n"; |
|
757 | + $html .= '</li>'."\n"; |
|
758 | 758 | } |
759 | 759 | |
760 | - $html .= '</ul>' . "\n"; |
|
760 | + $html .= '</ul>'."\n"; |
|
761 | 761 | |
762 | 762 | return $html; |
763 | 763 | } |
@@ -773,41 +773,41 @@ discard block |
||
773 | 773 | * |
774 | 774 | * @return string |
775 | 775 | */ |
776 | - private function get_attendees( $attendees, $attr ) { |
|
776 | + private function get_attendees($attendees, $attr) { |
|
777 | 777 | |
778 | - $attr = array_merge( array( |
|
779 | - 'photo' => 'show', // show/hide attendee photo |
|
780 | - 'email' => 'hide', // show/hide attendee email address |
|
781 | - 'rsvp' => 'hide', // show/hide rsvp response status |
|
782 | - 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
783 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
778 | + $attr = array_merge(array( |
|
779 | + 'photo' => 'show', // show/hide attendee photo |
|
780 | + 'email' => 'hide', // show/hide attendee email address |
|
781 | + 'rsvp' => 'hide', // show/hide rsvp response status |
|
782 | + 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
783 | + ), (array) shortcode_parse_atts($attr)); |
|
784 | 784 | |
785 | - $html = '<ul class="simcal-attendees" itemprop="attendees">' . "\n\t"; |
|
785 | + $html = '<ul class="simcal-attendees" itemprop="attendees">'."\n\t"; |
|
786 | 786 | |
787 | 787 | $known = 0; |
788 | 788 | $unknown = 0; |
789 | 789 | |
790 | - foreach ( $attendees as $attendee ) { |
|
790 | + foreach ($attendees as $attendee) { |
|
791 | 791 | |
792 | - if ( 'yes' == $attr['response'] && 'yes' != $attendee['response'] ) { |
|
792 | + if ('yes' == $attr['response'] && 'yes' != $attendee['response']) { |
|
793 | 793 | continue; |
794 | - } elseif ( 'no' == $attr['response'] && 'no' != $attendee['response'] ) { |
|
794 | + } elseif ('no' == $attr['response'] && 'no' != $attendee['response']) { |
|
795 | 795 | continue; |
796 | - } elseif ( 'maybe' == $attr['response'] && ! in_array( $attendee['response'], array( 'yes', 'maybe' ) ) ) { |
|
796 | + } elseif ('maybe' == $attr['response'] && ! in_array($attendee['response'], array('yes', 'maybe'))) { |
|
797 | 797 | continue; |
798 | 798 | } |
799 | 799 | |
800 | - if ( ! empty( $attendee['name'] ) ) { |
|
800 | + if ( ! empty($attendee['name'])) { |
|
801 | 801 | |
802 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $attendee['photo'] . '" itemprop="image" />' : ''; |
|
803 | - $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response( $attendee['response'] ) : ''; |
|
804 | - $guest = $photo . '<span itemprop="name">' . $attendee['name'] . $response . '</span>'; |
|
802 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$attendee['photo'].'" itemprop="image" />' : ''; |
|
803 | + $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response($attendee['response']) : ''; |
|
804 | + $guest = $photo.'<span itemprop="name">'.$attendee['name'].$response.'</span>'; |
|
805 | 805 | |
806 | - if ( ! empty( $attendee['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
807 | - $guest = sprintf( '<a href="mailto:' . $attendee['email'] . '" itemprop="email">%s</a>', $guest ); |
|
806 | + if ( ! empty($attendee['email']) && ('show' == $attr['email'])) { |
|
807 | + $guest = sprintf('<a href="mailto:'.$attendee['email'].'" itemprop="email">%s</a>', $guest); |
|
808 | 808 | } |
809 | 809 | |
810 | - $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">' . $guest . '</li>' . "\n"; |
|
810 | + $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">'.$guest.'</li>'."\n"; |
|
811 | 811 | |
812 | 812 | $known++; |
813 | 813 | |
@@ -818,21 +818,21 @@ discard block |
||
818 | 818 | } |
819 | 819 | } |
820 | 820 | |
821 | - if ( $unknown > 0 ) { |
|
822 | - if ( $known > 0 ) { |
|
821 | + if ($unknown > 0) { |
|
822 | + if ($known > 0) { |
|
823 | 823 | /* translators: One more person attending the event. */ |
824 | - $others = sprintf( _n( '1 more attendee', '%s more attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
824 | + $others = sprintf(_n('1 more attendee', '%s more attendees', $unknown, 'google-calendar-events'), $unknown); |
|
825 | 825 | } else { |
826 | 826 | /* translators: One or more persons attending the event whose name is unknown. */ |
827 | - $others = sprintf( _n( '1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
827 | + $others = sprintf(_n('1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events'), $unknown); |
|
828 | 828 | } |
829 | - $photo = $attr['photo'] !== 'hide' ? get_avatar( '', 128 ) : ''; |
|
830 | - $html .= '<li class="simcal-attendee simcal-attendee-anonymous">' . $photo . '<span>' . $others . '</span></li>' . "\n"; |
|
831 | - } elseif ( $known === 0 ) { |
|
832 | - $html .= '<li class="simcal-attendee">' . _x( 'No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events' ) . '</li>' . "\n"; |
|
829 | + $photo = $attr['photo'] !== 'hide' ? get_avatar('', 128) : ''; |
|
830 | + $html .= '<li class="simcal-attendee simcal-attendee-anonymous">'.$photo.'<span>'.$others.'</span></li>'."\n"; |
|
831 | + } elseif ($known === 0) { |
|
832 | + $html .= '<li class="simcal-attendee">'._x('No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events').'</li>'."\n"; |
|
833 | 833 | } |
834 | 834 | |
835 | - $html .= '</ul>' . "\n"; |
|
835 | + $html .= '</ul>'."\n"; |
|
836 | 836 | |
837 | 837 | return $html; |
838 | 838 | } |
@@ -846,23 +846,23 @@ discard block |
||
846 | 846 | * |
847 | 847 | * @return string |
848 | 848 | */ |
849 | - private function get_rsvp_response( $response ) { |
|
849 | + private function get_rsvp_response($response) { |
|
850 | 850 | |
851 | - if ( 'yes' == $response ) { |
|
851 | + if ('yes' == $response) { |
|
852 | 852 | /* translators: Someone replied with 'yes' to a rsvp request. */ |
853 | - $rsvp = __( 'Attending', 'google-calendar-events' ); |
|
854 | - } elseif ( 'no' == $response ) { |
|
853 | + $rsvp = __('Attending', 'google-calendar-events'); |
|
854 | + } elseif ('no' == $response) { |
|
855 | 855 | /* translators: Someone replied with 'no' to a rsvp request. */ |
856 | - $rsvp = __( 'Not attending', 'google-calendar-events' ); |
|
857 | - } elseif ( 'maybe' == $response ) { |
|
856 | + $rsvp = __('Not attending', 'google-calendar-events'); |
|
857 | + } elseif ('maybe' == $response) { |
|
858 | 858 | /* translators: Someone replied with 'maybe' to a rsvp request. */ |
859 | - $rsvp = __( 'Maybe attending', 'google-calendar-events' ); |
|
859 | + $rsvp = __('Maybe attending', 'google-calendar-events'); |
|
860 | 860 | } else { |
861 | 861 | /* translators: Someone did not send yet a rsvp confirmation to join an event. */ |
862 | - $rsvp = __( 'Response pending', 'google-calendar-events' ); |
|
862 | + $rsvp = __('Response pending', 'google-calendar-events'); |
|
863 | 863 | } |
864 | 864 | |
865 | - return ' <small>(' . $rsvp . ')</small>'; |
|
865 | + return ' <small>('.$rsvp.')</small>'; |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | /** |
@@ -876,21 +876,21 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return string |
878 | 878 | */ |
879 | - private function get_organizer( $organizer, $attr ) { |
|
879 | + private function get_organizer($organizer, $attr) { |
|
880 | 880 | |
881 | - $attr = array_merge( array( |
|
882 | - 'photo' => 'show', // show/hide attendee photo |
|
883 | - 'email' => 'hide', // show/hide attendee email address |
|
884 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
881 | + $attr = array_merge(array( |
|
882 | + 'photo' => 'show', // show/hide attendee photo |
|
883 | + 'email' => 'hide', // show/hide attendee email address |
|
884 | + ), (array) shortcode_parse_atts($attr)); |
|
885 | 885 | |
886 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $organizer['photo'] . '" itemprop="image" />' : ''; |
|
887 | - $organizer = $photo . '<span itemprop="name">' . $organizer['name'] . '</span>'; |
|
886 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$organizer['photo'].'" itemprop="image" />' : ''; |
|
887 | + $organizer = $photo.'<span itemprop="name">'.$organizer['name'].'</span>'; |
|
888 | 888 | |
889 | - if ( ! empty( $organizer['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
890 | - $organizer = sprintf( '<a href="mailto:' . $organizer['email'] . '" itemprop="email">%s</a>', $organizer ); |
|
889 | + if ( ! empty($organizer['email']) && ('show' == $attr['email'])) { |
|
890 | + $organizer = sprintf('<a href="mailto:'.$organizer['email'].'" itemprop="email">%s</a>', $organizer); |
|
891 | 891 | } |
892 | 892 | |
893 | - return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">' . $organizer . '</div>'; |
|
893 | + return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">'.$organizer.'</div>'; |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | /** |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | // This is largely borrowed on get_shortcode_regex() from WordPress Core. |
916 | 916 | // @see /wp-includes/shortcodes.php (with some modification) |
917 | 917 | |
918 | - $tagregexp = implode( '|', array_values( $this->tags ) ); |
|
918 | + $tagregexp = implode('|', array_values($this->tags)); |
|
919 | 919 | |
920 | 920 | return '/' |
921 | 921 | . '\\[' // Opening bracket |
@@ -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 | |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param array $e Events. |
46 | 46 | * @param string|\DateTimeZone $tz Timezone. |
47 | 47 | */ |
48 | - public function __construct( $e = array(), $tz = 'UTC' ) { |
|
49 | - $this->set_events( $e ); |
|
50 | - $this->set_timezone( $tz ); |
|
48 | + public function __construct($e = array(), $tz = 'UTC') { |
|
49 | + $this->set_events($e); |
|
50 | + $this->set_timezone($tz); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return array |
61 | 61 | */ |
62 | - public function get_events( $n = '' ) { |
|
63 | - if ( ! empty( $n ) && ! empty( $this->events ) ) { |
|
64 | - $length = absint( $n ); |
|
65 | - return array_slice( $this->events, 0, $length, true ); |
|
62 | + public function get_events($n = '') { |
|
63 | + if ( ! empty($n) && ! empty($this->events)) { |
|
64 | + $length = absint($n); |
|
65 | + return array_slice($this->events, 0, $length, true); |
|
66 | 66 | } |
67 | 67 | return $this->events; |
68 | 68 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param array $ev Events. |
76 | 76 | */ |
77 | - public function set_events( array $ev ) { |
|
77 | + public function set_events(array $ev) { |
|
78 | 78 | $this->events = $ev; |
79 | 79 | } |
80 | 80 | |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return Events |
89 | 89 | */ |
90 | - public function set_timezone( $tz ) { |
|
91 | - if ( $tz instanceof \DateTimeZone ) { |
|
90 | + public function set_timezone($tz) { |
|
91 | + if ($tz instanceof \DateTimeZone) { |
|
92 | 92 | $tz = $tz->getName(); |
93 | 93 | } |
94 | - $this->timezone = simcal_esc_timezone( $tz, $this->timezone ); |
|
94 | + $this->timezone = simcal_esc_timezone($tz, $this->timezone); |
|
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return Events |
106 | 106 | */ |
107 | - public function shift( $n ) { |
|
108 | - if ( ! empty( $this->events ) ) { |
|
109 | - $offset = intval( $n ); |
|
110 | - $length = count( $this->events ); |
|
111 | - $this->set_events( array_slice( $this->events, $offset, $length, true ) ); |
|
107 | + public function shift($n) { |
|
108 | + if ( ! empty($this->events)) { |
|
109 | + $offset = intval($n); |
|
110 | + $length = count($this->events); |
|
111 | + $this->set_events(array_slice($this->events, $offset, $length, true)); |
|
112 | 112 | } |
113 | 113 | return $this; |
114 | 114 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @return Events |
122 | 122 | */ |
123 | 123 | public function private_only() { |
124 | - $this->set_events( $this->filter_property( 'public', 'hide' ) ); |
|
124 | + $this->set_events($this->filter_property('public', 'hide')); |
|
125 | 125 | return $this; |
126 | 126 | } |
127 | 127 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @return Events |
134 | 134 | */ |
135 | 135 | public function public_only() { |
136 | - $this->set_events( $this->filter_property( 'public', 'show' ) ); |
|
136 | + $this->set_events($this->filter_property('public', 'show')); |
|
137 | 137 | return $this; |
138 | 138 | } |
139 | 139 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @return Events |
146 | 146 | */ |
147 | 147 | public function recurring() { |
148 | - $this->set_events( $this->filter_property( 'recurrence', 'show' ) ); |
|
148 | + $this->set_events($this->filter_property('recurrence', 'show')); |
|
149 | 149 | return $this; |
150 | 150 | } |
151 | 151 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return Events |
158 | 158 | */ |
159 | 159 | public function not_recurring() { |
160 | - $this->set_events( $this->filter_property( 'recurrence', 'hide' ) ); |
|
160 | + $this->set_events($this->filter_property('recurrence', 'hide')); |
|
161 | 161 | return $this; |
162 | 162 | } |
163 | 163 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @return Events |
170 | 170 | */ |
171 | 171 | public function whole_day() { |
172 | - $this->set_events( $this->filter_property( 'whole_day', 'show' ) ); |
|
172 | + $this->set_events($this->filter_property('whole_day', 'show')); |
|
173 | 173 | return $this; |
174 | 174 | } |
175 | 175 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return Events |
182 | 182 | */ |
183 | 183 | public function not_whole_day() { |
184 | - $this->set_events( $this->filter_property( 'whole_day', 'hide' ) ); |
|
184 | + $this->set_events($this->filter_property('whole_day', 'hide')); |
|
185 | 185 | return $this; |
186 | 186 | } |
187 | 187 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @return Events |
194 | 194 | */ |
195 | 195 | public function multi_day() { |
196 | - $this->set_events( $this->filter_property( 'multiple_days', 'show' ) ); |
|
196 | + $this->set_events($this->filter_property('multiple_days', 'show')); |
|
197 | 197 | return $this; |
198 | 198 | } |
199 | 199 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @return Events |
206 | 206 | */ |
207 | 207 | public function single_day() { |
208 | - $this->set_events( $this->filter_property( 'multiple_days', 'hide' ) ); |
|
208 | + $this->set_events($this->filter_property('multiple_days', 'hide')); |
|
209 | 209 | return $this; |
210 | 210 | } |
211 | 211 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @return Events |
218 | 218 | */ |
219 | 219 | public function with_location() { |
220 | - $this->set_events( $this->filter_property( 'venue', 'show' ) ); |
|
220 | + $this->set_events($this->filter_property('venue', 'show')); |
|
221 | 221 | return $this; |
222 | 222 | } |
223 | 223 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return Events |
230 | 230 | */ |
231 | 231 | public function without_location() { |
232 | - $this->set_events( $this->filter_property( 'venue', 'hide' ) ); |
|
232 | + $this->set_events($this->filter_property('venue', 'hide')); |
|
233 | 233 | return $this; |
234 | 234 | } |
235 | 235 | |
@@ -244,18 +244,18 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return array |
246 | 246 | */ |
247 | - private function filter_property( $property, $toggle ) { |
|
247 | + private function filter_property($property, $toggle) { |
|
248 | 248 | $filtered = array(); |
249 | - if ( ! empty( $this->events ) ) { |
|
250 | - foreach ( $this->events as $ts => $events ) { |
|
251 | - foreach ( $events as $event ) { |
|
252 | - if ( 'hide' == $toggle ) { |
|
253 | - if ( ! $event->$property ) { |
|
254 | - $filtered[ $ts ][] = $event; |
|
249 | + if ( ! empty($this->events)) { |
|
250 | + foreach ($this->events as $ts => $events) { |
|
251 | + foreach ($events as $event) { |
|
252 | + if ('hide' == $toggle) { |
|
253 | + if ( ! $event->$property) { |
|
254 | + $filtered[$ts][] = $event; |
|
255 | 255 | } |
256 | - } elseif ( 'show' == $toggle ) { |
|
257 | - if ( $event->$property ) { |
|
258 | - $filtered[ $ts ][] = $event; |
|
256 | + } elseif ('show' == $toggle) { |
|
257 | + if ($event->$property) { |
|
258 | + $filtered[$ts][] = $event; |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | } |
@@ -273,14 +273,14 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return Events |
275 | 275 | */ |
276 | - public function future( $present = '' ) { |
|
276 | + public function future($present = '') { |
|
277 | 277 | $last = $this->get_last(); |
278 | 278 | $to = $last instanceof Event ? $last->start_utc : false; |
279 | - if ( $to ) { |
|
280 | - if ( empty( $present ) ) { |
|
281 | - $present = Carbon::now( $this->timezone )->getTimestamp(); |
|
279 | + if ($to) { |
|
280 | + if (empty($present)) { |
|
281 | + $present = Carbon::now($this->timezone)->getTimestamp(); |
|
282 | 282 | } |
283 | - $this->set_events( $this->filter_events( intval( $present ), $to ) ); |
|
283 | + $this->set_events($this->filter_events(intval($present), $to)); |
|
284 | 284 | } |
285 | 285 | return $this; |
286 | 286 | } |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return Events |
296 | 296 | */ |
297 | - public function past( $present = '' ) { |
|
297 | + public function past($present = '') { |
|
298 | 298 | $first = $this->get_last(); |
299 | 299 | $from = $first instanceof Event ? $first->start_utc : false; |
300 | - if ( $from ) { |
|
301 | - if ( empty( $present ) ) { |
|
302 | - $present = Carbon::now( $this->timezone )->getTimestamp(); |
|
300 | + if ($from) { |
|
301 | + if (empty($present)) { |
|
302 | + $present = Carbon::now($this->timezone)->getTimestamp(); |
|
303 | 303 | } |
304 | - $this->set_events( $this->filter_events( $from, intval( $present ) ) ); |
|
304 | + $this->set_events($this->filter_events($from, intval($present))); |
|
305 | 305 | } |
306 | 306 | return $this; |
307 | 307 | } |
@@ -315,9 +315,9 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return Events |
317 | 317 | */ |
318 | - public function after( $time ) { |
|
319 | - $dt = $this->parse( $time ); |
|
320 | - return ! is_null( $dt ) ? $this->future( $dt->getTimestamp() ) : $this; |
|
318 | + public function after($time) { |
|
319 | + $dt = $this->parse($time); |
|
320 | + return ! is_null($dt) ? $this->future($dt->getTimestamp()) : $this; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | * |
330 | 330 | * @return Events |
331 | 331 | */ |
332 | - public function before( $time ) { |
|
333 | - $dt = $this->parse( $time ); |
|
334 | - return ! is_null( $dt ) ? $this->past( $dt->getTimestamp() ) : $this; |
|
332 | + public function before($time) { |
|
333 | + $dt = $this->parse($time); |
|
334 | + return ! is_null($dt) ? $this->past($dt->getTimestamp()) : $this; |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** |
@@ -343,10 +343,10 @@ discard block |
||
343 | 343 | * |
344 | 344 | * @return Events |
345 | 345 | */ |
346 | - public function from( $time ) { |
|
347 | - $last = $this->parse( $time ); |
|
348 | - if ( ! is_null( $last ) ) { |
|
349 | - $this->set_events( $this->filter_events( $time, $last->getTimestamp() ) ); |
|
346 | + public function from($time) { |
|
347 | + $last = $this->parse($time); |
|
348 | + if ( ! is_null($last)) { |
|
349 | + $this->set_events($this->filter_events($time, $last->getTimestamp())); |
|
350 | 350 | } |
351 | 351 | return $this; |
352 | 352 | } |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @return Events |
362 | 362 | */ |
363 | - public function to( $time ) { |
|
364 | - $first = $this->parse( $time ); |
|
365 | - if ( ! is_null( $first ) ) { |
|
366 | - $this->set_events( $this->filter_events( $first->getTimestamp(), $time ) ); |
|
363 | + public function to($time) { |
|
364 | + $first = $this->parse($time); |
|
365 | + if ( ! is_null($first)) { |
|
366 | + $this->set_events($this->filter_events($first->getTimestamp(), $time)); |
|
367 | 367 | } |
368 | 368 | return $this; |
369 | 369 | } |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @return null|Carbon |
379 | 379 | */ |
380 | - private function parse( $time ) { |
|
381 | - if ( is_int( $time ) ) { |
|
382 | - return Carbon::createFromTimestamp( $time, $this->timezone ); |
|
383 | - } elseif ( is_string( $time ) && ! empty( $time ) ) { |
|
384 | - return Carbon::parse( $time, $this->timezone ); |
|
385 | - } elseif ( $time instanceof Carbon ) { |
|
386 | - return $time->setTimezone( $this->timezone ); |
|
387 | - } elseif ( $time instanceof \DateTime ) { |
|
388 | - return Carbon::instance( $time )->setTimezone( $this->timezone ); |
|
380 | + private function parse($time) { |
|
381 | + if (is_int($time)) { |
|
382 | + return Carbon::createFromTimestamp($time, $this->timezone); |
|
383 | + } elseif (is_string($time) && ! empty($time)) { |
|
384 | + return Carbon::parse($time, $this->timezone); |
|
385 | + } elseif ($time instanceof Carbon) { |
|
386 | + return $time->setTimezone($this->timezone); |
|
387 | + } elseif ($time instanceof \DateTime) { |
|
388 | + return Carbon::instance($time)->setTimezone($this->timezone); |
|
389 | 389 | } |
390 | 390 | return null; |
391 | 391 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * @return null|Event |
399 | 399 | */ |
400 | 400 | public function get_first() { |
401 | - return array_shift( $this->events ); |
|
401 | + return array_shift($this->events); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @return null|Event |
410 | 410 | */ |
411 | 411 | public function get_last() { |
412 | - return array_pop( $this->events ); |
|
412 | + return array_pop($this->events); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | * @return null|Event |
421 | 421 | */ |
422 | 422 | public function get_upcoming() { |
423 | - return $this->get_closest( 'future' ); |
|
423 | + return $this->get_closest('future'); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @return null|Event |
432 | 432 | */ |
433 | 433 | public function get_latest() { |
434 | - return $this->get_closest( 'past' ); |
|
434 | + return $this->get_closest('past'); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -444,11 +444,11 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return null|Event |
446 | 446 | */ |
447 | - private function get_closest( $dir ) { |
|
448 | - if ( 'future' == $dir ) { |
|
449 | - return array_shift( $this->future()->get_events() ); |
|
450 | - } elseif ( 'past' == $dir ) { |
|
451 | - return array_shift( $this->past()->get_events() ); |
|
447 | + private function get_closest($dir) { |
|
448 | + if ('future' == $dir) { |
|
449 | + return array_shift($this->future()->get_events()); |
|
450 | + } elseif ('past' == $dir) { |
|
451 | + return array_shift($this->past()->get_events()); |
|
452 | 452 | } |
453 | 453 | return null; |
454 | 454 | } |
@@ -462,11 +462,11 @@ discard block |
||
462 | 462 | * |
463 | 463 | * @return array Multidimensional array with month number, week number and Event objects for each weekday. |
464 | 464 | */ |
465 | - public function get_year( $year ) { |
|
466 | - $y = intval( $year ); |
|
465 | + public function get_year($year) { |
|
466 | + $y = intval($year); |
|
467 | 467 | $months = array(); |
468 | - for ( $m = 1; $m <= 12; $m++ ) { |
|
469 | - $months[ strval( $m ) ] = $this->get_month( $y, $m ); |
|
468 | + for ($m = 1; $m <= 12; $m++) { |
|
469 | + $months[strval($m)] = $this->get_month($y, $m); |
|
470 | 470 | } |
471 | 471 | return $months; |
472 | 472 | } |
@@ -481,16 +481,16 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @return array Multidimensional array with week number, day of the week and array of Event objects for each week day. |
483 | 483 | */ |
484 | - public function get_month( $year, $month ) { |
|
485 | - $y = intval( $year ); |
|
486 | - $m = min( max( 1, absint( $month ) ), 12 ); |
|
487 | - $days = Carbon::createFromDate( $y, $m, 2, $this->timezone )->startOfMonth()->daysInMonth; |
|
484 | + public function get_month($year, $month) { |
|
485 | + $y = intval($year); |
|
486 | + $m = min(max(1, absint($month)), 12); |
|
487 | + $days = Carbon::createFromDate($y, $m, 2, $this->timezone)->startOfMonth()->daysInMonth; |
|
488 | 488 | $weeks = array(); |
489 | - for ( $d = 1; $d < $days; $d++ ) { |
|
490 | - $current = Carbon::createFromDate( $y, $m, $d ); |
|
489 | + for ($d = 1; $d < $days; $d++) { |
|
490 | + $current = Carbon::createFromDate($y, $m, $d); |
|
491 | 491 | $week = $current->weekOfYear; |
492 | 492 | $day = $current->dayOfWeek; |
493 | - $weeks[ strval( $week ) ][ strval( $day ) ] = $this->get_day( $y, $m, $d ); |
|
493 | + $weeks[strval($week)][strval($day)] = $this->get_day($y, $m, $d); |
|
494 | 494 | } |
495 | 495 | return $weeks; |
496 | 496 | } |
@@ -505,16 +505,16 @@ discard block |
||
505 | 505 | * |
506 | 506 | * @return array Associative array with day of the week for key and array of Event objects for value. |
507 | 507 | */ |
508 | - public function get_week( $year, $week ) { |
|
509 | - $y = intval( $year ); |
|
510 | - $w = absint( $week ); |
|
511 | - $m = date( 'n', strtotime( strval( $y ) . '-W' . strval( $w ) ) ); |
|
512 | - $month_dt = Carbon::createFromDate( $y, $m, 2, $this->timezone ); |
|
508 | + public function get_week($year, $week) { |
|
509 | + $y = intval($year); |
|
510 | + $w = absint($week); |
|
511 | + $m = date('n', strtotime(strval($y).'-W'.strval($w))); |
|
512 | + $month_dt = Carbon::createFromDate($y, $m, 2, $this->timezone); |
|
513 | 513 | $days = array(); |
514 | - for ( $d = 1; $d < $month_dt->daysInMonth; $d++ ) { |
|
515 | - $current = Carbon::createFromDate( $y, $m, $d ); |
|
516 | - if ( $w == $current->weekOfYear ) { |
|
517 | - $days[ strval( $current->dayOfWeek ) ] = $this->get_day( $y, $m, $d ); |
|
514 | + for ($d = 1; $d < $month_dt->daysInMonth; $d++) { |
|
515 | + $current = Carbon::createFromDate($y, $m, $d); |
|
516 | + if ($w == $current->weekOfYear) { |
|
517 | + $days[strval($current->dayOfWeek)] = $this->get_day($y, $m, $d); |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | return $days; |
@@ -531,13 +531,13 @@ discard block |
||
531 | 531 | * |
532 | 532 | * @return array Event objects for the day. |
533 | 533 | */ |
534 | - public function get_day( $year, $month, $day ) { |
|
535 | - $y = intval( $year ); |
|
536 | - $m = min( max( 1, absint( $month ) ), 12 ); |
|
537 | - $d = min( absint( $day ), 31 ); |
|
538 | - $from = Carbon::createFromDate( $y, $m, $d, $this->timezone )->startOfDay()->getTimestamp(); |
|
539 | - $to = Carbon::createFromDate( $y, $m, $d, $this->timezone )->endOfDay()->getTimestamp(); |
|
540 | - return $this->filter_events( $from, $to ); |
|
534 | + public function get_day($year, $month, $day) { |
|
535 | + $y = intval($year); |
|
536 | + $m = min(max(1, absint($month)), 12); |
|
537 | + $d = min(absint($day), 31); |
|
538 | + $from = Carbon::createFromDate($y, $m, $d, $this->timezone)->startOfDay()->getTimestamp(); |
|
539 | + $to = Carbon::createFromDate($y, $m, $d, $this->timezone)->endOfDay()->getTimestamp(); |
|
540 | + return $this->filter_events($from, $to); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | /** |
@@ -548,9 +548,9 @@ discard block |
||
548 | 548 | * @return array Event objects for today. |
549 | 549 | */ |
550 | 550 | public function get_today() { |
551 | - $start = Carbon::today( $this->timezone )->startOfDay()->getTimestamp(); |
|
552 | - $end = Carbon::today( $this->timezone )->endOfDay()->getTimestamp(); |
|
553 | - return $this->filter_events( $start, $end ); |
|
551 | + $start = Carbon::today($this->timezone)->startOfDay()->getTimestamp(); |
|
552 | + $end = Carbon::today($this->timezone)->endOfDay()->getTimestamp(); |
|
553 | + return $this->filter_events($start, $end); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -561,9 +561,9 @@ discard block |
||
561 | 561 | * @return array Event objects for tomorrow. |
562 | 562 | */ |
563 | 563 | public function get_tomorrow() { |
564 | - $start = Carbon::tomorrow( $this->timezone )->startOfDay()->getTimestamp(); |
|
565 | - $end = Carbon::tomorrow( $this->timezone )->endOfDay()->getTimestamp(); |
|
566 | - return $this->filter_events( $start, $end ); |
|
564 | + $start = Carbon::tomorrow($this->timezone)->startOfDay()->getTimestamp(); |
|
565 | + $end = Carbon::tomorrow($this->timezone)->endOfDay()->getTimestamp(); |
|
566 | + return $this->filter_events($start, $end); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | * @return array Event objects for yesterday. |
575 | 575 | */ |
576 | 576 | public function get_yesterday() { |
577 | - $start = Carbon::yesterday( $this->timezone )->startOfDay()->getTimestamp(); |
|
578 | - $end = Carbon::yesterday( $this->timezone )->endOfDay()->getTimestamp(); |
|
579 | - return $this->filter_events( $start, $end ); |
|
577 | + $start = Carbon::yesterday($this->timezone)->startOfDay()->getTimestamp(); |
|
578 | + $end = Carbon::yesterday($this->timezone)->endOfDay()->getTimestamp(); |
|
579 | + return $this->filter_events($start, $end); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -590,16 +590,16 @@ discard block |
||
590 | 590 | * |
591 | 591 | * @return array Filtered array of Event objects. |
592 | 592 | */ |
593 | - private function filter_events( $from, $to ) { |
|
594 | - $timestamps = array_keys( $this->events ); |
|
595 | - $lower_bound = array_filter( $timestamps, function( $ts ) use( $from ) { |
|
596 | - return intval( $ts ) > intval( $from ); |
|
593 | + private function filter_events($from, $to) { |
|
594 | + $timestamps = array_keys($this->events); |
|
595 | + $lower_bound = array_filter($timestamps, function($ts) use($from) { |
|
596 | + return intval($ts) > intval($from); |
|
597 | 597 | } ); |
598 | - $higher_bound = array_filter( $lower_bound, function( $ts ) use( $to ) { |
|
599 | - return intval( $ts ) > intval( $to ); |
|
598 | + $higher_bound = array_filter($lower_bound, function($ts) use($to) { |
|
599 | + return intval($ts) > intval($to); |
|
600 | 600 | } ); |
601 | - $filtered = array_combine( $higher_bound, $higher_bound ); |
|
602 | - return array_intersect_key( $this->events, $filtered ); |
|
601 | + $filtered = array_combine($higher_bound, $higher_bound); |
|
602 | + return array_intersect_key($this->events, $filtered); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | } |