@@ -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 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | use SimpleCalendar\Abstracts\Feed; |
12 | 12 | use SimpleCalendar\Abstracts\Field; |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -31,40 +31,40 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @param \WP_Post $post |
33 | 33 | */ |
34 | - public static function html( $post ) { |
|
34 | + public static function html($post) { |
|
35 | 35 | |
36 | 36 | // @see Meta_Boxes::save_meta_boxes() |
37 | - wp_nonce_field( 'simcal_save_data', 'simcal_meta_nonce' ); |
|
37 | + wp_nonce_field('simcal_save_data', 'simcal_meta_nonce'); |
|
38 | 38 | |
39 | 39 | ?> |
40 | 40 | <div class="simcal-panels-wrap"> |
41 | 41 | |
42 | 42 | <span class="simcal-box-handle"> |
43 | - <?php self::settings_handle( $post ); ?> |
|
43 | + <?php self::settings_handle($post); ?> |
|
44 | 44 | </span> |
45 | 45 | |
46 | 46 | <ul class="simcal-tabs"> |
47 | - <?php self::settings_tabs( $post ); ?> |
|
48 | - <?php do_action( 'simcal_settings_meta_tabs' ); ?> |
|
47 | + <?php self::settings_tabs($post); ?> |
|
48 | + <?php do_action('simcal_settings_meta_tabs'); ?> |
|
49 | 49 | </ul> |
50 | 50 | |
51 | 51 | <div class="simcal-panels"> |
52 | 52 | <div id="events-settings-panel" class="simcal-panel"> |
53 | - <?php self::events_settings_panel( $post ); ?> |
|
54 | - <?php do_action( 'simcal_settings_meta_events_panel', $post->ID ); ?> |
|
53 | + <?php self::events_settings_panel($post); ?> |
|
54 | + <?php do_action('simcal_settings_meta_events_panel', $post->ID); ?> |
|
55 | 55 | </div> |
56 | 56 | <div id="calendar-settings-panel" class="simcal-panel"> |
57 | - <?php do_action( 'simcal_settings_meta_calendar_panel', $post->ID ); ?> |
|
58 | - <?php self::calendar_settings_panel( $post ); ?> |
|
57 | + <?php do_action('simcal_settings_meta_calendar_panel', $post->ID); ?> |
|
58 | + <?php self::calendar_settings_panel($post); ?> |
|
59 | 59 | </div> |
60 | 60 | <?php |
61 | 61 | // Hook for additional settings panels. |
62 | - do_action( 'simcal_settings_meta_panels', $post->ID ); |
|
62 | + do_action('simcal_settings_meta_panels', $post->ID); |
|
63 | 63 | // Thus advanced panel is always the last one: |
64 | 64 | ?> |
65 | 65 | <div id="advanced-settings-panel" class="simcal-panel"> |
66 | - <?php self::advanced_settings_panel( $post ) ?> |
|
67 | - <?php do_action( 'simcal_settings_meta_advanced_panel', $post->ID ); ?> |
|
66 | + <?php self::advanced_settings_panel($post) ?> |
|
67 | + <?php do_action('simcal_settings_meta_advanced_panel', $post->ID); ?> |
|
68 | 68 | </div> |
69 | 69 | </div> |
70 | 70 | |
@@ -84,45 +84,45 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param \WP_Post $post |
86 | 86 | */ |
87 | - private static function settings_handle( $post ) { |
|
87 | + private static function settings_handle($post) { |
|
88 | 88 | |
89 | 89 | $feed_options = $calendar_options = $calendar_views = array(); |
90 | 90 | |
91 | 91 | $feed_types = simcal_get_feed_types(); |
92 | - foreach ( $feed_types as $feed_type ) { |
|
92 | + foreach ($feed_types as $feed_type) { |
|
93 | 93 | |
94 | - $feed = simcal_get_feed( $feed_type ); |
|
94 | + $feed = simcal_get_feed($feed_type); |
|
95 | 95 | |
96 | - if ( $feed instanceof Feed ) { |
|
97 | - $feed_options[ $feed_type ] = $feed->name; |
|
96 | + if ($feed instanceof Feed) { |
|
97 | + $feed_options[$feed_type] = $feed->name; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | $calendar_types = simcal_get_calendar_types(); |
102 | - foreach ( $calendar_types as $calendar_type => $views ) { |
|
102 | + foreach ($calendar_types as $calendar_type => $views) { |
|
103 | 103 | |
104 | - $calendar = simcal_get_calendar( $calendar_type ); |
|
104 | + $calendar = simcal_get_calendar($calendar_type); |
|
105 | 105 | |
106 | - if ( $calendar instanceof Calendar ) { |
|
107 | - $calendar_options[ $calendar_type ] = $calendar->name; |
|
108 | - $calendar_views[ $calendar_type ] = $calendar->views; |
|
106 | + if ($calendar instanceof Calendar) { |
|
107 | + $calendar_options[$calendar_type] = $calendar->name; |
|
108 | + $calendar_views[$calendar_type] = $calendar->views; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - if ( $feed_options ) { |
|
112 | + if ($feed_options) { |
|
113 | 113 | |
114 | - if ( $feed_types = wp_get_object_terms( $post->ID, 'calendar_feed' ) ) { |
|
115 | - $feed_type = sanitize_title( current( $feed_types )->name ); |
|
114 | + if ($feed_types = wp_get_object_terms($post->ID, 'calendar_feed')) { |
|
115 | + $feed_type = sanitize_title(current($feed_types)->name); |
|
116 | 116 | } else { |
117 | - $feed_type = apply_filters( 'simcal_default_feed_type', 'google' ); |
|
117 | + $feed_type = apply_filters('simcal_default_feed_type', 'google'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | ?> |
121 | - <label for="_feed_type"><span><?php _e( 'Event Source', 'google-calendar-events' ); ?></span> |
|
121 | + <label for="_feed_type"><span><?php _e('Event Source', 'google-calendar-events'); ?></span> |
|
122 | 122 | <select name="_feed_type" id="_feed_type"> |
123 | - <optgroup label="<?php _ex( 'Get events from', 'From which calendar source to load events from', 'google-calendar-events' ) ?>"> |
|
124 | - <?php foreach ( $feed_options as $feed => $name ) { ?> |
|
125 | - <option value="<?php echo $feed; ?>" <?php selected( $feed, $feed_type, true ); ?>><?php echo $name; ?></option> |
|
123 | + <optgroup label="<?php _ex('Get events from', 'From which calendar source to load events from', 'google-calendar-events') ?>"> |
|
124 | + <?php foreach ($feed_options as $feed => $name) { ?> |
|
125 | + <option value="<?php echo $feed; ?>" <?php selected($feed, $feed_type, true); ?>><?php echo $name; ?></option> |
|
126 | 126 | <?php } ?> |
127 | 127 | </optgroup> |
128 | 128 | </select> |
@@ -131,40 +131,40 @@ discard block |
||
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | - if ( $calendar_options ) { |
|
134 | + if ($calendar_options) { |
|
135 | 135 | |
136 | - if ( $calendar_types = wp_get_object_terms( $post->ID, 'calendar_type' ) ) { |
|
137 | - $calendar_type = sanitize_title( current( $calendar_types )->name ); |
|
136 | + if ($calendar_types = wp_get_object_terms($post->ID, 'calendar_type')) { |
|
137 | + $calendar_type = sanitize_title(current($calendar_types)->name); |
|
138 | 138 | } else { |
139 | - $calendar_type = apply_filters( 'simcal_default_calendar_type', 'default-calendar' ); |
|
139 | + $calendar_type = apply_filters('simcal_default_calendar_type', 'default-calendar'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | ?> |
143 | - <label for="_calendar_type"><span><?php _e( 'Calendar', 'google-calendar-events' ); ?></span> |
|
143 | + <label for="_calendar_type"><span><?php _e('Calendar', 'google-calendar-events'); ?></span> |
|
144 | 144 | <select name="_calendar_type" id="_calendar_type"> |
145 | - <optgroup label="<?php _e( 'Calendar to use', 'google-calendar-events' ); ?>"> |
|
146 | - <?php foreach ( $calendar_options as $calendar => $name ) { ?> |
|
147 | - <option value="<?php echo $calendar; ?>" <?php selected( $calendar, $calendar_type, true ); ?>><?php echo $name; ?></option> |
|
145 | + <optgroup label="<?php _e('Calendar to use', 'google-calendar-events'); ?>"> |
|
146 | + <?php foreach ($calendar_options as $calendar => $name) { ?> |
|
147 | + <option value="<?php echo $calendar; ?>" <?php selected($calendar, $calendar_type, true); ?>><?php echo $name; ?></option> |
|
148 | 148 | <?php } ?> |
149 | 149 | </optgroup> |
150 | 150 | </select> |
151 | 151 | </label> |
152 | 152 | <?php |
153 | 153 | |
154 | - if ( $calendar_views ) { |
|
154 | + if ($calendar_views) { |
|
155 | 155 | |
156 | - $calendar_view = get_post_meta( $post->ID, '_calendar_view', true ); |
|
156 | + $calendar_view = get_post_meta($post->ID, '_calendar_view', true); |
|
157 | 157 | |
158 | - foreach ( $calendar_views as $calendar => $views ) { |
|
158 | + foreach ($calendar_views as $calendar => $views) { |
|
159 | 159 | |
160 | - $calendar_type_view = isset( $calendar_view[ $calendar ] ) ? $calendar_view[ $calendar ] : ''; |
|
160 | + $calendar_type_view = isset($calendar_view[$calendar]) ? $calendar_view[$calendar] : ''; |
|
161 | 161 | |
162 | 162 | ?> |
163 | - <label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e( 'View', 'google-calendar-events' ); ?></span> |
|
163 | + <label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e('View', 'google-calendar-events'); ?></span> |
|
164 | 164 | <select name="_calendar_view[<?php echo $calendar; ?>]" id="_calendar_view_<?php echo $calendar; ?>"> |
165 | - <optgroup label="<?php _e( 'View to display', 'google-calendar-events' ); ?>"> |
|
166 | - <?php foreach ( $views as $view => $name ) { ?> |
|
167 | - <option value="<?php echo $view; ?>" <?php selected( $view, $calendar_type_view, true ); ?>><?php echo $name; ?></option> |
|
165 | + <optgroup label="<?php _e('View to display', 'google-calendar-events'); ?>"> |
|
166 | + <?php foreach ($views as $view => $name) { ?> |
|
167 | + <option value="<?php echo $view; ?>" <?php selected($view, $calendar_type_view, true); ?>><?php echo $name; ?></option> |
|
168 | 168 | <?php } ?> |
169 | 169 | </optgroup> |
170 | 170 | </select> |
@@ -184,42 +184,42 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @param \WP_Post $post |
186 | 186 | */ |
187 | - private static function settings_tabs( $post ) { |
|
187 | + private static function settings_tabs($post) { |
|
188 | 188 | |
189 | 189 | // Hook to add more tabs. |
190 | - $tabs = apply_filters( 'simcal_settings_meta_tabs_li', array( |
|
190 | + $tabs = apply_filters('simcal_settings_meta_tabs_li', array( |
|
191 | 191 | 'events' => array( |
192 | - 'label' => __( 'Events', 'google-calendar-events' ), |
|
192 | + 'label' => __('Events', 'google-calendar-events'), |
|
193 | 193 | 'target' => 'events-settings-panel', |
194 | - 'class' => array( 'active' ), |
|
194 | + 'class' => array('active'), |
|
195 | 195 | 'icon' => 'simcal-icon-event', |
196 | 196 | ), |
197 | 197 | 'calendar' => array( |
198 | - 'label' => __( 'Appearance', 'google-calendar-events' ), |
|
198 | + 'label' => __('Appearance', 'google-calendar-events'), |
|
199 | 199 | 'target' => 'calendar-settings-panel', |
200 | 200 | 'class' => array(), |
201 | 201 | 'icon' => 'simcal-icon-calendar', |
202 | 202 | ), |
203 | - ), $post->ID ); |
|
203 | + ), $post->ID); |
|
204 | 204 | |
205 | 205 | // Always keep advanced tab as the last one. |
206 | 206 | $tabs['advanced'] = array( |
207 | - 'label' => __( 'Advanced', 'google-calendar-events' ), |
|
207 | + 'label' => __('Advanced', 'google-calendar-events'), |
|
208 | 208 | 'target' => 'advanced-settings-panel', |
209 | 209 | 'class' => array(), |
210 | 210 | 'icon' => 'simcal-icon-settings', |
211 | 211 | ); |
212 | 212 | |
213 | 213 | // Output the tabs as list items. |
214 | - foreach ( $tabs as $key => $tab ) { |
|
214 | + foreach ($tabs as $key => $tab) { |
|
215 | 215 | |
216 | - if ( isset( $tab['target'] ) && isset( $tab['label'] ) ) { |
|
216 | + if (isset($tab['target']) && isset($tab['label'])) { |
|
217 | 217 | |
218 | 218 | $icon = $tab['icon'] ? $tab['icon'] : 'simcal-icon-panel'; |
219 | 219 | $class = $tab['class'] ? $tab['class'] : array(); |
220 | 220 | |
221 | - echo '<li class="' . $key . '-settings ' . $key . '-tab ' . implode( ' ', $class ) . '" data-tab="' . $key . '">'; |
|
222 | - echo '<a href="#' . $tab['target'] . '"><i class="' . $icon . '" ></i> <span>' . esc_html( $tab['label'] ) . '</span></a>'; |
|
221 | + echo '<li class="'.$key.'-settings '.$key.'-tab '.implode(' ', $class).'" data-tab="'.$key.'">'; |
|
222 | + echo '<a href="#'.$tab['target'].'"><i class="'.$icon.'" ></i> <span>'.esc_html($tab['label']).'</span></a>'; |
|
223 | 223 | echo '</li>'; |
224 | 224 | } |
225 | 225 | } |
@@ -233,22 +233,22 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @param \WP_Post $post |
235 | 235 | */ |
236 | - private static function events_settings_panel( $post ) { |
|
236 | + private static function events_settings_panel($post) { |
|
237 | 237 | |
238 | 238 | ?> |
239 | 239 | <table> |
240 | 240 | <thead> |
241 | - <tr><th colspan="2"><?php _e( 'Events setting', 'google-calendar-events' ); ?></th></tr> |
|
241 | + <tr><th colspan="2"><?php _e('Events setting', 'google-calendar-events'); ?></th></tr> |
|
242 | 242 | </thead> |
243 | 243 | <tbody class="simcal-panel-section simcal-panel-section-events-range"> |
244 | 244 | <tr class="simcal-panel-field"> |
245 | - <th><label for="_calendar_begins"><?php _e( 'Calendar start', 'google-calendar-events' ); ?></label></th> |
|
245 | + <th><label for="_calendar_begins"><?php _e('Calendar start', 'google-calendar-events'); ?></label></th> |
|
246 | 246 | <td> |
247 | 247 | <?php |
248 | 248 | |
249 | - $calendar_begins = esc_attr( get_post_meta( $post->ID, '_calendar_begins', true ) ); |
|
250 | - $calendar_begins_nth = max( absint( get_post_meta( $post->ID, '_calendar_begins_nth', true ) ), 1 ); |
|
251 | - $calendar_begins_nth_show = in_array( $calendar_begins, array( |
|
249 | + $calendar_begins = esc_attr(get_post_meta($post->ID, '_calendar_begins', true)); |
|
250 | + $calendar_begins_nth = max(absint(get_post_meta($post->ID, '_calendar_begins_nth', true)), 1); |
|
251 | + $calendar_begins_nth_show = in_array($calendar_begins, array( |
|
252 | 252 | 'days_before', |
253 | 253 | 'days_after', |
254 | 254 | 'weeks_before', |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | 'months_after', |
258 | 258 | 'years_before', |
259 | 259 | 'years_after', |
260 | - ) ); |
|
260 | + )); |
|
261 | 261 | |
262 | - simcal_print_field( array( |
|
262 | + simcal_print_field(array( |
|
263 | 263 | 'type' => 'standard', |
264 | 264 | 'subtype' => 'number', |
265 | 265 | 'name' => '_calendar_begins_nth', |
266 | 266 | 'id' => '_calendar_begins_nth', |
267 | - 'value' => strval( $calendar_begins_nth ), |
|
267 | + 'value' => strval($calendar_begins_nth), |
|
268 | 268 | 'attributes' => array( |
269 | 269 | 'min' => '1', |
270 | 270 | ), |
@@ -272,97 +272,97 @@ discard block |
||
272 | 272 | 'simcal-field-inline', |
273 | 273 | 'simcal-field-tiny', |
274 | 274 | ), |
275 | - 'style' => ! $calendar_begins_nth_show ? array( 'display' => 'none' ) : '', |
|
276 | - ) ); |
|
275 | + 'style' => ! $calendar_begins_nth_show ? array('display' => 'none') : '', |
|
276 | + )); |
|
277 | 277 | |
278 | 278 | ?> |
279 | 279 | <select name="_calendar_begins" |
280 | 280 | id="_calendar_begins" |
281 | 281 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
282 | - <optgroup label="<?php _e( 'Days', 'google-calendar-events' ); ?>"> |
|
282 | + <optgroup label="<?php _e('Days', 'google-calendar-events'); ?>"> |
|
283 | 283 | <option value="today" |
284 | 284 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
285 | - <?php selected( 'today', $calendar_begins, true ); ?>><?php _e( 'Today', 'google-calendar-events' ); ?></option> |
|
285 | + <?php selected('today', $calendar_begins, true); ?>><?php _e('Today', 'google-calendar-events'); ?></option> |
|
286 | 286 | <option value="now" |
287 | 287 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
288 | - <?php selected( 'now', $calendar_begins, true ); ?>><?php _e( 'Now', 'google-calendar-events' ); ?></option> |
|
288 | + <?php selected('now', $calendar_begins, true); ?>><?php _e('Now', 'google-calendar-events'); ?></option> |
|
289 | 289 | <option value="days_before" |
290 | 290 | data-hide-field="_calendar_begins_custom_date" |
291 | - data-show-field="_calendar_begins_nth" <?php selected( 'days_before', $calendar_begins, true ); ?>><?php _e( 'Day(s) before today', 'google-calendar-events' ); ?></option> |
|
291 | + data-show-field="_calendar_begins_nth" <?php selected('days_before', $calendar_begins, true); ?>><?php _e('Day(s) before today', 'google-calendar-events'); ?></option> |
|
292 | 292 | <option value="days_after" |
293 | 293 | data-hide-field="_calendar_begins_custom_date" |
294 | - data-show-field="_calendar_begins_nth" <?php selected( 'days_after', $calendar_begins, true ); ?>><?php _e( 'Day(s) after today', 'google-calendar-events' ); ?></option> |
|
294 | + data-show-field="_calendar_begins_nth" <?php selected('days_after', $calendar_begins, true); ?>><?php _e('Day(s) after today', 'google-calendar-events'); ?></option> |
|
295 | 295 | </optgroup> |
296 | - <optgroup label="<?php _e( 'Weeks', 'google-calendar-events' ); ?>"> |
|
296 | + <optgroup label="<?php _e('Weeks', 'google-calendar-events'); ?>"> |
|
297 | 297 | <option value="this_week" |
298 | 298 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
299 | - <?php selected( 'this_week', $calendar_begins, true ); ?>><?php _e( 'This week', 'google-calendar-events' ); ?></option> |
|
299 | + <?php selected('this_week', $calendar_begins, true); ?>><?php _e('This week', 'google-calendar-events'); ?></option> |
|
300 | 300 | <option value="weeks_before" |
301 | 301 | data-hide-field="_calendar_begins_custom_date" |
302 | - data-show-field="_calendar_begins_nth" <?php selected( 'weeks_before', $calendar_begins, true ); ?>><?php _e( 'Week(s) before current', 'google-calendar-events' ); ?></option> |
|
302 | + data-show-field="_calendar_begins_nth" <?php selected('weeks_before', $calendar_begins, true); ?>><?php _e('Week(s) before current', 'google-calendar-events'); ?></option> |
|
303 | 303 | <option value="weeks_after" |
304 | 304 | data-hide-field="_calendar_begins_custom_date" |
305 | - data-show-field="_calendar_begins_nth" <?php selected( 'weeks_after', $calendar_begins, true ); ?>><?php _e( 'Week(s) after current', 'google-calendar-events' ); ?></option> |
|
305 | + data-show-field="_calendar_begins_nth" <?php selected('weeks_after', $calendar_begins, true); ?>><?php _e('Week(s) after current', 'google-calendar-events'); ?></option> |
|
306 | 306 | </optgroup> |
307 | - <optgroup label="<?php _e( 'Months', 'google-calendar-events' ); ?>"> |
|
307 | + <optgroup label="<?php _e('Months', 'google-calendar-events'); ?>"> |
|
308 | 308 | <option value="this_month" |
309 | 309 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
310 | - <?php selected( 'this_month', $calendar_begins, true ); ?>><?php _e( 'This month', 'google-calendar-events' ); ?></option> |
|
310 | + <?php selected('this_month', $calendar_begins, true); ?>><?php _e('This month', 'google-calendar-events'); ?></option> |
|
311 | 311 | <option value="months_before" |
312 | 312 | data-hide-field="_calendar_begins_custom_date" |
313 | - data-show-field="_calendar_begins_nth" <?php selected( 'months_before', $calendar_begins, true ); ?>><?php _e( 'Month(s) before current', 'google-calendar-events' ); ?></option> |
|
313 | + data-show-field="_calendar_begins_nth" <?php selected('months_before', $calendar_begins, true); ?>><?php _e('Month(s) before current', 'google-calendar-events'); ?></option> |
|
314 | 314 | <option value="months_after" |
315 | 315 | data-hide-field="_calendar_begins_custom_date" |
316 | - data-show-field="_calendar_begins_nth" <?php selected( 'months_after', $calendar_begins, true ); ?>><?php _e( 'Month(s) after current', 'google-calendar-events' ); ?></option> |
|
316 | + data-show-field="_calendar_begins_nth" <?php selected('months_after', $calendar_begins, true); ?>><?php _e('Month(s) after current', 'google-calendar-events'); ?></option> |
|
317 | 317 | </optgroup> |
318 | - <optgroup label="<?php _e( 'Years', 'google-calendar-events' ); ?>"> |
|
318 | + <optgroup label="<?php _e('Years', 'google-calendar-events'); ?>"> |
|
319 | 319 | <option value="this_year" |
320 | 320 | data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth" |
321 | - <?php selected( 'this_year', $calendar_begins, true ); ?>><?php _e( 'This year', 'google-calendar-events' ); ?></option> |
|
321 | + <?php selected('this_year', $calendar_begins, true); ?>><?php _e('This year', 'google-calendar-events'); ?></option> |
|
322 | 322 | <option value="years_before" |
323 | - data-show-field="_calendar_begins_nth" <?php selected( 'years_before', $calendar_begins, true ); ?>><?php _e( 'Year(s) before current', 'google-calendar-events' ); ?></option> |
|
323 | + data-show-field="_calendar_begins_nth" <?php selected('years_before', $calendar_begins, true); ?>><?php _e('Year(s) before current', 'google-calendar-events'); ?></option> |
|
324 | 324 | <option value="years_after" |
325 | 325 | data-hide-field="_calendar_begins_custom_date" |
326 | - data-show-field="_calendar_begins_nth" <?php selected( 'years_after', $calendar_begins, true ); ?>><?php _e( 'Year(s) after current', 'google-calendar-events' ); ?></option> |
|
326 | + data-show-field="_calendar_begins_nth" <?php selected('years_after', $calendar_begins, true); ?>><?php _e('Year(s) after current', 'google-calendar-events'); ?></option> |
|
327 | 327 | </optgroup> |
328 | - <optgroup label="<?php _e( 'Other', 'google-calendar-events' ); ?>"> |
|
328 | + <optgroup label="<?php _e('Other', 'google-calendar-events'); ?>"> |
|
329 | 329 | <option value="custom_date" |
330 | 330 | data-hide-field="_calendar_begins_nth" |
331 | - data-show-field="_calendar_begins_custom_date" <?php selected( 'custom_date', $calendar_begins, true ); ?>><?php _e( 'Specific date', 'google-calendar-events' ); ?></option> |
|
331 | + data-show-field="_calendar_begins_custom_date" <?php selected('custom_date', $calendar_begins, true); ?>><?php _e('Specific date', 'google-calendar-events'); ?></option> |
|
332 | 332 | </optgroup> |
333 | 333 | </select> |
334 | 334 | <?php |
335 | 335 | |
336 | - simcal_print_field( array( |
|
336 | + simcal_print_field(array( |
|
337 | 337 | 'type' => 'date-picker', |
338 | 338 | 'name' => '_calendar_begins_custom_date', |
339 | 339 | 'id' => '_calendar_begins_custom_date', |
340 | - 'value' => get_post_meta( $post->ID, '_calendar_begins_custom_date', true ), |
|
340 | + 'value' => get_post_meta($post->ID, '_calendar_begins_custom_date', true), |
|
341 | 341 | 'class' => array( |
342 | 342 | 'simcal-field-inline', |
343 | 343 | ), |
344 | - 'style' => 'custom_date' != $calendar_begins ? array( 'display' => 'none' ) : '', |
|
345 | - ) ); |
|
344 | + 'style' => 'custom_date' != $calendar_begins ? array('display' => 'none') : '', |
|
345 | + )); |
|
346 | 346 | |
347 | 347 | ?> |
348 | 348 | <i class="simcal-icon-help simcal-help-tip" |
349 | - data-tip="<?php _e( 'The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events' ); ?>"></i> |
|
349 | + data-tip="<?php _e('The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events'); ?>"></i> |
|
350 | 350 | </td> |
351 | 351 | </tr> |
352 | 352 | <tr class="simcal-panel-field"> |
353 | - <th><label for="_feed_earliest_event_date"><?php _e( 'Earliest event', 'google-calendar-events' ); ?></label></th> |
|
353 | + <th><label for="_feed_earliest_event_date"><?php _e('Earliest event', 'google-calendar-events'); ?></label></th> |
|
354 | 354 | <td> |
355 | 355 | <?php |
356 | 356 | |
357 | - $earliest_event_saved = get_post_meta( $post->ID, '_feed_earliest_event_date', true ); |
|
358 | - $earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr( $earliest_event_saved ); |
|
357 | + $earliest_event_saved = get_post_meta($post->ID, '_feed_earliest_event_date', true); |
|
358 | + $earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr($earliest_event_saved); |
|
359 | 359 | |
360 | - simcal_print_field( array( |
|
360 | + simcal_print_field(array( |
|
361 | 361 | 'type' => 'standard', |
362 | 362 | 'subtype' => 'number', |
363 | 363 | 'name' => '_feed_earliest_event_date_range', |
364 | 364 | 'id' => '_feed_earliest_event_date_range', |
365 | - 'value' => strval( max( absint( get_post_meta( $post->ID, '_feed_earliest_event_date_range', true ) ), 1 ) ), |
|
365 | + 'value' => strval(max(absint(get_post_meta($post->ID, '_feed_earliest_event_date_range', true)), 1)), |
|
366 | 366 | 'attributes' => array( |
367 | 367 | 'min' => '1', |
368 | 368 | ), |
@@ -370,37 +370,37 @@ discard block |
||
370 | 370 | 'simcal-field-inline', |
371 | 371 | 'simcal-field-tiny', |
372 | 372 | ), |
373 | - 'style' => ( 'now' != $earliest_event ) && ( 'today' != $earliest_event ) ? array( 'display' => 'none' ) : '', |
|
374 | - ) ); |
|
373 | + 'style' => ('now' != $earliest_event) && ('today' != $earliest_event) ? array('display' => 'none') : '', |
|
374 | + )); |
|
375 | 375 | |
376 | 376 | ?> |
377 | 377 | <select name="_feed_earliest_event_date" |
378 | 378 | id="_feed_earliest_event_date" |
379 | 379 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
380 | - <option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Same as start date', 'google-calendar-events' ); ?></option> |
|
381 | - <option value="days_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'days_before', $earliest_event, true ); ?>><?php _e( 'Day(s) before start date', 'google-calendar-events' ); ?></option> |
|
382 | - <option value="weeks_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'weeks_before', $earliest_event, true ); ?>><?php _e( 'Week(s) before start date', 'google-calendar-events' ); ?></option> |
|
383 | - <option value="months_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'months_before', $earliest_event, true ); ?>><?php _e( 'Month(s) before start date', 'google-calendar-events' ); ?></option> |
|
384 | - <option value="years_before" data-show-field="_feed_earliest_event_date_range" <?php selected( 'years_before', $earliest_event, true ); ?>><?php _e( 'Year(s) before start date', 'google-calendar-events' ); ?></option> |
|
380 | + <option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Same as start date', 'google-calendar-events'); ?></option> |
|
381 | + <option value="days_before" data-show-field="_feed_earliest_event_date_range" <?php selected('days_before', $earliest_event, true); ?>><?php _e('Day(s) before start date', 'google-calendar-events'); ?></option> |
|
382 | + <option value="weeks_before" data-show-field="_feed_earliest_event_date_range" <?php selected('weeks_before', $earliest_event, true); ?>><?php _e('Week(s) before start date', 'google-calendar-events'); ?></option> |
|
383 | + <option value="months_before" data-show-field="_feed_earliest_event_date_range" <?php selected('months_before', $earliest_event, true); ?>><?php _e('Month(s) before start date', 'google-calendar-events'); ?></option> |
|
384 | + <option value="years_before" data-show-field="_feed_earliest_event_date_range" <?php selected('years_before', $earliest_event, true); ?>><?php _e('Year(s) before start date', 'google-calendar-events'); ?></option> |
|
385 | 385 | </select> |
386 | 386 | <i class="simcal-icon-help simcal-help-tip" |
387 | - data-tip="<?php _e( 'Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events' ); ?>"></i> |
|
387 | + data-tip="<?php _e('Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events'); ?>"></i> |
|
388 | 388 | </td> |
389 | 389 | </tr> |
390 | 390 | <tr class="simcal-panel-field"> |
391 | - <th><label for="_feed_latest_event_date"><?php _e( 'Latest event', 'google-calendar-events' ); ?></label></th> |
|
391 | + <th><label for="_feed_latest_event_date"><?php _e('Latest event', 'google-calendar-events'); ?></label></th> |
|
392 | 392 | <td> |
393 | 393 | <?php |
394 | 394 | |
395 | - $latest_event_saved = get_post_meta( $post->ID, '_feed_latest_event_date', true ); |
|
396 | - $latest_event = false == $latest_event_saved ? 'years_after' : esc_attr( $latest_event_saved ); |
|
395 | + $latest_event_saved = get_post_meta($post->ID, '_feed_latest_event_date', true); |
|
396 | + $latest_event = false == $latest_event_saved ? 'years_after' : esc_attr($latest_event_saved); |
|
397 | 397 | |
398 | - simcal_print_field( array( |
|
398 | + simcal_print_field(array( |
|
399 | 399 | 'type' => 'standard', |
400 | 400 | 'subtype' => 'number', |
401 | 401 | 'name' => '_feed_latest_event_date_range', |
402 | 402 | 'id' => '_feed_latest_event_date_range', |
403 | - 'value' => strval( max( absint( get_post_meta( $post->ID, '_feed_latest_event_date_range', true ) ), 1 ) ), |
|
403 | + 'value' => strval(max(absint(get_post_meta($post->ID, '_feed_latest_event_date_range', true)), 1)), |
|
404 | 404 | 'attributes' => array( |
405 | 405 | 'min' => '1', |
406 | 406 | ), |
@@ -408,21 +408,21 @@ discard block |
||
408 | 408 | 'simcal-field-inline', |
409 | 409 | 'simcal-field-tiny', |
410 | 410 | ), |
411 | - 'style' => 'indefinite' != $latest_event ? array( 'display' => 'none' ) : '', |
|
412 | - ) ); |
|
411 | + 'style' => 'indefinite' != $latest_event ? array('display' => 'none') : '', |
|
412 | + )); |
|
413 | 413 | |
414 | 414 | ?> |
415 | 415 | <select name="_feed_latest_event_date" |
416 | 416 | id="_feed_latest_event_date" |
417 | 417 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other"> |
418 | - <option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Day end of start date', 'google-calendar-events' ); ?></option> |
|
419 | - <option value="days_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'days_after', $latest_event, true ); ?>><?php _e( 'Day(s) after start date', 'google-calendar-events' ); ?></option> |
|
420 | - <option value="weeks_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'weeks_after', $latest_event, true ); ?>><?php _e( 'Weeks(s) after start date', 'google-calendar-events' ); ?></option> |
|
421 | - <option value="months_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'months_after', $latest_event, true ); ?>><?php _e( 'Month(s) after start date', 'google-calendar-events' ); ?></option> |
|
422 | - <option value="years_after" data-show-field="_feed_latest_event_date_range" <?php selected( 'years_after', $latest_event, true ); ?>><?php _e( 'Year(s) after start date', 'google-calendar-events' ); ?></option> |
|
418 | + <option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Day end of start date', 'google-calendar-events'); ?></option> |
|
419 | + <option value="days_after" data-show-field="_feed_latest_event_date_range" <?php selected('days_after', $latest_event, true); ?>><?php _e('Day(s) after start date', 'google-calendar-events'); ?></option> |
|
420 | + <option value="weeks_after" data-show-field="_feed_latest_event_date_range" <?php selected('weeks_after', $latest_event, true); ?>><?php _e('Weeks(s) after start date', 'google-calendar-events'); ?></option> |
|
421 | + <option value="months_after" data-show-field="_feed_latest_event_date_range" <?php selected('months_after', $latest_event, true); ?>><?php _e('Month(s) after start date', 'google-calendar-events'); ?></option> |
|
422 | + <option value="years_after" data-show-field="_feed_latest_event_date_range" <?php selected('years_after', $latest_event, true); ?>><?php _e('Year(s) after start date', 'google-calendar-events'); ?></option> |
|
423 | 423 | </select> |
424 | 424 | <i class="simcal-icon-help simcal-help-tip" |
425 | - data-tip="<?php _e( 'Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events' ); ?>"></i> |
|
425 | + data-tip="<?php _e('Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events'); ?>"></i> |
|
426 | 426 | </td> |
427 | 427 | </tr> |
428 | 428 | </tbody> |
@@ -439,68 +439,68 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @param \WP_Post $post |
441 | 441 | */ |
442 | - private static function calendar_settings_panel( $post ) { |
|
442 | + private static function calendar_settings_panel($post) { |
|
443 | 443 | |
444 | 444 | ?> |
445 | 445 | <table> |
446 | 446 | <thead> |
447 | - <tr><th colspan="2"><?php _e( 'Miscellaneous', 'google-calendar-events' ); ?></th></tr> |
|
447 | + <tr><th colspan="2"><?php _e('Miscellaneous', 'google-calendar-events'); ?></th></tr> |
|
448 | 448 | </thead> |
449 | 449 | <tbody class="simcal-panel-section"> |
450 | 450 | <tr class="simcal-panel-field"> |
451 | - <th><label for="_calendar_is_static"><?php _e( 'Static calendar', 'google-calendar-events' ); ?></label></th> |
|
451 | + <th><label for="_calendar_is_static"><?php _e('Static calendar', 'google-calendar-events'); ?></label></th> |
|
452 | 452 | <td> |
453 | 453 | <?php |
454 | 454 | |
455 | - $fixed = get_post_meta( $post->ID, '_calendar_is_static', true ); |
|
455 | + $fixed = get_post_meta($post->ID, '_calendar_is_static', true); |
|
456 | 456 | |
457 | - simcal_print_field( array( |
|
457 | + simcal_print_field(array( |
|
458 | 458 | 'type' => 'checkbox', |
459 | 459 | 'name' => '_calendar_is_static', |
460 | 460 | 'id' => '_calendar_is_static', |
461 | - 'tooltip' => __( 'Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events' ), |
|
461 | + 'tooltip' => __('Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events'), |
|
462 | 462 | 'value' => 'yes' == $fixed ? 'yes' : 'no', |
463 | - ) ); |
|
463 | + )); |
|
464 | 464 | |
465 | 465 | ?> |
466 | 466 | </td> |
467 | 467 | </tr> |
468 | 468 | <tr class="simcal-panel-field"> |
469 | - <th><label for="_no_events_message"><?php _e( 'No events message', 'google-calendar-events' ); ?></label></th> |
|
469 | + <th><label for="_no_events_message"><?php _e('No events message', 'google-calendar-events'); ?></label></th> |
|
470 | 470 | <td> |
471 | 471 | <?php |
472 | 472 | |
473 | - simcal_print_field( array( |
|
473 | + simcal_print_field(array( |
|
474 | 474 | 'type' => 'textarea', |
475 | 475 | 'name' => '_no_events_message', |
476 | 476 | 'id' => '_no_events_message', |
477 | - 'tooltip' => __( 'Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events' ), |
|
478 | - 'value' => get_post_meta( $post->ID, '_no_events_message', true ), |
|
479 | - ) ); |
|
477 | + 'tooltip' => __('Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events'), |
|
478 | + 'value' => get_post_meta($post->ID, '_no_events_message', true), |
|
479 | + )); |
|
480 | 480 | |
481 | 481 | ?> |
482 | 482 | </td> |
483 | 483 | </tr> |
484 | 484 | <tr class="simcal-panel-field"> |
485 | - <th><label for="_event_formatting"><?php _e( 'Event Formatting', 'google-calendar-events' ); ?></label></th> |
|
485 | + <th><label for="_event_formatting"><?php _e('Event Formatting', 'google-calendar-events'); ?></label></th> |
|
486 | 486 | <td> |
487 | 487 | <?php |
488 | 488 | |
489 | - $event_formatting = get_post_meta( $post->ID, '_event_formatting', true ); |
|
489 | + $event_formatting = get_post_meta($post->ID, '_event_formatting', true); |
|
490 | 490 | |
491 | - simcal_print_field( array( |
|
491 | + simcal_print_field(array( |
|
492 | 492 | 'type' => 'select', |
493 | 493 | 'name' => '_event_formatting', |
494 | 494 | 'id' => '_event_formatting', |
495 | - 'tooltip' => __( 'How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events' ), |
|
495 | + 'tooltip' => __('How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events'), |
|
496 | 496 | 'value' => $event_formatting, |
497 | 497 | 'default' => 'preserve_linebreaks', |
498 | 498 | 'options' => array( |
499 | - 'preserve_linebreaks' => __( 'Preserve line breaks, auto paragraphs (default)', 'google-calendar-events' ), |
|
500 | - 'no_linebreaks' => __( 'No line breaks, auto paragraphs', 'google-calendar-events' ), |
|
501 | - 'none' => __( 'No line breaks, no auto paragraphs', 'google-calendar-events' ), |
|
499 | + 'preserve_linebreaks' => __('Preserve line breaks, auto paragraphs (default)', 'google-calendar-events'), |
|
500 | + 'no_linebreaks' => __('No line breaks, auto paragraphs', 'google-calendar-events'), |
|
501 | + 'none' => __('No line breaks, no auto paragraphs', 'google-calendar-events'), |
|
502 | 502 | ), |
503 | - ) ); |
|
503 | + )); |
|
504 | 504 | |
505 | 505 | ?> |
506 | 506 | </td> |
@@ -519,28 +519,28 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @param \WP_Post $post |
521 | 521 | */ |
522 | - private static function advanced_settings_panel( $post ) { |
|
522 | + private static function advanced_settings_panel($post) { |
|
523 | 523 | |
524 | 524 | ?> |
525 | 525 | <table> |
526 | 526 | <thead> |
527 | - <tr><th colspan="2"><?php _e( 'Date and Time', 'google-calendar-events' ); ?></th></tr> |
|
527 | + <tr><th colspan="2"><?php _e('Date and Time', 'google-calendar-events'); ?></th></tr> |
|
528 | 528 | </thead> |
529 | 529 | <tbody class="simcal-panel-section simcal-panel-datetime-formatting"> |
530 | 530 | <tr class="simcal-panel-field"> |
531 | - <th><label for="_calendar_timezone_setting"><?php _e( 'Timezone', 'google-calendar-events' ); ?></label></th> |
|
531 | + <th><label for="_calendar_timezone_setting"><?php _e('Timezone', 'google-calendar-events'); ?></label></th> |
|
532 | 532 | <td> |
533 | 533 | <?php |
534 | 534 | |
535 | 535 | $timezone_wordpress = simcal_get_wp_timezone(); |
536 | 536 | $timezone_default = $timezone_wordpress ? $timezone_wordpress : 'UTC'; |
537 | - $timezone_setting = esc_attr( get_post_meta( $post->ID, '_feed_timezone_setting', true ) ); |
|
538 | - $timezone = esc_attr( get_post_meta( $post->ID, '_feed_timezone', true ) ); |
|
537 | + $timezone_setting = esc_attr(get_post_meta($post->ID, '_feed_timezone_setting', true)); |
|
538 | + $timezone = esc_attr(get_post_meta($post->ID, '_feed_timezone', true)); |
|
539 | 539 | $timezone = $timezone ? $timezone : $timezone_default; |
540 | - $show_use_calendar = isset( simcal_get_feed( $post )->type ); |
|
540 | + $show_use_calendar = isset(simcal_get_feed($post)->type); |
|
541 | 541 | |
542 | - if ( $show_use_calendar ) { |
|
543 | - $show_use_calendar = ( simcal_get_feed( $post )->type !== 'grouped-calendars' ? 1 : 0 ); |
|
542 | + if ($show_use_calendar) { |
|
543 | + $show_use_calendar = (simcal_get_feed($post)->type !== 'grouped-calendars' ? 1 : 0); |
|
544 | 544 | } else { |
545 | 545 | $show_use_calendar = true; |
546 | 546 | } |
@@ -550,56 +550,56 @@ discard block |
||
550 | 550 | id="_feed_timezone_setting" |
551 | 551 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other" |
552 | 552 | data-show-field-on-choice="true"> |
553 | - <option value="use_site" <?php selected( 'use_site', $timezone_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', $timezone_default ); ?></option> |
|
554 | - <?php if ( $show_use_calendar ) { ?> |
|
555 | - <option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected( 'use_calendar', $timezone_setting, true ); ?>><?php _ex( 'Events source default', 'Use the calendar default setting', 'google-calendar-events' ); ?></option> |
|
553 | + <option value="use_site" <?php selected('use_site', $timezone_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', $timezone_default); ?></option> |
|
554 | + <?php if ($show_use_calendar) { ?> |
|
555 | + <option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected('use_calendar', $timezone_setting, true); ?>><?php _ex('Events source default', 'Use the calendar default setting', 'google-calendar-events'); ?></option> |
|
556 | 556 | <?php } ?> |
557 | - <option value="use_custom" data-show-field="_feed_timezone" <?php selected( 'use_custom', $timezone_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
557 | + <option value="use_custom" data-show-field="_feed_timezone" <?php selected('use_custom', $timezone_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
558 | 558 | </select> |
559 | 559 | <select name="_feed_timezone" |
560 | 560 | id="_feed_timezone" |
561 | 561 | class="simcal-field simcal-field-select simcal-field-inline" |
562 | 562 | <?php echo 'use_custom' != $timezone_setting ? 'style="display: none;"' : ''; ?>> |
563 | - <?php echo wp_timezone_choice( $timezone ); ?> |
|
563 | + <?php echo wp_timezone_choice($timezone); ?> |
|
564 | 564 | </select> |
565 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Using a different timezone may alter the date and time display of your calendar events. It is recommended to keep the calendar default timezone.', 'google-calendar-events' ); ?>"></i> |
|
565 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Using a different timezone may alter the date and time display of your calendar events. It is recommended to keep the calendar default timezone.', 'google-calendar-events'); ?>"></i> |
|
566 | 566 | <p id="_use_calendar_warning" style="display: none;" class="simcal-field"> |
567 | - <?php printf( __( '<strong>Warning:</strong> Using this option can return unexpected results if you have specified <a href="%s" target="_blank">event level</a> timezones.', 'google-calendar-events' ), 'http://docs.simplecalendar.io/timezone-settings/' ); ?> |
|
567 | + <?php printf(__('<strong>Warning:</strong> Using this option can return unexpected results if you have specified <a href="%s" target="_blank">event level</a> timezones.', 'google-calendar-events'), 'http://docs.simplecalendar.io/timezone-settings/'); ?> |
|
568 | 568 | </p> |
569 | 569 | </td> |
570 | 570 | </tr> |
571 | 571 | <tr class="simcal-panel-field"> |
572 | - <th><label for="_calendar_date_format_setting"><?php _e( 'Date format', 'google-calendar-events' ); ?></label></th> |
|
572 | + <th><label for="_calendar_date_format_setting"><?php _e('Date format', 'google-calendar-events'); ?></label></th> |
|
573 | 573 | <td> |
574 | 574 | <?php |
575 | 575 | |
576 | - $date_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_setting', true ) ); |
|
577 | - $date_format_default = esc_attr( get_option( 'date_format' ) ); |
|
578 | - $date_format = esc_attr( get_post_meta( $post->ID, '_calendar_date_format', true ) ); |
|
579 | - $date_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_php', true ) ); |
|
576 | + $date_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_date_format_setting', true)); |
|
577 | + $date_format_default = esc_attr(get_option('date_format')); |
|
578 | + $date_format = esc_attr(get_post_meta($post->ID, '_calendar_date_format', true)); |
|
579 | + $date_format_php = esc_attr(get_post_meta($post->ID, '_calendar_date_format_php', true)); |
|
580 | 580 | $date_format_php = $date_format_php ? $date_format_php : $date_format_default; |
581 | 581 | |
582 | 582 | ?> |
583 | 583 | <select name="_calendar_date_format_setting" |
584 | 584 | id="_calendar_date_format_setting" |
585 | 585 | class="simcal-field simcal-field-select simcal-field-show-other"> |
586 | - <option value="use_site" data-show-field="_calendar_date_format_default" <?php selected( 'use_site', $date_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option> |
|
587 | - <option value="use_custom" data-show-field="_calendar_date_format" <?php selected( 'use_custom', $date_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
588 | - <option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected( 'use_custom_php', $date_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option> |
|
586 | + <option value="use_site" data-show-field="_calendar_date_format_default" <?php selected('use_site', $date_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option> |
|
587 | + <option value="use_custom" data-show-field="_calendar_date_format" <?php selected('use_custom', $date_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
588 | + <option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected('use_custom_php', $date_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option> |
|
589 | 589 | </select> |
590 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i> |
|
590 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i> |
|
591 | 591 | <p id="_calendar_date_format_default" style="<?php echo $date_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
592 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
593 | - <code><?php echo date_i18n( $date_format_default, time() ); ?></code> |
|
592 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
593 | + <code><?php echo date_i18n($date_format_default, time()); ?></code> |
|
594 | 594 | </p> |
595 | - <?php simcal_print_field( array( |
|
595 | + <?php simcal_print_field(array( |
|
596 | 596 | 'type' => 'datetime-format', |
597 | 597 | 'subtype' => 'date', |
598 | 598 | 'name' => '_calendar_date_format', |
599 | 599 | 'id' => '_calendar_date_format', |
600 | 600 | 'value' => $date_format, |
601 | - 'style' => $date_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
602 | - ) ); ?> |
|
601 | + 'style' => $date_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
602 | + )); ?> |
|
603 | 603 | <div class="simcal-field-datetime-format-php" id="_calendar_date_format_php_field" style="<?php echo $date_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
604 | 604 | <br> |
605 | 605 | <label for="_calendar_date_format_php"> |
@@ -608,70 +608,70 @@ discard block |
||
608 | 608 | id="_calendar_date_format_php" |
609 | 609 | class="simcal-field simcal-field-text simcal-field-small" |
610 | 610 | value="<?php echo $date_format_php; ?>" /> |
611 | - <?php printf( __( 'Enter a date format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?> |
|
611 | + <?php printf(__('Enter a date format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> |
|
612 | 612 | </label> |
613 | 613 | <p> |
614 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
615 | - <code><?php echo date_i18n( $date_format_php, time() ); ?></code> |
|
614 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
615 | + <code><?php echo date_i18n($date_format_php, time()); ?></code> |
|
616 | 616 | </p> |
617 | 617 | </div> |
618 | 618 | </td> |
619 | 619 | </tr> |
620 | 620 | <tr class="simcal-panel-field"> |
621 | - <th><label for="_calendar_datetime_separator"><?php _e( 'Separator', 'google-calendar-events' ); ?></label></th> |
|
621 | + <th><label for="_calendar_datetime_separator"><?php _e('Separator', 'google-calendar-events'); ?></label></th> |
|
622 | 622 | <td> |
623 | 623 | <?php |
624 | 624 | |
625 | - $separator = get_post_meta( $post->ID, '_calendar_datetime_separator', true ); |
|
625 | + $separator = get_post_meta($post->ID, '_calendar_datetime_separator', true); |
|
626 | 626 | $separator = false == $separator ? '@' : $separator; |
627 | 627 | |
628 | - simcal_print_field( array( |
|
628 | + simcal_print_field(array( |
|
629 | 629 | 'type' => 'standard', |
630 | 630 | 'subtype' => 'text', |
631 | 631 | 'name' => '_calendar_datetime_separator', |
632 | 632 | 'id' => '_calendar_datetime_separator', |
633 | 633 | 'value' => $separator, |
634 | - 'tooltip' => __( 'Used to divide date and time when both are shown.', 'google-calendar-events' ), |
|
634 | + 'tooltip' => __('Used to divide date and time when both are shown.', 'google-calendar-events'), |
|
635 | 635 | 'class' => array( |
636 | 636 | 'simcal-field-tiny', |
637 | 637 | ), |
638 | - ) ); |
|
638 | + )); |
|
639 | 639 | |
640 | 640 | ?> |
641 | 641 | </td> |
642 | 642 | </tr> |
643 | 643 | <tr class="simcal-panel-field"> |
644 | - <th><label for="_calendar_time_format_setting"><?php _e( 'Time format', 'google-calendar-events' ); ?></label></th> |
|
644 | + <th><label for="_calendar_time_format_setting"><?php _e('Time format', 'google-calendar-events'); ?></label></th> |
|
645 | 645 | <td> |
646 | 646 | <?php |
647 | 647 | |
648 | - $time_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_setting', true ) ); |
|
649 | - $time_format_default = esc_attr( get_option( 'time_format' ) ); |
|
650 | - $time_format = esc_attr( get_post_meta( $post->ID, '_calendar_time_format', true ) ); |
|
651 | - $time_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_php', true ) ); |
|
648 | + $time_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_time_format_setting', true)); |
|
649 | + $time_format_default = esc_attr(get_option('time_format')); |
|
650 | + $time_format = esc_attr(get_post_meta($post->ID, '_calendar_time_format', true)); |
|
651 | + $time_format_php = esc_attr(get_post_meta($post->ID, '_calendar_time_format_php', true)); |
|
652 | 652 | $time_format_php = $time_format_php ? $time_format_php : $time_format_default; |
653 | 653 | |
654 | 654 | ?> |
655 | 655 | <select name="_calendar_time_format_setting" |
656 | 656 | id="_calendar_time_format_setting" |
657 | 657 | class="simcal-field simcal-field-select simcal-field-show-other"> |
658 | - <option value="use_site" data-show-field="_calendar_time_format_default" <?php selected( 'use_site', $time_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option> |
|
659 | - <option value="use_custom" data-show-field="_calendar_time_format" <?php selected( 'use_custom', $time_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
660 | - <option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected( 'use_custom_php', $time_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option> |
|
658 | + <option value="use_site" data-show-field="_calendar_time_format_default" <?php selected('use_site', $time_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option> |
|
659 | + <option value="use_custom" data-show-field="_calendar_time_format" <?php selected('use_custom', $time_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
660 | + <option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected('use_custom_php', $time_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option> |
|
661 | 661 | </select> |
662 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i> |
|
662 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i> |
|
663 | 663 | <p id="_calendar_time_format_default" style="<?php echo $time_format_setting != 'use_site' ? 'display: none;' : ''; ?>"> |
664 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
665 | - <code><?php echo date_i18n( $time_format_default, time() ); ?></code> |
|
664 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
665 | + <code><?php echo date_i18n($time_format_default, time()); ?></code> |
|
666 | 666 | </p> |
667 | - <?php simcal_print_field( array( |
|
667 | + <?php simcal_print_field(array( |
|
668 | 668 | 'type' => 'datetime-format', |
669 | 669 | 'subtype' => 'time', |
670 | 670 | 'name' => '_calendar_time_format', |
671 | 671 | 'id' => '_calendar_time_format', |
672 | 672 | 'value' => $time_format, |
673 | - 'style' => $time_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '', |
|
674 | - ) ); ?> |
|
673 | + 'style' => $time_format_setting != 'use_custom' ? array('display' => 'none') : '', |
|
674 | + )); ?> |
|
675 | 675 | <div class="simcal-field-datetime-format-php" id="_calendar_time_format_php_field" style="<?php echo $time_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>"> |
676 | 676 | <br> |
677 | 677 | <label for="_calendar_date_format_php"> |
@@ -680,24 +680,24 @@ discard block |
||
680 | 680 | id="_calendar_time_format_php" |
681 | 681 | class="simcal-field simcal-field-text simcal-field-small" |
682 | 682 | value="<?php echo $time_format_php; ?>"/> |
683 | - <?php printf( __( 'Enter a time format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?> |
|
683 | + <?php printf(__('Enter a time format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?> |
|
684 | 684 | </label> |
685 | 685 | <p> |
686 | - <em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em> |
|
687 | - <code><?php echo date_i18n( $time_format_php, time() ); ?></code> |
|
686 | + <em><?php _e('Preview', 'google-calendar-events') ?>:</em> |
|
687 | + <code><?php echo date_i18n($time_format_php, time()); ?></code> |
|
688 | 688 | </p> |
689 | 689 | </div> |
690 | 690 | </td> |
691 | 691 | </tr> |
692 | 692 | <tr class="simcal-panel-field"> |
693 | - <th><label for="_calendar_week_starts_on_setting"><?php _e( 'Week starts on', 'google-calendar-events' ); ?></label></th> |
|
693 | + <th><label for="_calendar_week_starts_on_setting"><?php _e('Week starts on', 'google-calendar-events'); ?></label></th> |
|
694 | 694 | <td> |
695 | 695 | <?php |
696 | 696 | |
697 | - $week_starts_setting = esc_attr( get_post_meta( $post->ID, '_calendar_week_starts_on_setting', true ) ); |
|
698 | - $week_starts_default = esc_attr( get_option( 'start_of_week' ) ); |
|
699 | - $week_starts = intval( get_post_meta( $post->ID, '_calendar_week_starts_on', true ) ); |
|
700 | - $week_starts = is_numeric( $week_starts ) ? strval( $week_starts ) : $week_starts_default; |
|
697 | + $week_starts_setting = esc_attr(get_post_meta($post->ID, '_calendar_week_starts_on_setting', true)); |
|
698 | + $week_starts_default = esc_attr(get_option('start_of_week')); |
|
699 | + $week_starts = intval(get_post_meta($post->ID, '_calendar_week_starts_on', true)); |
|
700 | + $week_starts = is_numeric($week_starts) ? strval($week_starts) : $week_starts_default; |
|
701 | 701 | |
702 | 702 | ?> |
703 | 703 | <select |
@@ -705,39 +705,39 @@ discard block |
||
705 | 705 | id="_calendar_week_starts_on_setting" |
706 | 706 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next" |
707 | 707 | data-show-next-if-value="use_custom"> |
708 | - <option value="use_site" <?php selected( 'use_site', $week_starts_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', date_i18n( 'l', strtotime( "Sunday + $week_starts_default Days" ) ) ); ?></option> |
|
709 | - <option value="use_custom" <?php selected( 'use_custom', $week_starts_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option> |
|
708 | + <option value="use_site" <?php selected('use_site', $week_starts_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', date_i18n('l', strtotime("Sunday + $week_starts_default Days"))); ?></option> |
|
709 | + <option value="use_custom" <?php selected('use_custom', $week_starts_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option> |
|
710 | 710 | </select> |
711 | 711 | <select |
712 | 712 | name="_calendar_week_starts_on" |
713 | 713 | id="_calendar_week_starts_on" |
714 | 714 | class="simcal-field simcal-field-select simcal-field-inline" |
715 | 715 | <?php echo 'use_custom' != $week_starts_setting ? 'style="display: none;"' : ''; ?>> |
716 | - <?php $day_names = simcal_get_calendar_names_i18n( 'day', 'full' ); ?> |
|
717 | - <?php for ( $i = 0; $i <= 6; $i++ ) : ?> |
|
718 | - <option value="<?php echo $i; ?>" <?php selected( $i, $week_starts, true ); ?>><?php echo $day_names[ $i ]; ?></option> |
|
716 | + <?php $day_names = simcal_get_calendar_names_i18n('day', 'full'); ?> |
|
717 | + <?php for ($i = 0; $i <= 6; $i++) : ?> |
|
718 | + <option value="<?php echo $i; ?>" <?php selected($i, $week_starts, true); ?>><?php echo $day_names[$i]; ?></option> |
|
719 | 719 | <?php endfor; ?> |
720 | 720 | </select> |
721 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events' ); ?>"></i> |
|
721 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events'); ?>"></i> |
|
722 | 722 | </td> |
723 | 723 | </tr> |
724 | 724 | </tbody> |
725 | 725 | </table> |
726 | 726 | <table> |
727 | 727 | <thead> |
728 | - <tr><th colspan="2"><?php _e( 'Cache', 'google-calendar-events' ); ?></th></tr> |
|
728 | + <tr><th colspan="2"><?php _e('Cache', 'google-calendar-events'); ?></th></tr> |
|
729 | 729 | </thead> |
730 | 730 | <tbody class="simcal-panel-section simcal-panel-section-cache"> |
731 | 731 | <?php |
732 | 732 | |
733 | - $cache_freq = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_amount', true ) ); |
|
734 | - $cache_unit = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_unit', true ) ); |
|
735 | - $cache_freq = is_int( $cache_freq ) && $cache_freq >= 0 ? $cache_freq : '2'; |
|
733 | + $cache_freq = esc_attr(get_post_meta($post->ID, '_feed_cache_user_amount', true)); |
|
734 | + $cache_unit = esc_attr(get_post_meta($post->ID, '_feed_cache_user_unit', true)); |
|
735 | + $cache_freq = is_int($cache_freq) && $cache_freq >= 0 ? $cache_freq : '2'; |
|
736 | 736 | $cache_unit = $cache_unit ? $cache_unit : '3600'; |
737 | 737 | |
738 | 738 | ?> |
739 | 739 | <tr class="simcal-panel-field"> |
740 | - <th><label for="_feed_cache_user_amount"><?php _ex( 'Refresh interval', 'Cache maximum interval', 'google-calendar-events' ); ?></label></th> |
|
740 | + <th><label for="_feed_cache_user_amount"><?php _ex('Refresh interval', 'Cache maximum interval', 'google-calendar-events'); ?></label></th> |
|
741 | 741 | <td> |
742 | 742 | <input type="number" |
743 | 743 | name="_feed_cache_user_amount" |
@@ -748,12 +748,12 @@ discard block |
||
748 | 748 | <select name="_feed_cache_user_unit" |
749 | 749 | id="_feed_cache_user_unit" |
750 | 750 | class="simcal-field simcalfield-select simcal-field-inline"> |
751 | - <option value="60" <?php selected( '60', $cache_unit, true ); ?>><?php _e( 'Minute(s)', 'google-calendar-events' ); ?></option> |
|
752 | - <option value="3600" <?php selected( '3600', $cache_unit, true ); ?>><?php _e( 'Hour(s)', 'google-calendar-events' ); ?></option> |
|
753 | - <option value="86400" <?php selected( '86400', $cache_unit, true ); ?>><?php _e( 'Day(s)', 'google-calendar-events' ); ?></option> |
|
754 | - <option value="604800" <?php selected( '604800', $cache_unit, true ); ?>><?php _e( 'Week(s)', 'google-calendar-events' ); ?></option> |
|
751 | + <option value="60" <?php selected('60', $cache_unit, true); ?>><?php _e('Minute(s)', 'google-calendar-events'); ?></option> |
|
752 | + <option value="3600" <?php selected('3600', $cache_unit, true); ?>><?php _e('Hour(s)', 'google-calendar-events'); ?></option> |
|
753 | + <option value="86400" <?php selected('86400', $cache_unit, true); ?>><?php _e('Day(s)', 'google-calendar-events'); ?></option> |
|
754 | + <option value="604800" <?php selected('604800', $cache_unit, true); ?>><?php _e('Week(s)', 'google-calendar-events'); ?></option> |
|
755 | 755 | </select> |
756 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events' ); ?>"></i> |
|
756 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events'); ?>"></i> |
|
757 | 757 | </td> |
758 | 758 | </tr> |
759 | 759 | </tbody> |
@@ -772,21 +772,21 @@ discard block |
||
772 | 772 | * |
773 | 773 | * @return void |
774 | 774 | */ |
775 | - public static function print_panel_fields( $array, $post_id ) { |
|
775 | + public static function print_panel_fields($array, $post_id) { |
|
776 | 776 | |
777 | - foreach ( $array as $section => $fields ) : |
|
777 | + foreach ($array as $section => $fields) : |
|
778 | 778 | |
779 | - if ( $fields && is_array( $fields ) ) : |
|
779 | + if ($fields && is_array($fields)) : |
|
780 | 780 | |
781 | 781 | ?> |
782 | - <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr( $section ); ?>"> |
|
783 | - <?php foreach ( $fields as $key => $field ) : |
|
782 | + <tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr($section); ?>"> |
|
783 | + <?php foreach ($fields as $key => $field) : |
|
784 | 784 | |
785 | - $value = get_post_meta( $post_id, $key, true ); |
|
786 | - $field['value'] = $value ? $value : ( isset( $field['default'] ) ? $field['default'] : '' ); |
|
787 | - $the_field = simcal_get_field( $field ); ?> |
|
785 | + $value = get_post_meta($post_id, $key, true); |
|
786 | + $field['value'] = $value ? $value : (isset($field['default']) ? $field['default'] : ''); |
|
787 | + $the_field = simcal_get_field($field); ?> |
|
788 | 788 | |
789 | - <?php if ( $the_field instanceof Field ) : ?> |
|
789 | + <?php if ($the_field instanceof Field) : ?> |
|
790 | 790 | <tr class="simcal-panel-field"> |
791 | 791 | <th><label for="<?php echo $the_field->id ?>"><?php echo $the_field->title; ?></label></th> |
792 | 792 | <td><?php $the_field->html(); ?></td> |
@@ -813,30 +813,30 @@ discard block |
||
813 | 813 | * |
814 | 814 | * @return void |
815 | 815 | */ |
816 | - public static function save( $post_id, $post ) { |
|
816 | + public static function save($post_id, $post) { |
|
817 | 817 | |
818 | 818 | /* ====================== * |
819 | 819 | * Calendar type and view * |
820 | 820 | * ====================== */ |
821 | 821 | |
822 | 822 | // Unlink existing terms for feed type and calendar type. |
823 | - wp_delete_object_term_relationships( $post_id, array( |
|
823 | + wp_delete_object_term_relationships($post_id, array( |
|
824 | 824 | 'calendar_feed', |
825 | 825 | 'calendar_type', |
826 | - ) ); |
|
826 | + )); |
|
827 | 827 | |
828 | 828 | // Set the feed type as term. |
829 | - $feed_type = isset( $_POST['_feed_type'] ) ? sanitize_title( stripslashes( $_POST['_feed_type'] ) ) : apply_filters( 'simcal_default_feed_type', 'google' ); |
|
830 | - wp_set_object_terms( $post_id, $feed_type, 'calendar_feed' ); |
|
829 | + $feed_type = isset($_POST['_feed_type']) ? sanitize_title(stripslashes($_POST['_feed_type'])) : apply_filters('simcal_default_feed_type', 'google'); |
|
830 | + wp_set_object_terms($post_id, $feed_type, 'calendar_feed'); |
|
831 | 831 | |
832 | 832 | // Set the calendar type as a term. |
833 | - $calendar_type = isset( $_POST['_calendar_type'] ) ? sanitize_title( stripslashes( $_POST['_calendar_type'] ) ) : apply_filters( 'simcal_default_calendar_type', 'default-calendar' ); |
|
834 | - wp_set_object_terms( $post_id, $calendar_type, 'calendar_type' ); |
|
833 | + $calendar_type = isset($_POST['_calendar_type']) ? sanitize_title(stripslashes($_POST['_calendar_type'])) : apply_filters('simcal_default_calendar_type', 'default-calendar'); |
|
834 | + wp_set_object_terms($post_id, $calendar_type, 'calendar_type'); |
|
835 | 835 | // Set the calendar type view as post meta. |
836 | - $calendar_view = isset( $_POST['_calendar_view'] ) ? $_POST['_calendar_view'] : ''; |
|
837 | - if ( $calendar_view && is_array( $calendar_view ) ) { |
|
838 | - $views = array_map( 'sanitize_title', $calendar_view ); |
|
839 | - update_post_meta( $post_id, '_calendar_view', $views ); |
|
836 | + $calendar_view = isset($_POST['_calendar_view']) ? $_POST['_calendar_view'] : ''; |
|
837 | + if ($calendar_view && is_array($calendar_view)) { |
|
838 | + $views = array_map('sanitize_title', $calendar_view); |
|
839 | + update_post_meta($post_id, '_calendar_view', $views); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /* ===================== * |
@@ -844,102 +844,102 @@ discard block |
||
844 | 844 | * ===================== */ |
845 | 845 | |
846 | 846 | // Calendar opening. |
847 | - $calendar_begins = isset( $_POST['_calendar_begins'] ) ? sanitize_key( $_POST['_calendar_begins'] ) : 'this_month'; |
|
848 | - update_post_meta( $post_id, '_calendar_begins', $calendar_begins ); |
|
849 | - $calendar_begins_nth = isset( $_POST['_calendar_begins_nth'] ) ? absint( $_POST['_calendar_begins_nth'] ) : 2; |
|
850 | - update_post_meta( $post_id, '_calendar_begins_nth', $calendar_begins_nth ); |
|
851 | - $calendar_begins_custom_date = isset( $_POST['_calendar_begins_custom_date'] ) ? sanitize_title( $_POST['_calendar_begins_custom_date'] ) : ''; |
|
852 | - update_post_meta( $post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date ); |
|
847 | + $calendar_begins = isset($_POST['_calendar_begins']) ? sanitize_key($_POST['_calendar_begins']) : 'this_month'; |
|
848 | + update_post_meta($post_id, '_calendar_begins', $calendar_begins); |
|
849 | + $calendar_begins_nth = isset($_POST['_calendar_begins_nth']) ? absint($_POST['_calendar_begins_nth']) : 2; |
|
850 | + update_post_meta($post_id, '_calendar_begins_nth', $calendar_begins_nth); |
|
851 | + $calendar_begins_custom_date = isset($_POST['_calendar_begins_custom_date']) ? sanitize_title($_POST['_calendar_begins_custom_date']) : ''; |
|
852 | + update_post_meta($post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date); |
|
853 | 853 | |
854 | 854 | // Feed earliest events date. |
855 | - $earliest_events = isset( $_POST['_feed_earliest_event_date'] ) ? sanitize_key( $_POST['_feed_earliest_event_date'] ) : ''; |
|
856 | - update_post_meta( $post_id, '_feed_earliest_event_date', $earliest_events ); |
|
857 | - $earliest_events_range = isset( $_POST['_feed_earliest_event_date_range'] ) ? max( absint( $_POST['_feed_earliest_event_date_range'] ), 1 ) : 1; |
|
858 | - update_post_meta( $post_id, '_feed_earliest_event_date_range', $earliest_events_range ); |
|
855 | + $earliest_events = isset($_POST['_feed_earliest_event_date']) ? sanitize_key($_POST['_feed_earliest_event_date']) : ''; |
|
856 | + update_post_meta($post_id, '_feed_earliest_event_date', $earliest_events); |
|
857 | + $earliest_events_range = isset($_POST['_feed_earliest_event_date_range']) ? max(absint($_POST['_feed_earliest_event_date_range']), 1) : 1; |
|
858 | + update_post_meta($post_id, '_feed_earliest_event_date_range', $earliest_events_range); |
|
859 | 859 | |
860 | 860 | // Feed latest events date. |
861 | - $latest_events = isset( $_POST['_feed_latest_event_date'] ) ? sanitize_key( $_POST['_feed_latest_event_date'] ) : ''; |
|
862 | - update_post_meta( $post_id, '_feed_latest_event_date', $latest_events ); |
|
863 | - $latest_events_range = isset( $_POST['_feed_latest_event_date_range'] ) ? max( absint( $_POST['_feed_latest_event_date_range'] ), 1 ) : 1; |
|
864 | - update_post_meta( $post_id, '_feed_latest_event_date_range', $latest_events_range ); |
|
861 | + $latest_events = isset($_POST['_feed_latest_event_date']) ? sanitize_key($_POST['_feed_latest_event_date']) : ''; |
|
862 | + update_post_meta($post_id, '_feed_latest_event_date', $latest_events); |
|
863 | + $latest_events_range = isset($_POST['_feed_latest_event_date_range']) ? max(absint($_POST['_feed_latest_event_date_range']), 1) : 1; |
|
864 | + update_post_meta($post_id, '_feed_latest_event_date_range', $latest_events_range); |
|
865 | 865 | |
866 | 866 | /* ======================= * |
867 | 867 | * Calendar settings panel * |
868 | 868 | * ======================= */ |
869 | 869 | |
870 | 870 | // Static calendar. |
871 | - $static = isset( $_POST['_calendar_is_static'] ) ? 'yes' : 'no'; |
|
872 | - update_post_meta( $post_id, '_calendar_is_static', $static ); |
|
871 | + $static = isset($_POST['_calendar_is_static']) ? 'yes' : 'no'; |
|
872 | + update_post_meta($post_id, '_calendar_is_static', $static); |
|
873 | 873 | |
874 | 874 | // No events message. |
875 | - $message = isset( $_POST['_no_events_message'] ) ? wp_kses_post( $_POST['_no_events_message'] ) : ''; |
|
876 | - update_post_meta( $post_id, '_no_events_message', $message ); |
|
875 | + $message = isset($_POST['_no_events_message']) ? wp_kses_post($_POST['_no_events_message']) : ''; |
|
876 | + update_post_meta($post_id, '_no_events_message', $message); |
|
877 | 877 | |
878 | 878 | // _event_formatting |
879 | - $event_formatting = isset( $_POST['_event_formatting'] ) ? sanitize_key( $_POST['_event_formatting'] ) : 'preserve_linebreaks'; |
|
880 | - update_post_meta( $post_id, '_event_formatting', $event_formatting ); |
|
879 | + $event_formatting = isset($_POST['_event_formatting']) ? sanitize_key($_POST['_event_formatting']) : 'preserve_linebreaks'; |
|
880 | + update_post_meta($post_id, '_event_formatting', $event_formatting); |
|
881 | 881 | |
882 | 882 | /* ======================= * |
883 | 883 | * Advanced settings panel * |
884 | 884 | * ======================= */ |
885 | 885 | |
886 | 886 | // Timezone. |
887 | - $feed_timezone_setting = isset( $_POST['_feed_timezone_setting'] ) ? sanitize_key( $_POST['_feed_timezone_setting'] ) : 'use_calendar'; |
|
888 | - update_post_meta( $post_id, '_feed_timezone_setting', $feed_timezone_setting ); |
|
887 | + $feed_timezone_setting = isset($_POST['_feed_timezone_setting']) ? sanitize_key($_POST['_feed_timezone_setting']) : 'use_calendar'; |
|
888 | + update_post_meta($post_id, '_feed_timezone_setting', $feed_timezone_setting); |
|
889 | 889 | $default_timezone = simcal_get_wp_timezone(); |
890 | 890 | $feed_timezone = $default_timezone ? $default_timezone : 'UTC'; |
891 | - $feed_timezone = isset( $_POST['_feed_timezone'] ) ? sanitize_text_field( $_POST['_feed_timezone'] ) : $feed_timezone; |
|
892 | - update_post_meta( $post_id, '_feed_timezone', $feed_timezone ); |
|
891 | + $feed_timezone = isset($_POST['_feed_timezone']) ? sanitize_text_field($_POST['_feed_timezone']) : $feed_timezone; |
|
892 | + update_post_meta($post_id, '_feed_timezone', $feed_timezone); |
|
893 | 893 | |
894 | 894 | // Date format. |
895 | - $date_format_setting = isset( $_POST['_calendar_date_format_setting'] ) ? sanitize_key( $_POST['_calendar_date_format_setting'] ) : 'use_site'; |
|
896 | - update_post_meta( $post_id, '_calendar_date_format_setting', $date_format_setting ); |
|
897 | - $date_format = isset( $_POST['_calendar_date_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format'] ) ) : get_option( 'date_format' ); |
|
898 | - update_post_meta( $post_id, '_calendar_date_format', $date_format ); |
|
899 | - $date_format_php = isset( $_POST['_calendar_date_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format_php'] ) ) : get_option( 'date_format' ); |
|
900 | - update_post_meta( $post_id, '_calendar_date_format_php', $date_format_php ); |
|
895 | + $date_format_setting = isset($_POST['_calendar_date_format_setting']) ? sanitize_key($_POST['_calendar_date_format_setting']) : 'use_site'; |
|
896 | + update_post_meta($post_id, '_calendar_date_format_setting', $date_format_setting); |
|
897 | + $date_format = isset($_POST['_calendar_date_format']) ? sanitize_text_field(trim($_POST['_calendar_date_format'])) : get_option('date_format'); |
|
898 | + update_post_meta($post_id, '_calendar_date_format', $date_format); |
|
899 | + $date_format_php = isset($_POST['_calendar_date_format_php']) ? sanitize_text_field(trim($_POST['_calendar_date_format_php'])) : get_option('date_format'); |
|
900 | + update_post_meta($post_id, '_calendar_date_format_php', $date_format_php); |
|
901 | 901 | |
902 | 902 | // Time format. |
903 | - $time_format_setting = isset( $_POST['_calendar_time_format_setting'] ) ? sanitize_key( $_POST['_calendar_time_format_setting'] ) : 'use_site'; |
|
904 | - update_post_meta( $post_id, '_calendar_time_format_setting', $time_format_setting ); |
|
905 | - $time_format = isset( $_POST['_calendar_time_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format'] ) ) : get_option( 'time_format' ); |
|
906 | - update_post_meta( $post_id, '_calendar_time_format', $time_format ); |
|
907 | - $time_format_php = isset( $_POST['_calendar_time_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format_php'] ) ) : get_option( 'time_format' ); |
|
908 | - update_post_meta( $post_id, '_calendar_time_format_php', $time_format_php ); |
|
903 | + $time_format_setting = isset($_POST['_calendar_time_format_setting']) ? sanitize_key($_POST['_calendar_time_format_setting']) : 'use_site'; |
|
904 | + update_post_meta($post_id, '_calendar_time_format_setting', $time_format_setting); |
|
905 | + $time_format = isset($_POST['_calendar_time_format']) ? sanitize_text_field(trim($_POST['_calendar_time_format'])) : get_option('time_format'); |
|
906 | + update_post_meta($post_id, '_calendar_time_format', $time_format); |
|
907 | + $time_format_php = isset($_POST['_calendar_time_format_php']) ? sanitize_text_field(trim($_POST['_calendar_time_format_php'])) : get_option('time_format'); |
|
908 | + update_post_meta($post_id, '_calendar_time_format_php', $time_format_php); |
|
909 | 909 | |
910 | 910 | // Date-time separator. |
911 | - $datetime_separator = isset( $_POST['_calendar_datetime_separator'] ) ? sanitize_text_field( $_POST['_calendar_datetime_separator'] ) : ' '; |
|
912 | - update_post_meta( $post_id, '_calendar_datetime_separator', $datetime_separator ); |
|
911 | + $datetime_separator = isset($_POST['_calendar_datetime_separator']) ? sanitize_text_field($_POST['_calendar_datetime_separator']) : ' '; |
|
912 | + update_post_meta($post_id, '_calendar_datetime_separator', $datetime_separator); |
|
913 | 913 | |
914 | 914 | // Week start. |
915 | - $week_start_setting = isset( $_POST['_calendar_week_starts_on_setting'] ) ? sanitize_key( $_POST['_calendar_week_starts_on_setting'] ) : 'use_site'; |
|
916 | - update_post_meta( $post_id, '_calendar_week_starts_on_setting', $week_start_setting ); |
|
917 | - $week_start = isset( $_POST['_calendar_week_starts_on'] ) ? intval( $_POST['_calendar_week_starts_on'] ) : get_option( 'start_of_week' ); |
|
918 | - update_post_meta( $post_id, '_calendar_week_starts_on', $week_start ); |
|
915 | + $week_start_setting = isset($_POST['_calendar_week_starts_on_setting']) ? sanitize_key($_POST['_calendar_week_starts_on_setting']) : 'use_site'; |
|
916 | + update_post_meta($post_id, '_calendar_week_starts_on_setting', $week_start_setting); |
|
917 | + $week_start = isset($_POST['_calendar_week_starts_on']) ? intval($_POST['_calendar_week_starts_on']) : get_option('start_of_week'); |
|
918 | + update_post_meta($post_id, '_calendar_week_starts_on', $week_start); |
|
919 | 919 | |
920 | 920 | // Cache interval. |
921 | 921 | $cache = 7200; |
922 | - if ( isset( $_POST['_feed_cache_user_amount'] ) && isset( $_POST['_feed_cache_user_unit'] ) ) { |
|
923 | - $amount = is_numeric( $_POST['_feed_cache_user_amount'] ) || $_POST['_feed_cache_user_amount'] == 0 ? absint( $_POST['_feed_cache_user_amount'] ) : 1; |
|
924 | - $unit = is_numeric( $_POST['_feed_cache_user_unit'] ) ? absint( $_POST['_feed_cache_user_unit'] ) : 3600; |
|
925 | - update_post_meta( $post_id, '_feed_cache_user_amount', $amount ); |
|
926 | - update_post_meta( $post_id, '_feed_cache_user_unit', $unit ); |
|
927 | - $cache = ( ( $amount * $unit ) > 0 ) ? $amount * $unit : 1; |
|
922 | + if (isset($_POST['_feed_cache_user_amount']) && isset($_POST['_feed_cache_user_unit'])) { |
|
923 | + $amount = is_numeric($_POST['_feed_cache_user_amount']) || $_POST['_feed_cache_user_amount'] == 0 ? absint($_POST['_feed_cache_user_amount']) : 1; |
|
924 | + $unit = is_numeric($_POST['_feed_cache_user_unit']) ? absint($_POST['_feed_cache_user_unit']) : 3600; |
|
925 | + update_post_meta($post_id, '_feed_cache_user_amount', $amount); |
|
926 | + update_post_meta($post_id, '_feed_cache_user_unit', $unit); |
|
927 | + $cache = (($amount * $unit) > 0) ? $amount * $unit : 1; |
|
928 | 928 | } |
929 | - update_post_meta( $post_id, '_feed_cache', $cache ); |
|
929 | + update_post_meta($post_id, '_feed_cache', $cache); |
|
930 | 930 | |
931 | 931 | /* ============= * |
932 | 932 | * Miscellaneous * |
933 | 933 | * ============= */ |
934 | 934 | |
935 | 935 | // Update version. |
936 | - update_post_meta( $post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION ); |
|
936 | + update_post_meta($post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION); |
|
937 | 937 | |
938 | 938 | // Action hook. |
939 | - do_action( 'simcal_process_settings_meta', $post_id ); |
|
939 | + do_action('simcal_process_settings_meta', $post_id); |
|
940 | 940 | |
941 | 941 | // Clear cache. |
942 | - simcal_delete_feed_transients( $post_id ); |
|
942 | + simcal_delete_feed_transients($post_id); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | } |