@@ -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 | } |
@@ -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,44 +228,44 @@ 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 - 1000; |
237 | 237 | |
238 | - if ( $event->whole_day ) { |
|
239 | - $value = human_time_diff( $event->start, ( $event->end - 86500 ) ); |
|
238 | + if ($event->whole_day) { |
|
239 | + $value = human_time_diff($event->start, ($event->end - 86500)); |
|
240 | 240 | } else { |
241 | - $value = human_time_diff( $event->start, $event->end ); |
|
241 | + $value = human_time_diff($event->start, $event->end); |
|
242 | 242 | } |
243 | 243 | } else { |
244 | 244 | $duration = '-1'; |
245 | - $value = __( 'No end time', 'google-calendar-events' ); |
|
245 | + $value = __('No end time', 'google-calendar-events'); |
|
246 | 246 | } |
247 | - return ' <span class="simcal-event-duration" data-event-duration="' . $duration . '">' . $value . '</span>'; |
|
247 | + return ' <span class="simcal-event-duration" data-event-duration="'.$duration.'">'.$value.'</span>'; |
|
248 | 248 | |
249 | 249 | case 'location' : |
250 | 250 | case 'start-location' : |
251 | 251 | case 'end-location' : |
252 | 252 | $location = $tag == 'end-location' ? $event->end_location['address'] : $event->start_location['address']; |
253 | - return ' <span class="simcal-event-address simcal-event-start-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . wp_strip_all_tags( $location ) . '</span>'; |
|
253 | + return ' <span class="simcal-event-address simcal-event-start-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'.wp_strip_all_tags($location).'</span>'; |
|
254 | 254 | |
255 | 255 | case 'start-location-link': |
256 | 256 | case 'end-location-link' : |
257 | 257 | case 'maps-link' : |
258 | 258 | $location = $tag == 'end-location-link' ? $event->end_location['address'] : $event->start_location['address']; |
259 | - if ( ! empty( $location ) ) { |
|
260 | - $url = '//maps.google.com?q=' . urlencode( $location ); |
|
261 | - return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr ); |
|
259 | + if ( ! empty($location)) { |
|
260 | + $url = '//maps.google.com?q='.urlencode($location); |
|
261 | + return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr); |
|
262 | 262 | } |
263 | 263 | break; |
264 | 264 | |
265 | 265 | case 'link' : |
266 | 266 | case 'url' : |
267 | - $content = 'link' == $tag ? $calendar->get_event_html( $event, $partial ) : ''; |
|
268 | - return $this->make_link( $tag, $event->link, $content , $attr ); |
|
267 | + $content = 'link' == $tag ? $calendar->get_event_html($event, $partial) : ''; |
|
268 | + return $this->make_link($tag, $event->link, $content, $attr); |
|
269 | 269 | |
270 | 270 | case 'calendar' : |
271 | 271 | case 'feed-title' : |
@@ -287,22 +287,22 @@ discard block |
||
287 | 287 | |
288 | 288 | case 'attachments' : |
289 | 289 | $attachments = $event->get_attachments(); |
290 | - if ( ! empty( $attachments ) ) { |
|
291 | - return $this->get_attachments( $attachments ); |
|
290 | + if ( ! empty($attachments)) { |
|
291 | + return $this->get_attachments($attachments); |
|
292 | 292 | } |
293 | 293 | break; |
294 | 294 | |
295 | 295 | case 'attendees' : |
296 | 296 | $attendees = $event->get_attendees(); |
297 | - if ( ! empty( $attendees ) ) { |
|
298 | - return $this->get_attendees( $attendees, $attr ); |
|
297 | + if ( ! empty($attendees)) { |
|
298 | + return $this->get_attendees($attendees, $attr); |
|
299 | 299 | } |
300 | 300 | break; |
301 | 301 | |
302 | 302 | case 'organizer' : |
303 | 303 | $organizer = $event->get_organizer(); |
304 | - if ( ! empty( $organizer ) ) { |
|
305 | - return $this->get_organizer( $organizer, $attr ); |
|
304 | + if ( ! empty($organizer)) { |
|
305 | + return $this->get_organizer($organizer, $attr); |
|
306 | 306 | } |
307 | 307 | break; |
308 | 308 | |
@@ -311,35 +311,35 @@ discard block |
||
311 | 311 | * ================ */ |
312 | 312 | |
313 | 313 | case 'if-title': |
314 | - if ( ! empty( $event->title ) ) { |
|
315 | - return $calendar->get_event_html( $event, $partial ); |
|
314 | + if ( ! empty($event->title)) { |
|
315 | + return $calendar->get_event_html($event, $partial); |
|
316 | 316 | } |
317 | 317 | break; |
318 | 318 | |
319 | 319 | case 'if-description': |
320 | - if ( ! empty( $event->description ) ) { |
|
321 | - return $calendar->get_event_html( $event, $partial ); |
|
320 | + if ( ! empty($event->description)) { |
|
321 | + return $calendar->get_event_html($event, $partial); |
|
322 | 322 | } |
323 | 323 | break; |
324 | 324 | |
325 | 325 | case 'if-now' : |
326 | 326 | case 'if-not-now' : |
327 | 327 | |
328 | - $start_dt = $event->start_dt->setTimezone( $calendar->timezone ); |
|
328 | + $start_dt = $event->start_dt->setTimezone($calendar->timezone); |
|
329 | 329 | $start = $start_dt->getTimestamp(); |
330 | 330 | |
331 | - if ( $event->end_dt instanceof Carbon ) { |
|
332 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
331 | + if ($event->end_dt instanceof Carbon) { |
|
332 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
333 | 333 | } else { |
334 | 334 | return ''; |
335 | 335 | } |
336 | 336 | |
337 | - $now = ( $start <= $calendar->now ) && ( $end >= $calendar->now ); |
|
337 | + $now = ($start <= $calendar->now) && ($end >= $calendar->now); |
|
338 | 338 | |
339 | - if ( ( 'if-now' == $tag ) && $now ) { |
|
340 | - return $calendar->get_event_html( $event, $partial ); |
|
341 | - } elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) { |
|
342 | - return $calendar->get_event_html( $event, $partial ); |
|
339 | + if (('if-now' == $tag) && $now) { |
|
340 | + return $calendar->get_event_html($event, $partial); |
|
341 | + } elseif (('if-not-now' == $tag) && (false == $now)) { |
|
342 | + return $calendar->get_event_html($event, $partial); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | break; |
@@ -347,15 +347,15 @@ discard block |
||
347 | 347 | case 'if-started' : |
348 | 348 | case 'if-not-started' : |
349 | 349 | |
350 | - $start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
350 | + $start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
351 | 351 | |
352 | - if ( 'if-started' == $tag ) { |
|
353 | - if ( $start < $calendar->now ) { |
|
354 | - return $calendar->get_event_html( $event, $partial ); |
|
352 | + if ('if-started' == $tag) { |
|
353 | + if ($start < $calendar->now) { |
|
354 | + return $calendar->get_event_html($event, $partial); |
|
355 | 355 | } |
356 | - } elseif ( 'if-not-started' == $tag ) { |
|
357 | - if ( $start > $calendar->now ) { |
|
358 | - return $calendar->get_event_html( $event, $partial ); |
|
356 | + } elseif ('if-not-started' == $tag) { |
|
357 | + if ($start > $calendar->now) { |
|
358 | + return $calendar->get_event_html($event, $partial); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -364,17 +364,17 @@ discard block |
||
364 | 364 | case 'if-ended' : |
365 | 365 | case 'if-not-ended' : |
366 | 366 | |
367 | - if ( false !== $event->end ) { |
|
367 | + if (false !== $event->end) { |
|
368 | 368 | |
369 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
369 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
370 | 370 | |
371 | - if ( 'if-ended' == $tag ) { |
|
372 | - if ( $end < $calendar->now ) { |
|
373 | - return $calendar->get_event_html( $event, $partial ); |
|
371 | + if ('if-ended' == $tag) { |
|
372 | + if ($end < $calendar->now) { |
|
373 | + return $calendar->get_event_html($event, $partial); |
|
374 | 374 | } |
375 | - } elseif ( 'if-not-ended' == $tag ) { |
|
376 | - if ( $end > $calendar->now ) { |
|
377 | - return $calendar->get_event_html( $event, $partial ); |
|
375 | + } elseif ('if-not-ended' == $tag) { |
|
376 | + if ($end > $calendar->now) { |
|
377 | + return $calendar->get_event_html($event, $partial); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -383,14 +383,14 @@ discard block |
||
383 | 383 | break; |
384 | 384 | |
385 | 385 | case 'if-end-time' : |
386 | - if ( false !== $event->end ) { |
|
387 | - return $calendar->get_event_html( $event, $partial ); |
|
386 | + if (false !== $event->end) { |
|
387 | + return $calendar->get_event_html($event, $partial); |
|
388 | 388 | } |
389 | 389 | break; |
390 | 390 | |
391 | 391 | case 'if-no-end-time' : |
392 | - if ( false === $event->end ) { |
|
393 | - return $calendar->get_event_html( $event, $partial ); |
|
392 | + if (false === $event->end) { |
|
393 | + return $calendar->get_event_html($event, $partial); |
|
394 | 394 | } |
395 | 395 | break; |
396 | 396 | |
@@ -398,59 +398,59 @@ discard block |
||
398 | 398 | case 'if-whole-day' : |
399 | 399 | case 'if-not-all-day' : |
400 | 400 | case 'if-not-whole-day' : |
401 | - $bool = strstr( $tag, 'not' ) ? false : true; |
|
402 | - if ( $bool === $event->whole_day ) { |
|
403 | - return $calendar->get_event_html( $event, $partial ); |
|
401 | + $bool = strstr($tag, 'not') ? false : true; |
|
402 | + if ($bool === $event->whole_day) { |
|
403 | + return $calendar->get_event_html($event, $partial); |
|
404 | 404 | } |
405 | 405 | break; |
406 | 406 | |
407 | 407 | case 'if-recurring' : |
408 | - if ( ! empty( $event->recurrence ) ) { |
|
409 | - return $calendar->get_event_html( $event, $partial ); |
|
408 | + if ( ! empty($event->recurrence)) { |
|
409 | + return $calendar->get_event_html($event, $partial); |
|
410 | 410 | } |
411 | 411 | break; |
412 | 412 | |
413 | 413 | case 'if-not-recurring' : |
414 | - if ( false === $event->recurrence ) { |
|
415 | - return $calendar->get_event_html( $event, $partial ); |
|
414 | + if (false === $event->recurrence) { |
|
415 | + return $calendar->get_event_html($event, $partial); |
|
416 | 416 | } |
417 | 417 | break; |
418 | 418 | |
419 | 419 | case 'if-multi-day' : |
420 | - if ( false !== $event->multiple_days ) { |
|
421 | - return $calendar->get_event_html( $event, $partial ); |
|
420 | + if (false !== $event->multiple_days) { |
|
421 | + return $calendar->get_event_html($event, $partial); |
|
422 | 422 | } |
423 | 423 | break; |
424 | 424 | |
425 | 425 | case 'if-single-day' : |
426 | - if ( false === $event->multiple_days ) { |
|
427 | - return $calendar->get_event_html( $event, $partial ); |
|
426 | + if (false === $event->multiple_days) { |
|
427 | + return $calendar->get_event_html($event, $partial); |
|
428 | 428 | } |
429 | 429 | break; |
430 | 430 | |
431 | 431 | case 'if-location' : |
432 | 432 | case 'if-start-location' : |
433 | - if ( ! empty( $event->start_location['address'] ) ) { |
|
434 | - return $calendar->get_event_html( $event, $partial ); |
|
433 | + if ( ! empty($event->start_location['address'])) { |
|
434 | + return $calendar->get_event_html($event, $partial); |
|
435 | 435 | } |
436 | 436 | return false; |
437 | 437 | |
438 | 438 | case 'if-not-location' : |
439 | 439 | case 'if-not-start-location' : |
440 | - if ( empty( $event->start_location['address'] ) ) { |
|
441 | - return $calendar->get_event_html( $event, $partial ); |
|
440 | + if (empty($event->start_location['address'])) { |
|
441 | + return $calendar->get_event_html($event, $partial); |
|
442 | 442 | } |
443 | 443 | return ''; |
444 | 444 | |
445 | 445 | case 'if-not-end-location' : |
446 | - if ( empty( $event->end_location['address'] ) ) { |
|
447 | - return $calendar->get_event_html( $event, $partial ); |
|
446 | + if (empty($event->end_location['address'])) { |
|
447 | + return $calendar->get_event_html($event, $partial); |
|
448 | 448 | } |
449 | 449 | return ''; |
450 | 450 | |
451 | 451 | case 'if-end-location' : |
452 | - if ( ! empty( $event->end_location['address'] ) ) { |
|
453 | - return $calendar->get_event_html( $event, $partial ); |
|
452 | + if ( ! empty($event->end_location['address'])) { |
|
453 | + return $calendar->get_event_html($event, $partial); |
|
454 | 454 | } |
455 | 455 | return ''; |
456 | 456 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * ======= */ |
460 | 460 | |
461 | 461 | default : |
462 | - return wp_kses_post( $before . $partial . $after ); |
|
462 | + return wp_kses_post($before.$partial.$after); |
|
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
@@ -477,15 +477,15 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - private function limit_words( $text, $limit ) { |
|
480 | + private function limit_words($text, $limit) { |
|
481 | 481 | |
482 | - $text = wp_strip_all_tags( $text ); |
|
483 | - $limit = max( absint( $limit ), 0 ); |
|
482 | + $text = wp_strip_all_tags($text); |
|
483 | + $limit = max(absint($limit), 0); |
|
484 | 484 | |
485 | - if ( $limit > 0 && ( str_word_count( $text, 0 ) > $limit ) ) { |
|
486 | - $words = str_word_count( $text, 2 ); |
|
487 | - $pos = array_keys( $words ); |
|
488 | - $text = trim( substr( $text, 0, $pos[ $limit ] ) ) . '…'; |
|
485 | + if ($limit > 0 && (str_word_count($text, 0) > $limit)) { |
|
486 | + $words = str_word_count($text, 2); |
|
487 | + $pos = array_keys($words); |
|
488 | + $text = trim(substr($text, 0, $pos[$limit])).'…'; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | return $text; |
@@ -502,26 +502,26 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - private function get_title( $title, $attr ) { |
|
505 | + private function get_title($title, $attr) { |
|
506 | 506 | |
507 | - if ( empty( $title ) ) { |
|
507 | + if (empty($title)) { |
|
508 | 508 | return ''; |
509 | 509 | } |
510 | 510 | |
511 | - $attr = array_merge( array( |
|
512 | - 'html' => '', // Parse HTML |
|
513 | - 'limit' => 0, // Trim length to amount of words |
|
514 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
511 | + $attr = array_merge(array( |
|
512 | + 'html' => '', // Parse HTML |
|
513 | + 'limit' => 0, // Trim length to amount of words |
|
514 | + ), (array) shortcode_parse_atts($attr)); |
|
515 | 515 | |
516 | - if ( ! empty( $attr['html'] ) ) { |
|
517 | - $title = wp_kses_post( $title ); |
|
516 | + if ( ! empty($attr['html'])) { |
|
517 | + $title = wp_kses_post($title); |
|
518 | 518 | $tag = 'div'; |
519 | 519 | } else { |
520 | - $title = $this->limit_words( $title, $attr['limit'] ); |
|
520 | + $title = $this->limit_words($title, $attr['limit']); |
|
521 | 521 | $tag = 'span'; |
522 | 522 | } |
523 | 523 | |
524 | - return '<' . $tag . ' class="simcal-event-title" itemprop="name">' . $title . '</' . $tag . '>'; |
|
524 | + return '<'.$tag.' class="simcal-event-title" itemprop="name">'.$title.'</'.$tag.'>'; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -535,40 +535,40 @@ discard block |
||
535 | 535 | * |
536 | 536 | * @return string |
537 | 537 | */ |
538 | - private function get_description( $description, $attr ) { |
|
538 | + private function get_description($description, $attr) { |
|
539 | 539 | |
540 | - if ( empty( $description ) ) { |
|
540 | + if (empty($description)) { |
|
541 | 541 | return ''; |
542 | 542 | } |
543 | 543 | |
544 | - $attr = array_merge( array( |
|
545 | - 'limit' => 0, // Trim length to number of words |
|
546 | - 'html' => 'no', // Parse HTML content |
|
547 | - 'markdown' => 'no', // Parse Markdown content |
|
548 | - 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
549 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
544 | + $attr = array_merge(array( |
|
545 | + 'limit' => 0, // Trim length to number of words |
|
546 | + 'html' => 'no', // Parse HTML content |
|
547 | + 'markdown' => 'no', // Parse Markdown content |
|
548 | + 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
549 | + ), (array) shortcode_parse_atts($attr)); |
|
550 | 550 | |
551 | - $allow_html = 'no' != $attr['html'] ? true : false; |
|
551 | + $allow_html = 'no' != $attr['html'] ? true : false; |
|
552 | 552 | $allow_md = 'no' != $attr['markdown'] ? true : false; |
553 | 553 | |
554 | 554 | $html = '<div class="simcal-event-description" itemprop="description">'; |
555 | 555 | |
556 | 556 | // Markdown and HTML don't play well together, use one or the other in the same tag. |
557 | - if ( $allow_html || $allow_md ) { |
|
558 | - if ( $allow_html ) { |
|
559 | - $html .= wp_kses_post( $description ); |
|
560 | - } elseif ( $allow_md ) { |
|
557 | + if ($allow_html || $allow_md) { |
|
558 | + if ($allow_html) { |
|
559 | + $html .= wp_kses_post($description); |
|
560 | + } elseif ($allow_md) { |
|
561 | 561 | $markdown = new \Parsedown(); |
562 | - $html .= $markdown->text( wp_strip_all_tags( $description ) ); |
|
562 | + $html .= $markdown->text(wp_strip_all_tags($description)); |
|
563 | 563 | } |
564 | 564 | } else { |
565 | - $html .= $this->limit_words( $description, $attr['limit'] ); |
|
565 | + $html .= $this->limit_words($description, $attr['limit']); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | $html .= '</div>'; |
569 | 569 | |
570 | - if ( 'no' != $attr['autolink'] ) { |
|
571 | - $html = ' ' . make_clickable( $html ); |
|
570 | + if ('no' != $attr['autolink']) { |
|
571 | + $html = ' '.make_clickable($html); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | return $html; |
@@ -584,76 +584,76 @@ discard block |
||
584 | 584 | * |
585 | 585 | * @return string |
586 | 586 | */ |
587 | - private function get_when( Event $event ) { |
|
587 | + private function get_when(Event $event) { |
|
588 | 588 | |
589 | - $start = $event->start_dt->setTimezone( $event->timezone ); |
|
590 | - $end = ! is_null( $event->end_dt ) ? $event->end_dt->setTimezone( $event->timezone ) : null; |
|
589 | + $start = $event->start_dt->setTimezone($event->timezone); |
|
590 | + $end = ! is_null($event->end_dt) ? $event->end_dt->setTimezone($event->timezone) : null; |
|
591 | 591 | |
592 | 592 | $time_start = ''; |
593 | 593 | $time_end = ''; |
594 | 594 | |
595 | - if ( ! $event->whole_day ) { |
|
595 | + if ( ! $event->whole_day) { |
|
596 | 596 | |
597 | - $time_start = $this->calendar->datetime_separator . |
|
598 | - ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
599 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
600 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
601 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
602 | - date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
597 | + $time_start = $this->calendar->datetime_separator. |
|
598 | + ' <span class="simcal-event-start simcal-event-start-time" '. |
|
599 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
600 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
601 | + 'itemprop="startDate" content="'.$start->toIso8601String().'">'. |
|
602 | + date_i18n($this->calendar->time_format, $start->getTimestamp()). |
|
603 | 603 | '</span> '; |
604 | 604 | |
605 | - if ( $end instanceof Carbon ) { |
|
605 | + if ($end instanceof Carbon) { |
|
606 | 606 | |
607 | - $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . |
|
608 | - 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
609 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
610 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
611 | - date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
607 | + $time_end = ' <span class="simcal-event-end simcal-event-end-time" '. |
|
608 | + 'data-event-end="'.$end->getTimestamp().'" '. |
|
609 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
610 | + 'itemprop="endDate" content="'.$end->toIso8601String().'">'. |
|
611 | + date_i18n($this->calendar->time_format, $end->getTimestamp()). |
|
612 | 612 | '</span> '; |
613 | 613 | |
614 | 614 | } |
615 | 615 | |
616 | 616 | } |
617 | 617 | |
618 | - if ( $event->multiple_days ) { |
|
618 | + if ($event->multiple_days) { |
|
619 | 619 | |
620 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
621 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
622 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
623 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
624 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
625 | - '</span> ' . |
|
620 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
621 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
622 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
623 | + 'itemprop="startDate" content="'.$start->toIso8601String().'">'. |
|
624 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
625 | + '</span> '. |
|
626 | 626 | $time_start; |
627 | 627 | |
628 | - if ( $end instanceof Carbon ) { |
|
628 | + if ($end instanceof Carbon) { |
|
629 | 629 | |
630 | - $end = ( $event->whole_day ? Carbon::createFromTimestamp( $end->getTimestamp() )->startOfDay()->subSeconds( 1 ) : $end ); |
|
630 | + $end = ($event->whole_day ? Carbon::createFromTimestamp($end->getTimestamp())->startOfDay()->subSeconds(1) : $end); |
|
631 | 631 | |
632 | - $output .= '-' . |
|
633 | - ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
634 | - 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
635 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
636 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
637 | - date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
638 | - '</span> ' . |
|
632 | + $output .= '-'. |
|
633 | + ' <span class="simcal-event-start simcal-event-end-date" '. |
|
634 | + 'data-event-start="'.$end->getTimestamp().'" '. |
|
635 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
636 | + 'itemprop="endDate" content="'.$end->toIso8601String().'">'. |
|
637 | + date_i18n($this->calendar->date_format, $end->getTimestamp()). |
|
638 | + '</span> '. |
|
639 | 639 | $time_end; |
640 | 640 | } |
641 | 641 | |
642 | 642 | } else { |
643 | 643 | |
644 | - $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
|
644 | + $time_end = ! empty($time_start) && ! empty($time_end) ? ' - '.$time_end : ''; |
|
645 | 645 | |
646 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
647 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
648 | - 'data-event-format="' . $this->calendar->date_format . '">' . |
|
649 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
650 | - '</span> ' . |
|
651 | - $time_start . |
|
646 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
647 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
648 | + 'data-event-format="'.$this->calendar->date_format.'">'. |
|
649 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
650 | + '</span> '. |
|
651 | + $time_start. |
|
652 | 652 | $time_end; |
653 | 653 | |
654 | 654 | } |
655 | 655 | |
656 | - return trim( $output ); |
|
656 | + return trim($output); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | /** |
@@ -668,49 +668,49 @@ discard block |
||
668 | 668 | * |
669 | 669 | * @return string |
670 | 670 | */ |
671 | - private function get_dt( $tag, Event $event, $attr ) { |
|
671 | + private function get_dt($tag, Event $event, $attr) { |
|
672 | 672 | |
673 | - $bound = 0 === strpos( $tag, 'end' ) ? 'end' : 'start'; |
|
674 | - if ( ( 'end' == $bound ) && ( false === $event->end ) ) { |
|
673 | + $bound = 0 === strpos($tag, 'end') ? 'end' : 'start'; |
|
674 | + if (('end' == $bound) && (false === $event->end)) { |
|
675 | 675 | return ''; |
676 | 676 | } |
677 | 677 | |
678 | - $dt = $bound . '_dt'; |
|
679 | - if ( ! $event->$dt instanceof Carbon ) { |
|
678 | + $dt = $bound.'_dt'; |
|
679 | + if ( ! $event->$dt instanceof Carbon) { |
|
680 | 680 | return ''; |
681 | 681 | } |
682 | - $event_dt = $event->$dt->setTimezone( $event->timezone ); |
|
682 | + $event_dt = $event->$dt->setTimezone($event->timezone); |
|
683 | 683 | |
684 | - $attr = array_merge( array( |
|
684 | + $attr = array_merge(array( |
|
685 | 685 | 'format' => '', |
686 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
686 | + ), (array) shortcode_parse_atts($attr)); |
|
687 | 687 | |
688 | - $format = ltrim( strstr( $tag, '-' ), '-' ); |
|
688 | + $format = ltrim(strstr($tag, '-'), '-'); |
|
689 | 689 | $dt_format = ''; |
690 | - if ( ! empty( $attr['format'] ) ) { |
|
691 | - $dt_format = esc_attr( wp_strip_all_tags( $attr['format'] ) ); |
|
692 | - } elseif ( 'date' == $format ) { |
|
690 | + if ( ! empty($attr['format'])) { |
|
691 | + $dt_format = esc_attr(wp_strip_all_tags($attr['format'])); |
|
692 | + } elseif ('date' == $format) { |
|
693 | 693 | $dt_format = $this->calendar->date_format; |
694 | - } elseif ( 'time' == $format ) { |
|
694 | + } elseif ('time' == $format) { |
|
695 | 695 | $dt_format = $this->calendar->time_format; |
696 | 696 | } |
697 | 697 | |
698 | - if ( 'human' == $format ) { |
|
699 | - $value = human_time_diff( $event_dt->getTimestamp(), Carbon::now( $event->timezone )->getTimestamp() ); |
|
698 | + if ('human' == $format) { |
|
699 | + $value = human_time_diff($event_dt->getTimestamp(), Carbon::now($event->timezone)->getTimestamp()); |
|
700 | 700 | } else { |
701 | 701 | |
702 | - if ( $event->whole_day ) { |
|
703 | - $value = date_i18n( $dt_format, $event_dt->getTimestamp() - 86400 ); |
|
702 | + if ($event->whole_day) { |
|
703 | + $value = date_i18n($dt_format, $event_dt->getTimestamp() - 86400); |
|
704 | 704 | } else { |
705 | - $value = date_i18n( $dt_format, $event_dt->getTimestamp() ); |
|
705 | + $value = date_i18n($dt_format, $event_dt->getTimestamp()); |
|
706 | 706 | } |
707 | 707 | } |
708 | 708 | |
709 | - return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '"' . |
|
710 | - 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '"' . |
|
711 | - 'data-event-format="' . $dt_format . '"' . |
|
712 | - 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . |
|
713 | - $value . |
|
709 | + return '<span class="simcal-event-'.$bound.' '.'simcal-event-'.$bound.'-'.$format.'"'. |
|
710 | + 'data-event-'.$bound.'="'.$event_dt->getTimestamp().'"'. |
|
711 | + 'data-event-format="'.$dt_format.'"'. |
|
712 | + 'itemprop="'.$bound.'Date" content="'.$event_dt->toIso8601String().'">'. |
|
713 | + $value. |
|
714 | 714 | '</span>'; |
715 | 715 | } |
716 | 716 | |
@@ -727,23 +727,23 @@ discard block |
||
727 | 727 | * |
728 | 728 | * @return string |
729 | 729 | */ |
730 | - private function make_link( $tag, $url, $content, $attr ) { |
|
730 | + private function make_link($tag, $url, $content, $attr) { |
|
731 | 731 | |
732 | - if ( empty( $url ) ) { |
|
732 | + if (empty($url)) { |
|
733 | 733 | return ''; |
734 | 734 | } |
735 | 735 | |
736 | - $text = empty( $content ) ? $url : $content; |
|
736 | + $text = empty($content) ? $url : $content; |
|
737 | 737 | |
738 | - $attr = array_merge( array( |
|
739 | - 'autolink' => false, // Convert url to link anchor |
|
740 | - 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
741 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
738 | + $attr = array_merge(array( |
|
739 | + 'autolink' => false, // Convert url to link anchor |
|
740 | + 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
741 | + ), (array) shortcode_parse_atts($attr)); |
|
742 | 742 | |
743 | 743 | $anchor = $tag != 'url' ? 'yes' : $attr['autolink']; |
744 | 744 | $target = $attr['newwindow'] !== false ? 'target="_blank"' : ''; |
745 | 745 | |
746 | - return $anchor !== false ? ' <a href="' . esc_url( $url ) . '" ' . $target . '>' . $text . '</a>' : ' ' . $text; |
|
746 | + return $anchor !== false ? ' <a href="'.esc_url($url).'" '.$target.'>'.$text.'</a>' : ' '.$text; |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | /** |
@@ -756,20 +756,20 @@ discard block |
||
756 | 756 | * |
757 | 757 | * @return string |
758 | 758 | */ |
759 | - private function get_attachments( $attachments ) { |
|
759 | + private function get_attachments($attachments) { |
|
760 | 760 | |
761 | - $html = '<ul class="simcal-attachments">' . "\n\t"; |
|
761 | + $html = '<ul class="simcal-attachments">'."\n\t"; |
|
762 | 762 | |
763 | - foreach ( $attachments as $attachment ) { |
|
763 | + foreach ($attachments as $attachment) { |
|
764 | 764 | $html .= '<li class="simcal-attachment">'; |
765 | - $html .= '<a href="' . $attachment['url'] . '" target="_blank">'; |
|
766 | - $html .= ! empty( $attachment['icon'] ) ? '<img src="' . $attachment['icon'] . '" />' : ''; |
|
767 | - $html .= '<span>' . $attachment['name'] . '</span>'; |
|
765 | + $html .= '<a href="'.$attachment['url'].'" target="_blank">'; |
|
766 | + $html .= ! empty($attachment['icon']) ? '<img src="'.$attachment['icon'].'" />' : ''; |
|
767 | + $html .= '<span>'.$attachment['name'].'</span>'; |
|
768 | 768 | $html .= '</a>'; |
769 | - $html .= '</li>' . "\n"; |
|
769 | + $html .= '</li>'."\n"; |
|
770 | 770 | } |
771 | 771 | |
772 | - $html .= '</ul>' . "\n"; |
|
772 | + $html .= '</ul>'."\n"; |
|
773 | 773 | |
774 | 774 | return $html; |
775 | 775 | } |
@@ -785,41 +785,41 @@ discard block |
||
785 | 785 | * |
786 | 786 | * @return string |
787 | 787 | */ |
788 | - private function get_attendees( $attendees, $attr ) { |
|
788 | + private function get_attendees($attendees, $attr) { |
|
789 | 789 | |
790 | - $attr = array_merge( array( |
|
791 | - 'photo' => 'show', // show/hide attendee photo |
|
792 | - 'email' => 'hide', // show/hide attendee email address |
|
793 | - 'rsvp' => 'hide', // show/hide rsvp response status |
|
794 | - 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
795 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
790 | + $attr = array_merge(array( |
|
791 | + 'photo' => 'show', // show/hide attendee photo |
|
792 | + 'email' => 'hide', // show/hide attendee email address |
|
793 | + 'rsvp' => 'hide', // show/hide rsvp response status |
|
794 | + 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
795 | + ), (array) shortcode_parse_atts($attr)); |
|
796 | 796 | |
797 | - $html = '<ul class="simcal-attendees" itemprop="attendees">' . "\n\t"; |
|
797 | + $html = '<ul class="simcal-attendees" itemprop="attendees">'."\n\t"; |
|
798 | 798 | |
799 | 799 | $known = 0; |
800 | 800 | $unknown = 0; |
801 | 801 | |
802 | - foreach ( $attendees as $attendee ) { |
|
802 | + foreach ($attendees as $attendee) { |
|
803 | 803 | |
804 | - if ( 'yes' == $attr['response'] && 'yes' != $attendee['response'] ) { |
|
804 | + if ('yes' == $attr['response'] && 'yes' != $attendee['response']) { |
|
805 | 805 | continue; |
806 | - } elseif ( 'no' == $attr['response'] && 'no' != $attendee['response'] ) { |
|
806 | + } elseif ('no' == $attr['response'] && 'no' != $attendee['response']) { |
|
807 | 807 | continue; |
808 | - } elseif ( 'maybe' == $attr['response'] && ! in_array( $attendee['response'], array( 'yes', 'maybe' ) ) ) { |
|
808 | + } elseif ('maybe' == $attr['response'] && ! in_array($attendee['response'], array('yes', 'maybe'))) { |
|
809 | 809 | continue; |
810 | 810 | } |
811 | 811 | |
812 | - if ( ! empty( $attendee['name'] ) ) { |
|
812 | + if ( ! empty($attendee['name'])) { |
|
813 | 813 | |
814 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $attendee['photo'] . '" itemprop="image" />' : ''; |
|
815 | - $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response( $attendee['response'] ) : ''; |
|
816 | - $guest = $photo . '<span itemprop="name">' . $attendee['name'] . $response . '</span>'; |
|
814 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$attendee['photo'].'" itemprop="image" />' : ''; |
|
815 | + $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response($attendee['response']) : ''; |
|
816 | + $guest = $photo.'<span itemprop="name">'.$attendee['name'].$response.'</span>'; |
|
817 | 817 | |
818 | - if ( ! empty( $attendee['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
819 | - $guest = sprintf( '<a href="mailto:' . $attendee['email'] . '" itemprop="email">%s</a>', $guest ); |
|
818 | + if ( ! empty($attendee['email']) && ('show' == $attr['email'])) { |
|
819 | + $guest = sprintf('<a href="mailto:'.$attendee['email'].'" itemprop="email">%s</a>', $guest); |
|
820 | 820 | } |
821 | 821 | |
822 | - $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">' . $guest . '</li>' . "\n"; |
|
822 | + $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">'.$guest.'</li>'."\n"; |
|
823 | 823 | |
824 | 824 | $known++; |
825 | 825 | |
@@ -830,21 +830,21 @@ discard block |
||
830 | 830 | } |
831 | 831 | } |
832 | 832 | |
833 | - if ( $unknown > 0 ) { |
|
834 | - if ( $known > 0 ) { |
|
833 | + if ($unknown > 0) { |
|
834 | + if ($known > 0) { |
|
835 | 835 | /* translators: One more person attending the event. */ |
836 | - $others = sprintf( _n( '1 more attendee', '%s more attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
836 | + $others = sprintf(_n('1 more attendee', '%s more attendees', $unknown, 'google-calendar-events'), $unknown); |
|
837 | 837 | } else { |
838 | 838 | /* translators: One or more persons attending the event whose name is unknown. */ |
839 | - $others = sprintf( _n( '1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
839 | + $others = sprintf(_n('1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events'), $unknown); |
|
840 | 840 | } |
841 | - $photo = $attr['photo'] !== 'hide' ? get_avatar( '', 128 ) : ''; |
|
842 | - $html .= '<li class="simcal-attendee simcal-attendee-anonymous">' . $photo . '<span>' . $others . '</span></li>' . "\n"; |
|
843 | - } elseif ( $known === 0 ) { |
|
844 | - $html .= '<li class="simcal-attendee">' . _x( 'No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events' ) . '</li>' . "\n"; |
|
841 | + $photo = $attr['photo'] !== 'hide' ? get_avatar('', 128) : ''; |
|
842 | + $html .= '<li class="simcal-attendee simcal-attendee-anonymous">'.$photo.'<span>'.$others.'</span></li>'."\n"; |
|
843 | + } elseif ($known === 0) { |
|
844 | + $html .= '<li class="simcal-attendee">'._x('No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events').'</li>'."\n"; |
|
845 | 845 | } |
846 | 846 | |
847 | - $html .= '</ul>' . "\n"; |
|
847 | + $html .= '</ul>'."\n"; |
|
848 | 848 | |
849 | 849 | return $html; |
850 | 850 | } |
@@ -858,23 +858,23 @@ discard block |
||
858 | 858 | * |
859 | 859 | * @return string |
860 | 860 | */ |
861 | - private function get_rsvp_response( $response ) { |
|
861 | + private function get_rsvp_response($response) { |
|
862 | 862 | |
863 | - if ( 'yes' == $response ) { |
|
863 | + if ('yes' == $response) { |
|
864 | 864 | /* translators: Someone replied with 'yes' to a rsvp request. */ |
865 | - $rsvp = __( 'Attending', 'google-calendar-events' ); |
|
866 | - } elseif ( 'no' == $response ) { |
|
865 | + $rsvp = __('Attending', 'google-calendar-events'); |
|
866 | + } elseif ('no' == $response) { |
|
867 | 867 | /* translators: Someone replied with 'no' to a rsvp request. */ |
868 | - $rsvp = __( 'Not attending', 'google-calendar-events' ); |
|
869 | - } elseif ( 'maybe' == $response ) { |
|
868 | + $rsvp = __('Not attending', 'google-calendar-events'); |
|
869 | + } elseif ('maybe' == $response) { |
|
870 | 870 | /* translators: Someone replied with 'maybe' to a rsvp request. */ |
871 | - $rsvp = __( 'Maybe attending', 'google-calendar-events' ); |
|
871 | + $rsvp = __('Maybe attending', 'google-calendar-events'); |
|
872 | 872 | } else { |
873 | 873 | /* translators: Someone did not send yet a rsvp confirmation to join an event. */ |
874 | - $rsvp = __( 'Response pending', 'google-calendar-events' ); |
|
874 | + $rsvp = __('Response pending', 'google-calendar-events'); |
|
875 | 875 | } |
876 | 876 | |
877 | - return ' <small>(' . $rsvp . ')</small>'; |
|
877 | + return ' <small>('.$rsvp.')</small>'; |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | /** |
@@ -888,21 +888,21 @@ discard block |
||
888 | 888 | * |
889 | 889 | * @return string |
890 | 890 | */ |
891 | - private function get_organizer( $organizer, $attr ) { |
|
891 | + private function get_organizer($organizer, $attr) { |
|
892 | 892 | |
893 | - $attr = array_merge( array( |
|
894 | - 'photo' => 'show', // show/hide attendee photo |
|
895 | - 'email' => 'hide', // show/hide attendee email address |
|
896 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
893 | + $attr = array_merge(array( |
|
894 | + 'photo' => 'show', // show/hide attendee photo |
|
895 | + 'email' => 'hide', // show/hide attendee email address |
|
896 | + ), (array) shortcode_parse_atts($attr)); |
|
897 | 897 | |
898 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $organizer['photo'] . '" itemprop="image" />' : ''; |
|
899 | - $organizer_html = $photo . '<span itemprop="name">' . $organizer['name'] . '</span>'; |
|
898 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$organizer['photo'].'" itemprop="image" />' : ''; |
|
899 | + $organizer_html = $photo.'<span itemprop="name">'.$organizer['name'].'</span>'; |
|
900 | 900 | |
901 | - if ( ! empty( $organizer['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
902 | - $organizer_html = sprintf( '<a href="mailto:' . $organizer['email'] . '" itemprop="email">%s</a>', $organizer_html ); |
|
901 | + if ( ! empty($organizer['email']) && ('show' == $attr['email'])) { |
|
902 | + $organizer_html = sprintf('<a href="mailto:'.$organizer['email'].'" itemprop="email">%s</a>', $organizer_html); |
|
903 | 903 | } |
904 | 904 | |
905 | - return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">' . $organizer_html . '</div>'; |
|
905 | + return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">'.$organizer_html.'</div>'; |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | /** |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | // This is largely borrowed on get_shortcode_regex() from WordPress Core. |
928 | 928 | // @see /wp-includes/shortcodes.php (with some modification) |
929 | 929 | |
930 | - $tagregexp = implode( '|', array_values( $this->tags ) ); |
|
930 | + $tagregexp = implode('|', array_values($this->tags)); |
|
931 | 931 | |
932 | 932 | return '/' |
933 | 933 | . '\\[' // 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 | } |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | return array( |
83 | 83 | 'name' => $this->feed->name, |
84 | 84 | 'description' => __( "To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events' ) . |
85 | - '<br/><br/>' . |
|
86 | - '<em style="font-size: 14px;">' . |
|
87 | - sprintf( __( '<strong>Note:</strong> A Google API key is not needed for calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong>.', 'google-calendar-events' ), |
|
88 | - simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'settings-link' ) |
|
89 | - ) . |
|
90 | - '</em>', |
|
85 | + '<br/><br/>' . |
|
86 | + '<em style="font-size: 14px;">' . |
|
87 | + sprintf( __( '<strong>Note:</strong> A Google API key is not needed for calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong>.', 'google-calendar-events' ), |
|
88 | + simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'settings-link' ) |
|
89 | + ) . |
|
90 | + '</em>', |
|
91 | 91 | 'fields' => array( |
92 | 92 | 'api_key' => array( |
93 | 93 | 'type' => 'standard', |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | 'post' => $post_id, |
274 | 274 | 'dismissable' => false, |
275 | 275 | 'content' => '<p>' . |
276 | - '<i class="simcal-icon-warning"></i> ' . |
|
277 | - sprintf( |
|
278 | - __( 'Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events' ), |
|
279 | - admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds' ) |
|
280 | - ) . |
|
281 | - '</p>', |
|
276 | + '<i class="simcal-icon-warning"></i> ' . |
|
277 | + sprintf( |
|
278 | + __( 'Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events' ), |
|
279 | + admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds' ) |
|
280 | + ) . |
|
281 | + '</p>', |
|
282 | 282 | ) |
283 | 283 | ); |
284 | 284 | |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | 'post' => $post_id, |
306 | 306 | 'dismissable' => false, |
307 | 307 | 'content' => '<p>' . |
308 | - '<i class="simcal-icon-warning"></i> ' . |
|
309 | - __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' ) . |
|
310 | - '<br>' . $message . '<br>' . |
|
311 | - __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) . |
|
312 | - '</p>', |
|
308 | + '<i class="simcal-icon-warning"></i> ' . |
|
309 | + __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' ) . |
|
310 | + '<br>' . $message . '<br>' . |
|
311 | + __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) . |
|
312 | + '</p>', |
|
313 | 313 | ) |
314 | 314 | ); |
315 | 315 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | use SimpleCalendar\Admin\Notice; |
11 | 11 | use SimpleCalendar\Feeds\Google; |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param string $google_api_key |
55 | 55 | * @param string $google_calendar_id |
56 | 56 | */ |
57 | - public function __construct( Google $feed, $google_api_key, $google_calendar_id ) { |
|
57 | + public function __construct(Google $feed, $google_api_key, $google_calendar_id) { |
|
58 | 58 | |
59 | 59 | $this->feed = $feed; |
60 | 60 | $this->google_api_key = $google_api_key; |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | |
63 | 63 | $screen = simcal_is_admin_screen(); |
64 | 64 | |
65 | - if ( 'calendar' == $screen ) { |
|
66 | - $this->test_api_key_connection( $this->google_calendar_id ); |
|
67 | - add_filter( 'simcal_settings_meta_tabs_li', array( $this, 'add_settings_meta_tab_li' ), 10, 1 ); |
|
68 | - add_action( 'simcal_settings_meta_panels', array( $this, 'add_settings_meta_panel' ), 10, 1 ); |
|
65 | + if ('calendar' == $screen) { |
|
66 | + $this->test_api_key_connection($this->google_calendar_id); |
|
67 | + add_filter('simcal_settings_meta_tabs_li', array($this, 'add_settings_meta_tab_li'), 10, 1); |
|
68 | + add_action('simcal_settings_meta_panels', array($this, 'add_settings_meta_panel'), 10, 1); |
|
69 | 69 | } |
70 | 70 | |
71 | - add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 ); |
|
71 | + add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -81,20 +81,20 @@ discard block |
||
81 | 81 | public function settings_fields() { |
82 | 82 | return array( |
83 | 83 | 'name' => $this->feed->name, |
84 | - 'description' => __( "To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events' ) . |
|
85 | - '<br/><br/>' . |
|
86 | - '<em style="font-size: 14px;">' . |
|
87 | - sprintf( __( '<strong>Note:</strong> A Google API key is not needed for calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong>.', 'google-calendar-events' ), |
|
88 | - simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'settings-link' ) |
|
89 | - ) . |
|
84 | + 'description' => __("To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events'). |
|
85 | + '<br/><br/>'. |
|
86 | + '<em style="font-size: 14px;">'. |
|
87 | + sprintf(__('<strong>Note:</strong> A Google API key is not needed for calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong>.', 'google-calendar-events'), |
|
88 | + simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'settings-link') |
|
89 | + ). |
|
90 | 90 | '</em>', |
91 | 91 | 'fields' => array( |
92 | 92 | 'api_key' => array( |
93 | 93 | 'type' => 'standard', |
94 | 94 | 'subtype' => 'text', |
95 | - 'class' => array( 'simcal-wide-text regular-text', 'ltr' ), |
|
96 | - 'title' => __( 'Google API Key', 'google-calendar-events' ), |
|
97 | - 'validation' => array( $this, 'check_google_api_key' ), |
|
95 | + 'class' => array('simcal-wide-text regular-text', 'ltr'), |
|
96 | + 'title' => __('Google API Key', 'google-calendar-events'), |
|
97 | + 'validation' => array($this, 'check_google_api_key'), |
|
98 | 98 | ), |
99 | 99 | ), |
100 | 100 | ); |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return true|string |
115 | 115 | */ |
116 | - public function check_google_api_key( $api_key = '' ) { |
|
116 | + public function check_google_api_key($api_key = '') { |
|
117 | 117 | |
118 | 118 | $message = ''; |
119 | 119 | $has_errors = false; |
120 | 120 | |
121 | - if ( empty( $api_key ) ){ |
|
121 | + if (empty($api_key)) { |
|
122 | 122 | $api_key = $this->google_api_key; |
123 | - if ( empty( $api_key ) ) { |
|
124 | - $settings = get_option( 'simple-calendar_settings_feeds' ); |
|
125 | - $api_key = isset( $settings['google']['api_key'] ) ? esc_attr( $settings['google']['api_key'] ) : ''; |
|
123 | + if (empty($api_key)) { |
|
124 | + $settings = get_option('simple-calendar_settings_feeds'); |
|
125 | + $api_key = isset($settings['google']['api_key']) ? esc_attr($settings['google']['api_key']) : ''; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | - $message = '<p class="description">' . |
|
130 | - sprintf( __( '<a href="%s" target="_blank">Step-by-step instructions</a> ', 'google-calendar-events' ), |
|
131 | - simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/google-api-key/', 'core-plugin', 'settings-link' ) |
|
132 | - ) . |
|
133 | - '<br/>' . |
|
134 | - sprintf( __( '<a href="%s" target="_blank">Google Developers Console</a> ', 'google-calendar-events' ), |
|
135 | - simcal_get_url( 'gdev-console' ) |
|
136 | - ) . |
|
129 | + $message = '<p class="description">'. |
|
130 | + sprintf(__('<a href="%s" target="_blank">Step-by-step instructions</a> ', 'google-calendar-events'), |
|
131 | + simcal_ga_campaign_url(simcal_get_url('docs').'/google-api-key/', 'core-plugin', 'settings-link') |
|
132 | + ). |
|
133 | + '<br/>'. |
|
134 | + sprintf(__('<a href="%s" target="_blank">Google Developers Console</a> ', 'google-calendar-events'), |
|
135 | + simcal_get_url('gdev-console') |
|
136 | + ). |
|
137 | 137 | '</p>'; |
138 | 138 | |
139 | 139 | return $message; |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return array |
150 | 150 | */ |
151 | - public function add_settings_meta_tab_li( $tabs ) { |
|
152 | - return array_merge( $tabs, array( |
|
151 | + public function add_settings_meta_tab_li($tabs) { |
|
152 | + return array_merge($tabs, array( |
|
153 | 153 | 'google' => array( |
154 | 154 | 'label' => $this->feed->name, |
155 | 155 | 'target' => 'google-settings-panel', |
156 | - 'class' => array( 'simcal-feed-type', 'simcal-feed-type-google' ), |
|
156 | + 'class' => array('simcal-feed-type', 'simcal-feed-type-google'), |
|
157 | 157 | 'icon' => 'simcal-icon-google', |
158 | 158 | ), |
159 | - ) ); |
|
159 | + )); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @param int $post_id |
168 | 168 | */ |
169 | - public function add_settings_meta_panel( $post_id ) { |
|
169 | + public function add_settings_meta_panel($post_id) { |
|
170 | 170 | |
171 | 171 | $inputs = array( |
172 | 172 | $this->feed->type => array( |
@@ -175,30 +175,30 @@ discard block |
||
175 | 175 | 'subtype' => 'text', |
176 | 176 | 'name' => '_google_calendar_id', |
177 | 177 | 'id' => '_google_calendar_id', |
178 | - 'title' => __( 'Calendar ID', 'google-calendar-events' ), |
|
179 | - 'tooltip' => __( 'Visit your Google Calendar account, copy your public calendar ID, then paste it here.', 'google-calendar-events' ), |
|
180 | - 'placeholder' => __( 'Enter a valid Google Calendar ID from a public calendar', 'google-calendar-events' ), |
|
181 | - 'escaping' => array( $this->feed, 'esc_google_calendar_id' ), |
|
182 | - 'validation' => array( $this, 'test_api_key_connection' ), |
|
178 | + 'title' => __('Calendar ID', 'google-calendar-events'), |
|
179 | + 'tooltip' => __('Visit your Google Calendar account, copy your public calendar ID, then paste it here.', 'google-calendar-events'), |
|
180 | + 'placeholder' => __('Enter a valid Google Calendar ID from a public calendar', 'google-calendar-events'), |
|
181 | + 'escaping' => array($this->feed, 'esc_google_calendar_id'), |
|
182 | + 'validation' => array($this, 'test_api_key_connection'), |
|
183 | 183 | ), |
184 | 184 | '_google_events_search_query' => array( |
185 | 185 | 'type' => 'standard', |
186 | 186 | 'subtype' => 'text', |
187 | 187 | 'name' => '_google_events_search_query', |
188 | 188 | 'id' => '_google_events_search_query', |
189 | - 'title' => __( 'Search query', 'google-calendar-events' ), |
|
190 | - 'tooltip' => __( 'Type in keywords if you only want display events that match these terms. You can use basic boolean search operators too.', 'google-calendar-events' ), |
|
191 | - 'placeholder' => __( 'Filter events to display by search terms...', 'google-calendar-events' ), |
|
189 | + 'title' => __('Search query', 'google-calendar-events'), |
|
190 | + 'tooltip' => __('Type in keywords if you only want display events that match these terms. You can use basic boolean search operators too.', 'google-calendar-events'), |
|
191 | + 'placeholder' => __('Filter events to display by search terms...', 'google-calendar-events'), |
|
192 | 192 | ), |
193 | 193 | '_google_events_recurring' => array( |
194 | 194 | 'type' => 'select', |
195 | 195 | 'name' => '_google_events_recurring', |
196 | 196 | 'id' => '_google_events_recurring', |
197 | - 'title' => __( 'Recurring events', 'google-calendar-events' ), |
|
198 | - 'tooltip' => __( 'Events that are programmed to repeat themselves periodically.', 'google-calendar-events' ), |
|
197 | + 'title' => __('Recurring events', 'google-calendar-events'), |
|
198 | + 'tooltip' => __('Events that are programmed to repeat themselves periodically.', 'google-calendar-events'), |
|
199 | 199 | 'options' => array( |
200 | - 'show' => __( 'Show all', 'google-calendar-events' ), |
|
201 | - 'first-only' => __( 'Only show first occurrence', 'google-calendar-events' ), |
|
200 | + 'show' => __('Show all', 'google-calendar-events'), |
|
201 | + 'first-only' => __('Only show first occurrence', 'google-calendar-events'), |
|
202 | 202 | ), |
203 | 203 | ), |
204 | 204 | '_google_events_max_results' => array( |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | 'subtype' => 'number', |
207 | 207 | 'name' => '_google_events_max_results', |
208 | 208 | 'id' => '_google_events_max_results', |
209 | - 'title' => __( 'Maximum Events', 'google-calendar-events' ), |
|
210 | - 'tooltip' => __( 'Google Calendar only allows to query for a maximum amount of 2500 events from a calendar each time.', 'google-calendar-events' ), |
|
209 | + 'title' => __('Maximum Events', 'google-calendar-events'), |
|
210 | + 'tooltip' => __('Google Calendar only allows to query for a maximum amount of 2500 events from a calendar each time.', 'google-calendar-events'), |
|
211 | 211 | 'class' => array( |
212 | 212 | 'simcal-field-small', |
213 | 213 | ), |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | <div id="google-settings-panel" class="simcal-panel"> |
225 | 225 | <table> |
226 | 226 | <thead> |
227 | - <tr><th colspan="2"><?php _e( 'Google Calendar settings', 'google-calendar-events' ); ?></th></tr> |
|
227 | + <tr><th colspan="2"><?php _e('Google Calendar settings', 'google-calendar-events'); ?></th></tr> |
|
228 | 228 | </thead> |
229 | - <?php Settings::print_panel_fields( $inputs, $post_id ); ?> |
|
229 | + <?php Settings::print_panel_fields($inputs, $post_id); ?> |
|
230 | 230 | </table> |
231 | 231 | </div> |
232 | 232 | <?php |
@@ -242,47 +242,47 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return true|string |
244 | 244 | */ |
245 | - public function test_api_key_connection( $google_calendar_id ) { |
|
245 | + public function test_api_key_connection($google_calendar_id) { |
|
246 | 246 | |
247 | 247 | global $post; |
248 | 248 | |
249 | - $post_id = isset( $post->ID ) ? $post->ID : 0; |
|
249 | + $post_id = isset($post->ID) ? $post->ID : 0; |
|
250 | 250 | $feed = null; |
251 | - if ( $feed_type = wp_get_object_terms( $post_id, 'calendar_feed' ) ) { |
|
252 | - $feed = sanitize_title( current( $feed_type )->name ); |
|
251 | + if ($feed_type = wp_get_object_terms($post_id, 'calendar_feed')) { |
|
252 | + $feed = sanitize_title(current($feed_type)->name); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | $message = ''; |
256 | 256 | $error = ''; |
257 | 257 | $has_errors = false; |
258 | 258 | |
259 | - $message .= '<p class="description">' . |
|
259 | + $message .= '<p class="description">'. |
|
260 | 260 | sprintf( |
261 | - __( 'Step 1: Set the Google Calendar you want to use as <strong>"public."</strong> <a href="%1s" target="_blank">Detailed instructions</a>', 'google-calendar-events' ) . '<br />' . |
|
262 | - __( 'Step 2: Copy and paste your Google Calendar ID here. <a href="%2s" target="_blank">Detailed instructions</a>', 'google-calendar-events' ), |
|
263 | - simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/make-google-calendar-public/', 'core-plugin', 'settings-link' ), |
|
264 | - simcal_ga_campaign_url( simcal_get_url( 'docs' ) . '/find-google-calendar-id/', 'core-plugin', 'settings-link' ) |
|
265 | - ) . '</p>'; |
|
261 | + __('Step 1: Set the Google Calendar you want to use as <strong>"public."</strong> <a href="%1s" target="_blank">Detailed instructions</a>', 'google-calendar-events').'<br />'. |
|
262 | + __('Step 2: Copy and paste your Google Calendar ID here. <a href="%2s" target="_blank">Detailed instructions</a>', 'google-calendar-events'), |
|
263 | + simcal_ga_campaign_url(simcal_get_url('docs').'/make-google-calendar-public/', 'core-plugin', 'settings-link'), |
|
264 | + simcal_ga_campaign_url(simcal_get_url('docs').'/find-google-calendar-id/', 'core-plugin', 'settings-link') |
|
265 | + ).'</p>'; |
|
266 | 266 | |
267 | - if ( $post_id > 0 && ! is_null( $feed ) && ! empty( $this->feed->type ) ) { |
|
267 | + if ($post_id > 0 && ! is_null($feed) && ! empty($this->feed->type)) { |
|
268 | 268 | |
269 | - $no_key_notice = new Notice( array( |
|
270 | - 'id' => array( 'calendar_' . $post_id => 'google-no-api-key' ), |
|
269 | + $no_key_notice = new Notice(array( |
|
270 | + 'id' => array('calendar_'.$post_id => 'google-no-api-key'), |
|
271 | 271 | 'type' => 'error', |
272 | 272 | 'screen' => 'calendar', |
273 | 273 | 'post' => $post_id, |
274 | 274 | 'dismissable' => false, |
275 | - 'content' => '<p>' . |
|
276 | - '<i class="simcal-icon-warning"></i> ' . |
|
275 | + 'content' => '<p>'. |
|
276 | + '<i class="simcal-icon-warning"></i> '. |
|
277 | 277 | sprintf( |
278 | - __( 'Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events' ), |
|
279 | - admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds' ) |
|
280 | - ) . |
|
278 | + __('Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events'), |
|
279 | + admin_url('edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds') |
|
280 | + ). |
|
281 | 281 | '</p>', |
282 | 282 | ) |
283 | 283 | ); |
284 | 284 | |
285 | - if ( empty( $this->google_api_key ) && ( $feed == $this->feed->type ) ) { |
|
285 | + if (empty($this->google_api_key) && ($feed == $this->feed->type)) { |
|
286 | 286 | |
287 | 287 | $has_errors = true; |
288 | 288 | $no_key_notice->add(); |
@@ -292,28 +292,28 @@ discard block |
||
292 | 292 | $no_key_notice->remove(); |
293 | 293 | |
294 | 294 | try { |
295 | - $this->feed->make_request( $google_calendar_id ); |
|
296 | - } catch ( \Exception $e ) { |
|
295 | + $this->feed->make_request($google_calendar_id); |
|
296 | + } catch (\Exception $e) { |
|
297 | 297 | $error = $e->getMessage(); |
298 | - $message = ! empty( $error ) ? '<blockquote>' . $error . '</blockquote>' : ''; |
|
298 | + $message = ! empty($error) ? '<blockquote>'.$error.'</blockquote>' : ''; |
|
299 | 299 | } |
300 | 300 | |
301 | - $error_notice = new Notice( array( |
|
302 | - 'id' => array( 'calendar_' . $post_id => 'google-error-response' ), |
|
301 | + $error_notice = new Notice(array( |
|
302 | + 'id' => array('calendar_'.$post_id => 'google-error-response'), |
|
303 | 303 | 'type' => 'error', |
304 | 304 | 'screen' => 'calendar', |
305 | 305 | 'post' => $post_id, |
306 | 306 | 'dismissable' => false, |
307 | - 'content' => '<p>' . |
|
308 | - '<i class="simcal-icon-warning"></i> ' . |
|
309 | - __( 'While trying to retrieve events, Google returned an error:', 'google-calendar-events' ) . |
|
310 | - '<br>' . $message . '<br>' . |
|
311 | - __( 'Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events' ) . |
|
307 | + 'content' => '<p>'. |
|
308 | + '<i class="simcal-icon-warning"></i> '. |
|
309 | + __('While trying to retrieve events, Google returned an error:', 'google-calendar-events'). |
|
310 | + '<br>'.$message.'<br>'. |
|
311 | + __('Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events'). |
|
312 | 312 | '</p>', |
313 | 313 | ) |
314 | 314 | ); |
315 | 315 | |
316 | - if ( ! empty( $error ) && ( $feed == $this->feed->type ) ) { |
|
316 | + if ( ! empty($error) && ($feed == $this->feed->type)) { |
|
317 | 317 | $error_notice->add(); |
318 | 318 | $has_errors = true; |
319 | 319 | } else { |
@@ -335,21 +335,21 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @param int $post_id |
337 | 337 | */ |
338 | - public function process_meta( $post_id ) { |
|
338 | + public function process_meta($post_id) { |
|
339 | 339 | |
340 | - $calendar_id = isset( $_POST['_google_calendar_id'] ) ? base64_encode( trim( $_POST['_google_calendar_id'] ) ): ''; |
|
341 | - update_post_meta( $post_id, '_google_calendar_id', $calendar_id ); |
|
340 | + $calendar_id = isset($_POST['_google_calendar_id']) ? base64_encode(trim($_POST['_google_calendar_id'])) : ''; |
|
341 | + update_post_meta($post_id, '_google_calendar_id', $calendar_id); |
|
342 | 342 | |
343 | - $search_query = isset( $_POST['_google_events_search_query'] ) ? sanitize_text_field( $_POST['_google_events_search_query'] ) : ''; |
|
344 | - update_post_meta( $post_id, '_google_events_search_query', $search_query ); |
|
343 | + $search_query = isset($_POST['_google_events_search_query']) ? sanitize_text_field($_POST['_google_events_search_query']) : ''; |
|
344 | + update_post_meta($post_id, '_google_events_search_query', $search_query); |
|
345 | 345 | |
346 | - $recurring = isset( $_POST['_google_events_recurring'] ) ? sanitize_key( $_POST['_google_events_recurring'] ) : 'show'; |
|
347 | - update_post_meta( $post_id, '_google_events_recurring', $recurring ); |
|
346 | + $recurring = isset($_POST['_google_events_recurring']) ? sanitize_key($_POST['_google_events_recurring']) : 'show'; |
|
347 | + update_post_meta($post_id, '_google_events_recurring', $recurring); |
|
348 | 348 | |
349 | - $max_results = isset( $_POST['_google_events_max_results'] ) ? absint( $_POST['_google_events_max_results'] ) : '2500'; |
|
350 | - update_post_meta( $post_id, '_google_events_max_results', $max_results ); |
|
349 | + $max_results = isset($_POST['_google_events_max_results']) ? absint($_POST['_google_events_max_results']) : '2500'; |
|
350 | + update_post_meta($post_id, '_google_events_max_results', $max_results); |
|
351 | 351 | |
352 | - $this->test_api_key_connection( $calendar_id ); |
|
352 | + $this->test_api_key_connection($calendar_id); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Feeds\Grouped_Calendars; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -34,15 +34,15 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param Grouped_Calendars $feed |
36 | 36 | */ |
37 | - public function __construct( Grouped_Calendars $feed ) { |
|
37 | + public function __construct(Grouped_Calendars $feed) { |
|
38 | 38 | |
39 | 39 | $this->feed = $feed; |
40 | 40 | |
41 | - if ( 'calendar' == simcal_is_admin_screen() ) { |
|
42 | - add_filter( 'simcal_settings_meta_tabs_li', array( $this, 'add_settings_meta_tab_li' ), 10, 1 ); |
|
43 | - add_action( 'simcal_settings_meta_panels', array( $this, 'add_settings_meta_panel' ), 10, 1 ); |
|
41 | + if ('calendar' == simcal_is_admin_screen()) { |
|
42 | + add_filter('simcal_settings_meta_tabs_li', array($this, 'add_settings_meta_tab_li'), 10, 1); |
|
43 | + add_action('simcal_settings_meta_panels', array($this, 'add_settings_meta_panel'), 10, 1); |
|
44 | 44 | } |
45 | - add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 ); |
|
45 | + add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return array |
56 | 56 | */ |
57 | - public function add_settings_meta_tab_li( $tabs ) { |
|
58 | - return array_merge( $tabs, array( |
|
57 | + public function add_settings_meta_tab_li($tabs) { |
|
58 | + return array_merge($tabs, array( |
|
59 | 59 | 'grouped-calendars' => array( |
60 | 60 | 'label' => $this->feed->name, |
61 | 61 | 'target' => 'grouped-calendars-settings-panel', |
@@ -75,40 +75,40 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param int $post_id |
77 | 77 | */ |
78 | - public function add_settings_meta_panel( $post_id ) { |
|
78 | + public function add_settings_meta_panel($post_id) { |
|
79 | 79 | |
80 | 80 | ?> |
81 | 81 | <div id="grouped-calendars-settings-panel" class="simcal-panel"> |
82 | 82 | <table> |
83 | 83 | <thead> |
84 | - <tr><th colspan="2"><?php _e( 'Grouped Calendar settings', 'google-calendar-events' ); ?></th></tr> |
|
84 | + <tr><th colspan="2"><?php _e('Grouped Calendar settings', 'google-calendar-events'); ?></th></tr> |
|
85 | 85 | </thead> |
86 | 86 | <tbody class="simcal-panel-section"> |
87 | 87 | <tr class="simcal-panel-field"> |
88 | - <th><label for="_grouped_calendars_source"><?php _e( 'Get calendars from', 'google-calendar-events' ); ?></label></th> |
|
88 | + <th><label for="_grouped_calendars_source"><?php _e('Get calendars from', 'google-calendar-events'); ?></label></th> |
|
89 | 89 | <td> |
90 | 90 | <?php |
91 | 91 | |
92 | - $source = esc_attr( get_post_meta( $post_id, '_grouped_calendars_source', true ) ); |
|
93 | - $source = empty( $source ) ? 'ids' : $source; |
|
92 | + $source = esc_attr(get_post_meta($post_id, '_grouped_calendars_source', true)); |
|
93 | + $source = empty($source) ? 'ids' : $source; |
|
94 | 94 | |
95 | 95 | ?> |
96 | 96 | <select name="_grouped_calendars_source" |
97 | 97 | id="_grouped_calendars_source" |
98 | 98 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other" |
99 | 99 | data-show-field-on-choice="true"> |
100 | - <option value="ids" data-show-field="_grouped_calendars_ids" <?php selected( 'ids', $source, true ); ?>><?php _e( 'Manual selection', 'google-calendar-events' ); ?></option> |
|
101 | - <option value="category" data-show-field="_grouped_calendars_category" <?php selected( 'category', $source, true ); ?>><?php _e( 'Category', 'google-calendar-events' ); ?></option> |
|
100 | + <option value="ids" data-show-field="_grouped_calendars_ids" <?php selected('ids', $source, true); ?>><?php _e('Manual selection', 'google-calendar-events'); ?></option> |
|
101 | + <option value="category" data-show-field="_grouped_calendars_category" <?php selected('category', $source, true); ?>><?php _e('Category', 'google-calendar-events'); ?></option> |
|
102 | 102 | </select> |
103 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Choose from which calendar feeds you want to get events from. Choose them individually or select all those belonging to calendar feed categories.', 'google-calendar-events' ); ?>"></i> |
|
103 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Choose from which calendar feeds you want to get events from. Choose them individually or select all those belonging to calendar feed categories.', 'google-calendar-events'); ?>"></i> |
|
104 | 104 | <br><br> |
105 | 105 | <?php |
106 | 106 | |
107 | - $cals = simcal_get_calendars( $post_id ); |
|
108 | - $meta = get_post_meta( $post_id, '_grouped_calendars_ids', true ); |
|
109 | - $ids = $meta && is_array( $meta ) ? implode( ',', array_map( 'absint', $meta ) ) : absint( $meta ); |
|
107 | + $cals = simcal_get_calendars($post_id); |
|
108 | + $meta = get_post_meta($post_id, '_grouped_calendars_ids', true); |
|
109 | + $ids = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : absint($meta); |
|
110 | 110 | |
111 | - simcal_print_field( array( |
|
111 | + simcal_print_field(array( |
|
112 | 112 | 'type' => 'select', |
113 | 113 | 'multiselect' => 'multiselect', |
114 | 114 | 'name' => '_grouped_calendars_ids', |
@@ -116,25 +116,25 @@ discard block |
||
116 | 116 | 'value' => $ids !== 0 ? $ids : '', |
117 | 117 | 'options' => $cals, |
118 | 118 | 'enhanced' => 'enhanced', |
119 | - 'style' => 'ids' == $source ? '' : array( 'display' => 'none' ), |
|
119 | + 'style' => 'ids' == $source ? '' : array('display' => 'none'), |
|
120 | 120 | 'attributes' => array( |
121 | - 'data-noresults' => __( 'No results found.', 'google-calendar-events' ), |
|
121 | + 'data-noresults' => __('No results found.', 'google-calendar-events'), |
|
122 | 122 | ), |
123 | 123 | )); |
124 | 124 | |
125 | - $meta = get_post_meta( $post_id, '_grouped_calendars_category', true ); |
|
126 | - $category = $meta && is_array( $meta ) ? implode( ',', array_map( 'absint', $meta ) ): ''; |
|
125 | + $meta = get_post_meta($post_id, '_grouped_calendars_category', true); |
|
126 | + $category = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : ''; |
|
127 | 127 | |
128 | - $terms = get_terms( 'calendar_category' ); |
|
128 | + $terms = get_terms('calendar_category'); |
|
129 | 129 | |
130 | - if ( ! empty( $terms ) ) { |
|
130 | + if ( ! empty($terms)) { |
|
131 | 131 | |
132 | 132 | $categories = array(); |
133 | - foreach ( $terms as $term ) { |
|
134 | - $categories[ $term->term_id ] = $term->name; |
|
133 | + foreach ($terms as $term) { |
|
134 | + $categories[$term->term_id] = $term->name; |
|
135 | 135 | } |
136 | 136 | |
137 | - simcal_print_field( array( |
|
137 | + simcal_print_field(array( |
|
138 | 138 | 'type' => 'select', |
139 | 139 | 'multiselect' => 'multiselect', |
140 | 140 | 'name' => '_grouped_calendars_category', |
@@ -142,17 +142,17 @@ discard block |
||
142 | 142 | 'value' => $category, |
143 | 143 | 'options' => $categories, |
144 | 144 | 'enhanced' => 'enhanced', |
145 | - 'style' => 'category' == $source ? '' : array( 'display' => 'none' ), |
|
145 | + 'style' => 'category' == $source ? '' : array('display' => 'none'), |
|
146 | 146 | 'attributes' => array( |
147 | - 'data-noresults' => __( 'No results found.', 'google-calendar-events' ), |
|
147 | + 'data-noresults' => __('No results found.', 'google-calendar-events'), |
|
148 | 148 | ), |
149 | - ) ); |
|
149 | + )); |
|
150 | 150 | |
151 | 151 | } else { |
152 | 152 | |
153 | 153 | $style = 'category' == $source ? '' : 'display: none;'; |
154 | 154 | $style .= ' width: 100%; max-width: 500px'; |
155 | - echo '<input type="text" disabled="disabled" name="_grouped_calendars_category" id="_grouped_calendars_category" style="' . $style . '" placeholder="' . __( 'There are no calendar categories yet.', 'google-calendar-events' ) . '" />'; |
|
155 | + echo '<input type="text" disabled="disabled" name="_grouped_calendars_category" id="_grouped_calendars_category" style="'.$style.'" placeholder="'.__('There are no calendar categories yet.', 'google-calendar-events').'" />'; |
|
156 | 156 | |
157 | 157 | } |
158 | 158 | |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @param int $post_id |
175 | 175 | */ |
176 | - public function process_meta( $post_id ) { |
|
176 | + public function process_meta($post_id) { |
|
177 | 177 | |
178 | - $source = isset( $_POST['_grouped_calendars_source'] ) ? sanitize_key( $_POST['_grouped_calendars_source'] ) : 'ids'; |
|
179 | - update_post_meta( $post_id, '_grouped_calendars_source', $source ); |
|
178 | + $source = isset($_POST['_grouped_calendars_source']) ? sanitize_key($_POST['_grouped_calendars_source']) : 'ids'; |
|
179 | + update_post_meta($post_id, '_grouped_calendars_source', $source); |
|
180 | 180 | |
181 | - $ids = isset( $_POST['_grouped_calendars_ids'] ) ? array_map( 'absint', $_POST['_grouped_calendars_ids'] ) : ''; |
|
182 | - update_post_meta( $post_id, '_grouped_calendars_ids', $ids ); |
|
181 | + $ids = isset($_POST['_grouped_calendars_ids']) ? array_map('absint', $_POST['_grouped_calendars_ids']) : ''; |
|
182 | + update_post_meta($post_id, '_grouped_calendars_ids', $ids); |
|
183 | 183 | |
184 | - $category = isset( $_POST['_grouped_calendars_category'] ) ? array_map( 'absint', $_POST['_grouped_calendars_category'] ) : ''; |
|
185 | - update_post_meta( $post_id, '_grouped_calendars_category', $category ); |
|
184 | + $category = isset($_POST['_grouped_calendars_category']) ? array_map('absint', $_POST['_grouped_calendars_category']) : ''; |
|
185 | + update_post_meta($post_id, '_grouped_calendars_category', $category); |
|
186 | 186 | |
187 | 187 | } |
188 | 188 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @package SimpleCalendar/Admin/Functions |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return null|\SimpleCalendar\Abstracts\Admin_Page |
34 | 34 | */ |
35 | -function simcal_get_admin_page( $page ) { |
|
35 | +function simcal_get_admin_page($page) { |
|
36 | 36 | $objects = \SimpleCalendar\plugin()->objects; |
37 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page( $page ) : null; |
|
37 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page($page) : null; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @return null|\SimpleCalendar\Abstracts\Field |
49 | 49 | */ |
50 | -function simcal_get_field( $args, $name = '' ) { |
|
50 | +function simcal_get_field($args, $name = '') { |
|
51 | 51 | $objects = \SimpleCalendar\plugin()->objects; |
52 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field( $args, $name ) : null; |
|
52 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field($args, $name) : null; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return void |
64 | 64 | */ |
65 | -function simcal_print_field( $args, $name = '' ) { |
|
65 | +function simcal_print_field($args, $name = '') { |
|
66 | 66 | |
67 | - $field = simcal_get_field( $args, $name ); |
|
67 | + $field = simcal_get_field($args, $name); |
|
68 | 68 | |
69 | - if ( $field instanceof \SimpleCalendar\Abstracts\Field ) { |
|
69 | + if ($field instanceof \SimpleCalendar\Abstracts\Field) { |
|
70 | 70 | $field->html(); |
71 | 71 | } |
72 | 72 | } |
@@ -80,50 +80,50 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return bool |
82 | 82 | */ |
83 | -function simcal_delete_feed_transients( $id = '' ) { |
|
83 | +function simcal_delete_feed_transients($id = '') { |
|
84 | 84 | |
85 | - if ( is_numeric( $id ) ) { |
|
86 | - $id = intval( $id ) > 0 ? absint( $id ) : simcal_get_calendars(); |
|
87 | - } elseif ( $id instanceof WP_Post ) { |
|
85 | + if (is_numeric($id)) { |
|
86 | + $id = intval($id) > 0 ? absint($id) : simcal_get_calendars(); |
|
87 | + } elseif ($id instanceof WP_Post) { |
|
88 | 88 | $id = $id->ID; |
89 | - } elseif ( is_array( $id ) ) { |
|
90 | - $id = array_map( 'absint', $id ); |
|
89 | + } elseif (is_array($id)) { |
|
90 | + $id = array_map('absint', $id); |
|
91 | 91 | } else { |
92 | - $id = simcal_get_calendars( '', true ); |
|
92 | + $id = simcal_get_calendars('', true); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $feed_types = simcal_get_feed_types(); |
96 | 96 | |
97 | - if ( is_array( $id ) ) { |
|
97 | + if (is_array($id)) { |
|
98 | 98 | |
99 | - $posts = get_posts( array( |
|
99 | + $posts = get_posts(array( |
|
100 | 100 | 'post_type' => 'calendar', |
101 | 101 | 'fields' => 'ids', |
102 | 102 | 'post__in' => $id, |
103 | 103 | 'nopaging' => true, |
104 | - ) ); |
|
104 | + )); |
|
105 | 105 | |
106 | - foreach ( $posts as $post ) { |
|
107 | - $calendar = simcal_get_calendar( $post ); |
|
108 | - if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) { |
|
109 | - foreach ( $feed_types as $feed_type ) { |
|
110 | - delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type ); |
|
106 | + foreach ($posts as $post) { |
|
107 | + $calendar = simcal_get_calendar($post); |
|
108 | + if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) { |
|
109 | + foreach ($feed_types as $feed_type) { |
|
110 | + delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | 115 | } else { |
116 | 116 | |
117 | - $post = get_post( $id ); |
|
118 | - $calendar = simcal_get_calendar( $post ); |
|
119 | - if ( $calendar instanceof \SimpleCalendar\Abstracts\Calendar ) { |
|
120 | - foreach ( $feed_types as $feed_type ) { |
|
121 | - delete_transient( '_simple-calendar_feed_id_' . strval( $calendar->id ) . '_' . $feed_type ); |
|
117 | + $post = get_post($id); |
|
118 | + $calendar = simcal_get_calendar($post); |
|
119 | + if ($calendar instanceof \SimpleCalendar\Abstracts\Calendar) { |
|
120 | + foreach ($feed_types as $feed_type) { |
|
121 | + delete_transient('_simple-calendar_feed_id_'.strval($calendar->id).'_'.$feed_type); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - return delete_transient( '_simple-calendar_feed_ids' ); |
|
126 | + return delete_transient('_simple-calendar_feed_ids'); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -139,33 +139,33 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return array|string Sanitized variable |
141 | 141 | */ |
142 | -function simcal_sanitize_input( $var, $func = 'sanitize_text_field' ) { |
|
142 | +function simcal_sanitize_input($var, $func = 'sanitize_text_field') { |
|
143 | 143 | |
144 | - if ( is_null( $var ) ) { |
|
144 | + if (is_null($var)) { |
|
145 | 145 | return ''; |
146 | 146 | } |
147 | 147 | |
148 | - if ( is_bool( $var ) ) { |
|
149 | - if ( $var === true ) { |
|
148 | + if (is_bool($var)) { |
|
149 | + if ($var === true) { |
|
150 | 150 | return 'yes'; |
151 | 151 | } else { |
152 | 152 | return 'no'; |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | - if ( is_string( $var ) || is_numeric( $var ) ) { |
|
157 | - $func = is_string( $func ) && function_exists( $func ) ? $func : 'sanitize_text_field'; |
|
158 | - return call_user_func( $func, trim( strval( $var ) ) ); |
|
156 | + if (is_string($var) || is_numeric($var)) { |
|
157 | + $func = is_string($func) && function_exists($func) ? $func : 'sanitize_text_field'; |
|
158 | + return call_user_func($func, trim(strval($var))); |
|
159 | 159 | } |
160 | 160 | |
161 | - if ( is_object( $var ) ) { |
|
161 | + if (is_object($var)) { |
|
162 | 162 | $var = (array) $var; |
163 | 163 | } |
164 | 164 | |
165 | - if ( is_array( $var ) ) { |
|
165 | + if (is_array($var)) { |
|
166 | 166 | $array = array(); |
167 | - foreach ( $var as $k => $v ) { |
|
168 | - $array[ $k ] = simcal_sanitize_input( $v ); |
|
167 | + foreach ($var as $k => $v) { |
|
168 | + $array[$k] = simcal_sanitize_input($v); |
|
169 | 169 | } |
170 | 170 | return $array; |
171 | 171 | } |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | */ |
184 | 184 | function simcal_is_admin_screen() { |
185 | 185 | |
186 | - $view = function_exists( 'get_current_screen' ) ? get_current_screen() : false; |
|
186 | + $view = function_exists('get_current_screen') ? get_current_screen() : false; |
|
187 | 187 | |
188 | - if ( $view instanceof WP_Screen ) { |
|
188 | + if ($view instanceof WP_Screen) { |
|
189 | 189 | |
190 | 190 | // Screens used by this plugin. |
191 | 191 | $screens = array( |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | 'dashboard_page_simple-calendar_credits', |
201 | 201 | 'dashboard_page_simple-calendar_translators', |
202 | 202 | ); |
203 | - if ( in_array( $view->id, $screens ) ) { |
|
203 | + if (in_array($view->id, $screens)) { |
|
204 | 204 | return $view->id; |
205 | 205 | } |
206 | 206 | } |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @return \SimpleCalendar\Admin\Updater |
221 | 221 | */ |
222 | -function simcal_addon_updater( $_api_url, $_plugin_file, $_api_data = null ) { |
|
223 | - return new \SimpleCalendar\Admin\Updater( $_api_url, $_plugin_file, $_api_data ); |
|
222 | +function simcal_addon_updater($_api_url, $_plugin_file, $_api_data = null) { |
|
223 | + return new \SimpleCalendar\Admin\Updater($_api_url, $_plugin_file, $_api_data); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -232,10 +232,10 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return null|string |
234 | 234 | */ |
235 | -function simcal_get_license_key( $addon ) { |
|
236 | - $licenses = get_option( 'simple-calendar_settings_licenses', array() ); |
|
237 | - if ( isset( $licenses['keys'][ $addon ] ) ) { |
|
238 | - return empty( $licenses['keys'][ $addon ] ) ? null : $licenses['keys'][ $addon ]; |
|
235 | +function simcal_get_license_key($addon) { |
|
236 | + $licenses = get_option('simple-calendar_settings_licenses', array()); |
|
237 | + if (isset($licenses['keys'][$addon])) { |
|
238 | + return empty($licenses['keys'][$addon]) ? null : $licenses['keys'][$addon]; |
|
239 | 239 | } |
240 | 240 | return null; |
241 | 241 | } |
@@ -251,9 +251,9 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return array|string |
253 | 253 | */ |
254 | -function simcal_get_license_status( $addon = null ) { |
|
255 | - $licenses = get_option( 'simple-calendar_licenses_status', array() ); |
|
256 | - return isset( $licenses[ $addon ] ) ? $licenses[ $addon ] : $licenses; |
|
254 | +function simcal_get_license_status($addon = null) { |
|
255 | + $licenses = get_option('simple-calendar_licenses_status', array()); |
|
256 | + return isset($licenses[$addon]) ? $licenses[$addon] : $licenses; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @since 3.0.0 |
275 | 275 | */ |
276 | 276 | function simcal_delete_admin_notices() { |
277 | - delete_option( 'simple-calendar_admin_notices' ); |
|
277 | + delete_option('simple-calendar_admin_notices'); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -286,22 +286,22 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return void |
288 | 288 | */ |
289 | -function simcal_print_shortcode_tip( $post_id ) { |
|
289 | +function simcal_print_shortcode_tip($post_id) { |
|
290 | 290 | |
291 | 291 | $browser = new \Browser(); |
292 | - if ( $browser::PLATFORM_APPLE == $browser->getPlatform() ) { |
|
292 | + if ($browser::PLATFORM_APPLE == $browser->getPlatform()) { |
|
293 | 293 | $cmd = '⌘+C'; |
294 | 294 | } else { |
295 | 295 | $cmd = 'Ctrl+C'; |
296 | 296 | } |
297 | 297 | |
298 | - $shortcut = sprintf( __( 'Press %s to copy.', 'google-calendar-events' ), $cmd ); |
|
299 | - $shortcode = sprintf( '[calendar id="%s"]', $post_id ); |
|
298 | + $shortcut = sprintf(__('Press %s to copy.', 'google-calendar-events'), $cmd); |
|
299 | + $shortcode = sprintf('[calendar id="%s"]', $post_id); |
|
300 | 300 | |
301 | - echo "<input readonly='readonly' " . |
|
302 | - "class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' " . |
|
303 | - "title='" . $shortcut . "' " . |
|
304 | - "onclick='this.select();' value='" . $shortcode . "' />"; |
|
301 | + echo "<input readonly='readonly' ". |
|
302 | + "class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' ". |
|
303 | + "title='".$shortcut."' ". |
|
304 | + "onclick='this.select();' value='".$shortcode."' />"; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -316,20 +316,20 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @return string $url Full Google Analytics campaign URL |
318 | 318 | */ |
319 | -function simcal_ga_campaign_url( $base_url, $campaign, $content, $raw = false ) { |
|
319 | +function simcal_ga_campaign_url($base_url, $campaign, $content, $raw = false) { |
|
320 | 320 | |
321 | - $url = add_query_arg( array( |
|
321 | + $url = add_query_arg(array( |
|
322 | 322 | 'utm_source' => 'inside-plugin', |
323 | 323 | 'utm_medium' => 'link', |
324 | 324 | 'utm_campaign' => $campaign, // i.e. 'core-plugin', 'gcal-pro' |
325 | 325 | 'utm_content' => $content // i.e. 'sidebar-link', 'settings-link' |
326 | - ), $base_url ); |
|
326 | + ), $base_url); |
|
327 | 327 | |
328 | - if ( $raw ) { |
|
329 | - return esc_url_raw( $url ); |
|
328 | + if ($raw) { |
|
329 | + return esc_url_raw($url); |
|
330 | 330 | } |
331 | 331 | |
332 | - return esc_url( $url ); |
|
332 | + return esc_url($url); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | */ |
342 | 342 | function simcal_newsletter_signup() { |
343 | 343 | |
344 | - if ( $screen = simcal_is_admin_screen() ) { |
|
344 | + if ($screen = simcal_is_admin_screen()) { |
|
345 | 345 | |
346 | 346 | global $current_user; |
347 | 347 | get_currentuserinfo(); |
@@ -352,11 +352,11 @@ discard block |
||
352 | 352 | <div id="simcal-drip" class="<?php echo $screen; ?>"> |
353 | 353 | <div class="signup"> |
354 | 354 | <p> |
355 | - <?php _e( "Enter your name and email and we'll send you a coupon code for 20% off our Google Calendar Pro add-on.", 'google-calendar-events' ); ?> |
|
355 | + <?php _e("Enter your name and email and we'll send you a coupon code for 20% off our Google Calendar Pro add-on.", 'google-calendar-events'); ?> |
|
356 | 356 | </p> |
357 | 357 | |
358 | 358 | <p> |
359 | - <label for="simcal-drip-field-email"><?php _e( 'Your Email', 'google-calendar-events' ); ?></label><br /> |
|
359 | + <label for="simcal-drip-field-email"><?php _e('Your Email', 'google-calendar-events'); ?></label><br /> |
|
360 | 360 | <input type="email" |
361 | 361 | id="simcal-drip-field-email" |
362 | 362 | name="fields[email]" |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | </p> |
365 | 365 | |
366 | 366 | <p> |
367 | - <label for="simcal-drip-field-first_name"><?php _e( 'First Name', 'google-calendar-events' ); ?></label><br /> |
|
367 | + <label for="simcal-drip-field-first_name"><?php _e('First Name', 'google-calendar-events'); ?></label><br /> |
|
368 | 368 | <input type="text" |
369 | 369 | id="simcal-drip-field-first_name" |
370 | 370 | name="fields[first_name]" |
@@ -373,15 +373,15 @@ discard block |
||
373 | 373 | <p class="textright"> |
374 | 374 | <a href="#" |
375 | 375 | id="simcal-drip-signup" |
376 | - class="button button-primary"><?php _e( 'Send me the coupon', 'google-calendar-events' ); ?></a> |
|
376 | + class="button button-primary"><?php _e('Send me the coupon', 'google-calendar-events'); ?></a> |
|
377 | 377 | </p> |
378 | 378 | <div class="textright"> |
379 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'sidebar-link' ); ?>" |
|
380 | - target="_blank"><?php _e( 'Just take me to GCal Pro', 'google-calendar-events' ); ?></a> |
|
379 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'sidebar-link'); ?>" |
|
380 | + target="_blank"><?php _e('Just take me to GCal Pro', 'google-calendar-events'); ?></a> |
|
381 | 381 | </div> |
382 | 382 | </div> |
383 | 383 | <div class="thank-you" style="display: none;"> |
384 | - <?php _e( 'Thank you!', 'google-calendar-events' ); ?> |
|
384 | + <?php _e('Thank you!', 'google-calendar-events'); ?> |
|
385 | 385 | </div> |
386 | 386 | <div class="clear"> |
387 | 387 | </div> |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | |
393 | 393 | } |
394 | 394 | |
395 | -if ( ! function_exists( 'mb_detect_encoding' ) ) { |
|
395 | +if ( ! function_exists('mb_detect_encoding')) { |
|
396 | 396 | |
397 | 397 | /** |
398 | 398 | * Fallback function for `mb_detect_encoding()`, |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * |
407 | 407 | * @return bool |
408 | 408 | */ |
409 | - function mb_detect_encoding( $string, $enc = null, $ret = null ) { |
|
409 | + function mb_detect_encoding($string, $enc = null, $ret = null) { |
|
410 | 410 | |
411 | 411 | static $enclist = array( |
412 | 412 | 'UTF-8', |
@@ -432,10 +432,10 @@ discard block |
||
432 | 432 | |
433 | 433 | $result = false; |
434 | 434 | |
435 | - foreach ( $enclist as $item ) { |
|
436 | - $sample = iconv( $item, $item, $string ); |
|
437 | - if ( md5( $sample ) == md5( $string ) ) { |
|
438 | - if ( $ret === null ) { |
|
435 | + foreach ($enclist as $item) { |
|
436 | + $sample = iconv($item, $item, $string); |
|
437 | + if (md5($sample) == md5($string)) { |
|
438 | + if ($ret === null) { |
|
439 | 439 | $result = $item; |
440 | 440 | } else { |
441 | 441 | $result = true; |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Admin functions |
|
4 | - * |
|
5 | - * Functions for the admin back end components only. |
|
6 | - * |
|
7 | - * @package SimpleCalendar/Admin/Functions |
|
8 | - */ |
|
3 | + * Admin functions |
|
4 | + * |
|
5 | + * Functions for the admin back end components only. |
|
6 | + * |
|
7 | + * @package SimpleCalendar/Admin/Functions |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | 11 | exit; |