@@ -14,24 +14,24 @@ discard block |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | // Exit if accessed directly. |
17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
17 | +if ( ! defined('ABSPATH')) { |
|
18 | 18 | exit; |
19 | 19 | } |
20 | 20 | |
21 | 21 | // Plugin constants. |
22 | -$this_plugin_path = trailingslashit( dirname( __FILE__ ) ); |
|
23 | -$this_plugin_dir = plugin_dir_url( __FILE__ ); |
|
22 | +$this_plugin_path = trailingslashit(dirname(__FILE__)); |
|
23 | +$this_plugin_dir = plugin_dir_url(__FILE__); |
|
24 | 24 | $this_plugin_constants = array( |
25 | 25 | 'SIMPLE_CALENDAR_VERSION' => '3.0.15', |
26 | 26 | 'SIMPLE_CALENDAR_MAIN_FILE' => __FILE__, |
27 | 27 | 'SIMPLE_CALENDAR_URL' => $this_plugin_dir, |
28 | - 'SIMPLE_CALENDAR_ASSETS' => $this_plugin_dir . 'assets/', |
|
28 | + 'SIMPLE_CALENDAR_ASSETS' => $this_plugin_dir.'assets/', |
|
29 | 29 | 'SIMPLE_CALENDAR_PATH' => $this_plugin_path, |
30 | - 'SIMPLE_CALENDAR_INC' => $this_plugin_path . 'includes/', |
|
30 | + 'SIMPLE_CALENDAR_INC' => $this_plugin_path.'includes/', |
|
31 | 31 | ); |
32 | -foreach ( $this_plugin_constants as $constant => $value ) { |
|
33 | - if ( ! defined( $constant ) ) { |
|
34 | - define( $constant, $value ); |
|
32 | +foreach ($this_plugin_constants as $constant => $value) { |
|
33 | + if ( ! defined($constant)) { |
|
34 | + define($constant, $value); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | include_once 'includes/wp-requirements.php'; |
41 | 41 | |
42 | 42 | // Check plugin requirements before loading plugin. |
43 | -$this_plugin_checks = new SimCal_WP_Requirements( 'Simple Calendar', plugin_basename( __FILE__ ), array( |
|
43 | +$this_plugin_checks = new SimCal_WP_Requirements('Simple Calendar', plugin_basename(__FILE__), array( |
|
44 | 44 | 'PHP' => '5.3.3', |
45 | 45 | 'WordPress' => '4.1', |
46 | 46 | 'Extensions' => array( |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | 'json', |
50 | 50 | 'mbstring', |
51 | 51 | ), |
52 | - ) ); |
|
53 | -if ( $this_plugin_checks->pass() === false ) { |
|
52 | + )); |
|
53 | +if ($this_plugin_checks->pass() === false) { |
|
54 | 54 | $this_plugin_checks->halt(); |
55 | 55 | |
56 | 56 | return; |
@@ -353,9 +353,9 @@ |
||
353 | 353 | */ |
354 | 354 | public function __toString() |
355 | 355 | { |
356 | - return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" . |
|
357 | - "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" . |
|
358 | - "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" . |
|
356 | + return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n". |
|
357 | + "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n". |
|
358 | + "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n". |
|
359 | 359 | "<strong>Platform:</strong> {$this->getPlatform()}<br/>"; |
360 | 360 | } |
361 | 361 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | use SimpleCalendar\Abstracts\Feed; |
11 | 11 | use SimpleCalendar\Feeds\Admin\Grouped_Calendars_Admin; |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param string|Calendar $calendar |
40 | 40 | */ |
41 | - public function __construct( $calendar = '' ) { |
|
41 | + public function __construct($calendar = '') { |
|
42 | 42 | |
43 | - parent::__construct( $calendar ); |
|
43 | + parent::__construct($calendar); |
|
44 | 44 | |
45 | 45 | $this->type = 'grouped-calendars'; |
46 | - $this->name = __( 'Grouped Calendar', 'google-calendar-events' ); |
|
46 | + $this->name = __('Grouped Calendar', 'google-calendar-events'); |
|
47 | 47 | |
48 | - if ( $this->post_id > 0 ) { |
|
48 | + if ($this->post_id > 0) { |
|
49 | 49 | $this->set_source(); |
50 | - if ( ! is_admin() || defined( 'DOING_AJAX' ) ) { |
|
50 | + if ( ! is_admin() || defined('DOING_AJAX')) { |
|
51 | 51 | $this->events = $this->get_events(); |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
56 | - new Grouped_Calendars_Admin( $this ); |
|
55 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
56 | + new Grouped_Calendars_Admin($this); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -64,38 +64,38 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param array $ids Array of calendar ids. |
66 | 66 | */ |
67 | - public function set_source( $ids = array() ) { |
|
67 | + public function set_source($ids = array()) { |
|
68 | 68 | |
69 | - $source = get_post_meta( $this->post_id, '_grouped_calendars_source', true ); |
|
69 | + $source = get_post_meta($this->post_id, '_grouped_calendars_source', true); |
|
70 | 70 | |
71 | - if ( 'ids' == $source ) { |
|
71 | + if ('ids' == $source) { |
|
72 | 72 | |
73 | - if ( empty( $ids ) ) { |
|
74 | - $ids = get_post_meta( $this->post_id, '_grouped_calendars_ids', true ); |
|
73 | + if (empty($ids)) { |
|
74 | + $ids = get_post_meta($this->post_id, '_grouped_calendars_ids', true); |
|
75 | 75 | } |
76 | 76 | |
77 | - $this->calendars_ids = ! empty( $ids ) && is_array( $ids ) ? array_map( 'absint', $ids ) : array(); |
|
77 | + $this->calendars_ids = ! empty($ids) && is_array($ids) ? array_map('absint', $ids) : array(); |
|
78 | 78 | |
79 | - } elseif ( 'category' == $source ) { |
|
79 | + } elseif ('category' == $source) { |
|
80 | 80 | |
81 | - $categories = get_post_meta( $this->post_id, '_grouped_calendars_category', true ); |
|
81 | + $categories = get_post_meta($this->post_id, '_grouped_calendars_category', true); |
|
82 | 82 | |
83 | - if ( $categories && is_array( $categories ) ) { |
|
83 | + if ($categories && is_array($categories)) { |
|
84 | 84 | |
85 | 85 | $tax_query = array( |
86 | 86 | 'taxonomy' => 'calendar_category', |
87 | 87 | 'field' => 'term_id', |
88 | - 'terms' => array_map( 'absint', $categories ), |
|
88 | + 'terms' => array_map('absint', $categories), |
|
89 | 89 | ); |
90 | 90 | |
91 | - $calendars = get_posts( array( |
|
91 | + $calendars = get_posts(array( |
|
92 | 92 | 'post_type' => 'calendar', |
93 | - 'tax_query' => array( $tax_query ), |
|
93 | + 'tax_query' => array($tax_query), |
|
94 | 94 | 'nopaging' => true, |
95 | 95 | 'fields' => 'ids', |
96 | - ) ); |
|
96 | + )); |
|
97 | 97 | |
98 | - $this->calendars_ids = ! empty( $calendars ) && is_array( $calendars ) ? $calendars : array(); |
|
98 | + $this->calendars_ids = ! empty($calendars) && is_array($calendars) ? $calendars : array(); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | } |
@@ -111,57 +111,57 @@ discard block |
||
111 | 111 | public function get_events() { |
112 | 112 | |
113 | 113 | $ids = $this->calendars_ids; |
114 | - $events = get_transient( '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type ); |
|
114 | + $events = get_transient('_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type); |
|
115 | 115 | |
116 | - if ( empty( $events ) && ! empty( $ids ) && is_array( $ids ) ) { |
|
116 | + if (empty($events) && ! empty($ids) && is_array($ids)) { |
|
117 | 117 | |
118 | 118 | $events = array(); |
119 | 119 | |
120 | - foreach ( $ids as $cal_id ) { |
|
120 | + foreach ($ids as $cal_id) { |
|
121 | 121 | |
122 | - $calendar = simcal_get_calendar( intval( $cal_id ) ); |
|
122 | + $calendar = simcal_get_calendar(intval($cal_id)); |
|
123 | 123 | |
124 | - simcal_delete_feed_transients( $cal_id ); |
|
124 | + simcal_delete_feed_transients($cal_id); |
|
125 | 125 | |
126 | - if ( $calendar instanceof Calendar ) { |
|
126 | + if ($calendar instanceof Calendar) { |
|
127 | 127 | |
128 | 128 | // Sometimes the calendars might have events at the same time from different calendars |
129 | 129 | // When merging the arrays together some of the events will be lost because the keys are the same and one will overwrite the other |
130 | 130 | // This snippet checks if the key already exists in the master events array and if it does it subtracts 1 from it to make the key unique and then unsets the original key. |
131 | - foreach( $calendar->events as $k => $v ) { |
|
132 | - $calendar->events[ $this->update_array_timestamp( $events, $k ) ] = $v; |
|
131 | + foreach ($calendar->events as $k => $v) { |
|
132 | + $calendar->events[$this->update_array_timestamp($events, $k)] = $v; |
|
133 | 133 | } |
134 | 134 | |
135 | - $events = is_array( $calendar->events ) ? $events + $calendar->events : $events; |
|
135 | + $events = is_array($calendar->events) ? $events + $calendar->events : $events; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | } |
139 | 139 | |
140 | - if ( ! empty( $events ) ) { |
|
140 | + if ( ! empty($events)) { |
|
141 | 141 | |
142 | 142 | // Trim events to set the earliest one as specified in feed settings. |
143 | - $earliest_event = intval( $this->time_min ); |
|
144 | - if ( $earliest_event > 0 ) { |
|
145 | - $events = $this->array_filter_key( $events, array( $this, 'filter_events_before' ) ); |
|
143 | + $earliest_event = intval($this->time_min); |
|
144 | + if ($earliest_event > 0) { |
|
145 | + $events = $this->array_filter_key($events, array($this, 'filter_events_before')); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | // Trim events to set the latest one as specified in feed settings. |
149 | - $latest_event = intval( $this->time_max ); |
|
150 | - if ( $latest_event > 0 ) { |
|
151 | - $events = $this->array_filter_key( $events, array( $this, 'filter_events_after' ) ); |
|
149 | + $latest_event = intval($this->time_max); |
|
150 | + if ($latest_event > 0) { |
|
151 | + $events = $this->array_filter_key($events, array($this, 'filter_events_after')); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | set_transient( |
155 | - '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type, |
|
155 | + '_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type, |
|
156 | 156 | $events, |
157 | - absint( $this->cache ) |
|
157 | + absint($this->cache) |
|
158 | 158 | ); |
159 | 159 | } |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Sort events by start time before returning |
164 | - uasort( $events, array( $this, 'sort_by_start_time' ) ); |
|
164 | + uasort($events, array($this, 'sort_by_start_time')); |
|
165 | 165 | |
166 | 166 | return $events; |
167 | 167 | } |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | /* |
170 | 170 | * Recursive function to adjust the timestamp array indices that are the same. |
171 | 171 | */ |
172 | - public function update_array_timestamp( $arr, $i ) { |
|
172 | + public function update_array_timestamp($arr, $i) { |
|
173 | 173 | |
174 | - if ( array_key_exists( $i, $arr ) ) { |
|
175 | - $i = $this->update_array_timestamp( $arr, $i - 1 ); |
|
174 | + if (array_key_exists($i, $arr)) { |
|
175 | + $i = $this->update_array_timestamp($arr, $i - 1); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | return $i; |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | * @since 3.0.13 |
185 | 185 | * @access private |
186 | 186 | */ |
187 | - private function sort_by_start_time( $a, $b ) { |
|
188 | - if ( $a == $b ) { |
|
187 | + private function sort_by_start_time($a, $b) { |
|
188 | + if ($a == $b) { |
|
189 | 189 | return 0; |
190 | 190 | } |
191 | 191 | |
192 | - return ( $a[0]->start < $b[0]->start ) ? -1 : 1; |
|
192 | + return ($a[0]->start < $b[0]->start) ? -1 : 1; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return array |
209 | 209 | */ |
210 | - private function array_filter_key( array $array, $callback ) { |
|
211 | - $matched_keys = array_filter( array_keys( $array ), $callback ); |
|
212 | - return array_intersect_key( $array, array_flip( $matched_keys ) ); |
|
210 | + private function array_filter_key(array $array, $callback) { |
|
211 | + $matched_keys = array_filter(array_keys($array), $callback); |
|
212 | + return array_intersect_key($array, array_flip($matched_keys)); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return bool |
224 | 224 | */ |
225 | - private function filter_events_before( $event ) { |
|
226 | - if ( $this->time_min !== 0 ) { |
|
227 | - return intval( $event ) > intval( $this->time_min ); |
|
225 | + private function filter_events_before($event) { |
|
226 | + if ($this->time_min !== 0) { |
|
227 | + return intval($event) > intval($this->time_min); |
|
228 | 228 | } |
229 | 229 | return true; |
230 | 230 | } |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @return bool |
241 | 241 | */ |
242 | - private function filter_events_after( $event ) { |
|
243 | - if ( $this->time_max !== 0 ) { |
|
244 | - return intval( $event ) < intval( $this->time_max ); |
|
242 | + private function filter_events_after($event) { |
|
243 | + if ($this->time_max !== 0) { |
|
244 | + return intval($event) < intval($this->time_max); |
|
245 | 245 | } |
246 | 246 | return true; |
247 | 247 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Abstracts as Object; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -31,27 +31,27 @@ discard block |
||
31 | 31 | public function __construct() { |
32 | 32 | |
33 | 33 | // Add default feed type. |
34 | - add_filter( 'simcal_get_feed_types', function( $feed_types ) { |
|
35 | - return array_merge( $feed_types, array( |
|
34 | + add_filter('simcal_get_feed_types', function($feed_types) { |
|
35 | + return array_merge($feed_types, array( |
|
36 | 36 | 'google', |
37 | 37 | 'grouped-calendars', |
38 | - ) ); |
|
39 | - }, 10, 1 ); |
|
38 | + )); |
|
39 | + }, 10, 1); |
|
40 | 40 | |
41 | 41 | // Add default calendar type. |
42 | - add_filter( 'simcal_get_calendar_types', function( $calendar_types ) { |
|
43 | - return array_merge( $calendar_types, array( |
|
42 | + add_filter('simcal_get_calendar_types', function($calendar_types) { |
|
43 | + return array_merge($calendar_types, array( |
|
44 | 44 | 'default-calendar' => array( |
45 | 45 | 'grid', |
46 | 46 | 'list', |
47 | 47 | ), |
48 | - ) ); |
|
49 | - }, 10, 1 ); |
|
48 | + )); |
|
49 | + }, 10, 1); |
|
50 | 50 | |
51 | 51 | // Add default admin objects. |
52 | - if ( $is_admin = is_admin() ) { |
|
53 | - add_filter( 'simcal_get_admin_pages', function( $admin_pages ) { |
|
54 | - return array_merge( $admin_pages, array( |
|
52 | + if ($is_admin = is_admin()) { |
|
53 | + add_filter('simcal_get_admin_pages', function($admin_pages) { |
|
54 | + return array_merge($admin_pages, array( |
|
55 | 55 | 'add-ons' => array( |
56 | 56 | 'add-ons', |
57 | 57 | ), |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | 'tools' => array( |
64 | 64 | 'system-status', |
65 | 65 | ), |
66 | - ) ); |
|
67 | - }, 10, 1 ); |
|
66 | + )); |
|
67 | + }, 10, 1); |
|
68 | 68 | } |
69 | 69 | |
70 | - do_action( 'simcal_load_objects', $is_admin ); |
|
70 | + do_action('simcal_load_objects', $is_admin); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @return array |
79 | 79 | */ |
80 | 80 | public function get_feed_types() { |
81 | - $array = apply_filters( 'simcal_get_feed_types', array() ); |
|
82 | - ksort( $array ); |
|
81 | + $array = apply_filters('simcal_get_feed_types', array()); |
|
82 | + ksort($array); |
|
83 | 83 | return $array; |
84 | 84 | } |
85 | 85 | |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | * @return array |
92 | 92 | */ |
93 | 93 | public function get_calendar_types() { |
94 | - $array = apply_filters( 'simcal_get_calendar_types', array() ); |
|
95 | - ksort( $array ); |
|
94 | + $array = apply_filters('simcal_get_calendar_types', array()); |
|
95 | + ksort($array); |
|
96 | 96 | return $array; |
97 | 97 | } |
98 | 98 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return array |
105 | 105 | */ |
106 | 106 | public function get_admin_pages() { |
107 | - return apply_filters( 'simcal_get_admin_pages', array() ); |
|
107 | + return apply_filters('simcal_get_admin_pages', array()); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -118,30 +118,30 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return null|Object\Calendar |
120 | 120 | */ |
121 | - public function get_calendar( $object ) { |
|
121 | + public function get_calendar($object) { |
|
122 | 122 | |
123 | - if ( is_string( $object ) ) { |
|
124 | - return ! empty( $object ) ? $this->get_object( $object, 'calendar', '' ) : null; |
|
123 | + if (is_string($object)) { |
|
124 | + return ! empty($object) ? $this->get_object($object, 'calendar', '') : null; |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( is_object( $object ) ) { |
|
128 | - if ( $object instanceof Object\Calendar ) { |
|
129 | - return $this->get_object( $object->type, 'feed', $object ); |
|
130 | - } elseif ( $object instanceof \WP_Post ) { |
|
131 | - if ( $type = wp_get_object_terms( $object->ID, 'calendar_type' ) ) { |
|
132 | - $name = sanitize_title( current( $type )->name ); |
|
133 | - return $this->get_object( $name, 'calendar', $object ); |
|
127 | + if (is_object($object)) { |
|
128 | + if ($object instanceof Object\Calendar) { |
|
129 | + return $this->get_object($object->type, 'feed', $object); |
|
130 | + } elseif ($object instanceof \WP_Post) { |
|
131 | + if ($type = wp_get_object_terms($object->ID, 'calendar_type')) { |
|
132 | + $name = sanitize_title(current($type)->name); |
|
133 | + return $this->get_object($name, 'calendar', $object); |
|
134 | 134 | } |
135 | - } elseif ( isset( $object->type ) && isset( $object->id ) ) { |
|
136 | - return $this->get_object( $object->type, 'calendar', $object->id ); |
|
135 | + } elseif (isset($object->type) && isset($object->id)) { |
|
136 | + return $this->get_object($object->type, 'calendar', $object->id); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - if ( is_int( $object ) ) { |
|
141 | - $post = get_post( $object ); |
|
142 | - if ( $post && ( $type = wp_get_object_terms( $post->ID, 'calendar_type' ) ) ) { |
|
143 | - $name = sanitize_title( current( $type )->name ); |
|
144 | - return $this->get_object( $name, 'calendar', $post ); |
|
140 | + if (is_int($object)) { |
|
141 | + $post = get_post($object); |
|
142 | + if ($post && ($type = wp_get_object_terms($post->ID, 'calendar_type'))) { |
|
143 | + $name = sanitize_title(current($type)->name); |
|
144 | + return $this->get_object($name, 'calendar', $post); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
@@ -158,20 +158,20 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return null|Object\Calendar_View |
160 | 160 | */ |
161 | - public function get_calendar_view( $id = 0, $name = '' ) { |
|
161 | + public function get_calendar_view($id = 0, $name = '') { |
|
162 | 162 | |
163 | - if ( ! $name && $id > 0 ) { |
|
163 | + if ( ! $name && $id > 0) { |
|
164 | 164 | |
165 | - $calendar_view = get_post_meta( $id, '_calendar_view', true ); |
|
165 | + $calendar_view = get_post_meta($id, '_calendar_view', true); |
|
166 | 166 | |
167 | - if ( $terms = wp_get_object_terms( $id, 'calendar_type' ) ) { |
|
168 | - $calendar_type = sanitize_title( current( $terms )->name ); |
|
169 | - $name = isset( $calendar_view[ $calendar_type ] ) ? $calendar_type . '-' . $calendar_view[ $calendar_type ] : ''; |
|
167 | + if ($terms = wp_get_object_terms($id, 'calendar_type')) { |
|
168 | + $calendar_type = sanitize_title(current($terms)->name); |
|
169 | + $name = isset($calendar_view[$calendar_type]) ? $calendar_type.'-'.$calendar_view[$calendar_type] : ''; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | } |
173 | 173 | |
174 | - return $name ? $this->get_object( $name, 'calendar-view', '' ) : null; |
|
174 | + return $name ? $this->get_object($name, 'calendar-view', '') : null; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -185,41 +185,41 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return null|Object\Feed |
187 | 187 | */ |
188 | - public function get_feed( $object ) { |
|
188 | + public function get_feed($object) { |
|
189 | 189 | |
190 | - if ( is_string( $object ) ) { |
|
191 | - return ! empty( $object ) ? $this->get_object( $object, 'feed', '' ) : null; |
|
190 | + if (is_string($object)) { |
|
191 | + return ! empty($object) ? $this->get_object($object, 'feed', '') : null; |
|
192 | 192 | } |
193 | 193 | |
194 | - if ( is_object( $object ) ) { |
|
195 | - if ( $object instanceof Object\Calendar ) { |
|
194 | + if (is_object($object)) { |
|
195 | + if ($object instanceof Object\Calendar) { |
|
196 | 196 | $feed_name = ''; |
197 | - if ( empty( $object->feed ) ) { |
|
198 | - if ( $feed_type = wp_get_object_terms( $object->id, 'feed_type' ) ) { |
|
199 | - $feed_name = sanitize_title( current( $feed_type )->name ); |
|
197 | + if (empty($object->feed)) { |
|
198 | + if ($feed_type = wp_get_object_terms($object->id, 'feed_type')) { |
|
199 | + $feed_name = sanitize_title(current($feed_type)->name); |
|
200 | 200 | } |
201 | 201 | } else { |
202 | 202 | $feed_name = $object->feed; |
203 | 203 | } |
204 | - return $this->get_object( $feed_name, 'feed', $object ); |
|
205 | - } elseif ( $object instanceof \WP_Post ) { |
|
206 | - $calendar = $this->get_calendar( $object ); |
|
204 | + return $this->get_object($feed_name, 'feed', $object); |
|
205 | + } elseif ($object instanceof \WP_Post) { |
|
206 | + $calendar = $this->get_calendar($object); |
|
207 | 207 | |
208 | - if ( isset( $calendar->feed ) ) { |
|
209 | - return $this->get_object( $calendar->feed, 'feed', $calendar ); |
|
208 | + if (isset($calendar->feed)) { |
|
209 | + return $this->get_object($calendar->feed, 'feed', $calendar); |
|
210 | 210 | } else { |
211 | 211 | return null; |
212 | 212 | } |
213 | 213 | |
214 | 214 | |
215 | - } elseif ( isset( $object->feed ) && isset( $object->id ) ) { |
|
216 | - return $this->get_object( $object->feed, 'feed', $object ); |
|
215 | + } elseif (isset($object->feed) && isset($object->id)) { |
|
216 | + return $this->get_object($object->feed, 'feed', $object); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - if ( is_int( $object ) ) { |
|
221 | - $calendar = $this->get_calendar( $object ); |
|
222 | - return isset( $calendar->feed ) ? $this->get_object( $calendar->feed, 'feed', $calendar ) : null; |
|
220 | + if (is_int($object)) { |
|
221 | + $calendar = $this->get_calendar($object); |
|
222 | + return isset($calendar->feed) ? $this->get_object($calendar->feed, 'feed', $calendar) : null; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | return null; |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return null|Object\Field |
237 | 237 | */ |
238 | - public function get_field( $args, $name = '' ) { |
|
238 | + public function get_field($args, $name = '') { |
|
239 | 239 | |
240 | - if ( empty( $name ) ) { |
|
241 | - $name = isset( $args['type'] ) ? $args['type'] : false; |
|
240 | + if (empty($name)) { |
|
241 | + $name = isset($args['type']) ? $args['type'] : false; |
|
242 | 242 | } |
243 | 243 | |
244 | - return $name ? $this->get_object( $name, 'field', $args ) : null; |
|
244 | + return $name ? $this->get_object($name, 'field', $args) : null; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return null|Object\Admin_Page |
255 | 255 | */ |
256 | - public function get_admin_page( $name ) { |
|
257 | - return $name ? $this->get_object( $name, 'admin-page' ) : null; |
|
256 | + public function get_admin_page($name) { |
|
257 | + return $name ? $this->get_object($name, 'admin-page') : null; |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return null|Object |
271 | 271 | */ |
272 | - private function get_object( $name, $type, $args = '' ) { |
|
272 | + private function get_object($name, $type, $args = '') { |
|
273 | 273 | |
274 | 274 | $types = array( |
275 | 275 | 'admin-page', |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | 'field', |
280 | 280 | ); |
281 | 281 | |
282 | - if ( in_array( $type, $types ) ) { |
|
282 | + if (in_array($type, $types)) { |
|
283 | 283 | |
284 | - $class_name = $this->make_class_name( $name, $type ); |
|
285 | - $parent = '\\' . __NAMESPACE__ . '\Abstracts\\' . implode( '_', array_map( 'ucfirst', explode( '-', $type ) ) ); |
|
286 | - $class = class_exists( $class_name ) ? new $class_name( $args ) : false; |
|
284 | + $class_name = $this->make_class_name($name, $type); |
|
285 | + $parent = '\\'.__NAMESPACE__.'\Abstracts\\'.implode('_', array_map('ucfirst', explode('-', $type))); |
|
286 | + $class = class_exists($class_name) ? new $class_name($args) : false; |
|
287 | 287 | |
288 | 288 | return $class instanceof $parent ? $class : null; |
289 | 289 | } |
@@ -305,25 +305,25 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @return string The class name complete with its full namespace. |
307 | 307 | */ |
308 | - private function make_class_name( $name, $type ) { |
|
309 | - |
|
310 | - if ( 'calendar' == $type ) { |
|
311 | - $namespace = '\\' . __NAMESPACE__ . '\Calendars\\'; |
|
312 | - } elseif ( 'calendar-view' == $type ) { |
|
313 | - $namespace = '\\' . __NAMESPACE__ . '\Calendars\Views\\'; |
|
314 | - } elseif ( 'feed' == $type ) { |
|
315 | - $namespace = '\\' . __NAMESPACE__ . '\Feeds\\'; |
|
316 | - } elseif ( 'field' == $type ) { |
|
317 | - $namespace = '\\' . __NAMESPACE__ . '\Admin\Fields\\'; |
|
318 | - } elseif ( 'admin-page' == $type ) { |
|
319 | - $namespace = '\\' . __NAMESPACE__ . '\Admin\Pages\\'; |
|
308 | + private function make_class_name($name, $type) { |
|
309 | + |
|
310 | + if ('calendar' == $type) { |
|
311 | + $namespace = '\\'.__NAMESPACE__.'\Calendars\\'; |
|
312 | + } elseif ('calendar-view' == $type) { |
|
313 | + $namespace = '\\'.__NAMESPACE__.'\Calendars\Views\\'; |
|
314 | + } elseif ('feed' == $type) { |
|
315 | + $namespace = '\\'.__NAMESPACE__.'\Feeds\\'; |
|
316 | + } elseif ('field' == $type) { |
|
317 | + $namespace = '\\'.__NAMESPACE__.'\Admin\Fields\\'; |
|
318 | + } elseif ('admin-page' == $type) { |
|
319 | + $namespace = '\\'.__NAMESPACE__.'\Admin\Pages\\'; |
|
320 | 320 | } else { |
321 | 321 | return ''; |
322 | 322 | } |
323 | 323 | |
324 | - $class_name = implode( '_', array_map( 'ucfirst', explode( '-', $name ) ) ); |
|
324 | + $class_name = implode('_', array_map('ucfirst', explode('-', $name))); |
|
325 | 325 | |
326 | - return $namespace . $class_name; |
|
326 | + return $namespace.$class_name; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | use SimpleCalendar\Feeds\Grouped_Calendars; |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -34,15 +34,15 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param Grouped_Calendars $feed |
36 | 36 | */ |
37 | - public function __construct( Grouped_Calendars $feed ) { |
|
37 | + public function __construct(Grouped_Calendars $feed) { |
|
38 | 38 | |
39 | 39 | $this->feed = $feed; |
40 | 40 | |
41 | - if ( 'calendar' == simcal_is_admin_screen() ) { |
|
42 | - add_filter( 'simcal_settings_meta_tabs_li', array( $this, 'add_settings_meta_tab_li' ), 10, 1 ); |
|
43 | - add_action( 'simcal_settings_meta_panels', array( $this, 'add_settings_meta_panel' ), 10, 1 ); |
|
41 | + if ('calendar' == simcal_is_admin_screen()) { |
|
42 | + add_filter('simcal_settings_meta_tabs_li', array($this, 'add_settings_meta_tab_li'), 10, 1); |
|
43 | + add_action('simcal_settings_meta_panels', array($this, 'add_settings_meta_panel'), 10, 1); |
|
44 | 44 | } |
45 | - add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 ); |
|
45 | + add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return array |
56 | 56 | */ |
57 | - public function add_settings_meta_tab_li( $tabs ) { |
|
58 | - return array_merge( $tabs, array( |
|
57 | + public function add_settings_meta_tab_li($tabs) { |
|
58 | + return array_merge($tabs, array( |
|
59 | 59 | 'grouped-calendars' => array( |
60 | 60 | 'label' => $this->feed->name, |
61 | 61 | 'target' => 'grouped-calendars-settings-panel', |
@@ -75,40 +75,40 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param int $post_id |
77 | 77 | */ |
78 | - public function add_settings_meta_panel( $post_id ) { |
|
78 | + public function add_settings_meta_panel($post_id) { |
|
79 | 79 | |
80 | 80 | ?> |
81 | 81 | <div id="grouped-calendars-settings-panel" class="simcal-panel"> |
82 | 82 | <table> |
83 | 83 | <thead> |
84 | - <tr><th colspan="2"><?php _e( 'Grouped Calendar Settings', 'google-calendar-events' ); ?></th></tr> |
|
84 | + <tr><th colspan="2"><?php _e('Grouped Calendar Settings', 'google-calendar-events'); ?></th></tr> |
|
85 | 85 | </thead> |
86 | 86 | <tbody class="simcal-panel-section"> |
87 | 87 | <tr class="simcal-panel-field"> |
88 | - <th><label for="_grouped_calendars_source"><?php _e( 'Get Calendars From', 'google-calendar-events' ); ?></label></th> |
|
88 | + <th><label for="_grouped_calendars_source"><?php _e('Get Calendars From', 'google-calendar-events'); ?></label></th> |
|
89 | 89 | <td> |
90 | 90 | <?php |
91 | 91 | |
92 | - $source = esc_attr( get_post_meta( $post_id, '_grouped_calendars_source', true ) ); |
|
93 | - $source = empty( $source ) ? 'ids' : $source; |
|
92 | + $source = esc_attr(get_post_meta($post_id, '_grouped_calendars_source', true)); |
|
93 | + $source = empty($source) ? 'ids' : $source; |
|
94 | 94 | |
95 | 95 | ?> |
96 | 96 | <select name="_grouped_calendars_source" |
97 | 97 | id="_grouped_calendars_source" |
98 | 98 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other" |
99 | 99 | data-show-field-on-choice="true"> |
100 | - <option value="ids" data-show-field="_grouped_calendars_ids" <?php selected( 'ids', $source, true ); ?>><?php _e( 'Manual selection', 'google-calendar-events' ); ?></option> |
|
101 | - <option value="category" data-show-field="_grouped_calendars_category" <?php selected( 'category', $source, true ); ?>><?php _e( 'Category', 'google-calendar-events' ); ?></option> |
|
100 | + <option value="ids" data-show-field="_grouped_calendars_ids" <?php selected('ids', $source, true); ?>><?php _e('Manual selection', 'google-calendar-events'); ?></option> |
|
101 | + <option value="category" data-show-field="_grouped_calendars_category" <?php selected('category', $source, true); ?>><?php _e('Category', 'google-calendar-events'); ?></option> |
|
102 | 102 | </select> |
103 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Choose from which calendar feeds you want to get events from. Choose them individually or select all those belonging to calendar feed categories.', 'google-calendar-events' ); ?>"></i> |
|
103 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Choose from which calendar feeds you want to get events from. Choose them individually or select all those belonging to calendar feed categories.', 'google-calendar-events'); ?>"></i> |
|
104 | 104 | <br><br> |
105 | 105 | <?php |
106 | 106 | |
107 | - $cals = simcal_get_calendars( $post_id ); |
|
108 | - $meta = get_post_meta( $post_id, '_grouped_calendars_ids', true ); |
|
109 | - $ids = $meta && is_array( $meta ) ? implode( ',', array_map( 'absint', $meta ) ) : absint( $meta ); |
|
107 | + $cals = simcal_get_calendars($post_id); |
|
108 | + $meta = get_post_meta($post_id, '_grouped_calendars_ids', true); |
|
109 | + $ids = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : absint($meta); |
|
110 | 110 | |
111 | - simcal_print_field( array( |
|
111 | + simcal_print_field(array( |
|
112 | 112 | 'type' => 'select', |
113 | 113 | 'multiselect' => 'multiselect', |
114 | 114 | 'name' => '_grouped_calendars_ids', |
@@ -116,25 +116,25 @@ discard block |
||
116 | 116 | 'value' => $ids !== 0 ? $ids : '', |
117 | 117 | 'options' => $cals, |
118 | 118 | 'enhanced' => 'enhanced', |
119 | - 'style' => 'ids' == $source ? '' : array( 'display' => 'none' ), |
|
119 | + 'style' => 'ids' == $source ? '' : array('display' => 'none'), |
|
120 | 120 | 'attributes' => array( |
121 | - 'data-noresults' => __( 'No results found.', 'google-calendar-events' ), |
|
121 | + 'data-noresults' => __('No results found.', 'google-calendar-events'), |
|
122 | 122 | ), |
123 | 123 | )); |
124 | 124 | |
125 | - $meta = get_post_meta( $post_id, '_grouped_calendars_category', true ); |
|
126 | - $category = $meta && is_array( $meta ) ? implode( ',', array_map( 'absint', $meta ) ): ''; |
|
125 | + $meta = get_post_meta($post_id, '_grouped_calendars_category', true); |
|
126 | + $category = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : ''; |
|
127 | 127 | |
128 | - $terms = get_terms( 'calendar_category' ); |
|
128 | + $terms = get_terms('calendar_category'); |
|
129 | 129 | |
130 | - if ( ! empty( $terms ) ) { |
|
130 | + if ( ! empty($terms)) { |
|
131 | 131 | |
132 | 132 | $categories = array(); |
133 | - foreach ( $terms as $term ) { |
|
134 | - $categories[ $term->term_id ] = $term->name; |
|
133 | + foreach ($terms as $term) { |
|
134 | + $categories[$term->term_id] = $term->name; |
|
135 | 135 | } |
136 | 136 | |
137 | - simcal_print_field( array( |
|
137 | + simcal_print_field(array( |
|
138 | 138 | 'type' => 'select', |
139 | 139 | 'multiselect' => 'multiselect', |
140 | 140 | 'name' => '_grouped_calendars_category', |
@@ -142,17 +142,17 @@ discard block |
||
142 | 142 | 'value' => $category, |
143 | 143 | 'options' => $categories, |
144 | 144 | 'enhanced' => 'enhanced', |
145 | - 'style' => 'category' == $source ? '' : array( 'display' => 'none' ), |
|
145 | + 'style' => 'category' == $source ? '' : array('display' => 'none'), |
|
146 | 146 | 'attributes' => array( |
147 | - 'data-noresults' => __( 'No results found.', 'google-calendar-events' ), |
|
147 | + 'data-noresults' => __('No results found.', 'google-calendar-events'), |
|
148 | 148 | ), |
149 | - ) ); |
|
149 | + )); |
|
150 | 150 | |
151 | 151 | } else { |
152 | 152 | |
153 | 153 | $style = 'category' == $source ? '' : 'display: none;'; |
154 | 154 | $style .= ' width: 100%; max-width: 500px'; |
155 | - echo '<input type="text" disabled="disabled" name="_grouped_calendars_category" id="_grouped_calendars_category" style="' . $style . '" placeholder="' . __( 'There are no calendar categories yet.', 'google-calendar-events' ) . '" />'; |
|
155 | + echo '<input type="text" disabled="disabled" name="_grouped_calendars_category" id="_grouped_calendars_category" style="'.$style.'" placeholder="'.__('There are no calendar categories yet.', 'google-calendar-events').'" />'; |
|
156 | 156 | |
157 | 157 | } |
158 | 158 | |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @param int $post_id |
175 | 175 | */ |
176 | - public function process_meta( $post_id ) { |
|
176 | + public function process_meta($post_id) { |
|
177 | 177 | |
178 | - $source = isset( $_POST['_grouped_calendars_source'] ) ? sanitize_key( $_POST['_grouped_calendars_source'] ) : 'ids'; |
|
179 | - update_post_meta( $post_id, '_grouped_calendars_source', $source ); |
|
178 | + $source = isset($_POST['_grouped_calendars_source']) ? sanitize_key($_POST['_grouped_calendars_source']) : 'ids'; |
|
179 | + update_post_meta($post_id, '_grouped_calendars_source', $source); |
|
180 | 180 | |
181 | - $ids = isset( $_POST['_grouped_calendars_ids'] ) ? array_map( 'absint', $_POST['_grouped_calendars_ids'] ) : ''; |
|
182 | - update_post_meta( $post_id, '_grouped_calendars_ids', $ids ); |
|
181 | + $ids = isset($_POST['_grouped_calendars_ids']) ? array_map('absint', $_POST['_grouped_calendars_ids']) : ''; |
|
182 | + update_post_meta($post_id, '_grouped_calendars_ids', $ids); |
|
183 | 183 | |
184 | - $category = isset( $_POST['_grouped_calendars_category'] ) ? array_map( 'absint', $_POST['_grouped_calendars_category'] ) : ''; |
|
185 | - update_post_meta( $post_id, '_grouped_calendars_category', $category ); |
|
184 | + $category = isset($_POST['_grouped_calendars_category']) ? array_map('absint', $_POST['_grouped_calendars_category']) : ''; |
|
185 | + update_post_meta($post_id, '_grouped_calendars_category', $category); |
|
186 | 186 | |
187 | 187 | } |
188 | 188 |
@@ -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 | |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param array $field |
36 | 36 | */ |
37 | - public function __construct( $field ) { |
|
38 | - $this->addon = isset( $field['addon'] ) ? esc_attr( $field['addon'] ) : ''; |
|
37 | + public function __construct($field) { |
|
38 | + $this->addon = isset($field['addon']) ? esc_attr($field['addon']) : ''; |
|
39 | 39 | $this->type_class = 'simcal-field-license'; |
40 | - parent::__construct( $field ); |
|
40 | + parent::__construct($field); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function html() { |
49 | 49 | |
50 | - if ( ! empty( $this->addon ) ) { |
|
50 | + if ( ! empty($this->addon)) { |
|
51 | 51 | |
52 | - $status = apply_filters( 'simcal_addon_status_' . $this->addon, simcal_get_license_status( $this->addon ) ); |
|
52 | + $status = apply_filters('simcal_addon_status_'.$this->addon, simcal_get_license_status($this->addon)); |
|
53 | 53 | |
54 | - if ( $status !== 'valid' ) { |
|
54 | + if ($status !== 'valid') { |
|
55 | 55 | $display_activate = 'display: inline-block'; |
56 | 56 | $display_deactivate = 'display: none'; |
57 | 57 | $active = 'valid' == $status ? 'display: block' : 'display: none'; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } else { |
60 | 60 | $display_activate = $active = 'display: none'; |
61 | 61 | $display_deactivate = 'display: inline-block'; |
62 | - $disabled = empty( $this->value ) ? '' : 'disabled="disabled"'; |
|
62 | + $disabled = empty($this->value) ? '' : 'disabled="disabled"'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | ?> |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | <span class="simcal-addon-manage-license-buttons"> |
75 | 75 | |
76 | 76 | <button class="button-secondary simcal-addon-manage-license deactivate" data-add-on="<?php echo $this->addon; ?>" style="<?php echo $display_deactivate; ?>"> |
77 | - <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e( 'Deactivate', 'google-calendar-events' ); ?> |
|
77 | + <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e('Deactivate', 'google-calendar-events'); ?> |
|
78 | 78 | </button> |
79 | 79 | |
80 | 80 | <button class="button-secondary simcal-addon-manage-license activate" data-add-on="<?php echo $this->addon; ?>" style="<?php echo $display_activate; ?>"> |
81 | - <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e( 'Activate', 'google-calendar-events' ); ?> |
|
81 | + <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e('Activate', 'google-calendar-events'); ?> |
|
82 | 82 | </button> |
83 | 83 | |
84 | 84 | <span class="error" style="color: red; display: none"> </span> |
85 | 85 | |
86 | - <strong class="label" style="color:green; <?php echo $active; ?>"> <?php _e( '(active)', 'google-calendar-events' ); ?></strong> |
|
86 | + <strong class="label" style="color:green; <?php echo $active; ?>"> <?php _e('(active)', 'google-calendar-events'); ?></strong> |
|
87 | 87 | |
88 | 88 | </span> |
89 | 89 |
@@ -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 echo ( ! empty( $this->text ) ? $this->text : __( 'Yes', 'google-calendar-events' ) ); ?> |
|
89 | + <?php checked($this->value, 'yes', true); ?> |
|
90 | + <?php echo $this->attributes; ?>/><?php echo ( ! empty($this->text) ? $this->text : __('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 | } |
@@ -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 | |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | |
45 | 45 | self::$main_menu = 'edit.php?post_type=calendar'; |
46 | 46 | |
47 | - add_action( 'admin_menu', array( __CLASS__, 'add_menu_items' ) ); |
|
47 | + add_action('admin_menu', array(__CLASS__, 'add_menu_items')); |
|
48 | 48 | |
49 | - self::$plugin = plugin_basename( SIMPLE_CALENDAR_MAIN_FILE ); |
|
49 | + self::$plugin = plugin_basename(SIMPLE_CALENDAR_MAIN_FILE); |
|
50 | 50 | |
51 | 51 | new Welcome(); |
52 | 52 | |
53 | 53 | // Links and meta content in plugins page. |
54 | - add_filter( 'plugin_action_links_' . self::$plugin, array( __CLASS__, 'plugin_action_links' ), 10, 5 ); |
|
55 | - add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 ); |
|
54 | + add_filter('plugin_action_links_'.self::$plugin, array(__CLASS__, 'plugin_action_links'), 10, 5); |
|
55 | + add_filter('plugin_row_meta', array(__CLASS__, 'plugin_row_meta'), 10, 2); |
|
56 | 56 | // Custom text in admin footer. |
57 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 ); |
|
57 | + add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -66,41 +66,41 @@ discard block |
||
66 | 66 | |
67 | 67 | add_submenu_page( |
68 | 68 | self::$main_menu, |
69 | - __( 'Settings', 'google-calendar-events' ), |
|
70 | - __( 'Settings', 'google-calendar-events' ), |
|
69 | + __('Settings', 'google-calendar-events'), |
|
70 | + __('Settings', 'google-calendar-events'), |
|
71 | 71 | 'manage_options', |
72 | 72 | 'simple-calendar_settings', |
73 | - function () { |
|
74 | - $page = new Pages( 'settings' ); |
|
73 | + function() { |
|
74 | + $page = new Pages('settings'); |
|
75 | 75 | $page->html(); |
76 | 76 | } |
77 | 77 | ); |
78 | 78 | |
79 | 79 | add_submenu_page( |
80 | 80 | self::$main_menu, |
81 | - __( 'Add-ons', 'google-calendar-events' ), |
|
82 | - __( 'Add-ons', 'google-calendar-events' ), |
|
81 | + __('Add-ons', 'google-calendar-events'), |
|
82 | + __('Add-ons', 'google-calendar-events'), |
|
83 | 83 | 'manage_options', |
84 | 84 | 'simple-calendar_add_ons', |
85 | 85 | function() { |
86 | - $page = new Pages( 'add-ons' ); |
|
86 | + $page = new Pages('add-ons'); |
|
87 | 87 | $page->html(); |
88 | 88 | } |
89 | 89 | ); |
90 | 90 | |
91 | 91 | add_submenu_page( |
92 | 92 | self::$main_menu, |
93 | - __( 'Tools', 'google-calendar-events' ), |
|
94 | - __( 'Tools', 'google-calendar-events' ), |
|
93 | + __('Tools', 'google-calendar-events'), |
|
94 | + __('Tools', 'google-calendar-events'), |
|
95 | 95 | 'manage_options', |
96 | 96 | 'simple-calendar_tools', |
97 | - function () { |
|
98 | - $page = new Pages( 'tools' ); |
|
97 | + function() { |
|
98 | + $page = new Pages('tools'); |
|
99 | 99 | $page->html(); |
100 | 100 | } |
101 | 101 | ); |
102 | 102 | |
103 | - do_action( 'simcal_admin_add_menu_items' ); |
|
103 | + do_action('simcal_admin_add_menu_items'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return array |
115 | 115 | */ |
116 | - public static function plugin_action_links( $action_links, $file ) { |
|
116 | + public static function plugin_action_links($action_links, $file) { |
|
117 | 117 | |
118 | - if ( self::$plugin == $file ) { |
|
118 | + if (self::$plugin == $file) { |
|
119 | 119 | |
120 | 120 | $links = array(); |
121 | - $links['settings'] = '<a href="' . admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings' ) . '">' . __( 'Settings', 'google-calendar-events' ) . '</a>'; |
|
122 | - $links['feeds'] = '<a href="' . admin_url( 'edit.php?post_type=calendar' ) . '">' . __( 'Calendars', 'google-calendar-events' ) . '</a>'; |
|
121 | + $links['settings'] = '<a href="'.admin_url('edit.php?post_type=calendar&page=simple-calendar_settings').'">'.__('Settings', 'google-calendar-events').'</a>'; |
|
122 | + $links['feeds'] = '<a href="'.admin_url('edit.php?post_type=calendar').'">'.__('Calendars', 'google-calendar-events').'</a>'; |
|
123 | 123 | |
124 | - return apply_filters( 'simcal_plugin_action_links', array_merge( $links, $action_links ) ); |
|
124 | + return apply_filters('simcal_plugin_action_links', array_merge($links, $action_links)); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | return $action_links; |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return array |
139 | 139 | */ |
140 | - public static function plugin_row_meta( $meta_links, $file ) { |
|
140 | + public static function plugin_row_meta($meta_links, $file) { |
|
141 | 141 | |
142 | - if ( self::$plugin == $file ) { |
|
142 | + if (self::$plugin == $file) { |
|
143 | 143 | |
144 | 144 | $links = array(); |
145 | - $links['add-ons'] = '<a href="' . simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'plugin-listing' ) . '" target="_blank" >' . |
|
146 | - __( 'Add-ons', 'google-calendar-events' ) . '</a>'; |
|
145 | + $links['add-ons'] = '<a href="'.simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'plugin-listing').'" target="_blank" >'. |
|
146 | + __('Add-ons', 'google-calendar-events').'</a>'; |
|
147 | 147 | |
148 | - return apply_filters( 'simcal_plugin_action_links', array_merge( $meta_links, $links ) ); |
|
148 | + return apply_filters('simcal_plugin_action_links', array_merge($meta_links, $links)); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | return $meta_links; |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string|void |
164 | 164 | */ |
165 | - public function admin_footer_text( $footer_text ) { |
|
165 | + public function admin_footer_text($footer_text) { |
|
166 | 166 | |
167 | 167 | // Check to make sure we're on a SimpleCal admin page |
168 | 168 | $screen = simcal_is_admin_screen(); |
169 | - if ( $screen !== false ) { |
|
169 | + if ($screen !== false) { |
|
170 | 170 | |
171 | - if ( 'calendar' == $screen ) { |
|
171 | + if ('calendar' == $screen) { |
|
172 | 172 | |
173 | 173 | // Add Drip promo signup form (@see Newsletter meta box). |
174 | 174 | |
@@ -196,23 +196,23 @@ discard block |
||
196 | 196 | } |
197 | 197 | |
198 | 198 | // Change the footer text |
199 | - if ( ! get_option( 'simple-calendar_admin_footer_text_rated' ) ) { |
|
199 | + if ( ! get_option('simple-calendar_admin_footer_text_rated')) { |
|
200 | 200 | |
201 | 201 | $footer_text = sprintf( |
202 | - __( 'If you like <strong>Simple Calendar</strong> please leave us a %s★★★★★ rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events' ), |
|
203 | - '<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'google-calendar-events' ) . '">', '</a>' |
|
202 | + __('If you like <strong>Simple Calendar</strong> please leave us a %s★★★★★ rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events'), |
|
203 | + '<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="'.esc_attr__('Thanks :)', 'google-calendar-events').'">', '</a>' |
|
204 | 204 | ); |
205 | 205 | |
206 | 206 | $footer_text .= '<script type="text/javascript">'; |
207 | 207 | $footer_text .= "jQuery( 'a.simcal-rating-link' ).click( function() { |
208 | - jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url() . "', { action: 'simcal_rated' } ); |
|
208 | + jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url()."', { action: 'simcal_rated' } ); |
|
209 | 209 | jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) ); |
210 | 210 | });"; |
211 | 211 | $footer_text .= '</script>'; |
212 | 212 | |
213 | 213 | } else { |
214 | 214 | |
215 | - $footer_text = __( 'Thanks for using Simple Calendar!', 'google-calendar-events' ); |
|
215 | + $footer_text = __('Thanks for using Simple Calendar!', 'google-calendar-events'); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 |
@@ -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,20 +123,20 @@ discard block |
||
123 | 123 | ); |
124 | 124 | |
125 | 125 | // Update license in db. |
126 | - $keys = get_option( 'simple-calendar_settings_licenses', array() ); |
|
127 | - $keys['keys'][ $addon ] = $key; |
|
128 | - update_option( 'simple-calendar_settings_licenses', $keys ); |
|
126 | + $keys = get_option('simple-calendar_settings_licenses', array()); |
|
127 | + $keys['keys'][$addon] = $key; |
|
128 | + update_option('simple-calendar_settings_licenses', $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 | 138 | |
139 | - if ( ! empty( $license_data ) ) { |
|
139 | + if ( ! empty($license_data)) { |
|
140 | 140 | if ('deactivated' == $license_data->license) { |
141 | 141 | unset($status[$addon]); |
142 | 142 | update_option('simple-calendar_licenses_status', $status); |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | $message = 'valid' == $license_data->license ? 'valid' : __('License key is invalid.', 'google-calendar-events'); |
148 | 148 | wp_send_json_success($message); |
149 | 149 | } else { |
150 | - wp_send_json_error( '' ); |
|
150 | + wp_send_json_error(''); |
|
151 | 151 | } |
152 | 152 | } else { |
153 | - wp_send_json_error( __( 'An error has occurred, please try again.', 'google-calendar-events' ) ); |
|
153 | + wp_send_json_error(__('An error has occurred, please try again.', 'google-calendar-events')); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function reset_licenses() { |
163 | 163 | |
164 | - $nonce = isset( $_POST['nonce'] ) ? esc_attr( $_POST['nonce'] ) : ''; |
|
164 | + $nonce = isset($_POST['nonce']) ? esc_attr($_POST['nonce']) : ''; |
|
165 | 165 | |
166 | 166 | // Verify this request comes from the add-ons licenses activation settings page. |
167 | - if ( empty ( $nonce ) || ! wp_verify_nonce( $nonce, 'simcal_license_manager' ) ) { |
|
168 | - wp_send_json_error( sprintf( __( 'An error occurred: %s', 'google-calendar-events' ), 'Nonce verification failed.' ) ); |
|
167 | + if (empty ($nonce) || ! wp_verify_nonce($nonce, 'simcal_license_manager')) { |
|
168 | + wp_send_json_error(sprintf(__('An error occurred: %s', 'google-calendar-events'), 'Nonce verification failed.')); |
|
169 | 169 | } |
170 | 170 | |
171 | - delete_option( 'simple-calendar_settings_licenses' ); |
|
172 | - delete_option( 'simple-calendar_licenses_status' ); |
|
171 | + delete_option('simple-calendar_settings_licenses'); |
|
172 | + delete_option('simple-calendar_licenses_status'); |
|
173 | 173 | |
174 | - wp_send_json_success( 'success' ); |
|
174 | + wp_send_json_success('success'); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | } |