@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | use SimpleCalendar\Abstracts\Calendar_View; |
| 10 | 10 | use SimpleCalendar\Abstracts\Widget; |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -46,18 +46,18 @@ discard block |
||
| 46 | 46 | public function __construct() { |
| 47 | 47 | |
| 48 | 48 | $id_base = 'gce_widget'; // old id kept for legacy reasons |
| 49 | - $name = __( 'Simple Calendar', 'google-calendar-events' ); |
|
| 49 | + $name = __('Simple Calendar', 'google-calendar-events'); |
|
| 50 | 50 | $widget_options = array( |
| 51 | - 'description' => __( 'Display a calendar of events from one of your calendar feeds.', 'google-calendar-events' ) |
|
| 51 | + 'description' => __('Display a calendar of events from one of your calendar feeds.', 'google-calendar-events') |
|
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | - parent::__construct( $id_base, $name, $widget_options ); |
|
| 54 | + parent::__construct($id_base, $name, $widget_options); |
|
| 55 | 55 | |
| 56 | - if ( is_admin() ) { |
|
| 57 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
| 56 | + if (is_admin()) { |
|
| 57 | + if ( ! defined('DOING_AJAX')) { |
|
| 58 | 58 | $this->calendars = simcal_get_calendars(); |
| 59 | 59 | } else { |
| 60 | - $this->calendars = get_transient( '_simple-calendar_feed_ids' ); |
|
| 60 | + $this->calendars = get_transient('_simple-calendar_feed_ids'); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -70,18 +70,18 @@ discard block |
||
| 70 | 70 | * @param array $args Display arguments. |
| 71 | 71 | * @param array $instance The settings for the particular instance of the widget. |
| 72 | 72 | */ |
| 73 | - public function widget( $args, $instance ) { |
|
| 73 | + public function widget($args, $instance) { |
|
| 74 | 74 | |
| 75 | 75 | echo $args['before_widget']; |
| 76 | 76 | |
| 77 | - if ( ! empty( $instance['title'] ) ) { |
|
| 77 | + if ( ! empty($instance['title'])) { |
|
| 78 | 78 | |
| 79 | - echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title']; |
|
| 79 | + echo $args['before_title'].apply_filters('widget_title', $instance['title']).$args['after_title']; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $id = isset( $instance['calendar_id'] ) ? absint( $instance['calendar_id'] ) : 0; |
|
| 83 | - if ( $id > 0 ) { |
|
| 84 | - simcal_print_calendar( $id ); |
|
| 82 | + $id = isset($instance['calendar_id']) ? absint($instance['calendar_id']) : 0; |
|
| 83 | + if ($id > 0) { |
|
| 84 | + simcal_print_calendar($id); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | echo $args['after_widget']; |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return array Settings to save or bool false to cancel saving. |
| 103 | 103 | */ |
| 104 | - public function update( $new_instance, $old_instance ) { |
|
| 104 | + public function update($new_instance, $old_instance) { |
|
| 105 | 105 | |
| 106 | 106 | $instance = array(); |
| 107 | 107 | |
| 108 | - $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : ''; |
|
| 109 | - $instance['calendar_id'] = ( ! empty( $new_instance['calendar_id'] ) ) ? absint( $new_instance['calendar_id'] ) : ''; |
|
| 108 | + $instance['title'] = ( ! empty($new_instance['title'])) ? sanitize_text_field($new_instance['title']) : ''; |
|
| 109 | + $instance['calendar_id'] = ( ! empty($new_instance['calendar_id'])) ? absint($new_instance['calendar_id']) : ''; |
|
| 110 | 110 | |
| 111 | 111 | return $instance; |
| 112 | 112 | } |
@@ -120,34 +120,34 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return string |
| 122 | 122 | */ |
| 123 | - public function form( $instance ) { |
|
| 123 | + public function form($instance) { |
|
| 124 | 124 | |
| 125 | - $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : __( 'Calendar', 'google-calendar-events' ); |
|
| 126 | - $calendar_id = isset( $instance['calendar_id'] ) ? esc_attr( $instance['calendar_id'] ) : ''; |
|
| 125 | + $title = isset($instance['title']) ? esc_attr($instance['title']) : __('Calendar', 'google-calendar-events'); |
|
| 126 | + $calendar_id = isset($instance['calendar_id']) ? esc_attr($instance['calendar_id']) : ''; |
|
| 127 | 127 | |
| 128 | 128 | ?> |
| 129 | 129 | <div class="simcal-calendar-widget-settings"> |
| 130 | 130 | |
| 131 | 131 | <p> |
| 132 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'google-calendar-events' ); ?></label> |
|
| 132 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'google-calendar-events'); ?></label> |
|
| 133 | 133 | <br> |
| 134 | 134 | <input type="text" |
| 135 | - name="<?php echo $this->get_field_name( 'title' ); ?>" |
|
| 136 | - id="<?php echo $this->get_field_id( 'title' ); ?>" |
|
| 135 | + name="<?php echo $this->get_field_name('title'); ?>" |
|
| 136 | + id="<?php echo $this->get_field_id('title'); ?>" |
|
| 137 | 137 | class="widefat simcal-field simcal-field-standard simcal-field-text" |
| 138 | 138 | value="<?php echo $title; ?>"> |
| 139 | 139 | </p> |
| 140 | 140 | |
| 141 | 141 | <p> |
| 142 | - <label for="<?php echo $this->get_field_id( 'calendar_id' ); ?>"><?php _e( 'Calendar:', 'google-calendar-events' ); ?></label> |
|
| 142 | + <label for="<?php echo $this->get_field_id('calendar_id'); ?>"><?php _e('Calendar:', 'google-calendar-events'); ?></label> |
|
| 143 | 143 | <br> |
| 144 | - <?php $multiselect = count( $this->calendars ) > 15 ? ' simcal-field-select-enhanced' : ''; ?> |
|
| 145 | - <select name="<?php echo $this->get_field_name( 'calendar_id' ) ?>" |
|
| 146 | - id="<?php echo $this->get_field_id( 'calendar_id' ) ?>" |
|
| 144 | + <?php $multiselect = count($this->calendars) > 15 ? ' simcal-field-select-enhanced' : ''; ?> |
|
| 145 | + <select name="<?php echo $this->get_field_name('calendar_id') ?>" |
|
| 146 | + id="<?php echo $this->get_field_id('calendar_id') ?>" |
|
| 147 | 147 | class="simcal-field simcal-field-select<?php echo $multiselect; ?>" |
| 148 | - data-noresults="<?php __( 'No calendars found.', 'google-calendar-events' ); ?>"> |
|
| 149 | - <?php foreach ( $this->calendars as $id => $name ) : ?> |
|
| 150 | - <option value="<?php echo $id; ?>" <?php selected( $id, $calendar_id, true ); ?>><?php echo $name; ?></option> |
|
| 148 | + data-noresults="<?php __('No calendars found.', 'google-calendar-events'); ?>"> |
|
| 149 | + <?php foreach ($this->calendars as $id => $name) : ?> |
|
| 150 | + <option value="<?php echo $id; ?>" <?php selected($id, $calendar_id, true); ?>><?php echo $name; ?></option> |
|
| 151 | 151 | <?php endforeach; ?> |
| 152 | 152 | </select> |
| 153 | 153 | </p> |
@@ -6,20 +6,20 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | // Exit if not uninstalling from WordPress. |
| 9 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 9 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | // Get user options whether to delete settings and/or data. |
| 14 | -$settings = get_option( 'simple-calendar_settings_advanced' ); |
|
| 14 | +$settings = get_option('simple-calendar_settings_advanced'); |
|
| 15 | 15 | |
| 16 | -if ( isset( $settings['installation']['delete_settings'] ) ) { |
|
| 16 | +if (isset($settings['installation']['delete_settings'])) { |
|
| 17 | 17 | $delete_settings = 'yes' == $settings['installation']['delete_settings'] ? true : false; |
| 18 | 18 | } else { |
| 19 | 19 | $delete_settings = false; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -if ( isset( $settings['installation']['erase_data'] ) ) { |
|
| 22 | +if (isset($settings['installation']['erase_data'])) { |
|
| 23 | 23 | $erase_data = 'yes' == $settings['installation']['erase_data'] ? true : false; |
| 24 | 24 | } else { |
| 25 | 25 | $erase_data = false; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | global $wpdb; |
| 29 | 29 | |
| 30 | 30 | // Delete settings. |
| 31 | -if ( ( $delete_settings === true ) || ( $erase_data === true ) ) { |
|
| 31 | +if (($delete_settings === true) || ($erase_data === true)) { |
|
| 32 | 32 | $wpdb->query( |
| 33 | 33 | " |
| 34 | 34 | DELETE FROM $wpdb->options WHERE option_name LIKE '%simple-calendar%'; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Delete calendar data. |
| 40 | -if ( $erase_data === true ) { |
|
| 40 | +if ($erase_data === true) { |
|
| 41 | 41 | |
| 42 | 42 | // Delete calendar posts. |
| 43 | 43 | $wpdb->query( |
@@ -47,20 +47,20 @@ discard block |
||
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | 49 | // Delete calendar postmeta. |
| 50 | - $wpdb->query( " |
|
| 50 | + $wpdb->query(" |
|
| 51 | 51 | DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL; |
| 52 | 52 | " |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | 55 | // Delete calendar terms. |
| 56 | - $terms = get_terms( array( |
|
| 56 | + $terms = get_terms(array( |
|
| 57 | 57 | 'calendar_category', |
| 58 | 58 | 'calendar_feed', |
| 59 | 59 | 'calendar_type', |
| 60 | - ) ); |
|
| 61 | - if ( ! empty( $terms ) && is_array( $terms ) ) { |
|
| 62 | - foreach ( $terms as $term ) { |
|
| 63 | - wp_delete_term( $term->term_id, $term->taxonomy ); |
|
| 60 | + )); |
|
| 61 | + if ( ! empty($terms) && is_array($terms)) { |
|
| 62 | + foreach ($terms as $term) { |
|
| 63 | + wp_delete_term($term->term_id, $term->taxonomy); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -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 | |
@@ -234,30 +234,30 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @param array $event |
| 236 | 236 | */ |
| 237 | - public function __construct( array $event ) { |
|
| 237 | + public function __construct(array $event) { |
|
| 238 | 238 | |
| 239 | 239 | /* ================= * |
| 240 | 240 | * Event Identifiers * |
| 241 | 241 | * ================= */ |
| 242 | 242 | |
| 243 | 243 | // Event unique id. |
| 244 | - if ( ! empty( $event['uid'] ) ) { |
|
| 245 | - $this->uid = esc_attr( $event['uid'] ); |
|
| 244 | + if ( ! empty($event['uid'])) { |
|
| 245 | + $this->uid = esc_attr($event['uid']); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | // Event source. |
| 249 | - if ( ! empty( $event['source'] ) ) { |
|
| 250 | - $this->source = esc_attr( $event['source'] ); |
|
| 249 | + if ( ! empty($event['source'])) { |
|
| 250 | + $this->source = esc_attr($event['source']); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | // Event parent calendar id. |
| 254 | - if ( ! empty( $event['calendar'] ) ) { |
|
| 255 | - $this->calendar = max( intval( $event['calendar'] ), 0 ); |
|
| 254 | + if ( ! empty($event['calendar'])) { |
|
| 255 | + $this->calendar = max(intval($event['calendar']), 0); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | // Event parent calendar timezone. |
| 259 | - if ( ! empty( $event['timezone'] ) ) { |
|
| 260 | - $this->timezone = esc_attr( $event['timezone'] ); |
|
| 259 | + if ( ! empty($event['timezone'])) { |
|
| 260 | + $this->timezone = esc_attr($event['timezone']); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /* ============= * |
@@ -265,23 +265,23 @@ discard block |
||
| 265 | 265 | * ============= */ |
| 266 | 266 | |
| 267 | 267 | // Event title. |
| 268 | - if ( ! empty( $event['title'] ) ) { |
|
| 269 | - $this->title = esc_html( $event['title'] ); |
|
| 268 | + if ( ! empty($event['title'])) { |
|
| 269 | + $this->title = esc_html($event['title']); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // Event description. |
| 273 | - if ( ! empty( $event['description'] ) ) { |
|
| 274 | - $this->description = wp_kses_post( $event['description'] ); |
|
| 273 | + if ( ! empty($event['description'])) { |
|
| 274 | + $this->description = wp_kses_post($event['description']); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // Event link URL. |
| 278 | - if ( ! empty( $event['link'] ) ) { |
|
| 279 | - $this->link = esc_url_raw( $event['link'] ); |
|
| 278 | + if ( ! empty($event['link'])) { |
|
| 279 | + $this->link = esc_url_raw($event['link']); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // Event visibility. |
| 283 | - if ( ! empty( $event['visibility'] ) ) { |
|
| 284 | - $this->visibility = esc_attr( $event['visibility'] ); |
|
| 283 | + if ( ! empty($event['visibility'])) { |
|
| 284 | + $this->visibility = esc_attr($event['visibility']); |
|
| 285 | 285 | $this->public = $this->visibility == 'public' ? true : false; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -289,34 +289,34 @@ discard block |
||
| 289 | 289 | * Event Start * |
| 290 | 290 | * =========== */ |
| 291 | 291 | |
| 292 | - if ( ! empty( $event['start'] ) ) { |
|
| 293 | - $this->start = is_numeric( $event['start'] ) ? intval( $event['start'] ) : 0; |
|
| 294 | - if ( ! empty( $event['start_utc'] ) ) { |
|
| 295 | - $this->start_utc = is_numeric( $event['start_utc'] ) ? intval( $event['start_utc'] ) : 0; |
|
| 292 | + if ( ! empty($event['start'])) { |
|
| 293 | + $this->start = is_numeric($event['start']) ? intval($event['start']) : 0; |
|
| 294 | + if ( ! empty($event['start_utc'])) { |
|
| 295 | + $this->start_utc = is_numeric($event['start_utc']) ? intval($event['start_utc']) : 0; |
|
| 296 | 296 | } |
| 297 | - if ( ! empty( $event['start_timezone'] ) ) { |
|
| 298 | - $this->start_timezone = esc_attr( $event['start_timezone'] ); |
|
| 297 | + if ( ! empty($event['start_timezone'])) { |
|
| 298 | + $this->start_timezone = esc_attr($event['start_timezone']); |
|
| 299 | 299 | } |
| 300 | - $this->start_dt = Carbon::createFromTimestamp( $this->start, $this->start_timezone ); |
|
| 301 | - $start_location = isset( $event['start_location'] ) ? $event['start_location'] : ''; |
|
| 302 | - $this->start_location = $this->esc_location( $start_location ); |
|
| 300 | + $this->start_dt = Carbon::createFromTimestamp($this->start, $this->start_timezone); |
|
| 301 | + $start_location = isset($event['start_location']) ? $event['start_location'] : ''; |
|
| 302 | + $this->start_location = $this->esc_location($start_location); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /* ========= * |
| 306 | 306 | * Event End * |
| 307 | 307 | * ========= */ |
| 308 | 308 | |
| 309 | - if ( ! empty( $event['end'] ) ) { |
|
| 310 | - $this->end = is_numeric( $event['end'] ) ? intval( $event['end'] ): false; |
|
| 311 | - if ( ! empty( $event['end_timezone'] ) ) { |
|
| 312 | - $this->end_timezone = esc_attr( $event['end_timezone'] ); |
|
| 309 | + if ( ! empty($event['end'])) { |
|
| 310 | + $this->end = is_numeric($event['end']) ? intval($event['end']) : false; |
|
| 311 | + if ( ! empty($event['end_timezone'])) { |
|
| 312 | + $this->end_timezone = esc_attr($event['end_timezone']); |
|
| 313 | 313 | } |
| 314 | - if ( ! empty( $event['end_utc'] ) ) { |
|
| 315 | - $this->end_utc = is_numeric( $event['end_utc'] ) ? intval( $event['end_utc'] ) : false; |
|
| 316 | - $this->end_dt = Carbon::createFromTimestamp( $this->end, $this->end_timezone ); |
|
| 314 | + if ( ! empty($event['end_utc'])) { |
|
| 315 | + $this->end_utc = is_numeric($event['end_utc']) ? intval($event['end_utc']) : false; |
|
| 316 | + $this->end_dt = Carbon::createFromTimestamp($this->end, $this->end_timezone); |
|
| 317 | 317 | } |
| 318 | - $end_location = isset( $event['end_location'] ) ? $event['end_location'] : ''; |
|
| 319 | - $this->end_location = $this->esc_location( $end_location ); |
|
| 318 | + $end_location = isset($event['end_location']) ? $event['end_location'] : ''; |
|
| 319 | + $this->end_location = $this->esc_location($end_location); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /* ================== * |
@@ -324,18 +324,18 @@ discard block |
||
| 324 | 324 | * ================== */ |
| 325 | 325 | |
| 326 | 326 | // Whole day event. |
| 327 | - if ( ! empty( $event['whole_day'] ) ) { |
|
| 328 | - $this->whole_day = true === $event['whole_day'] ? true: false; |
|
| 327 | + if ( ! empty($event['whole_day'])) { |
|
| 328 | + $this->whole_day = true === $event['whole_day'] ? true : false; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // Multi day event. |
| 332 | - if ( ! empty( $event['multiple_days'] ) ) { |
|
| 333 | - $this->multiple_days = max( absint( $event['multiple_days'] ), 1 ); |
|
| 332 | + if ( ! empty($event['multiple_days'])) { |
|
| 333 | + $this->multiple_days = max(absint($event['multiple_days']), 1); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // Event recurrence. |
| 337 | - if ( isset( $event['recurrence'] ) ) { |
|
| 338 | - $this->recurrence = ! empty( $event['recurrence'] ) ? $event['recurrence'] : false; |
|
| 337 | + if (isset($event['recurrence'])) { |
|
| 338 | + $this->recurrence = ! empty($event['recurrence']) ? $event['recurrence'] : false; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /* ========== * |
@@ -343,18 +343,18 @@ discard block |
||
| 343 | 343 | * ========== */ |
| 344 | 344 | |
| 345 | 345 | // Event has venue(s). |
| 346 | - if ( $this->start_location['venue'] || $this->end_location['venue'] ) { |
|
| 346 | + if ($this->start_location['venue'] || $this->end_location['venue']) { |
|
| 347 | 347 | $this->venue = true; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | // Event meta. |
| 351 | - if ( ! empty( $event['meta'] ) ) { |
|
| 352 | - $this->meta = is_array( $event['meta'] ) ? $event['meta'] : array(); |
|
| 351 | + if ( ! empty($event['meta'])) { |
|
| 352 | + $this->meta = is_array($event['meta']) ? $event['meta'] : array(); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | // Event template. |
| 356 | - if ( ! empty( $event['template'] ) ) { |
|
| 357 | - $this->template = wp_kses_post( $event['template'] ); |
|
| 356 | + if ( ! empty($event['template'])) { |
|
| 357 | + $this->template = wp_kses_post($event['template']); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | } |
@@ -369,27 +369,27 @@ discard block |
||
| 369 | 369 | * |
| 370 | 370 | * @return array |
| 371 | 371 | */ |
| 372 | - private function esc_location( $var = '' ) { |
|
| 372 | + private function esc_location($var = '') { |
|
| 373 | 373 | |
| 374 | 374 | $location = array(); |
| 375 | 375 | |
| 376 | - if ( is_string( $var ) ) { |
|
| 376 | + if (is_string($var)) { |
|
| 377 | 377 | $var = array( |
| 378 | 378 | 'name' => $var, |
| 379 | 379 | 'address' => $var, |
| 380 | 380 | ); |
| 381 | - } elseif ( is_bool( $var ) || is_null( $var ) ) { |
|
| 381 | + } elseif (is_bool($var) || is_null($var)) { |
|
| 382 | 382 | $var = array(); |
| 383 | 383 | } else { |
| 384 | 384 | $var = (array) $var; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - $location['name'] = isset( $var['name'] ) ? esc_attr( strip_tags( $var['name'] ) ) : ''; |
|
| 388 | - $location['address'] = isset( $var['address'] ) ? esc_attr( strip_tags( $var['address'] ) ) : ''; |
|
| 389 | - $location['lat'] = isset( $var['lat'] ) ? $this->esc_coordinate( $var['lat'] ) : 0; |
|
| 390 | - $location['lng'] = isset( $var['lng'] ) ? $this->esc_coordinate( $var['lng'] ) : 0; |
|
| 387 | + $location['name'] = isset($var['name']) ? esc_attr(strip_tags($var['name'])) : ''; |
|
| 388 | + $location['address'] = isset($var['address']) ? esc_attr(strip_tags($var['address'])) : ''; |
|
| 389 | + $location['lat'] = isset($var['lat']) ? $this->esc_coordinate($var['lat']) : 0; |
|
| 390 | + $location['lng'] = isset($var['lng']) ? $this->esc_coordinate($var['lng']) : 0; |
|
| 391 | 391 | |
| 392 | - if ( ! empty( $location['name'] ) || ! empty( $location['address'] ) ) { |
|
| 392 | + if ( ! empty($location['name']) || ! empty($location['address'])) { |
|
| 393 | 393 | $location['venue'] = true; |
| 394 | 394 | } else { |
| 395 | 395 | $location['venue'] = false; |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | * |
| 409 | 409 | * @return int|float |
| 410 | 410 | */ |
| 411 | - private function esc_coordinate( $latlng = 0 ) { |
|
| 412 | - return is_numeric( $latlng ) ? floatval( $latlng ) : 0; |
|
| 411 | + private function esc_coordinate($latlng = 0) { |
|
| 412 | + return is_numeric($latlng) ? floatval($latlng) : 0; |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
@@ -422,8 +422,8 @@ discard block |
||
| 422 | 422 | * |
| 423 | 423 | * @return bool |
| 424 | 424 | */ |
| 425 | - public function set_timezone( $tz ) { |
|
| 426 | - if ( in_array( $tz, timezone_identifiers_list() ) ) { |
|
| 425 | + public function set_timezone($tz) { |
|
| 426 | + if (in_array($tz, timezone_identifiers_list())) { |
|
| 427 | 427 | $this->timezone = $tz; |
| 428 | 428 | return true; |
| 429 | 429 | } |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | * @return bool |
| 450 | 450 | */ |
| 451 | 451 | public function starts_today() { |
| 452 | - return $this->start_dt->setTimezone( $this->timezone )->isToday(); |
|
| 452 | + return $this->start_dt->setTimezone($this->timezone)->isToday(); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /** |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | * @return bool |
| 461 | 461 | */ |
| 462 | 462 | public function ends_today() { |
| 463 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isToday() : true; |
|
| 463 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isToday() : true; |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | /** |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | * @return bool |
| 472 | 472 | */ |
| 473 | 473 | public function starts_tomorrow() { |
| 474 | - return $this->start_dt->setTimezone( $this->timezone )->isTomorrow(); |
|
| 474 | + return $this->start_dt->setTimezone($this->timezone)->isTomorrow(); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | /** |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | * @return bool |
| 483 | 483 | */ |
| 484 | 484 | public function ends_tomorrow() { |
| 485 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isTomorrow() : false; |
|
| 485 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isTomorrow() : false; |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | /** |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | * @return bool |
| 494 | 494 | */ |
| 495 | 495 | public function started_yesterday() { |
| 496 | - return $this->start_dt->setTimezone( $this->timezone )->isYesterday(); |
|
| 496 | + return $this->start_dt->setTimezone($this->timezone)->isYesterday(); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | /** |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | * @return bool |
| 505 | 505 | */ |
| 506 | 506 | public function ended_yesterday() { |
| 507 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isYesterday() : false; |
|
| 507 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isYesterday() : false; |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | /** |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | * @return bool |
| 516 | 516 | */ |
| 517 | 517 | public function starts_future() { |
| 518 | - return $this->start_dt->setTimezone( $this->timezone )->isFuture(); |
|
| 518 | + return $this->start_dt->setTimezone($this->timezone)->isFuture(); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | /** |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | * @return bool |
| 527 | 527 | */ |
| 528 | 528 | public function ends_future() { |
| 529 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isFuture() : false; |
|
| 529 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isFuture() : false; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | * @return bool |
| 538 | 538 | */ |
| 539 | 539 | public function started_past() { |
| 540 | - return $this->start_dt->setTimezone( $this->timezone )->isPast(); |
|
| 540 | + return $this->start_dt->setTimezone($this->timezone)->isPast(); |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | /** |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | * @return bool |
| 549 | 549 | */ |
| 550 | 550 | public function ended_past() { |
| 551 | - return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isPast() : false; |
|
| 551 | + return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isPast() : false; |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -560,9 +560,9 @@ discard block |
||
| 560 | 560 | * |
| 561 | 561 | * @return string |
| 562 | 562 | */ |
| 563 | - public function get_color( $default = '' ) { |
|
| 564 | - if ( isset( $this->meta['color'] ) ) { |
|
| 565 | - return ! empty( $this->meta['color'] ) ? esc_attr( $this->meta['color'] ) : $default; |
|
| 563 | + public function get_color($default = '') { |
|
| 564 | + if (isset($this->meta['color'])) { |
|
| 565 | + return ! empty($this->meta['color']) ? esc_attr($this->meta['color']) : $default; |
|
| 566 | 566 | } |
| 567 | 567 | return $default; |
| 568 | 568 | } |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | * @return array |
| 576 | 576 | */ |
| 577 | 577 | public function get_attachments() { |
| 578 | - return isset( $this->meta['attachments'] ) ? $this->meta['attachments'] : array(); |
|
| 578 | + return isset($this->meta['attachments']) ? $this->meta['attachments'] : array(); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | /** |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | * @return array |
| 587 | 587 | */ |
| 588 | 588 | public function get_attendees() { |
| 589 | - return isset( $this->meta['attendees'] ) ? $this->meta['attendees'] : array(); |
|
| 589 | + return isset($this->meta['attendees']) ? $this->meta['attendees'] : array(); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | /** |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | * @return array |
| 598 | 598 | */ |
| 599 | 599 | public function get_organizer() { |
| 600 | - return isset( $this->meta['organizer'] ) ? $this->meta['organizer'] : array(); |
|
| 600 | + return isset($this->meta['organizer']) ? $this->meta['organizer'] : array(); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | } |
@@ -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 | } |
@@ -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 | } |