@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -26,233 +26,233 @@ discard block |
||
26 | 26 | { |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * return the timezone set for the WP install |
|
31 | - * |
|
32 | - * @return string valid timezone string for PHP DateTimeZone() class |
|
33 | - */ |
|
34 | - public static function get_timezone() |
|
35 | - { |
|
36 | - return EEH_DTT_Helper::get_valid_timezone_string(); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * get_valid_timezone_string |
|
42 | - * ensures that a valid timezone string is returned |
|
43 | - * |
|
44 | - * @access protected |
|
45 | - * @param string $timezone_string |
|
46 | - * @return string |
|
47 | - * @throws \EE_Error |
|
48 | - */ |
|
49 | - public static function get_valid_timezone_string($timezone_string = '') |
|
50 | - { |
|
51 | - // if passed a value, then use that, else get WP option |
|
52 | - $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
53 | - // value from above exists, use that, else get timezone string from gmt_offset |
|
54 | - $timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
55 | - EEH_DTT_Helper::validate_timezone($timezone_string); |
|
56 | - return $timezone_string; |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone. |
|
62 | - * |
|
63 | - * @static |
|
64 | - * @access public |
|
65 | - * @param string $timezone_string Timezone string to check |
|
66 | - * @param bool $throw_error |
|
67 | - * @return bool |
|
68 | - * @throws \EE_Error |
|
69 | - */ |
|
70 | - public static function validate_timezone($timezone_string, $throw_error = true) |
|
71 | - { |
|
72 | - // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it |
|
73 | - try { |
|
74 | - new DateTimeZone($timezone_string); |
|
75 | - } catch (Exception $e) { |
|
76 | - // sometimes we take exception to exceptions |
|
77 | - if (! $throw_error) { |
|
78 | - return false; |
|
79 | - } |
|
80 | - throw new EE_Error( |
|
81 | - sprintf( |
|
82 | - __('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', |
|
83 | - 'event_espresso'), |
|
84 | - $timezone_string, |
|
85 | - '<a href="http://www.php.net/manual/en/timezones.php">', |
|
86 | - '</a>' |
|
87 | - ) |
|
88 | - ); |
|
89 | - } |
|
90 | - return true; |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * _create_timezone_object_from_timezone_name |
|
96 | - * |
|
97 | - * @access protected |
|
98 | - * @param string $gmt_offset |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public static function get_timezone_string_from_gmt_offset($gmt_offset = '') |
|
102 | - { |
|
103 | - $timezone_string = 'UTC'; |
|
104 | - $gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset'); |
|
105 | - if ($gmt_offset !== '') { |
|
106 | - // convert GMT offset to seconds |
|
107 | - $gmt_offset = $gmt_offset * HOUR_IN_SECONDS; |
|
108 | - // account for WP offsets that aren't valid UTC |
|
109 | - $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset); |
|
110 | - // although we don't know the TZ abbreviation, we know the UTC offset |
|
111 | - $timezone_string = timezone_name_from_abbr(null, $gmt_offset); |
|
112 | - } |
|
113 | - // better have a valid timezone string by now, but if not, sigh... loop thru the timezone_abbreviations_list()... |
|
114 | - $timezone_string = $timezone_string !== false |
|
115 | - ? $timezone_string |
|
116 | - : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset); |
|
117 | - return $timezone_string; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Gets the site's GMT offset based on either the timezone string |
|
122 | - * (in which case teh gmt offset will vary depending on the location's |
|
123 | - * observance of daylight savings time) or the gmt_offset wp option |
|
124 | - * |
|
125 | - * @return int seconds offset |
|
126 | - */ |
|
127 | - public static function get_site_timezone_gmt_offset() |
|
128 | - { |
|
129 | - $timezone_string = get_option('timezone_string'); |
|
130 | - if ($timezone_string) { |
|
131 | - try { |
|
132 | - $timezone = new DateTimeZone($timezone_string); |
|
133 | - return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC |
|
134 | - } catch (Exception $e) { |
|
135 | - } |
|
136 | - } |
|
137 | - $offset = get_option('gmt_offset'); |
|
138 | - return (int)($offset * HOUR_IN_SECONDS); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * _create_timezone_object_from_timezone_name |
|
144 | - * |
|
145 | - * @access public |
|
146 | - * @param int $gmt_offset |
|
147 | - * @return int |
|
148 | - */ |
|
149 | - public static function adjust_invalid_gmt_offsets($gmt_offset = 0) |
|
150 | - { |
|
151 | - //make sure $gmt_offset is int |
|
152 | - $gmt_offset = (int)$gmt_offset; |
|
153 | - switch ($gmt_offset) { |
|
154 | - |
|
155 | - // case -30600 : |
|
156 | - // $gmt_offset = -28800; |
|
157 | - // break; |
|
158 | - |
|
159 | - case -27000 : |
|
160 | - $gmt_offset = -25200; |
|
161 | - break; |
|
162 | - |
|
163 | - case -23400 : |
|
164 | - $gmt_offset = -21600; |
|
165 | - break; |
|
166 | - |
|
167 | - case -19800 : |
|
168 | - $gmt_offset = -18000; |
|
169 | - break; |
|
170 | - |
|
171 | - case -9000 : |
|
172 | - $gmt_offset = -7200; |
|
173 | - break; |
|
174 | - |
|
175 | - case -5400 : |
|
176 | - $gmt_offset = -3600; |
|
177 | - break; |
|
178 | - |
|
179 | - case -1800 : |
|
180 | - $gmt_offset = 0; |
|
181 | - break; |
|
182 | - |
|
183 | - case 1800 : |
|
184 | - $gmt_offset = 3600; |
|
185 | - break; |
|
186 | - |
|
187 | - case 49500 : |
|
188 | - $gmt_offset = 50400; |
|
189 | - break; |
|
190 | - |
|
191 | - } |
|
192 | - return $gmt_offset; |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * get_timezone_string_from_abbreviations_list |
|
198 | - * |
|
199 | - * @access public |
|
200 | - * @param int $gmt_offset |
|
201 | - * @return string |
|
202 | - * @throws \EE_Error |
|
203 | - */ |
|
204 | - public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) |
|
205 | - { |
|
206 | - $abbreviations = timezone_abbreviations_list(); |
|
207 | - foreach ($abbreviations as $abbreviation) { |
|
208 | - foreach ($abbreviation as $city) { |
|
209 | - if ($city['offset'] === $gmt_offset && $city['dst'] === false) { |
|
210 | - // check if the timezone is valid but don't throw any errors if it isn't |
|
211 | - if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) { |
|
212 | - return $city['timezone_id']; |
|
213 | - } |
|
214 | - } |
|
215 | - } |
|
216 | - } |
|
217 | - throw new EE_Error( |
|
218 | - sprintf( |
|
219 | - __('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', |
|
220 | - 'event_espresso'), |
|
221 | - $gmt_offset, |
|
222 | - '<a href="http://www.php.net/manual/en/timezones.php">', |
|
223 | - '</a>' |
|
224 | - ) |
|
225 | - ); |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * @access public |
|
231 | - * @param string $timezone_string |
|
232 | - */ |
|
233 | - public static function timezone_select_input($timezone_string = '') |
|
234 | - { |
|
235 | - // get WP date time format |
|
236 | - $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
237 | - // if passed a value, then use that, else get WP option |
|
238 | - $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
239 | - // check if the timezone is valid but don't throw any errors if it isn't |
|
240 | - $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false); |
|
241 | - $gmt_offset = get_option('gmt_offset'); |
|
242 | - |
|
243 | - $check_zone_info = true; |
|
244 | - if (empty($timezone_string)) { |
|
245 | - // Create a UTC+- zone if no timezone string exists |
|
246 | - $check_zone_info = false; |
|
247 | - if ($gmt_offset > 0) { |
|
248 | - $timezone_string = 'UTC+' . $gmt_offset; |
|
249 | - } elseif ($gmt_offset < 0) { |
|
250 | - $timezone_string = 'UTC' . $gmt_offset; |
|
251 | - } else { |
|
252 | - $timezone_string = 'UTC'; |
|
253 | - } |
|
254 | - } |
|
255 | - ?> |
|
29 | + /** |
|
30 | + * return the timezone set for the WP install |
|
31 | + * |
|
32 | + * @return string valid timezone string for PHP DateTimeZone() class |
|
33 | + */ |
|
34 | + public static function get_timezone() |
|
35 | + { |
|
36 | + return EEH_DTT_Helper::get_valid_timezone_string(); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * get_valid_timezone_string |
|
42 | + * ensures that a valid timezone string is returned |
|
43 | + * |
|
44 | + * @access protected |
|
45 | + * @param string $timezone_string |
|
46 | + * @return string |
|
47 | + * @throws \EE_Error |
|
48 | + */ |
|
49 | + public static function get_valid_timezone_string($timezone_string = '') |
|
50 | + { |
|
51 | + // if passed a value, then use that, else get WP option |
|
52 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
53 | + // value from above exists, use that, else get timezone string from gmt_offset |
|
54 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
55 | + EEH_DTT_Helper::validate_timezone($timezone_string); |
|
56 | + return $timezone_string; |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone. |
|
62 | + * |
|
63 | + * @static |
|
64 | + * @access public |
|
65 | + * @param string $timezone_string Timezone string to check |
|
66 | + * @param bool $throw_error |
|
67 | + * @return bool |
|
68 | + * @throws \EE_Error |
|
69 | + */ |
|
70 | + public static function validate_timezone($timezone_string, $throw_error = true) |
|
71 | + { |
|
72 | + // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it |
|
73 | + try { |
|
74 | + new DateTimeZone($timezone_string); |
|
75 | + } catch (Exception $e) { |
|
76 | + // sometimes we take exception to exceptions |
|
77 | + if (! $throw_error) { |
|
78 | + return false; |
|
79 | + } |
|
80 | + throw new EE_Error( |
|
81 | + sprintf( |
|
82 | + __('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', |
|
83 | + 'event_espresso'), |
|
84 | + $timezone_string, |
|
85 | + '<a href="http://www.php.net/manual/en/timezones.php">', |
|
86 | + '</a>' |
|
87 | + ) |
|
88 | + ); |
|
89 | + } |
|
90 | + return true; |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * _create_timezone_object_from_timezone_name |
|
96 | + * |
|
97 | + * @access protected |
|
98 | + * @param string $gmt_offset |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public static function get_timezone_string_from_gmt_offset($gmt_offset = '') |
|
102 | + { |
|
103 | + $timezone_string = 'UTC'; |
|
104 | + $gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset'); |
|
105 | + if ($gmt_offset !== '') { |
|
106 | + // convert GMT offset to seconds |
|
107 | + $gmt_offset = $gmt_offset * HOUR_IN_SECONDS; |
|
108 | + // account for WP offsets that aren't valid UTC |
|
109 | + $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset); |
|
110 | + // although we don't know the TZ abbreviation, we know the UTC offset |
|
111 | + $timezone_string = timezone_name_from_abbr(null, $gmt_offset); |
|
112 | + } |
|
113 | + // better have a valid timezone string by now, but if not, sigh... loop thru the timezone_abbreviations_list()... |
|
114 | + $timezone_string = $timezone_string !== false |
|
115 | + ? $timezone_string |
|
116 | + : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset); |
|
117 | + return $timezone_string; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Gets the site's GMT offset based on either the timezone string |
|
122 | + * (in which case teh gmt offset will vary depending on the location's |
|
123 | + * observance of daylight savings time) or the gmt_offset wp option |
|
124 | + * |
|
125 | + * @return int seconds offset |
|
126 | + */ |
|
127 | + public static function get_site_timezone_gmt_offset() |
|
128 | + { |
|
129 | + $timezone_string = get_option('timezone_string'); |
|
130 | + if ($timezone_string) { |
|
131 | + try { |
|
132 | + $timezone = new DateTimeZone($timezone_string); |
|
133 | + return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC |
|
134 | + } catch (Exception $e) { |
|
135 | + } |
|
136 | + } |
|
137 | + $offset = get_option('gmt_offset'); |
|
138 | + return (int)($offset * HOUR_IN_SECONDS); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * _create_timezone_object_from_timezone_name |
|
144 | + * |
|
145 | + * @access public |
|
146 | + * @param int $gmt_offset |
|
147 | + * @return int |
|
148 | + */ |
|
149 | + public static function adjust_invalid_gmt_offsets($gmt_offset = 0) |
|
150 | + { |
|
151 | + //make sure $gmt_offset is int |
|
152 | + $gmt_offset = (int)$gmt_offset; |
|
153 | + switch ($gmt_offset) { |
|
154 | + |
|
155 | + // case -30600 : |
|
156 | + // $gmt_offset = -28800; |
|
157 | + // break; |
|
158 | + |
|
159 | + case -27000 : |
|
160 | + $gmt_offset = -25200; |
|
161 | + break; |
|
162 | + |
|
163 | + case -23400 : |
|
164 | + $gmt_offset = -21600; |
|
165 | + break; |
|
166 | + |
|
167 | + case -19800 : |
|
168 | + $gmt_offset = -18000; |
|
169 | + break; |
|
170 | + |
|
171 | + case -9000 : |
|
172 | + $gmt_offset = -7200; |
|
173 | + break; |
|
174 | + |
|
175 | + case -5400 : |
|
176 | + $gmt_offset = -3600; |
|
177 | + break; |
|
178 | + |
|
179 | + case -1800 : |
|
180 | + $gmt_offset = 0; |
|
181 | + break; |
|
182 | + |
|
183 | + case 1800 : |
|
184 | + $gmt_offset = 3600; |
|
185 | + break; |
|
186 | + |
|
187 | + case 49500 : |
|
188 | + $gmt_offset = 50400; |
|
189 | + break; |
|
190 | + |
|
191 | + } |
|
192 | + return $gmt_offset; |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * get_timezone_string_from_abbreviations_list |
|
198 | + * |
|
199 | + * @access public |
|
200 | + * @param int $gmt_offset |
|
201 | + * @return string |
|
202 | + * @throws \EE_Error |
|
203 | + */ |
|
204 | + public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) |
|
205 | + { |
|
206 | + $abbreviations = timezone_abbreviations_list(); |
|
207 | + foreach ($abbreviations as $abbreviation) { |
|
208 | + foreach ($abbreviation as $city) { |
|
209 | + if ($city['offset'] === $gmt_offset && $city['dst'] === false) { |
|
210 | + // check if the timezone is valid but don't throw any errors if it isn't |
|
211 | + if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) { |
|
212 | + return $city['timezone_id']; |
|
213 | + } |
|
214 | + } |
|
215 | + } |
|
216 | + } |
|
217 | + throw new EE_Error( |
|
218 | + sprintf( |
|
219 | + __('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', |
|
220 | + 'event_espresso'), |
|
221 | + $gmt_offset, |
|
222 | + '<a href="http://www.php.net/manual/en/timezones.php">', |
|
223 | + '</a>' |
|
224 | + ) |
|
225 | + ); |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * @access public |
|
231 | + * @param string $timezone_string |
|
232 | + */ |
|
233 | + public static function timezone_select_input($timezone_string = '') |
|
234 | + { |
|
235 | + // get WP date time format |
|
236 | + $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
237 | + // if passed a value, then use that, else get WP option |
|
238 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
239 | + // check if the timezone is valid but don't throw any errors if it isn't |
|
240 | + $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false); |
|
241 | + $gmt_offset = get_option('gmt_offset'); |
|
242 | + |
|
243 | + $check_zone_info = true; |
|
244 | + if (empty($timezone_string)) { |
|
245 | + // Create a UTC+- zone if no timezone string exists |
|
246 | + $check_zone_info = false; |
|
247 | + if ($gmt_offset > 0) { |
|
248 | + $timezone_string = 'UTC+' . $gmt_offset; |
|
249 | + } elseif ($gmt_offset < 0) { |
|
250 | + $timezone_string = 'UTC' . $gmt_offset; |
|
251 | + } else { |
|
252 | + $timezone_string = 'UTC'; |
|
253 | + } |
|
254 | + } |
|
255 | + ?> |
|
256 | 256 | |
257 | 257 | <p> |
258 | 258 | <label for="timezone_string"><?php _e('timezone'); ?></label> |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | |
266 | 266 | <p> |
267 | 267 | <span><?php |
268 | - printf( |
|
269 | - __('%1$sUTC%2$s time is %3$s'), |
|
270 | - '<abbr title="Coordinated Universal Time">', |
|
271 | - '</abbr>', |
|
272 | - '<code>' . date_i18n($datetime_format, false, true) . '</code>' |
|
273 | - ); |
|
274 | - ?></span> |
|
268 | + printf( |
|
269 | + __('%1$sUTC%2$s time is %3$s'), |
|
270 | + '<abbr title="Coordinated Universal Time">', |
|
271 | + '</abbr>', |
|
272 | + '<code>' . date_i18n($datetime_format, false, true) . '</code>' |
|
273 | + ); |
|
274 | + ?></span> |
|
275 | 275 | <?php if (! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
276 | 276 | <br/><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n($datetime_format) . '</code>'); ?></span> |
277 | 277 | <?php endif; ?> |
@@ -280,650 +280,650 @@ discard block |
||
280 | 280 | <br/> |
281 | 281 | <span> |
282 | 282 | <?php |
283 | - // Set TZ so localtime works. |
|
284 | - date_default_timezone_set($timezone_string); |
|
285 | - $now = localtime(time(), true); |
|
286 | - if ($now['tm_isdst']) { |
|
287 | - _e('This timezone is currently in daylight saving time.'); |
|
288 | - } else { |
|
289 | - _e('This timezone is currently in standard time.'); |
|
290 | - } |
|
291 | - ?> |
|
283 | + // Set TZ so localtime works. |
|
284 | + date_default_timezone_set($timezone_string); |
|
285 | + $now = localtime(time(), true); |
|
286 | + if ($now['tm_isdst']) { |
|
287 | + _e('This timezone is currently in daylight saving time.'); |
|
288 | + } else { |
|
289 | + _e('This timezone is currently in standard time.'); |
|
290 | + } |
|
291 | + ?> |
|
292 | 292 | <br/> |
293 | 293 | <?php |
294 | - if (function_exists('timezone_transitions_get')) { |
|
295 | - $found = false; |
|
296 | - $date_time_zone_selected = new DateTimeZone($timezone_string); |
|
297 | - $tz_offset = timezone_offset_get($date_time_zone_selected, date_create()); |
|
298 | - $right_now = time(); |
|
299 | - $tr['isdst'] = false; |
|
300 | - foreach (timezone_transitions_get($date_time_zone_selected) as $tr) { |
|
301 | - if ($tr['ts'] > $right_now) { |
|
302 | - $found = true; |
|
303 | - break; |
|
304 | - } |
|
305 | - } |
|
306 | - |
|
307 | - if ($found) { |
|
308 | - $message = $tr['isdst'] ? |
|
309 | - __(' Daylight saving time begins on: %s.') : |
|
310 | - __(' Standard time begins on: %s.'); |
|
311 | - // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
|
312 | - printf($message, |
|
313 | - '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >'); |
|
314 | - } else { |
|
315 | - _e('This timezone does not observe daylight saving time.'); |
|
316 | - } |
|
317 | - } |
|
318 | - // Set back to UTC. |
|
319 | - date_default_timezone_set('UTC'); |
|
320 | - ?> |
|
294 | + if (function_exists('timezone_transitions_get')) { |
|
295 | + $found = false; |
|
296 | + $date_time_zone_selected = new DateTimeZone($timezone_string); |
|
297 | + $tz_offset = timezone_offset_get($date_time_zone_selected, date_create()); |
|
298 | + $right_now = time(); |
|
299 | + $tr['isdst'] = false; |
|
300 | + foreach (timezone_transitions_get($date_time_zone_selected) as $tr) { |
|
301 | + if ($tr['ts'] > $right_now) { |
|
302 | + $found = true; |
|
303 | + break; |
|
304 | + } |
|
305 | + } |
|
306 | + |
|
307 | + if ($found) { |
|
308 | + $message = $tr['isdst'] ? |
|
309 | + __(' Daylight saving time begins on: %s.') : |
|
310 | + __(' Standard time begins on: %s.'); |
|
311 | + // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
|
312 | + printf($message, |
|
313 | + '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >'); |
|
314 | + } else { |
|
315 | + _e('This timezone does not observe daylight saving time.'); |
|
316 | + } |
|
317 | + } |
|
318 | + // Set back to UTC. |
|
319 | + date_default_timezone_set('UTC'); |
|
320 | + ?> |
|
321 | 321 | </span></p> |
322 | 322 | <?php |
323 | - endif; |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - /** |
|
328 | - * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string. |
|
329 | - * If no unix timestamp is given then time() is used. If no timezone is given then the set timezone string for |
|
330 | - * the site is used. |
|
331 | - * This is used typically when using a Unix timestamp any core WP functions that expect their specially |
|
332 | - * computed timestamp (i.e. date_i18n() ) |
|
333 | - * |
|
334 | - * @param int $unix_timestamp if 0, then time() will be used. |
|
335 | - * @param string $timezone_string timezone_string. If empty, then the current set timezone for the |
|
336 | - * site will be used. |
|
337 | - * @return int $unix_timestamp with the offset applied for the given timezone. |
|
338 | - */ |
|
339 | - public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') |
|
340 | - { |
|
341 | - $unix_timestamp = $unix_timestamp === 0 ? time() : (int)$unix_timestamp; |
|
342 | - $timezone_string = self::get_valid_timezone_string($timezone_string); |
|
343 | - $TimeZone = new DateTimeZone($timezone_string); |
|
344 | - |
|
345 | - $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone); |
|
346 | - $offset = timezone_offset_get($TimeZone, $DateTime); |
|
347 | - return (int)$DateTime->format('U') + (int)$offset; |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - /** |
|
352 | - * _set_date_time_field |
|
353 | - * modifies EE_Base_Class EE_Datetime_Field objects |
|
354 | - * |
|
355 | - * @param EE_Base_Class $obj EE_Base_Class object |
|
356 | - * @param DateTime $DateTime PHP DateTime object |
|
357 | - * @param string $datetime_field_name the datetime fieldname to be manipulated |
|
358 | - * @return EE_Base_Class |
|
359 | - */ |
|
360 | - protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) |
|
361 | - { |
|
362 | - // grab current datetime format |
|
363 | - $current_format = $obj->get_format(); |
|
364 | - // set new full timestamp format |
|
365 | - $obj->set_date_format(EE_Datetime_Field::mysql_date_format); |
|
366 | - $obj->set_time_format(EE_Datetime_Field::mysql_time_format); |
|
367 | - // set the new date value using a full timestamp format so that no data is lost |
|
368 | - $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format)); |
|
369 | - // reset datetime formats |
|
370 | - $obj->set_date_format($current_format[0]); |
|
371 | - $obj->set_time_format($current_format[1]); |
|
372 | - return $obj; |
|
373 | - } |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * date_time_add |
|
378 | - * helper for doing simple datetime calculations on a given datetime from EE_Base_Class |
|
379 | - * and modifying it IN the EE_Base_Class so you don't have to do anything else. |
|
380 | - * |
|
381 | - * @param EE_Base_Class $obj EE_Base_Class object |
|
382 | - * @param string $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated |
|
383 | - * @param string $period what you are adding. The options are (years, months, days, hours, |
|
384 | - * minutes, seconds) defaults to years |
|
385 | - * @param integer $value what you want to increment the time by |
|
386 | - * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it |
|
387 | - * (chaining) |
|
388 | - */ |
|
389 | - public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) |
|
390 | - { |
|
391 | - //get the raw UTC date. |
|
392 | - $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
393 | - $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value); |
|
394 | - return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
395 | - } |
|
396 | - |
|
397 | - |
|
398 | - /** |
|
399 | - * date_time_subtract |
|
400 | - * same as date_time_add except subtracting value instead of adding. |
|
401 | - * |
|
402 | - * @param \EE_Base_Class $obj |
|
403 | - * @param string $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated |
|
404 | - * @param string $period |
|
405 | - * @param int $value |
|
406 | - * @return \EE_Base_Class |
|
407 | - */ |
|
408 | - public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) |
|
409 | - { |
|
410 | - //get the raw UTC date |
|
411 | - $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
412 | - $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-'); |
|
413 | - return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
414 | - } |
|
415 | - |
|
416 | - |
|
417 | - /** |
|
418 | - * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters |
|
419 | - * |
|
420 | - * @param DateTime $DateTime DateTime object |
|
421 | - * @param string $period a value to indicate what interval is being used in the calculation. The options are |
|
422 | - * 'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years. |
|
423 | - * @param integer $value What you want to increment the date by |
|
424 | - * @param string $operand What operand you wish to use for the calculation |
|
425 | - * @return \DateTime return whatever type came in. |
|
426 | - * @throws \EE_Error |
|
427 | - */ |
|
428 | - protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') |
|
429 | - { |
|
430 | - if (! $DateTime instanceof DateTime) { |
|
431 | - throw new EE_Error( |
|
432 | - sprintf( |
|
433 | - __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
|
434 | - print_r($DateTime, true) |
|
435 | - ) |
|
436 | - ); |
|
437 | - } |
|
438 | - switch ($period) { |
|
439 | - case 'years' : |
|
440 | - $value = 'P' . $value . 'Y'; |
|
441 | - break; |
|
442 | - case 'months' : |
|
443 | - $value = 'P' . $value . 'M'; |
|
444 | - break; |
|
445 | - case 'weeks' : |
|
446 | - $value = 'P' . $value . 'W'; |
|
447 | - break; |
|
448 | - case 'days' : |
|
449 | - $value = 'P' . $value . 'D'; |
|
450 | - break; |
|
451 | - case 'hours' : |
|
452 | - $value = 'PT' . $value . 'H'; |
|
453 | - break; |
|
454 | - case 'minutes' : |
|
455 | - $value = 'PT' . $value . 'M'; |
|
456 | - break; |
|
457 | - case 'seconds' : |
|
458 | - $value = 'PT' . $value . 'S'; |
|
459 | - break; |
|
460 | - } |
|
461 | - switch ($operand) { |
|
462 | - case '+': |
|
463 | - $DateTime->add(new DateInterval($value)); |
|
464 | - break; |
|
465 | - case '-': |
|
466 | - $DateTime->sub(new DateInterval($value)); |
|
467 | - break; |
|
468 | - } |
|
469 | - return $DateTime; |
|
470 | - } |
|
471 | - |
|
472 | - |
|
473 | - /** |
|
474 | - * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters |
|
475 | - * |
|
476 | - * @param int $timestamp Unix timestamp |
|
477 | - * @param string $period a value to indicate what interval is being used in the calculation. The options are |
|
478 | - * 'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years. |
|
479 | - * @param integer $value What you want to increment the date by |
|
480 | - * @param string $operand What operand you wish to use for the calculation |
|
481 | - * @return \DateTime return whatever type came in. |
|
482 | - * @throws \EE_Error |
|
483 | - */ |
|
484 | - protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') |
|
485 | - { |
|
486 | - if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
487 | - throw new EE_Error( |
|
488 | - sprintf( |
|
489 | - __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
|
490 | - print_r($timestamp, true) |
|
491 | - ) |
|
492 | - ); |
|
493 | - } |
|
494 | - switch ($period) { |
|
495 | - case 'years' : |
|
496 | - $value = YEAR_IN_SECONDS * $value; |
|
497 | - break; |
|
498 | - case 'months' : |
|
499 | - $value = YEAR_IN_SECONDS / 12 * $value; |
|
500 | - break; |
|
501 | - case 'weeks' : |
|
502 | - $value = WEEK_IN_SECONDS * $value; |
|
503 | - break; |
|
504 | - case 'days' : |
|
505 | - $value = DAY_IN_SECONDS * $value; |
|
506 | - break; |
|
507 | - case 'hours' : |
|
508 | - $value = HOUR_IN_SECONDS * $value; |
|
509 | - break; |
|
510 | - case 'minutes' : |
|
511 | - $value = MINUTE_IN_SECONDS * $value; |
|
512 | - break; |
|
513 | - } |
|
514 | - switch ($operand) { |
|
515 | - case '+': |
|
516 | - $timestamp += $value; |
|
517 | - break; |
|
518 | - case '-': |
|
519 | - $timestamp -= $value; |
|
520 | - break; |
|
521 | - } |
|
522 | - return $timestamp; |
|
523 | - } |
|
524 | - |
|
525 | - |
|
526 | - /** |
|
527 | - * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming |
|
528 | - * parameters and returns the new timestamp or DateTime. |
|
529 | - * |
|
530 | - * @param int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp |
|
531 | - * @param string $period a value to indicate what interval is being used in the |
|
532 | - * calculation. The options are 'years', 'months', 'days', 'hours', |
|
533 | - * 'minutes', 'seconds'. Defaults to years. |
|
534 | - * @param integer $value What you want to increment the date by |
|
535 | - * @param string $operand What operand you wish to use for the calculation |
|
536 | - * @return mixed string|DateTime return whatever type came in. |
|
537 | - */ |
|
538 | - public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') |
|
539 | - { |
|
540 | - if ($DateTime_or_timestamp instanceof DateTime) { |
|
541 | - return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand); |
|
542 | - } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) { |
|
543 | - return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand); |
|
544 | - } else { |
|
545 | - //error |
|
546 | - return $DateTime_or_timestamp; |
|
547 | - } |
|
548 | - } |
|
549 | - |
|
550 | - |
|
551 | - /** |
|
552 | - * The purpose of this helper method is to receive an incoming format string in php date/time format |
|
553 | - * and spit out the js and moment.js equivalent formats. |
|
554 | - * Note, if no format string is given, then it is assumed the user wants what is set for WP. |
|
555 | - * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date- |
|
556 | - * time picker. |
|
557 | - * |
|
558 | - * @see http://stackoverflow.com/posts/16725290/ for the code inspiration. |
|
559 | - * @param null $date_format_string |
|
560 | - * @param null $time_format_string |
|
561 | - * @return array |
|
562 | - * array( |
|
563 | - * 'js' => array ( |
|
564 | - * 'date' => //date format |
|
565 | - * 'time' => //time format |
|
566 | - * ), |
|
567 | - * 'moment' => //date and time format. |
|
568 | - * ) |
|
569 | - */ |
|
570 | - public static function convert_php_to_js_and_moment_date_formats( |
|
571 | - $date_format_string = null, |
|
572 | - $time_format_string = null |
|
573 | - ) { |
|
574 | - if ($date_format_string === null) { |
|
575 | - $date_format_string = get_option('date_format'); |
|
576 | - } |
|
577 | - |
|
578 | - if ($time_format_string === null) { |
|
579 | - $time_format_string = get_option('time_format'); |
|
580 | - } |
|
581 | - |
|
582 | - $date_format = self::_php_to_js_moment_converter($date_format_string); |
|
583 | - $time_format = self::_php_to_js_moment_converter($time_format_string); |
|
584 | - |
|
585 | - return array( |
|
586 | - 'js' => array( |
|
587 | - 'date' => $date_format['js'], |
|
588 | - 'time' => $time_format['js'], |
|
589 | - ), |
|
590 | - 'moment' => $date_format['moment'] . ' ' . $time_format['moment'], |
|
591 | - ); |
|
592 | - } |
|
593 | - |
|
594 | - |
|
595 | - /** |
|
596 | - * This converts incoming format string into js and moment variations. |
|
597 | - * |
|
598 | - * @param string $format_string incoming php format string |
|
599 | - * @return array js and moment formats. |
|
600 | - */ |
|
601 | - protected static function _php_to_js_moment_converter($format_string) |
|
602 | - { |
|
603 | - /** |
|
604 | - * This is a map of symbols for formats. |
|
605 | - * The index is the php symbol, the equivalent values are in the array. |
|
606 | - * |
|
607 | - * @var array |
|
608 | - */ |
|
609 | - $symbols_map = array( |
|
610 | - // Day |
|
611 | - //01 |
|
612 | - 'd' => array( |
|
613 | - 'js' => 'dd', |
|
614 | - 'moment' => 'DD', |
|
615 | - ), |
|
616 | - //Mon |
|
617 | - 'D' => array( |
|
618 | - 'js' => 'D', |
|
619 | - 'moment' => 'ddd', |
|
620 | - ), |
|
621 | - //1,2,...31 |
|
622 | - 'j' => array( |
|
623 | - 'js' => 'd', |
|
624 | - 'moment' => 'D', |
|
625 | - ), |
|
626 | - //Monday |
|
627 | - 'l' => array( |
|
628 | - 'js' => 'DD', |
|
629 | - 'moment' => 'dddd', |
|
630 | - ), |
|
631 | - //ISO numeric representation of the day of the week (1-6) |
|
632 | - 'N' => array( |
|
633 | - 'js' => '', |
|
634 | - 'moment' => 'E', |
|
635 | - ), |
|
636 | - //st,nd.rd |
|
637 | - 'S' => array( |
|
638 | - 'js' => '', |
|
639 | - 'moment' => 'o', |
|
640 | - ), |
|
641 | - //numeric representation of day of week (0-6) |
|
642 | - 'w' => array( |
|
643 | - 'js' => '', |
|
644 | - 'moment' => 'd', |
|
645 | - ), |
|
646 | - //day of year starting from 0 (0-365) |
|
647 | - 'z' => array( |
|
648 | - 'js' => 'o', |
|
649 | - 'moment' => 'DDD' //note moment does not start with 0 so will need to modify by subtracting 1 |
|
650 | - ), |
|
651 | - // Week |
|
652 | - //ISO-8601 week number of year (weeks starting on monday) |
|
653 | - 'W' => array( |
|
654 | - 'js' => '', |
|
655 | - 'moment' => 'w', |
|
656 | - ), |
|
657 | - // Month |
|
658 | - // January...December |
|
659 | - 'F' => array( |
|
660 | - 'js' => 'MM', |
|
661 | - 'moment' => 'MMMM', |
|
662 | - ), |
|
663 | - //01...12 |
|
664 | - 'm' => array( |
|
665 | - 'js' => 'mm', |
|
666 | - 'moment' => 'MM', |
|
667 | - ), |
|
668 | - //Jan...Dec |
|
669 | - 'M' => array( |
|
670 | - 'js' => 'M', |
|
671 | - 'moment' => 'MMM', |
|
672 | - ), |
|
673 | - //1-12 |
|
674 | - 'n' => array( |
|
675 | - 'js' => 'm', |
|
676 | - 'moment' => 'M', |
|
677 | - ), |
|
678 | - //number of days in given month |
|
679 | - 't' => array( |
|
680 | - 'js' => '', |
|
681 | - 'moment' => '', |
|
682 | - ), |
|
683 | - // Year |
|
684 | - //whether leap year or not 1/0 |
|
685 | - 'L' => array( |
|
686 | - 'js' => '', |
|
687 | - 'moment' => '', |
|
688 | - ), |
|
689 | - //ISO-8601 year number |
|
690 | - 'o' => array( |
|
691 | - 'js' => '', |
|
692 | - 'moment' => 'GGGG', |
|
693 | - ), |
|
694 | - //1999...2003 |
|
695 | - 'Y' => array( |
|
696 | - 'js' => 'yy', |
|
697 | - 'moment' => 'YYYY', |
|
698 | - ), |
|
699 | - //99...03 |
|
700 | - 'y' => array( |
|
701 | - 'js' => 'y', |
|
702 | - 'moment' => 'YY', |
|
703 | - ), |
|
704 | - // Time |
|
705 | - // am/pm |
|
706 | - 'a' => array( |
|
707 | - 'js' => 'tt', |
|
708 | - 'moment' => 'a', |
|
709 | - ), |
|
710 | - // AM/PM |
|
711 | - 'A' => array( |
|
712 | - 'js' => 'TT', |
|
713 | - 'moment' => 'A', |
|
714 | - ), |
|
715 | - // Swatch Internet Time?!? |
|
716 | - 'B' => array( |
|
717 | - 'js' => '', |
|
718 | - 'moment' => '', |
|
719 | - ), |
|
720 | - //1...12 |
|
721 | - 'g' => array( |
|
722 | - 'js' => 'h', |
|
723 | - 'moment' => 'h', |
|
724 | - ), |
|
725 | - //0...23 |
|
726 | - 'G' => array( |
|
727 | - 'js' => 'H', |
|
728 | - 'moment' => 'H', |
|
729 | - ), |
|
730 | - //01...12 |
|
731 | - 'h' => array( |
|
732 | - 'js' => 'hh', |
|
733 | - 'moment' => 'hh', |
|
734 | - ), |
|
735 | - //00...23 |
|
736 | - 'H' => array( |
|
737 | - 'js' => 'HH', |
|
738 | - 'moment' => 'HH', |
|
739 | - ), |
|
740 | - //00..59 |
|
741 | - 'i' => array( |
|
742 | - 'js' => 'mm', |
|
743 | - 'moment' => 'mm', |
|
744 | - ), |
|
745 | - //seconds... 00...59 |
|
746 | - 's' => array( |
|
747 | - 'js' => 'ss', |
|
748 | - 'moment' => 'ss', |
|
749 | - ), |
|
750 | - //microseconds |
|
751 | - 'u' => array( |
|
752 | - 'js' => '', |
|
753 | - 'moment' => '', |
|
754 | - ), |
|
755 | - ); |
|
756 | - $jquery_ui_format = ""; |
|
757 | - $moment_format = ""; |
|
758 | - $escaping = false; |
|
759 | - for ($i = 0; $i < strlen($format_string); $i++) { |
|
760 | - $char = $format_string[$i]; |
|
761 | - if ($char === '\\') { // PHP date format escaping character |
|
762 | - $i++; |
|
763 | - if ($escaping) { |
|
764 | - $jquery_ui_format .= $format_string[$i]; |
|
765 | - $moment_format .= $format_string[$i]; |
|
766 | - } else { |
|
767 | - $jquery_ui_format .= '\'' . $format_string[$i]; |
|
768 | - $moment_format .= $format_string[$i]; |
|
769 | - } |
|
770 | - $escaping = true; |
|
771 | - } else { |
|
772 | - if ($escaping) { |
|
773 | - $jquery_ui_format .= "'"; |
|
774 | - $moment_format .= "'"; |
|
775 | - $escaping = false; |
|
776 | - } |
|
777 | - if (isset($symbols_map[$char])) { |
|
778 | - $jquery_ui_format .= $symbols_map[$char]['js']; |
|
779 | - $moment_format .= $symbols_map[$char]['moment']; |
|
780 | - } else { |
|
781 | - $jquery_ui_format .= $char; |
|
782 | - $moment_format .= $char; |
|
783 | - } |
|
784 | - } |
|
785 | - } |
|
786 | - return array('js' => $jquery_ui_format, 'moment' => $moment_format); |
|
787 | - } |
|
788 | - |
|
789 | - |
|
790 | - /** |
|
791 | - * This takes an incoming format string and validates it to ensure it will work fine with PHP. |
|
792 | - * |
|
793 | - * @param string $format_string Incoming format string for php date(). |
|
794 | - * @return mixed bool|array If all is okay then TRUE is returned. Otherwise an array of validation |
|
795 | - * errors is returned. So for client code calling, check for is_array() to |
|
796 | - * indicate failed validations. |
|
797 | - */ |
|
798 | - public static function validate_format_string($format_string) |
|
799 | - { |
|
800 | - $error_msg = array(); |
|
801 | - //time format checks |
|
802 | - switch (true) { |
|
803 | - case strpos($format_string, 'h') !== false : |
|
804 | - case strpos($format_string, 'g') !== false : |
|
805 | - /** |
|
806 | - * if the time string has a lowercase 'h' which == 12 hour time format and there |
|
807 | - * is not any ante meridiem format ('a' or 'A'). Then throw an error because its |
|
808 | - * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am. |
|
809 | - */ |
|
810 | - if (strpos(strtoupper($format_string), 'A') === false) { |
|
811 | - $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', |
|
812 | - 'event_espresso'); |
|
813 | - } |
|
814 | - break; |
|
815 | - |
|
816 | - } |
|
817 | - |
|
818 | - return empty($error_msg) ? true : $error_msg; |
|
819 | - } |
|
820 | - |
|
821 | - |
|
822 | - /** |
|
823 | - * If the the first date starts at midnight on one day, and the next date ends at midnight on the |
|
824 | - * very next day then this method will return true. |
|
825 | - * If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true. |
|
826 | - * If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false. |
|
827 | - * If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true. |
|
828 | - * |
|
829 | - * @param mixed $date_1 |
|
830 | - * @param mixed $date_2 |
|
831 | - * @return bool |
|
832 | - */ |
|
833 | - public static function dates_represent_one_24_hour_date($date_1, $date_2) |
|
834 | - { |
|
835 | - |
|
836 | - if ( |
|
837 | - (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
838 | - ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
|
839 | - ) { |
|
840 | - return false; |
|
841 | - } |
|
842 | - return $date_2->format('U') - $date_1->format('U') == 86400 ? true : false; |
|
843 | - } |
|
844 | - |
|
845 | - |
|
846 | - /** |
|
847 | - * This returns the appropriate query interval string that can be used in sql queries involving mysql Date |
|
848 | - * Functions. |
|
849 | - * |
|
850 | - * @param string $timezone_string A timezone string in a valid format to instantiate a DateTimeZone object. |
|
851 | - * @param string $field_for_interval The Database field that is the interval is applied to in the query. |
|
852 | - * @return string |
|
853 | - */ |
|
854 | - public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval) |
|
855 | - { |
|
856 | - try { |
|
857 | - /** need to account for timezone offset on the selects */ |
|
858 | - $DateTimeZone = new DateTimeZone($timezone_string); |
|
859 | - } catch (Exception $e) { |
|
860 | - $DateTimeZone = null; |
|
861 | - } |
|
862 | - |
|
863 | - /** |
|
864 | - * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds. |
|
865 | - * Hence we do the calc for DateTimeZone::getOffset. |
|
866 | - */ |
|
867 | - $offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset'); |
|
868 | - $query_interval = $offset < 0 |
|
869 | - ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)' |
|
870 | - : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)'; |
|
871 | - return $query_interval; |
|
872 | - } |
|
873 | - |
|
874 | - /** |
|
875 | - * Retrieves the site's default timezone and returns it formatted so it's ready for display |
|
876 | - * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string' |
|
877 | - * and 'gmt_offset' WordPress options directly; or use the filter |
|
878 | - * FHEE__EEH_DTT_Helper__get_timezone_string_for_display |
|
879 | - * (although note that we remove any HTML that may be added) |
|
880 | - * |
|
881 | - * @return string |
|
882 | - */ |
|
883 | - public static function get_timezone_string_for_display() |
|
884 | - { |
|
885 | - $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', ''); |
|
886 | - if (! empty($pretty_timezone)) { |
|
887 | - return esc_html($pretty_timezone); |
|
888 | - } |
|
889 | - $timezone_string = get_option('timezone_string'); |
|
890 | - if ($timezone_string) { |
|
891 | - static $mo_loaded = false; |
|
892 | - // Load translations for continents and cities just like wp_timezone_choice does |
|
893 | - if (! $mo_loaded) { |
|
894 | - $locale = get_locale(); |
|
895 | - $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo'; |
|
896 | - load_textdomain('continents-cities', $mofile); |
|
897 | - $mo_loaded = true; |
|
898 | - } |
|
899 | - //well that was easy. |
|
900 | - $parts = explode('/', $timezone_string); |
|
901 | - //remove the continent |
|
902 | - unset($parts[0]); |
|
903 | - $t_parts = array(); |
|
904 | - foreach ($parts as $part) { |
|
905 | - $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities'); |
|
906 | - } |
|
907 | - return implode(' - ', $t_parts); |
|
908 | - } |
|
909 | - //they haven't set the timezone string, so let's return a string like "UTC+1" |
|
910 | - $gmt_offset = get_option('gmt_offset'); |
|
911 | - if (intval($gmt_offset) >= 0) { |
|
912 | - $prefix = '+'; |
|
913 | - } else { |
|
914 | - $prefix = ''; |
|
915 | - } |
|
916 | - $parts = explode('.', (string)$gmt_offset); |
|
917 | - if (count($parts) === 1) { |
|
918 | - $parts[1] = '00'; |
|
919 | - } else { |
|
920 | - //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25) |
|
921 | - //to minutes, eg 30 or 15, respectively |
|
922 | - $hour_fraction = (float)('0.' . $parts[1]); |
|
923 | - $parts[1] = (string)$hour_fraction * 60; |
|
924 | - } |
|
925 | - return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts)); |
|
926 | - } |
|
323 | + endif; |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + /** |
|
328 | + * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string. |
|
329 | + * If no unix timestamp is given then time() is used. If no timezone is given then the set timezone string for |
|
330 | + * the site is used. |
|
331 | + * This is used typically when using a Unix timestamp any core WP functions that expect their specially |
|
332 | + * computed timestamp (i.e. date_i18n() ) |
|
333 | + * |
|
334 | + * @param int $unix_timestamp if 0, then time() will be used. |
|
335 | + * @param string $timezone_string timezone_string. If empty, then the current set timezone for the |
|
336 | + * site will be used. |
|
337 | + * @return int $unix_timestamp with the offset applied for the given timezone. |
|
338 | + */ |
|
339 | + public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') |
|
340 | + { |
|
341 | + $unix_timestamp = $unix_timestamp === 0 ? time() : (int)$unix_timestamp; |
|
342 | + $timezone_string = self::get_valid_timezone_string($timezone_string); |
|
343 | + $TimeZone = new DateTimeZone($timezone_string); |
|
344 | + |
|
345 | + $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone); |
|
346 | + $offset = timezone_offset_get($TimeZone, $DateTime); |
|
347 | + return (int)$DateTime->format('U') + (int)$offset; |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + /** |
|
352 | + * _set_date_time_field |
|
353 | + * modifies EE_Base_Class EE_Datetime_Field objects |
|
354 | + * |
|
355 | + * @param EE_Base_Class $obj EE_Base_Class object |
|
356 | + * @param DateTime $DateTime PHP DateTime object |
|
357 | + * @param string $datetime_field_name the datetime fieldname to be manipulated |
|
358 | + * @return EE_Base_Class |
|
359 | + */ |
|
360 | + protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) |
|
361 | + { |
|
362 | + // grab current datetime format |
|
363 | + $current_format = $obj->get_format(); |
|
364 | + // set new full timestamp format |
|
365 | + $obj->set_date_format(EE_Datetime_Field::mysql_date_format); |
|
366 | + $obj->set_time_format(EE_Datetime_Field::mysql_time_format); |
|
367 | + // set the new date value using a full timestamp format so that no data is lost |
|
368 | + $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format)); |
|
369 | + // reset datetime formats |
|
370 | + $obj->set_date_format($current_format[0]); |
|
371 | + $obj->set_time_format($current_format[1]); |
|
372 | + return $obj; |
|
373 | + } |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * date_time_add |
|
378 | + * helper for doing simple datetime calculations on a given datetime from EE_Base_Class |
|
379 | + * and modifying it IN the EE_Base_Class so you don't have to do anything else. |
|
380 | + * |
|
381 | + * @param EE_Base_Class $obj EE_Base_Class object |
|
382 | + * @param string $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated |
|
383 | + * @param string $period what you are adding. The options are (years, months, days, hours, |
|
384 | + * minutes, seconds) defaults to years |
|
385 | + * @param integer $value what you want to increment the time by |
|
386 | + * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it |
|
387 | + * (chaining) |
|
388 | + */ |
|
389 | + public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) |
|
390 | + { |
|
391 | + //get the raw UTC date. |
|
392 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
393 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value); |
|
394 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
395 | + } |
|
396 | + |
|
397 | + |
|
398 | + /** |
|
399 | + * date_time_subtract |
|
400 | + * same as date_time_add except subtracting value instead of adding. |
|
401 | + * |
|
402 | + * @param \EE_Base_Class $obj |
|
403 | + * @param string $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated |
|
404 | + * @param string $period |
|
405 | + * @param int $value |
|
406 | + * @return \EE_Base_Class |
|
407 | + */ |
|
408 | + public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) |
|
409 | + { |
|
410 | + //get the raw UTC date |
|
411 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
412 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-'); |
|
413 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
414 | + } |
|
415 | + |
|
416 | + |
|
417 | + /** |
|
418 | + * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters |
|
419 | + * |
|
420 | + * @param DateTime $DateTime DateTime object |
|
421 | + * @param string $period a value to indicate what interval is being used in the calculation. The options are |
|
422 | + * 'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years. |
|
423 | + * @param integer $value What you want to increment the date by |
|
424 | + * @param string $operand What operand you wish to use for the calculation |
|
425 | + * @return \DateTime return whatever type came in. |
|
426 | + * @throws \EE_Error |
|
427 | + */ |
|
428 | + protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') |
|
429 | + { |
|
430 | + if (! $DateTime instanceof DateTime) { |
|
431 | + throw new EE_Error( |
|
432 | + sprintf( |
|
433 | + __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
|
434 | + print_r($DateTime, true) |
|
435 | + ) |
|
436 | + ); |
|
437 | + } |
|
438 | + switch ($period) { |
|
439 | + case 'years' : |
|
440 | + $value = 'P' . $value . 'Y'; |
|
441 | + break; |
|
442 | + case 'months' : |
|
443 | + $value = 'P' . $value . 'M'; |
|
444 | + break; |
|
445 | + case 'weeks' : |
|
446 | + $value = 'P' . $value . 'W'; |
|
447 | + break; |
|
448 | + case 'days' : |
|
449 | + $value = 'P' . $value . 'D'; |
|
450 | + break; |
|
451 | + case 'hours' : |
|
452 | + $value = 'PT' . $value . 'H'; |
|
453 | + break; |
|
454 | + case 'minutes' : |
|
455 | + $value = 'PT' . $value . 'M'; |
|
456 | + break; |
|
457 | + case 'seconds' : |
|
458 | + $value = 'PT' . $value . 'S'; |
|
459 | + break; |
|
460 | + } |
|
461 | + switch ($operand) { |
|
462 | + case '+': |
|
463 | + $DateTime->add(new DateInterval($value)); |
|
464 | + break; |
|
465 | + case '-': |
|
466 | + $DateTime->sub(new DateInterval($value)); |
|
467 | + break; |
|
468 | + } |
|
469 | + return $DateTime; |
|
470 | + } |
|
471 | + |
|
472 | + |
|
473 | + /** |
|
474 | + * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters |
|
475 | + * |
|
476 | + * @param int $timestamp Unix timestamp |
|
477 | + * @param string $period a value to indicate what interval is being used in the calculation. The options are |
|
478 | + * 'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years. |
|
479 | + * @param integer $value What you want to increment the date by |
|
480 | + * @param string $operand What operand you wish to use for the calculation |
|
481 | + * @return \DateTime return whatever type came in. |
|
482 | + * @throws \EE_Error |
|
483 | + */ |
|
484 | + protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') |
|
485 | + { |
|
486 | + if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
487 | + throw new EE_Error( |
|
488 | + sprintf( |
|
489 | + __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
|
490 | + print_r($timestamp, true) |
|
491 | + ) |
|
492 | + ); |
|
493 | + } |
|
494 | + switch ($period) { |
|
495 | + case 'years' : |
|
496 | + $value = YEAR_IN_SECONDS * $value; |
|
497 | + break; |
|
498 | + case 'months' : |
|
499 | + $value = YEAR_IN_SECONDS / 12 * $value; |
|
500 | + break; |
|
501 | + case 'weeks' : |
|
502 | + $value = WEEK_IN_SECONDS * $value; |
|
503 | + break; |
|
504 | + case 'days' : |
|
505 | + $value = DAY_IN_SECONDS * $value; |
|
506 | + break; |
|
507 | + case 'hours' : |
|
508 | + $value = HOUR_IN_SECONDS * $value; |
|
509 | + break; |
|
510 | + case 'minutes' : |
|
511 | + $value = MINUTE_IN_SECONDS * $value; |
|
512 | + break; |
|
513 | + } |
|
514 | + switch ($operand) { |
|
515 | + case '+': |
|
516 | + $timestamp += $value; |
|
517 | + break; |
|
518 | + case '-': |
|
519 | + $timestamp -= $value; |
|
520 | + break; |
|
521 | + } |
|
522 | + return $timestamp; |
|
523 | + } |
|
524 | + |
|
525 | + |
|
526 | + /** |
|
527 | + * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming |
|
528 | + * parameters and returns the new timestamp or DateTime. |
|
529 | + * |
|
530 | + * @param int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp |
|
531 | + * @param string $period a value to indicate what interval is being used in the |
|
532 | + * calculation. The options are 'years', 'months', 'days', 'hours', |
|
533 | + * 'minutes', 'seconds'. Defaults to years. |
|
534 | + * @param integer $value What you want to increment the date by |
|
535 | + * @param string $operand What operand you wish to use for the calculation |
|
536 | + * @return mixed string|DateTime return whatever type came in. |
|
537 | + */ |
|
538 | + public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') |
|
539 | + { |
|
540 | + if ($DateTime_or_timestamp instanceof DateTime) { |
|
541 | + return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand); |
|
542 | + } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) { |
|
543 | + return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand); |
|
544 | + } else { |
|
545 | + //error |
|
546 | + return $DateTime_or_timestamp; |
|
547 | + } |
|
548 | + } |
|
549 | + |
|
550 | + |
|
551 | + /** |
|
552 | + * The purpose of this helper method is to receive an incoming format string in php date/time format |
|
553 | + * and spit out the js and moment.js equivalent formats. |
|
554 | + * Note, if no format string is given, then it is assumed the user wants what is set for WP. |
|
555 | + * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date- |
|
556 | + * time picker. |
|
557 | + * |
|
558 | + * @see http://stackoverflow.com/posts/16725290/ for the code inspiration. |
|
559 | + * @param null $date_format_string |
|
560 | + * @param null $time_format_string |
|
561 | + * @return array |
|
562 | + * array( |
|
563 | + * 'js' => array ( |
|
564 | + * 'date' => //date format |
|
565 | + * 'time' => //time format |
|
566 | + * ), |
|
567 | + * 'moment' => //date and time format. |
|
568 | + * ) |
|
569 | + */ |
|
570 | + public static function convert_php_to_js_and_moment_date_formats( |
|
571 | + $date_format_string = null, |
|
572 | + $time_format_string = null |
|
573 | + ) { |
|
574 | + if ($date_format_string === null) { |
|
575 | + $date_format_string = get_option('date_format'); |
|
576 | + } |
|
577 | + |
|
578 | + if ($time_format_string === null) { |
|
579 | + $time_format_string = get_option('time_format'); |
|
580 | + } |
|
581 | + |
|
582 | + $date_format = self::_php_to_js_moment_converter($date_format_string); |
|
583 | + $time_format = self::_php_to_js_moment_converter($time_format_string); |
|
584 | + |
|
585 | + return array( |
|
586 | + 'js' => array( |
|
587 | + 'date' => $date_format['js'], |
|
588 | + 'time' => $time_format['js'], |
|
589 | + ), |
|
590 | + 'moment' => $date_format['moment'] . ' ' . $time_format['moment'], |
|
591 | + ); |
|
592 | + } |
|
593 | + |
|
594 | + |
|
595 | + /** |
|
596 | + * This converts incoming format string into js and moment variations. |
|
597 | + * |
|
598 | + * @param string $format_string incoming php format string |
|
599 | + * @return array js and moment formats. |
|
600 | + */ |
|
601 | + protected static function _php_to_js_moment_converter($format_string) |
|
602 | + { |
|
603 | + /** |
|
604 | + * This is a map of symbols for formats. |
|
605 | + * The index is the php symbol, the equivalent values are in the array. |
|
606 | + * |
|
607 | + * @var array |
|
608 | + */ |
|
609 | + $symbols_map = array( |
|
610 | + // Day |
|
611 | + //01 |
|
612 | + 'd' => array( |
|
613 | + 'js' => 'dd', |
|
614 | + 'moment' => 'DD', |
|
615 | + ), |
|
616 | + //Mon |
|
617 | + 'D' => array( |
|
618 | + 'js' => 'D', |
|
619 | + 'moment' => 'ddd', |
|
620 | + ), |
|
621 | + //1,2,...31 |
|
622 | + 'j' => array( |
|
623 | + 'js' => 'd', |
|
624 | + 'moment' => 'D', |
|
625 | + ), |
|
626 | + //Monday |
|
627 | + 'l' => array( |
|
628 | + 'js' => 'DD', |
|
629 | + 'moment' => 'dddd', |
|
630 | + ), |
|
631 | + //ISO numeric representation of the day of the week (1-6) |
|
632 | + 'N' => array( |
|
633 | + 'js' => '', |
|
634 | + 'moment' => 'E', |
|
635 | + ), |
|
636 | + //st,nd.rd |
|
637 | + 'S' => array( |
|
638 | + 'js' => '', |
|
639 | + 'moment' => 'o', |
|
640 | + ), |
|
641 | + //numeric representation of day of week (0-6) |
|
642 | + 'w' => array( |
|
643 | + 'js' => '', |
|
644 | + 'moment' => 'd', |
|
645 | + ), |
|
646 | + //day of year starting from 0 (0-365) |
|
647 | + 'z' => array( |
|
648 | + 'js' => 'o', |
|
649 | + 'moment' => 'DDD' //note moment does not start with 0 so will need to modify by subtracting 1 |
|
650 | + ), |
|
651 | + // Week |
|
652 | + //ISO-8601 week number of year (weeks starting on monday) |
|
653 | + 'W' => array( |
|
654 | + 'js' => '', |
|
655 | + 'moment' => 'w', |
|
656 | + ), |
|
657 | + // Month |
|
658 | + // January...December |
|
659 | + 'F' => array( |
|
660 | + 'js' => 'MM', |
|
661 | + 'moment' => 'MMMM', |
|
662 | + ), |
|
663 | + //01...12 |
|
664 | + 'm' => array( |
|
665 | + 'js' => 'mm', |
|
666 | + 'moment' => 'MM', |
|
667 | + ), |
|
668 | + //Jan...Dec |
|
669 | + 'M' => array( |
|
670 | + 'js' => 'M', |
|
671 | + 'moment' => 'MMM', |
|
672 | + ), |
|
673 | + //1-12 |
|
674 | + 'n' => array( |
|
675 | + 'js' => 'm', |
|
676 | + 'moment' => 'M', |
|
677 | + ), |
|
678 | + //number of days in given month |
|
679 | + 't' => array( |
|
680 | + 'js' => '', |
|
681 | + 'moment' => '', |
|
682 | + ), |
|
683 | + // Year |
|
684 | + //whether leap year or not 1/0 |
|
685 | + 'L' => array( |
|
686 | + 'js' => '', |
|
687 | + 'moment' => '', |
|
688 | + ), |
|
689 | + //ISO-8601 year number |
|
690 | + 'o' => array( |
|
691 | + 'js' => '', |
|
692 | + 'moment' => 'GGGG', |
|
693 | + ), |
|
694 | + //1999...2003 |
|
695 | + 'Y' => array( |
|
696 | + 'js' => 'yy', |
|
697 | + 'moment' => 'YYYY', |
|
698 | + ), |
|
699 | + //99...03 |
|
700 | + 'y' => array( |
|
701 | + 'js' => 'y', |
|
702 | + 'moment' => 'YY', |
|
703 | + ), |
|
704 | + // Time |
|
705 | + // am/pm |
|
706 | + 'a' => array( |
|
707 | + 'js' => 'tt', |
|
708 | + 'moment' => 'a', |
|
709 | + ), |
|
710 | + // AM/PM |
|
711 | + 'A' => array( |
|
712 | + 'js' => 'TT', |
|
713 | + 'moment' => 'A', |
|
714 | + ), |
|
715 | + // Swatch Internet Time?!? |
|
716 | + 'B' => array( |
|
717 | + 'js' => '', |
|
718 | + 'moment' => '', |
|
719 | + ), |
|
720 | + //1...12 |
|
721 | + 'g' => array( |
|
722 | + 'js' => 'h', |
|
723 | + 'moment' => 'h', |
|
724 | + ), |
|
725 | + //0...23 |
|
726 | + 'G' => array( |
|
727 | + 'js' => 'H', |
|
728 | + 'moment' => 'H', |
|
729 | + ), |
|
730 | + //01...12 |
|
731 | + 'h' => array( |
|
732 | + 'js' => 'hh', |
|
733 | + 'moment' => 'hh', |
|
734 | + ), |
|
735 | + //00...23 |
|
736 | + 'H' => array( |
|
737 | + 'js' => 'HH', |
|
738 | + 'moment' => 'HH', |
|
739 | + ), |
|
740 | + //00..59 |
|
741 | + 'i' => array( |
|
742 | + 'js' => 'mm', |
|
743 | + 'moment' => 'mm', |
|
744 | + ), |
|
745 | + //seconds... 00...59 |
|
746 | + 's' => array( |
|
747 | + 'js' => 'ss', |
|
748 | + 'moment' => 'ss', |
|
749 | + ), |
|
750 | + //microseconds |
|
751 | + 'u' => array( |
|
752 | + 'js' => '', |
|
753 | + 'moment' => '', |
|
754 | + ), |
|
755 | + ); |
|
756 | + $jquery_ui_format = ""; |
|
757 | + $moment_format = ""; |
|
758 | + $escaping = false; |
|
759 | + for ($i = 0; $i < strlen($format_string); $i++) { |
|
760 | + $char = $format_string[$i]; |
|
761 | + if ($char === '\\') { // PHP date format escaping character |
|
762 | + $i++; |
|
763 | + if ($escaping) { |
|
764 | + $jquery_ui_format .= $format_string[$i]; |
|
765 | + $moment_format .= $format_string[$i]; |
|
766 | + } else { |
|
767 | + $jquery_ui_format .= '\'' . $format_string[$i]; |
|
768 | + $moment_format .= $format_string[$i]; |
|
769 | + } |
|
770 | + $escaping = true; |
|
771 | + } else { |
|
772 | + if ($escaping) { |
|
773 | + $jquery_ui_format .= "'"; |
|
774 | + $moment_format .= "'"; |
|
775 | + $escaping = false; |
|
776 | + } |
|
777 | + if (isset($symbols_map[$char])) { |
|
778 | + $jquery_ui_format .= $symbols_map[$char]['js']; |
|
779 | + $moment_format .= $symbols_map[$char]['moment']; |
|
780 | + } else { |
|
781 | + $jquery_ui_format .= $char; |
|
782 | + $moment_format .= $char; |
|
783 | + } |
|
784 | + } |
|
785 | + } |
|
786 | + return array('js' => $jquery_ui_format, 'moment' => $moment_format); |
|
787 | + } |
|
788 | + |
|
789 | + |
|
790 | + /** |
|
791 | + * This takes an incoming format string and validates it to ensure it will work fine with PHP. |
|
792 | + * |
|
793 | + * @param string $format_string Incoming format string for php date(). |
|
794 | + * @return mixed bool|array If all is okay then TRUE is returned. Otherwise an array of validation |
|
795 | + * errors is returned. So for client code calling, check for is_array() to |
|
796 | + * indicate failed validations. |
|
797 | + */ |
|
798 | + public static function validate_format_string($format_string) |
|
799 | + { |
|
800 | + $error_msg = array(); |
|
801 | + //time format checks |
|
802 | + switch (true) { |
|
803 | + case strpos($format_string, 'h') !== false : |
|
804 | + case strpos($format_string, 'g') !== false : |
|
805 | + /** |
|
806 | + * if the time string has a lowercase 'h' which == 12 hour time format and there |
|
807 | + * is not any ante meridiem format ('a' or 'A'). Then throw an error because its |
|
808 | + * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am. |
|
809 | + */ |
|
810 | + if (strpos(strtoupper($format_string), 'A') === false) { |
|
811 | + $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', |
|
812 | + 'event_espresso'); |
|
813 | + } |
|
814 | + break; |
|
815 | + |
|
816 | + } |
|
817 | + |
|
818 | + return empty($error_msg) ? true : $error_msg; |
|
819 | + } |
|
820 | + |
|
821 | + |
|
822 | + /** |
|
823 | + * If the the first date starts at midnight on one day, and the next date ends at midnight on the |
|
824 | + * very next day then this method will return true. |
|
825 | + * If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true. |
|
826 | + * If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false. |
|
827 | + * If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true. |
|
828 | + * |
|
829 | + * @param mixed $date_1 |
|
830 | + * @param mixed $date_2 |
|
831 | + * @return bool |
|
832 | + */ |
|
833 | + public static function dates_represent_one_24_hour_date($date_1, $date_2) |
|
834 | + { |
|
835 | + |
|
836 | + if ( |
|
837 | + (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
838 | + ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
|
839 | + ) { |
|
840 | + return false; |
|
841 | + } |
|
842 | + return $date_2->format('U') - $date_1->format('U') == 86400 ? true : false; |
|
843 | + } |
|
844 | + |
|
845 | + |
|
846 | + /** |
|
847 | + * This returns the appropriate query interval string that can be used in sql queries involving mysql Date |
|
848 | + * Functions. |
|
849 | + * |
|
850 | + * @param string $timezone_string A timezone string in a valid format to instantiate a DateTimeZone object. |
|
851 | + * @param string $field_for_interval The Database field that is the interval is applied to in the query. |
|
852 | + * @return string |
|
853 | + */ |
|
854 | + public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval) |
|
855 | + { |
|
856 | + try { |
|
857 | + /** need to account for timezone offset on the selects */ |
|
858 | + $DateTimeZone = new DateTimeZone($timezone_string); |
|
859 | + } catch (Exception $e) { |
|
860 | + $DateTimeZone = null; |
|
861 | + } |
|
862 | + |
|
863 | + /** |
|
864 | + * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds. |
|
865 | + * Hence we do the calc for DateTimeZone::getOffset. |
|
866 | + */ |
|
867 | + $offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset'); |
|
868 | + $query_interval = $offset < 0 |
|
869 | + ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)' |
|
870 | + : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)'; |
|
871 | + return $query_interval; |
|
872 | + } |
|
873 | + |
|
874 | + /** |
|
875 | + * Retrieves the site's default timezone and returns it formatted so it's ready for display |
|
876 | + * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string' |
|
877 | + * and 'gmt_offset' WordPress options directly; or use the filter |
|
878 | + * FHEE__EEH_DTT_Helper__get_timezone_string_for_display |
|
879 | + * (although note that we remove any HTML that may be added) |
|
880 | + * |
|
881 | + * @return string |
|
882 | + */ |
|
883 | + public static function get_timezone_string_for_display() |
|
884 | + { |
|
885 | + $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', ''); |
|
886 | + if (! empty($pretty_timezone)) { |
|
887 | + return esc_html($pretty_timezone); |
|
888 | + } |
|
889 | + $timezone_string = get_option('timezone_string'); |
|
890 | + if ($timezone_string) { |
|
891 | + static $mo_loaded = false; |
|
892 | + // Load translations for continents and cities just like wp_timezone_choice does |
|
893 | + if (! $mo_loaded) { |
|
894 | + $locale = get_locale(); |
|
895 | + $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo'; |
|
896 | + load_textdomain('continents-cities', $mofile); |
|
897 | + $mo_loaded = true; |
|
898 | + } |
|
899 | + //well that was easy. |
|
900 | + $parts = explode('/', $timezone_string); |
|
901 | + //remove the continent |
|
902 | + unset($parts[0]); |
|
903 | + $t_parts = array(); |
|
904 | + foreach ($parts as $part) { |
|
905 | + $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities'); |
|
906 | + } |
|
907 | + return implode(' - ', $t_parts); |
|
908 | + } |
|
909 | + //they haven't set the timezone string, so let's return a string like "UTC+1" |
|
910 | + $gmt_offset = get_option('gmt_offset'); |
|
911 | + if (intval($gmt_offset) >= 0) { |
|
912 | + $prefix = '+'; |
|
913 | + } else { |
|
914 | + $prefix = ''; |
|
915 | + } |
|
916 | + $parts = explode('.', (string)$gmt_offset); |
|
917 | + if (count($parts) === 1) { |
|
918 | + $parts[1] = '00'; |
|
919 | + } else { |
|
920 | + //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25) |
|
921 | + //to minutes, eg 30 or 15, respectively |
|
922 | + $hour_fraction = (float)('0.' . $parts[1]); |
|
923 | + $parts[1] = (string)$hour_fraction * 60; |
|
924 | + } |
|
925 | + return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts)); |
|
926 | + } |
|
927 | 927 | |
928 | 928 | |
929 | 929 | }// end class EEH_DTT_Helper |
930 | 930 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | } |
5 | 5 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | new DateTimeZone($timezone_string); |
75 | 75 | } catch (Exception $e) { |
76 | 76 | // sometimes we take exception to exceptions |
77 | - if (! $throw_error) { |
|
77 | + if ( ! $throw_error) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | throw new EE_Error( |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | } |
137 | 137 | $offset = get_option('gmt_offset'); |
138 | - return (int)($offset * HOUR_IN_SECONDS); |
|
138 | + return (int) ($offset * HOUR_IN_SECONDS); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | public static function adjust_invalid_gmt_offsets($gmt_offset = 0) |
150 | 150 | { |
151 | 151 | //make sure $gmt_offset is int |
152 | - $gmt_offset = (int)$gmt_offset; |
|
152 | + $gmt_offset = (int) $gmt_offset; |
|
153 | 153 | switch ($gmt_offset) { |
154 | 154 | |
155 | 155 | // case -30600 : |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | public static function timezone_select_input($timezone_string = '') |
234 | 234 | { |
235 | 235 | // get WP date time format |
236 | - $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
236 | + $datetime_format = get_option('date_format').' '.get_option('time_format'); |
|
237 | 237 | // if passed a value, then use that, else get WP option |
238 | 238 | $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
239 | 239 | // check if the timezone is valid but don't throw any errors if it isn't |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | // Create a UTC+- zone if no timezone string exists |
246 | 246 | $check_zone_info = false; |
247 | 247 | if ($gmt_offset > 0) { |
248 | - $timezone_string = 'UTC+' . $gmt_offset; |
|
248 | + $timezone_string = 'UTC+'.$gmt_offset; |
|
249 | 249 | } elseif ($gmt_offset < 0) { |
250 | - $timezone_string = 'UTC' . $gmt_offset; |
|
250 | + $timezone_string = 'UTC'.$gmt_offset; |
|
251 | 251 | } else { |
252 | 252 | $timezone_string = 'UTC'; |
253 | 253 | } |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | __('%1$sUTC%2$s time is %3$s'), |
270 | 270 | '<abbr title="Coordinated Universal Time">', |
271 | 271 | '</abbr>', |
272 | - '<code>' . date_i18n($datetime_format, false, true) . '</code>' |
|
272 | + '<code>'.date_i18n($datetime_format, false, true).'</code>' |
|
273 | 273 | ); |
274 | 274 | ?></span> |
275 | - <?php if (! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
|
276 | - <br/><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n($datetime_format) . '</code>'); ?></span> |
|
275 | + <?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
|
276 | + <br/><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span> |
|
277 | 277 | <?php endif; ?> |
278 | 278 | |
279 | 279 | <?php if ($check_zone_info && $timezone_string) : ?> |
@@ -306,11 +306,10 @@ discard block |
||
306 | 306 | |
307 | 307 | if ($found) { |
308 | 308 | $message = $tr['isdst'] ? |
309 | - __(' Daylight saving time begins on: %s.') : |
|
310 | - __(' Standard time begins on: %s.'); |
|
309 | + __(' Daylight saving time begins on: %s.') : __(' Standard time begins on: %s.'); |
|
311 | 310 | // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
312 | 311 | printf($message, |
313 | - '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >'); |
|
312 | + '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >'); |
|
314 | 313 | } else { |
315 | 314 | _e('This timezone does not observe daylight saving time.'); |
316 | 315 | } |
@@ -338,13 +337,13 @@ discard block |
||
338 | 337 | */ |
339 | 338 | public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') |
340 | 339 | { |
341 | - $unix_timestamp = $unix_timestamp === 0 ? time() : (int)$unix_timestamp; |
|
340 | + $unix_timestamp = $unix_timestamp === 0 ? time() : (int) $unix_timestamp; |
|
342 | 341 | $timezone_string = self::get_valid_timezone_string($timezone_string); |
343 | 342 | $TimeZone = new DateTimeZone($timezone_string); |
344 | 343 | |
345 | - $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone); |
|
344 | + $DateTime = new DateTime('@'.$unix_timestamp, $TimeZone); |
|
346 | 345 | $offset = timezone_offset_get($TimeZone, $DateTime); |
347 | - return (int)$DateTime->format('U') + (int)$offset; |
|
346 | + return (int) $DateTime->format('U') + (int) $offset; |
|
348 | 347 | } |
349 | 348 | |
350 | 349 | |
@@ -427,7 +426,7 @@ discard block |
||
427 | 426 | */ |
428 | 427 | protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') |
429 | 428 | { |
430 | - if (! $DateTime instanceof DateTime) { |
|
429 | + if ( ! $DateTime instanceof DateTime) { |
|
431 | 430 | throw new EE_Error( |
432 | 431 | sprintf( |
433 | 432 | __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
@@ -437,25 +436,25 @@ discard block |
||
437 | 436 | } |
438 | 437 | switch ($period) { |
439 | 438 | case 'years' : |
440 | - $value = 'P' . $value . 'Y'; |
|
439 | + $value = 'P'.$value.'Y'; |
|
441 | 440 | break; |
442 | 441 | case 'months' : |
443 | - $value = 'P' . $value . 'M'; |
|
442 | + $value = 'P'.$value.'M'; |
|
444 | 443 | break; |
445 | 444 | case 'weeks' : |
446 | - $value = 'P' . $value . 'W'; |
|
445 | + $value = 'P'.$value.'W'; |
|
447 | 446 | break; |
448 | 447 | case 'days' : |
449 | - $value = 'P' . $value . 'D'; |
|
448 | + $value = 'P'.$value.'D'; |
|
450 | 449 | break; |
451 | 450 | case 'hours' : |
452 | - $value = 'PT' . $value . 'H'; |
|
451 | + $value = 'PT'.$value.'H'; |
|
453 | 452 | break; |
454 | 453 | case 'minutes' : |
455 | - $value = 'PT' . $value . 'M'; |
|
454 | + $value = 'PT'.$value.'M'; |
|
456 | 455 | break; |
457 | 456 | case 'seconds' : |
458 | - $value = 'PT' . $value . 'S'; |
|
457 | + $value = 'PT'.$value.'S'; |
|
459 | 458 | break; |
460 | 459 | } |
461 | 460 | switch ($operand) { |
@@ -483,7 +482,7 @@ discard block |
||
483 | 482 | */ |
484 | 483 | protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') |
485 | 484 | { |
486 | - if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
485 | + if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
487 | 486 | throw new EE_Error( |
488 | 487 | sprintf( |
489 | 488 | __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
@@ -587,7 +586,7 @@ discard block |
||
587 | 586 | 'date' => $date_format['js'], |
588 | 587 | 'time' => $time_format['js'], |
589 | 588 | ), |
590 | - 'moment' => $date_format['moment'] . ' ' . $time_format['moment'], |
|
589 | + 'moment' => $date_format['moment'].' '.$time_format['moment'], |
|
591 | 590 | ); |
592 | 591 | } |
593 | 592 | |
@@ -606,7 +605,7 @@ discard block |
||
606 | 605 | * |
607 | 606 | * @var array |
608 | 607 | */ |
609 | - $symbols_map = array( |
|
608 | + $symbols_map = array( |
|
610 | 609 | // Day |
611 | 610 | //01 |
612 | 611 | 'd' => array( |
@@ -764,7 +763,7 @@ discard block |
||
764 | 763 | $jquery_ui_format .= $format_string[$i]; |
765 | 764 | $moment_format .= $format_string[$i]; |
766 | 765 | } else { |
767 | - $jquery_ui_format .= '\'' . $format_string[$i]; |
|
766 | + $jquery_ui_format .= '\''.$format_string[$i]; |
|
768 | 767 | $moment_format .= $format_string[$i]; |
769 | 768 | } |
770 | 769 | $escaping = true; |
@@ -834,7 +833,7 @@ discard block |
||
834 | 833 | { |
835 | 834 | |
836 | 835 | if ( |
837 | - (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
836 | + ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
838 | 837 | ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
839 | 838 | ) { |
840 | 839 | return false; |
@@ -866,8 +865,8 @@ discard block |
||
866 | 865 | */ |
867 | 866 | $offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset'); |
868 | 867 | $query_interval = $offset < 0 |
869 | - ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)' |
|
870 | - : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)'; |
|
868 | + ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)' |
|
869 | + : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)'; |
|
871 | 870 | return $query_interval; |
872 | 871 | } |
873 | 872 | |
@@ -883,16 +882,16 @@ discard block |
||
883 | 882 | public static function get_timezone_string_for_display() |
884 | 883 | { |
885 | 884 | $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', ''); |
886 | - if (! empty($pretty_timezone)) { |
|
885 | + if ( ! empty($pretty_timezone)) { |
|
887 | 886 | return esc_html($pretty_timezone); |
888 | 887 | } |
889 | 888 | $timezone_string = get_option('timezone_string'); |
890 | 889 | if ($timezone_string) { |
891 | 890 | static $mo_loaded = false; |
892 | 891 | // Load translations for continents and cities just like wp_timezone_choice does |
893 | - if (! $mo_loaded) { |
|
892 | + if ( ! $mo_loaded) { |
|
894 | 893 | $locale = get_locale(); |
895 | - $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo'; |
|
894 | + $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo'; |
|
896 | 895 | load_textdomain('continents-cities', $mofile); |
897 | 896 | $mo_loaded = true; |
898 | 897 | } |
@@ -913,16 +912,16 @@ discard block |
||
913 | 912 | } else { |
914 | 913 | $prefix = ''; |
915 | 914 | } |
916 | - $parts = explode('.', (string)$gmt_offset); |
|
915 | + $parts = explode('.', (string) $gmt_offset); |
|
917 | 916 | if (count($parts) === 1) { |
918 | 917 | $parts[1] = '00'; |
919 | 918 | } else { |
920 | 919 | //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25) |
921 | 920 | //to minutes, eg 30 or 15, respectively |
922 | - $hour_fraction = (float)('0.' . $parts[1]); |
|
923 | - $parts[1] = (string)$hour_fraction * 60; |
|
921 | + $hour_fraction = (float) ('0.'.$parts[1]); |
|
922 | + $parts[1] = (string) $hour_fraction * 60; |
|
924 | 923 | } |
925 | - return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts)); |
|
924 | + return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts)); |
|
926 | 925 | } |
927 | 926 | |
928 | 927 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -13,168 +13,168 @@ discard block |
||
13 | 13 | class EE_Messages_Scheduler extends EE_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Number of seconds between batch sends/generates on the cron job. |
|
18 | - * Defaults to 5 minutes in seconds. If you want to change this interval, you can use the native WordPress |
|
19 | - * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added. |
|
20 | - * |
|
21 | - * @type int |
|
22 | - */ |
|
23 | - const message_cron_schedule = 300; |
|
24 | - |
|
25 | - /** |
|
26 | - * Constructor |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - //register tasks (and make sure only registered once). |
|
31 | - if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
32 | - add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
33 | - } |
|
34 | - |
|
35 | - //register callbacks for scheduled events (but make sure they are set only once). |
|
36 | - if (! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
37 | - array('EE_Messages_Scheduler', 'batch_generation')) |
|
38 | - ) { |
|
39 | - add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
40 | - add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
41 | - } |
|
42 | - |
|
43 | - //add custom schedules |
|
44 | - add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Add custom schedules for wp_cron |
|
50 | - * |
|
51 | - * @param $schedules |
|
52 | - */ |
|
53 | - public function custom_schedules($schedules) |
|
54 | - { |
|
55 | - $schedules['ee_message_cron'] = array( |
|
56 | - 'interval' => self::message_cron_schedule, |
|
57 | - 'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', |
|
58 | - 'event_espresso'), |
|
59 | - ); |
|
60 | - return $schedules; |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and |
|
66 | - * remove. |
|
67 | - * |
|
68 | - * @param array $tasks already existing scheduled tasks |
|
69 | - * @return array |
|
70 | - */ |
|
71 | - public function register_scheduled_tasks($tasks) |
|
72 | - { |
|
73 | - $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
|
74 | - $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
|
75 | - return $tasks; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * This initiates a non-blocking separate request to execute on a scheduled task. |
|
81 | - * Note: The EED_Messages module has the handlers for these requests. |
|
82 | - * |
|
83 | - * @param string $task The task the request is being generated for. |
|
84 | - */ |
|
85 | - public static function initiate_scheduled_non_blocking_request($task) |
|
86 | - { |
|
87 | - if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
|
88 | - true)) { |
|
89 | - $request_url = add_query_arg( |
|
90 | - array_merge( |
|
91 | - array('ee' => 'msg_cron_trigger'), |
|
92 | - EE_Messages_Scheduler::get_request_params($task) |
|
93 | - ), |
|
94 | - site_url() |
|
95 | - ); |
|
96 | - $request_args = array( |
|
97 | - 'timeout' => 300, |
|
98 | - 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
99 | - 'sslverify' => false, |
|
100 | - 'redirection' => 10, |
|
101 | - ); |
|
102 | - $response = wp_remote_get($request_url, $request_args); |
|
103 | - if (is_wp_error($response)) { |
|
104 | - trigger_error($response->get_error_message()); |
|
105 | - } |
|
106 | - } else { |
|
107 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron($task); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * This returns |
|
114 | - * the request params used for a scheduled message task request. |
|
115 | - * |
|
116 | - * @param string $task The task the request is for. |
|
117 | - * @return array |
|
118 | - */ |
|
119 | - public static function get_request_params($task) |
|
120 | - { |
|
121 | - //transient is used for flood control on msg_cron_trigger requests |
|
122 | - $transient_key = 'ee_trans_' . uniqid($task); |
|
123 | - set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
|
124 | - return array( |
|
125 | - 'type' => $task, |
|
126 | - 'key' => $transient_key, |
|
127 | - ); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * This is used to execute an immediate call to the run_cron task performed by EED_Messages |
|
133 | - * |
|
134 | - * @param string $task The task the request is being generated for. |
|
135 | - */ |
|
136 | - public static function initiate_immediate_request_on_cron($task) |
|
137 | - { |
|
138 | - $request_args = EE_Messages_Scheduler::get_request_params($task); |
|
139 | - //set those request args in the request so it gets picked up |
|
140 | - foreach ($request_args as $request_key => $request_value) { |
|
141 | - EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
142 | - } |
|
143 | - EED_Messages::instance()->run_cron(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event |
|
149 | - */ |
|
150 | - public static function batch_generation() |
|
151 | - { |
|
152 | - /** |
|
153 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
154 | - */ |
|
155 | - if ( |
|
156 | - ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
157 | - || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
158 | - ) { |
|
159 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate'); |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * Callback for scheduled AHEE__EE_Messages_Scheduler__sending |
|
166 | - */ |
|
167 | - public static function batch_sending() |
|
168 | - { |
|
169 | - /** |
|
170 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
171 | - */ |
|
172 | - if ( |
|
173 | - ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
174 | - || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
175 | - ) { |
|
176 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); |
|
177 | - } |
|
178 | - } |
|
16 | + /** |
|
17 | + * Number of seconds between batch sends/generates on the cron job. |
|
18 | + * Defaults to 5 minutes in seconds. If you want to change this interval, you can use the native WordPress |
|
19 | + * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added. |
|
20 | + * |
|
21 | + * @type int |
|
22 | + */ |
|
23 | + const message_cron_schedule = 300; |
|
24 | + |
|
25 | + /** |
|
26 | + * Constructor |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + //register tasks (and make sure only registered once). |
|
31 | + if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
32 | + add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
33 | + } |
|
34 | + |
|
35 | + //register callbacks for scheduled events (but make sure they are set only once). |
|
36 | + if (! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
37 | + array('EE_Messages_Scheduler', 'batch_generation')) |
|
38 | + ) { |
|
39 | + add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
40 | + add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
41 | + } |
|
42 | + |
|
43 | + //add custom schedules |
|
44 | + add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Add custom schedules for wp_cron |
|
50 | + * |
|
51 | + * @param $schedules |
|
52 | + */ |
|
53 | + public function custom_schedules($schedules) |
|
54 | + { |
|
55 | + $schedules['ee_message_cron'] = array( |
|
56 | + 'interval' => self::message_cron_schedule, |
|
57 | + 'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', |
|
58 | + 'event_espresso'), |
|
59 | + ); |
|
60 | + return $schedules; |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and |
|
66 | + * remove. |
|
67 | + * |
|
68 | + * @param array $tasks already existing scheduled tasks |
|
69 | + * @return array |
|
70 | + */ |
|
71 | + public function register_scheduled_tasks($tasks) |
|
72 | + { |
|
73 | + $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
|
74 | + $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
|
75 | + return $tasks; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * This initiates a non-blocking separate request to execute on a scheduled task. |
|
81 | + * Note: The EED_Messages module has the handlers for these requests. |
|
82 | + * |
|
83 | + * @param string $task The task the request is being generated for. |
|
84 | + */ |
|
85 | + public static function initiate_scheduled_non_blocking_request($task) |
|
86 | + { |
|
87 | + if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
|
88 | + true)) { |
|
89 | + $request_url = add_query_arg( |
|
90 | + array_merge( |
|
91 | + array('ee' => 'msg_cron_trigger'), |
|
92 | + EE_Messages_Scheduler::get_request_params($task) |
|
93 | + ), |
|
94 | + site_url() |
|
95 | + ); |
|
96 | + $request_args = array( |
|
97 | + 'timeout' => 300, |
|
98 | + 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
99 | + 'sslverify' => false, |
|
100 | + 'redirection' => 10, |
|
101 | + ); |
|
102 | + $response = wp_remote_get($request_url, $request_args); |
|
103 | + if (is_wp_error($response)) { |
|
104 | + trigger_error($response->get_error_message()); |
|
105 | + } |
|
106 | + } else { |
|
107 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron($task); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * This returns |
|
114 | + * the request params used for a scheduled message task request. |
|
115 | + * |
|
116 | + * @param string $task The task the request is for. |
|
117 | + * @return array |
|
118 | + */ |
|
119 | + public static function get_request_params($task) |
|
120 | + { |
|
121 | + //transient is used for flood control on msg_cron_trigger requests |
|
122 | + $transient_key = 'ee_trans_' . uniqid($task); |
|
123 | + set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
|
124 | + return array( |
|
125 | + 'type' => $task, |
|
126 | + 'key' => $transient_key, |
|
127 | + ); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * This is used to execute an immediate call to the run_cron task performed by EED_Messages |
|
133 | + * |
|
134 | + * @param string $task The task the request is being generated for. |
|
135 | + */ |
|
136 | + public static function initiate_immediate_request_on_cron($task) |
|
137 | + { |
|
138 | + $request_args = EE_Messages_Scheduler::get_request_params($task); |
|
139 | + //set those request args in the request so it gets picked up |
|
140 | + foreach ($request_args as $request_key => $request_value) { |
|
141 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
142 | + } |
|
143 | + EED_Messages::instance()->run_cron(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event |
|
149 | + */ |
|
150 | + public static function batch_generation() |
|
151 | + { |
|
152 | + /** |
|
153 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
154 | + */ |
|
155 | + if ( |
|
156 | + ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
157 | + || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
158 | + ) { |
|
159 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate'); |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * Callback for scheduled AHEE__EE_Messages_Scheduler__sending |
|
166 | + */ |
|
167 | + public static function batch_sending() |
|
168 | + { |
|
169 | + /** |
|
170 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
171 | + */ |
|
172 | + if ( |
|
173 | + ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
174 | + || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
175 | + ) { |
|
176 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); |
|
177 | + } |
|
178 | + } |
|
179 | 179 | |
180 | 180 | } //end EE_Messages_Scheduler |
181 | 181 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | public function __construct() |
29 | 29 | { |
30 | 30 | //register tasks (and make sure only registered once). |
31 | - if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
31 | + if ( ! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
32 | 32 | add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
33 | 33 | } |
34 | 34 | |
35 | 35 | //register callbacks for scheduled events (but make sure they are set only once). |
36 | - if (! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
36 | + if ( ! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
37 | 37 | array('EE_Messages_Scheduler', 'batch_generation')) |
38 | 38 | ) { |
39 | 39 | add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
88 | 88 | true)) { |
89 | - $request_url = add_query_arg( |
|
89 | + $request_url = add_query_arg( |
|
90 | 90 | array_merge( |
91 | 91 | array('ee' => 'msg_cron_trigger'), |
92 | 92 | EE_Messages_Scheduler::get_request_params($task) |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | 'sslverify' => false, |
100 | 100 | 'redirection' => 10, |
101 | 101 | ); |
102 | - $response = wp_remote_get($request_url, $request_args); |
|
102 | + $response = wp_remote_get($request_url, $request_args); |
|
103 | 103 | if (is_wp_error($response)) { |
104 | 104 | trigger_error($response->get_error_message()); |
105 | 105 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public static function get_request_params($task) |
120 | 120 | { |
121 | 121 | //transient is used for flood control on msg_cron_trigger requests |
122 | - $transient_key = 'ee_trans_' . uniqid($task); |
|
122 | + $transient_key = 'ee_trans_'.uniqid($task); |
|
123 | 123 | set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
124 | 124 | return array( |
125 | 125 | 'type' => $task, |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\libraries\iframe_display\Iframe; |
5 | 5 | |
6 | 6 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
7 | - exit( 'No direct script access allowed' ); |
|
7 | + exit( 'No direct script access allowed' ); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -21,64 +21,64 @@ discard block |
||
21 | 21 | class TicketSelectorIframe extends Iframe |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * TicketSelectorIframe constructor. |
|
26 | - * |
|
27 | - * @throws \DomainException |
|
28 | - * @throws \EE_Error |
|
29 | - */ |
|
30 | - public function __construct() |
|
31 | - { |
|
32 | - \EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
33 | - /** @type \EEM_Event $EEM_Event */ |
|
34 | - $EEM_Event = \EE_Registry::instance()->load_model( 'Event' ); |
|
35 | - $event = $EEM_Event->get_one_by_ID( |
|
36 | - \EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
37 | - ); |
|
38 | - $ticket_selector = new DisplayTicketSelector(); |
|
39 | - $ticket_selector->setIframe( true ); |
|
40 | - parent::__construct( |
|
41 | - esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
42 | - $ticket_selector->display( $event ) |
|
43 | - ); |
|
44 | - $this->addStylesheets( |
|
45 | - apply_filters( |
|
46 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
47 | - array( |
|
48 | - 'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL |
|
49 | - . 'ticket_selector_embed.css?ver=' |
|
50 | - . EVENT_ESPRESSO_VERSION, |
|
51 | - 'ticket_selector' => TICKET_SELECTOR_ASSETS_URL |
|
52 | - . 'ticket_selector.css?ver=' |
|
53 | - . EVENT_ESPRESSO_VERSION, |
|
54 | - ), |
|
55 | - $this |
|
56 | - ) |
|
57 | - ); |
|
58 | - if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
59 | - $this->addStylesheets( array('site_theme' => '' ) ); |
|
60 | - } |
|
61 | - $this->addScripts( |
|
62 | - apply_filters( |
|
63 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
64 | - array( |
|
65 | - 'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL |
|
66 | - . 'ticket_selector_iframe_embed.js?ver=' |
|
67 | - . EVENT_ESPRESSO_VERSION, |
|
68 | - ), |
|
69 | - $this |
|
70 | - ) |
|
71 | - ); |
|
72 | - $this->addLocalizedVars( |
|
73 | - array( |
|
74 | - 'ticket_selector_iframe' => true, |
|
75 | - 'EEDTicketSelectorMsg' => __( |
|
76 | - 'Please choose at least one ticket before continuing.', |
|
77 | - 'event_espresso' |
|
78 | - ), |
|
79 | - ) |
|
80 | - ); |
|
81 | - } |
|
24 | + /** |
|
25 | + * TicketSelectorIframe constructor. |
|
26 | + * |
|
27 | + * @throws \DomainException |
|
28 | + * @throws \EE_Error |
|
29 | + */ |
|
30 | + public function __construct() |
|
31 | + { |
|
32 | + \EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
33 | + /** @type \EEM_Event $EEM_Event */ |
|
34 | + $EEM_Event = \EE_Registry::instance()->load_model( 'Event' ); |
|
35 | + $event = $EEM_Event->get_one_by_ID( |
|
36 | + \EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
37 | + ); |
|
38 | + $ticket_selector = new DisplayTicketSelector(); |
|
39 | + $ticket_selector->setIframe( true ); |
|
40 | + parent::__construct( |
|
41 | + esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
42 | + $ticket_selector->display( $event ) |
|
43 | + ); |
|
44 | + $this->addStylesheets( |
|
45 | + apply_filters( |
|
46 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
47 | + array( |
|
48 | + 'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL |
|
49 | + . 'ticket_selector_embed.css?ver=' |
|
50 | + . EVENT_ESPRESSO_VERSION, |
|
51 | + 'ticket_selector' => TICKET_SELECTOR_ASSETS_URL |
|
52 | + . 'ticket_selector.css?ver=' |
|
53 | + . EVENT_ESPRESSO_VERSION, |
|
54 | + ), |
|
55 | + $this |
|
56 | + ) |
|
57 | + ); |
|
58 | + if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
59 | + $this->addStylesheets( array('site_theme' => '' ) ); |
|
60 | + } |
|
61 | + $this->addScripts( |
|
62 | + apply_filters( |
|
63 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
64 | + array( |
|
65 | + 'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL |
|
66 | + . 'ticket_selector_iframe_embed.js?ver=' |
|
67 | + . EVENT_ESPRESSO_VERSION, |
|
68 | + ), |
|
69 | + $this |
|
70 | + ) |
|
71 | + ); |
|
72 | + $this->addLocalizedVars( |
|
73 | + array( |
|
74 | + 'ticket_selector_iframe' => true, |
|
75 | + 'EEDTicketSelectorMsg' => __( |
|
76 | + 'Please choose at least one ticket before continuing.', |
|
77 | + 'event_espresso' |
|
78 | + ), |
|
79 | + ) |
|
80 | + ); |
|
81 | + } |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | // End of file TicketSelectorIframe.php |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | |
4 | 4 | use EventEspresso\core\libraries\iframe_display\Iframe; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
7 | - exit( 'No direct script access allowed' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct() |
31 | 31 | { |
32 | - \EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
32 | + \EE_Registry::instance()->REQ->set_espresso_page(true); |
|
33 | 33 | /** @type \EEM_Event $EEM_Event */ |
34 | - $EEM_Event = \EE_Registry::instance()->load_model( 'Event' ); |
|
34 | + $EEM_Event = \EE_Registry::instance()->load_model('Event'); |
|
35 | 35 | $event = $EEM_Event->get_one_by_ID( |
36 | - \EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
36 | + \EE_Registry::instance()->REQ->get('event', 0) |
|
37 | 37 | ); |
38 | 38 | $ticket_selector = new DisplayTicketSelector(); |
39 | - $ticket_selector->setIframe( true ); |
|
39 | + $ticket_selector->setIframe(true); |
|
40 | 40 | parent::__construct( |
41 | - esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
42 | - $ticket_selector->display( $event ) |
|
41 | + esc_html__('Ticket Selector', 'event_espresso'), |
|
42 | + $ticket_selector->display($event) |
|
43 | 43 | ); |
44 | 44 | $this->addStylesheets( |
45 | 45 | apply_filters( |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | ) |
57 | 57 | ); |
58 | 58 | if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
59 | - $this->addStylesheets( array('site_theme' => '' ) ); |
|
59 | + $this->addStylesheets(array('site_theme' => '')); |
|
60 | 60 | } |
61 | 61 | $this->addScripts( |
62 | 62 | apply_filters( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -17,151 +17,151 @@ discard block |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * enqueues css and js, so that this can be called statically |
|
22 | - */ |
|
23 | - public static function enqueue_styles_and_scripts() |
|
24 | - { |
|
25 | - wp_register_style( |
|
26 | - 'checkbox_dropdown_selector', |
|
27 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
28 | - array('espresso_default'), |
|
29 | - EVENT_ESPRESSO_VERSION |
|
30 | - ); |
|
31 | - wp_enqueue_style('checkbox_dropdown_selector'); |
|
32 | - wp_register_script( |
|
33 | - 'checkbox_dropdown_selector', |
|
34 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
35 | - array('jquery'), |
|
36 | - EVENT_ESPRESSO_VERSION, |
|
37 | - true |
|
38 | - ); |
|
39 | - wp_enqueue_script('checkbox_dropdown_selector'); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
46 | - */ |
|
47 | - public function enqueue_js(){ |
|
48 | - EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * callback for Iframe::addStylesheets() child class methods |
|
55 | - * |
|
56 | - * @param array $iframe_css |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - public function iframe_css(array $iframe_css){ |
|
60 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
61 | - return $iframe_css; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * callback for Iframe::addScripts() child class methods |
|
68 | - * |
|
69 | - * @param array $iframe_js |
|
70 | - * @return array |
|
71 | - */ |
|
72 | - public function iframe_js(array $iframe_js){ |
|
73 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
74 | - return $iframe_js; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @throws EE_Error |
|
80 | - * @return string of html to display the field |
|
81 | - */ |
|
82 | - public function display() |
|
83 | - { |
|
84 | - $input = $this->get_input(); |
|
85 | - $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : ''; |
|
86 | - // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
87 | - $input->set_label_sizes(); |
|
88 | - $label_size_class = $input->get_label_size_class(); |
|
89 | - if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
90 | - EE_Error::doing_it_wrong( |
|
91 | - 'EE_Checkbox_Display_Strategy::display()', |
|
92 | - sprintf( |
|
93 | - esc_html__( |
|
94 | - 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
95 | - 'event_espresso' |
|
96 | - ), |
|
97 | - $input->html_id(), |
|
98 | - var_export($input->raw_value(), true), |
|
99 | - $input->html_name() . '[]' |
|
100 | - ), |
|
101 | - '4.8.1' |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
107 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
108 | - // $html .= ' name="' . $input->html_name() . '"'; |
|
109 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | - $html .= ' style="' . $input->html_style() . '"'; |
|
111 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
112 | - $html .= ' ' . $input->html_other_attributes() . '>'; |
|
113 | - $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
114 | - $html .= $select_button_text; |
|
115 | - $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
116 | - $html .= '</button>'; |
|
117 | - $html .= EEH_HTML::div( |
|
118 | - '', |
|
119 | - $input->html_id() . '-options-dv', |
|
120 | - 'checkbox-dropdown-selector' |
|
121 | - ); |
|
122 | - $html .= EEH_HTML::link( |
|
123 | - '', |
|
124 | - '<span class="dashicons dashicons-no"></span>', |
|
125 | - esc_html__('close datetime selector', 'event_espresso'), |
|
126 | - '', |
|
127 | - 'close-espresso-notice' |
|
128 | - ); |
|
129 | - $html .= EEH_HTML::ul(); |
|
130 | - $input_raw_value = (array)$input->raw_value(); |
|
131 | - foreach ($input->options() as $value => $display_text) { |
|
132 | - $html .= EEH_HTML::li(); |
|
133 | - $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
134 | - $html_id = $this->get_sub_input_id($value); |
|
135 | - $html .= EEH_HTML::nl(0, 'checkbox'); |
|
136 | - $html .= '<label for="' |
|
137 | - . $html_id |
|
138 | - . '" id="' |
|
139 | - . $html_id |
|
140 | - . '-lbl" class="ee-checkbox-label-after' |
|
141 | - . $label_size_class |
|
142 | - . '">'; |
|
143 | - $html .= EEH_HTML::nl(1, 'checkbox'); |
|
144 | - $html .= '<input type="checkbox"'; |
|
145 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
146 | - $html .= ' id="' . $html_id . '"'; |
|
147 | - $html .= ' class="' . $input->html_class() . '-option"'; |
|
148 | - $html .= ' style="' . $input->html_style() . '"'; |
|
149 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
150 | - $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
151 | - ? ' checked="checked"' |
|
152 | - : ''; |
|
153 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
154 | - $html .= '>'; |
|
155 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
156 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
157 | - $html .= EEH_HTML::lix(); |
|
158 | - } |
|
159 | - $html .= EEH_HTML::ulx(); |
|
160 | - $html .= EEH_HTML::divx(); |
|
161 | - $html .= EEH_HTML::divx(); |
|
162 | - $html .= \EEH_HTML::br(); |
|
163 | - return $html; |
|
164 | - } |
|
20 | + /** |
|
21 | + * enqueues css and js, so that this can be called statically |
|
22 | + */ |
|
23 | + public static function enqueue_styles_and_scripts() |
|
24 | + { |
|
25 | + wp_register_style( |
|
26 | + 'checkbox_dropdown_selector', |
|
27 | + EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
28 | + array('espresso_default'), |
|
29 | + EVENT_ESPRESSO_VERSION |
|
30 | + ); |
|
31 | + wp_enqueue_style('checkbox_dropdown_selector'); |
|
32 | + wp_register_script( |
|
33 | + 'checkbox_dropdown_selector', |
|
34 | + EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
35 | + array('jquery'), |
|
36 | + EVENT_ESPRESSO_VERSION, |
|
37 | + true |
|
38 | + ); |
|
39 | + wp_enqueue_script('checkbox_dropdown_selector'); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
46 | + */ |
|
47 | + public function enqueue_js(){ |
|
48 | + EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * callback for Iframe::addStylesheets() child class methods |
|
55 | + * |
|
56 | + * @param array $iframe_css |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + public function iframe_css(array $iframe_css){ |
|
60 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
61 | + return $iframe_css; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * callback for Iframe::addScripts() child class methods |
|
68 | + * |
|
69 | + * @param array $iframe_js |
|
70 | + * @return array |
|
71 | + */ |
|
72 | + public function iframe_js(array $iframe_js){ |
|
73 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
74 | + return $iframe_js; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @throws EE_Error |
|
80 | + * @return string of html to display the field |
|
81 | + */ |
|
82 | + public function display() |
|
83 | + { |
|
84 | + $input = $this->get_input(); |
|
85 | + $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : ''; |
|
86 | + // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
87 | + $input->set_label_sizes(); |
|
88 | + $label_size_class = $input->get_label_size_class(); |
|
89 | + if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
90 | + EE_Error::doing_it_wrong( |
|
91 | + 'EE_Checkbox_Display_Strategy::display()', |
|
92 | + sprintf( |
|
93 | + esc_html__( |
|
94 | + 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
95 | + 'event_espresso' |
|
96 | + ), |
|
97 | + $input->html_id(), |
|
98 | + var_export($input->raw_value(), true), |
|
99 | + $input->html_name() . '[]' |
|
100 | + ), |
|
101 | + '4.8.1' |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
107 | + $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
108 | + // $html .= ' name="' . $input->html_name() . '"'; |
|
109 | + $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | + $html .= ' style="' . $input->html_style() . '"'; |
|
111 | + $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
112 | + $html .= ' ' . $input->html_other_attributes() . '>'; |
|
113 | + $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
114 | + $html .= $select_button_text; |
|
115 | + $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
116 | + $html .= '</button>'; |
|
117 | + $html .= EEH_HTML::div( |
|
118 | + '', |
|
119 | + $input->html_id() . '-options-dv', |
|
120 | + 'checkbox-dropdown-selector' |
|
121 | + ); |
|
122 | + $html .= EEH_HTML::link( |
|
123 | + '', |
|
124 | + '<span class="dashicons dashicons-no"></span>', |
|
125 | + esc_html__('close datetime selector', 'event_espresso'), |
|
126 | + '', |
|
127 | + 'close-espresso-notice' |
|
128 | + ); |
|
129 | + $html .= EEH_HTML::ul(); |
|
130 | + $input_raw_value = (array)$input->raw_value(); |
|
131 | + foreach ($input->options() as $value => $display_text) { |
|
132 | + $html .= EEH_HTML::li(); |
|
133 | + $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
134 | + $html_id = $this->get_sub_input_id($value); |
|
135 | + $html .= EEH_HTML::nl(0, 'checkbox'); |
|
136 | + $html .= '<label for="' |
|
137 | + . $html_id |
|
138 | + . '" id="' |
|
139 | + . $html_id |
|
140 | + . '-lbl" class="ee-checkbox-label-after' |
|
141 | + . $label_size_class |
|
142 | + . '">'; |
|
143 | + $html .= EEH_HTML::nl(1, 'checkbox'); |
|
144 | + $html .= '<input type="checkbox"'; |
|
145 | + $html .= ' name="' . $input->html_name() . '[]"'; |
|
146 | + $html .= ' id="' . $html_id . '"'; |
|
147 | + $html .= ' class="' . $input->html_class() . '-option"'; |
|
148 | + $html .= ' style="' . $input->html_style() . '"'; |
|
149 | + $html .= ' value="' . esc_attr($value) . '"'; |
|
150 | + $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
151 | + ? ' checked="checked"' |
|
152 | + : ''; |
|
153 | + $html .= ' ' . $this->_input->other_html_attributes(); |
|
154 | + $html .= '>'; |
|
155 | + $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
156 | + $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
157 | + $html .= EEH_HTML::lix(); |
|
158 | + } |
|
159 | + $html .= EEH_HTML::ulx(); |
|
160 | + $html .= EEH_HTML::divx(); |
|
161 | + $html .= EEH_HTML::divx(); |
|
162 | + $html .= \EEH_HTML::br(); |
|
163 | + return $html; |
|
164 | + } |
|
165 | 165 | |
166 | 166 | |
167 | 167 |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | { |
25 | 25 | wp_register_style( |
26 | 26 | 'checkbox_dropdown_selector', |
27 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
27 | + EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css', |
|
28 | 28 | array('espresso_default'), |
29 | 29 | EVENT_ESPRESSO_VERSION |
30 | 30 | ); |
31 | 31 | wp_enqueue_style('checkbox_dropdown_selector'); |
32 | 32 | wp_register_script( |
33 | 33 | 'checkbox_dropdown_selector', |
34 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
34 | + EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js', |
|
35 | 35 | array('jquery'), |
36 | 36 | EVENT_ESPRESSO_VERSION, |
37 | 37 | true |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * Informs the rest of the forms system what CSS and JS is needed to display the input |
46 | 46 | */ |
47 | - public function enqueue_js(){ |
|
47 | + public function enqueue_js() { |
|
48 | 48 | EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
49 | 49 | } |
50 | 50 | |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param array $iframe_css |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public function iframe_css(array $iframe_css){ |
|
60 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
59 | + public function iframe_css(array $iframe_css) { |
|
60 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css'; |
|
61 | 61 | return $iframe_css; |
62 | 62 | } |
63 | 63 | |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @param array $iframe_js |
70 | 70 | * @return array |
71 | 71 | */ |
72 | - public function iframe_js(array $iframe_js){ |
|
73 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
72 | + public function iframe_js(array $iframe_js) { |
|
73 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js'; |
|
74 | 74 | return $iframe_js; |
75 | 75 | } |
76 | 76 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | ), |
97 | 97 | $input->html_id(), |
98 | 98 | var_export($input->raw_value(), true), |
99 | - $input->html_name() . '[]' |
|
99 | + $input->html_name().'[]' |
|
100 | 100 | ), |
101 | 101 | '4.8.1' |
102 | 102 | ); |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | |
105 | 105 | |
106 | 106 | $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
107 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
107 | + $html .= '<button id="'.$input->html_id().'-btn"'; |
|
108 | 108 | // $html .= ' name="' . $input->html_name() . '"'; |
109 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | - $html .= ' style="' . $input->html_style() . '"'; |
|
111 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
112 | - $html .= ' ' . $input->html_other_attributes() . '>'; |
|
109 | + $html .= ' class="'.$input->html_class().' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | + $html .= ' style="'.$input->html_style().'"'; |
|
111 | + $html .= ' data-target="'.$input->html_id().'-options-dv"'; |
|
112 | + $html .= ' '.$input->html_other_attributes().'>'; |
|
113 | 113 | $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
114 | 114 | $html .= $select_button_text; |
115 | 115 | $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
116 | 116 | $html .= '</button>'; |
117 | 117 | $html .= EEH_HTML::div( |
118 | 118 | '', |
119 | - $input->html_id() . '-options-dv', |
|
119 | + $input->html_id().'-options-dv', |
|
120 | 120 | 'checkbox-dropdown-selector' |
121 | 121 | ); |
122 | 122 | $html .= EEH_HTML::link( |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | 'close-espresso-notice' |
128 | 128 | ); |
129 | 129 | $html .= EEH_HTML::ul(); |
130 | - $input_raw_value = (array)$input->raw_value(); |
|
130 | + $input_raw_value = (array) $input->raw_value(); |
|
131 | 131 | foreach ($input->options() as $value => $display_text) { |
132 | 132 | $html .= EEH_HTML::li(); |
133 | 133 | $value = $input->get_normalization_strategy()->unnormalize_one($value); |
@@ -142,18 +142,18 @@ discard block |
||
142 | 142 | . '">'; |
143 | 143 | $html .= EEH_HTML::nl(1, 'checkbox'); |
144 | 144 | $html .= '<input type="checkbox"'; |
145 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
146 | - $html .= ' id="' . $html_id . '"'; |
|
147 | - $html .= ' class="' . $input->html_class() . '-option"'; |
|
148 | - $html .= ' style="' . $input->html_style() . '"'; |
|
149 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
145 | + $html .= ' name="'.$input->html_name().'[]"'; |
|
146 | + $html .= ' id="'.$html_id.'"'; |
|
147 | + $html .= ' class="'.$input->html_class().'-option"'; |
|
148 | + $html .= ' style="'.$input->html_style().'"'; |
|
149 | + $html .= ' value="'.esc_attr($value).'"'; |
|
150 | 150 | $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
151 | 151 | ? ' checked="checked"' |
152 | 152 | : ''; |
153 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
153 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
154 | 154 | $html .= '>'; |
155 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
156 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
155 | + $html .= '<span class="datetime-selector-option-text-spn">'.$display_text.'</span>'; |
|
156 | + $html .= EEH_HTML::nl(-1, 'checkbox').'</label>'; |
|
157 | 157 | $html .= EEH_HTML::lix(); |
158 | 158 | } |
159 | 159 | $html .= EEH_HTML::ulx(); |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class EED_Ticket_Selector extends EED_Module { |
24 | 24 | |
25 | - /** |
|
26 | - * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector |
|
27 | - */ |
|
28 | - private static $ticket_selector; |
|
25 | + /** |
|
26 | + * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector |
|
27 | + */ |
|
28 | + private static $ticket_selector; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button |
|
32 | - */ |
|
33 | - private static $iframe_embed_button; |
|
30 | + /** |
|
31 | + * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button |
|
32 | + */ |
|
33 | + private static $iframe_embed_button; |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | // routing |
62 | 62 | EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
63 | 63 | EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
64 | - EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections'); |
|
65 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
64 | + EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections'); |
|
65 | + add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
66 | 66 | add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
67 | 67 | add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
68 | - EED_Ticket_Selector::loadIframeAssets(); |
|
69 | - } |
|
68 | + EED_Ticket_Selector::loadIframeAssets(); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | 72 | |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | 10 |
86 | 86 | ); |
87 | 87 | |
88 | - /** |
|
89 | - * Make sure assets for the ticket selector are loaded on the espresso registrations route so admin side |
|
90 | - * registrations work. |
|
91 | - */ |
|
88 | + /** |
|
89 | + * Make sure assets for the ticket selector are loaded on the espresso registrations route so admin side |
|
90 | + * registrations work. |
|
91 | + */ |
|
92 | 92 | add_action( |
93 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration', |
|
94 | - array('EED_Ticket_Selector', 'set_definitions'), |
|
95 | - 10 |
|
96 | - ); |
|
97 | - } |
|
93 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration', |
|
94 | + array('EED_Ticket_Selector', 'set_definitions'), |
|
95 | + 10 |
|
96 | + ); |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | 100 | |
@@ -110,23 +110,23 @@ discard block |
||
110 | 110 | |
111 | 111 | //if config is not set, initialize |
112 | 112 | if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
113 | - \EED_Ticket_Selector::instance()->set_config(); |
|
114 | - \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
113 | + \EED_Ticket_Selector::instance()->set_config(); |
|
114 | + \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | 119 | |
120 | 120 | /** |
121 | - * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector |
|
122 | - */ |
|
123 | - public static function ticketSelector() |
|
124 | - { |
|
125 | - if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
126 | - EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(); |
|
127 | - } |
|
128 | - return EED_Ticket_Selector::$ticket_selector; |
|
129 | - } |
|
121 | + * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector |
|
122 | + */ |
|
123 | + public static function ticketSelector() |
|
124 | + { |
|
125 | + if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
126 | + EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(); |
|
127 | + } |
|
128 | + return EED_Ticket_Selector::$ticket_selector; |
|
129 | + } |
|
130 | 130 | |
131 | 131 | |
132 | 132 | /** |
@@ -179,15 +179,15 @@ discard block |
||
179 | 179 | |
180 | 180 | |
181 | 181 | |
182 | - /** |
|
183 | - * creates buttons for selecting number of attendees for an event |
|
184 | - * |
|
185 | - * @access public |
|
186 | - * @param WP_Post|int $event |
|
187 | - * @param bool $view_details |
|
188 | - * @return string |
|
189 | - * @throws \EE_Error |
|
190 | - */ |
|
182 | + /** |
|
183 | + * creates buttons for selecting number of attendees for an event |
|
184 | + * |
|
185 | + * @access public |
|
186 | + * @param WP_Post|int $event |
|
187 | + * @param bool $view_details |
|
188 | + * @return string |
|
189 | + * @throws \EE_Error |
|
190 | + */ |
|
191 | 191 | public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
192 | 192 | return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details ); |
193 | 193 | } |
@@ -208,26 +208,26 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | |
211 | - /** |
|
212 | - * cancel_ticket_selections |
|
213 | - * |
|
214 | - * @access public |
|
215 | - * @return string |
|
216 | - */ |
|
217 | - public static function cancel_ticket_selections() |
|
218 | - { |
|
219 | - $form = new ProcessTicketSelector(); |
|
220 | - return $form->cancelTicketSelections(); |
|
221 | - } |
|
211 | + /** |
|
212 | + * cancel_ticket_selections |
|
213 | + * |
|
214 | + * @access public |
|
215 | + * @return string |
|
216 | + */ |
|
217 | + public static function cancel_ticket_selections() |
|
218 | + { |
|
219 | + $form = new ProcessTicketSelector(); |
|
220 | + return $form->cancelTicketSelections(); |
|
221 | + } |
|
222 | 222 | |
223 | 223 | |
224 | 224 | |
225 | 225 | /** |
226 | - * load js |
|
227 | - * |
|
228 | - * @access public |
|
229 | - * @return void |
|
230 | - */ |
|
226 | + * load js |
|
227 | + * |
|
228 | + * @access public |
|
229 | + * @return void |
|
230 | + */ |
|
231 | 231 | public static function load_tckt_slctr_assets() { |
232 | 232 | if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
233 | 233 | // add some style |
@@ -236,194 +236,194 @@ discard block |
||
236 | 236 | // make it dance |
237 | 237 | wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
238 | 238 | wp_enqueue_script('ticket_selector'); |
239 | - require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'); |
|
240 | - \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
241 | - } |
|
239 | + require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'); |
|
240 | + \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @return void |
|
248 | + */ |
|
249 | + public static function loadIframeAssets() |
|
250 | + { |
|
251 | + // for event lists |
|
252 | + add_filter( |
|
253 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
254 | + array('EED_Ticket_Selector', 'iframeCss') |
|
255 | + ); |
|
256 | + add_filter( |
|
257 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
258 | + array('EED_Ticket_Selector', 'iframeJs') |
|
259 | + ); |
|
260 | + // for ticket selectors |
|
261 | + add_filter( |
|
262 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
263 | + array('EED_Ticket_Selector', 'iframeCss') |
|
264 | + ); |
|
265 | + add_filter( |
|
266 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
267 | + array('EED_Ticket_Selector', 'iframeJs') |
|
268 | + ); |
|
242 | 269 | } |
243 | 270 | |
244 | 271 | |
245 | 272 | |
246 | - /** |
|
247 | - * @return void |
|
248 | - */ |
|
249 | - public static function loadIframeAssets() |
|
250 | - { |
|
251 | - // for event lists |
|
252 | - add_filter( |
|
253 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
254 | - array('EED_Ticket_Selector', 'iframeCss') |
|
255 | - ); |
|
256 | - add_filter( |
|
257 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
258 | - array('EED_Ticket_Selector', 'iframeJs') |
|
259 | - ); |
|
260 | - // for ticket selectors |
|
261 | - add_filter( |
|
262 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
263 | - array('EED_Ticket_Selector', 'iframeCss') |
|
264 | - ); |
|
265 | - add_filter( |
|
266 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
267 | - array('EED_Ticket_Selector', 'iframeJs') |
|
268 | - ); |
|
269 | - } |
|
270 | - |
|
271 | - |
|
272 | - |
|
273 | - /** |
|
274 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
275 | - * |
|
276 | - * @param array $iframe_css |
|
277 | - * @return array |
|
278 | - */ |
|
279 | - public static function iframeCss(array $iframe_css) |
|
280 | - { |
|
281 | - $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'; |
|
282 | - return $iframe_css; |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
289 | - * |
|
290 | - * @param array $iframe_js |
|
291 | - * @return array |
|
292 | - */ |
|
293 | - public static function iframeJs(array $iframe_js) |
|
294 | - { |
|
295 | - $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js'; |
|
296 | - return $iframe_js; |
|
297 | - } |
|
273 | + /** |
|
274 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
275 | + * |
|
276 | + * @param array $iframe_css |
|
277 | + * @return array |
|
278 | + */ |
|
279 | + public static function iframeCss(array $iframe_css) |
|
280 | + { |
|
281 | + $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'; |
|
282 | + return $iframe_css; |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
289 | + * |
|
290 | + * @param array $iframe_js |
|
291 | + * @return array |
|
292 | + */ |
|
293 | + public static function iframeJs(array $iframe_js) |
|
294 | + { |
|
295 | + $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js'; |
|
296 | + return $iframe_js; |
|
297 | + } |
|
298 | 298 | |
299 | 299 | |
300 | 300 | /****************************** DEPRECATED ******************************/ |
301 | 301 | |
302 | 302 | |
303 | 303 | |
304 | - /** |
|
305 | - * @deprecated |
|
306 | - * @return string |
|
307 | - * @throws \EE_Error |
|
308 | - */ |
|
309 | - public static function display_view_details_btn() |
|
310 | - { |
|
311 | - // todo add doing_it_wrong() notice during next major version |
|
312 | - return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * @deprecated |
|
319 | - * @return string |
|
320 | - * @throws \EE_Error |
|
321 | - */ |
|
322 | - public static function display_ticket_selector_submit() |
|
323 | - { |
|
324 | - // todo add doing_it_wrong() notice during next major version |
|
325 | - return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
326 | - } |
|
327 | - |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * @deprecated |
|
332 | - * @param string $permalink_string |
|
333 | - * @param int $id |
|
334 | - * @param string $new_title |
|
335 | - * @param string $new_slug |
|
336 | - * @return string |
|
337 | - */ |
|
338 | - public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
339 | - { |
|
340 | - // todo add doing_it_wrong() notice during next major version |
|
341 | - if ( |
|
342 | - \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
343 | - && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
344 | - ) { |
|
345 | - $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
346 | - $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
347 | - } |
|
348 | - return ''; |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - |
|
353 | - /** |
|
354 | - * @deprecated |
|
355 | - * @param int $ID |
|
356 | - * @param string $external_url |
|
357 | - * @return string |
|
358 | - */ |
|
359 | - public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
360 | - { |
|
361 | - // todo add doing_it_wrong() notice during next major version |
|
362 | - return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * @deprecated |
|
369 | - * @return string |
|
370 | - */ |
|
371 | - public static function ticket_selector_form_close() |
|
372 | - { |
|
373 | - // todo add doing_it_wrong() notice during next major version |
|
374 | - return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
375 | - } |
|
376 | - |
|
377 | - |
|
378 | - |
|
379 | - /** |
|
380 | - * @deprecated |
|
381 | - * @return string |
|
382 | - */ |
|
383 | - public static function no_tkt_slctr_end_dv() |
|
384 | - { |
|
385 | - // todo add doing_it_wrong() notice during next major version |
|
386 | - return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * @deprecated 4.9.13 |
|
393 | - * @return string |
|
394 | - */ |
|
395 | - public static function tkt_slctr_end_dv() |
|
396 | - { |
|
397 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
398 | - } |
|
399 | - |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * @deprecated |
|
404 | - * @return string |
|
405 | - */ |
|
406 | - public static function clear_tkt_slctr() |
|
407 | - { |
|
408 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - |
|
413 | - /** |
|
414 | - * @deprecated |
|
415 | - */ |
|
416 | - public static function load_tckt_slctr_assets_admin() |
|
417 | - { |
|
418 | - // todo add doing_it_wrong() notice during next major version |
|
419 | - if ( |
|
420 | - \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
421 | - && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
422 | - ) { |
|
423 | - $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
424 | - $iframe_embed_button->embedButtonAssets(); |
|
425 | - } |
|
426 | - } |
|
304 | + /** |
|
305 | + * @deprecated |
|
306 | + * @return string |
|
307 | + * @throws \EE_Error |
|
308 | + */ |
|
309 | + public static function display_view_details_btn() |
|
310 | + { |
|
311 | + // todo add doing_it_wrong() notice during next major version |
|
312 | + return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * @deprecated |
|
319 | + * @return string |
|
320 | + * @throws \EE_Error |
|
321 | + */ |
|
322 | + public static function display_ticket_selector_submit() |
|
323 | + { |
|
324 | + // todo add doing_it_wrong() notice during next major version |
|
325 | + return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
326 | + } |
|
327 | + |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * @deprecated |
|
332 | + * @param string $permalink_string |
|
333 | + * @param int $id |
|
334 | + * @param string $new_title |
|
335 | + * @param string $new_slug |
|
336 | + * @return string |
|
337 | + */ |
|
338 | + public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
339 | + { |
|
340 | + // todo add doing_it_wrong() notice during next major version |
|
341 | + if ( |
|
342 | + \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
343 | + && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
344 | + ) { |
|
345 | + $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
346 | + $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
347 | + } |
|
348 | + return ''; |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + |
|
353 | + /** |
|
354 | + * @deprecated |
|
355 | + * @param int $ID |
|
356 | + * @param string $external_url |
|
357 | + * @return string |
|
358 | + */ |
|
359 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
360 | + { |
|
361 | + // todo add doing_it_wrong() notice during next major version |
|
362 | + return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * @deprecated |
|
369 | + * @return string |
|
370 | + */ |
|
371 | + public static function ticket_selector_form_close() |
|
372 | + { |
|
373 | + // todo add doing_it_wrong() notice during next major version |
|
374 | + return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
375 | + } |
|
376 | + |
|
377 | + |
|
378 | + |
|
379 | + /** |
|
380 | + * @deprecated |
|
381 | + * @return string |
|
382 | + */ |
|
383 | + public static function no_tkt_slctr_end_dv() |
|
384 | + { |
|
385 | + // todo add doing_it_wrong() notice during next major version |
|
386 | + return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * @deprecated 4.9.13 |
|
393 | + * @return string |
|
394 | + */ |
|
395 | + public static function tkt_slctr_end_dv() |
|
396 | + { |
|
397 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
398 | + } |
|
399 | + |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * @deprecated |
|
404 | + * @return string |
|
405 | + */ |
|
406 | + public static function clear_tkt_slctr() |
|
407 | + { |
|
408 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + |
|
413 | + /** |
|
414 | + * @deprecated |
|
415 | + */ |
|
416 | + public static function load_tckt_slctr_assets_admin() |
|
417 | + { |
|
418 | + // todo add doing_it_wrong() notice during next major version |
|
419 | + if ( |
|
420 | + \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
421 | + && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
422 | + ) { |
|
423 | + $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
424 | + $iframe_embed_button->embedButtonAssets(); |
|
425 | + } |
|
426 | + } |
|
427 | 427 | |
428 | 428 | |
429 | 429 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * process_ticket_selections |
199 | 199 | * |
200 | 200 | * @access public |
201 | - * @return array or FALSE |
|
201 | + * @return boolean|null or FALSE |
|
202 | 202 | * @throws \EE_Error |
203 | 203 | */ |
204 | 204 | public function process_ticket_selections() { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * cancel_ticket_selections |
213 | 213 | * |
214 | 214 | * @access public |
215 | - * @return string |
|
215 | + * @return false|null |
|
216 | 216 | */ |
217 | 217 | public static function cancel_ticket_selections() |
218 | 218 | { |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | use EventEspresso\modules\ticket_selector\TicketSelectorIframe; |
4 | 4 | use EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
7 | - exit( 'No direct script access allowed' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | * @return EED_Ticket_Selector |
39 | 39 | */ |
40 | 40 | public static function instance() { |
41 | - return parent::get_instance( __CLASS__ ); |
|
41 | + return parent::get_instance(__CLASS__); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - protected function set_config(){ |
|
47 | - $this->set_config_section( 'template_settings' ); |
|
48 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
49 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
46 | + protected function set_config() { |
|
47 | + $this->set_config_section('template_settings'); |
|
48 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
49 | + $this->set_config_name('EED_Ticket_Selector'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public static function set_hooks() { |
61 | 61 | // routing |
62 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
63 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
62 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
63 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
64 | 64 | EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections'); |
65 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
66 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
67 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
65 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
66 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
67 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
68 | 68 | EED_Ticket_Selector::loadIframeAssets(); |
69 | 69 | } |
70 | 70 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | // to load assets for "espresso_events" page on the "edit" route (action) |
82 | 82 | add_action( |
83 | 83 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit', |
84 | - array( 'EED_Ticket_Selector', 'ticket_selector_iframe_embed_button' ), |
|
84 | + array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'), |
|
85 | 85 | 10 |
86 | 86 | ); |
87 | 87 | |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | * @return void |
106 | 106 | */ |
107 | 107 | public static function set_definitions() { |
108 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
109 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
108 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
109 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
110 | 110 | |
111 | 111 | //if config is not set, initialize |
112 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
|
112 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
113 | 113 | \EED_Ticket_Selector::instance()->set_config(); |
114 | 114 | \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
115 | 115 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param WP $WP |
137 | 137 | * @return void |
138 | 138 | */ |
139 | - public function run( $WP ) {} |
|
139 | + public function run($WP) {} |
|
140 | 140 | |
141 | 141 | |
142 | 142 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return \EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton |
145 | 145 | */ |
146 | 146 | public static function getIframeEmbedButton() { |
147 | - if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton ) { |
|
147 | + if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) { |
|
148 | 148 | self::$iframe_embed_button = new TicketSelectorIframeEmbedButton(); |
149 | 149 | } |
150 | 150 | return self::$iframe_embed_button; |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | * @return string |
189 | 189 | * @throws \EE_Error |
190 | 190 | */ |
191 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
192 | - return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details ); |
|
191 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
192 | + return EED_Ticket_Selector::ticketSelector()->display($event, $view_details); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -229,14 +229,14 @@ discard block |
||
229 | 229 | * @return void |
230 | 230 | */ |
231 | 231 | public static function load_tckt_slctr_assets() { |
232 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
232 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
233 | 233 | // add some style |
234 | - wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'); |
|
234 | + wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'); |
|
235 | 235 | wp_enqueue_style('ticket_selector'); |
236 | 236 | // make it dance |
237 | - wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
|
237 | + wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js', array('espresso_core'), '', TRUE); |
|
238 | 238 | wp_enqueue_script('ticket_selector'); |
239 | - require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'); |
|
239 | + require_once(EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'); |
|
240 | 240 | \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
241 | 241 | } |
242 | 242 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public static function iframeCss(array $iframe_css) |
280 | 280 | { |
281 | - $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'; |
|
281 | + $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'; |
|
282 | 282 | return $iframe_css; |
283 | 283 | } |
284 | 284 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public static function iframeJs(array $iframe_js) |
294 | 294 | { |
295 | - $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js'; |
|
295 | + $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js'; |
|
296 | 296 | return $iframe_js; |
297 | 297 | } |
298 | 298 | |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | { |
418 | 418 | // todo add doing_it_wrong() notice during next major version |
419 | 419 | if ( |
420 | - \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
421 | - && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
420 | + \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
421 | + && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
422 | 422 | ) { |
423 | 423 | $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
424 | 424 | $iframe_embed_button->embedButtonAssets(); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * can_use_espresso_conditionals |
144 | 144 | * tests whether the Espresso Conditional tags like is_espresso_event_single() can be called |
145 | 145 | * |
146 | - * @param $conditional_tag |
|
146 | + * @param string $conditional_tag |
|
147 | 147 | * @return bool |
148 | 148 | */ |
149 | 149 | function can_use_espresso_conditionals( $conditional_tag ) { |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | /** |
856 | 856 | * espresso_event_venues |
857 | 857 | * |
858 | - * @return array all venues related to an event |
|
858 | + * @return EE_Venue[] all venues related to an event |
|
859 | 859 | */ |
860 | 860 | function espresso_event_venues() { |
861 | 861 | return EEH_Venue_View::get_event_venues(); |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | * |
889 | 889 | * @param int $VNU_ID optional, the venue id to check. |
890 | 890 | * |
891 | - * @return bool | null |
|
891 | + * @return null|boolean | null |
|
892 | 892 | */ |
893 | 893 | function espresso_is_venue_private( $VNU_ID = 0 ) { |
894 | 894 | return EEH_Venue_View::is_venue_private( $VNU_ID ); |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | * returns true or false if a venue is password protected or not |
903 | 903 | * |
904 | 904 | * @param int $VNU_ID optional, the venue id to check. |
905 | - * @return string |
|
905 | + * @return boolean |
|
906 | 906 | */ |
907 | 907 | function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
908 | 908 | EE_Registry::instance()->load_helper( 'Venue_View' ); |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | * @param int | \EE_Event $event |
28 | 28 | * @return bool |
29 | 29 | */ |
30 | -function is_espresso_event( $event = NULL ) { |
|
31 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
30 | +function is_espresso_event($event = NULL) { |
|
31 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
32 | 32 | // extract EE_Event object from passed param regardless of what it is (within reason of course) |
33 | - $event = EEH_Event_View::get_event( $event ); |
|
33 | + $event = EEH_Event_View::get_event($event); |
|
34 | 34 | // do we have a valid event ? |
35 | - return $event instanceof EE_Event ? TRUE : FALSE; |
|
35 | + return $event instanceof EE_Event ? TRUE : FALSE; |
|
36 | 36 | } |
37 | 37 | return FALSE; |
38 | 38 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return bool |
45 | 45 | */ |
46 | 46 | function is_espresso_event_single() { |
47 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
47 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
48 | 48 | global $wp_query; |
49 | 49 | // return conditionals set by CPTs |
50 | 50 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return bool |
60 | 60 | */ |
61 | 61 | function is_espresso_event_archive() { |
62 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
62 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
63 | 63 | global $wp_query; |
64 | 64 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE; |
65 | 65 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return bool |
74 | 74 | */ |
75 | 75 | function is_espresso_event_taxonomy() { |
76 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
76 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
77 | 77 | global $wp_query; |
78 | 78 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE; |
79 | 79 | } |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * @param int | \EE_Venue $venue |
88 | 88 | * @return bool |
89 | 89 | */ |
90 | -function is_espresso_venue( $venue = NULL ) { |
|
91 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
90 | +function is_espresso_venue($venue = NULL) { |
|
91 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
92 | 92 | // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
93 | - $venue = EEH_Venue_View::get_venue( $venue, FALSE ); |
|
93 | + $venue = EEH_Venue_View::get_venue($venue, FALSE); |
|
94 | 94 | // do we have a valid event ? |
95 | 95 | return $venue instanceof EE_Venue ? TRUE : FALSE; |
96 | 96 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return bool |
105 | 105 | */ |
106 | 106 | function is_espresso_venue_single() { |
107 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
107 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
108 | 108 | global $wp_query; |
109 | 109 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE; |
110 | 110 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return bool |
119 | 119 | */ |
120 | 120 | function is_espresso_venue_archive() { |
121 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
121 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
122 | 122 | global $wp_query; |
123 | 123 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE; |
124 | 124 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @return bool |
133 | 133 | */ |
134 | 134 | function is_espresso_venue_taxonomy() { |
135 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
135 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
136 | 136 | global $wp_query; |
137 | 137 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE; |
138 | 138 | } |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | * @param $conditional_tag |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | -function can_use_espresso_conditionals( $conditional_tag ) { |
|
150 | - if ( ! did_action( 'AHEE__EE_System__initialize' )) { |
|
149 | +function can_use_espresso_conditionals($conditional_tag) { |
|
150 | + if ( ! did_action('AHEE__EE_System__initialize')) { |
|
151 | 151 | EE_Error::doing_it_wrong( |
152 | 152 | __FUNCTION__, |
153 | 153 | sprintf( |
154 | - __( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'), |
|
154 | + __('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'), |
|
155 | 155 | $conditional_tag |
156 | 156 | ), |
157 | 157 | '4.4.0' |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | |
167 | 167 | /*************************** Event Queries ***************************/ |
168 | 168 | |
169 | -if ( ! function_exists( 'espresso_get_events' )) { |
|
169 | +if ( ! function_exists('espresso_get_events')) { |
|
170 | 170 | /** |
171 | 171 | * espresso_get_events |
172 | 172 | * @param array $params |
173 | 173 | * @return array |
174 | 174 | */ |
175 | - function espresso_get_events( $params = array() ) { |
|
175 | + function espresso_get_events($params = array()) { |
|
176 | 176 | //set default params |
177 | 177 | $default_espresso_events_params = array( |
178 | 178 | 'limit' => 10, |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | 'sort' => 'ASC' |
184 | 184 | ); |
185 | 185 | // allow the defaults to be filtered |
186 | - $default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params ); |
|
186 | + $default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params); |
|
187 | 187 | // grab params and merge with defaults, then extract |
188 | - $params = array_merge( $default_espresso_events_params, $params ); |
|
188 | + $params = array_merge($default_espresso_events_params, $params); |
|
189 | 189 | // run the query |
190 | - $events_query = new EE_Event_List_Query( $params ); |
|
190 | + $events_query = new EE_Event_List_Query($params); |
|
191 | 191 | // assign results to a variable so we can return it |
192 | 192 | $events = $events_query->have_posts() ? $events_query->posts : array(); |
193 | 193 | // but first reset the query and postdata |
194 | 194 | wp_reset_query(); |
195 | 195 | wp_reset_postdata(); |
196 | 196 | EED_Events_Archive::remove_all_events_archive_filters(); |
197 | - unset( $events_query ); |
|
197 | + unset($events_query); |
|
198 | 198 | return $events; |
199 | 199 | } |
200 | 200 | } |
@@ -208,32 +208,32 @@ discard block |
||
208 | 208 | * espresso_load_ticket_selector |
209 | 209 | */ |
210 | 210 | function espresso_load_ticket_selector() { |
211 | - EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' ); |
|
211 | + EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
212 | 212 | } |
213 | 213 | |
214 | -if ( ! function_exists( 'espresso_ticket_selector' )) { |
|
214 | +if ( ! function_exists('espresso_ticket_selector')) { |
|
215 | 215 | /** |
216 | 216 | * espresso_ticket_selector |
217 | 217 | * @param null $event |
218 | 218 | */ |
219 | - function espresso_ticket_selector( $event = NULL ) { |
|
220 | - if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
|
219 | + function espresso_ticket_selector($event = NULL) { |
|
220 | + if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) { |
|
221 | 221 | espresso_load_ticket_selector(); |
222 | - echo EED_Ticket_Selector::display_ticket_selector( $event ); |
|
222 | + echo EED_Ticket_Selector::display_ticket_selector($event); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | 227 | |
228 | - if ( ! function_exists( 'espresso_view_details_btn' )) { |
|
228 | + if ( ! function_exists('espresso_view_details_btn')) { |
|
229 | 229 | /** |
230 | 230 | * espresso_view_details_btn |
231 | 231 | * @param null $event |
232 | 232 | */ |
233 | - function espresso_view_details_btn( $event = NULL ) { |
|
234 | - if ( ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) { |
|
233 | + function espresso_view_details_btn($event = NULL) { |
|
234 | + if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) { |
|
235 | 235 | espresso_load_ticket_selector(); |
236 | - echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE ); |
|
236 | + echo EED_Ticket_Selector::display_ticket_selector($event, TRUE); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | /*************************** EEH_Event_View ***************************/ |
245 | 245 | |
246 | -if ( ! function_exists( 'espresso_load_event_list_assets' )) { |
|
246 | +if ( ! function_exists('espresso_load_event_list_assets')) { |
|
247 | 247 | /** |
248 | 248 | * espresso_load_event_list_assets |
249 | 249 | * ensures that event list styles and scripts are loaded |
@@ -252,13 +252,13 @@ discard block |
||
252 | 252 | */ |
253 | 253 | function espresso_load_event_list_assets() { |
254 | 254 | $event_list = EED_Events_Archive::instance(); |
255 | - add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 ); |
|
256 | - add_filter( 'FHEE_enable_default_espresso_css', '__return_true' ); |
|
255 | + add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10); |
|
256 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | 260 | |
261 | -if ( ! function_exists( 'espresso_event_reg_button' )) { |
|
261 | +if ( ! function_exists('espresso_event_reg_button')) { |
|
262 | 262 | /** |
263 | 263 | * espresso_event_reg_button |
264 | 264 | * returns the "Register Now" button if event is active, |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | * @param bool $EVT_ID |
271 | 271 | * @return string |
272 | 272 | */ |
273 | - function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) { |
|
274 | - $event_status = EEH_Event_View::event_active_status( $EVT_ID ); |
|
275 | - switch ( $event_status ) { |
|
273 | + function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) { |
|
274 | + $event_status = EEH_Event_View::event_active_status($EVT_ID); |
|
275 | + switch ($event_status) { |
|
276 | 276 | case EE_Datetime::sold_out : |
277 | 277 | $btn_text = __('Sold Out', 'event_espresso'); |
278 | 278 | $class = 'ee-pink'; |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | case EE_Datetime::upcoming : |
289 | 289 | case EE_Datetime::active : |
290 | 290 | default : |
291 | - $btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' ); |
|
291 | + $btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso'); |
|
292 | 292 | $class = 'ee-green'; |
293 | 293 | } |
294 | - if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) { |
|
294 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
295 | 295 | $btn_text = $btn_text_if_inactive; |
296 | 296 | $class = 'ee-grey'; |
297 | 297 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | |
307 | 307 | |
308 | -if ( ! function_exists( 'espresso_display_ticket_selector' )) { |
|
308 | +if ( ! function_exists('espresso_display_ticket_selector')) { |
|
309 | 309 | /** |
310 | 310 | * espresso_display_ticket_selector |
311 | 311 | * whether or not to display the Ticket Selector for an event |
@@ -313,14 +313,14 @@ discard block |
||
313 | 313 | * @param bool $EVT_ID |
314 | 314 | * @return boolean |
315 | 315 | */ |
316 | - function espresso_display_ticket_selector( $EVT_ID = FALSE ) { |
|
317 | - return EEH_Event_View::display_ticket_selector( $EVT_ID ); |
|
316 | + function espresso_display_ticket_selector($EVT_ID = FALSE) { |
|
317 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | 321 | |
322 | 322 | |
323 | -if ( ! function_exists( 'espresso_event_status_banner' )) { |
|
323 | +if ( ! function_exists('espresso_event_status_banner')) { |
|
324 | 324 | /** |
325 | 325 | * espresso_event_status |
326 | 326 | * returns a banner showing the event status if it is sold out, expired, or inactive |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | * @param bool $EVT_ID |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - function espresso_event_status_banner( $EVT_ID = FALSE ) { |
|
332 | - return EEH_Event_View::event_status( $EVT_ID ); |
|
331 | + function espresso_event_status_banner($EVT_ID = FALSE) { |
|
332 | + return EEH_Event_View::event_status($EVT_ID); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | 336 | |
337 | -if ( ! function_exists( 'espresso_event_status' )) { |
|
337 | +if ( ! function_exists('espresso_event_status')) { |
|
338 | 338 | /** |
339 | 339 | * espresso_event_status |
340 | 340 | * returns the event status if it is sold out, expired, or inactive |
@@ -343,17 +343,17 @@ discard block |
||
343 | 343 | * @param bool $echo |
344 | 344 | * @return string |
345 | 345 | */ |
346 | - function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) { |
|
347 | - if ( $echo ) { |
|
348 | - echo EEH_Event_View::event_active_status( $EVT_ID ); |
|
346 | + function espresso_event_status($EVT_ID = 0, $echo = TRUE) { |
|
347 | + if ($echo) { |
|
348 | + echo EEH_Event_View::event_active_status($EVT_ID); |
|
349 | 349 | return ''; |
350 | 350 | } |
351 | - return EEH_Event_View::event_active_status( $EVT_ID ); |
|
351 | + return EEH_Event_View::event_active_status($EVT_ID); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | 355 | |
356 | -if ( ! function_exists( 'espresso_event_categories' )) { |
|
356 | +if ( ! function_exists('espresso_event_categories')) { |
|
357 | 357 | /** |
358 | 358 | * espresso_event_categories |
359 | 359 | * returns the terms associated with an event |
@@ -363,17 +363,17 @@ discard block |
||
363 | 363 | * @param bool $echo |
364 | 364 | * @return string |
365 | 365 | */ |
366 | - function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
367 | - if ( $echo ) { |
|
368 | - echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
366 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
367 | + if ($echo) { |
|
368 | + echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
369 | 369 | return ''; |
370 | 370 | } |
371 | - return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
371 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | 375 | |
376 | -if ( ! function_exists( 'espresso_event_tickets_available' )) { |
|
376 | +if ( ! function_exists('espresso_event_tickets_available')) { |
|
377 | 377 | /** |
378 | 378 | * espresso_event_tickets_available |
379 | 379 | * returns the ticket types available for purchase for an event |
@@ -383,26 +383,26 @@ discard block |
||
383 | 383 | * @param bool $format |
384 | 384 | * @return string |
385 | 385 | */ |
386 | - function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) { |
|
387 | - $tickets = EEH_Event_View::event_tickets_available( $EVT_ID ); |
|
388 | - if ( is_array( $tickets ) && ! empty( $tickets )) { |
|
386 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) { |
|
387 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
388 | + if (is_array($tickets) && ! empty($tickets)) { |
|
389 | 389 | // if formatting then $html will be a string, else it will be an array of ticket objects |
390 | - $html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array(); |
|
391 | - foreach ( $tickets as $ticket ) { |
|
392 | - if ( $ticket instanceof EE_Ticket ) { |
|
393 | - if ( $format ) { |
|
394 | - $html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">'; |
|
395 | - $html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() ); |
|
390 | + $html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array(); |
|
391 | + foreach ($tickets as $ticket) { |
|
392 | + if ($ticket instanceof EE_Ticket) { |
|
393 | + if ($format) { |
|
394 | + $html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">'; |
|
395 | + $html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes()); |
|
396 | 396 | $html .= '</li>'; |
397 | 397 | } else { |
398 | 398 | $html[] = $ticket; |
399 | 399 | } |
400 | 400 | } |
401 | 401 | } |
402 | - if ( $format ) { |
|
402 | + if ($format) { |
|
403 | 403 | $html .= '</ul>'; |
404 | 404 | } |
405 | - if ( $echo && ! $format ) { |
|
405 | + if ($echo && ! $format) { |
|
406 | 406 | echo $html; |
407 | 407 | return ''; |
408 | 408 | } |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | -if ( ! function_exists( 'espresso_event_date_obj' )) { |
|
415 | +if ( ! function_exists('espresso_event_date_obj')) { |
|
416 | 416 | /** |
417 | 417 | * espresso_event_date_obj |
418 | 418 | * returns the primary date object for an event |
@@ -420,13 +420,13 @@ discard block |
||
420 | 420 | * @param bool $EVT_ID |
421 | 421 | * @return object |
422 | 422 | */ |
423 | - function espresso_event_date_obj( $EVT_ID = FALSE ) { |
|
424 | - return EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
423 | + function espresso_event_date_obj($EVT_ID = FALSE) { |
|
424 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | |
428 | 428 | |
429 | -if ( ! function_exists( 'espresso_event_date' )) { |
|
429 | +if ( ! function_exists('espresso_event_date')) { |
|
430 | 430 | /** |
431 | 431 | * espresso_event_date |
432 | 432 | * returns the primary date for an event |
@@ -437,22 +437,22 @@ discard block |
||
437 | 437 | * @param bool $echo |
438 | 438 | * @return string |
439 | 439 | */ |
440 | - function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
441 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
442 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
443 | - $date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format ); |
|
444 | - $time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format ); |
|
445 | - if($echo){ |
|
446 | - echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
440 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
441 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
442 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
443 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
444 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
445 | + if ($echo) { |
|
446 | + echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
447 | 447 | return ''; |
448 | 448 | } |
449 | - return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
449 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
450 | 450 | |
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | 454 | |
455 | -if ( ! function_exists( 'espresso_list_of_event_dates' )) { |
|
455 | +if ( ! function_exists('espresso_list_of_event_dates')) { |
|
456 | 456 | /** |
457 | 457 | * espresso_list_of_event_dates |
458 | 458 | * returns a unordered list of dates for an event |
@@ -467,40 +467,40 @@ discard block |
||
467 | 467 | * @param null $limit |
468 | 468 | * @return string |
469 | 469 | */ |
470 | - function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) { |
|
471 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
472 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
473 | - $date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format ); |
|
474 | - $time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format ); |
|
475 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
476 | - if ( ! $format ) { |
|
477 | - return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes ); |
|
470 | + function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) { |
|
471 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
472 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
473 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
474 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
475 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit); |
|
476 | + if ( ! $format) { |
|
477 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
478 | 478 | } |
479 | 479 | //d( $datetimes ); |
480 | - if ( is_array( $datetimes ) && ! empty( $datetimes )) { |
|
480 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
481 | 481 | global $post; |
482 | - $html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
483 | - foreach ( $datetimes as $datetime ) { |
|
484 | - if ( $datetime instanceof EE_Datetime ) { |
|
485 | - $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
486 | - $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
482 | + $html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
483 | + foreach ($datetimes as $datetime) { |
|
484 | + if ($datetime instanceof EE_Datetime) { |
|
485 | + $html .= '<li id="ee-event-datetimes-li-'.$datetime->ID(); |
|
486 | + $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">'; |
|
487 | 487 | $datetime_name = $datetime->name(); |
488 | - $html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : ''; |
|
489 | - $html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : ''; |
|
490 | - $html .= '<span class="dashicons dashicons-calendar"></span>' . $datetime->date_range( $date_format ) . '<br/>'; |
|
491 | - $html .= '<span class="dashicons dashicons-clock"></span>' . $datetime->time_range( $time_format ); |
|
488 | + $html .= ! empty($datetime_name) ? '<strong>'.$datetime_name.'</strong>' : ''; |
|
489 | + $html .= ! empty($datetime_name) && $add_breaks ? '<br />' : ''; |
|
490 | + $html .= '<span class="dashicons dashicons-calendar"></span>'.$datetime->date_range($date_format).'<br/>'; |
|
491 | + $html .= '<span class="dashicons dashicons-clock"></span>'.$datetime->time_range($time_format); |
|
492 | 492 | $datetime_description = $datetime->description(); |
493 | - $html .= ! empty( $datetime_description ) && $add_breaks ? '<br />' : ''; |
|
494 | - $html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : ''; |
|
495 | - $html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime ); |
|
493 | + $html .= ! empty($datetime_description) && $add_breaks ? '<br />' : ''; |
|
494 | + $html .= ! empty($datetime_description) ? ' - '.$datetime_description : ''; |
|
495 | + $html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime); |
|
496 | 496 | $html .= '</li>'; |
497 | 497 | } |
498 | 498 | } |
499 | 499 | $html .= $format ? '</ul>' : ''; |
500 | 500 | } else { |
501 | - $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : ''; |
|
501 | + $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : ''; |
|
502 | 502 | } |
503 | - if ( $echo ) { |
|
503 | + if ($echo) { |
|
504 | 504 | echo $html; |
505 | 505 | return ''; |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | } |
510 | 510 | |
511 | 511 | |
512 | -if ( ! function_exists( 'espresso_event_end_date' )) { |
|
512 | +if ( ! function_exists('espresso_event_end_date')) { |
|
513 | 513 | /** |
514 | 514 | * espresso_event_end_date |
515 | 515 | * returns the last date for an event |
@@ -520,20 +520,20 @@ discard block |
||
520 | 520 | * @param bool $echo |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
524 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
525 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
526 | - $date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format ); |
|
527 | - $time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format ); |
|
528 | - if($echo){ |
|
529 | - echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
523 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
524 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
525 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
526 | + $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
527 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
528 | + if ($echo) { |
|
529 | + echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
530 | 530 | return ''; |
531 | 531 | } |
532 | - return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
532 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 | |
536 | -if ( ! function_exists( 'espresso_event_date_range' )) { |
|
536 | +if ( ! function_exists('espresso_event_date_range')) { |
|
537 | 537 | /** |
538 | 538 | * espresso_event_date_range |
539 | 539 | * returns the first and last chronologically ordered dates for an event (if different) |
@@ -546,31 +546,31 @@ discard block |
||
546 | 546 | * @param bool $echo |
547 | 547 | * @return string |
548 | 548 | */ |
549 | - function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
549 | + function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
550 | 550 | // set and filter date and time formats when a range is returned |
551 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
552 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format ); |
|
551 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
552 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
553 | 553 | // get the start and end date with NO time portion |
554 | - $the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID ); |
|
555 | - $the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID ); |
|
554 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
555 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
556 | 556 | // now we can determine if date range spans more than one day |
557 | - if ( $the_event_date != $the_event_end_date ) { |
|
558 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
559 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format ); |
|
557 | + if ($the_event_date != $the_event_end_date) { |
|
558 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
559 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
560 | 560 | $html = sprintf( |
561 | - __( '%1$s - %2$s', 'event_espresso' ), |
|
562 | - EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ), |
|
563 | - EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID ) |
|
561 | + __('%1$s - %2$s', 'event_espresso'), |
|
562 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
563 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
564 | 564 | ); |
565 | 565 | } else { |
566 | 566 | // set and filter date and time formats when only a single datetime is returned |
567 | - $single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' ); |
|
568 | - $single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' ); |
|
569 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format ); |
|
570 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format ); |
|
571 | - $html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID ); |
|
567 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
568 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
569 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
570 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
571 | + $html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
572 | 572 | } |
573 | - if ( $echo ) { |
|
573 | + if ($echo) { |
|
574 | 574 | echo $html; |
575 | 575 | return ''; |
576 | 576 | } |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | } |
580 | 580 | |
581 | 581 | |
582 | -if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) { |
|
582 | +if ( ! function_exists('espresso_event_date_as_calendar_page')) { |
|
583 | 583 | /** |
584 | 584 | * espresso_event_date_as_calendar_page |
585 | 585 | * returns the primary date for an event, stylized to appear as the page of a calendar |
@@ -587,15 +587,15 @@ discard block |
||
587 | 587 | * @param bool $EVT_ID |
588 | 588 | * @return string |
589 | 589 | */ |
590 | - function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) { |
|
591 | - EEH_Event_View::event_date_as_calendar_page( $EVT_ID ); |
|
590 | + function espresso_event_date_as_calendar_page($EVT_ID = FALSE) { |
|
591 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | 595 | |
596 | 596 | |
597 | 597 | |
598 | -if ( ! function_exists( 'espresso_event_link_url' )) { |
|
598 | +if ( ! function_exists('espresso_event_link_url')) { |
|
599 | 599 | /** |
600 | 600 | * espresso_event_link_url |
601 | 601 | * |
@@ -603,18 +603,18 @@ discard block |
||
603 | 603 | * @param bool $echo |
604 | 604 | * @return string |
605 | 605 | */ |
606 | - function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) { |
|
607 | - if ( $echo ) { |
|
608 | - echo EEH_Event_View::event_link_url( $EVT_ID ); |
|
606 | + function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) { |
|
607 | + if ($echo) { |
|
608 | + echo EEH_Event_View::event_link_url($EVT_ID); |
|
609 | 609 | return ''; |
610 | 610 | } |
611 | - return EEH_Event_View::event_link_url( $EVT_ID ); |
|
611 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
615 | 615 | |
616 | 616 | |
617 | -if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) { |
|
617 | +if ( ! function_exists('espresso_event_has_content_or_excerpt')) { |
|
618 | 618 | /** |
619 | 619 | * espresso_event_has_content_or_excerpt |
620 | 620 | * |
@@ -622,15 +622,15 @@ discard block |
||
622 | 622 | * @param bool $EVT_ID |
623 | 623 | * @return boolean |
624 | 624 | */ |
625 | - function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) { |
|
626 | - return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID ); |
|
625 | + function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) { |
|
626 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | |
630 | 630 | |
631 | 631 | |
632 | 632 | |
633 | -if ( ! function_exists( 'espresso_event_content_or_excerpt' )) { |
|
633 | +if ( ! function_exists('espresso_event_content_or_excerpt')) { |
|
634 | 634 | /** |
635 | 635 | * espresso_event_content_or_excerpt |
636 | 636 | * |
@@ -639,18 +639,18 @@ discard block |
||
639 | 639 | * @param bool $echo |
640 | 640 | * @return string |
641 | 641 | */ |
642 | - function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) { |
|
643 | - if ( $echo ) { |
|
644 | - echo EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
642 | + function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) { |
|
643 | + if ($echo) { |
|
644 | + echo EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
645 | 645 | return ''; |
646 | 646 | } |
647 | - return EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
647 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
651 | 651 | |
652 | 652 | |
653 | -if ( ! function_exists( 'espresso_event_phone' )) { |
|
653 | +if ( ! function_exists('espresso_event_phone')) { |
|
654 | 654 | /** |
655 | 655 | * espresso_event_phone |
656 | 656 | * |
@@ -658,18 +658,18 @@ discard block |
||
658 | 658 | * @param bool $echo |
659 | 659 | * @return string |
660 | 660 | */ |
661 | - function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) { |
|
662 | - if ( $echo ) { |
|
663 | - echo EEH_Event_View::event_phone( $EVT_ID ); |
|
661 | + function espresso_event_phone($EVT_ID = 0, $echo = TRUE) { |
|
662 | + if ($echo) { |
|
663 | + echo EEH_Event_View::event_phone($EVT_ID); |
|
664 | 664 | return ''; |
665 | 665 | } |
666 | - return EEH_Event_View::event_phone( $EVT_ID ); |
|
666 | + return EEH_Event_View::event_phone($EVT_ID); |
|
667 | 667 | } |
668 | 668 | } |
669 | 669 | |
670 | 670 | |
671 | 671 | |
672 | -if ( ! function_exists( 'espresso_edit_event_link' )) { |
|
672 | +if ( ! function_exists('espresso_edit_event_link')) { |
|
673 | 673 | /** |
674 | 674 | * espresso_edit_event_link |
675 | 675 | * returns a link to edit an event |
@@ -678,39 +678,39 @@ discard block |
||
678 | 678 | * @param bool $echo |
679 | 679 | * @return string |
680 | 680 | */ |
681 | - function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) { |
|
682 | - if ( $echo ) { |
|
683 | - echo EEH_Event_View::edit_event_link( $EVT_ID ); |
|
681 | + function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) { |
|
682 | + if ($echo) { |
|
683 | + echo EEH_Event_View::edit_event_link($EVT_ID); |
|
684 | 684 | return ''; |
685 | 685 | } |
686 | - return EEH_Event_View::edit_event_link( $EVT_ID ); |
|
686 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | 690 | |
691 | -if ( ! function_exists( 'espresso_organization_name' )) { |
|
691 | +if ( ! function_exists('espresso_organization_name')) { |
|
692 | 692 | /** |
693 | 693 | * espresso_organization_name |
694 | 694 | * @param bool $echo |
695 | 695 | * @return string |
696 | 696 | */ |
697 | 697 | function espresso_organization_name($echo = TRUE) { |
698 | - if($echo){ |
|
699 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
698 | + if ($echo) { |
|
699 | + echo EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
700 | 700 | return ''; |
701 | 701 | } |
702 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
702 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
703 | 703 | } |
704 | 704 | } |
705 | 705 | |
706 | -if ( ! function_exists( 'espresso_organization_address' )) { |
|
706 | +if ( ! function_exists('espresso_organization_address')) { |
|
707 | 707 | /** |
708 | 708 | * espresso_organization_address |
709 | 709 | * @param string $type |
710 | 710 | * @return string |
711 | 711 | */ |
712 | - function espresso_organization_address( $type = 'inline' ) { |
|
713 | - if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) { |
|
712 | + function espresso_organization_address($type = 'inline') { |
|
713 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
714 | 714 | $address = new EventEspresso\core\domain\entities\GenericAddress( |
715 | 715 | EE_Registry::instance()->CFG->organization->address_1, |
716 | 716 | EE_Registry::instance()->CFG->organization->address_2, |
@@ -719,129 +719,129 @@ discard block |
||
719 | 719 | EE_Registry::instance()->CFG->organization->zip, |
720 | 720 | EE_Registry::instance()->CFG->organization->CNT_ISO |
721 | 721 | ); |
722 | - return EEH_Address::format( $address, $type ); |
|
722 | + return EEH_Address::format($address, $type); |
|
723 | 723 | } |
724 | 724 | return ''; |
725 | 725 | } |
726 | 726 | } |
727 | 727 | |
728 | -if ( ! function_exists( 'espresso_organization_email' )) { |
|
728 | +if ( ! function_exists('espresso_organization_email')) { |
|
729 | 729 | /** |
730 | 730 | * espresso_organization_email |
731 | 731 | * @param bool $echo |
732 | 732 | * @return string |
733 | 733 | */ |
734 | - function espresso_organization_email( $echo = TRUE ) { |
|
735 | - if($echo){ |
|
736 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
734 | + function espresso_organization_email($echo = TRUE) { |
|
735 | + if ($echo) { |
|
736 | + echo EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
737 | 737 | return ''; |
738 | 738 | } |
739 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
739 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
740 | 740 | } |
741 | 741 | } |
742 | 742 | |
743 | -if ( ! function_exists( 'espresso_organization_logo_url' )) { |
|
743 | +if ( ! function_exists('espresso_organization_logo_url')) { |
|
744 | 744 | /** |
745 | 745 | * espresso_organization_logo_url |
746 | 746 | * @param bool $echo |
747 | 747 | * @return string |
748 | 748 | */ |
749 | - function espresso_organization_logo_url( $echo = TRUE ) { |
|
750 | - if($echo){ |
|
751 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
749 | + function espresso_organization_logo_url($echo = TRUE) { |
|
750 | + if ($echo) { |
|
751 | + echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
752 | 752 | return ''; |
753 | 753 | } |
754 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
754 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
755 | 755 | } |
756 | 756 | } |
757 | 757 | |
758 | -if ( ! function_exists( 'espresso_organization_facebook' )) { |
|
758 | +if ( ! function_exists('espresso_organization_facebook')) { |
|
759 | 759 | /** |
760 | 760 | * espresso_organization_facebook |
761 | 761 | * @param bool $echo |
762 | 762 | * @return string |
763 | 763 | */ |
764 | - function espresso_organization_facebook( $echo = TRUE ) { |
|
765 | - if($echo){ |
|
766 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
764 | + function espresso_organization_facebook($echo = TRUE) { |
|
765 | + if ($echo) { |
|
766 | + echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
767 | 767 | return ''; |
768 | 768 | } |
769 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
769 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
770 | 770 | } |
771 | 771 | } |
772 | 772 | |
773 | -if ( ! function_exists( 'espresso_organization_twitter' )) { |
|
773 | +if ( ! function_exists('espresso_organization_twitter')) { |
|
774 | 774 | /** |
775 | 775 | * espresso_organization_twitter |
776 | 776 | * @param bool $echo |
777 | 777 | * @return string |
778 | 778 | */ |
779 | - function espresso_organization_twitter( $echo = TRUE ) { |
|
780 | - if($echo){ |
|
781 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
779 | + function espresso_organization_twitter($echo = TRUE) { |
|
780 | + if ($echo) { |
|
781 | + echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
782 | 782 | return ''; |
783 | 783 | } |
784 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
784 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
788 | -if ( ! function_exists( 'espresso_organization_linkedin' )) { |
|
788 | +if ( ! function_exists('espresso_organization_linkedin')) { |
|
789 | 789 | /** |
790 | 790 | * espresso_organization_linkedin |
791 | 791 | * @param bool $echo |
792 | 792 | * @return string |
793 | 793 | */ |
794 | - function espresso_organization_linkedin( $echo = TRUE ) { |
|
795 | - if($echo){ |
|
796 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
794 | + function espresso_organization_linkedin($echo = TRUE) { |
|
795 | + if ($echo) { |
|
796 | + echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
797 | 797 | return ''; |
798 | 798 | } |
799 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
799 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
800 | 800 | } |
801 | 801 | } |
802 | 802 | |
803 | -if ( ! function_exists( 'espresso_organization_pinterest' )) { |
|
803 | +if ( ! function_exists('espresso_organization_pinterest')) { |
|
804 | 804 | /** |
805 | 805 | * espresso_organization_pinterest |
806 | 806 | * @param bool $echo |
807 | 807 | * @return string |
808 | 808 | */ |
809 | - function espresso_organization_pinterest( $echo = TRUE ) { |
|
810 | - if($echo){ |
|
811 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
809 | + function espresso_organization_pinterest($echo = TRUE) { |
|
810 | + if ($echo) { |
|
811 | + echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
812 | 812 | return ''; |
813 | 813 | } |
814 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
814 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
815 | 815 | } |
816 | 816 | } |
817 | 817 | |
818 | -if ( ! function_exists( 'espresso_organization_google' )) { |
|
818 | +if ( ! function_exists('espresso_organization_google')) { |
|
819 | 819 | /** |
820 | 820 | * espresso_organization_google |
821 | 821 | * @param bool $echo |
822 | 822 | * @return string |
823 | 823 | */ |
824 | - function espresso_organization_google( $echo = TRUE ) { |
|
825 | - if($echo){ |
|
826 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
824 | + function espresso_organization_google($echo = TRUE) { |
|
825 | + if ($echo) { |
|
826 | + echo EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
827 | 827 | return ''; |
828 | 828 | } |
829 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
829 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
830 | 830 | } |
831 | 831 | } |
832 | 832 | |
833 | -if ( ! function_exists( 'espresso_organization_instagram' )) { |
|
833 | +if ( ! function_exists('espresso_organization_instagram')) { |
|
834 | 834 | /** |
835 | 835 | * espresso_organization_instagram |
836 | 836 | * @param bool $echo |
837 | 837 | * @return string |
838 | 838 | */ |
839 | - function espresso_organization_instagram( $echo = TRUE ) { |
|
840 | - if($echo){ |
|
841 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
839 | + function espresso_organization_instagram($echo = TRUE) { |
|
840 | + if ($echo) { |
|
841 | + echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
842 | 842 | return ''; |
843 | 843 | } |
844 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
844 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | |
852 | 852 | |
853 | 853 | |
854 | -if ( ! function_exists( 'espresso_event_venues' )) { |
|
854 | +if ( ! function_exists('espresso_event_venues')) { |
|
855 | 855 | /** |
856 | 856 | * espresso_event_venues |
857 | 857 | * |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | |
866 | 866 | |
867 | 867 | |
868 | -if ( ! function_exists( 'espresso_venue_id' )) { |
|
868 | +if ( ! function_exists('espresso_venue_id')) { |
|
869 | 869 | /** |
870 | 870 | * espresso_venue_name |
871 | 871 | * |
@@ -873,15 +873,15 @@ discard block |
||
873 | 873 | * @param int $EVT_ID |
874 | 874 | * @return string |
875 | 875 | */ |
876 | - function espresso_venue_id( $EVT_ID = 0 ) { |
|
877 | - $venue = EEH_Venue_View::get_venue( $EVT_ID ); |
|
876 | + function espresso_venue_id($EVT_ID = 0) { |
|
877 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
878 | 878 | return $venue instanceof EE_Venue ? $venue->ID() : 0; |
879 | 879 | } |
880 | 880 | } |
881 | 881 | |
882 | 882 | |
883 | 883 | |
884 | -if ( ! function_exists( 'espresso_is_venue_private' ) ) { |
|
884 | +if ( ! function_exists('espresso_is_venue_private')) { |
|
885 | 885 | /** |
886 | 886 | * Return whether a venue is private or not. |
887 | 887 | * @see EEH_Venue_View::get_venue() for more info on expected return results. |
@@ -890,45 +890,45 @@ discard block |
||
890 | 890 | * |
891 | 891 | * @return bool | null |
892 | 892 | */ |
893 | - function espresso_is_venue_private( $VNU_ID = 0 ) { |
|
894 | - return EEH_Venue_View::is_venue_private( $VNU_ID ); |
|
893 | + function espresso_is_venue_private($VNU_ID = 0) { |
|
894 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | |
898 | 898 | |
899 | 899 | |
900 | -if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) { |
|
900 | +if ( ! function_exists('espresso_venue_is_password_protected')) { |
|
901 | 901 | /** |
902 | 902 | * returns true or false if a venue is password protected or not |
903 | 903 | * |
904 | 904 | * @param int $VNU_ID optional, the venue id to check. |
905 | 905 | * @return string |
906 | 906 | */ |
907 | - function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
|
908 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
909 | - return EEH_Venue_View::is_venue_password_protected( $VNU_ID ); |
|
907 | + function espresso_venue_is_password_protected($VNU_ID = 0) { |
|
908 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
909 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
910 | 910 | } |
911 | 911 | } |
912 | 912 | |
913 | 913 | |
914 | 914 | |
915 | -if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) { |
|
915 | +if ( ! function_exists('espresso_password_protected_venue_form')) { |
|
916 | 916 | /** |
917 | 917 | * Returns a password form if venue is password protected. |
918 | 918 | * |
919 | 919 | * @param int $VNU_ID optional, the venue id to check. |
920 | 920 | * @return string |
921 | 921 | */ |
922 | - function espresso_password_protected_venue_form( $VNU_ID = 0 ) { |
|
923 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
924 | - return EEH_Venue_View::password_protected_venue_form( $VNU_ID ); |
|
922 | + function espresso_password_protected_venue_form($VNU_ID = 0) { |
|
923 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
924 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
925 | 925 | } |
926 | 926 | } |
927 | 927 | |
928 | 928 | |
929 | 929 | |
930 | 930 | |
931 | -if ( ! function_exists( 'espresso_venue_name' )) { |
|
931 | +if ( ! function_exists('espresso_venue_name')) { |
|
932 | 932 | /** |
933 | 933 | * espresso_venue_name |
934 | 934 | * |
@@ -938,19 +938,19 @@ discard block |
||
938 | 938 | * @param bool $echo |
939 | 939 | * @return string |
940 | 940 | */ |
941 | - function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) { |
|
942 | - if($echo){ |
|
943 | - echo EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
941 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) { |
|
942 | + if ($echo) { |
|
943 | + echo EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
944 | 944 | return ''; |
945 | 945 | } |
946 | - return EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
946 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
947 | 947 | } |
948 | 948 | } |
949 | 949 | |
950 | 950 | |
951 | 951 | |
952 | 952 | |
953 | -if ( ! function_exists( 'espresso_venue_link' )) { |
|
953 | +if ( ! function_exists('espresso_venue_link')) { |
|
954 | 954 | /** |
955 | 955 | * espresso_venue_link |
956 | 956 | * |
@@ -959,14 +959,14 @@ discard block |
||
959 | 959 | * @param string $text |
960 | 960 | * @return string |
961 | 961 | */ |
962 | - function espresso_venue_link( $VNU_ID = 0, $text = '' ) { |
|
963 | - return EEH_Venue_View::venue_details_link( $VNU_ID, $text ); |
|
962 | + function espresso_venue_link($VNU_ID = 0, $text = '') { |
|
963 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
964 | 964 | } |
965 | 965 | } |
966 | 966 | |
967 | 967 | |
968 | 968 | |
969 | -if ( ! function_exists( 'espresso_venue_description' )) { |
|
969 | +if ( ! function_exists('espresso_venue_description')) { |
|
970 | 970 | /** |
971 | 971 | * espresso_venue_description |
972 | 972 | * |
@@ -975,17 +975,17 @@ discard block |
||
975 | 975 | * @param bool $echo |
976 | 976 | * @return string |
977 | 977 | */ |
978 | - function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) { |
|
979 | - if($echo){ |
|
980 | - echo EEH_Venue_View::venue_description( $VNU_ID ); |
|
978 | + function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) { |
|
979 | + if ($echo) { |
|
980 | + echo EEH_Venue_View::venue_description($VNU_ID); |
|
981 | 981 | return ''; |
982 | 982 | } |
983 | - return EEH_Venue_View::venue_description( $VNU_ID ); |
|
983 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
984 | 984 | } |
985 | 985 | } |
986 | 986 | |
987 | 987 | |
988 | -if ( ! function_exists( 'espresso_venue_excerpt' )) { |
|
988 | +if ( ! function_exists('espresso_venue_excerpt')) { |
|
989 | 989 | /** |
990 | 990 | * espresso_venue_excerpt |
991 | 991 | * |
@@ -994,18 +994,18 @@ discard block |
||
994 | 994 | * @param bool $echo |
995 | 995 | * @return string |
996 | 996 | */ |
997 | - function espresso_venue_excerpt( $VNU_ID = 0, $echo = TRUE ) { |
|
998 | - if ( $echo ) { |
|
999 | - echo EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
997 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) { |
|
998 | + if ($echo) { |
|
999 | + echo EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1000 | 1000 | return ''; |
1001 | 1001 | } |
1002 | - return EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
1002 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1003 | 1003 | } |
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | |
1007 | 1007 | |
1008 | -if ( ! function_exists( 'espresso_venue_categories' )) { |
|
1008 | +if ( ! function_exists('espresso_venue_categories')) { |
|
1009 | 1009 | /** |
1010 | 1010 | * espresso_venue_categories |
1011 | 1011 | * returns the terms associated with a venue |
@@ -1015,17 +1015,17 @@ discard block |
||
1015 | 1015 | * @param bool $echo |
1016 | 1016 | * @return string |
1017 | 1017 | */ |
1018 | - function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
1019 | - if ( $echo ) { |
|
1020 | - echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1018 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
1019 | + if ($echo) { |
|
1020 | + echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1021 | 1021 | return ''; |
1022 | 1022 | } |
1023 | - return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1023 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | |
1028 | -if ( ! function_exists( 'espresso_venue_address' )) { |
|
1028 | +if ( ! function_exists('espresso_venue_address')) { |
|
1029 | 1029 | /** |
1030 | 1030 | * espresso_venue_address |
1031 | 1031 | * returns a formatted block of html for displaying a venue's address |
@@ -1035,17 +1035,17 @@ discard block |
||
1035 | 1035 | * @param bool $echo |
1036 | 1036 | * @return string |
1037 | 1037 | */ |
1038 | - function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1039 | - if ( $echo ) { |
|
1040 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1038 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1039 | + if ($echo) { |
|
1040 | + echo EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1041 | 1041 | return ''; |
1042 | 1042 | } |
1043 | - return EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1043 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1044 | 1044 | } |
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | |
1048 | -if ( ! function_exists( 'espresso_venue_raw_address' )) { |
|
1048 | +if ( ! function_exists('espresso_venue_raw_address')) { |
|
1049 | 1049 | /** |
1050 | 1050 | * espresso_venue_address |
1051 | 1051 | * returns an UN-formatted string containing a venue's address |
@@ -1055,17 +1055,17 @@ discard block |
||
1055 | 1055 | * @param bool $echo |
1056 | 1056 | * @return string |
1057 | 1057 | */ |
1058 | - function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1059 | - if ( $echo ) { |
|
1060 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1058 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1059 | + if ($echo) { |
|
1060 | + echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1061 | 1061 | return ''; |
1062 | 1062 | } |
1063 | - return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1063 | + return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1064 | 1064 | } |
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | |
1068 | -if ( ! function_exists( 'espresso_venue_has_address' )) { |
|
1068 | +if ( ! function_exists('espresso_venue_has_address')) { |
|
1069 | 1069 | /** |
1070 | 1070 | * espresso_venue_has_address |
1071 | 1071 | * returns TRUE or FALSE if a Venue has address information |
@@ -1073,13 +1073,13 @@ discard block |
||
1073 | 1073 | * @param int $VNU_ID |
1074 | 1074 | * @return bool |
1075 | 1075 | */ |
1076 | - function espresso_venue_has_address( $VNU_ID = 0 ) { |
|
1077 | - return EEH_Venue_View::venue_has_address( $VNU_ID ); |
|
1076 | + function espresso_venue_has_address($VNU_ID = 0) { |
|
1077 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1078 | 1078 | } |
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | |
1082 | -if ( ! function_exists( 'espresso_venue_gmap' )) { |
|
1082 | +if ( ! function_exists('espresso_venue_gmap')) { |
|
1083 | 1083 | /** |
1084 | 1084 | * espresso_venue_gmap |
1085 | 1085 | * returns a google map for the venue address |
@@ -1090,17 +1090,17 @@ discard block |
||
1090 | 1090 | * @param bool $echo |
1091 | 1091 | * @return string |
1092 | 1092 | */ |
1093 | - function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE ) { |
|
1094 | - if ( $echo ) { |
|
1095 | - echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1093 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) { |
|
1094 | + if ($echo) { |
|
1095 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1096 | 1096 | return ''; |
1097 | 1097 | } |
1098 | - return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1098 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1099 | 1099 | } |
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | |
1103 | -if ( ! function_exists( 'espresso_venue_phone' )) { |
|
1103 | +if ( ! function_exists('espresso_venue_phone')) { |
|
1104 | 1104 | /** |
1105 | 1105 | * espresso_venue_phone |
1106 | 1106 | * |
@@ -1108,18 +1108,18 @@ discard block |
||
1108 | 1108 | * @param bool $echo |
1109 | 1109 | * @return string |
1110 | 1110 | */ |
1111 | - function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) { |
|
1112 | - if ( $echo ) { |
|
1113 | - echo EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1111 | + function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) { |
|
1112 | + if ($echo) { |
|
1113 | + echo EEH_Venue_View::venue_phone($VNU_ID); |
|
1114 | 1114 | return ''; |
1115 | 1115 | } |
1116 | - return EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1116 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | |
1121 | 1121 | |
1122 | -if ( ! function_exists( 'espresso_venue_website' )) { |
|
1122 | +if ( ! function_exists('espresso_venue_website')) { |
|
1123 | 1123 | /** |
1124 | 1124 | * espresso_venue_website |
1125 | 1125 | * |
@@ -1127,18 +1127,18 @@ discard block |
||
1127 | 1127 | * @param bool $echo |
1128 | 1128 | * @return string |
1129 | 1129 | */ |
1130 | - function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) { |
|
1131 | - if ( $echo ) { |
|
1132 | - echo EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1130 | + function espresso_venue_website($VNU_ID = 0, $echo = TRUE) { |
|
1131 | + if ($echo) { |
|
1132 | + echo EEH_Venue_View::venue_website_link($VNU_ID); |
|
1133 | 1133 | return ''; |
1134 | 1134 | } |
1135 | - return EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1135 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1136 | 1136 | } |
1137 | 1137 | } |
1138 | 1138 | |
1139 | 1139 | |
1140 | 1140 | |
1141 | -if ( ! function_exists( 'espresso_edit_venue_link' )) { |
|
1141 | +if ( ! function_exists('espresso_edit_venue_link')) { |
|
1142 | 1142 | /** |
1143 | 1143 | * espresso_edit_venue_link |
1144 | 1144 | * |
@@ -1146,12 +1146,12 @@ discard block |
||
1146 | 1146 | * @param bool $echo |
1147 | 1147 | * @return string |
1148 | 1148 | */ |
1149 | - function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) { |
|
1150 | - if($echo){ |
|
1151 | - echo EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1149 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) { |
|
1150 | + if ($echo) { |
|
1151 | + echo EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1152 | 1152 | return ''; |
1153 | 1153 | } |
1154 | - return EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1154 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1155 | 1155 | } |
1156 | 1156 | } |
1157 | 1157 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | { |
183 | 183 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
184 | 184 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
185 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
185 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
186 | 186 | //load and setup EE_Capabilities |
187 | 187 | $this->registry->load_core('Capabilities'); |
188 | 188 | //caps need to be initialized on every request so that capability maps are set. |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | && $_GET['activate'] === 'true' |
206 | 206 | ) |
207 | 207 | ) { |
208 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
208 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
209 | 209 | } |
210 | 210 | do_action('AHEE__EE_System__load_espresso_addons__complete'); |
211 | 211 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | private function _parse_model_names() |
688 | 688 | { |
689 | 689 | //get all the files in the EE_MODELS folder that end in .model.php |
690 | - $models = glob(EE_MODELS . '*.model.php'); |
|
690 | + $models = glob(EE_MODELS.'*.model.php'); |
|
691 | 691 | $model_names = array(); |
692 | 692 | $non_abstract_db_models = array(); |
693 | 693 | foreach ($models as $model) { |
@@ -715,8 +715,8 @@ discard block |
||
715 | 715 | */ |
716 | 716 | private function _maybe_brew_regular() |
717 | 717 | { |
718 | - if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
719 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
718 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
719 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
720 | 720 | } |
721 | 721 | } |
722 | 722 | |
@@ -757,8 +757,8 @@ discard block |
||
757 | 757 | 'event_espresso'); |
758 | 758 | $msg .= '<ul>'; |
759 | 759 | foreach ($class_names as $class_name) { |
760 | - $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
761 | - $class_name) . '</b></li>'; |
|
760 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
761 | + $class_name).'</b></li>'; |
|
762 | 762 | } |
763 | 763 | $msg .= '</ul>'; |
764 | 764 | $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | 'href' => $events_admin_url, |
1054 | 1054 | 'meta' => array( |
1055 | 1055 | 'title' => __('Event Espresso', 'event_espresso'), |
1056 | - 'class' => $menu_class . 'first', |
|
1056 | + 'class' => $menu_class.'first', |
|
1057 | 1057 | ), |
1058 | 1058 | )); |
1059 | 1059 | //Events |
@@ -1430,10 +1430,10 @@ discard block |
||
1430 | 1430 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1431 | 1431 | if (apply_filters('FHEE_load_jquery_validate', false)) { |
1432 | 1432 | // register jQuery Validate and additional methods |
1433 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1433 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
1434 | 1434 | array('jquery'), '1.15.0', true); |
1435 | 1435 | wp_register_script('jquery-validate-extra-methods', |
1436 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1436 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
1437 | 1437 | array('jquery', 'jquery-validate'), '1.15.0', true); |
1438 | 1438 | } |
1439 | 1439 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use EventEspresso\core\services\conditional_logic\rules\RuleManager; |
7 | 7 | |
8 | 8 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
9 | - exit('No direct script access allowed'); |
|
9 | + exit('No direct script access allowed'); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | |
@@ -23,1440 +23,1440 @@ discard block |
||
23 | 23 | { |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
28 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
29 | - */ |
|
30 | - const req_type_normal = 0; |
|
31 | - |
|
32 | - /** |
|
33 | - * Indicates this is a brand new installation of EE so we should install |
|
34 | - * tables and default data etc |
|
35 | - */ |
|
36 | - const req_type_new_activation = 1; |
|
37 | - |
|
38 | - /** |
|
39 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
40 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
41 | - * and that default data is setup too |
|
42 | - */ |
|
43 | - const req_type_reactivation = 2; |
|
44 | - |
|
45 | - /** |
|
46 | - * indicates that EE has been upgraded since its previous request. |
|
47 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
48 | - */ |
|
49 | - const req_type_upgrade = 3; |
|
50 | - |
|
51 | - /** |
|
52 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
53 | - */ |
|
54 | - const req_type_downgrade = 4; |
|
55 | - |
|
56 | - /** |
|
57 | - * @deprecated since version 4.6.0.dev.006 |
|
58 | - * Now whenever a new_activation is detected the request type is still just |
|
59 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
60 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
61 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
62 | - * (Specifically, when the migration manager indicates migrations are finished |
|
63 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
64 | - */ |
|
65 | - const req_type_activation_but_not_installed = 5; |
|
66 | - |
|
67 | - /** |
|
68 | - * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
69 | - */ |
|
70 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * instance of the EE_System object |
|
75 | - * |
|
76 | - * @var $_instance |
|
77 | - * @access private |
|
78 | - */ |
|
79 | - private static $_instance = null; |
|
80 | - |
|
81 | - /** |
|
82 | - * @type EE_Registry $Registry |
|
83 | - * @access protected |
|
84 | - */ |
|
85 | - protected $registry; |
|
86 | - |
|
87 | - /** |
|
88 | - * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
89 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
90 | - * |
|
91 | - * @var int |
|
92 | - */ |
|
93 | - private $_req_type; |
|
94 | - |
|
95 | - /** |
|
96 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
97 | - * |
|
98 | - * @var boolean |
|
99 | - */ |
|
100 | - private $_major_version_change = false; |
|
101 | - |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * @singleton method used to instantiate class object |
|
106 | - * @access public |
|
107 | - * @param \EE_Registry $Registry |
|
108 | - * @return \EE_System |
|
109 | - */ |
|
110 | - public static function instance(EE_Registry $Registry = null) |
|
111 | - { |
|
112 | - // check if class object is instantiated |
|
113 | - if ( ! self::$_instance instanceof EE_System) { |
|
114 | - self::$_instance = new self($Registry); |
|
115 | - } |
|
116 | - return self::$_instance; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * resets the instance and returns it |
|
123 | - * |
|
124 | - * @return EE_System |
|
125 | - */ |
|
126 | - public static function reset() |
|
127 | - { |
|
128 | - self::$_instance->_req_type = null; |
|
129 | - //make sure none of the old hooks are left hanging around |
|
130 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
131 | - //we need to reset the migration manager in order for it to detect DMSs properly |
|
132 | - EE_Data_Migration_Manager::reset(); |
|
133 | - self::instance()->detect_activations_or_upgrades(); |
|
134 | - self::instance()->perform_activations_upgrades_and_migrations(); |
|
135 | - return self::instance(); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * sets hooks for running rest of system |
|
142 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
143 | - * starting EE Addons from any other point may lead to problems |
|
144 | - * |
|
145 | - * @access private |
|
146 | - * @param \EE_Registry $Registry |
|
147 | - */ |
|
148 | - private function __construct(EE_Registry $Registry) |
|
149 | - { |
|
150 | - $this->registry = $Registry; |
|
151 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
152 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
153 | - add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
154 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
155 | - // because the newly-activated addon didn't get a chance to run at all |
|
156 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
157 | - // detect whether install or upgrade |
|
158 | - add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
159 | - 3); |
|
160 | - // load EE_Config, EE_Textdomain, etc |
|
161 | - add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
162 | - // load EE_Config, EE_Textdomain, etc |
|
163 | - add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
164 | - array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
165 | - // you wanna get going? I wanna get going... let's get going! |
|
166 | - add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
167 | - //other housekeeping |
|
168 | - //exclude EE critical pages from wp_list_pages |
|
169 | - add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
170 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
171 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
172 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * load_espresso_addons |
|
179 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
180 | - * this is hooked into both: |
|
181 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
182 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
183 | - * and the WP 'activate_plugin' hookpoint |
|
184 | - * |
|
185 | - * @access public |
|
186 | - * @return void |
|
187 | - */ |
|
188 | - public function load_espresso_addons() |
|
189 | - { |
|
190 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
191 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
192 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
193 | - //load and setup EE_Capabilities |
|
194 | - $this->registry->load_core('Capabilities'); |
|
195 | - //caps need to be initialized on every request so that capability maps are set. |
|
196 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
197 | - $this->registry->CAP->init_caps(); |
|
198 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
199 | - //if the WP API basic auth plugin isn't already loaded, load it now. |
|
200 | - //We want it for mobile apps. Just include the entire plugin |
|
201 | - //also, don't load the basic auth when a plugin is getting activated, because |
|
202 | - //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
203 | - //and causes a fatal error |
|
204 | - if ( ! function_exists('json_basic_auth_handler') |
|
205 | - && ! function_exists('json_basic_auth_error') |
|
206 | - && ! ( |
|
207 | - isset($_GET['action']) |
|
208 | - && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
209 | - ) |
|
210 | - && ! ( |
|
211 | - isset($_GET['activate']) |
|
212 | - && $_GET['activate'] === 'true' |
|
213 | - ) |
|
214 | - ) { |
|
215 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
216 | - } |
|
217 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * detect_activations_or_upgrades |
|
224 | - * Checks for activation or upgrade of core first; |
|
225 | - * then also checks if any registered addons have been activated or upgraded |
|
226 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
227 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
228 | - * |
|
229 | - * @access public |
|
230 | - * @return void |
|
231 | - */ |
|
232 | - public function detect_activations_or_upgrades() |
|
233 | - { |
|
234 | - //first off: let's make sure to handle core |
|
235 | - $this->detect_if_activation_or_upgrade(); |
|
236 | - foreach ($this->registry->addons as $addon) { |
|
237 | - //detect teh request type for that addon |
|
238 | - $addon->detect_activation_or_upgrade(); |
|
239 | - } |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * detect_if_activation_or_upgrade |
|
246 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
247 | - * and either setting up the DB or setting up maintenance mode etc. |
|
248 | - * |
|
249 | - * @access public |
|
250 | - * @return void |
|
251 | - */ |
|
252 | - public function detect_if_activation_or_upgrade() |
|
253 | - { |
|
254 | - do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
255 | - // load M-Mode class |
|
256 | - $this->registry->load_core('Maintenance_Mode'); |
|
257 | - // check if db has been updated, or if its a brand-new installation |
|
258 | - $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
259 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
260 | - //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
261 | - switch ($request_type) { |
|
262 | - case EE_System::req_type_new_activation: |
|
263 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
264 | - $this->_handle_core_version_change($espresso_db_update); |
|
265 | - break; |
|
266 | - case EE_System::req_type_reactivation: |
|
267 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
268 | - $this->_handle_core_version_change($espresso_db_update); |
|
269 | - break; |
|
270 | - case EE_System::req_type_upgrade: |
|
271 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
272 | - //migrations may be required now that we've upgraded |
|
273 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
274 | - $this->_handle_core_version_change($espresso_db_update); |
|
275 | - // echo "done upgrade";die; |
|
276 | - break; |
|
277 | - case EE_System::req_type_downgrade: |
|
278 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
279 | - //its possible migrations are no longer required |
|
280 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
281 | - $this->_handle_core_version_change($espresso_db_update); |
|
282 | - break; |
|
283 | - case EE_System::req_type_normal: |
|
284 | - default: |
|
285 | - // $this->_maybe_redirect_to_ee_about(); |
|
286 | - break; |
|
287 | - } |
|
288 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * Updates the list of installed versions and sets hooks for |
|
295 | - * initializing the database later during the request |
|
296 | - * |
|
297 | - * @param array $espresso_db_update |
|
298 | - */ |
|
299 | - protected function _handle_core_version_change($espresso_db_update) |
|
300 | - { |
|
301 | - $this->update_list_of_installed_versions($espresso_db_update); |
|
302 | - //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
303 | - add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
304 | - array($this, 'initialize_db_if_no_migrations_required')); |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
311 | - * information about what versions of EE have been installed and activated, |
|
312 | - * NOT necessarily the state of the database |
|
313 | - * |
|
314 | - * @param null $espresso_db_update |
|
315 | - * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
316 | - * from the options table |
|
317 | - * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
318 | - */ |
|
319 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
320 | - { |
|
321 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
322 | - if ( ! $espresso_db_update) { |
|
323 | - $espresso_db_update = get_option('espresso_db_update'); |
|
324 | - } |
|
325 | - // check that option is an array |
|
326 | - if ( ! is_array($espresso_db_update)) { |
|
327 | - // if option is FALSE, then it never existed |
|
328 | - if ($espresso_db_update === false) { |
|
329 | - // make $espresso_db_update an array and save option with autoload OFF |
|
330 | - $espresso_db_update = array(); |
|
331 | - add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
332 | - } else { |
|
333 | - // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
334 | - $espresso_db_update = array($espresso_db_update => array()); |
|
335 | - update_option('espresso_db_update', $espresso_db_update); |
|
336 | - } |
|
337 | - } else { |
|
338 | - $corrected_db_update = array(); |
|
339 | - //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
340 | - foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
341 | - if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
342 | - //the key is an int, and the value IS NOT an array |
|
343 | - //so it must be numerically-indexed, where values are versions installed... |
|
344 | - //fix it! |
|
345 | - $version_string = $should_be_array; |
|
346 | - $corrected_db_update[$version_string] = array('unknown-date'); |
|
347 | - } else { |
|
348 | - //ok it checks out |
|
349 | - $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
350 | - } |
|
351 | - } |
|
352 | - $espresso_db_update = $corrected_db_update; |
|
353 | - update_option('espresso_db_update', $espresso_db_update); |
|
354 | - } |
|
355 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
356 | - return $espresso_db_update; |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
363 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
364 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
365 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
366 | - * so that it will be done when migrations are finished |
|
367 | - * |
|
368 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
369 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
370 | - * This is a resource-intensive job |
|
371 | - * so we prefer to only do it when necessary |
|
372 | - * @return void |
|
373 | - */ |
|
374 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
375 | - { |
|
376 | - $request_type = $this->detect_req_type(); |
|
377 | - //only initialize system if we're not in maintenance mode. |
|
378 | - if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
379 | - update_option('ee_flush_rewrite_rules', true); |
|
380 | - if ($verify_schema) { |
|
381 | - EEH_Activation::initialize_db_and_folders(); |
|
382 | - } |
|
383 | - EEH_Activation::initialize_db_content(); |
|
384 | - EEH_Activation::system_initialization(); |
|
385 | - if ($initialize_addons_too) { |
|
386 | - $this->initialize_addons(); |
|
387 | - } |
|
388 | - } else { |
|
389 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
390 | - } |
|
391 | - if ($request_type === EE_System::req_type_new_activation |
|
392 | - || $request_type === EE_System::req_type_reactivation |
|
393 | - || ( |
|
394 | - $request_type === EE_System::req_type_upgrade |
|
395 | - && $this->is_major_version_change() |
|
396 | - ) |
|
397 | - ) { |
|
398 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * Initializes the db for all registered addons |
|
406 | - */ |
|
407 | - public function initialize_addons() |
|
408 | - { |
|
409 | - //foreach registered addon, make sure its db is up-to-date too |
|
410 | - foreach ($this->registry->addons as $addon) { |
|
411 | - $addon->initialize_db_if_no_migrations_required(); |
|
412 | - } |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - |
|
417 | - /** |
|
418 | - * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
419 | - * |
|
420 | - * @param array $version_history |
|
421 | - * @param string $current_version_to_add version to be added to the version history |
|
422 | - * @return boolean success as to whether or not this option was changed |
|
423 | - */ |
|
424 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
425 | - { |
|
426 | - if ( ! $version_history) { |
|
427 | - $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
428 | - } |
|
429 | - if ($current_version_to_add == null) { |
|
430 | - $current_version_to_add = espresso_version(); |
|
431 | - } |
|
432 | - $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
433 | - // re-save |
|
434 | - return update_option('espresso_db_update', $version_history); |
|
435 | - } |
|
436 | - |
|
437 | - |
|
438 | - |
|
439 | - /** |
|
440 | - * Detects if the current version indicated in the has existed in the list of |
|
441 | - * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
442 | - * |
|
443 | - * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
444 | - * If not supplied, fetches it from the options table. |
|
445 | - * Also, caches its result so later parts of the code can also know whether |
|
446 | - * there's been an update or not. This way we can add the current version to |
|
447 | - * espresso_db_update, but still know if this is a new install or not |
|
448 | - * @return int one of the constants on EE_System::req_type_ |
|
449 | - */ |
|
450 | - public function detect_req_type($espresso_db_update = null) |
|
451 | - { |
|
452 | - if ($this->_req_type === null) { |
|
453 | - $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
454 | - : $this->fix_espresso_db_upgrade_option(); |
|
455 | - $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
456 | - 'ee_espresso_activation', espresso_version()); |
|
457 | - $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
458 | - } |
|
459 | - return $this->_req_type; |
|
460 | - } |
|
461 | - |
|
462 | - |
|
463 | - |
|
464 | - /** |
|
465 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
466 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
467 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
468 | - * |
|
469 | - * @param $activation_history |
|
470 | - * @return bool |
|
471 | - */ |
|
472 | - protected function _detect_major_version_change($activation_history) |
|
473 | - { |
|
474 | - $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
475 | - $previous_version_parts = explode('.', $previous_version); |
|
476 | - $current_version_parts = explode('.', espresso_version()); |
|
477 | - return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
478 | - && ($previous_version_parts[0] !== $current_version_parts[0] |
|
479 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
480 | - ); |
|
481 | - } |
|
482 | - |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * Returns true if either the major or minor version of EE changed during this request. |
|
487 | - * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
488 | - * |
|
489 | - * @return bool |
|
490 | - */ |
|
491 | - public function is_major_version_change() |
|
492 | - { |
|
493 | - return $this->_major_version_change; |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - |
|
498 | - /** |
|
499 | - * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
500 | - * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
501 | - * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
502 | - * just activated to (for core that will always be espresso_version()) |
|
503 | - * |
|
504 | - * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
505 | - * ee plugin. for core that's 'espresso_db_update' |
|
506 | - * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
507 | - * indicate that this plugin was just activated |
|
508 | - * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
509 | - * espresso_version()) |
|
510 | - * @return int one of the constants on EE_System::req_type_* |
|
511 | - */ |
|
512 | - public static function detect_req_type_given_activation_history( |
|
513 | - $activation_history_for_addon, |
|
514 | - $activation_indicator_option_name, |
|
515 | - $version_to_upgrade_to |
|
516 | - ) { |
|
517 | - $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
518 | - if ($activation_history_for_addon) { |
|
519 | - //it exists, so this isn't a completely new install |
|
520 | - //check if this version already in that list of previously installed versions |
|
521 | - if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
522 | - //it a version we haven't seen before |
|
523 | - if ($version_is_higher === 1) { |
|
524 | - $req_type = EE_System::req_type_upgrade; |
|
525 | - } else { |
|
526 | - $req_type = EE_System::req_type_downgrade; |
|
527 | - } |
|
528 | - delete_option($activation_indicator_option_name); |
|
529 | - } else { |
|
530 | - // its not an update. maybe a reactivation? |
|
531 | - if (get_option($activation_indicator_option_name, false)) { |
|
532 | - if ($version_is_higher === -1) { |
|
533 | - $req_type = EE_System::req_type_downgrade; |
|
534 | - } elseif ($version_is_higher === 0) { |
|
535 | - //we've seen this version before, but it's an activation. must be a reactivation |
|
536 | - $req_type = EE_System::req_type_reactivation; |
|
537 | - } else {//$version_is_higher === 1 |
|
538 | - $req_type = EE_System::req_type_upgrade; |
|
539 | - } |
|
540 | - delete_option($activation_indicator_option_name); |
|
541 | - } else { |
|
542 | - //we've seen this version before and the activation indicate doesn't show it was just activated |
|
543 | - if ($version_is_higher === -1) { |
|
544 | - $req_type = EE_System::req_type_downgrade; |
|
545 | - } elseif ($version_is_higher === 0) { |
|
546 | - //we've seen this version before and it's not an activation. its normal request |
|
547 | - $req_type = EE_System::req_type_normal; |
|
548 | - } else {//$version_is_higher === 1 |
|
549 | - $req_type = EE_System::req_type_upgrade; |
|
550 | - } |
|
551 | - } |
|
552 | - } |
|
553 | - } else { |
|
554 | - //brand new install |
|
555 | - $req_type = EE_System::req_type_new_activation; |
|
556 | - delete_option($activation_indicator_option_name); |
|
557 | - } |
|
558 | - return $req_type; |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - |
|
563 | - /** |
|
564 | - * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
565 | - * the $activation_history_for_addon |
|
566 | - * |
|
567 | - * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
568 | - * sometimes containing 'unknown-date' |
|
569 | - * @param string $version_to_upgrade_to (current version) |
|
570 | - * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
571 | - * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
572 | - * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
573 | - * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
574 | - */ |
|
575 | - protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
576 | - { |
|
577 | - //find the most recently-activated version |
|
578 | - $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
579 | - return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
580 | - } |
|
581 | - |
|
582 | - |
|
583 | - |
|
584 | - /** |
|
585 | - * Gets the most recently active version listed in the activation history, |
|
586 | - * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
587 | - * |
|
588 | - * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
589 | - * sometimes containing 'unknown-date' |
|
590 | - * @return string |
|
591 | - */ |
|
592 | - protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
593 | - { |
|
594 | - $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
595 | - $most_recently_active_version = '0.0.0.dev.000'; |
|
596 | - if (is_array($activation_history)) { |
|
597 | - foreach ($activation_history as $version => $times_activated) { |
|
598 | - //check there is a record of when this version was activated. Otherwise, |
|
599 | - //mark it as unknown |
|
600 | - if ( ! $times_activated) { |
|
601 | - $times_activated = array('unknown-date'); |
|
602 | - } |
|
603 | - if (is_string($times_activated)) { |
|
604 | - $times_activated = array($times_activated); |
|
605 | - } |
|
606 | - foreach ($times_activated as $an_activation) { |
|
607 | - if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
608 | - $most_recently_active_version = $version; |
|
609 | - $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
610 | - ? '1970-01-01 00:00:00' : $an_activation; |
|
611 | - } |
|
612 | - } |
|
613 | - } |
|
614 | - } |
|
615 | - return $most_recently_active_version; |
|
616 | - } |
|
617 | - |
|
618 | - |
|
619 | - |
|
620 | - /** |
|
621 | - * This redirects to the about EE page after activation |
|
622 | - * |
|
623 | - * @return void |
|
624 | - */ |
|
625 | - public function redirect_to_about_ee() |
|
626 | - { |
|
627 | - $notices = EE_Error::get_notices(false); |
|
628 | - //if current user is an admin and it's not an ajax or rest request |
|
629 | - if ( |
|
630 | - ! (defined('DOING_AJAX') && DOING_AJAX) |
|
631 | - && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
632 | - && ! isset($notices['errors']) |
|
633 | - && apply_filters( |
|
634 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
635 | - $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
636 | - ) |
|
637 | - ) { |
|
638 | - $query_params = array('page' => 'espresso_about'); |
|
639 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
640 | - $query_params['new_activation'] = true; |
|
641 | - } |
|
642 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
643 | - $query_params['reactivation'] = true; |
|
644 | - } |
|
645 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
646 | - wp_safe_redirect($url); |
|
647 | - exit(); |
|
648 | - } |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - |
|
653 | - /** |
|
654 | - * load_core_configuration |
|
655 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
656 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
657 | - * |
|
658 | - * @return void |
|
659 | - */ |
|
660 | - public function load_core_configuration() |
|
661 | - { |
|
662 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
663 | - $this->registry->load_core('EE_Load_Textdomain'); |
|
664 | - //load textdomain |
|
665 | - EE_Load_Textdomain::load_textdomain(); |
|
666 | - // load and setup EE_Config and EE_Network_Config |
|
667 | - $this->registry->load_core('Config'); |
|
668 | - $this->registry->load_core('Network_Config'); |
|
669 | - // setup autoloaders |
|
670 | - // enable logging? |
|
671 | - if ($this->registry->CFG->admin->use_full_logging) { |
|
672 | - $this->registry->load_core('Log'); |
|
673 | - } |
|
674 | - // check for activation errors |
|
675 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
676 | - if ($activation_errors) { |
|
677 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
678 | - update_option('ee_plugin_activation_errors', false); |
|
679 | - } |
|
680 | - // get model names |
|
681 | - $this->_parse_model_names(); |
|
682 | - //load caf stuff a chance to play during the activation process too. |
|
683 | - $this->_maybe_brew_regular(); |
|
684 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
685 | - } |
|
686 | - |
|
687 | - |
|
688 | - |
|
689 | - /** |
|
690 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
691 | - * |
|
692 | - * @return void |
|
693 | - */ |
|
694 | - private function _parse_model_names() |
|
695 | - { |
|
696 | - //get all the files in the EE_MODELS folder that end in .model.php |
|
697 | - $models = glob(EE_MODELS . '*.model.php'); |
|
698 | - $model_names = array(); |
|
699 | - $non_abstract_db_models = array(); |
|
700 | - foreach ($models as $model) { |
|
701 | - // get model classname |
|
702 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
703 | - $short_name = str_replace('EEM_', '', $classname); |
|
704 | - $reflectionClass = new ReflectionClass($classname); |
|
705 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
706 | - $non_abstract_db_models[$short_name] = $classname; |
|
707 | - } |
|
708 | - $model_names[$short_name] = $classname; |
|
709 | - } |
|
710 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
711 | - $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', |
|
712 | - $non_abstract_db_models); |
|
713 | - } |
|
714 | - |
|
715 | - |
|
716 | - |
|
717 | - /** |
|
718 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
719 | - * that need to be setup before our EE_System launches. |
|
720 | - * |
|
721 | - * @return void |
|
722 | - */ |
|
723 | - private function _maybe_brew_regular() |
|
724 | - { |
|
725 | - if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
726 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
727 | - } |
|
728 | - } |
|
729 | - |
|
730 | - |
|
731 | - |
|
732 | - /** |
|
733 | - * register_shortcodes_modules_and_widgets |
|
734 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
735 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
736 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
737 | - * |
|
738 | - * @access public |
|
739 | - * @return void |
|
740 | - */ |
|
741 | - public function register_shortcodes_modules_and_widgets() |
|
742 | - { |
|
743 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
744 | - // check for addons using old hookpoint |
|
745 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
746 | - $this->_incompatible_addon_error(); |
|
747 | - } |
|
748 | - } |
|
749 | - |
|
750 | - |
|
751 | - |
|
752 | - /** |
|
753 | - * _incompatible_addon_error |
|
754 | - * |
|
755 | - * @access public |
|
756 | - * @return void |
|
757 | - */ |
|
758 | - private function _incompatible_addon_error() |
|
759 | - { |
|
760 | - // get array of classes hooking into here |
|
761 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
762 | - if ( ! empty($class_names)) { |
|
763 | - $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
764 | - 'event_espresso'); |
|
765 | - $msg .= '<ul>'; |
|
766 | - foreach ($class_names as $class_name) { |
|
767 | - $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
768 | - $class_name) . '</b></li>'; |
|
769 | - } |
|
770 | - $msg .= '</ul>'; |
|
771 | - $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
772 | - 'event_espresso'); |
|
773 | - // save list of incompatible addons to wp-options for later use |
|
774 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
775 | - if (is_admin()) { |
|
776 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
777 | - } |
|
778 | - } |
|
779 | - } |
|
780 | - |
|
781 | - |
|
782 | - |
|
783 | - /** |
|
784 | - * brew_espresso |
|
785 | - * begins the process of setting hooks for initializing EE in the correct order |
|
786 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
787 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
788 | - * |
|
789 | - * @return void |
|
790 | - */ |
|
791 | - public function brew_espresso() |
|
792 | - { |
|
793 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
794 | - // load some final core systems |
|
795 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
796 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
797 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
798 | - add_action('init', array($this, 'load_controllers'), 7); |
|
799 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
800 | - add_action('init', array($this, 'initialize'), 10); |
|
801 | - add_action('init', array($this, 'initialize_last'), 100); |
|
802 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
803 | - add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
804 | - add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
805 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
806 | - // pew pew pew |
|
807 | - $this->registry->load_core('PUE'); |
|
808 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
809 | - } |
|
810 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
811 | - } |
|
812 | - |
|
813 | - |
|
814 | - |
|
815 | - /** |
|
816 | - * set_hooks_for_core |
|
817 | - * |
|
818 | - * @access public |
|
819 | - * @return void |
|
820 | - */ |
|
821 | - public function set_hooks_for_core() |
|
822 | - { |
|
823 | - $this->_deactivate_incompatible_addons(); |
|
824 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
825 | - } |
|
826 | - |
|
827 | - |
|
828 | - |
|
829 | - /** |
|
830 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
831 | - * deactivates any addons considered incompatible with the current version of EE |
|
832 | - */ |
|
833 | - private function _deactivate_incompatible_addons() |
|
834 | - { |
|
835 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
836 | - if ( ! empty($incompatible_addons)) { |
|
837 | - $active_plugins = get_option('active_plugins', array()); |
|
838 | - foreach ($active_plugins as $active_plugin) { |
|
839 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
840 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
841 | - unset($_GET['activate']); |
|
842 | - espresso_deactivate_plugin($active_plugin); |
|
843 | - } |
|
844 | - } |
|
845 | - } |
|
846 | - } |
|
847 | - } |
|
848 | - |
|
849 | - |
|
850 | - |
|
851 | - /** |
|
852 | - * perform_activations_upgrades_and_migrations |
|
853 | - * |
|
854 | - * @access public |
|
855 | - * @return void |
|
856 | - */ |
|
857 | - public function perform_activations_upgrades_and_migrations() |
|
858 | - { |
|
859 | - //first check if we had previously attempted to setup EE's directories but failed |
|
860 | - if (EEH_Activation::upload_directories_incomplete()) { |
|
861 | - EEH_Activation::create_upload_directories(); |
|
862 | - } |
|
863 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
864 | - } |
|
865 | - |
|
866 | - |
|
867 | - |
|
868 | - /** |
|
869 | - * load_CPTs_and_session |
|
870 | - * |
|
871 | - * @access public |
|
872 | - * @return void |
|
873 | - */ |
|
874 | - public function load_CPTs_and_session() |
|
875 | - { |
|
876 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
877 | - // register Custom Post Types |
|
878 | - $this->registry->load_core('Register_CPTs'); |
|
879 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
880 | - } |
|
881 | - |
|
882 | - |
|
883 | - |
|
884 | - /** |
|
885 | - * load_controllers |
|
886 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
887 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
888 | - * time |
|
889 | - * |
|
890 | - * @access public |
|
891 | - * @return void |
|
892 | - */ |
|
893 | - public function load_controllers() |
|
894 | - { |
|
895 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
896 | - // let's get it started |
|
897 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
898 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
899 | - $this->registry->load_core('Front_Controller', array(), false, true); |
|
900 | - } else if ( ! EE_FRONT_AJAX) { |
|
901 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
902 | - EE_Registry::instance()->load_core('Admin'); |
|
903 | - } |
|
904 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
905 | - } |
|
906 | - |
|
907 | - |
|
908 | - |
|
909 | - /** |
|
910 | - * core_loaded_and_ready |
|
911 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
912 | - * |
|
913 | - * @access public |
|
914 | - * @return void |
|
915 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
916 | - */ |
|
917 | - public function core_loaded_and_ready() |
|
918 | - { |
|
919 | - new AutomatedActionManager( |
|
920 | - new AutomatedActionFactory( |
|
921 | - new CronManager(), |
|
922 | - new RuleManager( |
|
923 | - new QueryParamGenerator() |
|
924 | - ) |
|
925 | - ), |
|
926 | - new CapabilitiesChecker( |
|
927 | - $this->registry->CAP |
|
928 | - ) |
|
929 | - ); |
|
930 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
931 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
932 | - $this->registry->load_core('Session'); |
|
933 | - // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
|
934 | - } |
|
935 | - |
|
936 | - |
|
937 | - |
|
938 | - /** |
|
939 | - * initialize |
|
940 | - * this is the best place to begin initializing client code |
|
941 | - * |
|
942 | - * @access public |
|
943 | - * @return void |
|
944 | - */ |
|
945 | - public function initialize() |
|
946 | - { |
|
947 | - do_action('AHEE__EE_System__initialize'); |
|
948 | - } |
|
949 | - |
|
950 | - |
|
951 | - |
|
952 | - /** |
|
953 | - * initialize_last |
|
954 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
955 | - * initialize has done so |
|
956 | - * |
|
957 | - * @access public |
|
958 | - * @return void |
|
959 | - */ |
|
960 | - public function initialize_last() |
|
961 | - { |
|
962 | - do_action('AHEE__EE_System__initialize_last'); |
|
963 | - } |
|
964 | - |
|
965 | - |
|
966 | - |
|
967 | - /** |
|
968 | - * set_hooks_for_shortcodes_modules_and_addons |
|
969 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
970 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
971 | - * |
|
972 | - * @access public |
|
973 | - * @return void |
|
974 | - */ |
|
975 | - public function set_hooks_for_shortcodes_modules_and_addons() |
|
976 | - { |
|
977 | - // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
978 | - } |
|
979 | - |
|
980 | - |
|
981 | - |
|
982 | - /** |
|
983 | - * do_not_cache |
|
984 | - * sets no cache headers and defines no cache constants for WP plugins |
|
985 | - * |
|
986 | - * @access public |
|
987 | - * @return void |
|
988 | - */ |
|
989 | - public static function do_not_cache() |
|
990 | - { |
|
991 | - // set no cache constants |
|
992 | - if ( ! defined('DONOTCACHEPAGE')) { |
|
993 | - define('DONOTCACHEPAGE', true); |
|
994 | - } |
|
995 | - if ( ! defined('DONOTCACHCEOBJECT')) { |
|
996 | - define('DONOTCACHCEOBJECT', true); |
|
997 | - } |
|
998 | - if ( ! defined('DONOTCACHEDB')) { |
|
999 | - define('DONOTCACHEDB', true); |
|
1000 | - } |
|
1001 | - // add no cache headers |
|
1002 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
1003 | - // plus a little extra for nginx and Google Chrome |
|
1004 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1005 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1006 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1007 | - } |
|
1008 | - |
|
1009 | - |
|
1010 | - |
|
1011 | - /** |
|
1012 | - * extra_nocache_headers |
|
1013 | - * |
|
1014 | - * @access public |
|
1015 | - * @param $headers |
|
1016 | - * @return array |
|
1017 | - */ |
|
1018 | - public static function extra_nocache_headers($headers) |
|
1019 | - { |
|
1020 | - // for NGINX |
|
1021 | - $headers['X-Accel-Expires'] = 0; |
|
1022 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1023 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1024 | - return $headers; |
|
1025 | - } |
|
1026 | - |
|
1027 | - |
|
1028 | - |
|
1029 | - /** |
|
1030 | - * nocache_headers |
|
1031 | - * |
|
1032 | - * @access public |
|
1033 | - * @return void |
|
1034 | - */ |
|
1035 | - public static function nocache_headers() |
|
1036 | - { |
|
1037 | - nocache_headers(); |
|
1038 | - } |
|
1039 | - |
|
1040 | - |
|
1041 | - |
|
1042 | - /** |
|
1043 | - * espresso_toolbar_items |
|
1044 | - * |
|
1045 | - * @access public |
|
1046 | - * @param WP_Admin_Bar $admin_bar |
|
1047 | - * @return void |
|
1048 | - */ |
|
1049 | - public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1050 | - { |
|
1051 | - // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1052 | - if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1053 | - || defined('DOING_AJAX') |
|
1054 | - || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1055 | - ) { |
|
1056 | - return; |
|
1057 | - } |
|
1058 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1059 | - $menu_class = 'espresso_menu_item_class'; |
|
1060 | - //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1061 | - //because they're only defined in each of their respective constructors |
|
1062 | - //and this might be a frontend request, in which case they aren't available |
|
1063 | - $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1064 | - $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1065 | - $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1066 | - //Top Level |
|
1067 | - $admin_bar->add_menu(array( |
|
1068 | - 'id' => 'espresso-toolbar', |
|
1069 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1070 | - . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1071 | - . '</span>', |
|
1072 | - 'href' => $events_admin_url, |
|
1073 | - 'meta' => array( |
|
1074 | - 'title' => __('Event Espresso', 'event_espresso'), |
|
1075 | - 'class' => $menu_class . 'first', |
|
1076 | - ), |
|
1077 | - )); |
|
1078 | - //Events |
|
1079 | - if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
1080 | - $admin_bar->add_menu(array( |
|
1081 | - 'id' => 'espresso-toolbar-events', |
|
1082 | - 'parent' => 'espresso-toolbar', |
|
1083 | - 'title' => __('Events', 'event_espresso'), |
|
1084 | - 'href' => $events_admin_url, |
|
1085 | - 'meta' => array( |
|
1086 | - 'title' => __('Events', 'event_espresso'), |
|
1087 | - 'target' => '', |
|
1088 | - 'class' => $menu_class, |
|
1089 | - ), |
|
1090 | - )); |
|
1091 | - } |
|
1092 | - if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
1093 | - //Events Add New |
|
1094 | - $admin_bar->add_menu(array( |
|
1095 | - 'id' => 'espresso-toolbar-events-new', |
|
1096 | - 'parent' => 'espresso-toolbar-events', |
|
1097 | - 'title' => __('Add New', 'event_espresso'), |
|
1098 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1099 | - 'meta' => array( |
|
1100 | - 'title' => __('Add New', 'event_espresso'), |
|
1101 | - 'target' => '', |
|
1102 | - 'class' => $menu_class, |
|
1103 | - ), |
|
1104 | - )); |
|
1105 | - } |
|
1106 | - if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1107 | - //Current post |
|
1108 | - global $post; |
|
1109 | - if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1110 | - 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1111 | - ) { |
|
1112 | - //Events Edit Current Event |
|
1113 | - $admin_bar->add_menu(array( |
|
1114 | - 'id' => 'espresso-toolbar-events-edit', |
|
1115 | - 'parent' => 'espresso-toolbar-events', |
|
1116 | - 'title' => __('Edit Event', 'event_espresso'), |
|
1117 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1118 | - $events_admin_url), |
|
1119 | - 'meta' => array( |
|
1120 | - 'title' => __('Edit Event', 'event_espresso'), |
|
1121 | - 'target' => '', |
|
1122 | - 'class' => $menu_class, |
|
1123 | - ), |
|
1124 | - )); |
|
1125 | - } |
|
1126 | - } |
|
1127 | - //Events View |
|
1128 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1129 | - 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1130 | - ) { |
|
1131 | - $admin_bar->add_menu(array( |
|
1132 | - 'id' => 'espresso-toolbar-events-view', |
|
1133 | - 'parent' => 'espresso-toolbar-events', |
|
1134 | - 'title' => __('View', 'event_espresso'), |
|
1135 | - 'href' => $events_admin_url, |
|
1136 | - 'meta' => array( |
|
1137 | - 'title' => __('View', 'event_espresso'), |
|
1138 | - 'target' => '', |
|
1139 | - 'class' => $menu_class, |
|
1140 | - ), |
|
1141 | - )); |
|
1142 | - } |
|
1143 | - if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1144 | - //Events View All |
|
1145 | - $admin_bar->add_menu(array( |
|
1146 | - 'id' => 'espresso-toolbar-events-all', |
|
1147 | - 'parent' => 'espresso-toolbar-events-view', |
|
1148 | - 'title' => __('All', 'event_espresso'), |
|
1149 | - 'href' => $events_admin_url, |
|
1150 | - 'meta' => array( |
|
1151 | - 'title' => __('All', 'event_espresso'), |
|
1152 | - 'target' => '', |
|
1153 | - 'class' => $menu_class, |
|
1154 | - ), |
|
1155 | - )); |
|
1156 | - } |
|
1157 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1158 | - 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1159 | - ) { |
|
1160 | - //Events View Today |
|
1161 | - $admin_bar->add_menu(array( |
|
1162 | - 'id' => 'espresso-toolbar-events-today', |
|
1163 | - 'parent' => 'espresso-toolbar-events-view', |
|
1164 | - 'title' => __('Today', 'event_espresso'), |
|
1165 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1166 | - $events_admin_url), |
|
1167 | - 'meta' => array( |
|
1168 | - 'title' => __('Today', 'event_espresso'), |
|
1169 | - 'target' => '', |
|
1170 | - 'class' => $menu_class, |
|
1171 | - ), |
|
1172 | - )); |
|
1173 | - } |
|
1174 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1175 | - 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1176 | - ) { |
|
1177 | - //Events View This Month |
|
1178 | - $admin_bar->add_menu(array( |
|
1179 | - 'id' => 'espresso-toolbar-events-month', |
|
1180 | - 'parent' => 'espresso-toolbar-events-view', |
|
1181 | - 'title' => __('This Month', 'event_espresso'), |
|
1182 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1183 | - $events_admin_url), |
|
1184 | - 'meta' => array( |
|
1185 | - 'title' => __('This Month', 'event_espresso'), |
|
1186 | - 'target' => '', |
|
1187 | - 'class' => $menu_class, |
|
1188 | - ), |
|
1189 | - )); |
|
1190 | - } |
|
1191 | - //Registration Overview |
|
1192 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1193 | - 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1194 | - ) { |
|
1195 | - $admin_bar->add_menu(array( |
|
1196 | - 'id' => 'espresso-toolbar-registrations', |
|
1197 | - 'parent' => 'espresso-toolbar', |
|
1198 | - 'title' => __('Registrations', 'event_espresso'), |
|
1199 | - 'href' => $reg_admin_url, |
|
1200 | - 'meta' => array( |
|
1201 | - 'title' => __('Registrations', 'event_espresso'), |
|
1202 | - 'target' => '', |
|
1203 | - 'class' => $menu_class, |
|
1204 | - ), |
|
1205 | - )); |
|
1206 | - } |
|
1207 | - //Registration Overview Today |
|
1208 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1209 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1210 | - ) { |
|
1211 | - $admin_bar->add_menu(array( |
|
1212 | - 'id' => 'espresso-toolbar-registrations-today', |
|
1213 | - 'parent' => 'espresso-toolbar-registrations', |
|
1214 | - 'title' => __('Today', 'event_espresso'), |
|
1215 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1216 | - $reg_admin_url), |
|
1217 | - 'meta' => array( |
|
1218 | - 'title' => __('Today', 'event_espresso'), |
|
1219 | - 'target' => '', |
|
1220 | - 'class' => $menu_class, |
|
1221 | - ), |
|
1222 | - )); |
|
1223 | - } |
|
1224 | - //Registration Overview Today Completed |
|
1225 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1226 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1227 | - ) { |
|
1228 | - $admin_bar->add_menu(array( |
|
1229 | - 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1230 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1231 | - 'title' => __('Approved', 'event_espresso'), |
|
1232 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1233 | - 'action' => 'default', |
|
1234 | - 'status' => 'today', |
|
1235 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1236 | - ), $reg_admin_url), |
|
1237 | - 'meta' => array( |
|
1238 | - 'title' => __('Approved', 'event_espresso'), |
|
1239 | - 'target' => '', |
|
1240 | - 'class' => $menu_class, |
|
1241 | - ), |
|
1242 | - )); |
|
1243 | - } |
|
1244 | - //Registration Overview Today Pending\ |
|
1245 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1246 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1247 | - ) { |
|
1248 | - $admin_bar->add_menu(array( |
|
1249 | - 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1250 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1251 | - 'title' => __('Pending', 'event_espresso'), |
|
1252 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1253 | - 'action' => 'default', |
|
1254 | - 'status' => 'today', |
|
1255 | - 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1256 | - ), $reg_admin_url), |
|
1257 | - 'meta' => array( |
|
1258 | - 'title' => __('Pending Payment', 'event_espresso'), |
|
1259 | - 'target' => '', |
|
1260 | - 'class' => $menu_class, |
|
1261 | - ), |
|
1262 | - )); |
|
1263 | - } |
|
1264 | - //Registration Overview Today Incomplete |
|
1265 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1266 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1267 | - ) { |
|
1268 | - $admin_bar->add_menu(array( |
|
1269 | - 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1270 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1271 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1272 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1273 | - 'action' => 'default', |
|
1274 | - 'status' => 'today', |
|
1275 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1276 | - ), $reg_admin_url), |
|
1277 | - 'meta' => array( |
|
1278 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1279 | - 'target' => '', |
|
1280 | - 'class' => $menu_class, |
|
1281 | - ), |
|
1282 | - )); |
|
1283 | - } |
|
1284 | - //Registration Overview Today Incomplete |
|
1285 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1286 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1287 | - ) { |
|
1288 | - $admin_bar->add_menu(array( |
|
1289 | - 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1290 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1291 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1292 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1293 | - 'action' => 'default', |
|
1294 | - 'status' => 'today', |
|
1295 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1296 | - ), $reg_admin_url), |
|
1297 | - 'meta' => array( |
|
1298 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1299 | - 'target' => '', |
|
1300 | - 'class' => $menu_class, |
|
1301 | - ), |
|
1302 | - )); |
|
1303 | - } |
|
1304 | - //Registration Overview This Month |
|
1305 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1306 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1307 | - ) { |
|
1308 | - $admin_bar->add_menu(array( |
|
1309 | - 'id' => 'espresso-toolbar-registrations-month', |
|
1310 | - 'parent' => 'espresso-toolbar-registrations', |
|
1311 | - 'title' => __('This Month', 'event_espresso'), |
|
1312 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1313 | - $reg_admin_url), |
|
1314 | - 'meta' => array( |
|
1315 | - 'title' => __('This Month', 'event_espresso'), |
|
1316 | - 'target' => '', |
|
1317 | - 'class' => $menu_class, |
|
1318 | - ), |
|
1319 | - )); |
|
1320 | - } |
|
1321 | - //Registration Overview This Month Approved |
|
1322 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1323 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1324 | - ) { |
|
1325 | - $admin_bar->add_menu(array( |
|
1326 | - 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1327 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1328 | - 'title' => __('Approved', 'event_espresso'), |
|
1329 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1330 | - 'action' => 'default', |
|
1331 | - 'status' => 'month', |
|
1332 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1333 | - ), $reg_admin_url), |
|
1334 | - 'meta' => array( |
|
1335 | - 'title' => __('Approved', 'event_espresso'), |
|
1336 | - 'target' => '', |
|
1337 | - 'class' => $menu_class, |
|
1338 | - ), |
|
1339 | - )); |
|
1340 | - } |
|
1341 | - //Registration Overview This Month Pending |
|
1342 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1343 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1344 | - ) { |
|
1345 | - $admin_bar->add_menu(array( |
|
1346 | - 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1347 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1348 | - 'title' => __('Pending', 'event_espresso'), |
|
1349 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1350 | - 'action' => 'default', |
|
1351 | - 'status' => 'month', |
|
1352 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1353 | - ), $reg_admin_url), |
|
1354 | - 'meta' => array( |
|
1355 | - 'title' => __('Pending', 'event_espresso'), |
|
1356 | - 'target' => '', |
|
1357 | - 'class' => $menu_class, |
|
1358 | - ), |
|
1359 | - )); |
|
1360 | - } |
|
1361 | - //Registration Overview This Month Not Approved |
|
1362 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1363 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1364 | - ) { |
|
1365 | - $admin_bar->add_menu(array( |
|
1366 | - 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1367 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1368 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1369 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1370 | - 'action' => 'default', |
|
1371 | - 'status' => 'month', |
|
1372 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1373 | - ), $reg_admin_url), |
|
1374 | - 'meta' => array( |
|
1375 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1376 | - 'target' => '', |
|
1377 | - 'class' => $menu_class, |
|
1378 | - ), |
|
1379 | - )); |
|
1380 | - } |
|
1381 | - //Registration Overview This Month Cancelled |
|
1382 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1383 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1384 | - ) { |
|
1385 | - $admin_bar->add_menu(array( |
|
1386 | - 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1387 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1388 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1389 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1390 | - 'action' => 'default', |
|
1391 | - 'status' => 'month', |
|
1392 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1393 | - ), $reg_admin_url), |
|
1394 | - 'meta' => array( |
|
1395 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1396 | - 'target' => '', |
|
1397 | - 'class' => $menu_class, |
|
1398 | - ), |
|
1399 | - )); |
|
1400 | - } |
|
1401 | - //Extensions & Services |
|
1402 | - if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1403 | - 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1404 | - ) { |
|
1405 | - $admin_bar->add_menu(array( |
|
1406 | - 'id' => 'espresso-toolbar-extensions-and-services', |
|
1407 | - 'parent' => 'espresso-toolbar', |
|
1408 | - 'title' => __('Extensions & Services', 'event_espresso'), |
|
1409 | - 'href' => $extensions_admin_url, |
|
1410 | - 'meta' => array( |
|
1411 | - 'title' => __('Extensions & Services', 'event_espresso'), |
|
1412 | - 'target' => '', |
|
1413 | - 'class' => $menu_class, |
|
1414 | - ), |
|
1415 | - )); |
|
1416 | - } |
|
1417 | - } |
|
1418 | - |
|
1419 | - |
|
1420 | - |
|
1421 | - /** |
|
1422 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1423 | - * never returned with the function. |
|
1424 | - * |
|
1425 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
1426 | - * @return array |
|
1427 | - */ |
|
1428 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
1429 | - { |
|
1430 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1431 | - } |
|
1432 | - |
|
1433 | - |
|
1434 | - |
|
1435 | - |
|
1436 | - |
|
1437 | - |
|
1438 | - /*********************************************** WP_ENQUEUE_SCRIPTS HOOK ***********************************************/ |
|
1439 | - /** |
|
1440 | - * wp_enqueue_scripts |
|
1441 | - * |
|
1442 | - * @access public |
|
1443 | - * @return void |
|
1444 | - */ |
|
1445 | - public function wp_enqueue_scripts() |
|
1446 | - { |
|
1447 | - // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
|
1448 | - if (apply_filters('FHEE_load_EE_System_scripts', true)) { |
|
1449 | - // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1450 | - if (apply_filters('FHEE_load_jquery_validate', false)) { |
|
1451 | - // register jQuery Validate and additional methods |
|
1452 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1453 | - array('jquery'), '1.15.0', true); |
|
1454 | - wp_register_script('jquery-validate-extra-methods', |
|
1455 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1456 | - array('jquery', 'jquery-validate'), '1.15.0', true); |
|
1457 | - } |
|
1458 | - } |
|
1459 | - } |
|
26 | + /** |
|
27 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
28 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
29 | + */ |
|
30 | + const req_type_normal = 0; |
|
31 | + |
|
32 | + /** |
|
33 | + * Indicates this is a brand new installation of EE so we should install |
|
34 | + * tables and default data etc |
|
35 | + */ |
|
36 | + const req_type_new_activation = 1; |
|
37 | + |
|
38 | + /** |
|
39 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
40 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
41 | + * and that default data is setup too |
|
42 | + */ |
|
43 | + const req_type_reactivation = 2; |
|
44 | + |
|
45 | + /** |
|
46 | + * indicates that EE has been upgraded since its previous request. |
|
47 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
48 | + */ |
|
49 | + const req_type_upgrade = 3; |
|
50 | + |
|
51 | + /** |
|
52 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
53 | + */ |
|
54 | + const req_type_downgrade = 4; |
|
55 | + |
|
56 | + /** |
|
57 | + * @deprecated since version 4.6.0.dev.006 |
|
58 | + * Now whenever a new_activation is detected the request type is still just |
|
59 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
60 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
61 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
62 | + * (Specifically, when the migration manager indicates migrations are finished |
|
63 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
64 | + */ |
|
65 | + const req_type_activation_but_not_installed = 5; |
|
66 | + |
|
67 | + /** |
|
68 | + * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
69 | + */ |
|
70 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * instance of the EE_System object |
|
75 | + * |
|
76 | + * @var $_instance |
|
77 | + * @access private |
|
78 | + */ |
|
79 | + private static $_instance = null; |
|
80 | + |
|
81 | + /** |
|
82 | + * @type EE_Registry $Registry |
|
83 | + * @access protected |
|
84 | + */ |
|
85 | + protected $registry; |
|
86 | + |
|
87 | + /** |
|
88 | + * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
89 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
90 | + * |
|
91 | + * @var int |
|
92 | + */ |
|
93 | + private $_req_type; |
|
94 | + |
|
95 | + /** |
|
96 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
97 | + * |
|
98 | + * @var boolean |
|
99 | + */ |
|
100 | + private $_major_version_change = false; |
|
101 | + |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * @singleton method used to instantiate class object |
|
106 | + * @access public |
|
107 | + * @param \EE_Registry $Registry |
|
108 | + * @return \EE_System |
|
109 | + */ |
|
110 | + public static function instance(EE_Registry $Registry = null) |
|
111 | + { |
|
112 | + // check if class object is instantiated |
|
113 | + if ( ! self::$_instance instanceof EE_System) { |
|
114 | + self::$_instance = new self($Registry); |
|
115 | + } |
|
116 | + return self::$_instance; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * resets the instance and returns it |
|
123 | + * |
|
124 | + * @return EE_System |
|
125 | + */ |
|
126 | + public static function reset() |
|
127 | + { |
|
128 | + self::$_instance->_req_type = null; |
|
129 | + //make sure none of the old hooks are left hanging around |
|
130 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
131 | + //we need to reset the migration manager in order for it to detect DMSs properly |
|
132 | + EE_Data_Migration_Manager::reset(); |
|
133 | + self::instance()->detect_activations_or_upgrades(); |
|
134 | + self::instance()->perform_activations_upgrades_and_migrations(); |
|
135 | + return self::instance(); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * sets hooks for running rest of system |
|
142 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
143 | + * starting EE Addons from any other point may lead to problems |
|
144 | + * |
|
145 | + * @access private |
|
146 | + * @param \EE_Registry $Registry |
|
147 | + */ |
|
148 | + private function __construct(EE_Registry $Registry) |
|
149 | + { |
|
150 | + $this->registry = $Registry; |
|
151 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
152 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
153 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
154 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
155 | + // because the newly-activated addon didn't get a chance to run at all |
|
156 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
157 | + // detect whether install or upgrade |
|
158 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
159 | + 3); |
|
160 | + // load EE_Config, EE_Textdomain, etc |
|
161 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
162 | + // load EE_Config, EE_Textdomain, etc |
|
163 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
164 | + array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
165 | + // you wanna get going? I wanna get going... let's get going! |
|
166 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
167 | + //other housekeeping |
|
168 | + //exclude EE critical pages from wp_list_pages |
|
169 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
170 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
171 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
172 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * load_espresso_addons |
|
179 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
180 | + * this is hooked into both: |
|
181 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
182 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
183 | + * and the WP 'activate_plugin' hookpoint |
|
184 | + * |
|
185 | + * @access public |
|
186 | + * @return void |
|
187 | + */ |
|
188 | + public function load_espresso_addons() |
|
189 | + { |
|
190 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
191 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
192 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
193 | + //load and setup EE_Capabilities |
|
194 | + $this->registry->load_core('Capabilities'); |
|
195 | + //caps need to be initialized on every request so that capability maps are set. |
|
196 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
197 | + $this->registry->CAP->init_caps(); |
|
198 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
199 | + //if the WP API basic auth plugin isn't already loaded, load it now. |
|
200 | + //We want it for mobile apps. Just include the entire plugin |
|
201 | + //also, don't load the basic auth when a plugin is getting activated, because |
|
202 | + //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
203 | + //and causes a fatal error |
|
204 | + if ( ! function_exists('json_basic_auth_handler') |
|
205 | + && ! function_exists('json_basic_auth_error') |
|
206 | + && ! ( |
|
207 | + isset($_GET['action']) |
|
208 | + && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
209 | + ) |
|
210 | + && ! ( |
|
211 | + isset($_GET['activate']) |
|
212 | + && $_GET['activate'] === 'true' |
|
213 | + ) |
|
214 | + ) { |
|
215 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
216 | + } |
|
217 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * detect_activations_or_upgrades |
|
224 | + * Checks for activation or upgrade of core first; |
|
225 | + * then also checks if any registered addons have been activated or upgraded |
|
226 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
227 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
228 | + * |
|
229 | + * @access public |
|
230 | + * @return void |
|
231 | + */ |
|
232 | + public function detect_activations_or_upgrades() |
|
233 | + { |
|
234 | + //first off: let's make sure to handle core |
|
235 | + $this->detect_if_activation_or_upgrade(); |
|
236 | + foreach ($this->registry->addons as $addon) { |
|
237 | + //detect teh request type for that addon |
|
238 | + $addon->detect_activation_or_upgrade(); |
|
239 | + } |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * detect_if_activation_or_upgrade |
|
246 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
247 | + * and either setting up the DB or setting up maintenance mode etc. |
|
248 | + * |
|
249 | + * @access public |
|
250 | + * @return void |
|
251 | + */ |
|
252 | + public function detect_if_activation_or_upgrade() |
|
253 | + { |
|
254 | + do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
255 | + // load M-Mode class |
|
256 | + $this->registry->load_core('Maintenance_Mode'); |
|
257 | + // check if db has been updated, or if its a brand-new installation |
|
258 | + $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
259 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
260 | + //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
261 | + switch ($request_type) { |
|
262 | + case EE_System::req_type_new_activation: |
|
263 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
264 | + $this->_handle_core_version_change($espresso_db_update); |
|
265 | + break; |
|
266 | + case EE_System::req_type_reactivation: |
|
267 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
268 | + $this->_handle_core_version_change($espresso_db_update); |
|
269 | + break; |
|
270 | + case EE_System::req_type_upgrade: |
|
271 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
272 | + //migrations may be required now that we've upgraded |
|
273 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
274 | + $this->_handle_core_version_change($espresso_db_update); |
|
275 | + // echo "done upgrade";die; |
|
276 | + break; |
|
277 | + case EE_System::req_type_downgrade: |
|
278 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
279 | + //its possible migrations are no longer required |
|
280 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
281 | + $this->_handle_core_version_change($espresso_db_update); |
|
282 | + break; |
|
283 | + case EE_System::req_type_normal: |
|
284 | + default: |
|
285 | + // $this->_maybe_redirect_to_ee_about(); |
|
286 | + break; |
|
287 | + } |
|
288 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * Updates the list of installed versions and sets hooks for |
|
295 | + * initializing the database later during the request |
|
296 | + * |
|
297 | + * @param array $espresso_db_update |
|
298 | + */ |
|
299 | + protected function _handle_core_version_change($espresso_db_update) |
|
300 | + { |
|
301 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
302 | + //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
303 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
304 | + array($this, 'initialize_db_if_no_migrations_required')); |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
311 | + * information about what versions of EE have been installed and activated, |
|
312 | + * NOT necessarily the state of the database |
|
313 | + * |
|
314 | + * @param null $espresso_db_update |
|
315 | + * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
316 | + * from the options table |
|
317 | + * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
318 | + */ |
|
319 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
320 | + { |
|
321 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
322 | + if ( ! $espresso_db_update) { |
|
323 | + $espresso_db_update = get_option('espresso_db_update'); |
|
324 | + } |
|
325 | + // check that option is an array |
|
326 | + if ( ! is_array($espresso_db_update)) { |
|
327 | + // if option is FALSE, then it never existed |
|
328 | + if ($espresso_db_update === false) { |
|
329 | + // make $espresso_db_update an array and save option with autoload OFF |
|
330 | + $espresso_db_update = array(); |
|
331 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
332 | + } else { |
|
333 | + // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
334 | + $espresso_db_update = array($espresso_db_update => array()); |
|
335 | + update_option('espresso_db_update', $espresso_db_update); |
|
336 | + } |
|
337 | + } else { |
|
338 | + $corrected_db_update = array(); |
|
339 | + //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
340 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
341 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
342 | + //the key is an int, and the value IS NOT an array |
|
343 | + //so it must be numerically-indexed, where values are versions installed... |
|
344 | + //fix it! |
|
345 | + $version_string = $should_be_array; |
|
346 | + $corrected_db_update[$version_string] = array('unknown-date'); |
|
347 | + } else { |
|
348 | + //ok it checks out |
|
349 | + $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
350 | + } |
|
351 | + } |
|
352 | + $espresso_db_update = $corrected_db_update; |
|
353 | + update_option('espresso_db_update', $espresso_db_update); |
|
354 | + } |
|
355 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
356 | + return $espresso_db_update; |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
363 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
364 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
365 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
366 | + * so that it will be done when migrations are finished |
|
367 | + * |
|
368 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
369 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
370 | + * This is a resource-intensive job |
|
371 | + * so we prefer to only do it when necessary |
|
372 | + * @return void |
|
373 | + */ |
|
374 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
375 | + { |
|
376 | + $request_type = $this->detect_req_type(); |
|
377 | + //only initialize system if we're not in maintenance mode. |
|
378 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
379 | + update_option('ee_flush_rewrite_rules', true); |
|
380 | + if ($verify_schema) { |
|
381 | + EEH_Activation::initialize_db_and_folders(); |
|
382 | + } |
|
383 | + EEH_Activation::initialize_db_content(); |
|
384 | + EEH_Activation::system_initialization(); |
|
385 | + if ($initialize_addons_too) { |
|
386 | + $this->initialize_addons(); |
|
387 | + } |
|
388 | + } else { |
|
389 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
390 | + } |
|
391 | + if ($request_type === EE_System::req_type_new_activation |
|
392 | + || $request_type === EE_System::req_type_reactivation |
|
393 | + || ( |
|
394 | + $request_type === EE_System::req_type_upgrade |
|
395 | + && $this->is_major_version_change() |
|
396 | + ) |
|
397 | + ) { |
|
398 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * Initializes the db for all registered addons |
|
406 | + */ |
|
407 | + public function initialize_addons() |
|
408 | + { |
|
409 | + //foreach registered addon, make sure its db is up-to-date too |
|
410 | + foreach ($this->registry->addons as $addon) { |
|
411 | + $addon->initialize_db_if_no_migrations_required(); |
|
412 | + } |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + |
|
417 | + /** |
|
418 | + * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
419 | + * |
|
420 | + * @param array $version_history |
|
421 | + * @param string $current_version_to_add version to be added to the version history |
|
422 | + * @return boolean success as to whether or not this option was changed |
|
423 | + */ |
|
424 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
425 | + { |
|
426 | + if ( ! $version_history) { |
|
427 | + $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
428 | + } |
|
429 | + if ($current_version_to_add == null) { |
|
430 | + $current_version_to_add = espresso_version(); |
|
431 | + } |
|
432 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
433 | + // re-save |
|
434 | + return update_option('espresso_db_update', $version_history); |
|
435 | + } |
|
436 | + |
|
437 | + |
|
438 | + |
|
439 | + /** |
|
440 | + * Detects if the current version indicated in the has existed in the list of |
|
441 | + * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
442 | + * |
|
443 | + * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
444 | + * If not supplied, fetches it from the options table. |
|
445 | + * Also, caches its result so later parts of the code can also know whether |
|
446 | + * there's been an update or not. This way we can add the current version to |
|
447 | + * espresso_db_update, but still know if this is a new install or not |
|
448 | + * @return int one of the constants on EE_System::req_type_ |
|
449 | + */ |
|
450 | + public function detect_req_type($espresso_db_update = null) |
|
451 | + { |
|
452 | + if ($this->_req_type === null) { |
|
453 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
454 | + : $this->fix_espresso_db_upgrade_option(); |
|
455 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
456 | + 'ee_espresso_activation', espresso_version()); |
|
457 | + $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
458 | + } |
|
459 | + return $this->_req_type; |
|
460 | + } |
|
461 | + |
|
462 | + |
|
463 | + |
|
464 | + /** |
|
465 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
466 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
467 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
468 | + * |
|
469 | + * @param $activation_history |
|
470 | + * @return bool |
|
471 | + */ |
|
472 | + protected function _detect_major_version_change($activation_history) |
|
473 | + { |
|
474 | + $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
475 | + $previous_version_parts = explode('.', $previous_version); |
|
476 | + $current_version_parts = explode('.', espresso_version()); |
|
477 | + return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
478 | + && ($previous_version_parts[0] !== $current_version_parts[0] |
|
479 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
480 | + ); |
|
481 | + } |
|
482 | + |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * Returns true if either the major or minor version of EE changed during this request. |
|
487 | + * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
488 | + * |
|
489 | + * @return bool |
|
490 | + */ |
|
491 | + public function is_major_version_change() |
|
492 | + { |
|
493 | + return $this->_major_version_change; |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + |
|
498 | + /** |
|
499 | + * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
500 | + * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
501 | + * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
502 | + * just activated to (for core that will always be espresso_version()) |
|
503 | + * |
|
504 | + * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
505 | + * ee plugin. for core that's 'espresso_db_update' |
|
506 | + * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
507 | + * indicate that this plugin was just activated |
|
508 | + * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
509 | + * espresso_version()) |
|
510 | + * @return int one of the constants on EE_System::req_type_* |
|
511 | + */ |
|
512 | + public static function detect_req_type_given_activation_history( |
|
513 | + $activation_history_for_addon, |
|
514 | + $activation_indicator_option_name, |
|
515 | + $version_to_upgrade_to |
|
516 | + ) { |
|
517 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
518 | + if ($activation_history_for_addon) { |
|
519 | + //it exists, so this isn't a completely new install |
|
520 | + //check if this version already in that list of previously installed versions |
|
521 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
522 | + //it a version we haven't seen before |
|
523 | + if ($version_is_higher === 1) { |
|
524 | + $req_type = EE_System::req_type_upgrade; |
|
525 | + } else { |
|
526 | + $req_type = EE_System::req_type_downgrade; |
|
527 | + } |
|
528 | + delete_option($activation_indicator_option_name); |
|
529 | + } else { |
|
530 | + // its not an update. maybe a reactivation? |
|
531 | + if (get_option($activation_indicator_option_name, false)) { |
|
532 | + if ($version_is_higher === -1) { |
|
533 | + $req_type = EE_System::req_type_downgrade; |
|
534 | + } elseif ($version_is_higher === 0) { |
|
535 | + //we've seen this version before, but it's an activation. must be a reactivation |
|
536 | + $req_type = EE_System::req_type_reactivation; |
|
537 | + } else {//$version_is_higher === 1 |
|
538 | + $req_type = EE_System::req_type_upgrade; |
|
539 | + } |
|
540 | + delete_option($activation_indicator_option_name); |
|
541 | + } else { |
|
542 | + //we've seen this version before and the activation indicate doesn't show it was just activated |
|
543 | + if ($version_is_higher === -1) { |
|
544 | + $req_type = EE_System::req_type_downgrade; |
|
545 | + } elseif ($version_is_higher === 0) { |
|
546 | + //we've seen this version before and it's not an activation. its normal request |
|
547 | + $req_type = EE_System::req_type_normal; |
|
548 | + } else {//$version_is_higher === 1 |
|
549 | + $req_type = EE_System::req_type_upgrade; |
|
550 | + } |
|
551 | + } |
|
552 | + } |
|
553 | + } else { |
|
554 | + //brand new install |
|
555 | + $req_type = EE_System::req_type_new_activation; |
|
556 | + delete_option($activation_indicator_option_name); |
|
557 | + } |
|
558 | + return $req_type; |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + |
|
563 | + /** |
|
564 | + * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
565 | + * the $activation_history_for_addon |
|
566 | + * |
|
567 | + * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
568 | + * sometimes containing 'unknown-date' |
|
569 | + * @param string $version_to_upgrade_to (current version) |
|
570 | + * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
571 | + * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
572 | + * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
573 | + * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
574 | + */ |
|
575 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
576 | + { |
|
577 | + //find the most recently-activated version |
|
578 | + $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
579 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
580 | + } |
|
581 | + |
|
582 | + |
|
583 | + |
|
584 | + /** |
|
585 | + * Gets the most recently active version listed in the activation history, |
|
586 | + * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
587 | + * |
|
588 | + * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
589 | + * sometimes containing 'unknown-date' |
|
590 | + * @return string |
|
591 | + */ |
|
592 | + protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
593 | + { |
|
594 | + $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
595 | + $most_recently_active_version = '0.0.0.dev.000'; |
|
596 | + if (is_array($activation_history)) { |
|
597 | + foreach ($activation_history as $version => $times_activated) { |
|
598 | + //check there is a record of when this version was activated. Otherwise, |
|
599 | + //mark it as unknown |
|
600 | + if ( ! $times_activated) { |
|
601 | + $times_activated = array('unknown-date'); |
|
602 | + } |
|
603 | + if (is_string($times_activated)) { |
|
604 | + $times_activated = array($times_activated); |
|
605 | + } |
|
606 | + foreach ($times_activated as $an_activation) { |
|
607 | + if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
608 | + $most_recently_active_version = $version; |
|
609 | + $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
610 | + ? '1970-01-01 00:00:00' : $an_activation; |
|
611 | + } |
|
612 | + } |
|
613 | + } |
|
614 | + } |
|
615 | + return $most_recently_active_version; |
|
616 | + } |
|
617 | + |
|
618 | + |
|
619 | + |
|
620 | + /** |
|
621 | + * This redirects to the about EE page after activation |
|
622 | + * |
|
623 | + * @return void |
|
624 | + */ |
|
625 | + public function redirect_to_about_ee() |
|
626 | + { |
|
627 | + $notices = EE_Error::get_notices(false); |
|
628 | + //if current user is an admin and it's not an ajax or rest request |
|
629 | + if ( |
|
630 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
631 | + && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
632 | + && ! isset($notices['errors']) |
|
633 | + && apply_filters( |
|
634 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
635 | + $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
636 | + ) |
|
637 | + ) { |
|
638 | + $query_params = array('page' => 'espresso_about'); |
|
639 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
640 | + $query_params['new_activation'] = true; |
|
641 | + } |
|
642 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
643 | + $query_params['reactivation'] = true; |
|
644 | + } |
|
645 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
646 | + wp_safe_redirect($url); |
|
647 | + exit(); |
|
648 | + } |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + |
|
653 | + /** |
|
654 | + * load_core_configuration |
|
655 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
656 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
657 | + * |
|
658 | + * @return void |
|
659 | + */ |
|
660 | + public function load_core_configuration() |
|
661 | + { |
|
662 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
663 | + $this->registry->load_core('EE_Load_Textdomain'); |
|
664 | + //load textdomain |
|
665 | + EE_Load_Textdomain::load_textdomain(); |
|
666 | + // load and setup EE_Config and EE_Network_Config |
|
667 | + $this->registry->load_core('Config'); |
|
668 | + $this->registry->load_core('Network_Config'); |
|
669 | + // setup autoloaders |
|
670 | + // enable logging? |
|
671 | + if ($this->registry->CFG->admin->use_full_logging) { |
|
672 | + $this->registry->load_core('Log'); |
|
673 | + } |
|
674 | + // check for activation errors |
|
675 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
676 | + if ($activation_errors) { |
|
677 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
678 | + update_option('ee_plugin_activation_errors', false); |
|
679 | + } |
|
680 | + // get model names |
|
681 | + $this->_parse_model_names(); |
|
682 | + //load caf stuff a chance to play during the activation process too. |
|
683 | + $this->_maybe_brew_regular(); |
|
684 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
685 | + } |
|
686 | + |
|
687 | + |
|
688 | + |
|
689 | + /** |
|
690 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
691 | + * |
|
692 | + * @return void |
|
693 | + */ |
|
694 | + private function _parse_model_names() |
|
695 | + { |
|
696 | + //get all the files in the EE_MODELS folder that end in .model.php |
|
697 | + $models = glob(EE_MODELS . '*.model.php'); |
|
698 | + $model_names = array(); |
|
699 | + $non_abstract_db_models = array(); |
|
700 | + foreach ($models as $model) { |
|
701 | + // get model classname |
|
702 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
703 | + $short_name = str_replace('EEM_', '', $classname); |
|
704 | + $reflectionClass = new ReflectionClass($classname); |
|
705 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
706 | + $non_abstract_db_models[$short_name] = $classname; |
|
707 | + } |
|
708 | + $model_names[$short_name] = $classname; |
|
709 | + } |
|
710 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
711 | + $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', |
|
712 | + $non_abstract_db_models); |
|
713 | + } |
|
714 | + |
|
715 | + |
|
716 | + |
|
717 | + /** |
|
718 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
719 | + * that need to be setup before our EE_System launches. |
|
720 | + * |
|
721 | + * @return void |
|
722 | + */ |
|
723 | + private function _maybe_brew_regular() |
|
724 | + { |
|
725 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
726 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
727 | + } |
|
728 | + } |
|
729 | + |
|
730 | + |
|
731 | + |
|
732 | + /** |
|
733 | + * register_shortcodes_modules_and_widgets |
|
734 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
735 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
736 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
737 | + * |
|
738 | + * @access public |
|
739 | + * @return void |
|
740 | + */ |
|
741 | + public function register_shortcodes_modules_and_widgets() |
|
742 | + { |
|
743 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
744 | + // check for addons using old hookpoint |
|
745 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
746 | + $this->_incompatible_addon_error(); |
|
747 | + } |
|
748 | + } |
|
749 | + |
|
750 | + |
|
751 | + |
|
752 | + /** |
|
753 | + * _incompatible_addon_error |
|
754 | + * |
|
755 | + * @access public |
|
756 | + * @return void |
|
757 | + */ |
|
758 | + private function _incompatible_addon_error() |
|
759 | + { |
|
760 | + // get array of classes hooking into here |
|
761 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
762 | + if ( ! empty($class_names)) { |
|
763 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
764 | + 'event_espresso'); |
|
765 | + $msg .= '<ul>'; |
|
766 | + foreach ($class_names as $class_name) { |
|
767 | + $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
768 | + $class_name) . '</b></li>'; |
|
769 | + } |
|
770 | + $msg .= '</ul>'; |
|
771 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
772 | + 'event_espresso'); |
|
773 | + // save list of incompatible addons to wp-options for later use |
|
774 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
775 | + if (is_admin()) { |
|
776 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
777 | + } |
|
778 | + } |
|
779 | + } |
|
780 | + |
|
781 | + |
|
782 | + |
|
783 | + /** |
|
784 | + * brew_espresso |
|
785 | + * begins the process of setting hooks for initializing EE in the correct order |
|
786 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
787 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
788 | + * |
|
789 | + * @return void |
|
790 | + */ |
|
791 | + public function brew_espresso() |
|
792 | + { |
|
793 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
794 | + // load some final core systems |
|
795 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
796 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
797 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
798 | + add_action('init', array($this, 'load_controllers'), 7); |
|
799 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
800 | + add_action('init', array($this, 'initialize'), 10); |
|
801 | + add_action('init', array($this, 'initialize_last'), 100); |
|
802 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
803 | + add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
804 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
805 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
806 | + // pew pew pew |
|
807 | + $this->registry->load_core('PUE'); |
|
808 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
809 | + } |
|
810 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
811 | + } |
|
812 | + |
|
813 | + |
|
814 | + |
|
815 | + /** |
|
816 | + * set_hooks_for_core |
|
817 | + * |
|
818 | + * @access public |
|
819 | + * @return void |
|
820 | + */ |
|
821 | + public function set_hooks_for_core() |
|
822 | + { |
|
823 | + $this->_deactivate_incompatible_addons(); |
|
824 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
825 | + } |
|
826 | + |
|
827 | + |
|
828 | + |
|
829 | + /** |
|
830 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
831 | + * deactivates any addons considered incompatible with the current version of EE |
|
832 | + */ |
|
833 | + private function _deactivate_incompatible_addons() |
|
834 | + { |
|
835 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
836 | + if ( ! empty($incompatible_addons)) { |
|
837 | + $active_plugins = get_option('active_plugins', array()); |
|
838 | + foreach ($active_plugins as $active_plugin) { |
|
839 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
840 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
841 | + unset($_GET['activate']); |
|
842 | + espresso_deactivate_plugin($active_plugin); |
|
843 | + } |
|
844 | + } |
|
845 | + } |
|
846 | + } |
|
847 | + } |
|
848 | + |
|
849 | + |
|
850 | + |
|
851 | + /** |
|
852 | + * perform_activations_upgrades_and_migrations |
|
853 | + * |
|
854 | + * @access public |
|
855 | + * @return void |
|
856 | + */ |
|
857 | + public function perform_activations_upgrades_and_migrations() |
|
858 | + { |
|
859 | + //first check if we had previously attempted to setup EE's directories but failed |
|
860 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
861 | + EEH_Activation::create_upload_directories(); |
|
862 | + } |
|
863 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
864 | + } |
|
865 | + |
|
866 | + |
|
867 | + |
|
868 | + /** |
|
869 | + * load_CPTs_and_session |
|
870 | + * |
|
871 | + * @access public |
|
872 | + * @return void |
|
873 | + */ |
|
874 | + public function load_CPTs_and_session() |
|
875 | + { |
|
876 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
877 | + // register Custom Post Types |
|
878 | + $this->registry->load_core('Register_CPTs'); |
|
879 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
880 | + } |
|
881 | + |
|
882 | + |
|
883 | + |
|
884 | + /** |
|
885 | + * load_controllers |
|
886 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
887 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
888 | + * time |
|
889 | + * |
|
890 | + * @access public |
|
891 | + * @return void |
|
892 | + */ |
|
893 | + public function load_controllers() |
|
894 | + { |
|
895 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
896 | + // let's get it started |
|
897 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
898 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
899 | + $this->registry->load_core('Front_Controller', array(), false, true); |
|
900 | + } else if ( ! EE_FRONT_AJAX) { |
|
901 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
902 | + EE_Registry::instance()->load_core('Admin'); |
|
903 | + } |
|
904 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
905 | + } |
|
906 | + |
|
907 | + |
|
908 | + |
|
909 | + /** |
|
910 | + * core_loaded_and_ready |
|
911 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
912 | + * |
|
913 | + * @access public |
|
914 | + * @return void |
|
915 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
916 | + */ |
|
917 | + public function core_loaded_and_ready() |
|
918 | + { |
|
919 | + new AutomatedActionManager( |
|
920 | + new AutomatedActionFactory( |
|
921 | + new CronManager(), |
|
922 | + new RuleManager( |
|
923 | + new QueryParamGenerator() |
|
924 | + ) |
|
925 | + ), |
|
926 | + new CapabilitiesChecker( |
|
927 | + $this->registry->CAP |
|
928 | + ) |
|
929 | + ); |
|
930 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
931 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
932 | + $this->registry->load_core('Session'); |
|
933 | + // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
|
934 | + } |
|
935 | + |
|
936 | + |
|
937 | + |
|
938 | + /** |
|
939 | + * initialize |
|
940 | + * this is the best place to begin initializing client code |
|
941 | + * |
|
942 | + * @access public |
|
943 | + * @return void |
|
944 | + */ |
|
945 | + public function initialize() |
|
946 | + { |
|
947 | + do_action('AHEE__EE_System__initialize'); |
|
948 | + } |
|
949 | + |
|
950 | + |
|
951 | + |
|
952 | + /** |
|
953 | + * initialize_last |
|
954 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
955 | + * initialize has done so |
|
956 | + * |
|
957 | + * @access public |
|
958 | + * @return void |
|
959 | + */ |
|
960 | + public function initialize_last() |
|
961 | + { |
|
962 | + do_action('AHEE__EE_System__initialize_last'); |
|
963 | + } |
|
964 | + |
|
965 | + |
|
966 | + |
|
967 | + /** |
|
968 | + * set_hooks_for_shortcodes_modules_and_addons |
|
969 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
970 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
971 | + * |
|
972 | + * @access public |
|
973 | + * @return void |
|
974 | + */ |
|
975 | + public function set_hooks_for_shortcodes_modules_and_addons() |
|
976 | + { |
|
977 | + // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
978 | + } |
|
979 | + |
|
980 | + |
|
981 | + |
|
982 | + /** |
|
983 | + * do_not_cache |
|
984 | + * sets no cache headers and defines no cache constants for WP plugins |
|
985 | + * |
|
986 | + * @access public |
|
987 | + * @return void |
|
988 | + */ |
|
989 | + public static function do_not_cache() |
|
990 | + { |
|
991 | + // set no cache constants |
|
992 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
993 | + define('DONOTCACHEPAGE', true); |
|
994 | + } |
|
995 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
996 | + define('DONOTCACHCEOBJECT', true); |
|
997 | + } |
|
998 | + if ( ! defined('DONOTCACHEDB')) { |
|
999 | + define('DONOTCACHEDB', true); |
|
1000 | + } |
|
1001 | + // add no cache headers |
|
1002 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
1003 | + // plus a little extra for nginx and Google Chrome |
|
1004 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1005 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1006 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1007 | + } |
|
1008 | + |
|
1009 | + |
|
1010 | + |
|
1011 | + /** |
|
1012 | + * extra_nocache_headers |
|
1013 | + * |
|
1014 | + * @access public |
|
1015 | + * @param $headers |
|
1016 | + * @return array |
|
1017 | + */ |
|
1018 | + public static function extra_nocache_headers($headers) |
|
1019 | + { |
|
1020 | + // for NGINX |
|
1021 | + $headers['X-Accel-Expires'] = 0; |
|
1022 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1023 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1024 | + return $headers; |
|
1025 | + } |
|
1026 | + |
|
1027 | + |
|
1028 | + |
|
1029 | + /** |
|
1030 | + * nocache_headers |
|
1031 | + * |
|
1032 | + * @access public |
|
1033 | + * @return void |
|
1034 | + */ |
|
1035 | + public static function nocache_headers() |
|
1036 | + { |
|
1037 | + nocache_headers(); |
|
1038 | + } |
|
1039 | + |
|
1040 | + |
|
1041 | + |
|
1042 | + /** |
|
1043 | + * espresso_toolbar_items |
|
1044 | + * |
|
1045 | + * @access public |
|
1046 | + * @param WP_Admin_Bar $admin_bar |
|
1047 | + * @return void |
|
1048 | + */ |
|
1049 | + public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1050 | + { |
|
1051 | + // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1052 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1053 | + || defined('DOING_AJAX') |
|
1054 | + || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1055 | + ) { |
|
1056 | + return; |
|
1057 | + } |
|
1058 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1059 | + $menu_class = 'espresso_menu_item_class'; |
|
1060 | + //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1061 | + //because they're only defined in each of their respective constructors |
|
1062 | + //and this might be a frontend request, in which case they aren't available |
|
1063 | + $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1064 | + $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1065 | + $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1066 | + //Top Level |
|
1067 | + $admin_bar->add_menu(array( |
|
1068 | + 'id' => 'espresso-toolbar', |
|
1069 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1070 | + . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1071 | + . '</span>', |
|
1072 | + 'href' => $events_admin_url, |
|
1073 | + 'meta' => array( |
|
1074 | + 'title' => __('Event Espresso', 'event_espresso'), |
|
1075 | + 'class' => $menu_class . 'first', |
|
1076 | + ), |
|
1077 | + )); |
|
1078 | + //Events |
|
1079 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
1080 | + $admin_bar->add_menu(array( |
|
1081 | + 'id' => 'espresso-toolbar-events', |
|
1082 | + 'parent' => 'espresso-toolbar', |
|
1083 | + 'title' => __('Events', 'event_espresso'), |
|
1084 | + 'href' => $events_admin_url, |
|
1085 | + 'meta' => array( |
|
1086 | + 'title' => __('Events', 'event_espresso'), |
|
1087 | + 'target' => '', |
|
1088 | + 'class' => $menu_class, |
|
1089 | + ), |
|
1090 | + )); |
|
1091 | + } |
|
1092 | + if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
1093 | + //Events Add New |
|
1094 | + $admin_bar->add_menu(array( |
|
1095 | + 'id' => 'espresso-toolbar-events-new', |
|
1096 | + 'parent' => 'espresso-toolbar-events', |
|
1097 | + 'title' => __('Add New', 'event_espresso'), |
|
1098 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1099 | + 'meta' => array( |
|
1100 | + 'title' => __('Add New', 'event_espresso'), |
|
1101 | + 'target' => '', |
|
1102 | + 'class' => $menu_class, |
|
1103 | + ), |
|
1104 | + )); |
|
1105 | + } |
|
1106 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1107 | + //Current post |
|
1108 | + global $post; |
|
1109 | + if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1110 | + 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1111 | + ) { |
|
1112 | + //Events Edit Current Event |
|
1113 | + $admin_bar->add_menu(array( |
|
1114 | + 'id' => 'espresso-toolbar-events-edit', |
|
1115 | + 'parent' => 'espresso-toolbar-events', |
|
1116 | + 'title' => __('Edit Event', 'event_espresso'), |
|
1117 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1118 | + $events_admin_url), |
|
1119 | + 'meta' => array( |
|
1120 | + 'title' => __('Edit Event', 'event_espresso'), |
|
1121 | + 'target' => '', |
|
1122 | + 'class' => $menu_class, |
|
1123 | + ), |
|
1124 | + )); |
|
1125 | + } |
|
1126 | + } |
|
1127 | + //Events View |
|
1128 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1129 | + 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1130 | + ) { |
|
1131 | + $admin_bar->add_menu(array( |
|
1132 | + 'id' => 'espresso-toolbar-events-view', |
|
1133 | + 'parent' => 'espresso-toolbar-events', |
|
1134 | + 'title' => __('View', 'event_espresso'), |
|
1135 | + 'href' => $events_admin_url, |
|
1136 | + 'meta' => array( |
|
1137 | + 'title' => __('View', 'event_espresso'), |
|
1138 | + 'target' => '', |
|
1139 | + 'class' => $menu_class, |
|
1140 | + ), |
|
1141 | + )); |
|
1142 | + } |
|
1143 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1144 | + //Events View All |
|
1145 | + $admin_bar->add_menu(array( |
|
1146 | + 'id' => 'espresso-toolbar-events-all', |
|
1147 | + 'parent' => 'espresso-toolbar-events-view', |
|
1148 | + 'title' => __('All', 'event_espresso'), |
|
1149 | + 'href' => $events_admin_url, |
|
1150 | + 'meta' => array( |
|
1151 | + 'title' => __('All', 'event_espresso'), |
|
1152 | + 'target' => '', |
|
1153 | + 'class' => $menu_class, |
|
1154 | + ), |
|
1155 | + )); |
|
1156 | + } |
|
1157 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1158 | + 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1159 | + ) { |
|
1160 | + //Events View Today |
|
1161 | + $admin_bar->add_menu(array( |
|
1162 | + 'id' => 'espresso-toolbar-events-today', |
|
1163 | + 'parent' => 'espresso-toolbar-events-view', |
|
1164 | + 'title' => __('Today', 'event_espresso'), |
|
1165 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1166 | + $events_admin_url), |
|
1167 | + 'meta' => array( |
|
1168 | + 'title' => __('Today', 'event_espresso'), |
|
1169 | + 'target' => '', |
|
1170 | + 'class' => $menu_class, |
|
1171 | + ), |
|
1172 | + )); |
|
1173 | + } |
|
1174 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1175 | + 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1176 | + ) { |
|
1177 | + //Events View This Month |
|
1178 | + $admin_bar->add_menu(array( |
|
1179 | + 'id' => 'espresso-toolbar-events-month', |
|
1180 | + 'parent' => 'espresso-toolbar-events-view', |
|
1181 | + 'title' => __('This Month', 'event_espresso'), |
|
1182 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1183 | + $events_admin_url), |
|
1184 | + 'meta' => array( |
|
1185 | + 'title' => __('This Month', 'event_espresso'), |
|
1186 | + 'target' => '', |
|
1187 | + 'class' => $menu_class, |
|
1188 | + ), |
|
1189 | + )); |
|
1190 | + } |
|
1191 | + //Registration Overview |
|
1192 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1193 | + 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1194 | + ) { |
|
1195 | + $admin_bar->add_menu(array( |
|
1196 | + 'id' => 'espresso-toolbar-registrations', |
|
1197 | + 'parent' => 'espresso-toolbar', |
|
1198 | + 'title' => __('Registrations', 'event_espresso'), |
|
1199 | + 'href' => $reg_admin_url, |
|
1200 | + 'meta' => array( |
|
1201 | + 'title' => __('Registrations', 'event_espresso'), |
|
1202 | + 'target' => '', |
|
1203 | + 'class' => $menu_class, |
|
1204 | + ), |
|
1205 | + )); |
|
1206 | + } |
|
1207 | + //Registration Overview Today |
|
1208 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1209 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1210 | + ) { |
|
1211 | + $admin_bar->add_menu(array( |
|
1212 | + 'id' => 'espresso-toolbar-registrations-today', |
|
1213 | + 'parent' => 'espresso-toolbar-registrations', |
|
1214 | + 'title' => __('Today', 'event_espresso'), |
|
1215 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1216 | + $reg_admin_url), |
|
1217 | + 'meta' => array( |
|
1218 | + 'title' => __('Today', 'event_espresso'), |
|
1219 | + 'target' => '', |
|
1220 | + 'class' => $menu_class, |
|
1221 | + ), |
|
1222 | + )); |
|
1223 | + } |
|
1224 | + //Registration Overview Today Completed |
|
1225 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1226 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1227 | + ) { |
|
1228 | + $admin_bar->add_menu(array( |
|
1229 | + 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1230 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1231 | + 'title' => __('Approved', 'event_espresso'), |
|
1232 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1233 | + 'action' => 'default', |
|
1234 | + 'status' => 'today', |
|
1235 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1236 | + ), $reg_admin_url), |
|
1237 | + 'meta' => array( |
|
1238 | + 'title' => __('Approved', 'event_espresso'), |
|
1239 | + 'target' => '', |
|
1240 | + 'class' => $menu_class, |
|
1241 | + ), |
|
1242 | + )); |
|
1243 | + } |
|
1244 | + //Registration Overview Today Pending\ |
|
1245 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1246 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1247 | + ) { |
|
1248 | + $admin_bar->add_menu(array( |
|
1249 | + 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1250 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1251 | + 'title' => __('Pending', 'event_espresso'), |
|
1252 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1253 | + 'action' => 'default', |
|
1254 | + 'status' => 'today', |
|
1255 | + 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1256 | + ), $reg_admin_url), |
|
1257 | + 'meta' => array( |
|
1258 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1259 | + 'target' => '', |
|
1260 | + 'class' => $menu_class, |
|
1261 | + ), |
|
1262 | + )); |
|
1263 | + } |
|
1264 | + //Registration Overview Today Incomplete |
|
1265 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1266 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1267 | + ) { |
|
1268 | + $admin_bar->add_menu(array( |
|
1269 | + 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1270 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1271 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1272 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1273 | + 'action' => 'default', |
|
1274 | + 'status' => 'today', |
|
1275 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1276 | + ), $reg_admin_url), |
|
1277 | + 'meta' => array( |
|
1278 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1279 | + 'target' => '', |
|
1280 | + 'class' => $menu_class, |
|
1281 | + ), |
|
1282 | + )); |
|
1283 | + } |
|
1284 | + //Registration Overview Today Incomplete |
|
1285 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1286 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1287 | + ) { |
|
1288 | + $admin_bar->add_menu(array( |
|
1289 | + 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1290 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1291 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1292 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1293 | + 'action' => 'default', |
|
1294 | + 'status' => 'today', |
|
1295 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1296 | + ), $reg_admin_url), |
|
1297 | + 'meta' => array( |
|
1298 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1299 | + 'target' => '', |
|
1300 | + 'class' => $menu_class, |
|
1301 | + ), |
|
1302 | + )); |
|
1303 | + } |
|
1304 | + //Registration Overview This Month |
|
1305 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1306 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1307 | + ) { |
|
1308 | + $admin_bar->add_menu(array( |
|
1309 | + 'id' => 'espresso-toolbar-registrations-month', |
|
1310 | + 'parent' => 'espresso-toolbar-registrations', |
|
1311 | + 'title' => __('This Month', 'event_espresso'), |
|
1312 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1313 | + $reg_admin_url), |
|
1314 | + 'meta' => array( |
|
1315 | + 'title' => __('This Month', 'event_espresso'), |
|
1316 | + 'target' => '', |
|
1317 | + 'class' => $menu_class, |
|
1318 | + ), |
|
1319 | + )); |
|
1320 | + } |
|
1321 | + //Registration Overview This Month Approved |
|
1322 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1323 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1324 | + ) { |
|
1325 | + $admin_bar->add_menu(array( |
|
1326 | + 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1327 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1328 | + 'title' => __('Approved', 'event_espresso'), |
|
1329 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1330 | + 'action' => 'default', |
|
1331 | + 'status' => 'month', |
|
1332 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1333 | + ), $reg_admin_url), |
|
1334 | + 'meta' => array( |
|
1335 | + 'title' => __('Approved', 'event_espresso'), |
|
1336 | + 'target' => '', |
|
1337 | + 'class' => $menu_class, |
|
1338 | + ), |
|
1339 | + )); |
|
1340 | + } |
|
1341 | + //Registration Overview This Month Pending |
|
1342 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1343 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1344 | + ) { |
|
1345 | + $admin_bar->add_menu(array( |
|
1346 | + 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1347 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1348 | + 'title' => __('Pending', 'event_espresso'), |
|
1349 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1350 | + 'action' => 'default', |
|
1351 | + 'status' => 'month', |
|
1352 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1353 | + ), $reg_admin_url), |
|
1354 | + 'meta' => array( |
|
1355 | + 'title' => __('Pending', 'event_espresso'), |
|
1356 | + 'target' => '', |
|
1357 | + 'class' => $menu_class, |
|
1358 | + ), |
|
1359 | + )); |
|
1360 | + } |
|
1361 | + //Registration Overview This Month Not Approved |
|
1362 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1363 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1364 | + ) { |
|
1365 | + $admin_bar->add_menu(array( |
|
1366 | + 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1367 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1368 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1369 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1370 | + 'action' => 'default', |
|
1371 | + 'status' => 'month', |
|
1372 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1373 | + ), $reg_admin_url), |
|
1374 | + 'meta' => array( |
|
1375 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1376 | + 'target' => '', |
|
1377 | + 'class' => $menu_class, |
|
1378 | + ), |
|
1379 | + )); |
|
1380 | + } |
|
1381 | + //Registration Overview This Month Cancelled |
|
1382 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1383 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1384 | + ) { |
|
1385 | + $admin_bar->add_menu(array( |
|
1386 | + 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1387 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1388 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1389 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1390 | + 'action' => 'default', |
|
1391 | + 'status' => 'month', |
|
1392 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1393 | + ), $reg_admin_url), |
|
1394 | + 'meta' => array( |
|
1395 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1396 | + 'target' => '', |
|
1397 | + 'class' => $menu_class, |
|
1398 | + ), |
|
1399 | + )); |
|
1400 | + } |
|
1401 | + //Extensions & Services |
|
1402 | + if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1403 | + 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1404 | + ) { |
|
1405 | + $admin_bar->add_menu(array( |
|
1406 | + 'id' => 'espresso-toolbar-extensions-and-services', |
|
1407 | + 'parent' => 'espresso-toolbar', |
|
1408 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1409 | + 'href' => $extensions_admin_url, |
|
1410 | + 'meta' => array( |
|
1411 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1412 | + 'target' => '', |
|
1413 | + 'class' => $menu_class, |
|
1414 | + ), |
|
1415 | + )); |
|
1416 | + } |
|
1417 | + } |
|
1418 | + |
|
1419 | + |
|
1420 | + |
|
1421 | + /** |
|
1422 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1423 | + * never returned with the function. |
|
1424 | + * |
|
1425 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
1426 | + * @return array |
|
1427 | + */ |
|
1428 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
1429 | + { |
|
1430 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1431 | + } |
|
1432 | + |
|
1433 | + |
|
1434 | + |
|
1435 | + |
|
1436 | + |
|
1437 | + |
|
1438 | + /*********************************************** WP_ENQUEUE_SCRIPTS HOOK ***********************************************/ |
|
1439 | + /** |
|
1440 | + * wp_enqueue_scripts |
|
1441 | + * |
|
1442 | + * @access public |
|
1443 | + * @return void |
|
1444 | + */ |
|
1445 | + public function wp_enqueue_scripts() |
|
1446 | + { |
|
1447 | + // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
|
1448 | + if (apply_filters('FHEE_load_EE_System_scripts', true)) { |
|
1449 | + // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1450 | + if (apply_filters('FHEE_load_jquery_validate', false)) { |
|
1451 | + // register jQuery Validate and additional methods |
|
1452 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1453 | + array('jquery'), '1.15.0', true); |
|
1454 | + wp_register_script('jquery-validate-extra-methods', |
|
1455 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1456 | + array('jquery', 'jquery-validate'), '1.15.0', true); |
|
1457 | + } |
|
1458 | + } |
|
1459 | + } |
|
1460 | 1460 | |
1461 | 1461 | |
1462 | 1462 |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public static function instance() { |
75 | 75 | // check if class object is instantiated |
76 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Maintenance_Mode )) { |
|
76 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Maintenance_Mode)) { |
|
77 | 77 | self::$_instance = new self(); |
78 | 78 | } |
79 | 79 | return self::$_instance; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode) |
84 | 84 | * @return EE_Maintenance_Mode |
85 | 85 | */ |
86 | - public static function reset(){ |
|
86 | + public static function reset() { |
|
87 | 87 | self::instance()->set_maintenance_mode_if_db_old(); |
88 | 88 | return self::instance(); |
89 | 89 | } |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | */ |
99 | 99 | private function __construct() { |
100 | 100 | // if M-Mode level 2 is engaged, we still need basic assets loaded |
101 | - add_action( 'wp_enqueue_scripts', array( $this, 'load_assets_required_for_m_mode' )); |
|
101 | + add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode')); |
|
102 | 102 | // shut 'er down down for maintenance ? |
103 | - add_filter( 'the_content', array( $this, 'the_content' ), 2 ); |
|
103 | + add_filter('the_content', array($this, 'the_content'), 2); |
|
104 | 104 | // add powered by EE msg |
105 | - add_action( 'shutdown', array( $this, 'display_maintenance_mode_notice' ), 10 ); |
|
105 | + add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * retrieves the maintenance mode option value from the db |
113 | 113 | * @return int |
114 | 114 | */ |
115 | - public function real_level(){ |
|
116 | - return get_option( self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance ); |
|
115 | + public function real_level() { |
|
116 | + return get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * thinks their tables are present and up-to-date). |
122 | 122 | * @return boolean |
123 | 123 | */ |
124 | - public function models_can_query(){ |
|
124 | + public function models_can_query() { |
|
125 | 125 | return $this->real_level() != EE_Maintenance_Mode::level_2_complete_maintenance; |
126 | 126 | } |
127 | 127 | |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode |
135 | 135 | * @return int |
136 | 136 | */ |
137 | - public function level(){ |
|
137 | + public function level() { |
|
138 | 138 | $real_maintenance_mode_level = $this->real_level(); |
139 | 139 | //if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend |
140 | - if( ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests |
|
140 | + if (( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests |
|
141 | 141 | current_user_can('administrator') && //when the user is an admin |
142 | - $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance){//and we're in level 1 |
|
142 | + $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance) {//and we're in level 1 |
|
143 | 143 | $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
144 | - }else{ |
|
144 | + } else { |
|
145 | 145 | $maintenance_mode_level = $real_maintenance_mode_level; |
146 | 146 | } |
147 | 147 | return $maintenance_mode_level; |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | * Determines if we need to put EE in maintenance mode because the database needs updating |
152 | 152 | * @return boolean true if DB is old and maintenance mode was triggered; false otherwise |
153 | 153 | */ |
154 | - public function set_maintenance_mode_if_db_old(){ |
|
155 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
156 | - if( EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){ |
|
154 | + public function set_maintenance_mode_if_db_old() { |
|
155 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
156 | + if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
157 | 157 | update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
158 | 158 | return true; |
159 | - }elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
159 | + }elseif ($this->level() == self::level_2_complete_maintenance) { |
|
160 | 160 | //we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
161 | 161 | //then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
162 | - update_option( self::option_name_maintenance_mode, self::level_0_not_in_maintenance ); |
|
162 | + update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance); |
|
163 | 163 | return false; |
164 | - }else{ |
|
164 | + } else { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @param int $level |
172 | 172 | * @return void |
173 | 173 | */ |
174 | - public function set_maintenance_level($level){ |
|
175 | - do_action( 'AHEE__EE_Maintenance_Mode__set_maintenance_level', $level ); |
|
174 | + public function set_maintenance_level($level) { |
|
175 | + do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level); |
|
176 | 176 | update_option(self::option_name_maintenance_mode, intval($level)); |
177 | 177 | } |
178 | 178 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @return string |
200 | 200 | */ |
201 | 201 | public function load_assets_required_for_m_mode() { |
202 | - if ( $this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is( 'espresso_core', 'enqueued' )) { |
|
203 | - wp_register_style( 'espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
202 | + if ($this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is('espresso_core', 'enqueued')) { |
|
203 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
204 | 204 | wp_enqueue_style('espresso_default'); |
205 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
206 | - wp_enqueue_script( 'espresso_core' ); |
|
205 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
206 | + wp_enqueue_script('espresso_core'); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public static function template_include() { |
223 | 223 | // shut 'er down down for maintenance ? then don't use any of our templates for our endpoints |
224 | - return get_template_directory() . '/index.php'; |
|
224 | + return get_template_directory().'/index.php'; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -235,12 +235,12 @@ discard block |
||
235 | 235 | * @param string $the_content |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public function the_content( $the_content ) { |
|
238 | + public function the_content($the_content) { |
|
239 | 239 | // check if M-mode is engaged and for EE shortcode |
240 | - if ( $this->level() && strpos( $the_content, '[ESPRESSO_' ) !== false ) { |
|
240 | + if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) { |
|
241 | 241 | // this can eventually be moved to a template, or edited via admin. But for now... |
242 | 242 | $the_content = sprintf( |
243 | - __( '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso' ), |
|
243 | + __('%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso'), |
|
244 | 244 | '<h3>', |
245 | 245 | '</h3><p>', |
246 | 246 | '</p>' |
@@ -264,16 +264,16 @@ discard block |
||
264 | 264 | // check if M-mode is engaged and for EE shortcode |
265 | 265 | if ( |
266 | 266 | $this->real_level() && |
267 | - current_user_can( 'administrator' ) && |
|
267 | + current_user_can('administrator') && |
|
268 | 268 | ! is_admin() && |
269 | - ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
269 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
270 | 270 | && EE_Registry::instance()->REQ->is_espresso_page() |
271 | 271 | ) { |
272 | 272 | printf( |
273 | - __( '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso' ), |
|
273 | + __('%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso'), |
|
274 | 274 | '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="', |
275 | 275 | '"><span class="dashicons dashicons-no"></span></a><p>', |
276 | - ' » <a href="' . add_query_arg( array( 'page' => 'espresso_maintenance_settings' ), admin_url( 'admin.php' )) . '">', |
|
276 | + ' » <a href="'.add_query_arg(array('page' => 'espresso_maintenance_settings'), admin_url('admin.php')).'">', |
|
277 | 277 | '</a></p></div>' |
278 | 278 | ); |
279 | 279 | } |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * @ return void |
292 | 292 | */ |
293 | 293 | final function __destruct() {} |
294 | - final function __call($a,$b) {} |
|
294 | + final function __call($a, $b) {} |
|
295 | 295 | final function __get($a) {} |
296 | - final function __set($a,$b) {} |
|
296 | + final function __set($a, $b) {} |
|
297 | 297 | final function __isset($a) {} |
298 | 298 | final function __unset($a) {} |
299 | 299 | final function __sleep() { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | final function __invoke() {} |
305 | 305 | final function __set_state() {} |
306 | 306 | final function __clone() {} |
307 | - final static function __callStatic($a,$b) {} |
|
307 | + final static function __callStatic($a, $b) {} |
|
308 | 308 | |
309 | 309 | } |
310 | 310 | // End of file EE_Maintenance_Mode.core.php |