@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | namespace SimpleCalendar\Admin; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | 38 | |
39 | - $this->install = isset( $_GET['simcal_install'] ) ? esc_attr( $_GET['simcal_install'] ) : ''; |
|
39 | + $this->install = isset($_GET['simcal_install']) ? esc_attr($_GET['simcal_install']) : ''; |
|
40 | 40 | |
41 | - add_action( 'admin_menu', array( $this, 'welcome_page_tabs' ) ); |
|
42 | - add_action( 'admin_head', array( $this, 'remove_submenu_pages' ) ); |
|
41 | + add_action('admin_menu', array($this, 'welcome_page_tabs')); |
|
42 | + add_action('admin_head', array($this, 'remove_submenu_pages')); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function welcome_page_tabs() { |
51 | 51 | |
52 | - $welcome_page_name = __( 'About Simple Calendar', 'google-calendar-events' ); |
|
53 | - $welcome_page_title = __( 'Welcome to Simple Calendar', 'google-calendar-events' ); |
|
52 | + $welcome_page_name = __('About Simple Calendar', 'google-calendar-events'); |
|
53 | + $welcome_page_title = __('Welcome to Simple Calendar', 'google-calendar-events'); |
|
54 | 54 | |
55 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : 'simple-calendar_about'; |
|
55 | + $page = isset($_GET['page']) ? $_GET['page'] : 'simple-calendar_about'; |
|
56 | 56 | |
57 | - switch ( $page ) { |
|
57 | + switch ($page) { |
|
58 | 58 | |
59 | 59 | case 'simple-calendar_about' : |
60 | 60 | $page = add_dashboard_page( |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | $welcome_page_name, |
63 | 63 | 'manage_options', |
64 | 64 | 'simple-calendar_about', |
65 | - array( $this, 'about_screen' ) |
|
65 | + array($this, 'about_screen') |
|
66 | 66 | ); |
67 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
67 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
68 | 68 | break; |
69 | 69 | |
70 | 70 | case 'simple-calendar_credits' : |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | $welcome_page_name, |
74 | 74 | 'manage_options', |
75 | 75 | 'simple-calendar_credits', |
76 | - array( $this, 'credits_screen' ) |
|
76 | + array($this, 'credits_screen') |
|
77 | 77 | ); |
78 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
78 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
79 | 79 | break; |
80 | 80 | |
81 | 81 | case 'simple-calendar_translators' : |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | $welcome_page_name, |
85 | 85 | 'manage_options', |
86 | 86 | 'simple-calendar_translators', |
87 | - array( $this, 'translators_screen' ) |
|
87 | + array($this, 'translators_screen') |
|
88 | 88 | ); |
89 | - add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); |
|
89 | + add_action('admin_print_styles-'.$page, array($this, 'styles')); |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | * @since 3.0.0 |
99 | 99 | */ |
100 | 100 | public function remove_submenu_pages() { |
101 | - remove_submenu_page( 'index.php', 'simple-calendar_about' ); |
|
102 | - remove_submenu_page( 'index.php', 'simple-calendar_credits' ); |
|
103 | - remove_submenu_page( 'index.php', 'simple-calendar_translators' ); |
|
101 | + remove_submenu_page('index.php', 'simple-calendar_about'); |
|
102 | + remove_submenu_page('index.php', 'simple-calendar_credits'); |
|
103 | + remove_submenu_page('index.php', 'simple-calendar_translators'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | |
130 | 130 | ?> |
131 | 131 | <p> |
132 | - <a href="<?php echo admin_url( 'edit.php?post_type=calendar' ); ?>" |
|
132 | + <a href="<?php echo admin_url('edit.php?post_type=calendar'); ?>" |
|
133 | 133 | class="button button-primary" |
134 | - ><?php _e( 'Calendars', 'google-calendar-events' ); ?></a> |
|
135 | - <a href="<?php echo esc_url( add_query_arg( 'page', 'simple-calendar_settings', admin_url( 'admin.php' ) ) ); ?>" |
|
134 | + ><?php _e('Calendars', 'google-calendar-events'); ?></a> |
|
135 | + <a href="<?php echo esc_url(add_query_arg('page', 'simple-calendar_settings', admin_url('admin.php'))); ?>" |
|
136 | 136 | class="button button-primary" |
137 | - ><?php _e( 'Settings', 'google-calendar-events' ); ?></a> |
|
138 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'add-ons' ), 'core-plugin', 'welcome-page' ); ?>" |
|
137 | + ><?php _e('Settings', 'google-calendar-events'); ?></a> |
|
138 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('add-ons'), 'core-plugin', 'welcome-page'); ?>" |
|
139 | 139 | class="docs button button-primary" target="_blank" |
140 | - ><?php _e( 'Add-ons', 'google-calendar-events' ); ?></a> |
|
141 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'docs' ), 'core-plugin', 'welcome-page' ); ?>" |
|
140 | + ><?php _e('Add-ons', 'google-calendar-events'); ?></a> |
|
141 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('docs'), 'core-plugin', 'welcome-page'); ?>" |
|
142 | 142 | class="docs button button-primary" target="_blank" |
143 | - ><?php _e( 'Documentation', 'google-calendar-events' ); ?></a> |
|
143 | + ><?php _e('Documentation', 'google-calendar-events'); ?></a> |
|
144 | 144 | </p> |
145 | 145 | <?php |
146 | 146 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | <h1> |
158 | 158 | <?php |
159 | 159 | /* translators: %s prints the current version of the plugin. */ |
160 | - printf( __( 'Welcome to Simple Calendar %s', 'google-calendar-events' ), SIMPLE_CALENDAR_VERSION ); |
|
160 | + printf(__('Welcome to Simple Calendar %s', 'google-calendar-events'), SIMPLE_CALENDAR_VERSION); |
|
161 | 161 | ?> |
162 | 162 | </h1> |
163 | 163 | |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | <?php |
166 | 166 | |
167 | 167 | // Difference message if updating vs fresh install. |
168 | - if ( 'update' == $this->install ) { |
|
169 | - $message = __( 'Thanks for updating to the latest version!', 'google-calendar-events' ); |
|
168 | + if ('update' == $this->install) { |
|
169 | + $message = __('Thanks for updating to the latest version!', 'google-calendar-events'); |
|
170 | 170 | } else { |
171 | - $message = __( 'Thanks for installing!', 'google-calendar-events' ); |
|
171 | + $message = __('Thanks for installing!', 'google-calendar-events'); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | echo $message; |
175 | 175 | |
176 | 176 | /* translators: %s prints the current version of the plugin. */ |
177 | - printf( ' ' . __( "Simple Calendar %s has many new display options and is much easier to configure. We think you'll really enjoy using it.", 'google-calendar-events' ), SIMPLE_CALENDAR_VERSION ); |
|
177 | + printf(' '.__("Simple Calendar %s has many new display options and is much easier to configure. We think you'll really enjoy using it.", 'google-calendar-events'), SIMPLE_CALENDAR_VERSION); |
|
178 | 178 | |
179 | 179 | ?> |
180 | 180 | </div> |
@@ -184,21 +184,21 @@ discard block |
||
184 | 184 | <?php $this->main_nav_links(); ?> |
185 | 185 | |
186 | 186 | <h2 class="nav-tab-wrapper"> |
187 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_about' ) { |
|
187 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_about') { |
|
188 | 188 | echo 'nav-tab-active'; |
189 | 189 | } ?>" |
190 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_about' ), 'index.php' ) ) ); ?>" |
|
191 | - ><?php _e( "What's New", 'google-calendar-events' ); ?></a> |
|
192 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_credits' ) { |
|
190 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_about'), 'index.php'))); ?>" |
|
191 | + ><?php _e("What's New", 'google-calendar-events'); ?></a> |
|
192 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_credits') { |
|
193 | 193 | echo 'nav-tab-active'; |
194 | 194 | } ?>" |
195 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_credits' ), 'index.php' ) ) ); ?>" |
|
196 | - ><?php _e( 'Credits', 'google-calendar-events' ); ?></a> |
|
197 | - <a class="nav-tab <?php if ( $_GET['page'] == 'simple-calendar_translators' ) { |
|
195 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_credits'), 'index.php'))); ?>" |
|
196 | + ><?php _e('Credits', 'google-calendar-events'); ?></a> |
|
197 | + <a class="nav-tab <?php if ($_GET['page'] == 'simple-calendar_translators') { |
|
198 | 198 | echo 'nav-tab-active'; |
199 | 199 | } ?>" |
200 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'simple-calendar_translators' ), 'index.php' ) ) ); ?>" |
|
201 | - ><?php _e( 'Translators', 'google-calendar-events' ); ?></a> |
|
200 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'simple-calendar_translators'), 'index.php'))); ?>" |
|
201 | + ><?php _e('Translators', 'google-calendar-events'); ?></a> |
|
202 | 202 | </h2> |
203 | 203 | <?php |
204 | 204 | |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * @since 3.0.0 |
211 | 211 | */ |
212 | 212 | public function about_screen() { |
213 | - $welcome_image_about_path = SIMPLE_CALENDAR_ASSETS . '/images/welcome'; |
|
214 | - $welcome_gcal_pro_link = simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'welcome-page' ); |
|
213 | + $welcome_image_about_path = SIMPLE_CALENDAR_ASSETS.'/images/welcome'; |
|
214 | + $welcome_gcal_pro_link = simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'welcome-page'); |
|
215 | 215 | |
216 | 216 | ?> |
217 | 217 | <div id="simcal-welcome"> |
@@ -219,18 +219,18 @@ discard block |
||
219 | 219 | |
220 | 220 | <?php $this->intro(); ?> |
221 | 221 | |
222 | - <h3><?php _e( 'Modern calendar displays with easily updateable event text and color options.', 'google-calendar-events' ); ?></h3> |
|
223 | - <img src="<?php echo $welcome_image_about_path . '/grid-view-custom-colors.png'; ?>" /> |
|
222 | + <h3><?php _e('Modern calendar displays with easily updateable event text and color options.', 'google-calendar-events'); ?></h3> |
|
223 | + <img src="<?php echo $welcome_image_about_path.'/grid-view-custom-colors.png'; ?>" /> |
|
224 | 224 | |
225 | - <h3><?php _e( 'Mobile responsive and widget ready.', 'google-calendar-events' ); ?></h3> |
|
226 | - <img src="<?php echo $welcome_image_about_path . '/list-view-widget.png'; ?>" /> |
|
227 | - <img src="<?php echo $welcome_image_about_path . '/grid-view-widget-dark-theme.png'; ?>" /> |
|
225 | + <h3><?php _e('Mobile responsive and widget ready.', 'google-calendar-events'); ?></h3> |
|
226 | + <img src="<?php echo $welcome_image_about_path.'/list-view-widget.png'; ?>" /> |
|
227 | + <img src="<?php echo $welcome_image_about_path.'/grid-view-widget-dark-theme.png'; ?>" /> |
|
228 | 228 | |
229 | - <h3><?php _e( 'Simpler, more intuitive calendar settings.', 'google-calendar-events' ); ?></h3> |
|
230 | - <img src="<?php echo $welcome_image_about_path . '/calendar-settings-appearance.png'; ?>" /> |
|
229 | + <h3><?php _e('Simpler, more intuitive calendar settings.', 'google-calendar-events'); ?></h3> |
|
230 | + <img src="<?php echo $welcome_image_about_path.'/calendar-settings-appearance.png'; ?>" /> |
|
231 | 231 | |
232 | - <h3><?php echo sprintf( __( 'Extendible with add-ons like <a href="%s" target="_blank">Google Calendar Pro</a>.', 'google-calendar-events' ), $welcome_gcal_pro_link ); ?></h3> |
|
233 | - <a href="<?php echo $welcome_gcal_pro_link; ?>" target="_blank"><img src="<?php echo $welcome_image_about_path . '/google-calendar-pro-list-view-annotated.png'; ?>" /></a> |
|
232 | + <h3><?php echo sprintf(__('Extendible with add-ons like <a href="%s" target="_blank">Google Calendar Pro</a>.', 'google-calendar-events'), $welcome_gcal_pro_link); ?></h3> |
|
233 | + <a href="<?php echo $welcome_gcal_pro_link; ?>" target="_blank"><img src="<?php echo $welcome_image_about_path.'/google-calendar-pro-list-view-annotated.png'; ?>" /></a> |
|
234 | 234 | |
235 | 235 | <hr/> |
236 | 236 | |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | <?php |
258 | 258 | |
259 | 259 | printf( |
260 | - __( "Simple Calendar is created by a worldwide team of developers. If you'd like to contribute please visit our <a href='%s' target='_blank'>GitHub repo</a>.", 'google-calendar-events' ), |
|
261 | - simcal_get_url( 'github' ) |
|
260 | + __("Simple Calendar is created by a worldwide team of developers. If you'd like to contribute please visit our <a href='%s' target='_blank'>GitHub repo</a>.", 'google-calendar-events'), |
|
261 | + simcal_get_url('github') |
|
262 | 262 | ); |
263 | 263 | |
264 | 264 | ?> |
@@ -282,10 +282,10 @@ discard block |
||
282 | 282 | <div class="wrap about-wrap translators-wrap"> |
283 | 283 | <?php $this->intro(); ?> |
284 | 284 | <p class="about-description"> |
285 | - <?php _e( 'Simple Calendar has been kindly translated into several other languages by contributors from all over the world.', 'google-calendar-events' ); ?> |
|
285 | + <?php _e('Simple Calendar has been kindly translated into several other languages by contributors from all over the world.', 'google-calendar-events'); ?> |
|
286 | 286 | </p> |
287 | 287 | <p class="about-description"> |
288 | - <a href="https://translate.wordpress.org/projects/wp-plugins/google-calendar-events" target="_blank"><?php _e( 'Click here to help translate', 'google-calendar-events' ); ?></a> |
|
288 | + <a href="https://translate.wordpress.org/projects/wp-plugins/google-calendar-events" target="_blank"><?php _e('Click here to help translate', 'google-calendar-events'); ?></a> |
|
289 | 289 | </p> |
290 | 290 | <?php |
291 | 291 | |
@@ -314,31 +314,31 @@ discard block |
||
314 | 314 | |
315 | 315 | $contributors = $this->get_contributors(); |
316 | 316 | |
317 | - if ( empty( $contributors ) ) { |
|
317 | + if (empty($contributors)) { |
|
318 | 318 | return ''; |
319 | 319 | } |
320 | 320 | |
321 | 321 | $contributor_list = '<ul class="wp-people-group">'; |
322 | 322 | |
323 | - foreach ( $contributors as $contributor ) { |
|
323 | + foreach ($contributors as $contributor) { |
|
324 | 324 | |
325 | 325 | // Skip contributor bots |
326 | - $contributor_bots = array( 'gitter-badger' ); |
|
327 | - if ( in_array( $contributor->login, $contributor_bots ) ) { |
|
326 | + $contributor_bots = array('gitter-badger'); |
|
327 | + if (in_array($contributor->login, $contributor_bots)) { |
|
328 | 328 | continue; |
329 | 329 | } |
330 | 330 | |
331 | 331 | $contributor_list .= '<li class="wp-person">'; |
332 | 332 | $contributor_list .= sprintf( |
333 | 333 | '<a href="%s" title="%s" target="_blank">%s</a>', |
334 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
335 | - esc_html( sprintf( __( 'View %s', 'google-calendar-events' ), $contributor->login ) ), |
|
336 | - sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) ) |
|
334 | + esc_url('https://github.com/'.$contributor->login), |
|
335 | + esc_html(sprintf(__('View %s', 'google-calendar-events'), $contributor->login)), |
|
336 | + sprintf('<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url($contributor->avatar_url), esc_html($contributor->login)) |
|
337 | 337 | ); |
338 | 338 | $contributor_list .= sprintf( |
339 | 339 | '<a class="web" href="%s" target="_blank">%s</a>', |
340 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
341 | - esc_html( $contributor->login ) |
|
340 | + esc_url('https://github.com/'.$contributor->login), |
|
341 | + esc_html($contributor->login) |
|
342 | 342 | ); |
343 | 343 | $contributor_list .= '</li>'; |
344 | 344 | |
@@ -358,24 +358,24 @@ discard block |
||
358 | 358 | */ |
359 | 359 | public function get_contributors() { |
360 | 360 | |
361 | - $contributors = get_transient( '_simple-calendar_contributors' ); |
|
362 | - if ( false !== $contributors ) { |
|
361 | + $contributors = get_transient('_simple-calendar_contributors'); |
|
362 | + if (false !== $contributors) { |
|
363 | 363 | return $contributors; |
364 | 364 | } |
365 | 365 | |
366 | 366 | $response = wp_safe_remote_get( |
367 | 367 | 'https://api.github.com/repos/moonstonemedia/Simple-Calendar/contributors' |
368 | 368 | ); |
369 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
369 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
370 | 370 | return array(); |
371 | 371 | } |
372 | 372 | |
373 | - $contributors = json_decode( wp_remote_retrieve_body( $response ) ); |
|
374 | - if ( ! is_array( $contributors ) ) { |
|
373 | + $contributors = json_decode(wp_remote_retrieve_body($response)); |
|
374 | + if ( ! is_array($contributors)) { |
|
375 | 375 | return array(); |
376 | 376 | } |
377 | 377 | |
378 | - set_transient( '_simple-calendar_contributors', $contributors, HOUR_IN_SECONDS ); |
|
378 | + set_transient('_simple-calendar_contributors', $contributors, HOUR_IN_SECONDS); |
|
379 | 379 | |
380 | 380 | return $contributors; |
381 | 381 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts\Field; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; // Exit if accessed directly. |
13 | 13 | } |
14 | 14 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param array $field |
30 | 30 | */ |
31 | - public function __construct( $field ) { |
|
31 | + public function __construct($field) { |
|
32 | 32 | $this->type_class = 'simcal-field-checkboxes'; |
33 | - parent::__construct( $field ); |
|
33 | + parent::__construct($field); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -40,33 +40,33 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function html() { |
42 | 42 | |
43 | - if ( ! empty( $this->options ) && count( (array) $this->options ) > 1 ) { |
|
43 | + if ( ! empty($this->options) && count((array) $this->options) > 1) { |
|
44 | 44 | |
45 | - if ( ! empty( $this->description ) ) { |
|
46 | - echo '<p class="description">' . wp_kses_post( $this->description ) . ' ' . $this->tooltip . '</p>'; |
|
45 | + if ( ! empty($this->description)) { |
|
46 | + echo '<p class="description">'.wp_kses_post($this->description).' '.$this->tooltip.'</p>'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | ?> |
50 | - <fieldset class="<?php echo $this->class; ?>" <?php echo ! empty( $this->style ) ? 'style="' . $this->style . '"' : ''; ?>> |
|
50 | + <fieldset class="<?php echo $this->class; ?>" <?php echo ! empty($this->style) ? 'style="'.$this->style.'"' : ''; ?>> |
|
51 | 51 | <?php |
52 | 52 | |
53 | - if ( ! empty( $this->title ) ) { |
|
54 | - echo '<legend class="screen-reader-text"><span>' . $this->title . '</span></legend>'; |
|
53 | + if ( ! empty($this->title)) { |
|
54 | + echo '<legend class="screen-reader-text"><span>'.$this->title.'</span></legend>'; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | ?> |
58 | 58 | <ul> |
59 | - <?php foreach ( $this->options as $option => $name ) : ?> |
|
59 | + <?php foreach ($this->options as $option => $name) : ?> |
|
60 | 60 | <li> |
61 | - <label for="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>"> |
|
61 | + <label for="<?php echo $this->id.'-'.trim(strval($option)); ?>"> |
|
62 | 62 | <input name="<?php echo $this->name; ?>" |
63 | - id="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>" |
|
63 | + id="<?php echo $this->id.'-'.trim(strval($option)); ?>" |
|
64 | 64 | class="simcal-field simcal-field-checkbox" |
65 | 65 | type="checkbox" |
66 | - value="<?php echo trim( strval( $option ) ); ?>" |
|
67 | - <?php checked( $this->value, 'yes', true ); ?> |
|
66 | + value="<?php echo trim(strval($option)); ?>" |
|
67 | + <?php checked($this->value, 'yes', true); ?> |
|
68 | 68 | <?php echo $this->attributes; ?> |
69 | - /><?php echo esc_attr( $name ); ?> |
|
69 | + /><?php echo esc_attr($name); ?> |
|
70 | 70 | </label> |
71 | 71 | </li> |
72 | 72 | <?php endforeach; ?> |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | } else { |
78 | 78 | |
79 | 79 | ?> |
80 | - <span class="simcal-field-bool" <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?>> |
|
81 | - <?php if ( ! empty( $this->title ) ) : ?> |
|
80 | + <span class="simcal-field-bool" <?php echo $this->style ? 'style="'.$this->style.'"' : ''; ?>> |
|
81 | + <?php if ( ! empty($this->title)) : ?> |
|
82 | 82 | <span class="screen-reader-text"><?php echo $this->title; ?></span> |
83 | 83 | <?php endif; ?> |
84 | 84 | <input name="<?php echo $this->name; ?>" |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | id="<?php echo $this->id; ?>" |
87 | 87 | class="simcal-field simcal-field-checkbox <?php echo $this->class; ?>" |
88 | 88 | value="yes" |
89 | - <?php checked( $this->value, 'yes', true ); ?> |
|
90 | - <?php echo $this->attributes; ?>/><?php _e( 'Yes', 'google-calendar-events' ); ?> |
|
89 | + <?php checked($this->value, 'yes', true); ?> |
|
90 | + <?php echo $this->attributes; ?>/><?php _e('Yes', 'google-calendar-events'); ?> |
|
91 | 91 | </span> |
92 | 92 | <?php |
93 | 93 | |
94 | 94 | echo $this->tooltip; |
95 | 95 | |
96 | - if ( ! empty( $this->description ) ) { |
|
97 | - echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>'; |
|
96 | + if ( ! empty($this->description)) { |
|
97 | + echo '<p class="description">'.wp_kses_post($this->description).'</p>'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | } |
@@ -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> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events' ), |
|
88 | - simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'settings-link' ) |
|
89 | - ) . |
|
90 | - '</em>', |
|
85 | + '<br/><br/>' . |
|
86 | + '<em style="font-size: 14px;">' . |
|
87 | + sprintf( __( '<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events' ), |
|
88 | + simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'settings-link' ) |
|
89 | + ) . |
|
90 | + '</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> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events' ), |
|
88 | - simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'settings-link' ) |
|
89 | - ) . |
|
84 | + 'description' => __("To read events from your public Google Calendars you'll need create a Google API key and save it here.", 'google-calendar-events'). |
|
85 | + '<br/><br/>'. |
|
86 | + '<em style="font-size: 14px;">'. |
|
87 | + sprintf(__('<strong>Note:</strong> Calendars configured to use the <strong><a href="%s" target="_blank">Google Calendar Pro add-on</a></strong> use a different method of authorization.', 'google-calendar-events'), |
|
88 | + simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'settings-link') |
|
89 | + ). |
|
90 | 90 | '</em>', |
91 | 91 | 'fields' => array( |
92 | 92 | 'api_key' => array( |
93 | 93 | 'type' => 'standard', |
94 | 94 | 'subtype' => 'text', |
95 | - 'class' => array( 'simcal-wide-text regular-text', 'ltr' ), |
|
96 | - 'title' => __( 'Google API Key', 'google-calendar-events' ), |
|
97 | - 'validation' => array( $this, 'check_google_api_key' ), |
|
95 | + 'class' => array('simcal-wide-text regular-text', 'ltr'), |
|
96 | + 'title' => __('Google API Key', 'google-calendar-events'), |
|
97 | + 'validation' => array($this, 'check_google_api_key'), |
|
98 | 98 | ), |
99 | 99 | ), |
100 | 100 | ); |
@@ -113,27 +113,27 @@ discard block |
||
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 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @package SimpleCalendar/Admin/Functions |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return null|\SimpleCalendar\Abstracts\Admin_Page |
34 | 34 | */ |
35 | -function simcal_get_admin_page( $page ) { |
|
35 | +function simcal_get_admin_page($page) { |
|
36 | 36 | $objects = \SimpleCalendar\plugin()->objects; |
37 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page( $page ) : null; |
|
37 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_admin_page($page) : null; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @return null|\SimpleCalendar\Abstracts\Field |
49 | 49 | */ |
50 | -function simcal_get_field( $args, $name = '' ) { |
|
50 | +function simcal_get_field($args, $name = '') { |
|
51 | 51 | $objects = \SimpleCalendar\plugin()->objects; |
52 | - return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field( $args, $name ) : null; |
|
52 | + return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field($args, $name) : null; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return void |
64 | 64 | */ |
65 | -function simcal_print_field( $args, $name = '' ) { |
|
65 | +function simcal_print_field($args, $name = '') { |
|
66 | 66 | |
67 | - $field = simcal_get_field( $args, $name ); |
|
67 | + $field = simcal_get_field($args, $name); |
|
68 | 68 | |
69 | - if ( $field instanceof \SimpleCalendar\Abstracts\Field ) { |
|
69 | + if ($field instanceof \SimpleCalendar\Abstracts\Field) { |
|
70 | 70 | $field->html(); |
71 | 71 | } |
72 | 72 | } |
@@ -84,33 +84,33 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return array|string Sanitized variable |
86 | 86 | */ |
87 | -function simcal_sanitize_input( $var, $func = 'sanitize_text_field' ) { |
|
87 | +function simcal_sanitize_input($var, $func = 'sanitize_text_field') { |
|
88 | 88 | |
89 | - if ( is_null( $var ) ) { |
|
89 | + if (is_null($var)) { |
|
90 | 90 | return ''; |
91 | 91 | } |
92 | 92 | |
93 | - if ( is_bool( $var ) ) { |
|
94 | - if ( $var === true ) { |
|
93 | + if (is_bool($var)) { |
|
94 | + if ($var === true) { |
|
95 | 95 | return 'yes'; |
96 | 96 | } else { |
97 | 97 | return 'no'; |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - if ( is_string( $var ) || is_numeric( $var ) ) { |
|
102 | - $func = is_string( $func ) && function_exists( $func ) ? $func : 'sanitize_text_field'; |
|
103 | - return call_user_func( $func, trim( strval( $var ) ) ); |
|
101 | + if (is_string($var) || is_numeric($var)) { |
|
102 | + $func = is_string($func) && function_exists($func) ? $func : 'sanitize_text_field'; |
|
103 | + return call_user_func($func, trim(strval($var))); |
|
104 | 104 | } |
105 | 105 | |
106 | - if ( is_object( $var ) ) { |
|
106 | + if (is_object($var)) { |
|
107 | 107 | $var = (array) $var; |
108 | 108 | } |
109 | 109 | |
110 | - if ( is_array( $var ) ) { |
|
110 | + if (is_array($var)) { |
|
111 | 111 | $array = array(); |
112 | - foreach ( $var as $k => $v ) { |
|
113 | - $array[ $k ] = simcal_sanitize_input( $v ); |
|
112 | + foreach ($var as $k => $v) { |
|
113 | + $array[$k] = simcal_sanitize_input($v); |
|
114 | 114 | } |
115 | 115 | return $array; |
116 | 116 | } |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | */ |
129 | 129 | function simcal_is_admin_screen() { |
130 | 130 | |
131 | - $view = function_exists( 'get_current_screen' ) ? get_current_screen() : false; |
|
131 | + $view = function_exists('get_current_screen') ? get_current_screen() : false; |
|
132 | 132 | |
133 | - if ( $view instanceof WP_Screen ) { |
|
133 | + if ($view instanceof WP_Screen) { |
|
134 | 134 | |
135 | 135 | // Screens used by this plugin. |
136 | 136 | $screens = array( |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'dashboard_page_simple-calendar_credits', |
146 | 146 | 'dashboard_page_simple-calendar_translators', |
147 | 147 | ); |
148 | - if ( in_array( $view->id, $screens ) ) { |
|
148 | + if (in_array($view->id, $screens)) { |
|
149 | 149 | return $view->id; |
150 | 150 | } |
151 | 151 | } |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return \SimpleCalendar\Admin\Updater |
166 | 166 | */ |
167 | -function simcal_addon_updater( $_api_url, $_plugin_file, $_api_data = null ) { |
|
168 | - return new \SimpleCalendar\Admin\Updater( $_api_url, $_plugin_file, $_api_data ); |
|
167 | +function simcal_addon_updater($_api_url, $_plugin_file, $_api_data = null) { |
|
168 | + return new \SimpleCalendar\Admin\Updater($_api_url, $_plugin_file, $_api_data); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return null|string |
179 | 179 | */ |
180 | -function simcal_get_license_key( $addon ) { |
|
181 | - $licenses = get_option( 'simple-calendar_settings_licenses', array() ); |
|
182 | - if ( isset( $licenses['keys'][ $addon ] ) ) { |
|
183 | - return empty( $licenses['keys'][ $addon ] ) ? null : $licenses['keys'][ $addon ]; |
|
180 | +function simcal_get_license_key($addon) { |
|
181 | + $licenses = get_option('simple-calendar_settings_licenses', array()); |
|
182 | + if (isset($licenses['keys'][$addon])) { |
|
183 | + return empty($licenses['keys'][$addon]) ? null : $licenses['keys'][$addon]; |
|
184 | 184 | } |
185 | 185 | return null; |
186 | 186 | } |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return array|string |
198 | 198 | */ |
199 | -function simcal_get_license_status( $addon = null ) { |
|
200 | - $licenses = get_option( 'simple-calendar_licenses_status', array() ); |
|
201 | - return isset( $licenses[ $addon ] ) ? $licenses[ $addon ] : $licenses; |
|
199 | +function simcal_get_license_status($addon = null) { |
|
200 | + $licenses = get_option('simple-calendar_licenses_status', array()); |
|
201 | + return isset($licenses[$addon]) ? $licenses[$addon] : $licenses; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @since 3.0.0 |
220 | 220 | */ |
221 | 221 | function simcal_delete_admin_notices() { |
222 | - delete_option( 'simple-calendar_admin_notices' ); |
|
222 | + delete_option('simple-calendar_admin_notices'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -231,22 +231,22 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return void |
233 | 233 | */ |
234 | -function simcal_print_shortcode_tip( $post_id ) { |
|
234 | +function simcal_print_shortcode_tip($post_id) { |
|
235 | 235 | |
236 | 236 | $browser = new \Browser(); |
237 | - if ( $browser::PLATFORM_APPLE == $browser->getPlatform() ) { |
|
237 | + if ($browser::PLATFORM_APPLE == $browser->getPlatform()) { |
|
238 | 238 | $cmd = '⌘+C'; |
239 | 239 | } else { |
240 | 240 | $cmd = 'Ctrl+C'; |
241 | 241 | } |
242 | 242 | |
243 | - $shortcut = sprintf( __( 'Press %s to copy.', 'google-calendar-events' ), $cmd ); |
|
244 | - $shortcode = sprintf( '[calendar id="%s"]', $post_id ); |
|
243 | + $shortcut = sprintf(__('Press %s to copy.', 'google-calendar-events'), $cmd); |
|
244 | + $shortcode = sprintf('[calendar id="%s"]', $post_id); |
|
245 | 245 | |
246 | - echo "<input readonly='readonly' " . |
|
247 | - "class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' " . |
|
248 | - "title='" . $shortcut . "' " . |
|
249 | - "onclick='this.select();' value='" . $shortcode . "' />"; |
|
246 | + echo "<input readonly='readonly' ". |
|
247 | + "class='simcal-shortcode simcal-calendar-shortcode simcal-shortcode-tip' ". |
|
248 | + "title='".$shortcut."' ". |
|
249 | + "onclick='this.select();' value='".$shortcode."' />"; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -261,20 +261,20 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return string $url Full Google Analytics campaign URL |
263 | 263 | */ |
264 | -function simcal_ga_campaign_url( $base_url, $campaign, $content, $raw = false ) { |
|
264 | +function simcal_ga_campaign_url($base_url, $campaign, $content, $raw = false) { |
|
265 | 265 | |
266 | - $url = add_query_arg( array( |
|
266 | + $url = add_query_arg(array( |
|
267 | 267 | 'utm_source' => 'inside-plugin', |
268 | 268 | 'utm_medium' => 'link', |
269 | 269 | 'utm_campaign' => $campaign, // i.e. 'core-plugin', 'gcal-pro' |
270 | 270 | 'utm_content' => $content // i.e. 'sidebar-link', 'settings-link' |
271 | - ), $base_url ); |
|
271 | + ), $base_url); |
|
272 | 272 | |
273 | - if ( $raw ) { |
|
274 | - return esc_url_raw( $url ); |
|
273 | + if ($raw) { |
|
274 | + return esc_url_raw($url); |
|
275 | 275 | } |
276 | 276 | |
277 | - return esc_url( $url ); |
|
277 | + return esc_url($url); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | function simcal_newsletter_signup() { |
288 | 288 | |
289 | - if ( $screen = simcal_is_admin_screen() ) { |
|
289 | + if ($screen = simcal_is_admin_screen()) { |
|
290 | 290 | |
291 | 291 | global $current_user; |
292 | 292 | get_currentuserinfo(); |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | <div id="simcal-drip" class="<?php echo $screen; ?>"> |
298 | 298 | <div class="signup"> |
299 | 299 | <p> |
300 | - <?php _e( "Enter your name and email and we'll send you a coupon code for 20% off our Google Calendar Pro add-on.", 'google-calendar-events' ); ?> |
|
300 | + <?php _e("Enter your name and email and we'll send you a coupon code for 20% off our Google Calendar Pro add-on.", 'google-calendar-events'); ?> |
|
301 | 301 | </p> |
302 | 302 | |
303 | 303 | <p> |
304 | - <label for="simcal-drip-field-email"><?php _e( 'Your Email', 'google-calendar-events' ); ?></label><br /> |
|
304 | + <label for="simcal-drip-field-email"><?php _e('Your Email', 'google-calendar-events'); ?></label><br /> |
|
305 | 305 | <input type="email" |
306 | 306 | id="simcal-drip-field-email" |
307 | 307 | name="fields[email]" |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | </p> |
310 | 310 | |
311 | 311 | <p> |
312 | - <label for="simcal-drip-field-first_name"><?php _e( 'First Name', 'google-calendar-events' ); ?></label><br /> |
|
312 | + <label for="simcal-drip-field-first_name"><?php _e('First Name', 'google-calendar-events'); ?></label><br /> |
|
313 | 313 | <input type="text" |
314 | 314 | id="simcal-drip-field-first_name" |
315 | 315 | name="fields[first_name]" |
@@ -318,15 +318,15 @@ discard block |
||
318 | 318 | <p class="textright"> |
319 | 319 | <a href="#" |
320 | 320 | id="simcal-drip-signup" |
321 | - class="button button-primary"><?php _e( 'Send me the coupon', 'google-calendar-events' ); ?></a> |
|
321 | + class="button button-primary"><?php _e('Send me the coupon', 'google-calendar-events'); ?></a> |
|
322 | 322 | </p> |
323 | 323 | <div class="textright"> |
324 | - <a href="<?php echo simcal_ga_campaign_url( simcal_get_url( 'gcal-pro' ), 'core-plugin', 'sidebar-link' ); ?>" |
|
325 | - target="_blank"><?php _e( 'Just take me to GCal Pro', 'google-calendar-events' ); ?></a> |
|
324 | + <a href="<?php echo simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'sidebar-link'); ?>" |
|
325 | + target="_blank"><?php _e('Just take me to GCal Pro', 'google-calendar-events'); ?></a> |
|
326 | 326 | </div> |
327 | 327 | </div> |
328 | 328 | <div class="thank-you" style="display: none;"> |
329 | - <?php _e( 'Thank you!', 'google-calendar-events' ); ?> |
|
329 | + <?php _e('Thank you!', 'google-calendar-events'); ?> |
|
330 | 330 | </div> |
331 | 331 | <div class="clear"> |
332 | 332 | </div> |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | |
338 | 338 | } |
339 | 339 | |
340 | -if ( ! function_exists( 'mb_detect_encoding' ) ) { |
|
340 | +if ( ! function_exists('mb_detect_encoding')) { |
|
341 | 341 | |
342 | 342 | /** |
343 | 343 | * Fallback function for `mb_detect_encoding()`, |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return bool |
353 | 353 | */ |
354 | - function mb_detect_encoding( $string, $enc = null, $ret = null ) { |
|
354 | + function mb_detect_encoding($string, $enc = null, $ret = null) { |
|
355 | 355 | |
356 | 356 | static $enclist = array( |
357 | 357 | 'UTF-8', |
@@ -377,10 +377,10 @@ discard block |
||
377 | 377 | |
378 | 378 | $result = false; |
379 | 379 | |
380 | - foreach ( $enclist as $item ) { |
|
381 | - $sample = iconv( $item, $item, $string ); |
|
382 | - if ( md5( $sample ) == md5( $string ) ) { |
|
383 | - if ( $ret === null ) { |
|
380 | + foreach ($enclist as $item) { |
|
381 | + $sample = iconv($item, $item, $string); |
|
382 | + if (md5($sample) == md5($string)) { |
|
383 | + if ($ret === null) { |
|
384 | 384 | $result = $item; |
385 | 385 | } else { |
386 | 386 | $result = true; |
@@ -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 | |
@@ -132,22 +132,22 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @param string|Calendar $calendar |
134 | 134 | */ |
135 | - public function __construct( $calendar = '' ) { |
|
135 | + public function __construct($calendar = '') { |
|
136 | 136 | |
137 | - if ( $calendar instanceof Calendar ) { |
|
137 | + if ($calendar instanceof Calendar) { |
|
138 | 138 | |
139 | - if ( isset( $calendar->id ) ) { |
|
139 | + if (isset($calendar->id)) { |
|
140 | 140 | $this->post_id = $calendar->id; |
141 | 141 | } |
142 | - if ( isset( $calendar->start ) ) { |
|
142 | + if (isset($calendar->start)) { |
|
143 | 143 | $this->calendar_start = $calendar->start; |
144 | 144 | } |
145 | - $this->week_starts = isset( $calendar->week_starts ) ? $calendar->week_starts : get_option( 'start_of_week' ); |
|
146 | - $this->events_template = ! empty( $calendar->events_template ) ? $calendar->events_template : simcal_default_event_template(); |
|
145 | + $this->week_starts = isset($calendar->week_starts) ? $calendar->week_starts : get_option('start_of_week'); |
|
146 | + $this->events_template = ! empty($calendar->events_template) ? $calendar->events_template : simcal_default_event_template(); |
|
147 | 147 | |
148 | - if ( $this->post_id > 0 ) { |
|
148 | + if ($this->post_id > 0) { |
|
149 | 149 | $this->set_cache(); |
150 | - $this->timezone_setting = get_post_meta( $this->post_id, '_feed_timezone_setting', true ); |
|
150 | + $this->timezone_setting = get_post_meta($this->post_id, '_feed_timezone_setting', true); |
|
151 | 151 | $this->timezone = $calendar->timezone; |
152 | 152 | $this->set_earliest_event(); |
153 | 153 | $this->set_latest_event(); |
@@ -173,25 +173,25 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @param int $timestamp |
175 | 175 | */ |
176 | - public function set_earliest_event( $timestamp = 0 ) { |
|
176 | + public function set_earliest_event($timestamp = 0) { |
|
177 | 177 | |
178 | - $earliest = intval( $timestamp ); |
|
178 | + $earliest = intval($timestamp); |
|
179 | 179 | |
180 | - if ( $earliest === 0 ) { |
|
180 | + if ($earliest === 0) { |
|
181 | 181 | |
182 | - $start = Carbon::createFromTimestamp( $this->calendar_start, $this->timezone ); |
|
182 | + $start = Carbon::createFromTimestamp($this->calendar_start, $this->timezone); |
|
183 | 183 | |
184 | - $earliest_date = esc_attr( get_post_meta( $this->post_id, '_feed_earliest_event_date', true ) ); |
|
185 | - $earliest_range = max( absint( get_post_meta( $this->post_id, '_feed_earliest_event_date_range', true ) ), 1 ); |
|
184 | + $earliest_date = esc_attr(get_post_meta($this->post_id, '_feed_earliest_event_date', true)); |
|
185 | + $earliest_range = max(absint(get_post_meta($this->post_id, '_feed_earliest_event_date_range', true)), 1); |
|
186 | 186 | |
187 | - if ( 'days_before' == $earliest_date ) { |
|
188 | - $earliest = $start->subDays( $earliest_range )->getTimestamp(); |
|
189 | - } elseif ( 'weeks_before' == $earliest_date ) { |
|
190 | - $earliest = $start->subWeeks( $earliest_range )->addDay()->getTimestamp(); |
|
191 | - } elseif ( 'months_before' == $earliest_date ) { |
|
192 | - $earliest = $start->subMonths( $earliest_range )->addDay()->getTimestamp(); |
|
193 | - } elseif ( 'years_before' == $earliest_date ) { |
|
194 | - $earliest = $start->subYears( $earliest_range )->addDay()->getTimestamp(); |
|
187 | + if ('days_before' == $earliest_date) { |
|
188 | + $earliest = $start->subDays($earliest_range)->getTimestamp(); |
|
189 | + } elseif ('weeks_before' == $earliest_date) { |
|
190 | + $earliest = $start->subWeeks($earliest_range)->addDay()->getTimestamp(); |
|
191 | + } elseif ('months_before' == $earliest_date) { |
|
192 | + $earliest = $start->subMonths($earliest_range)->addDay()->getTimestamp(); |
|
193 | + } elseif ('years_before' == $earliest_date) { |
|
194 | + $earliest = $start->subYears($earliest_range)->addDay()->getTimestamp(); |
|
195 | 195 | } else { |
196 | 196 | $earliest = $start->getTimestamp(); |
197 | 197 | } |
@@ -207,25 +207,25 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param int $timestamp |
209 | 209 | */ |
210 | - public function set_latest_event( $timestamp = 0 ) { |
|
210 | + public function set_latest_event($timestamp = 0) { |
|
211 | 211 | |
212 | - $latest = intval( $timestamp ); |
|
212 | + $latest = intval($timestamp); |
|
213 | 213 | |
214 | - if ( $latest === 0 ) { |
|
214 | + if ($latest === 0) { |
|
215 | 215 | |
216 | - $start = Carbon::createFromTimestamp( $this->calendar_start, $this->timezone )->endOfDay(); |
|
216 | + $start = Carbon::createFromTimestamp($this->calendar_start, $this->timezone)->endOfDay(); |
|
217 | 217 | |
218 | - $latest_date = esc_attr( get_post_meta( $this->post_id, '_feed_latest_event_date', true ) ); |
|
219 | - $latest_range = max( absint( get_post_meta( $this->post_id, '_feed_latest_event_date_range', true ) ), 1 ); |
|
218 | + $latest_date = esc_attr(get_post_meta($this->post_id, '_feed_latest_event_date', true)); |
|
219 | + $latest_range = max(absint(get_post_meta($this->post_id, '_feed_latest_event_date_range', true)), 1); |
|
220 | 220 | |
221 | - if ( 'days_after' == $latest_date ) { |
|
222 | - $latest = $start->addDays( $latest_range )->getTimestamp(); |
|
223 | - } elseif ( 'weeks_after' == $latest_date ) { |
|
224 | - $latest = $start->addWeeks( $latest_range )->subDay()->getTimestamp(); |
|
225 | - } elseif ( 'months_after' == $latest_date ) { |
|
226 | - $latest = $start->addMonths( $latest_range )->subDay()->getTimestamp(); |
|
227 | - } elseif ( 'years_after' == $latest_date ) { |
|
228 | - $latest = $start->addYears( $latest_range )->subDay()->getTimestamp(); |
|
221 | + if ('days_after' == $latest_date) { |
|
222 | + $latest = $start->addDays($latest_range)->getTimestamp(); |
|
223 | + } elseif ('weeks_after' == $latest_date) { |
|
224 | + $latest = $start->addWeeks($latest_range)->subDay()->getTimestamp(); |
|
225 | + } elseif ('months_after' == $latest_date) { |
|
226 | + $latest = $start->addMonths($latest_range)->subDay()->getTimestamp(); |
|
227 | + } elseif ('years_after' == $latest_date) { |
|
228 | + $latest = $start->addYears($latest_range)->subDay()->getTimestamp(); |
|
229 | 229 | } else { |
230 | 230 | $latest = $start->getTimestamp(); |
231 | 231 | } |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @param int $time |
244 | 244 | */ |
245 | - public function set_cache( $time = 0 ) { |
|
246 | - if ( $time === 0 || ! is_numeric( $time ) ) { |
|
247 | - $cache = get_post_meta( $this->post_id, '_feed_cache', true ); |
|
248 | - $time = is_numeric( $cache ) && $cache >= 0 ? absint( $cache ) : $this->cache; |
|
245 | + public function set_cache($time = 0) { |
|
246 | + if ($time === 0 || ! is_numeric($time)) { |
|
247 | + $cache = get_post_meta($this->post_id, '_feed_cache', true); |
|
248 | + $time = is_numeric($cache) && $cache >= 0 ? absint($cache) : $this->cache; |
|
249 | 249 | } |
250 | - $this->cache = absint( $time ); |
|
250 | + $this->cache = absint($time); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Admin; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -25,19 +25,19 @@ discard block |
||
25 | 25 | public function __construct() { |
26 | 26 | |
27 | 27 | // Set an option if the user rated the plugin. |
28 | - add_action( 'wp_ajax_simcal_rated', array( $this, 'rate_plugin' ) ); |
|
28 | + add_action('wp_ajax_simcal_rated', array($this, 'rate_plugin')); |
|
29 | 29 | |
30 | 30 | // Set an option if the user rated the plugin. |
31 | - add_action( 'wp_ajax_simcal_clear_cache', array( $this, 'clear_cache' ) ); |
|
31 | + add_action('wp_ajax_simcal_clear_cache', array($this, 'clear_cache')); |
|
32 | 32 | |
33 | 33 | // Convert a datetime format. |
34 | - add_action( 'wp_ajax_simcal_date_i18n_input_preview', array( $this, 'date_i18n' ) ); |
|
34 | + add_action('wp_ajax_simcal_date_i18n_input_preview', array($this, 'date_i18n')); |
|
35 | 35 | |
36 | 36 | // Manage an add-on license activation or deactivation. |
37 | - add_action( 'wp_ajax_simcal_manage_add_on_license', array( $this, 'manage_add_on_license' ) ); |
|
37 | + add_action('wp_ajax_simcal_manage_add_on_license', array($this, 'manage_add_on_license')); |
|
38 | 38 | |
39 | 39 | // Reset add-ons licenses. |
40 | - add_action( 'wp_ajax_simcal_reset_add_ons_licenses', array( $this, 'reset_licenses' ) ); |
|
40 | + add_action('wp_ajax_simcal_reset_add_ons_licenses', array($this, 'reset_licenses')); |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function clear_cache() { |
50 | 50 | |
51 | - $id = isset( $_POST['id'] ) ? ( is_array( $_POST['id'] ) ? array_map( 'intval', $_POST['id'] ) : intval( $_POST['id'] ) ) : ''; |
|
51 | + $id = isset($_POST['id']) ? (is_array($_POST['id']) ? array_map('intval', $_POST['id']) : intval($_POST['id'])) : ''; |
|
52 | 52 | |
53 | - if ( ! empty( $id ) ) { |
|
54 | - simcal_delete_feed_transients( $id ); |
|
53 | + if ( ! empty($id)) { |
|
54 | + simcal_delete_feed_transients($id); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @since 3.0.0 |
62 | 62 | */ |
63 | 63 | public function rate_plugin() { |
64 | - update_option( 'simple-calendar_admin_footer_text_rated', date( 'Y-m-d', time() ) ); |
|
64 | + update_option('simple-calendar_admin_footer_text_rated', date('Y-m-d', time())); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function date_i18n() { |
73 | 73 | |
74 | - $value = isset( $_POST['value'] ) ? esc_attr( $_POST['value'] ) : ' '; |
|
75 | - $timestamp = isset( $_POST['timestamp'] ) ? absint( $_POST['timestamp'] ) : time(); |
|
74 | + $value = isset($_POST['value']) ? esc_attr($_POST['value']) : ' '; |
|
75 | + $timestamp = isset($_POST['timestamp']) ? absint($_POST['timestamp']) : time(); |
|
76 | 76 | |
77 | - wp_send_json_success( date_i18n( $value, $timestamp ) ); |
|
77 | + wp_send_json_success(date_i18n($value, $timestamp)); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -86,35 +86,35 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function manage_add_on_license() { |
88 | 88 | |
89 | - $addon = isset( $_POST['add_on'] ) ? sanitize_key( $_POST['add_on'] ) : false; |
|
90 | - $action = isset( $_POST['license_action'] ) ? esc_attr( $_POST['license_action'] ) : false; |
|
91 | - $key = isset( $_POST['license_key'] ) ? esc_attr( $_POST['license_key'] ) : ''; |
|
92 | - $nonce = isset( $_POST['nonce'] ) ? esc_attr( $_POST['nonce'] ) : ''; |
|
89 | + $addon = isset($_POST['add_on']) ? sanitize_key($_POST['add_on']) : false; |
|
90 | + $action = isset($_POST['license_action']) ? esc_attr($_POST['license_action']) : false; |
|
91 | + $key = isset($_POST['license_key']) ? esc_attr($_POST['license_key']) : ''; |
|
92 | + $nonce = isset($_POST['nonce']) ? esc_attr($_POST['nonce']) : ''; |
|
93 | 93 | |
94 | 94 | // Verify that there are valid variables to process. |
95 | - if ( false === $addon || ! in_array( $action, array( 'activate_license', 'deactivate_license' ) ) ) { |
|
96 | - wp_send_json_error( __( 'Add-on unspecified or invalid action.', 'google-calendar-events' ) ); |
|
95 | + if (false === $addon || ! in_array($action, array('activate_license', 'deactivate_license'))) { |
|
96 | + wp_send_json_error(__('Add-on unspecified or invalid action.', 'google-calendar-events')); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Verify this request comes from the add-ons licenses activation settings page. |
100 | - if ( ! wp_verify_nonce( $nonce, 'simcal_license_manager' ) ) { |
|
101 | - wp_send_json_error( sprintf( __( 'An error occurred: %s', 'google-calendar-events' ), 'Nonce verification failed.' ) ); |
|
100 | + if ( ! wp_verify_nonce($nonce, 'simcal_license_manager')) { |
|
101 | + wp_send_json_error(sprintf(__('An error occurred: %s', 'google-calendar-events'), 'Nonce verification failed.')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | // Removes the prefix and converts simcal_{id_no} to {id_no}. |
105 | - $id = intval( substr( $addon, 7 ) ); |
|
105 | + $id = intval(substr($addon, 7)); |
|
106 | 106 | |
107 | 107 | // Data to send in API request. |
108 | 108 | $api_request = array( |
109 | 109 | 'edd_action' => $action, |
110 | 110 | 'license' => $key, |
111 | - 'item_id' => urlencode( $id ), |
|
111 | + 'item_id' => urlencode($id), |
|
112 | 112 | 'url' => home_url() |
113 | 113 | ); |
114 | 114 | |
115 | 115 | // Call the custom API. |
116 | 116 | $response = wp_remote_post( |
117 | - defined( 'SIMPLE_CALENDAR_STORE_URL' ) ? SIMPLE_CALENDAR_STORE_URL : simcal_get_url( 'home' ), |
|
117 | + defined('SIMPLE_CALENDAR_STORE_URL') ? SIMPLE_CALENDAR_STORE_URL : simcal_get_url('home'), |
|
118 | 118 | array( |
119 | 119 | 'timeout' => 15, |
120 | 120 | 'sslverify' => false, |
@@ -123,29 +123,29 @@ discard block |
||
123 | 123 | ); |
124 | 124 | |
125 | 125 | // Update license in db. |
126 | - $keys = get_option( 'simple-calendar_settings_licenses', array() ); |
|
127 | - $new_keys = array_merge( (array) $keys, array( 'keys' => array( $addon => $key ) ) ); |
|
128 | - update_option( 'simple-calendar_settings_licenses', $new_keys ); |
|
126 | + $keys = get_option('simple-calendar_settings_licenses', array()); |
|
127 | + $new_keys = array_merge((array) $keys, array('keys' => array($addon => $key))); |
|
128 | + update_option('simple-calendar_settings_licenses', $new_keys); |
|
129 | 129 | |
130 | 130 | // Make sure there is a response. |
131 | - if ( is_wp_error( $response ) ) { |
|
132 | - wp_send_json_error( sprintf( __( 'There was an error processing your request: %s', 'google-calendar-events' ), $response->get_error_message() ) ); |
|
131 | + if (is_wp_error($response)) { |
|
132 | + wp_send_json_error(sprintf(__('There was an error processing your request: %s', 'google-calendar-events'), $response->get_error_message())); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | // Decode the license data and save. |
136 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
136 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
137 | 137 | $status = simcal_get_license_status(); |
138 | - if ( 'deactivated' == $license_data->license ) { |
|
139 | - unset( $status[ $addon ] ); |
|
140 | - update_option( 'simple-calendar_licenses_status', $status ); |
|
141 | - wp_send_json_success( $license_data->license ); |
|
142 | - } elseif ( in_array( $license_data->license, array( 'valid', 'invalid' ) ) ) { |
|
143 | - $status[ $addon ] = $license_data->license; |
|
144 | - update_option( 'simple-calendar_licenses_status', $status ); |
|
145 | - $message = 'valid' == $license_data->license ? 'valid' : __( 'License key is invalid.', 'google-calendar-events' ); |
|
146 | - wp_send_json_success( $message ); |
|
138 | + if ('deactivated' == $license_data->license) { |
|
139 | + unset($status[$addon]); |
|
140 | + update_option('simple-calendar_licenses_status', $status); |
|
141 | + wp_send_json_success($license_data->license); |
|
142 | + } elseif (in_array($license_data->license, array('valid', 'invalid'))) { |
|
143 | + $status[$addon] = $license_data->license; |
|
144 | + update_option('simple-calendar_licenses_status', $status); |
|
145 | + $message = 'valid' == $license_data->license ? 'valid' : __('License key is invalid.', 'google-calendar-events'); |
|
146 | + wp_send_json_success($message); |
|
147 | 147 | } else { |
148 | - wp_send_json_error( '' ); |
|
148 | + wp_send_json_error(''); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function reset_licenses() { |
158 | 158 | |
159 | - $nonce = isset( $_POST['nonce'] ) ? esc_attr( $_POST['nonce'] ) : ''; |
|
159 | + $nonce = isset($_POST['nonce']) ? esc_attr($_POST['nonce']) : ''; |
|
160 | 160 | |
161 | 161 | // Verify this request comes from the add-ons licenses activation settings page. |
162 | - if ( empty ( $nonce ) || ! wp_verify_nonce( $nonce, 'simcal_license_manager' ) ) { |
|
163 | - wp_send_json_error( sprintf( __( 'An error occurred: %s', 'google-calendar-events' ), 'Nonce verification failed.' ) ); |
|
162 | + if (empty ($nonce) || ! wp_verify_nonce($nonce, 'simcal_license_manager')) { |
|
163 | + wp_send_json_error(sprintf(__('An error occurred: %s', 'google-calendar-events'), 'Nonce verification failed.')); |
|
164 | 164 | } |
165 | 165 | |
166 | - delete_option( 'simple-calendar_settings_licenses' ); |
|
167 | - delete_option( 'simple-calendar_licenses_status' ); |
|
166 | + delete_option('simple-calendar_settings_licenses'); |
|
167 | + delete_option('simple-calendar_licenses_status'); |
|
168 | 168 | |
169 | - wp_send_json_success( 'success' ); |
|
169 | + wp_send_json_success('success'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @param string $version (optional) Current plugin version, defaults to value in plugin constant. |
65 | 65 | */ |
66 | - public function __construct( $version = SIMPLE_CALENDAR_VERSION ) { |
|
66 | + public function __construct($version = SIMPLE_CALENDAR_VERSION) { |
|
67 | 67 | // Look for previous version in current or legacy option, null for fresh install. |
68 | - $installed = get_option( 'simple-calendar_version', null ); |
|
69 | - $this->installed_ver = is_null( $installed ) ? get_option( 'gce_version', null ) : $installed; |
|
68 | + $installed = get_option('simple-calendar_version', null); |
|
69 | + $this->installed_ver = is_null($installed) ? get_option('gce_version', null) : $installed; |
|
70 | 70 | $this->new_ver = $version; |
71 | 71 | |
72 | - if ( version_compare( $this->installed_ver, $this->new_ver, '<' ) ) { |
|
72 | + if (version_compare($this->installed_ver, $this->new_ver, '<')) { |
|
73 | 73 | $this->run_updates(); |
74 | 74 | } |
75 | 75 | } |
@@ -83,18 +83,18 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function run_updates() { |
85 | 85 | |
86 | - do_action( 'simcal_before_update', $this->installed_ver ); |
|
86 | + do_action('simcal_before_update', $this->installed_ver); |
|
87 | 87 | |
88 | - if ( ! is_null( $this->installed_ver ) ) { |
|
88 | + if ( ! is_null($this->installed_ver)) { |
|
89 | 89 | |
90 | - if ( version_compare( $this->installed_ver, $this->new_ver ) === -1 ) { |
|
90 | + if (version_compare($this->installed_ver, $this->new_ver) === -1) { |
|
91 | 91 | |
92 | - $post_type = version_compare( $this->installed_ver, '3.0.0' ) === -1 ? 'gce_feed' : 'calendar'; |
|
93 | - $this->posts = $this->get_posts( $post_type ); |
|
92 | + $post_type = version_compare($this->installed_ver, '3.0.0') === -1 ? 'gce_feed' : 'calendar'; |
|
93 | + $this->posts = $this->get_posts($post_type); |
|
94 | 94 | |
95 | - foreach ( $this->update_path as $update_to ) { |
|
96 | - if ( version_compare( $this->installed_ver, $update_to, '<' ) ) { |
|
97 | - $this->update( $update_to ); |
|
95 | + foreach ($this->update_path as $update_to) { |
|
96 | + if (version_compare($this->installed_ver, $update_to, '<')) { |
|
97 | + $this->update($update_to); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -109,28 +109,28 @@ discard block |
||
109 | 109 | |
110 | 110 | } |
111 | 111 | |
112 | - do_action( 'simcal_updated', $this->new_ver ); |
|
112 | + do_action('simcal_updated', $this->new_ver); |
|
113 | 113 | |
114 | 114 | // Redirect to a welcome page if new install or major update. |
115 | - if ( is_null( $this->installed_ver ) ) { |
|
116 | - set_transient( '_simple-calendar_activation_redirect', 'fresh', 60 ); |
|
115 | + if (is_null($this->installed_ver)) { |
|
116 | + set_transient('_simple-calendar_activation_redirect', 'fresh', 60); |
|
117 | 117 | } else { |
118 | - $major_new = substr( $this->new_ver, 0, strrpos( $this->new_ver, '.' ) ); |
|
119 | - $major_old = substr( $this->installed_ver, 0, strrpos( $this->installed_ver, '.' ) ); |
|
120 | - if ( version_compare( $major_new, $major_old, '>' ) ) { |
|
121 | - set_transient( '_simple-calendar_activation_redirect', 'update', 60 ); |
|
122 | - } elseif ( $major_old == $major_new ) { |
|
123 | - $version = explode( '.', $this->new_ver ); |
|
124 | - end( $version ); |
|
125 | - if ( 0 === intval( current( $version ) ) ) { |
|
126 | - set_transient( '_simple-calendar_activation_redirect', 'update', 60 ); |
|
118 | + $major_new = substr($this->new_ver, 0, strrpos($this->new_ver, '.')); |
|
119 | + $major_old = substr($this->installed_ver, 0, strrpos($this->installed_ver, '.')); |
|
120 | + if (version_compare($major_new, $major_old, '>')) { |
|
121 | + set_transient('_simple-calendar_activation_redirect', 'update', 60); |
|
122 | + } elseif ($major_old == $major_new) { |
|
123 | + $version = explode('.', $this->new_ver); |
|
124 | + end($version); |
|
125 | + if (0 === intval(current($version))) { |
|
126 | + set_transient('_simple-calendar_activation_redirect', 'update', 60); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | 131 | $this->admin_redirects(); |
132 | 132 | |
133 | - update_option( 'simple-calendar_version', $this->new_ver ); |
|
133 | + update_option('simple-calendar_version', $this->new_ver); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -142,25 +142,25 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function admin_redirects() { |
144 | 144 | |
145 | - $transient = get_transient( '_simple-calendar_activation_redirect' ); |
|
145 | + $transient = get_transient('_simple-calendar_activation_redirect'); |
|
146 | 146 | |
147 | - if ( ! $transient || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { |
|
147 | + if ( ! $transient || is_network_admin() || isset($_GET['activate-multi']) || ! current_user_can('manage_options')) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | - delete_transient( '_simple-calendar_activation_redirect' ); |
|
151 | + delete_transient('_simple-calendar_activation_redirect'); |
|
152 | 152 | |
153 | 153 | // Do not redirect if already on welcome page screen. |
154 | - if ( ! empty( $_GET['page'] ) && in_array( $_GET['page'], array( 'simple-calendar_about' ) ) ) { |
|
154 | + if ( ! empty($_GET['page']) && in_array($_GET['page'], array('simple-calendar_about'))) { |
|
155 | 155 | return; |
156 | 156 | } |
157 | 157 | |
158 | 158 | $url = add_query_arg( |
159 | 159 | 'simcal_install', |
160 | - esc_attr( $transient ), |
|
161 | - admin_url( 'index.php?page=simple-calendar_about' ) |
|
160 | + esc_attr($transient), |
|
161 | + admin_url('index.php?page=simple-calendar_about') |
|
162 | 162 | ); |
163 | - wp_safe_redirect( $url ); |
|
163 | + wp_safe_redirect($url); |
|
164 | 164 | exit; |
165 | 165 | } |
166 | 166 | |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return array |
175 | 175 | */ |
176 | - private function get_posts( $post_type ) { |
|
176 | + private function get_posts($post_type) { |
|
177 | 177 | |
178 | 178 | $posts = array(); |
179 | 179 | |
180 | - if ( ! empty( $post_type ) ) { |
|
180 | + if ( ! empty($post_type)) { |
|
181 | 181 | |
182 | 182 | // https://core.trac.wordpress.org/ticket/18408 |
183 | - $posts = get_posts( array( |
|
183 | + $posts = get_posts(array( |
|
184 | 184 | 'post_type' => $post_type, |
185 | 185 | 'post_status' => array( |
186 | 186 | 'draft', |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'trash', |
192 | 192 | ), |
193 | 193 | 'nopaging' => true, |
194 | - ) ); |
|
194 | + )); |
|
195 | 195 | |
196 | 196 | wp_reset_postdata(); |
197 | 197 | } |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @param string $version |
210 | 210 | */ |
211 | - private function update( $version ) { |
|
211 | + private function update($version) { |
|
212 | 212 | |
213 | - $update_v = '\\' . __NAMESPACE__ . '\Updates\\Update_V' . str_replace( '.', '', $version ); |
|
213 | + $update_v = '\\'.__NAMESPACE__.'\Updates\\Update_V'.str_replace('.', '', $version); |
|
214 | 214 | |
215 | - if ( class_exists( $update_v ) ) { |
|
216 | - new $update_v( $this->posts ); |
|
215 | + if (class_exists($update_v)) { |
|
216 | + new $update_v($this->posts); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 |
@@ -6,9 +6,6 @@ |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar\Updates; |
8 | 8 | |
9 | -use Carbon\Carbon; |
|
10 | -use SimpleCalendar\Post_Types; |
|
11 | - |
|
12 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
13 | 10 | exit; |
14 | 11 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Carbon\Carbon; |
10 | 10 | use SimpleCalendar\Post_Types; |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param array $posts |
25 | 25 | */ |
26 | - public function __construct( $posts ) { |
|
26 | + public function __construct($posts) { |
|
27 | 27 | |
28 | 28 | $this->update_options(); |
29 | 29 | } |
@@ -34,22 +34,22 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function update_options() { |
36 | 36 | |
37 | - $settings_advanced = get_option( 'simple-calendar_settings_advanced' ); |
|
37 | + $settings_advanced = get_option('simple-calendar_settings_advanced'); |
|
38 | 38 | |
39 | 39 | // Remove stored always_enqueue value |
40 | - if ( isset( $settings_advanced['assets']['always_enqueue'] ) ) { |
|
41 | - unset( $settings_advanced['assets']['always_enqueue'] ); |
|
40 | + if (isset($settings_advanced['assets']['always_enqueue'])) { |
|
41 | + unset($settings_advanced['assets']['always_enqueue']); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // Remove stored disable_js value |
45 | - if ( isset( $settings_advanced['assets']['disable_js'] ) ) { |
|
46 | - unset( $settings_advanced['assets']['disable_js'] ); |
|
45 | + if (isset($settings_advanced['assets']['disable_js'])) { |
|
46 | + unset($settings_advanced['assets']['disable_js']); |
|
47 | 47 | } |
48 | 48 | |
49 | - update_option( 'simple-calendar_settings_advanced', $settings_advanced ); |
|
49 | + update_option('simple-calendar_settings_advanced', $settings_advanced); |
|
50 | 50 | |
51 | 51 | // Delete legacy options. |
52 | - delete_option( 'simple-calendar_defaults' ); |
|
52 | + delete_option('simple-calendar_defaults'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | } |
@@ -14,31 +14,31 @@ discard block |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | // Exit if accessed directly. |
17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
17 | +if ( ! defined('ABSPATH')) { |
|
18 | 18 | exit; |
19 | 19 | } |
20 | 20 | |
21 | 21 | // Composer fallback for PHP < 5.3.0. |
22 | -if ( version_compare( PHP_VERSION, '5.3.0' ) === -1 ) { |
|
22 | +if (version_compare(PHP_VERSION, '5.3.0') === -1) { |
|
23 | 23 | include_once 'vendor/autoload_52.php'; |
24 | 24 | } else { |
25 | 25 | include_once 'vendor/autoload.php'; |
26 | 26 | } |
27 | 27 | |
28 | 28 | // Plugin constants. |
29 | -$this_plugin_path = trailingslashit( dirname( __FILE__ ) ); |
|
30 | -$this_plugin_dir = plugin_dir_url( __FILE__ ); |
|
29 | +$this_plugin_path = trailingslashit(dirname(__FILE__)); |
|
30 | +$this_plugin_dir = plugin_dir_url(__FILE__); |
|
31 | 31 | $this_plugin_constants = array( |
32 | 32 | 'SIMPLE_CALENDAR_VERSION' => '3.0.13', |
33 | 33 | 'SIMPLE_CALENDAR_MAIN_FILE' => __FILE__, |
34 | 34 | 'SIMPLE_CALENDAR_URL' => $this_plugin_dir, |
35 | - 'SIMPLE_CALENDAR_ASSETS' => $this_plugin_dir . 'assets/', |
|
35 | + 'SIMPLE_CALENDAR_ASSETS' => $this_plugin_dir.'assets/', |
|
36 | 36 | 'SIMPLE_CALENDAR_PATH' => $this_plugin_path, |
37 | - 'SIMPLE_CALENDAR_INC' => $this_plugin_path . 'includes/', |
|
37 | + 'SIMPLE_CALENDAR_INC' => $this_plugin_path.'includes/', |
|
38 | 38 | ); |
39 | -foreach ( $this_plugin_constants as $constant => $value ) { |
|
40 | - if ( ! defined( $constant ) ) { |
|
41 | - define( $constant, $value ); |
|
39 | +foreach ($this_plugin_constants as $constant => $value) { |
|
40 | + if ( ! defined($constant)) { |
|
41 | + define($constant, $value); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | include_once 'includes/wp-requirements.php'; |
48 | 48 | |
49 | 49 | // Check plugin requirements before loading plugin. |
50 | -$this_plugin_checks = new SimCal_WP_Requirements( 'Simple Calendar', plugin_basename( __FILE__ ), array( |
|
50 | +$this_plugin_checks = new SimCal_WP_Requirements('Simple Calendar', plugin_basename(__FILE__), array( |
|
51 | 51 | 'PHP' => '5.3.3', |
52 | 52 | 'WordPress' => '4.0.0', |
53 | 53 | 'Extensions' => array( |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | 'json', |
57 | 57 | 'mbstring', |
58 | 58 | ), |
59 | - ) ); |
|
60 | -if ( $this_plugin_checks->pass() === false ) { |
|
59 | + )); |
|
60 | +if ($this_plugin_checks->pass() === false) { |
|
61 | 61 | $this_plugin_checks->halt(); |
62 | 62 | |
63 | 63 | return; |