@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | namespace SimpleCalendar; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | 36 | |
37 | - $this->widgets = apply_filters( 'simcal_get_widgets', array( |
|
37 | + $this->widgets = apply_filters('simcal_get_widgets', array( |
|
38 | 38 | 'SimpleCalendar\Widgets\Calendar' |
39 | - ), array() ); |
|
39 | + ), array()); |
|
40 | 40 | |
41 | - add_action( 'widgets_init', array( $this, 'register' ) ); |
|
41 | + add_action('widgets_init', array($this, 'register')); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | |
51 | 51 | $widgets = $this->widgets; |
52 | 52 | |
53 | - if ( ! empty( $widgets ) && is_array( $widgets ) ) { |
|
54 | - foreach ( $widgets as $widget ) { |
|
55 | - register_widget( $widget ); |
|
53 | + if ( ! empty($widgets) && is_array($widgets)) { |
|
54 | + foreach ($widgets as $widget) { |
|
55 | + register_widget($widget); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | - do_action( 'simcal_register_widgets' ); |
|
59 | + do_action('simcal_register_widgets'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | } |
@@ -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 | |
@@ -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; |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @param string $version (optional) Current plugin version, defaults to value in plugin constant. |
65 | 65 | */ |
66 | - public function __construct( $version = SIMPLE_CALENDAR_VERSION ) { |
|
66 | + public function __construct($version = SIMPLE_CALENDAR_VERSION) { |
|
67 | 67 | // Look for previous version in current or legacy option, null for fresh install. |
68 | - $installed = get_option( 'simple-calendar_version', null ); |
|
69 | - $this->installed_ver = is_null( $installed ) ? get_option( 'gce_version', null ) : $installed; |
|
68 | + $installed = get_option('simple-calendar_version', null); |
|
69 | + $this->installed_ver = is_null($installed) ? get_option('gce_version', null) : $installed; |
|
70 | 70 | $this->new_ver = $version; |
71 | 71 | |
72 | - if ( version_compare( $this->installed_ver, $this->new_ver, '<' ) ) { |
|
72 | + if (version_compare($this->installed_ver, $this->new_ver, '<')) { |
|
73 | 73 | $this->run_updates(); |
74 | 74 | } |
75 | 75 | } |
@@ -83,18 +83,18 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function run_updates() { |
85 | 85 | |
86 | - do_action( 'simcal_before_update', $this->installed_ver ); |
|
86 | + do_action('simcal_before_update', $this->installed_ver); |
|
87 | 87 | |
88 | - if ( ! is_null( $this->installed_ver ) ) { |
|
88 | + if ( ! is_null($this->installed_ver)) { |
|
89 | 89 | |
90 | - if ( version_compare( $this->installed_ver, $this->new_ver ) === -1 ) { |
|
90 | + if (version_compare($this->installed_ver, $this->new_ver) === -1) { |
|
91 | 91 | |
92 | - $post_type = version_compare( $this->installed_ver, '3.0.0' ) === -1 ? 'gce_feed' : 'calendar'; |
|
93 | - $this->posts = $this->get_posts( $post_type ); |
|
92 | + $post_type = version_compare($this->installed_ver, '3.0.0') === -1 ? 'gce_feed' : 'calendar'; |
|
93 | + $this->posts = $this->get_posts($post_type); |
|
94 | 94 | |
95 | - foreach ( $this->update_path as $update_to ) { |
|
96 | - if ( version_compare( $this->installed_ver, $update_to, '<' ) ) { |
|
97 | - $this->update( $update_to ); |
|
95 | + foreach ($this->update_path as $update_to) { |
|
96 | + if (version_compare($this->installed_ver, $update_to, '<')) { |
|
97 | + $this->update($update_to); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -109,28 +109,28 @@ discard block |
||
109 | 109 | |
110 | 110 | } |
111 | 111 | |
112 | - do_action( 'simcal_updated', $this->new_ver ); |
|
112 | + do_action('simcal_updated', $this->new_ver); |
|
113 | 113 | |
114 | 114 | // Redirect to a welcome page if new install or major update. |
115 | - if ( is_null( $this->installed_ver ) ) { |
|
116 | - set_transient( '_simple-calendar_activation_redirect', 'fresh', 60 ); |
|
115 | + if (is_null($this->installed_ver)) { |
|
116 | + set_transient('_simple-calendar_activation_redirect', 'fresh', 60); |
|
117 | 117 | } else { |
118 | - $major_new = substr( $this->new_ver, 0, strrpos( $this->new_ver, '.' ) ); |
|
119 | - $major_old = substr( $this->installed_ver, 0, strrpos( $this->installed_ver, '.' ) ); |
|
120 | - if ( version_compare( $major_new, $major_old, '>' ) ) { |
|
121 | - set_transient( '_simple-calendar_activation_redirect', 'update', 60 ); |
|
122 | - } elseif ( $major_old == $major_new ) { |
|
123 | - $version = explode( '.', $this->new_ver ); |
|
124 | - end( $version ); |
|
125 | - if ( 0 === intval( current( $version ) ) ) { |
|
126 | - set_transient( '_simple-calendar_activation_redirect', 'update', 60 ); |
|
118 | + $major_new = substr($this->new_ver, 0, strrpos($this->new_ver, '.')); |
|
119 | + $major_old = substr($this->installed_ver, 0, strrpos($this->installed_ver, '.')); |
|
120 | + if (version_compare($major_new, $major_old, '>')) { |
|
121 | + set_transient('_simple-calendar_activation_redirect', 'update', 60); |
|
122 | + } elseif ($major_old == $major_new) { |
|
123 | + $version = explode('.', $this->new_ver); |
|
124 | + end($version); |
|
125 | + if (0 === intval(current($version))) { |
|
126 | + set_transient('_simple-calendar_activation_redirect', 'update', 60); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | 131 | $this->admin_redirects(); |
132 | 132 | |
133 | - update_option( 'simple-calendar_version', $this->new_ver ); |
|
133 | + update_option('simple-calendar_version', $this->new_ver); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -142,25 +142,25 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function admin_redirects() { |
144 | 144 | |
145 | - $transient = get_transient( '_simple-calendar_activation_redirect' ); |
|
145 | + $transient = get_transient('_simple-calendar_activation_redirect'); |
|
146 | 146 | |
147 | - if ( ! $transient || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { |
|
147 | + if ( ! $transient || is_network_admin() || isset($_GET['activate-multi']) || ! current_user_can('manage_options')) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | - delete_transient( '_simple-calendar_activation_redirect' ); |
|
151 | + delete_transient('_simple-calendar_activation_redirect'); |
|
152 | 152 | |
153 | 153 | // Do not redirect if already on welcome page screen. |
154 | - if ( ! empty( $_GET['page'] ) && in_array( $_GET['page'], array( 'simple-calendar_about' ) ) ) { |
|
154 | + if ( ! empty($_GET['page']) && in_array($_GET['page'], array('simple-calendar_about'))) { |
|
155 | 155 | return; |
156 | 156 | } |
157 | 157 | |
158 | 158 | $url = add_query_arg( |
159 | 159 | 'simcal_install', |
160 | - esc_attr( $transient ), |
|
161 | - admin_url( 'index.php?page=simple-calendar_about' ) |
|
160 | + esc_attr($transient), |
|
161 | + admin_url('index.php?page=simple-calendar_about') |
|
162 | 162 | ); |
163 | - wp_safe_redirect( $url ); |
|
163 | + wp_safe_redirect($url); |
|
164 | 164 | exit; |
165 | 165 | } |
166 | 166 | |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return array |
175 | 175 | */ |
176 | - private function get_posts( $post_type ) { |
|
176 | + private function get_posts($post_type) { |
|
177 | 177 | |
178 | 178 | $posts = array(); |
179 | 179 | |
180 | - if ( ! empty( $post_type ) ) { |
|
180 | + if ( ! empty($post_type)) { |
|
181 | 181 | |
182 | 182 | // https://core.trac.wordpress.org/ticket/18408 |
183 | - $posts = get_posts( array( |
|
183 | + $posts = get_posts(array( |
|
184 | 184 | 'post_type' => $post_type, |
185 | 185 | 'post_status' => array( |
186 | 186 | 'draft', |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'trash', |
192 | 192 | ), |
193 | 193 | 'nopaging' => true, |
194 | - ) ); |
|
194 | + )); |
|
195 | 195 | |
196 | 196 | wp_reset_postdata(); |
197 | 197 | } |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @param string $version |
210 | 210 | */ |
211 | - private function update( $version ) { |
|
211 | + private function update($version) { |
|
212 | 212 | |
213 | - $update_v = '\\' . __NAMESPACE__ . '\Updates\\Update_V' . str_replace( '.', '', $version ); |
|
213 | + $update_v = '\\'.__NAMESPACE__.'\Updates\\Update_V'.str_replace('.', '', $version); |
|
214 | 214 | |
215 | - if ( class_exists( $update_v ) ) { |
|
216 | - new $update_v( $this->posts ); |
|
215 | + if (class_exists($update_v)) { |
|
216 | + new $update_v($this->posts); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @license GPL2+ |
12 | 12 | */ |
13 | 13 | |
14 | -if ( ! class_exists( 'SimCal_WP_Requirements' ) ) { |
|
14 | +if ( ! class_exists('SimCal_WP_Requirements')) { |
|
15 | 15 | |
16 | 16 | class SimCal_WP_Requirements { |
17 | 17 | |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | * @param string $plugin Output of `plugin_basename( __FILE__ )`. |
91 | 91 | * @param array $requirements Associative array with requirements. |
92 | 92 | */ |
93 | - public function __construct( $name, $plugin, $requirements ) { |
|
93 | + public function __construct($name, $plugin, $requirements) { |
|
94 | 94 | |
95 | - $this->name = htmlspecialchars( strip_tags( $name ) ); |
|
95 | + $this->name = htmlspecialchars(strip_tags($name)); |
|
96 | 96 | $this->plugin = $plugin; |
97 | 97 | $this->requirements = $requirements; |
98 | 98 | |
99 | - if ( ! empty( $requirements ) && is_array( $requirements ) ) { |
|
99 | + if ( ! empty($requirements) && is_array($requirements)) { |
|
100 | 100 | |
101 | 101 | $failures = $extensions = array(); |
102 | 102 | |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | ); |
110 | 110 | |
111 | 111 | // Check for WordPress version. |
112 | - if ( $requirements['WordPress'] && is_string( $requirements['WordPress'] ) ) { |
|
113 | - if ( function_exists( 'get_bloginfo' ) ) { |
|
114 | - $wp_version = get_bloginfo( 'version' ); |
|
115 | - if ( version_compare( $wp_version, $requirements['WordPress'] ) === - 1 ) { |
|
112 | + if ($requirements['WordPress'] && is_string($requirements['WordPress'])) { |
|
113 | + if (function_exists('get_bloginfo')) { |
|
114 | + $wp_version = get_bloginfo('version'); |
|
115 | + if (version_compare($wp_version, $requirements['WordPress']) === - 1) { |
|
116 | 116 | $failures['WordPress'] = $wp_version; |
117 | 117 | $this->wp = false; |
118 | 118 | } |
@@ -120,24 +120,24 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | // Check fo PHP version. |
123 | - if ( $requirements['PHP'] && is_string( $requirements['PHP'] ) ) { |
|
124 | - if ( version_compare( PHP_VERSION, $requirements['PHP'] ) === -1 ) { |
|
123 | + if ($requirements['PHP'] && is_string($requirements['PHP'])) { |
|
124 | + if (version_compare(PHP_VERSION, $requirements['PHP']) === -1) { |
|
125 | 125 | $failures['PHP'] = PHP_VERSION; |
126 | 126 | $this->php = false; |
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | 130 | // Check fo PHP Extensions. |
131 | - if ( $requirements['Extensions'] && is_array( $requirements['Extensions'] ) ) { |
|
132 | - foreach ( $requirements['Extensions'] as $extension ) { |
|
133 | - if ( $extension && is_string( $extension ) ) { |
|
134 | - $extensions[ $extension ] = extension_loaded( $extension ); |
|
131 | + if ($requirements['Extensions'] && is_array($requirements['Extensions'])) { |
|
132 | + foreach ($requirements['Extensions'] as $extension) { |
|
133 | + if ($extension && is_string($extension)) { |
|
134 | + $extensions[$extension] = extension_loaded($extension); |
|
135 | 135 | } |
136 | 136 | } |
137 | - if ( in_array( false, $extensions ) ) { |
|
138 | - foreach ( $extensions as $extension_name => $found ) { |
|
139 | - if ( $found === false ) { |
|
140 | - $failures['Extensions'][ $extension_name ] = $extension_name; |
|
137 | + if (in_array(false, $extensions)) { |
|
138 | + foreach ($extensions as $extension_name => $found) { |
|
139 | + if ($found === false) { |
|
140 | + $failures['Extensions'][$extension_name] = $extension_name; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | $this->extensions = false; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | } else { |
150 | 150 | |
151 | - trigger_error( 'WP Requirements: the requirements are invalid.', E_USER_ERROR ); |
|
151 | + trigger_error('WP Requirements: the requirements are invalid.', E_USER_ERROR); |
|
152 | 152 | |
153 | 153 | } |
154 | 154 | } |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * @return bool |
169 | 169 | */ |
170 | 170 | public function pass() { |
171 | - if ( in_array( false, array( |
|
171 | + if (in_array(false, array( |
|
172 | 172 | $this->wp, |
173 | 173 | $this->php, |
174 | 174 | $this->extensions, |
175 | - ) ) ) { |
|
175 | + ))) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | return true; |
@@ -185,28 +185,28 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public function get_notice( $message = '' ) { |
|
188 | + public function get_notice($message = '') { |
|
189 | 189 | |
190 | 190 | $notice = ''; |
191 | 191 | $name = $this->name; |
192 | 192 | $failures = $this->failures; |
193 | 193 | |
194 | - if ( ! empty( $failures ) && is_array( $failures ) ) { |
|
194 | + if ( ! empty($failures) && is_array($failures)) { |
|
195 | 195 | |
196 | - $notice = '<div class="error">' . "\n"; |
|
197 | - $notice .= "\t" . '<p>' . "\n"; |
|
198 | - $notice .= '<strong>' . sprintf( '%s could not be activated.', $name ) . '</strong><br>'; |
|
196 | + $notice = '<div class="error">'."\n"; |
|
197 | + $notice .= "\t".'<p>'."\n"; |
|
198 | + $notice .= '<strong>'.sprintf('%s could not be activated.', $name).'</strong><br>'; |
|
199 | 199 | |
200 | - foreach ( $failures as $requirement => $found ) { |
|
200 | + foreach ($failures as $requirement => $found) { |
|
201 | 201 | |
202 | - $required = $this->requirements[ $requirement ]; |
|
202 | + $required = $this->requirements[$requirement]; |
|
203 | 203 | |
204 | - if ( 'Extensions' == $requirement ) { |
|
205 | - if ( is_array( $found ) ) { |
|
204 | + if ('Extensions' == $requirement) { |
|
205 | + if (is_array($found)) { |
|
206 | 206 | $notice .= sprintf( |
207 | 207 | 'Required PHP Extension(s) not found: %s.', |
208 | - join( ', ', $found ) |
|
209 | - ) . '<br>'; |
|
208 | + join(', ', $found) |
|
209 | + ).'<br>'; |
|
210 | 210 | } |
211 | 211 | } else { |
212 | 212 | $notice .= sprintf( |
@@ -214,14 +214,14 @@ discard block |
||
214 | 214 | $requirement, |
215 | 215 | $required, |
216 | 216 | $found |
217 | - ) . '<br>'; |
|
217 | + ).'<br>'; |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | } |
221 | 221 | |
222 | - $notice .= '<em>' . sprintf( 'Please update to meet %s requirements.', $name ) . '</em>' . "\n"; |
|
223 | - $notice .= "\t" . '</p>' . "\n"; |
|
224 | - if ( $message ) { |
|
222 | + $notice .= '<em>'.sprintf('Please update to meet %s requirements.', $name).'</em>'."\n"; |
|
223 | + $notice .= "\t".'</p>'."\n"; |
|
224 | + if ($message) { |
|
225 | 225 | $notice .= $message; |
226 | 226 | } |
227 | 227 | $notice .= '</div>'; |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * Deactivate plugin. |
242 | 242 | */ |
243 | 243 | public function deactivate_plugin() { |
244 | - if ( function_exists( 'deactivate_plugins' ) && function_exists( 'plugin_basename' ) ) { |
|
245 | - deactivate_plugins( $this->plugin ); |
|
244 | + if (function_exists('deactivate_plugins') && function_exists('plugin_basename')) { |
|
245 | + deactivate_plugins($this->plugin); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
@@ -251,17 +251,17 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @param string $message An additional message in notice. |
253 | 253 | */ |
254 | - public function halt( $message = '' ) { |
|
254 | + public function halt($message = '') { |
|
255 | 255 | |
256 | - $this->notice = $this->get_notice( $message ); |
|
256 | + $this->notice = $this->get_notice($message); |
|
257 | 257 | |
258 | - if ( $this->notice && function_exists( 'add_action' ) ) { |
|
258 | + if ($this->notice && function_exists('add_action')) { |
|
259 | 259 | |
260 | - add_action( 'admin_notices', array( $this, 'print_notice' ) ); |
|
261 | - add_action( 'admin_init', array( $this, 'deactivate_plugin' ) ); |
|
260 | + add_action('admin_notices', array($this, 'print_notice')); |
|
261 | + add_action('admin_init', array($this, 'deactivate_plugin')); |
|
262 | 262 | |
263 | - if ( isset( $_GET['activate'] ) ) { |
|
264 | - unset( $_GET['activate'] ); |
|
263 | + if (isset($_GET['activate'])) { |
|
264 | + unset($_GET['activate']); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Carbon\Carbon; |
10 | 10 | use SimpleCalendar\Post_Types; |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param array $posts |
25 | 25 | */ |
26 | - public function __construct( $posts ) { |
|
26 | + public function __construct($posts) { |
|
27 | 27 | |
28 | 28 | $this->update_options(); |
29 | 29 | } |
@@ -34,22 +34,22 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function update_options() { |
36 | 36 | |
37 | - $settings_advanced = get_option( 'simple-calendar_settings_advanced' ); |
|
37 | + $settings_advanced = get_option('simple-calendar_settings_advanced'); |
|
38 | 38 | |
39 | 39 | // Remove stored always_enqueue value |
40 | - if ( isset( $settings_advanced['assets']['always_enqueue'] ) ) { |
|
41 | - unset( $settings_advanced['assets']['always_enqueue'] ); |
|
40 | + if (isset($settings_advanced['assets']['always_enqueue'])) { |
|
41 | + unset($settings_advanced['assets']['always_enqueue']); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // Remove stored disable_js value |
45 | - if ( isset( $settings_advanced['assets']['disable_js'] ) ) { |
|
46 | - unset( $settings_advanced['assets']['disable_js'] ); |
|
45 | + if (isset($settings_advanced['assets']['disable_js'])) { |
|
46 | + unset($settings_advanced['assets']['disable_js']); |
|
47 | 47 | } |
48 | 48 | |
49 | - update_option( 'simple-calendar_settings_advanced', $settings_advanced ); |
|
49 | + update_option('simple-calendar_settings_advanced', $settings_advanced); |
|
50 | 50 | |
51 | 51 | // Delete legacy options. |
52 | - delete_option( 'simple-calendar_defaults' ); |
|
52 | + delete_option('simple-calendar_defaults'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | } |
@@ -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 | |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | 36 | |
37 | - $this->min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG == true ) ? '' : '.min'; |
|
37 | + $this->min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG == true) ? '' : '.min'; |
|
38 | 38 | |
39 | - add_action( 'admin_enqueue_scripts', array( $this, 'load' ) ); |
|
39 | + add_action('admin_enqueue_scripts', array($this, 'load')); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function load() { |
48 | 48 | |
49 | - $css_path = SIMPLE_CALENDAR_ASSETS . 'css/'; |
|
50 | - $css_path_vendor = $css_path . 'vendor/'; |
|
51 | - $js_path = SIMPLE_CALENDAR_ASSETS . 'js/'; |
|
52 | - $js_path_vendor = $js_path . 'vendor/'; |
|
49 | + $css_path = SIMPLE_CALENDAR_ASSETS.'css/'; |
|
50 | + $css_path_vendor = $css_path.'vendor/'; |
|
51 | + $js_path = SIMPLE_CALENDAR_ASSETS.'js/'; |
|
52 | + $js_path_vendor = $js_path.'vendor/'; |
|
53 | 53 | |
54 | 54 | /* ====================== * |
55 | 55 | * Register Admin Scripts * |
@@ -58,21 +58,21 @@ discard block |
||
58 | 58 | // TipTip uses ".minified.js" filename ending. |
59 | 59 | wp_register_script( |
60 | 60 | 'simcal-tiptip', |
61 | - $js_path_vendor . 'jquery.tipTip' . ( ( $this->min !== '' ) ? '.minified' : '' ) . '.js', |
|
62 | - array( 'jquery' ), |
|
61 | + $js_path_vendor.'jquery.tipTip'.(($this->min !== '') ? '.minified' : '').'.js', |
|
62 | + array('jquery'), |
|
63 | 63 | '1.3', |
64 | 64 | true |
65 | 65 | ); |
66 | 66 | wp_register_script( |
67 | 67 | 'simcal-select2', |
68 | - $js_path_vendor . 'select2' . $this->min . '.js', |
|
68 | + $js_path_vendor.'select2'.$this->min.'.js', |
|
69 | 69 | array(), |
70 | 70 | '4.0', |
71 | 71 | true |
72 | 72 | ); |
73 | 73 | wp_register_script( |
74 | 74 | 'simcal-admin', |
75 | - $js_path . 'admin' . $this->min . '.js', |
|
75 | + $js_path.'admin'.$this->min.'.js', |
|
76 | 76 | array( |
77 | 77 | 'jquery', |
78 | 78 | 'jquery-ui-sortable', |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | ); |
87 | 87 | wp_register_script( |
88 | 88 | 'simcal-admin-add-calendar', |
89 | - $js_path . 'admin-add-calendar' . $this->min . '.js', |
|
90 | - array( 'simcal-select2' ), |
|
89 | + $js_path.'admin-add-calendar'.$this->min.'.js', |
|
90 | + array('simcal-select2'), |
|
91 | 91 | SIMPLE_CALENDAR_VERSION, |
92 | 92 | true |
93 | 93 | ); |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | |
99 | 99 | wp_register_style( |
100 | 100 | 'simcal-select2', |
101 | - $css_path_vendor . 'select2' . $this->min . '.css', |
|
101 | + $css_path_vendor.'select2'.$this->min.'.css', |
|
102 | 102 | array(), |
103 | 103 | '4.0.0' |
104 | 104 | ); |
105 | 105 | wp_register_style( |
106 | 106 | 'simcal-admin', |
107 | - $css_path . 'admin' . $this->min . '.css', |
|
107 | + $css_path.'admin'.$this->min.'.css', |
|
108 | 108 | array( |
109 | 109 | 'wp-color-picker', |
110 | 110 | 'simcal-select2', |
@@ -113,21 +113,21 @@ discard block |
||
113 | 113 | ); |
114 | 114 | wp_register_style( |
115 | 115 | 'simcal-admin-add-calendar', |
116 | - $css_path . 'admin-add-calendar' . $this->min . '.css', |
|
117 | - array( 'simcal-select2' ), |
|
116 | + $css_path.'admin-add-calendar'.$this->min.'.css', |
|
117 | + array('simcal-select2'), |
|
118 | 118 | SIMPLE_CALENDAR_VERSION |
119 | 119 | ); |
120 | 120 | |
121 | - if ( simcal_is_admin_screen() !== false ) { |
|
121 | + if (simcal_is_admin_screen() !== false) { |
|
122 | 122 | |
123 | - wp_enqueue_script( 'simcal-admin' ); |
|
123 | + wp_enqueue_script('simcal-admin'); |
|
124 | 124 | wp_localize_script( |
125 | 125 | 'simcal-admin', |
126 | 126 | 'simcal_admin', |
127 | 127 | simcal_common_scripts_variables() |
128 | 128 | ); |
129 | 129 | |
130 | - wp_enqueue_style( 'simcal-admin' ); |
|
130 | + wp_enqueue_style('simcal-admin'); |
|
131 | 131 | |
132 | 132 | } else { |
133 | 133 | |
@@ -135,25 +135,25 @@ discard block |
||
135 | 135 | $screen = get_current_screen(); |
136 | 136 | |
137 | 137 | $post_types = array(); |
138 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
139 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
138 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
139 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
140 | 140 | $post_types = $settings['general']['attach_calendars_posts']; |
141 | 141 | } |
142 | 142 | |
143 | 143 | $conditions = array( |
144 | - in_array( $post_type, (array) $post_types ), |
|
144 | + in_array($post_type, (array) $post_types), |
|
145 | 145 | $screen->id == 'widgets', |
146 | 146 | ); |
147 | 147 | |
148 | - if ( in_array( true, $conditions ) ) { |
|
148 | + if (in_array(true, $conditions)) { |
|
149 | 149 | |
150 | - wp_enqueue_script( 'simcal-admin-add-calendar' ); |
|
151 | - wp_localize_script( 'simcal-admin-add-calendar', 'simcal_admin', array( |
|
150 | + wp_enqueue_script('simcal-admin-add-calendar'); |
|
151 | + wp_localize_script('simcal-admin-add-calendar', 'simcal_admin', array( |
|
152 | 152 | 'locale' => get_locale(), |
153 | 153 | 'text_dir' => is_rtl() ? 'rtl' : 'ltr', |
154 | - ) ); |
|
154 | + )); |
|
155 | 155 | |
156 | - wp_enqueue_style( 'simcal-admin-add-calendar' ); |
|
156 | + wp_enqueue_style('simcal-admin-add-calendar'); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | } |
@@ -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; |
13 | 13 | } |
14 | 14 | |
@@ -51,32 +51,32 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @param array $field |
53 | 53 | */ |
54 | - public function __construct( $field ) { |
|
54 | + public function __construct($field) { |
|
55 | 55 | |
56 | 56 | $class = 'simcal-field-select'; |
57 | 57 | |
58 | - $enhanced = isset( $field['enhanced'] ) ? $field['enhanced'] : ''; |
|
59 | - if ( 'enhanced' == $enhanced ) { |
|
58 | + $enhanced = isset($field['enhanced']) ? $field['enhanced'] : ''; |
|
59 | + if ('enhanced' == $enhanced) { |
|
60 | 60 | $this->enhanced = true; |
61 | 61 | $class .= ' simcal-field-select-enhanced'; |
62 | 62 | } |
63 | 63 | |
64 | - $multiselect = isset( $field['multiselect'] ) ? $field['multiselect'] : ''; |
|
65 | - if ( 'multiselect' == $multiselect ) { |
|
64 | + $multiselect = isset($field['multiselect']) ? $field['multiselect'] : ''; |
|
65 | + if ('multiselect' == $multiselect) { |
|
66 | 66 | $this->multiselect = true; |
67 | 67 | $class .= ' simcal-field-multiselect'; |
68 | 68 | } |
69 | 69 | |
70 | - if ( isset( $field['default'] ) ) { |
|
70 | + if (isset($field['default'])) { |
|
71 | 71 | $this->default = $field['default']; |
72 | 72 | } |
73 | 73 | |
74 | 74 | $this->type_class = $class; |
75 | 75 | |
76 | - $allow_void = isset( $field['allow_void'] ) ? $field['allow_void'] : ''; |
|
76 | + $allow_void = isset($field['allow_void']) ? $field['allow_void'] : ''; |
|
77 | 77 | $this->allow_void = 'allow_void' == $allow_void ? true : false; |
78 | 78 | |
79 | - parent::__construct( $field ); |
|
79 | + parent::__construct($field); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -86,36 +86,36 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function html() { |
88 | 88 | |
89 | - if ( $this->multiselect === true && ! is_array( $this->value ) ) { |
|
90 | - $this->value = explode( ',', $this->value ); |
|
89 | + if ($this->multiselect === true && ! is_array($this->value)) { |
|
90 | + $this->value = explode(',', $this->value); |
|
91 | 91 | } |
92 | 92 | |
93 | - if ( $this->default ) { |
|
94 | - if ( empty( $this->value ) || $this->value == '' ) { |
|
93 | + if ($this->default) { |
|
94 | + if (empty($this->value) || $this->value == '') { |
|
95 | 95 | $this->value = $this->default; |
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | 99 | ?> |
100 | - <select name="<?php echo $this->name; ?><?php if ( $this->multiselect === true ) { echo '[]'; } ?>" |
|
100 | + <select name="<?php echo $this->name; ?><?php if ($this->multiselect === true) { echo '[]'; } ?>" |
|
101 | 101 | id="<?php echo $this->id; ?>" |
102 | 102 | style="<?php echo $this->style; ?>" |
103 | 103 | class="<?php echo $this->class; ?>" |
104 | 104 | <?php echo $this->attributes; ?> |
105 | - <?php echo ( $this->multiselect === true ) ? ' multiple="multiple"' : ''; ?>> |
|
105 | + <?php echo ($this->multiselect === true) ? ' multiple="multiple"' : ''; ?>> |
|
106 | 106 | <?php |
107 | 107 | |
108 | - if ( $this->allow_void === true ) { |
|
109 | - echo '<option value=""' . selected( '', $this->value, false ) . '></option>'; |
|
108 | + if ($this->allow_void === true) { |
|
109 | + echo '<option value=""'.selected('', $this->value, false).'></option>'; |
|
110 | 110 | } |
111 | 111 | |
112 | - foreach ( $this->options as $option => $name ) { |
|
113 | - if ( is_array( $this->value ) ) { |
|
114 | - $selected = selected( in_array( $option, $this->value ), true, false ); |
|
112 | + foreach ($this->options as $option => $name) { |
|
113 | + if (is_array($this->value)) { |
|
114 | + $selected = selected(in_array($option, $this->value), true, false); |
|
115 | 115 | } else { |
116 | - $selected = selected( $this->value, trim( strval( $option ) ), false ); |
|
116 | + $selected = selected($this->value, trim(strval($option)), false); |
|
117 | 117 | } |
118 | - echo '<option value="' . $option . '" ' . $selected . '>' . esc_attr( $name ) . '</option>'; |
|
118 | + echo '<option value="'.$option.'" '.$selected.'>'.esc_attr($name).'</option>'; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | ?> |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | |
125 | 125 | echo $this->tooltip; |
126 | 126 | |
127 | - if ( ! empty( $this->description ) ) { |
|
128 | - echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>'; |
|
127 | + if ( ! empty($this->description)) { |
|
128 | + echo '<p class="description">'.wp_kses_post($this->description).'</p>'; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | } |