@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -59,24 +59,24 @@ discard block |
||
59 | 59 | * was not a new generated template but just reactivated (which only happens for global templates that |
60 | 60 | * already exist in the database. |
61 | 61 | */ |
62 | - public static function generate_new_templates( $messenger, $message_types, $GRP_ID = 0, $global = false ) { |
|
62 | + public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
|
63 | 63 | //make sure message_type is an array. |
64 | 64 | $message_types = (array) $message_types; |
65 | 65 | $templates = array(); |
66 | 66 | |
67 | - if ( empty( $messenger ) ) { |
|
68 | - throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') ); |
|
67 | + if (empty($messenger)) { |
|
68 | + throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | //if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files. |
72 | - if ( empty( $message_types ) ) { |
|
73 | - throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') ); |
|
72 | + if (empty($message_types)) { |
|
73 | + throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | EEH_MSG_Template::_set_autoloader(); |
77 | - foreach ( $message_types as $message_type ) { |
|
77 | + foreach ($message_types as $message_type) { |
|
78 | 78 | //if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty. |
79 | - if ( $global && empty( $GRP_ID ) ) { |
|
79 | + if ($global && empty($GRP_ID)) { |
|
80 | 80 | $GRP_ID = EEM_Message_Template_Group::instance()->get_one( |
81 | 81 | array( |
82 | 82 | array( |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // if this is global template generation. |
92 | 92 | // First let's determine if we already HAVE global templates for this messenger and message_type combination. |
93 | 93 | // If we do then NO generation!! |
94 | - if ( $global && EEH_MSG_Template::already_generated( $messenger, $message_type, $GRP_ID ) ) { |
|
94 | + if ($global && EEH_MSG_Template::already_generated($messenger, $message_type, $GRP_ID)) { |
|
95 | 95 | $templates[] = array( |
96 | 96 | 'GRP_ID' => $GRP_ID, |
97 | 97 | 'MTP_context' => '', |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | //we already have generated templates for this so let's go to the next message type. |
100 | 100 | continue; |
101 | 101 | } |
102 | - $new_message_template_group = EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $global ); |
|
102 | + $new_message_template_group = EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $global); |
|
103 | 103 | |
104 | - if ( ! $new_message_template_group ) { |
|
104 | + if ( ! $new_message_template_group) { |
|
105 | 105 | continue; |
106 | 106 | } |
107 | 107 | $templates[] = $new_message_template_group; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | * @param int $GRP_ID GRP ID ( if a custom template) (if not provided then we're just doing global template check) |
119 | 119 | * @return bool true = generated, false = hasn't been generated. |
120 | 120 | */ |
121 | - public static function already_generated( $messenger, $message_type, $GRP_ID = 0 ) { |
|
121 | + public static function already_generated($messenger, $message_type, $GRP_ID = 0) { |
|
122 | 122 | EEH_MSG_Template::_set_autoloader(); |
123 | 123 | //what method we use depends on whether we have an GRP_ID or not |
124 | - $count = empty( $GRP_ID ) |
|
124 | + $count = empty($GRP_ID) |
|
125 | 125 | ? EEM_Message_Template::instance()->count( |
126 | 126 | array( |
127 | 127 | array( |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | ) |
132 | 132 | ) |
133 | 133 | ) |
134 | - : EEM_Message_Template::instance()->count( array( array( 'GRP_ID' => $GRP_ID ) ) ); |
|
134 | + : EEM_Message_Template::instance()->count(array(array('GRP_ID' => $GRP_ID))); |
|
135 | 135 | |
136 | 136 | return $count > 0; |
137 | 137 | } |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * @param array $message_type_names Message type slug |
148 | 148 | * @return int count of updated records. |
149 | 149 | */ |
150 | - public static function update_to_active( $messenger_names, $message_type_names ) { |
|
151 | - $messenger_names = is_array( $messenger_names ) ? $messenger_names : array( $messenger_names ); |
|
152 | - $message_type_names = is_array( $message_type_names ) ? $message_type_names : array( $message_type_names ); |
|
150 | + public static function update_to_active($messenger_names, $message_type_names) { |
|
151 | + $messenger_names = is_array($messenger_names) ? $messenger_names : array($messenger_names); |
|
152 | + $message_type_names = is_array($message_type_names) ? $message_type_names : array($message_type_names); |
|
153 | 153 | return EEM_Message_Template_Group::instance()->update( |
154 | - array( 'MTP_is_active' => 1 ), |
|
154 | + array('MTP_is_active' => 1), |
|
155 | 155 | array( |
156 | 156 | array( |
157 | - 'MTP_messenger' => array( 'IN', $messenger_names ), |
|
158 | - 'MTP_message_type' => array( 'IN', $message_type_names ) |
|
157 | + 'MTP_messenger' => array('IN', $messenger_names), |
|
158 | + 'MTP_message_type' => array('IN', $message_type_names) |
|
159 | 159 | ) |
160 | 160 | ) |
161 | 161 | ); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return int count of updated records. |
178 | 178 | */ |
179 | - public static function update_to_inactive( $messenger_names = array(), $message_type_names = array() ) { |
|
179 | + public static function update_to_inactive($messenger_names = array(), $message_type_names = array()) { |
|
180 | 180 | return EEM_Message_Template_Group::instance()->deactivate_message_template_groups_for( |
181 | 181 | $messenger_names, |
182 | 182 | $message_type_names |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * @param string $type |
194 | 194 | * @return array array consisting of installed messenger objects and installed message type objects. |
195 | 195 | */ |
196 | - public static function get_installed_message_objects( $type = 'all' ) { |
|
196 | + public static function get_installed_message_objects($type = 'all') { |
|
197 | 197 | self::_set_autoloader(); |
198 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
198 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
199 | 199 | return array( |
200 | 200 | 'messenger' => $message_resource_manager->installed_messengers(), |
201 | 201 | 'message_type' => $message_resource_manager->installed_message_types() |
@@ -231,74 +231,74 @@ discard block |
||
231 | 231 | $context = 'admin', |
232 | 232 | $merged = false |
233 | 233 | ) { |
234 | - $messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) ); |
|
235 | - $mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) ); |
|
234 | + $messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger))); |
|
235 | + $mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type))); |
|
236 | 236 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
237 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
237 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
238 | 238 | //convert slug to object |
239 | - $messenger = $message_resource_manager->get_messenger( $messenger ); |
|
239 | + $messenger = $message_resource_manager->get_messenger($messenger); |
|
240 | 240 | |
241 | 241 | //if messenger isn't a EE_messenger resource then bail. |
242 | - if ( ! $messenger instanceof EE_messenger ) { |
|
242 | + if ( ! $messenger instanceof EE_messenger) { |
|
243 | 243 | return array(); |
244 | 244 | } |
245 | 245 | |
246 | 246 | //validate class for getting our list of shortcodes |
247 | - $classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator'; |
|
248 | - if ( ! class_exists( $classname ) ) { |
|
249 | - $msg[] = __( 'The Validator class was unable to load', 'event_espresso' ); |
|
247 | + $classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator'; |
|
248 | + if ( ! class_exists($classname)) { |
|
249 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
250 | 250 | $msg[] = sprintf( |
251 | - __( 'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso' ), |
|
251 | + __('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), |
|
252 | 252 | $classname |
253 | 253 | ); |
254 | - throw new EE_Error( implode( '||', $msg ) ); |
|
254 | + throw new EE_Error(implode('||', $msg)); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** @type EE_Messages_Validator $_VLD */ |
258 | - $_VLD = new $classname( array(), $context ); |
|
258 | + $_VLD = new $classname(array(), $context); |
|
259 | 259 | $valid_shortcodes = $_VLD->get_validators(); |
260 | 260 | |
261 | 261 | //let's make sure we're only getting the shortcode part of the validators |
262 | 262 | $shortcodes = array(); |
263 | - foreach ( $valid_shortcodes as $field => $validators ) { |
|
264 | - $shortcodes[ $field ] = $validators['shortcodes']; |
|
263 | + foreach ($valid_shortcodes as $field => $validators) { |
|
264 | + $shortcodes[$field] = $validators['shortcodes']; |
|
265 | 265 | } |
266 | 266 | $valid_shortcodes = $shortcodes; |
267 | 267 | |
268 | 268 | //if not all fields let's make sure we ONLY include the shortcodes for the specified fields. |
269 | - if ( ! empty( $fields ) ) { |
|
269 | + if ( ! empty($fields)) { |
|
270 | 270 | $specified_shortcodes = array(); |
271 | - foreach ( $fields as $field ) { |
|
272 | - if ( isset( $valid_shortcodes[ $field ] ) ) { |
|
273 | - $specified_shortcodes[ $field ] = $valid_shortcodes[ $field ]; |
|
271 | + foreach ($fields as $field) { |
|
272 | + if (isset($valid_shortcodes[$field])) { |
|
273 | + $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | $valid_shortcodes = $specified_shortcodes; |
277 | 277 | } |
278 | 278 | |
279 | 279 | //if not merged then let's replace the fields with the localized fields |
280 | - if ( ! $merged ) { |
|
280 | + if ( ! $merged) { |
|
281 | 281 | //let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array. |
282 | 282 | $field_settings = $messenger->get_template_fields(); |
283 | 283 | $localized = array(); |
284 | - foreach ( $valid_shortcodes as $field => $shortcodes ) { |
|
284 | + foreach ($valid_shortcodes as $field => $shortcodes) { |
|
285 | 285 | //get localized field label |
286 | - if ( isset( $field_settings[ $field ] ) ) { |
|
286 | + if (isset($field_settings[$field])) { |
|
287 | 287 | //possible that this is used as a main field. |
288 | - if ( empty( $field_settings[ $field ] ) ) { |
|
289 | - if ( isset( $field_settings['extra'][ $field ] ) ) { |
|
290 | - $_field = $field_settings['extra'][ $field ]['main']['label']; |
|
288 | + if (empty($field_settings[$field])) { |
|
289 | + if (isset($field_settings['extra'][$field])) { |
|
290 | + $_field = $field_settings['extra'][$field]['main']['label']; |
|
291 | 291 | } else { |
292 | 292 | $_field = $field; |
293 | 293 | } |
294 | 294 | } else { |
295 | - $_field = $field_settings[ $field ]['label']; |
|
295 | + $_field = $field_settings[$field]['label']; |
|
296 | 296 | } |
297 | - } else if ( isset( $field_settings['extra'] ) ) { |
|
297 | + } else if (isset($field_settings['extra'])) { |
|
298 | 298 | //loop through extra "main fields" and see if any of their children have our field |
299 | - foreach ( $field_settings['extra'] as $main_field => $fields ) { |
|
300 | - if ( isset( $fields[ $field ] ) ) { |
|
301 | - $_field = $fields[ $field ]['label']; |
|
299 | + foreach ($field_settings['extra'] as $main_field => $fields) { |
|
300 | + if (isset($fields[$field])) { |
|
301 | + $_field = $fields[$field]['label']; |
|
302 | 302 | } else { |
303 | 303 | $_field = $field; |
304 | 304 | } |
@@ -306,22 +306,22 @@ discard block |
||
306 | 306 | } else { |
307 | 307 | $_field = $field; |
308 | 308 | } |
309 | - if ( isset( $_field ) ) { |
|
310 | - $localized[ $_field ] = $shortcodes; |
|
309 | + if (isset($_field)) { |
|
310 | + $localized[$_field] = $shortcodes; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | $valid_shortcodes = $localized; |
314 | 314 | } |
315 | 315 | |
316 | 316 | //if $merged then let's merge all the shortcodes into one list NOT indexed by field. |
317 | - if ( $merged ) { |
|
317 | + if ($merged) { |
|
318 | 318 | $merged_codes = array(); |
319 | - foreach ( $valid_shortcodes as $field => $shortcode ) { |
|
320 | - foreach ( $shortcode as $code => $label ) { |
|
321 | - if ( isset( $merged_codes[ $code ] ) ) { |
|
319 | + foreach ($valid_shortcodes as $field => $shortcode) { |
|
320 | + foreach ($shortcode as $code => $label) { |
|
321 | + if (isset($merged_codes[$code])) { |
|
322 | 322 | continue; |
323 | 323 | } else { |
324 | - $merged_codes[ $code ] = $label; |
|
324 | + $merged_codes[$code] = $label; |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | } |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | * @throws \EE_Error |
342 | 342 | * @return EE_messenger |
343 | 343 | */ |
344 | - public static function messenger_obj( $messenger ) { |
|
344 | + public static function messenger_obj($messenger) { |
|
345 | 345 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
346 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
347 | - return $Message_Resource_Manager->get_messenger( $messenger ); |
|
346 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
347 | + return $Message_Resource_Manager->get_messenger($messenger); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * @throws \EE_Error |
358 | 358 | * @return EE_message_type |
359 | 359 | */ |
360 | - public static function message_type_obj( $message_type ) { |
|
360 | + public static function message_type_obj($message_type) { |
|
361 | 361 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
362 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
363 | - return $Message_Resource_Manager->get_message_type( $message_type ); |
|
362 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
363 | + return $Message_Resource_Manager->get_message_type($message_type); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
@@ -374,11 +374,11 @@ discard block |
||
374 | 374 | * @param string $message_type message type to check for. |
375 | 375 | * @return boolean |
376 | 376 | */ |
377 | - public static function is_mt_active( $message_type ) { |
|
377 | + public static function is_mt_active($message_type) { |
|
378 | 378 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
379 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
379 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
380 | 380 | $active_mts = $Message_Resource_Manager->list_of_active_message_types(); |
381 | - return in_array( $message_type, $active_mts ); |
|
381 | + return in_array($message_type, $active_mts); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | * @param string $messenger slug for messenger to check. |
392 | 392 | * @return boolean |
393 | 393 | */ |
394 | - public static function is_messenger_active( $messenger ) { |
|
394 | + public static function is_messenger_active($messenger) { |
|
395 | 395 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
396 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
397 | - $active_messenger = $Message_Resource_Manager->get_active_messenger( $messenger ); |
|
396 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
397 | + $active_messenger = $Message_Resource_Manager->get_active_messenger($messenger); |
|
398 | 398 | return $active_messenger instanceof EE_messenger ? true : false; |
399 | 399 | } |
400 | 400 | |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | public static function get_active_messengers_in_db() { |
413 | 413 | EE_Error::doing_it_wrong( |
414 | 414 | __METHOD__, |
415 | - __( 'Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso' ), |
|
415 | + __('Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso'), |
|
416 | 416 | '4.9.0' |
417 | 417 | ); |
418 | 418 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
419 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
419 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
420 | 420 | return $Message_Resource_Manager->get_active_messengers_option(); |
421 | 421 | } |
422 | 422 | |
@@ -433,15 +433,15 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @return bool FALSE if not updated, TRUE if updated. |
435 | 435 | */ |
436 | - public static function update_active_messengers_in_db( $data_to_save ) { |
|
436 | + public static function update_active_messengers_in_db($data_to_save) { |
|
437 | 437 | EE_Error::doing_it_wrong( |
438 | 438 | __METHOD__, |
439 | - __( 'Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso' ), |
|
439 | + __('Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso'), |
|
440 | 440 | '4.9.0' |
441 | 441 | ); |
442 | 442 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
443 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
444 | - return $Message_Resource_Manager->update_active_messengers_option( $data_to_save ); |
|
443 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
444 | + return $Message_Resource_Manager->update_active_messengers_option($data_to_save); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | |
@@ -465,34 +465,34 @@ discard block |
||
465 | 465 | $sending_messenger = '' |
466 | 466 | ) { |
467 | 467 | //first determine if the url can be to the EE_Message object. |
468 | - if ( ! $message_type->always_generate() ) { |
|
469 | - return EEH_MSG_Template::generate_browser_trigger( $message ); |
|
468 | + if ( ! $message_type->always_generate()) { |
|
469 | + return EEH_MSG_Template::generate_browser_trigger($message); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | //if $registration object is not valid then exit early because there's nothing that can be generated. |
473 | - if ( ! $registration instanceof EE_Registration ) { |
|
473 | + if ( ! $registration instanceof EE_Registration) { |
|
474 | 474 | throw new EE_Error( |
475 | - __( 'Incoming value for registration is not a valid EE_Registration object.', 'event_espresso' ) |
|
475 | + __('Incoming value for registration is not a valid EE_Registration object.', 'event_espresso') |
|
476 | 476 | ); |
477 | 477 | } |
478 | 478 | |
479 | 479 | //validate given context |
480 | 480 | $contexts = $message_type->get_contexts(); |
481 | - if ( $message->context() !== '' && ! isset( $contexts[$message->context()] ) ) { |
|
481 | + if ($message->context() !== '' && ! isset($contexts[$message->context()])) { |
|
482 | 482 | throw new EE_Error( |
483 | 483 | sprintf( |
484 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
484 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
485 | 485 | $message->context(), |
486 | - get_class( $message_type ) |
|
486 | + get_class($message_type) |
|
487 | 487 | ) |
488 | 488 | ); |
489 | 489 | } |
490 | 490 | |
491 | 491 | //valid sending messenger but only if sending messenger set. Otherwise generating messenger is used. |
492 | - if ( ! empty( $sending_messenger ) ) { |
|
492 | + if ( ! empty($sending_messenger)) { |
|
493 | 493 | $with_messengers = $message_type->with_messengers(); |
494 | - if ( ! isset( $with_messengers[$message->messenger()] ) |
|
495 | - || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
494 | + if ( ! isset($with_messengers[$message->messenger()]) |
|
495 | + || ! in_array($sending_messenger, $with_messengers[$message->messenger()])) { |
|
496 | 496 | throw new EE_Error( |
497 | 497 | sprintf( |
498 | 498 | __( |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | 'event_espresso' |
501 | 501 | ), |
502 | 502 | $sending_messenger, |
503 | - get_class( $message_type ) |
|
503 | + get_class($message_type) |
|
504 | 504 | ) |
505 | 505 | ); |
506 | 506 | } |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | * @param EE_Message $message |
524 | 524 | * @return string. |
525 | 525 | */ |
526 | - public static function generate_browser_trigger( EE_Message $message ) { |
|
526 | + public static function generate_browser_trigger(EE_Message $message) { |
|
527 | 527 | $query_args = array( |
528 | 528 | 'ee' => 'msg_browser_trigger', |
529 | 529 | 'token' => $message->MSG_token() |
530 | 530 | ); |
531 | 531 | return apply_filters( |
532 | 532 | 'FHEE__EEH_MSG_Template__generate_browser_trigger', |
533 | - add_query_arg( $query_args, site_url() ), |
|
533 | + add_query_arg($query_args, site_url()), |
|
534 | 534 | $message |
535 | 535 | ); |
536 | 536 | } |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @param EE_Message $message |
546 | 546 | * @return string |
547 | 547 | */ |
548 | - public static function generate_error_display_trigger( EE_Message $message ) { |
|
548 | + public static function generate_error_display_trigger(EE_Message $message) { |
|
549 | 549 | return apply_filters( |
550 | 550 | 'FHEE__EEH_MSG_Template__generate_error_display_trigger', |
551 | 551 | add_query_arg( |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | 'GRP_ID' => $message_template_group, |
596 | 596 | 'id' => $data_id |
597 | 597 | ); |
598 | - $url = add_query_arg( $query_args, get_home_url() ); |
|
598 | + $url = add_query_arg($query_args, get_home_url()); |
|
599 | 599 | |
600 | 600 | //made it here so now we can just get the url and filter it. Filtered globally and by message type. |
601 | 601 | $url = apply_filters( |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | * @param string $type What action to return. |
624 | 624 | * @return string |
625 | 625 | */ |
626 | - public static function get_message_action_icon( $type ) { |
|
626 | + public static function get_message_action_icon($type) { |
|
627 | 627 | $action_icons = self::get_message_action_icons(); |
628 | - return isset( $action_icons[ $type ] ) ? $action_icons[ $type ] : ''; |
|
628 | + return isset($action_icons[$type]) ? $action_icons[$type] : ''; |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | |
@@ -637,34 +637,34 @@ discard block |
||
637 | 637 | * @return array |
638 | 638 | */ |
639 | 639 | public static function get_message_action_icons() { |
640 | - return apply_filters( 'FHEE__EEH_MSG_Template__message_action_icons', |
|
640 | + return apply_filters('FHEE__EEH_MSG_Template__message_action_icons', |
|
641 | 641 | array( |
642 | 642 | 'view' => array( |
643 | - 'label' => __( 'View Message', 'event_espresso' ), |
|
643 | + 'label' => __('View Message', 'event_espresso'), |
|
644 | 644 | 'css_class' => 'dashicons dashicons-welcome-view-site', |
645 | 645 | ), |
646 | 646 | 'error' => array( |
647 | - 'label' => __( 'View Error Message', 'event_espresso' ), |
|
647 | + 'label' => __('View Error Message', 'event_espresso'), |
|
648 | 648 | 'css_class' => 'dashicons dashicons-info', |
649 | 649 | ), |
650 | 650 | 'see_notifications_for' => array( |
651 | - 'label' => __( 'View Related Messages', 'event_espresso' ), |
|
651 | + 'label' => __('View Related Messages', 'event_espresso'), |
|
652 | 652 | 'css_class' => 'dashicons dashicons-megaphone', |
653 | 653 | ), |
654 | 654 | 'generate_now' => array( |
655 | - 'label' => __( 'Generate the message now.', 'event_espresso' ), |
|
655 | + 'label' => __('Generate the message now.', 'event_espresso'), |
|
656 | 656 | 'css_class' => 'dashicons dashicons-admin-tools', |
657 | 657 | ), |
658 | 658 | 'send_now' => array( |
659 | - 'label' => __( 'Send Immediately', 'event_espresso' ), |
|
659 | + 'label' => __('Send Immediately', 'event_espresso'), |
|
660 | 660 | 'css_class' => 'dashicons dashicons-controls-forward', |
661 | 661 | ), |
662 | 662 | 'queue_for_resending' => array( |
663 | - 'label' => __( 'Queue for Resending', 'event_espresso' ), |
|
663 | + 'label' => __('Queue for Resending', 'event_espresso'), |
|
664 | 664 | 'css_class' => 'dashicons dashicons-controls-repeat', |
665 | 665 | ), |
666 | 666 | 'view_transaction' => array( |
667 | - 'label' => __( 'View related Transaction', 'event_espresso' ), |
|
667 | + 'label' => __('View related Transaction', 'event_espresso'), |
|
668 | 668 | 'css_class' => 'dashicons dashicons-cart', |
669 | 669 | ) |
670 | 670 | ) |
@@ -683,9 +683,9 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return string |
685 | 685 | */ |
686 | - public static function get_message_action_url( $type, EE_Message $message = null, $query_params = array() ) { |
|
687 | - $action_urls = self::get_message_action_urls( $message, $query_params ); |
|
688 | - return isset( $action_urls[ $type ] ) ? $action_urls[ $type ] : ''; |
|
686 | + public static function get_message_action_url($type, EE_Message $message = null, $query_params = array()) { |
|
687 | + $action_urls = self::get_message_action_urls($message, $query_params); |
|
688 | + return isset($action_urls[$type]) ? $action_urls[$type] : ''; |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -700,15 +700,15 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @return array |
702 | 702 | */ |
703 | - public static function get_message_action_urls( EE_Message $message = null, $query_params = array() ) { |
|
704 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
703 | + public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) { |
|
704 | + EE_Registry::instance()->load_helper('URL'); |
|
705 | 705 | //if $message is not an instance of EE_Message then let's just do a dummy. |
706 | - $message = empty( $message ) ? EE_Message_Factory::create() : $message; |
|
707 | - $action_urls = apply_filters( |
|
706 | + $message = empty($message) ? EE_Message_Factory::create() : $message; |
|
707 | + $action_urls = apply_filters( |
|
708 | 708 | 'FHEE__EEH_MSG_Template__get_message_action_url', |
709 | 709 | array( |
710 | - 'view' => EEH_MSG_Template::generate_browser_trigger( $message ), |
|
711 | - 'error' => EEH_MSG_Template::generate_error_display_trigger( $message ), |
|
710 | + 'view' => EEH_MSG_Template::generate_browser_trigger($message), |
|
711 | + 'error' => EEH_MSG_Template::generate_error_display_trigger($message), |
|
712 | 712 | 'see_notifications_for' => EEH_URL::add_query_args_and_nonce( |
713 | 713 | array_merge( |
714 | 714 | array( |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | ), |
719 | 719 | $query_params |
720 | 720 | ), |
721 | - admin_url( 'admin.php' ) |
|
721 | + admin_url('admin.php') |
|
722 | 722 | ), |
723 | 723 | 'generate_now' => EEH_URL::add_query_args_and_nonce( |
724 | 724 | array( |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | 'action' => 'generate_now', |
727 | 727 | 'MSG_ID' => $message->ID() |
728 | 728 | ), |
729 | - admin_url( 'admin.php' ) |
|
729 | + admin_url('admin.php') |
|
730 | 730 | ), |
731 | 731 | 'send_now' => EEH_URL::add_query_args_and_nonce( |
732 | 732 | array( |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | 'action' => 'send_now', |
735 | 735 | 'MSG_ID' => $message->ID() |
736 | 736 | ), |
737 | - admin_url( 'admin.php' ) |
|
737 | + admin_url('admin.php') |
|
738 | 738 | ), |
739 | 739 | 'queue_for_resending' => EEH_URL::add_query_args_and_nonce( |
740 | 740 | array( |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | 'action' => 'queue_for_resending', |
743 | 743 | 'MSG_ID' => $message->ID() |
744 | 744 | ), |
745 | - admin_url( 'admin.php' ) |
|
745 | + admin_url('admin.php') |
|
746 | 746 | ), |
747 | 747 | ) |
748 | 748 | ); |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | 'action' => 'view_transaction', |
761 | 761 | 'TXN_ID' => $message->TXN_ID() |
762 | 762 | ), |
763 | - admin_url( 'admin.php' ) |
|
763 | + admin_url('admin.php') |
|
764 | 764 | ); |
765 | 765 | } else { |
766 | 766 | $action_urls['view_transaction'] = ''; |
@@ -781,26 +781,26 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return string |
783 | 783 | */ |
784 | - public static function get_message_action_link( $type, EE_Message $message = null, $query_params = array() ) { |
|
785 | - $url = EEH_MSG_Template::get_message_action_url( $type, $message, $query_params ); |
|
786 | - $icon_css = EEH_MSG_Template::get_message_action_icon( $type ); |
|
787 | - $title = isset( $icon_css['label'] ) ? 'title="' . $icon_css['label'] . '"' : ''; |
|
784 | + public static function get_message_action_link($type, EE_Message $message = null, $query_params = array()) { |
|
785 | + $url = EEH_MSG_Template::get_message_action_url($type, $message, $query_params); |
|
786 | + $icon_css = EEH_MSG_Template::get_message_action_icon($type); |
|
787 | + $title = isset($icon_css['label']) ? 'title="'.$icon_css['label'].'"' : ''; |
|
788 | 788 | |
789 | - if ( empty( $url ) || empty( $icon_css ) || ! isset( $icon_css['css_class'] ) ) { |
|
789 | + if (empty($url) || empty($icon_css) || ! isset($icon_css['css_class'])) { |
|
790 | 790 | return ''; |
791 | 791 | } |
792 | 792 | |
793 | 793 | $icon_css['css_class'] .= esc_attr( |
794 | 794 | apply_filters( |
795 | 795 | 'FHEE__EEH_MSG_Template__get_message_action_link__icon_css_class', |
796 | - ' js-ee-message-action-link ee-message-action-link-' . $type, |
|
796 | + ' js-ee-message-action-link ee-message-action-link-'.$type, |
|
797 | 797 | $type, |
798 | 798 | $message, |
799 | 799 | $query_params |
800 | 800 | ) |
801 | 801 | ); |
802 | 802 | |
803 | - return '<a href="' . $url . '"' . $title . '><span class="' . esc_attr( $icon_css['css_class'] ) . '"></span></a>'; |
|
803 | + return '<a href="'.$url.'"'.$title.'><span class="'.esc_attr($icon_css['css_class']).'"></span></a>'; |
|
804 | 804 | |
805 | 805 | } |
806 | 806 | |
@@ -838,9 +838,9 @@ discard block |
||
838 | 838 | * @param $reg_status |
839 | 839 | * @return string |
840 | 840 | */ |
841 | - public static function convert_reg_status_to_message_type( $reg_status ) { |
|
841 | + public static function convert_reg_status_to_message_type($reg_status) { |
|
842 | 842 | $reg_status_array = self::reg_status_to_message_type_array(); |
843 | - return isset( $reg_status_array[$reg_status] ) ? $reg_status_array[$reg_status] : ''; |
|
843 | + return isset($reg_status_array[$reg_status]) ? $reg_status_array[$reg_status] : ''; |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | |
@@ -874,9 +874,9 @@ discard block |
||
874 | 874 | * @param $payment_status |
875 | 875 | * @return string |
876 | 876 | */ |
877 | - public static function convert_payment_status_to_message_type( $payment_status ) { |
|
877 | + public static function convert_payment_status_to_message_type($payment_status) { |
|
878 | 878 | $payment_status_array = self::payment_status_to_message_type_array(); |
879 | - return isset( $payment_status_array[$payment_status] ) ? $payment_status_array[$payment_status] : ''; |
|
879 | + return isset($payment_status_array[$payment_status]) ? $payment_status_array[$payment_status] : ''; |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | |
@@ -887,32 +887,32 @@ discard block |
||
887 | 887 | * |
888 | 888 | * @return EE_Messages_Template_Pack |
889 | 889 | */ |
890 | - public static function get_template_pack( $template_pack_name ) { |
|
891 | - if ( ! self::$_template_pack_collection instanceof EE_Object_Collection ) { |
|
890 | + public static function get_template_pack($template_pack_name) { |
|
891 | + if ( ! self::$_template_pack_collection instanceof EE_Object_Collection) { |
|
892 | 892 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
893 | 893 | } |
894 | 894 | |
895 | 895 | //first see if in collection already |
896 | - $template_pack = self::$_template_pack_collection->get_by_name( $template_pack_name ); |
|
896 | + $template_pack = self::$_template_pack_collection->get_by_name($template_pack_name); |
|
897 | 897 | |
898 | - if ( $template_pack instanceof EE_Messages_Template_Pack ) { |
|
898 | + if ($template_pack instanceof EE_Messages_Template_Pack) { |
|
899 | 899 | return $template_pack; |
900 | 900 | } |
901 | 901 | |
902 | 902 | //nope...let's get it. |
903 | 903 | //not set yet so let's attempt to get it. |
904 | - $pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
904 | + $pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
905 | 905 | ' ', |
906 | 906 | '_', |
907 | 907 | ucwords( |
908 | - str_replace( '_', ' ', $template_pack_name ) |
|
908 | + str_replace('_', ' ', $template_pack_name) |
|
909 | 909 | ) |
910 | 910 | ); |
911 | - if ( ! class_exists( $pack_class_name ) && $template_pack_name !== 'default' ) { |
|
912 | - return self::get_template_pack( 'default' ); |
|
911 | + if ( ! class_exists($pack_class_name) && $template_pack_name !== 'default') { |
|
912 | + return self::get_template_pack('default'); |
|
913 | 913 | } else { |
914 | 914 | $template_pack = new $pack_class_name; |
915 | - self::$_template_pack_collection->add( $template_pack ); |
|
915 | + self::$_template_pack_collection->add($template_pack); |
|
916 | 916 | return $template_pack; |
917 | 917 | } |
918 | 918 | } |
@@ -930,26 +930,26 @@ discard block |
||
930 | 930 | */ |
931 | 931 | public static function get_template_pack_collection() { |
932 | 932 | $new_collection = false; |
933 | - if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection ) { |
|
933 | + if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection) { |
|
934 | 934 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
935 | 935 | $new_collection = true; |
936 | 936 | } |
937 | 937 | |
938 | 938 | //glob the defaults directory for messages |
939 | - $templates = glob( EE_LIBRARIES . 'messages/defaults/*', GLOB_ONLYDIR ); |
|
940 | - foreach( $templates as $template_path ) { |
|
939 | + $templates = glob(EE_LIBRARIES.'messages/defaults/*', GLOB_ONLYDIR); |
|
940 | + foreach ($templates as $template_path) { |
|
941 | 941 | //grab folder name |
942 | - $template = basename( $template_path ); |
|
942 | + $template = basename($template_path); |
|
943 | 943 | |
944 | - if ( ! $new_collection ) { |
|
944 | + if ( ! $new_collection) { |
|
945 | 945 | //already have it? |
946 | - if ( self::$_template_pack_collection->get_by_name( $template ) instanceof EE_Messages_Template_Pack ) { |
|
946 | + if (self::$_template_pack_collection->get_by_name($template) instanceof EE_Messages_Template_Pack) { |
|
947 | 947 | continue; |
948 | 948 | } |
949 | 949 | } |
950 | 950 | |
951 | 951 | //setup classname. |
952 | - $template_pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
952 | + $template_pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
953 | 953 | ' ', |
954 | 954 | '_', |
955 | 955 | ucwords( |
@@ -960,20 +960,20 @@ discard block |
||
960 | 960 | ) |
961 | 961 | ) |
962 | 962 | ); |
963 | - if ( ! class_exists( $template_pack_class_name ) ) { |
|
963 | + if ( ! class_exists($template_pack_class_name)) { |
|
964 | 964 | continue; |
965 | 965 | } |
966 | - self::$_template_pack_collection->add( new $template_pack_class_name ); |
|
966 | + self::$_template_pack_collection->add(new $template_pack_class_name); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | /** |
970 | 970 | * Filter for plugins to add in any additional template packs |
971 | 971 | * Note the filter name here is for backward compat, this used to be found in EED_Messages. |
972 | 972 | */ |
973 | - $additional_template_packs = apply_filters( 'FHEE__EED_Messages__get_template_packs__template_packs', array() ); |
|
974 | - foreach ( (array) $additional_template_packs as $template_pack ) { |
|
975 | - if ( ! self::$_template_pack_collection->contains($template_pack ) ) { |
|
976 | - self::$_template_pack_collection->add( $template_pack ); |
|
973 | + $additional_template_packs = apply_filters('FHEE__EED_Messages__get_template_packs__template_packs', array()); |
|
974 | + foreach ((array) $additional_template_packs as $template_pack) { |
|
975 | + if ( ! self::$_template_pack_collection->contains($template_pack)) { |
|
976 | + self::$_template_pack_collection->add($template_pack); |
|
977 | 977 | } |
978 | 978 | } |
979 | 979 | return self::$_template_pack_collection; |
@@ -991,16 +991,16 @@ discard block |
||
991 | 991 | * @return array |
992 | 992 | * @throws \EE_Error |
993 | 993 | */ |
994 | - public static function create_new_templates( $messenger_name, $message_type_name, $GRP_ID = 0, $global = false ) { |
|
994 | + public static function create_new_templates($messenger_name, $message_type_name, $GRP_ID = 0, $global = false) { |
|
995 | 995 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
996 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
997 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
998 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
999 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type, $global ) ) { |
|
996 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
997 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
998 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
999 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type, $global)) { |
|
1000 | 1000 | return array(); |
1001 | 1001 | } |
1002 | 1002 | //whew made it this far! Okay, let's go ahead and create the templates then |
1003 | - return EEH_MSG_Template::_create_new_templates( $messenger, $message_type, $GRP_ID, $global ); |
|
1003 | + return EEH_MSG_Template::_create_new_templates($messenger, $message_type, $GRP_ID, $global); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | |
@@ -1012,15 +1012,15 @@ discard block |
||
1012 | 1012 | * @param $global |
1013 | 1013 | * @return array|mixed |
1014 | 1014 | */ |
1015 | - protected static function _create_new_templates( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) { |
|
1015 | + protected static function _create_new_templates(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global) { |
|
1016 | 1016 | //if we're creating a custom template then we don't need to use the defaults class |
1017 | - if ( ! $global ) { |
|
1018 | - return EEH_MSG_Template::_create_custom_template_group( $messenger, $message_type, $GRP_ID ); |
|
1017 | + if ( ! $global) { |
|
1018 | + return EEH_MSG_Template::_create_custom_template_group($messenger, $message_type, $GRP_ID); |
|
1019 | 1019 | } |
1020 | 1020 | /** @type EE_Messages_Template_Defaults $Message_Template_Defaults */ |
1021 | 1021 | $Message_Template_Defaults = EE_Registry::factory( |
1022 | 1022 | 'EE_Messages_Template_Defaults', |
1023 | - array( $messenger, $message_type, $GRP_ID ) |
|
1023 | + array($messenger, $message_type, $GRP_ID) |
|
1024 | 1024 | ); |
1025 | 1025 | //generate templates |
1026 | 1026 | $success = $Message_Template_Defaults->create_new_templates(); |
@@ -1028,10 +1028,10 @@ discard block |
||
1028 | 1028 | //if creating the template failed. Then we should deactivate the related message_type for the messenger because |
1029 | 1029 | //its not active if it doesn't have a template. Note this is only happening for GLOBAL template creation |
1030 | 1030 | //attempts. |
1031 | - if ( ! $success ) { |
|
1031 | + if ( ! $success) { |
|
1032 | 1032 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
1033 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1034 | - $message_resource_manager->deactivate_message_type_for_messenger( $message_type->name, $messenger->name ); |
|
1033 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1034 | + $message_resource_manager->deactivate_message_type_for_messenger($message_type->name, $messenger->name); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | /** |
@@ -1059,11 +1059,11 @@ discard block |
||
1059 | 1059 | * ) |
1060 | 1060 | * @access private |
1061 | 1061 | */ |
1062 | - private static function _create_custom_template_group( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID ) { |
|
1062 | + private static function _create_custom_template_group(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID) { |
|
1063 | 1063 | //defaults |
1064 | - $success = array( 'GRP_ID' => null, 'MTP_context' => '' ); |
|
1064 | + $success = array('GRP_ID' => null, 'MTP_context' => ''); |
|
1065 | 1065 | //get the template group to use as a template from the db. If $GRP_ID is empty then we'll assume the base will be the global template matching the messenger and message type. |
1066 | - $Message_Template_Group = empty( $GRP_ID ) |
|
1066 | + $Message_Template_Group = empty($GRP_ID) |
|
1067 | 1067 | ? EEM_Message_Template_Group::instance()->get_one( |
1068 | 1068 | array( |
1069 | 1069 | array( |
@@ -1073,9 +1073,9 @@ discard block |
||
1073 | 1073 | ) |
1074 | 1074 | ) |
1075 | 1075 | ) |
1076 | - : EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1076 | + : EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1077 | 1077 | //if we don't have a mtg at this point then we need to bail. |
1078 | - if ( ! $Message_Template_Group instanceof EE_Message_Template_Group ) { |
|
1078 | + if ( ! $Message_Template_Group instanceof EE_Message_Template_Group) { |
|
1079 | 1079 | EE_Error::add_error( |
1080 | 1080 | sprintf( |
1081 | 1081 | __( |
@@ -1094,42 +1094,42 @@ discard block |
||
1094 | 1094 | $message_templates = $Message_Template_Group->message_templates(); |
1095 | 1095 | //now we have what we need to setup the new template |
1096 | 1096 | $new_mtg = clone $Message_Template_Group; |
1097 | - $new_mtg->set( 'GRP_ID', 0 ); |
|
1098 | - $new_mtg->set( 'MTP_is_global', false ); |
|
1099 | - $template_name = defined( 'DOING_AJAX' ) && ! empty( $_POST[ 'templateName' ] ) |
|
1100 | - ? $_POST[ 'templateName' ] |
|
1097 | + $new_mtg->set('GRP_ID', 0); |
|
1098 | + $new_mtg->set('MTP_is_global', false); |
|
1099 | + $template_name = defined('DOING_AJAX') && ! empty($_POST['templateName']) |
|
1100 | + ? $_POST['templateName'] |
|
1101 | 1101 | : __( |
1102 | 1102 | 'New Custom Template', |
1103 | 1103 | 'event_espresso' |
1104 | 1104 | ); |
1105 | - $template_description = defined( "DOING_AJAX" ) && ! empty( $_POST[ 'templateDescription' ] ) |
|
1106 | - ? $_POST[ 'templateDescription' ] |
|
1105 | + $template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription']) |
|
1106 | + ? $_POST['templateDescription'] |
|
1107 | 1107 | : sprintf( |
1108 | 1108 | __( |
1109 | 1109 | 'This is a custom template that was created for the %s messenger and %s message type.', |
1110 | 1110 | 'event_espresso' |
1111 | 1111 | ), |
1112 | - $new_mtg->messenger_obj()->label[ 'singular' ], |
|
1113 | - $new_mtg->message_type_obj()->label[ 'singular' ] |
|
1112 | + $new_mtg->messenger_obj()->label['singular'], |
|
1113 | + $new_mtg->message_type_obj()->label['singular'] |
|
1114 | 1114 | ); |
1115 | - $new_mtg->set( 'MTP_name', $template_name ); |
|
1116 | - $new_mtg->set( 'MTP_description', $template_description ); |
|
1115 | + $new_mtg->set('MTP_name', $template_name); |
|
1116 | + $new_mtg->set('MTP_description', $template_description); |
|
1117 | 1117 | //remove ALL relations on this template group so they don't get saved! |
1118 | - $new_mtg->_remove_relations( 'Message_Template' ); |
|
1118 | + $new_mtg->_remove_relations('Message_Template'); |
|
1119 | 1119 | $new_mtg->save(); |
1120 | - $success[ 'GRP_ID' ] = $new_mtg->ID(); |
|
1121 | - $success[ 'template_name' ] = $template_name; |
|
1120 | + $success['GRP_ID'] = $new_mtg->ID(); |
|
1121 | + $success['template_name'] = $template_name; |
|
1122 | 1122 | //add new message templates and add relation to. |
1123 | - foreach ( $message_templates as $message_template ) { |
|
1124 | - if ( ! $message_template instanceof EE_Message_Template ) { |
|
1123 | + foreach ($message_templates as $message_template) { |
|
1124 | + if ( ! $message_template instanceof EE_Message_Template) { |
|
1125 | 1125 | continue; |
1126 | 1126 | } |
1127 | 1127 | $new_message_template = clone $message_template; |
1128 | - $new_message_template->set( 'MTP_ID', 0 ); |
|
1129 | - $new_message_template->set( 'GRP_ID', $new_mtg->ID() ); //relation |
|
1128 | + $new_message_template->set('MTP_ID', 0); |
|
1129 | + $new_message_template->set('GRP_ID', $new_mtg->ID()); //relation |
|
1130 | 1130 | $new_message_template->save(); |
1131 | - if ( empty( $success[ 'MTP_context' ] ) ) { |
|
1132 | - $success[ 'MTP_context' ] = $new_message_template->get( 'MTP_context' ); |
|
1131 | + if (empty($success['MTP_context'])) { |
|
1132 | + $success['MTP_context'] = $new_message_template->get('MTP_context'); |
|
1133 | 1133 | } |
1134 | 1134 | } |
1135 | 1135 | return $success; |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | $global = false |
1152 | 1152 | ) { |
1153 | 1153 | //is given message_type valid for given messenger (if this is not a global save) |
1154 | - if ( $global ) { |
|
1154 | + if ($global) { |
|
1155 | 1155 | return true; |
1156 | 1156 | } |
1157 | 1157 | $active_templates = EEM_Message_Template_Group::instance()->count( |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | ) |
1164 | 1164 | ) |
1165 | 1165 | ); |
1166 | - if ( $active_templates > 0 ) { |
|
1166 | + if ($active_templates > 0) { |
|
1167 | 1167 | return true; |
1168 | 1168 | } |
1169 | 1169 | EE_Error::add_error( |
@@ -1192,24 +1192,24 @@ discard block |
||
1192 | 1192 | * @param string $message_type_name name of EE_message_type |
1193 | 1193 | * @return array |
1194 | 1194 | */ |
1195 | - public static function get_fields( $messenger_name, $message_type_name ) { |
|
1195 | + public static function get_fields($messenger_name, $message_type_name) { |
|
1196 | 1196 | $template_fields = array(); |
1197 | 1197 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
1198 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1199 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
1200 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
1201 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type ) ) { |
|
1198 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1199 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
1200 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
1201 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type)) { |
|
1202 | 1202 | return array(); |
1203 | 1203 | } |
1204 | 1204 | //okay now let's assemble an array with the messenger template fields added to the message_type contexts. |
1205 | - foreach ( $message_type->get_contexts() as $context => $details ) { |
|
1206 | - foreach ( $messenger->get_template_fields() as $field => $value ) { |
|
1207 | - $template_fields[ $context ][ $field ] = $value; |
|
1205 | + foreach ($message_type->get_contexts() as $context => $details) { |
|
1206 | + foreach ($messenger->get_template_fields() as $field => $value) { |
|
1207 | + $template_fields[$context][$field] = $value; |
|
1208 | 1208 | } |
1209 | 1209 | } |
1210 | - if ( empty( $template_fields ) ) { |
|
1210 | + if (empty($template_fields)) { |
|
1211 | 1211 | EE_Error::add_error( |
1212 | - __( 'Something went wrong and we couldn\'t get any templates assembled', 'event_espresso' ), |
|
1212 | + __('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), |
|
1213 | 1213 | __FILE__, |
1214 | 1214 | __FUNCTION__, |
1215 | 1215 | __LINE__ |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public static function instance() { |
135 | 135 | // check if class object is instantiated, and instantiated properly |
136 | - if ( ! self::$_instance instanceof EE_Config ) { |
|
136 | + if ( ! self::$_instance instanceof EE_Config) { |
|
137 | 137 | self::$_instance = new self(); |
138 | 138 | } |
139 | 139 | return self::$_instance; |
@@ -153,20 +153,20 @@ discard block |
||
153 | 153 | * site was put into maintenance mode) |
154 | 154 | * @return EE_Config |
155 | 155 | */ |
156 | - public static function reset( $hard_reset = false, $reinstantiate = true ) { |
|
157 | - if ( $hard_reset ) { |
|
156 | + public static function reset($hard_reset = false, $reinstantiate = true) { |
|
157 | + if ($hard_reset) { |
|
158 | 158 | self::$_instance->_addon_option_names = array(); |
159 | 159 | self::$_instance->_initialize_config(); |
160 | 160 | self::$_instance->update_espresso_config(); |
161 | 161 | } |
162 | - if ( self::$_instance instanceof EE_Config ) { |
|
162 | + if (self::$_instance instanceof EE_Config) { |
|
163 | 163 | self::$_instance->update_addon_option_names(); |
164 | 164 | } |
165 | 165 | self::$_instance = null; |
166 | 166 | //we don't need to reset the static properties imo because those should |
167 | 167 | //only change when a module is added or removed. Currently we don't |
168 | 168 | //support removing a module during a request when it previously existed |
169 | - if ( $reinstantiate ) { |
|
169 | + if ($reinstantiate) { |
|
170 | 170 | return self::instance(); |
171 | 171 | } else { |
172 | 172 | return null; |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | * @access private |
182 | 182 | */ |
183 | 183 | private function __construct() { |
184 | - do_action( 'AHEE__EE_Config__construct__begin', $this ); |
|
185 | - EE_Config::$_logging_enabled = apply_filters( 'FHEE__EE_Config___construct__logging_enabled', false ); |
|
184 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
185 | + EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
186 | 186 | // setup empty config classes |
187 | 187 | $this->_initialize_config(); |
188 | 188 | // load existing EE site settings |
@@ -192,17 +192,17 @@ discard block |
||
192 | 192 | // register shortcodes and modules |
193 | 193 | add_action( |
194 | 194 | 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
195 | - array( $this, 'register_shortcodes_and_modules' ), |
|
195 | + array($this, 'register_shortcodes_and_modules'), |
|
196 | 196 | 999 |
197 | 197 | ); |
198 | 198 | // initialize shortcodes and modules |
199 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'initialize_shortcodes_and_modules' ) ); |
|
199 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
200 | 200 | // register widgets |
201 | - add_action( 'widgets_init', array( $this, 'widgets_init' ), 10 ); |
|
201 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
202 | 202 | // shutdown |
203 | - add_action( 'shutdown', array( $this, 'shutdown' ), 10 ); |
|
203 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
204 | 204 | // construct__end hook |
205 | - do_action( 'AHEE__EE_Config__construct__end', $this ); |
|
205 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
206 | 206 | // hardcoded hack |
207 | 207 | $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
208 | 208 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @return string current theme set. |
225 | 225 | */ |
226 | 226 | public static function get_current_theme() { |
227 | - return isset( self::$_instance->template_settings->current_espresso_theme ) |
|
227 | + return isset(self::$_instance->template_settings->current_espresso_theme) |
|
228 | 228 | ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
229 | 229 | } |
230 | 230 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | private function _initialize_config() { |
240 | 240 | EE_Config::trim_log(); |
241 | 241 | //set defaults |
242 | - $this->_addon_option_names = get_option( EE_Config::ADDON_OPTION_NAMES, array() ); |
|
242 | + $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
243 | 243 | $this->addons = new stdClass(); |
244 | 244 | // set _module_route_map |
245 | 245 | EE_Config::$_module_route_map = array(); |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | */ |
260 | 260 | private function _load_core_config() { |
261 | 261 | // load_core_config__start hook |
262 | - do_action( 'AHEE__EE_Config___load_core_config__start', $this ); |
|
262 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
263 | 263 | $espresso_config = $this->get_espresso_config(); |
264 | - foreach ( $espresso_config as $config => $settings ) { |
|
264 | + foreach ($espresso_config as $config => $settings) { |
|
265 | 265 | // load_core_config__start hook |
266 | 266 | $settings = apply_filters( |
267 | 267 | 'FHEE__EE_Config___load_core_config__config_settings', |
@@ -269,22 +269,22 @@ discard block |
||
269 | 269 | $config, |
270 | 270 | $this |
271 | 271 | ); |
272 | - if ( is_object( $settings ) && property_exists( $this, $config ) ) { |
|
273 | - $this->{$config} = apply_filters( 'FHEE__EE_Config___load_core_config__' . $config, $settings ); |
|
272 | + if (is_object($settings) && property_exists($this, $config)) { |
|
273 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings); |
|
274 | 274 | //call configs populate method to ensure any defaults are set for empty values. |
275 | - if ( method_exists( $settings, 'populate' ) ) { |
|
275 | + if (method_exists($settings, 'populate')) { |
|
276 | 276 | $this->{$config}->populate(); |
277 | 277 | } |
278 | - if ( method_exists( $settings, 'do_hooks' ) ) { |
|
278 | + if (method_exists($settings, 'do_hooks')) { |
|
279 | 279 | $this->{$config}->do_hooks(); |
280 | 280 | } |
281 | 281 | } |
282 | 282 | } |
283 | - if ( apply_filters( 'FHEE__EE_Config___load_core_config__update_espresso_config', false ) ) { |
|
283 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
284 | 284 | $this->update_espresso_config(); |
285 | 285 | } |
286 | 286 | // load_core_config__end hook |
287 | - do_action( 'AHEE__EE_Config___load_core_config__end', $this ); |
|
287 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -299,23 +299,23 @@ discard block |
||
299 | 299 | $this->core = $this->core instanceof EE_Core_Config |
300 | 300 | ? $this->core |
301 | 301 | : new EE_Core_Config(); |
302 | - $this->core = apply_filters( 'FHEE__EE_Config___initialize_config__core', $this->core ); |
|
302 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
303 | 303 | $this->organization = $this->organization instanceof EE_Organization_Config |
304 | 304 | ? $this->organization |
305 | 305 | : new EE_Organization_Config(); |
306 | - $this->organization = apply_filters( 'FHEE__EE_Config___initialize_config__organization', $this->organization ); |
|
306 | + $this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', $this->organization); |
|
307 | 307 | $this->currency = $this->currency instanceof EE_Currency_Config |
308 | 308 | ? $this->currency |
309 | 309 | : new EE_Currency_Config(); |
310 | - $this->currency = apply_filters( 'FHEE__EE_Config___initialize_config__currency', $this->currency ); |
|
310 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
311 | 311 | $this->registration = $this->registration instanceof EE_Registration_Config |
312 | 312 | ? $this->registration |
313 | 313 | : new EE_Registration_Config(); |
314 | - $this->registration = apply_filters( 'FHEE__EE_Config___initialize_config__registration', $this->registration ); |
|
314 | + $this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', $this->registration); |
|
315 | 315 | $this->admin = $this->admin instanceof EE_Admin_Config |
316 | 316 | ? $this->admin |
317 | 317 | : new EE_Admin_Config(); |
318 | - $this->admin = apply_filters( 'FHEE__EE_Config___initialize_config__admin', $this->admin ); |
|
318 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
319 | 319 | $this->template_settings = $this->template_settings instanceof EE_Template_Config |
320 | 320 | ? $this->template_settings |
321 | 321 | : new EE_Template_Config(); |
@@ -326,19 +326,19 @@ discard block |
||
326 | 326 | $this->map_settings = $this->map_settings instanceof EE_Map_Config |
327 | 327 | ? $this->map_settings |
328 | 328 | : new EE_Map_Config(); |
329 | - $this->map_settings = apply_filters( 'FHEE__EE_Config___initialize_config__map_settings', $this->map_settings ); |
|
329 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', $this->map_settings); |
|
330 | 330 | $this->environment = $this->environment instanceof EE_Environment_Config |
331 | 331 | ? $this->environment |
332 | 332 | : new EE_Environment_Config(); |
333 | - $this->environment = apply_filters( 'FHEE__EE_Config___initialize_config__environment', $this->environment ); |
|
333 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', $this->environment); |
|
334 | 334 | $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
335 | 335 | ? $this->tax_settings |
336 | 336 | : new EE_Tax_Config(); |
337 | - $this->tax_settings = apply_filters( 'FHEE__EE_Config___initialize_config__tax_settings', $this->tax_settings ); |
|
337 | + $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', $this->tax_settings); |
|
338 | 338 | $this->gateway = $this->gateway instanceof EE_Gateway_Config |
339 | 339 | ? $this->gateway |
340 | 340 | : new EE_Gateway_Config(); |
341 | - $this->gateway = apply_filters( 'FHEE__EE_Config___initialize_config__gateway', $this->gateway ); |
|
341 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | // grab espresso configuration |
354 | 354 | return apply_filters( |
355 | 355 | 'FHEE__EE_Config__get_espresso_config__CFG', |
356 | - get_option( EE_Config::OPTION_NAME, array() ) |
|
356 | + get_option(EE_Config::OPTION_NAME, array()) |
|
357 | 357 | ); |
358 | 358 | } |
359 | 359 | |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | * @param $old_value |
368 | 368 | * @param $value |
369 | 369 | */ |
370 | - public function double_check_config_comparison( $option = '', $old_value, $value ) { |
|
370 | + public function double_check_config_comparison($option = '', $old_value, $value) { |
|
371 | 371 | // make sure we're checking the ee config |
372 | - if ( $option === EE_Config::OPTION_NAME ) { |
|
372 | + if ($option === EE_Config::OPTION_NAME) { |
|
373 | 373 | // run a loose comparison of the old value against the new value for type and properties, |
374 | 374 | // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
375 | - if ( $value != $old_value ) { |
|
375 | + if ($value != $old_value) { |
|
376 | 376 | // if they are NOT the same, then remove the hook, |
377 | 377 | // which means the subsequent update results will be based solely on the update query results |
378 | 378 | // the reason we do this is because, as stated above, |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | // the string it sees in the db looks the same as the new one it has been passed!!! |
388 | 388 | // This results in the query returning an "affected rows" value of ZERO, |
389 | 389 | // which gets returned immediately by WP update_option and looks like an error. |
390 | - remove_action( 'update_option', array( $this, 'check_config_updated' ) ); |
|
390 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | } |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | */ |
402 | 402 | protected function _reset_espresso_addon_config() { |
403 | 403 | $this->_addon_option_names = array(); |
404 | - foreach ( $this->addons as $addon_name => $addon_config_obj ) { |
|
405 | - $addon_config_obj = maybe_unserialize( $addon_config_obj ); |
|
406 | - $config_class = get_class( $addon_config_obj ); |
|
407 | - if ( $addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class ) { |
|
408 | - $this->update_config( 'addons', $addon_name, $addon_config_obj, false ); |
|
404 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
405 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
406 | + $config_class = get_class($addon_config_obj); |
|
407 | + if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
408 | + $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
409 | 409 | } |
410 | 410 | $this->addons->{$addon_name} = null; |
411 | 411 | } |
@@ -421,22 +421,22 @@ discard block |
||
421 | 421 | * @param bool $add_error |
422 | 422 | * @return bool |
423 | 423 | */ |
424 | - public function update_espresso_config( $add_success = false, $add_error = true ) { |
|
424 | + public function update_espresso_config($add_success = false, $add_error = true) { |
|
425 | 425 | // don't allow config updates during WP heartbeats |
426 | - if ( \EE_Registry::instance()->REQ->get( 'action', '' ) === 'heartbeat' ) { |
|
426 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
427 | 427 | return false; |
428 | 428 | } |
429 | 429 | // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
430 | 430 | //$clone = clone( self::$_instance ); |
431 | 431 | //self::$_instance = NULL; |
432 | - do_action( 'AHEE__EE_Config__update_espresso_config__begin', $this ); |
|
432 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
433 | 433 | $this->_reset_espresso_addon_config(); |
434 | 434 | // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
435 | 435 | // but BEFORE the actual update occurs |
436 | - add_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1, 3 ); |
|
436 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
437 | 437 | // now update "ee_config" |
438 | - $saved = update_option( EE_Config::OPTION_NAME, $this ); |
|
439 | - EE_Config::log( EE_Config::OPTION_NAME ); |
|
438 | + $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
439 | + EE_Config::log(EE_Config::OPTION_NAME); |
|
440 | 440 | // if not saved... check if the hook we just added still exists; |
441 | 441 | // if it does, it means one of two things: |
442 | 442 | // that update_option bailed at the ( $value === $old_value ) conditional, |
@@ -447,17 +447,17 @@ discard block |
||
447 | 447 | // but just means no update occurred, so don't display an error to the user. |
448 | 448 | // BUT... if update_option returns FALSE, AND the hook is missing, |
449 | 449 | // then it means that something truly went wrong |
450 | - $saved = ! $saved ? has_action( 'update_option', array( $this, 'double_check_config_comparison' ) ) : $saved; |
|
450 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
451 | 451 | // remove our action since we don't want it in the system anymore |
452 | - remove_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1 ); |
|
453 | - do_action( 'AHEE__EE_Config__update_espresso_config__end', $this, $saved ); |
|
452 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
453 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
454 | 454 | //self::$_instance = $clone; |
455 | 455 | //unset( $clone ); |
456 | 456 | // if config remains the same or was updated successfully |
457 | - if ( $saved ) { |
|
458 | - if ( $add_success ) { |
|
457 | + if ($saved) { |
|
458 | + if ($add_success) { |
|
459 | 459 | EE_Error::add_success( |
460 | - __( 'The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso' ), |
|
460 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
461 | 461 | __FILE__, |
462 | 462 | __FUNCTION__, |
463 | 463 | __LINE__ |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | } |
466 | 466 | return true; |
467 | 467 | } else { |
468 | - if ( $add_error ) { |
|
468 | + if ($add_error) { |
|
469 | 469 | EE_Error::add_error( |
470 | - __( 'The Event Espresso Configuration Settings were not updated.', 'event_espresso' ), |
|
470 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
471 | 471 | __FILE__, |
472 | 472 | __FUNCTION__, |
473 | 473 | __LINE__ |
@@ -496,16 +496,16 @@ discard block |
||
496 | 496 | $name = '', |
497 | 497 | $config_class = '', |
498 | 498 | $config_obj = null, |
499 | - $tests_to_run = array( 1, 2, 3, 4, 5, 6, 7, 8 ), |
|
499 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
500 | 500 | $display_errors = true |
501 | 501 | ) { |
502 | 502 | try { |
503 | - foreach ( $tests_to_run as $test ) { |
|
504 | - switch ( $test ) { |
|
503 | + foreach ($tests_to_run as $test) { |
|
504 | + switch ($test) { |
|
505 | 505 | // TEST #1 : check that section was set |
506 | 506 | case 1 : |
507 | - if ( empty( $section ) ) { |
|
508 | - if ( $display_errors ) { |
|
507 | + if (empty($section)) { |
|
508 | + if ($display_errors) { |
|
509 | 509 | throw new EE_Error( |
510 | 510 | sprintf( |
511 | 511 | __( |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | break; |
522 | 522 | // TEST #2 : check that settings section exists |
523 | 523 | case 2 : |
524 | - if ( ! isset( $this->{$section} ) ) { |
|
525 | - if ( $display_errors ) { |
|
524 | + if ( ! isset($this->{$section} )) { |
|
525 | + if ($display_errors) { |
|
526 | 526 | throw new EE_Error( |
527 | 527 | sprintf( |
528 | - __( 'The "%s" configuration section does not exist.', 'event_espresso' ), |
|
528 | + __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
529 | 529 | $section |
530 | 530 | ) |
531 | 531 | ); |
@@ -536,9 +536,9 @@ discard block |
||
536 | 536 | // TEST #3 : check that section is the proper format |
537 | 537 | case 3 : |
538 | 538 | if ( |
539 | - ! ( $this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass ) |
|
539 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
540 | 540 | ) { |
541 | - if ( $display_errors ) { |
|
541 | + if ($display_errors) { |
|
542 | 542 | throw new EE_Error( |
543 | 543 | sprintf( |
544 | 544 | __( |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | break; |
555 | 555 | // TEST #4 : check that config section name has been set |
556 | 556 | case 4 : |
557 | - if ( empty( $name ) ) { |
|
558 | - if ( $display_errors ) { |
|
557 | + if (empty($name)) { |
|
558 | + if ($display_errors) { |
|
559 | 559 | throw new EE_Error( |
560 | 560 | __( |
561 | 561 | 'No name has been provided for the specific configuration section.', |
@@ -568,8 +568,8 @@ discard block |
||
568 | 568 | break; |
569 | 569 | // TEST #5 : check that a config class name has been set |
570 | 570 | case 5 : |
571 | - if ( empty( $config_class ) ) { |
|
572 | - if ( $display_errors ) { |
|
571 | + if (empty($config_class)) { |
|
572 | + if ($display_errors) { |
|
573 | 573 | throw new EE_Error( |
574 | 574 | __( |
575 | 575 | 'No class name has been provided for the specific configuration section.', |
@@ -582,8 +582,8 @@ discard block |
||
582 | 582 | break; |
583 | 583 | // TEST #6 : verify config class is accessible |
584 | 584 | case 6 : |
585 | - if ( ! class_exists( $config_class ) ) { |
|
586 | - if ( $display_errors ) { |
|
585 | + if ( ! class_exists($config_class)) { |
|
586 | + if ($display_errors) { |
|
587 | 587 | throw new EE_Error( |
588 | 588 | sprintf( |
589 | 589 | __( |
@@ -599,11 +599,11 @@ discard block |
||
599 | 599 | break; |
600 | 600 | // TEST #7 : check that config has even been set |
601 | 601 | case 7 : |
602 | - if ( ! isset( $this->{$section}->{$name} ) ) { |
|
603 | - if ( $display_errors ) { |
|
602 | + if ( ! isset($this->{$section}->{$name} )) { |
|
603 | + if ($display_errors) { |
|
604 | 604 | throw new EE_Error( |
605 | 605 | sprintf( |
606 | - __( 'No configuration has been set for "%1$s->%2$s".', 'event_espresso' ), |
|
606 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
607 | 607 | $section, |
608 | 608 | $name |
609 | 609 | ) |
@@ -612,13 +612,13 @@ discard block |
||
612 | 612 | return false; |
613 | 613 | } else { |
614 | 614 | // and make sure it's not serialized |
615 | - $this->{$section}->{$name} = maybe_unserialize( $this->{$section}->{$name} ); |
|
615 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name} ); |
|
616 | 616 | } |
617 | 617 | break; |
618 | 618 | // TEST #8 : check that config is the requested type |
619 | 619 | case 8 : |
620 | - if ( ! $this->{$section}->{$name} instanceof $config_class ) { |
|
621 | - if ( $display_errors ) { |
|
620 | + if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
621 | + if ($display_errors) { |
|
622 | 622 | throw new EE_Error( |
623 | 623 | sprintf( |
624 | 624 | __( |
@@ -636,12 +636,12 @@ discard block |
||
636 | 636 | break; |
637 | 637 | // TEST #9 : verify config object |
638 | 638 | case 9 : |
639 | - if ( ! $config_obj instanceof EE_Config_Base ) { |
|
640 | - if ( $display_errors ) { |
|
639 | + if ( ! $config_obj instanceof EE_Config_Base) { |
|
640 | + if ($display_errors) { |
|
641 | 641 | throw new EE_Error( |
642 | 642 | sprintf( |
643 | - __( 'The "%s" class is not an instance of EE_Config_Base.', 'event_espresso' ), |
|
644 | - print_r( $config_obj, true ) |
|
643 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
644 | + print_r($config_obj, true) |
|
645 | 645 | ) |
646 | 646 | ); |
647 | 647 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | break; |
651 | 651 | } |
652 | 652 | } |
653 | - } catch ( EE_Error $e ) { |
|
653 | + } catch (EE_Error $e) { |
|
654 | 654 | $e->get_error(); |
655 | 655 | } |
656 | 656 | // you have successfully run the gauntlet |
@@ -667,8 +667,8 @@ discard block |
||
667 | 667 | * @param string $name |
668 | 668 | * @return string |
669 | 669 | */ |
670 | - private function _generate_config_option_name( $section = '', $name = '' ) { |
|
671 | - return 'ee_config-' . strtolower( $section . '-' . str_replace( array( 'EE_', 'EED_' ), '', $name ) ); |
|
670 | + private function _generate_config_option_name($section = '', $name = '') { |
|
671 | + return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name)); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | |
@@ -682,10 +682,10 @@ discard block |
||
682 | 682 | * @param string $name |
683 | 683 | * @return string |
684 | 684 | */ |
685 | - private function _set_config_class( $config_class = '', $name = '' ) { |
|
686 | - return ! empty( $config_class ) |
|
685 | + private function _set_config_class($config_class = '', $name = '') { |
|
686 | + return ! empty($config_class) |
|
687 | 687 | ? $config_class |
688 | - : str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $name ) ) ) . '_Config'; |
|
688 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config'; |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -700,36 +700,36 @@ discard block |
||
700 | 700 | * @param EE_Config_Base $config_obj |
701 | 701 | * @return EE_Config_Base |
702 | 702 | */ |
703 | - public function set_config( $section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null ) { |
|
703 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) { |
|
704 | 704 | // ensure config class is set to something |
705 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
705 | + $config_class = $this->_set_config_class($config_class, $name); |
|
706 | 706 | // run tests 1-4, 6, and 7 to verify all config params are set and valid |
707 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ) ) ) { |
|
707 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
708 | 708 | return null; |
709 | 709 | } |
710 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
710 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
711 | 711 | // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
712 | - if ( ! isset( $this->_addon_option_names[ $config_option_name ] ) ) { |
|
713 | - $this->_addon_option_names[ $config_option_name ] = $config_class; |
|
712 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
713 | + $this->_addon_option_names[$config_option_name] = $config_class; |
|
714 | 714 | $this->update_addon_option_names(); |
715 | 715 | } |
716 | 716 | // verify the incoming config object but suppress errors |
717 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false ) ) { |
|
717 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
718 | 718 | $config_obj = new $config_class(); |
719 | 719 | } |
720 | - if ( get_option( $config_option_name ) ) { |
|
721 | - EE_Config::log( $config_option_name ); |
|
722 | - update_option( $config_option_name, $config_obj ); |
|
720 | + if (get_option($config_option_name)) { |
|
721 | + EE_Config::log($config_option_name); |
|
722 | + update_option($config_option_name, $config_obj); |
|
723 | 723 | $this->{$section}->{$name} = $config_obj; |
724 | 724 | return $this->{$section}->{$name}; |
725 | 725 | } else { |
726 | 726 | // create a wp-option for this config |
727 | - if ( add_option( $config_option_name, $config_obj, '', 'no' ) ) { |
|
728 | - $this->{$section}->{$name} = maybe_unserialize( $config_obj ); |
|
727 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
728 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
729 | 729 | return $this->{$section}->{$name}; |
730 | 730 | } else { |
731 | 731 | EE_Error::add_error( |
732 | - sprintf( __( 'The "%s" could not be saved to the database.', 'event_espresso' ), $config_class ), |
|
732 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
733 | 733 | __FILE__, |
734 | 734 | __FUNCTION__, |
735 | 735 | __LINE__ |
@@ -752,46 +752,46 @@ discard block |
||
752 | 752 | * @param bool $throw_errors |
753 | 753 | * @return bool |
754 | 754 | */ |
755 | - public function update_config( $section = '', $name = '', $config_obj = '', $throw_errors = true ) { |
|
755 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) { |
|
756 | 756 | // don't allow config updates during WP heartbeats |
757 | - if ( \EE_Registry::instance()->REQ->get( 'action', '' ) === 'heartbeat' ) { |
|
757 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
758 | 758 | return false; |
759 | 759 | } |
760 | - $config_obj = maybe_unserialize( $config_obj ); |
|
760 | + $config_obj = maybe_unserialize($config_obj); |
|
761 | 761 | // get class name of the incoming object |
762 | - $config_class = get_class( $config_obj ); |
|
762 | + $config_class = get_class($config_obj); |
|
763 | 763 | // run tests 1-5 and 9 to verify config |
764 | 764 | if ( ! $this->_verify_config_params( |
765 | 765 | $section, |
766 | 766 | $name, |
767 | 767 | $config_class, |
768 | 768 | $config_obj, |
769 | - array( 1, 2, 3, 4, 7, 9 ) |
|
769 | + array(1, 2, 3, 4, 7, 9) |
|
770 | 770 | ) |
771 | 771 | ) { |
772 | 772 | return false; |
773 | 773 | } |
774 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
774 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
775 | 775 | // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
776 | - if ( ! isset( $this->_addon_option_names[ $config_option_name ] ) ) { |
|
776 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
777 | 777 | // save new config to db |
778 | - if( $this->set_config( $section, $name, $config_class, $config_obj ) ) { |
|
778 | + if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
779 | 779 | return true; |
780 | 780 | } |
781 | 781 | } else { |
782 | 782 | // first check if the record already exists |
783 | - $existing_config = get_option( $config_option_name ); |
|
784 | - $config_obj = serialize( $config_obj ); |
|
783 | + $existing_config = get_option($config_option_name); |
|
784 | + $config_obj = serialize($config_obj); |
|
785 | 785 | // just return if db record is already up to date (NOT type safe comparison) |
786 | - if ( $existing_config == $config_obj ) { |
|
786 | + if ($existing_config == $config_obj) { |
|
787 | 787 | $this->{$section}->{$name} = $config_obj; |
788 | 788 | return true; |
789 | - } else if ( update_option( $config_option_name, $config_obj ) ) { |
|
790 | - EE_Config::log( $config_option_name ); |
|
789 | + } else if (update_option($config_option_name, $config_obj)) { |
|
790 | + EE_Config::log($config_option_name); |
|
791 | 791 | // update wp-option for this config class |
792 | 792 | $this->{$section}->{$name} = $config_obj; |
793 | 793 | return true; |
794 | - } elseif ( $throw_errors ) { |
|
794 | + } elseif ($throw_errors) { |
|
795 | 795 | EE_Error::add_error( |
796 | 796 | sprintf( |
797 | 797 | __( |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | 'event_espresso' |
800 | 800 | ), |
801 | 801 | $config_class, |
802 | - 'EE_Config->' . $section . '->' . $name |
|
802 | + 'EE_Config->'.$section.'->'.$name |
|
803 | 803 | ), |
804 | 804 | __FILE__, |
805 | 805 | __FUNCTION__, |
@@ -821,34 +821,34 @@ discard block |
||
821 | 821 | * @param string $config_class |
822 | 822 | * @return mixed EE_Config_Base | NULL |
823 | 823 | */ |
824 | - public function get_config( $section = '', $name = '', $config_class = '' ) { |
|
824 | + public function get_config($section = '', $name = '', $config_class = '') { |
|
825 | 825 | // ensure config class is set to something |
826 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
826 | + $config_class = $this->_set_config_class($config_class, $name); |
|
827 | 827 | // run tests 1-4, 6 and 7 to verify that all params have been set |
828 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ) ) ) { |
|
828 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
829 | 829 | return null; |
830 | 830 | } |
831 | 831 | // now test if the requested config object exists, but suppress errors |
832 | - if ( $this->_verify_config_params( $section, $name, $config_class, null, array( 7, 8 ), false ) ) { |
|
832 | + if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
833 | 833 | // config already exists, so pass it back |
834 | 834 | return $this->{$section}->{$name}; |
835 | 835 | } |
836 | 836 | // load config option from db if it exists |
837 | - $config_obj = $this->get_config_option( $this->_generate_config_option_name( $section, $name ) ); |
|
837 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
838 | 838 | // verify the newly retrieved config object, but suppress errors |
839 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false ) ) { |
|
839 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
840 | 840 | // config is good, so set it and pass it back |
841 | 841 | $this->{$section}->{$name} = $config_obj; |
842 | 842 | return $this->{$section}->{$name}; |
843 | 843 | } |
844 | 844 | // oops! $config_obj is not already set and does not exist in the db, so create a new one |
845 | - $config_obj = $this->set_config( $section, $name, $config_class ); |
|
845 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
846 | 846 | // verify the newly created config object |
847 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ) ) ) { |
|
847 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
848 | 848 | return $this->{$section}->{$name}; |
849 | 849 | } else { |
850 | 850 | EE_Error::add_error( |
851 | - sprintf( __( 'The "%s" could not be retrieved from the database.', 'event_espresso' ), $config_class ), |
|
851 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
852 | 852 | __FILE__, |
853 | 853 | __FUNCTION__, |
854 | 854 | __LINE__ |
@@ -866,11 +866,11 @@ discard block |
||
866 | 866 | * @param string $config_option_name |
867 | 867 | * @return mixed EE_Config_Base | FALSE |
868 | 868 | */ |
869 | - public function get_config_option( $config_option_name = '' ) { |
|
869 | + public function get_config_option($config_option_name = '') { |
|
870 | 870 | // retrieve the wp-option for this config class. |
871 | - $config_option = maybe_unserialize( get_option( $config_option_name, array() ) ); |
|
872 | - if ( empty( $config_option ) ) { |
|
873 | - EE_Config::log( $config_option_name . '-NOT-FOUND' ); |
|
871 | + $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
872 | + if (empty($config_option)) { |
|
873 | + EE_Config::log($config_option_name.'-NOT-FOUND'); |
|
874 | 874 | } |
875 | 875 | return $config_option; |
876 | 876 | } |
@@ -882,17 +882,17 @@ discard block |
||
882 | 882 | * |
883 | 883 | * @param string $config_option_name |
884 | 884 | */ |
885 | - public static function log( $config_option_name = '' ) { |
|
886 | - if ( EE_Config::logging_enabled() && ! empty( $config_option_name ) ) { |
|
887 | - $config_log = get_option( EE_Config::LOG_NAME, array() ); |
|
885 | + public static function log($config_option_name = '') { |
|
886 | + if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
887 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
888 | 888 | //copy incoming $_REQUEST and sanitize it so we can save it |
889 | 889 | $_request = $_REQUEST; |
890 | - array_walk_recursive( $_request, 'sanitize_text_field' ); |
|
891 | - $config_log[ (string) microtime( true ) ] = array( |
|
890 | + array_walk_recursive($_request, 'sanitize_text_field'); |
|
891 | + $config_log[(string) microtime(true)] = array( |
|
892 | 892 | 'config_name' => $config_option_name, |
893 | 893 | 'request' => $_request, |
894 | 894 | ); |
895 | - update_option( EE_Config::LOG_NAME, $config_log ); |
|
895 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | |
@@ -903,15 +903,15 @@ discard block |
||
903 | 903 | * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
904 | 904 | */ |
905 | 905 | public static function trim_log() { |
906 | - if ( ! EE_Config::logging_enabled() ) { |
|
906 | + if ( ! EE_Config::logging_enabled()) { |
|
907 | 907 | return; |
908 | 908 | } |
909 | - $config_log = maybe_unserialize( get_option( EE_Config::LOG_NAME, array() ) ); |
|
910 | - $log_length = count( $config_log ); |
|
911 | - if ( $log_length > EE_Config::LOG_LENGTH ) { |
|
912 | - ksort( $config_log ); |
|
913 | - $config_log = array_slice( $config_log, $log_length - EE_Config::LOG_LENGTH, null, true ); |
|
914 | - update_option( EE_Config::LOG_NAME, $config_log ); |
|
909 | + $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
910 | + $log_length = count($config_log); |
|
911 | + if ($log_length > EE_Config::LOG_LENGTH) { |
|
912 | + ksort($config_log); |
|
913 | + $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
914 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
915 | 915 | } |
916 | 916 | } |
917 | 917 | |
@@ -926,14 +926,14 @@ discard block |
||
926 | 926 | * @return string |
927 | 927 | */ |
928 | 928 | public static function get_page_for_posts() { |
929 | - $page_for_posts = get_option( 'page_for_posts' ); |
|
930 | - if ( ! $page_for_posts ) { |
|
929 | + $page_for_posts = get_option('page_for_posts'); |
|
930 | + if ( ! $page_for_posts) { |
|
931 | 931 | return 'posts'; |
932 | 932 | } |
933 | 933 | /** @type WPDB $wpdb */ |
934 | 934 | global $wpdb; |
935 | 935 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
936 | - return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts ) ); |
|
936 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | |
@@ -989,17 +989,17 @@ discard block |
||
989 | 989 | ) |
990 | 990 | ) { |
991 | 991 | // grab list of installed widgets |
992 | - $widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR ); |
|
992 | + $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR); |
|
993 | 993 | // filter list of modules to register |
994 | 994 | $widgets_to_register = apply_filters( |
995 | 995 | 'FHEE__EE_Config__register_widgets__widgets_to_register', |
996 | 996 | $widgets_to_register |
997 | 997 | ); |
998 | - if ( ! empty( $widgets_to_register ) ) { |
|
998 | + if ( ! empty($widgets_to_register)) { |
|
999 | 999 | // cycle thru widget folders |
1000 | - foreach ( $widgets_to_register as $widget_path ) { |
|
1000 | + foreach ($widgets_to_register as $widget_path) { |
|
1001 | 1001 | // add to list of installed widget modules |
1002 | - EE_Config::register_ee_widget( $widget_path ); |
|
1002 | + EE_Config::register_ee_widget($widget_path); |
|
1003 | 1003 | } |
1004 | 1004 | } |
1005 | 1005 | // filter list of installed modules |
@@ -1019,57 +1019,57 @@ discard block |
||
1019 | 1019 | * @param string $widget_path - full path up to and including widget folder |
1020 | 1020 | * @return void |
1021 | 1021 | */ |
1022 | - public static function register_ee_widget( $widget_path = null ) { |
|
1023 | - do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path ); |
|
1022 | + public static function register_ee_widget($widget_path = null) { |
|
1023 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
1024 | 1024 | $widget_ext = '.widget.php'; |
1025 | 1025 | // make all separators match |
1026 | - $widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS ); |
|
1026 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
1027 | 1027 | // does the file path INCLUDE the actual file name as part of the path ? |
1028 | - if ( strpos( $widget_path, $widget_ext ) !== false ) { |
|
1028 | + if (strpos($widget_path, $widget_ext) !== false) { |
|
1029 | 1029 | // grab and shortcode file name from directory name and break apart at dots |
1030 | - $file_name = explode( '.', basename( $widget_path ) ); |
|
1030 | + $file_name = explode('.', basename($widget_path)); |
|
1031 | 1031 | // take first segment from file name pieces and remove class prefix if it exists |
1032 | - $widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0]; |
|
1032 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1033 | 1033 | // sanitize shortcode directory name |
1034 | - $widget = sanitize_key( $widget ); |
|
1034 | + $widget = sanitize_key($widget); |
|
1035 | 1035 | // now we need to rebuild the shortcode path |
1036 | - $widget_path = explode( DS, $widget_path ); |
|
1036 | + $widget_path = explode(DS, $widget_path); |
|
1037 | 1037 | // remove last segment |
1038 | - array_pop( $widget_path ); |
|
1038 | + array_pop($widget_path); |
|
1039 | 1039 | // glue it back together |
1040 | - $widget_path = implode( DS, $widget_path ); |
|
1040 | + $widget_path = implode(DS, $widget_path); |
|
1041 | 1041 | } else { |
1042 | 1042 | // grab and sanitize widget directory name |
1043 | - $widget = sanitize_key( basename( $widget_path ) ); |
|
1043 | + $widget = sanitize_key(basename($widget_path)); |
|
1044 | 1044 | } |
1045 | 1045 | // create classname from widget directory name |
1046 | - $widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget ) ) ); |
|
1046 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1047 | 1047 | // add class prefix |
1048 | - $widget_class = 'EEW_' . $widget; |
|
1048 | + $widget_class = 'EEW_'.$widget; |
|
1049 | 1049 | // does the widget exist ? |
1050 | - if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext ) ) { |
|
1050 | + if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) { |
|
1051 | 1051 | $msg = sprintf( |
1052 | 1052 | __( |
1053 | 1053 | 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
1054 | 1054 | 'event_espresso' |
1055 | 1055 | ), |
1056 | 1056 | $widget_class, |
1057 | - $widget_path . DS . $widget_class . $widget_ext |
|
1057 | + $widget_path.DS.$widget_class.$widget_ext |
|
1058 | 1058 | ); |
1059 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1059 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1060 | 1060 | return; |
1061 | 1061 | } |
1062 | 1062 | // load the widget class file |
1063 | - require_once( $widget_path . DS . $widget_class . $widget_ext ); |
|
1063 | + require_once($widget_path.DS.$widget_class.$widget_ext); |
|
1064 | 1064 | // verify that class exists |
1065 | - if ( ! class_exists( $widget_class ) ) { |
|
1066 | - $msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class ); |
|
1067 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1065 | + if ( ! class_exists($widget_class)) { |
|
1066 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1067 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1068 | 1068 | return; |
1069 | 1069 | } |
1070 | - register_widget( $widget_class ); |
|
1070 | + register_widget($widget_class); |
|
1071 | 1071 | // add to array of registered widgets |
1072 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1072 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext; |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | |
@@ -1082,17 +1082,17 @@ discard block |
||
1082 | 1082 | */ |
1083 | 1083 | private function _register_shortcodes() { |
1084 | 1084 | // grab list of installed shortcodes |
1085 | - $shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR ); |
|
1085 | + $shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR); |
|
1086 | 1086 | // filter list of modules to register |
1087 | 1087 | $shortcodes_to_register = apply_filters( |
1088 | 1088 | 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
1089 | 1089 | $shortcodes_to_register |
1090 | 1090 | ); |
1091 | - if ( ! empty( $shortcodes_to_register ) ) { |
|
1091 | + if ( ! empty($shortcodes_to_register)) { |
|
1092 | 1092 | // cycle thru shortcode folders |
1093 | - foreach ( $shortcodes_to_register as $shortcode_path ) { |
|
1093 | + foreach ($shortcodes_to_register as $shortcode_path) { |
|
1094 | 1094 | // add to list of installed shortcode modules |
1095 | - EE_Config::register_shortcode( $shortcode_path ); |
|
1095 | + EE_Config::register_shortcode($shortcode_path); |
|
1096 | 1096 | } |
1097 | 1097 | } |
1098 | 1098 | // filter list of installed modules |
@@ -1111,64 +1111,64 @@ discard block |
||
1111 | 1111 | * @param string $shortcode_path - full path up to and including shortcode folder |
1112 | 1112 | * @return bool |
1113 | 1113 | */ |
1114 | - public static function register_shortcode( $shortcode_path = null ) { |
|
1115 | - do_action( 'AHEE__EE_Config__register_shortcode__begin', $shortcode_path ); |
|
1114 | + public static function register_shortcode($shortcode_path = null) { |
|
1115 | + do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
1116 | 1116 | $shortcode_ext = '.shortcode.php'; |
1117 | 1117 | // make all separators match |
1118 | - $shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path ); |
|
1118 | + $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
1119 | 1119 | // does the file path INCLUDE the actual file name as part of the path ? |
1120 | - if ( strpos( $shortcode_path, $shortcode_ext ) !== false ) { |
|
1120 | + if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
1121 | 1121 | // grab shortcode file name from directory name and break apart at dots |
1122 | - $shortcode_file = explode( '.', basename( $shortcode_path ) ); |
|
1122 | + $shortcode_file = explode('.', basename($shortcode_path)); |
|
1123 | 1123 | // take first segment from file name pieces and remove class prefix if it exists |
1124 | - $shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0 |
|
1125 | - ? substr( $shortcode_file[0], 4 ) |
|
1124 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
1125 | + ? substr($shortcode_file[0], 4) |
|
1126 | 1126 | : $shortcode_file[0]; |
1127 | 1127 | // sanitize shortcode directory name |
1128 | - $shortcode = sanitize_key( $shortcode ); |
|
1128 | + $shortcode = sanitize_key($shortcode); |
|
1129 | 1129 | // now we need to rebuild the shortcode path |
1130 | - $shortcode_path = explode( DS, $shortcode_path ); |
|
1130 | + $shortcode_path = explode(DS, $shortcode_path); |
|
1131 | 1131 | // remove last segment |
1132 | - array_pop( $shortcode_path ); |
|
1132 | + array_pop($shortcode_path); |
|
1133 | 1133 | // glue it back together |
1134 | - $shortcode_path = implode( DS, $shortcode_path ) . DS; |
|
1134 | + $shortcode_path = implode(DS, $shortcode_path).DS; |
|
1135 | 1135 | } else { |
1136 | 1136 | // we need to generate the filename based off of the folder name |
1137 | 1137 | // grab and sanitize shortcode directory name |
1138 | - $shortcode = sanitize_key( basename( $shortcode_path ) ); |
|
1139 | - $shortcode_path = rtrim( $shortcode_path, DS ) . DS; |
|
1138 | + $shortcode = sanitize_key(basename($shortcode_path)); |
|
1139 | + $shortcode_path = rtrim($shortcode_path, DS).DS; |
|
1140 | 1140 | } |
1141 | 1141 | // create classname from shortcode directory or file name |
1142 | - $shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode ) ) ); |
|
1142 | + $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
1143 | 1143 | // add class prefix |
1144 | - $shortcode_class = 'EES_' . $shortcode; |
|
1144 | + $shortcode_class = 'EES_'.$shortcode; |
|
1145 | 1145 | // does the shortcode exist ? |
1146 | - if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext ) ) { |
|
1146 | + if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) { |
|
1147 | 1147 | $msg = sprintf( |
1148 | 1148 | __( |
1149 | 1149 | 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
1150 | 1150 | 'event_espresso' |
1151 | 1151 | ), |
1152 | 1152 | $shortcode_class, |
1153 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
1153 | + $shortcode_path.DS.$shortcode_class.$shortcode_ext |
|
1154 | 1154 | ); |
1155 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1155 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1156 | 1156 | return false; |
1157 | 1157 | } |
1158 | 1158 | // load the shortcode class file |
1159 | - require_once( $shortcode_path . $shortcode_class . $shortcode_ext ); |
|
1159 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext); |
|
1160 | 1160 | // verify that class exists |
1161 | - if ( ! class_exists( $shortcode_class ) ) { |
|
1161 | + if ( ! class_exists($shortcode_class)) { |
|
1162 | 1162 | $msg = sprintf( |
1163 | - __( 'The requested %s shortcode class does not exist.', 'event_espresso' ), |
|
1163 | + __('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
1164 | 1164 | $shortcode_class |
1165 | 1165 | ); |
1166 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1166 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1167 | 1167 | return false; |
1168 | 1168 | } |
1169 | - $shortcode = strtoupper( $shortcode ); |
|
1169 | + $shortcode = strtoupper($shortcode); |
|
1170 | 1170 | // add to array of registered shortcodes |
1171 | - EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
1171 | + EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext; |
|
1172 | 1172 | return true; |
1173 | 1173 | } |
1174 | 1174 | |
@@ -1182,22 +1182,22 @@ discard block |
||
1182 | 1182 | */ |
1183 | 1183 | private function _register_modules() { |
1184 | 1184 | // grab list of installed modules |
1185 | - $modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR ); |
|
1185 | + $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR); |
|
1186 | 1186 | // filter list of modules to register |
1187 | 1187 | $modules_to_register = apply_filters( |
1188 | 1188 | 'FHEE__EE_Config__register_modules__modules_to_register', |
1189 | 1189 | $modules_to_register |
1190 | 1190 | ); |
1191 | - if ( ! empty( $modules_to_register ) ) { |
|
1191 | + if ( ! empty($modules_to_register)) { |
|
1192 | 1192 | // loop through folders |
1193 | - foreach ( $modules_to_register as $module_path ) { |
|
1193 | + foreach ($modules_to_register as $module_path) { |
|
1194 | 1194 | /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
1195 | 1195 | if ( |
1196 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1197 | - && $module_path !== EE_MODULES . 'gateways' |
|
1196 | + $module_path !== EE_MODULES.'zzz-copy-this-module-template' |
|
1197 | + && $module_path !== EE_MODULES.'gateways' |
|
1198 | 1198 | ) { |
1199 | 1199 | // add to list of installed modules |
1200 | - EE_Config::register_module( $module_path ); |
|
1200 | + EE_Config::register_module($module_path); |
|
1201 | 1201 | } |
1202 | 1202 | } |
1203 | 1203 | } |
@@ -1217,39 +1217,39 @@ discard block |
||
1217 | 1217 | * @param string $module_path - full path up to and including module folder |
1218 | 1218 | * @return bool |
1219 | 1219 | */ |
1220 | - public static function register_module( $module_path = null ) { |
|
1221 | - do_action( 'AHEE__EE_Config__register_module__begin', $module_path ); |
|
1220 | + public static function register_module($module_path = null) { |
|
1221 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1222 | 1222 | $module_ext = '.module.php'; |
1223 | 1223 | // make all separators match |
1224 | - $module_path = str_replace( array( '\\', '/' ), DS, $module_path ); |
|
1224 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1225 | 1225 | // does the file path INCLUDE the actual file name as part of the path ? |
1226 | - if ( strpos( $module_path, $module_ext ) !== false ) { |
|
1226 | + if (strpos($module_path, $module_ext) !== false) { |
|
1227 | 1227 | // grab and shortcode file name from directory name and break apart at dots |
1228 | - $module_file = explode( '.', basename( $module_path ) ); |
|
1228 | + $module_file = explode('.', basename($module_path)); |
|
1229 | 1229 | // now we need to rebuild the shortcode path |
1230 | - $module_path = explode( DS, $module_path ); |
|
1230 | + $module_path = explode(DS, $module_path); |
|
1231 | 1231 | // remove last segment |
1232 | - array_pop( $module_path ); |
|
1232 | + array_pop($module_path); |
|
1233 | 1233 | // glue it back together |
1234 | - $module_path = implode( DS, $module_path ) . DS; |
|
1234 | + $module_path = implode(DS, $module_path).DS; |
|
1235 | 1235 | // take first segment from file name pieces and sanitize it |
1236 | - $module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] ); |
|
1236 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1237 | 1237 | // ensure class prefix is added |
1238 | - $module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module; |
|
1238 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module; |
|
1239 | 1239 | } else { |
1240 | 1240 | // we need to generate the filename based off of the folder name |
1241 | 1241 | // grab and sanitize module name |
1242 | - $module = strtolower( basename( $module_path ) ); |
|
1243 | - $module = preg_replace( '/[^a-z0-9_\-]/', '', $module ); |
|
1242 | + $module = strtolower(basename($module_path)); |
|
1243 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1244 | 1244 | // like trailingslashit() |
1245 | - $module_path = rtrim( $module_path, DS ) . DS; |
|
1245 | + $module_path = rtrim($module_path, DS).DS; |
|
1246 | 1246 | // create classname from module directory name |
1247 | - $module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module ) ) ); |
|
1247 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1248 | 1248 | // add class prefix |
1249 | - $module_class = 'EED_' . $module; |
|
1249 | + $module_class = 'EED_'.$module; |
|
1250 | 1250 | } |
1251 | 1251 | // does the module exist ? |
1252 | - if ( ! is_readable( $module_path . DS . $module_class . $module_ext ) ) { |
|
1252 | + if ( ! is_readable($module_path.DS.$module_class.$module_ext)) { |
|
1253 | 1253 | $msg = sprintf( |
1254 | 1254 | __( |
1255 | 1255 | 'The requested %s module file could not be found or is not readable due to file permissions.', |
@@ -1257,19 +1257,19 @@ discard block |
||
1257 | 1257 | ), |
1258 | 1258 | $module |
1259 | 1259 | ); |
1260 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1260 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1261 | 1261 | return false; |
1262 | 1262 | } |
1263 | 1263 | // load the module class file |
1264 | - require_once( $module_path . $module_class . $module_ext ); |
|
1264 | + require_once($module_path.$module_class.$module_ext); |
|
1265 | 1265 | // verify that class exists |
1266 | - if ( ! class_exists( $module_class ) ) { |
|
1267 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
1268 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1266 | + if ( ! class_exists($module_class)) { |
|
1267 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1268 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1269 | 1269 | return false; |
1270 | 1270 | } |
1271 | 1271 | // add to array of registered modules |
1272 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1272 | + EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext; |
|
1273 | 1273 | do_action( |
1274 | 1274 | 'AHEE__EE_Config__register_module__complete', |
1275 | 1275 | $module_class, |
@@ -1289,26 +1289,26 @@ discard block |
||
1289 | 1289 | */ |
1290 | 1290 | private function _initialize_shortcodes() { |
1291 | 1291 | // cycle thru shortcode folders |
1292 | - foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) { |
|
1292 | + foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
|
1293 | 1293 | // add class prefix |
1294 | - $shortcode_class = 'EES_' . $shortcode; |
|
1294 | + $shortcode_class = 'EES_'.$shortcode; |
|
1295 | 1295 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1296 | 1296 | // which set hooks ? |
1297 | - if ( is_admin() ) { |
|
1297 | + if (is_admin()) { |
|
1298 | 1298 | // fire immediately |
1299 | - call_user_func( array( $shortcode_class, 'set_hooks_admin' ) ); |
|
1299 | + call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
1300 | 1300 | } else { |
1301 | 1301 | // delay until other systems are online |
1302 | 1302 | add_action( |
1303 | 1303 | 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
1304 | - array( $shortcode_class, 'set_hooks' ) |
|
1304 | + array($shortcode_class, 'set_hooks') |
|
1305 | 1305 | ); |
1306 | 1306 | // convert classname to UPPERCASE and create WP shortcode. |
1307 | - $shortcode_tag = strtoupper( $shortcode ); |
|
1307 | + $shortcode_tag = strtoupper($shortcode); |
|
1308 | 1308 | // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
1309 | - if ( ! shortcode_exists( $shortcode_tag ) ) { |
|
1309 | + if ( ! shortcode_exists($shortcode_tag)) { |
|
1310 | 1310 | // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
1311 | - add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' ) ); |
|
1311 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
1312 | 1312 | } |
1313 | 1313 | } |
1314 | 1314 | } |
@@ -1325,17 +1325,17 @@ discard block |
||
1325 | 1325 | */ |
1326 | 1326 | private function _initialize_modules() { |
1327 | 1327 | // cycle thru shortcode folders |
1328 | - foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) { |
|
1328 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1329 | 1329 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1330 | 1330 | // which set hooks ? |
1331 | - if ( is_admin() ) { |
|
1331 | + if (is_admin()) { |
|
1332 | 1332 | // fire immediately |
1333 | - call_user_func( array( $module_class, 'set_hooks_admin' ) ); |
|
1333 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
1334 | 1334 | } else { |
1335 | 1335 | // delay until other systems are online |
1336 | 1336 | add_action( |
1337 | 1337 | 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
1338 | - array( $module_class, 'set_hooks' ) |
|
1338 | + array($module_class, 'set_hooks') |
|
1339 | 1339 | ); |
1340 | 1340 | } |
1341 | 1341 | } |
@@ -1353,29 +1353,29 @@ discard block |
||
1353 | 1353 | * @param string $key - url param key indicating a route is being called |
1354 | 1354 | * @return bool |
1355 | 1355 | */ |
1356 | - public static function register_route( $route = null, $module = null, $method_name = null, $key = 'ee' ) { |
|
1357 | - do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name ); |
|
1358 | - $module = str_replace( 'EED_', '', $module ); |
|
1359 | - $module_class = 'EED_' . $module; |
|
1360 | - if ( ! isset( EE_Registry::instance()->modules->{$module_class} ) ) { |
|
1361 | - $msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module ); |
|
1362 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1356 | + public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') { |
|
1357 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1358 | + $module = str_replace('EED_', '', $module); |
|
1359 | + $module_class = 'EED_'.$module; |
|
1360 | + if ( ! isset(EE_Registry::instance()->modules->{$module_class} )) { |
|
1361 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1362 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1363 | 1363 | return false; |
1364 | 1364 | } |
1365 | - if ( empty( $route ) ) { |
|
1366 | - $msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route ); |
|
1367 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1365 | + if (empty($route)) { |
|
1366 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1367 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1368 | 1368 | return false; |
1369 | 1369 | } |
1370 | - if ( ! method_exists( 'EED_' . $module, $method_name ) ) { |
|
1370 | + if ( ! method_exists('EED_'.$module, $method_name)) { |
|
1371 | 1371 | $msg = sprintf( |
1372 | - __( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ), |
|
1372 | + __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1373 | 1373 | $route |
1374 | 1374 | ); |
1375 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1375 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1376 | 1376 | return false; |
1377 | 1377 | } |
1378 | - EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name ); |
|
1378 | + EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name); |
|
1379 | 1379 | return true; |
1380 | 1380 | } |
1381 | 1381 | |
@@ -1389,11 +1389,11 @@ discard block |
||
1389 | 1389 | * @param string $key - url param key indicating a route is being called |
1390 | 1390 | * @return string |
1391 | 1391 | */ |
1392 | - public static function get_route( $route = null, $key = 'ee' ) { |
|
1393 | - do_action( 'AHEE__EE_Config__get_route__begin', $route ); |
|
1394 | - $route = (string) apply_filters( 'FHEE__EE_Config__get_route', $route ); |
|
1395 | - if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] ) ) { |
|
1396 | - return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
1392 | + public static function get_route($route = null, $key = 'ee') { |
|
1393 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1394 | + $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
1395 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1396 | + return EE_Config::$_module_route_map[$key][$route]; |
|
1397 | 1397 | } |
1398 | 1398 | return null; |
1399 | 1399 | } |
@@ -1423,49 +1423,49 @@ discard block |
||
1423 | 1423 | * @param string $key - url param key indicating a route is being called |
1424 | 1424 | * @return bool |
1425 | 1425 | */ |
1426 | - public static function register_forward( $route = null, $status = 0, $forward = null, $key = 'ee' ) { |
|
1427 | - do_action( 'AHEE__EE_Config__register_forward', $route, $status, $forward ); |
|
1428 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route ) ) { |
|
1426 | + public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') { |
|
1427 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1428 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1429 | 1429 | $msg = sprintf( |
1430 | - __( 'The module route %s for this forward has not been registered.', 'event_espresso' ), |
|
1430 | + __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1431 | 1431 | $route |
1432 | 1432 | ); |
1433 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1433 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1434 | 1434 | return false; |
1435 | 1435 | } |
1436 | - if ( empty( $forward ) ) { |
|
1437 | - $msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route ); |
|
1438 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1436 | + if (empty($forward)) { |
|
1437 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1438 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1439 | 1439 | return false; |
1440 | 1440 | } |
1441 | - if ( is_array( $forward ) ) { |
|
1442 | - if ( ! isset( $forward[1] ) ) { |
|
1441 | + if (is_array($forward)) { |
|
1442 | + if ( ! isset($forward[1])) { |
|
1443 | 1443 | $msg = sprintf( |
1444 | - __( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ), |
|
1444 | + __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1445 | 1445 | $route |
1446 | 1446 | ); |
1447 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1447 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1448 | 1448 | return false; |
1449 | 1449 | } |
1450 | - if ( ! method_exists( $forward[0], $forward[1] ) ) { |
|
1450 | + if ( ! method_exists($forward[0], $forward[1])) { |
|
1451 | 1451 | $msg = sprintf( |
1452 | - __( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ), |
|
1452 | + __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1453 | 1453 | $forward[1], |
1454 | 1454 | $route |
1455 | 1455 | ); |
1456 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1456 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1457 | 1457 | return false; |
1458 | 1458 | } |
1459 | - } else if ( ! function_exists( $forward ) ) { |
|
1459 | + } else if ( ! function_exists($forward)) { |
|
1460 | 1460 | $msg = sprintf( |
1461 | - __( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ), |
|
1461 | + __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1462 | 1462 | $forward, |
1463 | 1463 | $route |
1464 | 1464 | ); |
1465 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1465 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1466 | 1466 | return false; |
1467 | 1467 | } |
1468 | - EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward; |
|
1468 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1469 | 1469 | return true; |
1470 | 1470 | } |
1471 | 1471 | |
@@ -1481,12 +1481,12 @@ discard block |
||
1481 | 1481 | * @param string $key - url param key indicating a route is being called |
1482 | 1482 | * @return string |
1483 | 1483 | */ |
1484 | - public static function get_forward( $route = null, $status = 0, $key = 'ee' ) { |
|
1485 | - do_action( 'AHEE__EE_Config__get_forward__begin', $route, $status ); |
|
1486 | - if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] ) ) { |
|
1484 | + public static function get_forward($route = null, $status = 0, $key = 'ee') { |
|
1485 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1486 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1487 | 1487 | return apply_filters( |
1488 | 1488 | 'FHEE__EE_Config__get_forward', |
1489 | - EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], |
|
1489 | + EE_Config::$_module_forward_map[$key][$route][$status], |
|
1490 | 1490 | $route, |
1491 | 1491 | $status |
1492 | 1492 | ); |
@@ -1508,17 +1508,17 @@ discard block |
||
1508 | 1508 | * @param string $key - url param key indicating a route is being called |
1509 | 1509 | * @return bool |
1510 | 1510 | */ |
1511 | - public static function register_view( $route = null, $status = 0, $view = null, $key = 'ee' ) { |
|
1512 | - do_action( 'AHEE__EE_Config__register_view__begin', $route, $status, $view ); |
|
1513 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route ) ) { |
|
1511 | + public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') { |
|
1512 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1513 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1514 | 1514 | $msg = sprintf( |
1515 | - __( 'The module route %s for this view has not been registered.', 'event_espresso' ), |
|
1515 | + __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1516 | 1516 | $route |
1517 | 1517 | ); |
1518 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1518 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1519 | 1519 | return false; |
1520 | 1520 | } |
1521 | - if ( ! is_readable( $view ) ) { |
|
1521 | + if ( ! is_readable($view)) { |
|
1522 | 1522 | $msg = sprintf( |
1523 | 1523 | __( |
1524 | 1524 | 'The %s view file could not be found or is not readable due to file permissions.', |
@@ -1526,10 +1526,10 @@ discard block |
||
1526 | 1526 | ), |
1527 | 1527 | $view |
1528 | 1528 | ); |
1529 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1529 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1530 | 1530 | return false; |
1531 | 1531 | } |
1532 | - EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view; |
|
1532 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1533 | 1533 | return true; |
1534 | 1534 | } |
1535 | 1535 | |
@@ -1545,12 +1545,12 @@ discard block |
||
1545 | 1545 | * @param string $key - url param key indicating a route is being called |
1546 | 1546 | * @return string |
1547 | 1547 | */ |
1548 | - public static function get_view( $route = null, $status = 0, $key = 'ee' ) { |
|
1549 | - do_action( 'AHEE__EE_Config__get_view__begin', $route, $status ); |
|
1550 | - if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] ) ) { |
|
1548 | + public static function get_view($route = null, $status = 0, $key = 'ee') { |
|
1549 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1550 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1551 | 1551 | return apply_filters( |
1552 | 1552 | 'FHEE__EE_Config__get_view', |
1553 | - EE_Config::$_module_view_map[ $key ][ $route ][ $status ], |
|
1553 | + EE_Config::$_module_view_map[$key][$route][$status], |
|
1554 | 1554 | $route, |
1555 | 1555 | $status |
1556 | 1556 | ); |
@@ -1561,7 +1561,7 @@ discard block |
||
1561 | 1561 | |
1562 | 1562 | |
1563 | 1563 | public function update_addon_option_names() { |
1564 | - update_option( EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names ); |
|
1564 | + update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1565 | 1565 | } |
1566 | 1566 | |
1567 | 1567 | |
@@ -1589,22 +1589,22 @@ discard block |
||
1589 | 1589 | * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
1590 | 1590 | * @throws \EE_Error |
1591 | 1591 | */ |
1592 | - public function get_pretty( $property ) { |
|
1593 | - if ( ! property_exists( $this, $property ) ) { |
|
1592 | + public function get_pretty($property) { |
|
1593 | + if ( ! property_exists($this, $property)) { |
|
1594 | 1594 | throw new EE_Error( |
1595 | 1595 | sprintf( |
1596 | 1596 | __( |
1597 | 1597 | '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
1598 | 1598 | 'event_espresso' |
1599 | 1599 | ), |
1600 | - get_class( $this ), |
|
1600 | + get_class($this), |
|
1601 | 1601 | $property |
1602 | 1602 | ) |
1603 | 1603 | ); |
1604 | 1604 | } |
1605 | 1605 | //just handling escaping of strings for now. |
1606 | - if ( is_string( $this->{$property} ) ) { |
|
1607 | - return stripslashes( $this->{$property} ); |
|
1606 | + if (is_string($this->{$property} )) { |
|
1607 | + return stripslashes($this->{$property} ); |
|
1608 | 1608 | } |
1609 | 1609 | return $this->{$property}; |
1610 | 1610 | } |
@@ -1613,17 +1613,17 @@ discard block |
||
1613 | 1613 | |
1614 | 1614 | public function populate() { |
1615 | 1615 | //grab defaults via a new instance of this class. |
1616 | - $class_name = get_class( $this ); |
|
1616 | + $class_name = get_class($this); |
|
1617 | 1617 | $defaults = new $class_name; |
1618 | 1618 | //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
1619 | 1619 | //default from our $defaults object. |
1620 | - foreach ( get_object_vars( $defaults ) as $property => $value ) { |
|
1621 | - if ( $this->{$property} === null ) { |
|
1620 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
1621 | + if ($this->{$property} === null) { |
|
1622 | 1622 | $this->{$property} = $value; |
1623 | 1623 | } |
1624 | 1624 | } |
1625 | 1625 | //cleanup |
1626 | - unset( $defaults ); |
|
1626 | + unset($defaults); |
|
1627 | 1627 | } |
1628 | 1628 | |
1629 | 1629 | |
@@ -1639,7 +1639,7 @@ discard block |
||
1639 | 1639 | * @param $a |
1640 | 1640 | * @return bool |
1641 | 1641 | */ |
1642 | - public function __isset( $a ) { |
|
1642 | + public function __isset($a) { |
|
1643 | 1643 | return false; |
1644 | 1644 | } |
1645 | 1645 | |
@@ -1651,7 +1651,7 @@ discard block |
||
1651 | 1651 | * @param $a |
1652 | 1652 | * @return bool |
1653 | 1653 | */ |
1654 | - public function __unset( $a ) { |
|
1654 | + public function __unset($a) { |
|
1655 | 1655 | return false; |
1656 | 1656 | } |
1657 | 1657 | |
@@ -1761,7 +1761,7 @@ discard block |
||
1761 | 1761 | $this->current_blog_id = get_current_blog_id(); |
1762 | 1762 | $this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id; |
1763 | 1763 | $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
1764 | - $this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', false ) : true; |
|
1764 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1765 | 1765 | $this->post_shortcodes = array(); |
1766 | 1766 | $this->module_route_map = array(); |
1767 | 1767 | $this->module_forward_map = array(); |
@@ -1777,9 +1777,9 @@ discard block |
||
1777 | 1777 | $this->thank_you_page_url = ''; |
1778 | 1778 | $this->cancel_page_url = ''; |
1779 | 1779 | //cpt slugs |
1780 | - $this->event_cpt_slug = __( 'events', 'event_espresso' ); |
|
1780 | + $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1781 | 1781 | //ueip constant check |
1782 | - if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) { |
|
1782 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1783 | 1783 | $this->ee_ueip_optin = false; |
1784 | 1784 | $this->ee_ueip_has_notified = true; |
1785 | 1785 | } |
@@ -1822,11 +1822,11 @@ discard block |
||
1822 | 1822 | * @return string |
1823 | 1823 | */ |
1824 | 1824 | public function reg_page_url() { |
1825 | - if ( ! $this->reg_page_url ) { |
|
1825 | + if ( ! $this->reg_page_url) { |
|
1826 | 1826 | $this->reg_page_url = add_query_arg( |
1827 | - array( 'uts' => time() ), |
|
1828 | - get_permalink( $this->reg_page_id ) |
|
1829 | - ) . '#checkout'; |
|
1827 | + array('uts' => time()), |
|
1828 | + get_permalink($this->reg_page_id) |
|
1829 | + ).'#checkout'; |
|
1830 | 1830 | } |
1831 | 1831 | return $this->reg_page_url; |
1832 | 1832 | } |
@@ -1841,12 +1841,12 @@ discard block |
||
1841 | 1841 | * @access public |
1842 | 1842 | * @return string |
1843 | 1843 | */ |
1844 | - public function txn_page_url( $query_args = array() ) { |
|
1845 | - if ( ! $this->txn_page_url ) { |
|
1846 | - $this->txn_page_url = get_permalink( $this->txn_page_id ); |
|
1844 | + public function txn_page_url($query_args = array()) { |
|
1845 | + if ( ! $this->txn_page_url) { |
|
1846 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1847 | 1847 | } |
1848 | - if ( $query_args ) { |
|
1849 | - return add_query_arg( $query_args, $this->txn_page_url ); |
|
1848 | + if ($query_args) { |
|
1849 | + return add_query_arg($query_args, $this->txn_page_url); |
|
1850 | 1850 | } else { |
1851 | 1851 | return $this->txn_page_url; |
1852 | 1852 | } |
@@ -1862,12 +1862,12 @@ discard block |
||
1862 | 1862 | * @access public |
1863 | 1863 | * @return string |
1864 | 1864 | */ |
1865 | - public function thank_you_page_url( $query_args = array() ) { |
|
1866 | - if ( ! $this->thank_you_page_url ) { |
|
1867 | - $this->thank_you_page_url = get_permalink( $this->thank_you_page_id ); |
|
1865 | + public function thank_you_page_url($query_args = array()) { |
|
1866 | + if ( ! $this->thank_you_page_url) { |
|
1867 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1868 | 1868 | } |
1869 | - if ( $query_args ) { |
|
1870 | - return add_query_arg( $query_args, $this->thank_you_page_url ); |
|
1869 | + if ($query_args) { |
|
1870 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
1871 | 1871 | } else { |
1872 | 1872 | return $this->thank_you_page_url; |
1873 | 1873 | } |
@@ -1882,8 +1882,8 @@ discard block |
||
1882 | 1882 | * @return string |
1883 | 1883 | */ |
1884 | 1884 | public function cancel_page_url() { |
1885 | - if ( ! $this->cancel_page_url ) { |
|
1886 | - $this->cancel_page_url = get_permalink( $this->cancel_page_id ); |
|
1885 | + if ( ! $this->cancel_page_url) { |
|
1886 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1887 | 1887 | } |
1888 | 1888 | return $this->cancel_page_url; |
1889 | 1889 | } |
@@ -1912,22 +1912,22 @@ discard block |
||
1912 | 1912 | */ |
1913 | 1913 | protected function _get_main_ee_ueip_optin() { |
1914 | 1914 | //if this is the main site then we can just bypass our direct query. |
1915 | - if ( is_main_site() ) { |
|
1916 | - return get_option( 'ee_ueip_optin', false ); |
|
1915 | + if (is_main_site()) { |
|
1916 | + return get_option('ee_ueip_optin', false); |
|
1917 | 1917 | } |
1918 | 1918 | |
1919 | 1919 | //is this already cached for this request? If so use it. |
1920 | - if ( ! empty( EE_Core_Config::$ee_ueip_option ) ) { |
|
1920 | + if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1921 | 1921 | return EE_Core_Config::$ee_ueip_option; |
1922 | 1922 | } |
1923 | 1923 | |
1924 | 1924 | global $wpdb; |
1925 | 1925 | $current_network_main_site = is_multisite() ? get_current_site() : null; |
1926 | - $current_main_site_id = ! empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1; |
|
1926 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1927 | 1927 | $option = 'ee_ueip_optin'; |
1928 | 1928 | |
1929 | 1929 | //set correct table for query |
1930 | - $table_name = $wpdb->get_blog_prefix( $current_main_site_id ) . 'options'; |
|
1930 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options'; |
|
1931 | 1931 | |
1932 | 1932 | |
1933 | 1933 | //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
@@ -1935,20 +1935,20 @@ discard block |
||
1935 | 1935 | //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
1936 | 1936 | //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
1937 | 1937 | //for the purpose of caching. |
1938 | - $pre = apply_filters( 'pre_option_' . $option, false, $option ); |
|
1939 | - if ( false !== $pre ) { |
|
1938 | + $pre = apply_filters('pre_option_'.$option, false, $option); |
|
1939 | + if (false !== $pre) { |
|
1940 | 1940 | EE_Core_Config::$ee_ueip_option = $pre; |
1941 | 1941 | return EE_Core_Config::$ee_ueip_option; |
1942 | 1942 | } |
1943 | 1943 | |
1944 | - $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", $option ) ); |
|
1945 | - if ( is_object( $row ) ) { |
|
1944 | + $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", $option)); |
|
1945 | + if (is_object($row)) { |
|
1946 | 1946 | $value = $row->option_value; |
1947 | 1947 | } else { //option does not exist so use default. |
1948 | - return apply_filters( 'default_option_' . $option, false, $option ); |
|
1948 | + return apply_filters('default_option_'.$option, false, $option); |
|
1949 | 1949 | } |
1950 | 1950 | |
1951 | - EE_Core_Config::$ee_ueip_option = apply_filters( 'option_' . $option, maybe_unserialize( $value ), $option ); |
|
1951 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option); |
|
1952 | 1952 | return EE_Core_Config::$ee_ueip_option; |
1953 | 1953 | } |
1954 | 1954 | |
@@ -1964,7 +1964,7 @@ discard block |
||
1964 | 1964 | //reset all url properties |
1965 | 1965 | $this->_reset_urls(); |
1966 | 1966 | //return what to save to db |
1967 | - return array_keys( get_object_vars( $this ) ); |
|
1967 | + return array_keys(get_object_vars($this)); |
|
1968 | 1968 | } |
1969 | 1969 | |
1970 | 1970 | } |
@@ -2111,14 +2111,14 @@ discard block |
||
2111 | 2111 | */ |
2112 | 2112 | public function __construct() { |
2113 | 2113 | // set default organization settings |
2114 | - $this->name = get_bloginfo( 'name' ); |
|
2114 | + $this->name = get_bloginfo('name'); |
|
2115 | 2115 | $this->address_1 = '123 Onna Road'; |
2116 | 2116 | $this->address_2 = 'PO Box 123'; |
2117 | 2117 | $this->city = 'Inna City'; |
2118 | 2118 | $this->STA_ID = 4; |
2119 | 2119 | $this->CNT_ISO = 'US'; |
2120 | 2120 | $this->zip = '12345'; |
2121 | - $this->email = get_bloginfo( 'admin_email' ); |
|
2121 | + $this->email = get_bloginfo('admin_email'); |
|
2122 | 2122 | $this->phone = ''; |
2123 | 2123 | $this->vat = '123456789'; |
2124 | 2124 | $this->logo_url = ''; |
@@ -2206,46 +2206,46 @@ discard block |
||
2206 | 2206 | * @param string $CNT_ISO |
2207 | 2207 | * @throws \EE_Error |
2208 | 2208 | */ |
2209 | - public function __construct( $CNT_ISO = '' ) { |
|
2209 | + public function __construct($CNT_ISO = '') { |
|
2210 | 2210 | /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
2211 | - $table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
2211 | + $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
2212 | 2212 | // get country code from organization settings or use default |
2213 | - $ORG_CNT = isset( EE_Registry::instance()->CFG->organization ) |
|
2213 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2214 | 2214 | && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
2215 | 2215 | ? EE_Registry::instance()->CFG->organization->CNT_ISO |
2216 | 2216 | : ''; |
2217 | 2217 | // but override if requested |
2218 | - $CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT; |
|
2218 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2219 | 2219 | // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
2220 | 2220 | if ( |
2221 | - ! empty( $CNT_ISO ) |
|
2221 | + ! empty($CNT_ISO) |
|
2222 | 2222 | && EE_Maintenance_Mode::instance()->models_can_query() |
2223 | - && $table_analysis->tableExists( EE_Registry::instance()->load_model( 'Country' )->table() ) |
|
2223 | + && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
2224 | 2224 | ) { |
2225 | 2225 | // retrieve the country settings from the db, just in case they have been customized |
2226 | - $country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO ); |
|
2227 | - if ( $country instanceof EE_Country ) { |
|
2228 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2229 | - $this->name = $country->currency_name_single(); // Dollar |
|
2230 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
2231 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
2232 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2233 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2234 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2235 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2226 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2227 | + if ($country instanceof EE_Country) { |
|
2228 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2229 | + $this->name = $country->currency_name_single(); // Dollar |
|
2230 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
2231 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
2232 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2233 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2234 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2235 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2236 | 2236 | } |
2237 | 2237 | } |
2238 | 2238 | // fallback to hardcoded defaults, in case the above failed |
2239 | - if ( empty( $this->code ) ) { |
|
2239 | + if (empty($this->code)) { |
|
2240 | 2240 | // set default currency settings |
2241 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2242 | - $this->name = __( 'Dollar', 'event_espresso' ); // Dollar |
|
2243 | - $this->plural = __( 'Dollars', 'event_espresso' ); // Dollars |
|
2244 | - $this->sign = '$'; // currency sign: $ |
|
2245 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2246 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2247 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2248 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2241 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2242 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2243 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2244 | + $this->sign = '$'; // currency sign: $ |
|
2245 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2246 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2247 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2248 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2249 | 2249 | } |
2250 | 2250 | } |
2251 | 2251 | } |
@@ -2407,7 +2407,7 @@ discard block |
||
2407 | 2407 | * @since 4.8.8.rc.019 |
2408 | 2408 | */ |
2409 | 2409 | public function do_hooks() { |
2410 | - add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' ) ); |
|
2410 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2411 | 2411 | } |
2412 | 2412 | |
2413 | 2413 | |
@@ -2416,7 +2416,7 @@ discard block |
||
2416 | 2416 | * @return void |
2417 | 2417 | */ |
2418 | 2418 | public function set_default_reg_status_on_EEM_Event() { |
2419 | - EEM_Event::set_default_reg_status( $this->default_STS_ID ); |
|
2419 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2420 | 2420 | } |
2421 | 2421 | |
2422 | 2422 | |
@@ -2520,10 +2520,10 @@ discard block |
||
2520 | 2520 | * @param bool $reset |
2521 | 2521 | * @return string |
2522 | 2522 | */ |
2523 | - public function log_file_name( $reset = false ) { |
|
2524 | - if ( empty( $this->log_file_name ) || $reset ) { |
|
2525 | - $this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', true ) ) ) . '.txt'; |
|
2526 | - EE_Config::instance()->update_espresso_config( false, false ); |
|
2523 | + public function log_file_name($reset = false) { |
|
2524 | + if (empty($this->log_file_name) || $reset) { |
|
2525 | + $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt'; |
|
2526 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2527 | 2527 | } |
2528 | 2528 | return $this->log_file_name; |
2529 | 2529 | } |
@@ -2534,10 +2534,10 @@ discard block |
||
2534 | 2534 | * @param bool $reset |
2535 | 2535 | * @return string |
2536 | 2536 | */ |
2537 | - public function debug_file_name( $reset = false ) { |
|
2538 | - if ( empty( $this->debug_file_name ) || $reset ) { |
|
2539 | - $this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', true ) ) ) . '.txt'; |
|
2540 | - EE_Config::instance()->update_espresso_config( false, false ); |
|
2537 | + public function debug_file_name($reset = false) { |
|
2538 | + if (empty($this->debug_file_name) || $reset) { |
|
2539 | + $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt'; |
|
2540 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2541 | 2541 | } |
2542 | 2542 | return $this->debug_file_name; |
2543 | 2543 | } |
@@ -2548,7 +2548,7 @@ discard block |
||
2548 | 2548 | * @return string |
2549 | 2549 | */ |
2550 | 2550 | public function affiliate_id() { |
2551 | - return ! empty( $this->affiliate_id ) ? $this->affiliate_id : 'default'; |
|
2551 | + return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
2552 | 2552 | } |
2553 | 2553 | |
2554 | 2554 | |
@@ -2728,21 +2728,21 @@ discard block |
||
2728 | 2728 | $this->use_google_maps = true; |
2729 | 2729 | $this->google_map_api_key = ''; |
2730 | 2730 | // for event details pages (reg page) |
2731 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2732 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2733 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2734 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2735 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2736 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2737 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2731 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2732 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2733 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2734 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2735 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2736 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2737 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2738 | 2738 | // for event list pages |
2739 | - $this->event_list_map_width = 300; // ee_map_width |
|
2740 | - $this->event_list_map_height = 185; // ee_map_height |
|
2741 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2742 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
2743 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
2744 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2745 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2739 | + $this->event_list_map_width = 300; // ee_map_width |
|
2740 | + $this->event_list_map_height = 185; // ee_map_height |
|
2741 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2742 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
2743 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
2744 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2745 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2746 | 2746 | } |
2747 | 2747 | |
2748 | 2748 | } |
@@ -2904,7 +2904,7 @@ discard block |
||
2904 | 2904 | * @return void |
2905 | 2905 | */ |
2906 | 2906 | protected function _set_php_values() { |
2907 | - $this->php->max_input_vars = ini_get( 'max_input_vars' ); |
|
2907 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
2908 | 2908 | $this->php->version = phpversion(); |
2909 | 2909 | } |
2910 | 2910 | |
@@ -2923,10 +2923,10 @@ discard block |
||
2923 | 2923 | * @type string $msg Any message to be displayed. |
2924 | 2924 | * } |
2925 | 2925 | */ |
2926 | - public function max_input_vars_limit_check( $input_count = 0 ) { |
|
2927 | - if ( ! empty( $this->php->max_input_vars ) |
|
2928 | - && ( $input_count >= $this->php->max_input_vars ) |
|
2929 | - && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9 ) |
|
2926 | + public function max_input_vars_limit_check($input_count = 0) { |
|
2927 | + if ( ! empty($this->php->max_input_vars) |
|
2928 | + && ($input_count >= $this->php->max_input_vars) |
|
2929 | + && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
2930 | 2930 | ) { |
2931 | 2931 | return sprintf( |
2932 | 2932 | __( |
@@ -3022,7 +3022,7 @@ discard block |
||
3022 | 3022 | */ |
3023 | 3023 | public function __construct() { |
3024 | 3024 | $this->payment_settings = array(); |
3025 | - $this->active_gateways = array( 'Invoice' => false ); |
|
3025 | + $this->active_gateways = array('Invoice' => false); |
|
3026 | 3026 | } |
3027 | 3027 | } |
3028 | 3028 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * EEH_Activation Helper |
4 | 4 | * |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * @return \EventEspresso\core\services\database\TableAnalysis |
55 | 55 | */ |
56 | 56 | public static function getTableAnalysis() { |
57 | - if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis ) { |
|
58 | - self::$table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
57 | + if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
58 | + self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
59 | 59 | } |
60 | 60 | return self::$table_analysis; |
61 | 61 | } |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @return \EventEspresso\core\services\database\TableManager |
67 | 67 | */ |
68 | 68 | public static function getTableManager() { |
69 | - if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager ) { |
|
70 | - self::$table_manager = EE_Registry::instance()->create( 'TableManager', array(), true ); |
|
69 | + if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
70 | + self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
71 | 71 | } |
72 | 72 | return self::$table_manager; |
73 | 73 | } |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @param $table_name |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
86 | - return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
85 | + public static function ensure_table_name_has_prefix($table_name) { |
|
86 | + return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return boolean success, whether the database and folders are setup properly |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public static function initialize_db_and_folders(){ |
|
114 | + public static function initialize_db_and_folders() { |
|
115 | 115 | $good_filesystem = EEH_Activation::create_upload_directories(); |
116 | 116 | $good_db = EEH_Activation::create_database_tables(); |
117 | 117 | return $good_filesystem && $good_db; |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @throws \EE_Error |
129 | 129 | */ |
130 | - public static function initialize_db_content(){ |
|
130 | + public static function initialize_db_content() { |
|
131 | 131 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
132 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
132 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | EEH_Activation::remove_cron_tasks(); |
147 | 147 | EEH_Activation::create_cron_tasks(); |
148 | 148 | // remove all TXN locks since that is being done via extra meta now |
149 | - delete_option( 'ee_locked_transactions' ); |
|
149 | + delete_option('ee_locked_transactions'); |
|
150 | 150 | //also, check for CAF default db content |
151 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
151 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
152 | 152 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
153 | 153 | //which users really won't care about on initial activation |
154 | 154 | EE_Error::overwrite_success(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @return array |
169 | 169 | * @throws \EE_Error |
170 | 170 | */ |
171 | - public static function get_cron_tasks( $which_to_include ) { |
|
171 | + public static function get_cron_tasks($which_to_include) { |
|
172 | 172 | $cron_tasks = apply_filters( |
173 | 173 | 'FHEE__EEH_Activation__get_cron_tasks', |
174 | 174 | array( |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
178 | 178 | ) |
179 | 179 | ); |
180 | - if ( $which_to_include === 'old' ) { |
|
180 | + if ($which_to_include === 'old') { |
|
181 | 181 | $cron_tasks = array_filter( |
182 | 182 | $cron_tasks, |
183 | - function ( $value ) { |
|
183 | + function($value) { |
|
184 | 184 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
185 | 185 | } |
186 | 186 | ); |
187 | - } elseif ( $which_to_include === 'current' ) { |
|
188 | - $cron_tasks = array_filter( $cron_tasks ); |
|
189 | - } elseif ( WP_DEBUG && $which_to_include !== 'all' ) { |
|
187 | + } elseif ($which_to_include === 'current') { |
|
188 | + $cron_tasks = array_filter($cron_tasks); |
|
189 | + } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
190 | 190 | throw new EE_Error( |
191 | 191 | sprintf( |
192 | 192 | __( |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public static function create_cron_tasks() { |
211 | 211 | |
212 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
213 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
214 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
212 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
213 | + if ( ! wp_next_scheduled($hook_name)) { |
|
214 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
226 | 226 | * @throws \EE_Error |
227 | 227 | */ |
228 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
228 | + public static function remove_cron_tasks($remove_all = true) { |
|
229 | 229 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
230 | 230 | $crons = _get_cron_array(); |
231 | - $crons = is_array( $crons ) ? $crons : array(); |
|
231 | + $crons = is_array($crons) ? $crons : array(); |
|
232 | 232 | /* reminder of what $crons look like: |
233 | 233 | * Top-level keys are timestamps, and their values are arrays. |
234 | 234 | * The 2nd level arrays have keys with each of the cron task hook names to run at that time |
@@ -246,23 +246,23 @@ discard block |
||
246 | 246 | * ... |
247 | 247 | * ... |
248 | 248 | */ |
249 | - $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ); |
|
250 | - foreach ( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
251 | - if ( is_array( $hooks_to_fire_at_time ) ) { |
|
252 | - foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
|
253 | - if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
254 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
249 | + $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
250 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
251 | + if (is_array($hooks_to_fire_at_time)) { |
|
252 | + foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
253 | + if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
254 | + && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
255 | 255 | ) { |
256 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
256 | + unset($crons[$timestamp][$hook_name]); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | //also take care of any empty cron timestamps. |
260 | - if ( empty( $hooks_to_fire_at_time ) ) { |
|
261 | - unset( $crons[ $timestamp ] ); |
|
260 | + if (empty($hooks_to_fire_at_time)) { |
|
261 | + unset($crons[$timestamp]); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | } |
265 | - _set_cron_array( $crons ); |
|
265 | + _set_cron_array($crons); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public static function CPT_initialization() { |
279 | 279 | // register Custom Post Types |
280 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
280 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
281 | 281 | flush_rewrite_rules(); |
282 | 282 | } |
283 | 283 | |
@@ -295,11 +295,11 @@ discard block |
||
295 | 295 | * @return void |
296 | 296 | */ |
297 | 297 | public static function reset_and_update_config() { |
298 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
299 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
298 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
299 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
300 | 300 | //EE_Config::reset(); |
301 | - if ( ! EE_Config::logging_enabled() ) { |
|
302 | - delete_option( EE_Config::LOG_NAME ); |
|
301 | + if ( ! EE_Config::logging_enabled()) { |
|
302 | + delete_option(EE_Config::LOG_NAME); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
@@ -312,28 +312,28 @@ discard block |
||
312 | 312 | */ |
313 | 313 | public static function load_calendar_config() { |
314 | 314 | // grab array of all plugin folders and loop thru it |
315 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
316 | - if ( empty( $plugins ) ) { |
|
315 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
316 | + if (empty($plugins)) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | - foreach ( $plugins as $plugin_path ) { |
|
319 | + foreach ($plugins as $plugin_path) { |
|
320 | 320 | // grab plugin folder name from path |
321 | - $plugin = basename( $plugin_path ); |
|
321 | + $plugin = basename($plugin_path); |
|
322 | 322 | // drill down to Espresso plugins |
323 | 323 | // then to calendar related plugins |
324 | 324 | if ( |
325 | - strpos( $plugin, 'espresso' ) !== FALSE |
|
326 | - || strpos( $plugin, 'Espresso' ) !== FALSE |
|
327 | - || strpos( $plugin, 'ee4' ) !== FALSE |
|
328 | - || strpos( $plugin, 'EE4' ) !== FALSE |
|
329 | - || strpos( $plugin, 'calendar' ) !== false |
|
325 | + strpos($plugin, 'espresso') !== FALSE |
|
326 | + || strpos($plugin, 'Espresso') !== FALSE |
|
327 | + || strpos($plugin, 'ee4') !== FALSE |
|
328 | + || strpos($plugin, 'EE4') !== FALSE |
|
329 | + || strpos($plugin, 'calendar') !== false |
|
330 | 330 | ) { |
331 | 331 | // this is what we are looking for |
332 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
332 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
333 | 333 | // does it exist in this folder ? |
334 | - if ( is_readable( $calendar_config )) { |
|
334 | + if (is_readable($calendar_config)) { |
|
335 | 335 | // YEAH! let's load it |
336 | - require_once( $calendar_config ); |
|
336 | + require_once($calendar_config); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | } |
@@ -349,21 +349,21 @@ discard block |
||
349 | 349 | * @param \EE_Config $EE_Config |
350 | 350 | * @return \stdClass |
351 | 351 | */ |
352 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
353 | - $convert_from_array = array( 'addons' ); |
|
352 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
353 | + $convert_from_array = array('addons'); |
|
354 | 354 | // in case old settings were saved as an array |
355 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
355 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
356 | 356 | // convert existing settings to an object |
357 | 357 | $config_array = $settings; |
358 | 358 | $settings = new stdClass(); |
359 | - foreach ( $config_array as $key => $value ){ |
|
360 | - if ( $key === 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
361 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
359 | + foreach ($config_array as $key => $value) { |
|
360 | + if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
361 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
362 | 362 | } else { |
363 | 363 | $settings->{$key} = $value; |
364 | 364 | } |
365 | 365 | } |
366 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
366 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
367 | 367 | } |
368 | 368 | return $settings; |
369 | 369 | } |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | */ |
380 | 380 | public static function deactivate_event_espresso() { |
381 | 381 | // check permissions |
382 | - if ( current_user_can( 'activate_plugins' )) { |
|
383 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
382 | + if (current_user_can('activate_plugins')) { |
|
383 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
@@ -402,25 +402,25 @@ discard block |
||
402 | 402 | $critical_pages = array( |
403 | 403 | array( |
404 | 404 | 'id' =>'reg_page_id', |
405 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
405 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
406 | 406 | 'post' => NULL, |
407 | 407 | 'code' => 'ESPRESSO_CHECKOUT' |
408 | 408 | ), |
409 | 409 | array( |
410 | 410 | 'id' => 'txn_page_id', |
411 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
411 | + 'name' => __('Transactions', 'event_espresso'), |
|
412 | 412 | 'post' => NULL, |
413 | 413 | 'code' => 'ESPRESSO_TXN_PAGE' |
414 | 414 | ), |
415 | 415 | array( |
416 | 416 | 'id' => 'thank_you_page_id', |
417 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
417 | + 'name' => __('Thank You', 'event_espresso'), |
|
418 | 418 | 'post' => NULL, |
419 | 419 | 'code' => 'ESPRESSO_THANK_YOU' |
420 | 420 | ), |
421 | 421 | array( |
422 | 422 | 'id' => 'cancel_page_id', |
423 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
423 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
424 | 424 | 'post' => NULL, |
425 | 425 | 'code' => 'ESPRESSO_CANCELLED' |
426 | 426 | ), |
@@ -428,62 +428,62 @@ discard block |
||
428 | 428 | |
429 | 429 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
430 | 430 | |
431 | - foreach ( $critical_pages as $critical_page ) { |
|
431 | + foreach ($critical_pages as $critical_page) { |
|
432 | 432 | // is critical page ID set in config ? |
433 | - if ( $EE_Core_Config->{$critical_page[ 'id' ]} !== FALSE ) { |
|
433 | + if ($EE_Core_Config->{$critical_page['id']} !== FALSE) { |
|
434 | 434 | // attempt to find post by ID |
435 | - $critical_page['post'] = get_post( $EE_Core_Config->{$critical_page[ 'id' ]} ); |
|
435 | + $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']} ); |
|
436 | 436 | } |
437 | 437 | // no dice? |
438 | - if ( $critical_page['post'] === null ) { |
|
438 | + if ($critical_page['post'] === null) { |
|
439 | 439 | // attempt to find post by title |
440 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
440 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
441 | 441 | // still nothing? |
442 | - if ( $critical_page['post'] === null ) { |
|
443 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
442 | + if ($critical_page['post'] === null) { |
|
443 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
444 | 444 | // REALLY? Still nothing ??!?!? |
445 | - if ( $critical_page['post'] === null ) { |
|
446 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
447 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
445 | + if ($critical_page['post'] === null) { |
|
446 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
447 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
448 | 448 | break; |
449 | 449 | } |
450 | 450 | } |
451 | 451 | } |
452 | 452 | // track post_shortcodes |
453 | - if ( $critical_page['post'] ) { |
|
454 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
453 | + if ($critical_page['post']) { |
|
454 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
455 | 455 | } |
456 | 456 | // check that Post ID matches critical page ID in config |
457 | 457 | if ( |
458 | - isset( $critical_page['post']->ID ) |
|
459 | - && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page[ 'id' ]} |
|
458 | + isset($critical_page['post']->ID) |
|
459 | + && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
460 | 460 | ) { |
461 | 461 | //update Config with post ID |
462 | - $EE_Core_Config->{$critical_page[ 'id' ]} = $critical_page['post']->ID; |
|
463 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
464 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
465 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
462 | + $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
463 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
464 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
465 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
466 | 466 | } |
467 | 467 | } |
468 | 468 | |
469 | 469 | $critical_page_problem = |
470 | - ! isset( $critical_page['post']->post_status ) |
|
470 | + ! isset($critical_page['post']->post_status) |
|
471 | 471 | || $critical_page['post']->post_status !== 'publish' |
472 | - || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE |
|
472 | + || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE |
|
473 | 473 | ? TRUE |
474 | 474 | : $critical_page_problem; |
475 | 475 | |
476 | 476 | } |
477 | 477 | |
478 | - if ( $critical_page_problem ) { |
|
478 | + if ($critical_page_problem) { |
|
479 | 479 | $msg = sprintf( |
480 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
481 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
480 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
481 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
482 | 482 | ); |
483 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
483 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
484 | 484 | } |
485 | - if ( EE_Error::has_notices() ) { |
|
486 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
485 | + if (EE_Error::has_notices()) { |
|
486 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
@@ -495,13 +495,13 @@ discard block |
||
495 | 495 | * parameter to the shortcode |
496 | 496 | * @return WP_Post or NULl |
497 | 497 | */ |
498 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
498 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
499 | 499 | global $wpdb; |
500 | 500 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
501 | 501 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
502 | - if($post_id){ |
|
502 | + if ($post_id) { |
|
503 | 503 | return get_post($post_id); |
504 | - }else{ |
|
504 | + } else { |
|
505 | 505 | return NULL; |
506 | 506 | } |
507 | 507 | |
@@ -518,32 +518,32 @@ discard block |
||
518 | 518 | * @param array $critical_page |
519 | 519 | * @return array |
520 | 520 | */ |
521 | - public static function create_critical_page( $critical_page ) { |
|
521 | + public static function create_critical_page($critical_page) { |
|
522 | 522 | |
523 | 523 | $post_args = array( |
524 | 524 | 'post_title' => $critical_page['name'], |
525 | 525 | 'post_status' => 'publish', |
526 | 526 | 'post_type' => 'page', |
527 | 527 | 'comment_status' => 'closed', |
528 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
528 | + 'post_content' => '['.$critical_page['code'].']' |
|
529 | 529 | ); |
530 | 530 | |
531 | - $post_id = wp_insert_post( $post_args ); |
|
532 | - if ( ! $post_id ) { |
|
531 | + $post_id = wp_insert_post($post_args); |
|
532 | + if ( ! $post_id) { |
|
533 | 533 | $msg = sprintf( |
534 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
534 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
535 | 535 | $critical_page['name'] |
536 | 536 | ); |
537 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
537 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
538 | 538 | return $critical_page; |
539 | 539 | } |
540 | 540 | // get newly created post's details |
541 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
541 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
542 | 542 | $msg = sprintf( |
543 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
543 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
544 | 544 | $critical_page['name'] |
545 | 545 | ); |
546 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
546 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | return $critical_page; |
@@ -562,35 +562,35 @@ discard block |
||
562 | 562 | * @param array $critical_page |
563 | 563 | * @return void |
564 | 564 | */ |
565 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
565 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
566 | 566 | // check the goods |
567 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
567 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
568 | 568 | $msg = sprintf( |
569 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
569 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
570 | 570 | $critical_page['name'] |
571 | 571 | ); |
572 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
572 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
573 | 573 | return; |
574 | 574 | } |
575 | 575 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
576 | 576 | // map shortcode to post |
577 | - $EE_Core_Config->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
577 | + $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
578 | 578 | // and make sure it's NOT added to the WP "Posts Page" |
579 | 579 | // name of the WP Posts Page |
580 | 580 | $posts_page = EE_Config::get_page_for_posts(); |
581 | - if ( isset( $EE_Core_Config->post_shortcodes[ $posts_page ] )) { |
|
582 | - unset( $EE_Core_Config->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
581 | + if (isset($EE_Core_Config->post_shortcodes[$posts_page])) { |
|
582 | + unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]); |
|
583 | 583 | } |
584 | - if ( $posts_page !== 'posts' && isset( $EE_Core_Config->post_shortcodes['posts'] )) { |
|
585 | - unset( $EE_Core_Config->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
584 | + if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) { |
|
585 | + unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]); |
|
586 | 586 | } |
587 | 587 | // update post_shortcode CFG |
588 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
588 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
589 | 589 | $msg = sprintf( |
590 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
590 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
591 | 591 | $critical_page['name'] |
592 | 592 | ); |
593 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
593 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
@@ -608,24 +608,24 @@ discard block |
||
608 | 608 | public static function get_default_creator_id() { |
609 | 609 | global $wpdb; |
610 | 610 | |
611 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
611 | + if ( ! empty(self::$_default_creator_id)) { |
|
612 | 612 | return self::$_default_creator_id; |
613 | 613 | }/**/ |
614 | 614 | |
615 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
615 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
616 | 616 | |
617 | 617 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
618 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
619 | - if ( $pre_filtered_id !== false ) { |
|
618 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
619 | + if ($pre_filtered_id !== false) { |
|
620 | 620 | return (int) $pre_filtered_id; |
621 | 621 | } |
622 | 622 | |
623 | - $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'capabilities' ); |
|
624 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
625 | - $user_id = $wpdb->get_var( $query ); |
|
626 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
627 | - if ( $user_id && (int)$user_id ) { |
|
628 | - self::$_default_creator_id = (int)$user_id; |
|
623 | + $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities'); |
|
624 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
625 | + $user_id = $wpdb->get_var($query); |
|
626 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
627 | + if ($user_id && (int) $user_id) { |
|
628 | + self::$_default_creator_id = (int) $user_id; |
|
629 | 629 | return self::$_default_creator_id; |
630 | 630 | } else { |
631 | 631 | return NULL; |
@@ -654,28 +654,28 @@ discard block |
||
654 | 654 | * @return void |
655 | 655 | * @throws EE_Error if there are database errors |
656 | 656 | */ |
657 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
658 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
657 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
658 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
659 | 659 | return; |
660 | 660 | } |
661 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
662 | - if ( ! function_exists( 'dbDelta' )) { |
|
663 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
661 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
662 | + if ( ! function_exists('dbDelta')) { |
|
663 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
664 | 664 | } |
665 | 665 | $tableAnalysis = \EEH_Activation::getTableAnalysis(); |
666 | - $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix( $table_name ); |
|
666 | + $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name); |
|
667 | 667 | // do we need to first delete an existing version of this table ? |
668 | - if ( $drop_pre_existing_table && $tableAnalysis->tableExists( $wp_table_name ) ){ |
|
668 | + if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) { |
|
669 | 669 | // ok, delete the table... but ONLY if it's empty |
670 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
670 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
671 | 671 | // table is NOT empty, are you SURE you want to delete this table ??? |
672 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
673 | - \EEH_Activation::getTableManager()->dropTable( $wp_table_name ); |
|
674 | - } else if ( ! $deleted_safely ) { |
|
672 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
673 | + \EEH_Activation::getTableManager()->dropTable($wp_table_name); |
|
674 | + } else if ( ! $deleted_safely) { |
|
675 | 675 | // so we should be more cautious rather than just dropping tables so easily |
676 | 676 | EE_Error::add_persistent_admin_notice( |
677 | - 'bad_table_' . $wp_table_name . '_detected', |
|
678 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
677 | + 'bad_table_'.$wp_table_name.'_detected', |
|
678 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
679 | 679 | $wp_table_name, |
680 | 680 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
681 | 681 | '<b>wp-config.php</b>', |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | TRUE ); |
684 | 684 | } |
685 | 685 | } |
686 | - $engine = str_replace( 'ENGINE=', '', $engine ); |
|
687 | - \EEH_Activation::getTableManager()->createTable( $table_name, $sql, $engine ); |
|
686 | + $engine = str_replace('ENGINE=', '', $engine); |
|
687 | + \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -702,8 +702,8 @@ discard block |
||
702 | 702 | * 'VARCHAR(10)' |
703 | 703 | * @return bool|int |
704 | 704 | */ |
705 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
706 | - return \EEH_Activation::getTableManager()->addColumn( $table_name, $column_name, $column_info ); |
|
705 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
706 | + return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | |
@@ -719,8 +719,8 @@ discard block |
||
719 | 719 | * @param string $table_name, without prefixed $wpdb->prefix |
720 | 720 | * @return array of database column names |
721 | 721 | */ |
722 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
723 | - return \EEH_Activation::getTableManager()->getTableColumns( $table_name ); |
|
722 | + public static function get_fields_on_table($table_name = NULL) { |
|
723 | + return \EEH_Activation::getTableManager()->getTableColumns($table_name); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | |
@@ -734,8 +734,8 @@ discard block |
||
734 | 734 | * @param string $table_name |
735 | 735 | * @return bool |
736 | 736 | */ |
737 | - public static function db_table_is_empty( $table_name ) { |
|
738 | - return \EEH_Activation::getTableAnalysis()->tableIsEmpty( $table_name ); |
|
737 | + public static function db_table_is_empty($table_name) { |
|
738 | + return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | |
@@ -748,9 +748,9 @@ discard block |
||
748 | 748 | * @param string $table_name |
749 | 749 | * @return bool | int |
750 | 750 | */ |
751 | - public static function delete_db_table_if_empty( $table_name ) { |
|
752 | - if ( \EEH_Activation::getTableAnalysis()->tableIsEmpty( $table_name ) ) { |
|
753 | - return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
|
751 | + public static function delete_db_table_if_empty($table_name) { |
|
752 | + if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) { |
|
753 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
754 | 754 | } |
755 | 755 | return false; |
756 | 756 | } |
@@ -766,8 +766,8 @@ discard block |
||
766 | 766 | * @param string $table_name |
767 | 767 | * @return bool | int |
768 | 768 | */ |
769 | - public static function delete_unused_db_table( $table_name ) { |
|
770 | - return \EEH_Activation::getTableManager()->dropTable( $table_name ); |
|
769 | + public static function delete_unused_db_table($table_name) { |
|
770 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | |
@@ -782,8 +782,8 @@ discard block |
||
782 | 782 | * @param string $index_name |
783 | 783 | * @return bool | int |
784 | 784 | */ |
785 | - public static function drop_index( $table_name, $index_name ) { |
|
786 | - return \EEH_Activation::getTableManager()->dropIndex( $table_name, $index_name ); |
|
785 | + public static function drop_index($table_name, $index_name) { |
|
786 | + return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | |
@@ -797,27 +797,27 @@ discard block |
||
797 | 797 | * @return boolean success (whether database is setup properly or not) |
798 | 798 | */ |
799 | 799 | public static function create_database_tables() { |
800 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
800 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
801 | 801 | //find the migration script that sets the database to be compatible with the code |
802 | 802 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
803 | - if( $dms_name ){ |
|
804 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
805 | - $current_data_migration_script->set_migrating( false ); |
|
803 | + if ($dms_name) { |
|
804 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
805 | + $current_data_migration_script->set_migrating(false); |
|
806 | 806 | $current_data_migration_script->schema_changes_before_migration(); |
807 | 807 | $current_data_migration_script->schema_changes_after_migration(); |
808 | - if( $current_data_migration_script->get_errors() ){ |
|
809 | - if( WP_DEBUG ){ |
|
810 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
811 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
808 | + if ($current_data_migration_script->get_errors()) { |
|
809 | + if (WP_DEBUG) { |
|
810 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
811 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
812 | 812 | } |
813 | - }else{ |
|
814 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
813 | + } else { |
|
814 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
815 | 815 | } |
816 | 816 | return false; |
817 | 817 | } |
818 | 818 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
819 | - }else{ |
|
820 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
819 | + } else { |
|
820 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
821 | 821 | return false; |
822 | 822 | } |
823 | 823 | return true; |
@@ -837,27 +837,27 @@ discard block |
||
837 | 837 | public static function initialize_system_questions() { |
838 | 838 | // QUESTION GROUPS |
839 | 839 | global $wpdb; |
840 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question_group' ); |
|
840 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group'); |
|
841 | 841 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
842 | 842 | // what we have |
843 | - $question_groups = $wpdb->get_col( $SQL ); |
|
843 | + $question_groups = $wpdb->get_col($SQL); |
|
844 | 844 | // check the response |
845 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
845 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
846 | 846 | // what we should have |
847 | - $QSG_systems = array( 1, 2 ); |
|
847 | + $QSG_systems = array(1, 2); |
|
848 | 848 | // loop thru what we should have and compare to what we have |
849 | - foreach ( $QSG_systems as $QSG_system ) { |
|
849 | + foreach ($QSG_systems as $QSG_system) { |
|
850 | 850 | // reset values array |
851 | 851 | $QSG_values = array(); |
852 | 852 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
853 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
853 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
854 | 854 | // add it |
855 | - switch ( $QSG_system ) { |
|
855 | + switch ($QSG_system) { |
|
856 | 856 | |
857 | 857 | case 1: |
858 | 858 | $QSG_values = array( |
859 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
860 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
859 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
860 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
861 | 861 | 'QSG_desc' => '', |
862 | 862 | 'QSG_order' => 1, |
863 | 863 | 'QSG_show_group_name' => 1, |
@@ -869,8 +869,8 @@ discard block |
||
869 | 869 | |
870 | 870 | case 2: |
871 | 871 | $QSG_values = array( |
872 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
873 | - 'QSG_identifier' => 'address-information-' . time(), |
|
872 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
873 | + 'QSG_identifier' => 'address-information-'.time(), |
|
874 | 874 | 'QSG_desc' => '', |
875 | 875 | 'QSG_order' => 2, |
876 | 876 | 'QSG_show_group_name' => 1, |
@@ -882,14 +882,14 @@ discard block |
||
882 | 882 | |
883 | 883 | } |
884 | 884 | // make sure we have some values before inserting them |
885 | - if ( ! empty( $QSG_values )) { |
|
885 | + if ( ! empty($QSG_values)) { |
|
886 | 886 | // insert system question |
887 | 887 | $wpdb->insert( |
888 | 888 | $table_name, |
889 | 889 | $QSG_values, |
890 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
890 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
891 | 891 | ); |
892 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
892 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
893 | 893 | } |
894 | 894 | } |
895 | 895 | } |
@@ -898,10 +898,10 @@ discard block |
||
898 | 898 | |
899 | 899 | // QUESTIONS |
900 | 900 | global $wpdb; |
901 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question' ); |
|
901 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question'); |
|
902 | 902 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
903 | 903 | // what we have |
904 | - $questions = $wpdb->get_col( $SQL ); |
|
904 | + $questions = $wpdb->get_col($SQL); |
|
905 | 905 | // what we should have |
906 | 906 | $QST_systems = array( |
907 | 907 | 'fname', |
@@ -918,25 +918,25 @@ discard block |
||
918 | 918 | $order_for_group_1 = 1; |
919 | 919 | $order_for_group_2 = 1; |
920 | 920 | // loop thru what we should have and compare to what we have |
921 | - foreach ( $QST_systems as $QST_system ) { |
|
921 | + foreach ($QST_systems as $QST_system) { |
|
922 | 922 | // reset values array |
923 | 923 | $QST_values = array(); |
924 | 924 | // if we don't have what we should have |
925 | - if ( ! in_array( $QST_system, $questions )) { |
|
925 | + if ( ! in_array($QST_system, $questions)) { |
|
926 | 926 | // add it |
927 | - switch ( $QST_system ) { |
|
927 | + switch ($QST_system) { |
|
928 | 928 | |
929 | 929 | case 'fname': |
930 | 930 | $QST_values = array( |
931 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
932 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
931 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
932 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
933 | 933 | 'QST_system' => 'fname', |
934 | 934 | 'QST_type' => 'TEXT', |
935 | 935 | 'QST_required' => 1, |
936 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
936 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
937 | 937 | 'QST_order' => 1, |
938 | 938 | 'QST_admin_only' => 0, |
939 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
939 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
940 | 940 | 'QST_wp_user' => self::get_default_creator_id(), |
941 | 941 | 'QST_deleted' => 0 |
942 | 942 | ); |
@@ -944,15 +944,15 @@ discard block |
||
944 | 944 | |
945 | 945 | case 'lname': |
946 | 946 | $QST_values = array( |
947 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
948 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
947 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
948 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
949 | 949 | 'QST_system' => 'lname', |
950 | 950 | 'QST_type' => 'TEXT', |
951 | 951 | 'QST_required' => 1, |
952 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
952 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
953 | 953 | 'QST_order' => 2, |
954 | 954 | 'QST_admin_only' => 0, |
955 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
955 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
956 | 956 | 'QST_wp_user' => self::get_default_creator_id(), |
957 | 957 | 'QST_deleted' => 0 |
958 | 958 | ); |
@@ -960,15 +960,15 @@ discard block |
||
960 | 960 | |
961 | 961 | case 'email': |
962 | 962 | $QST_values = array( |
963 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
964 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
963 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
964 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
965 | 965 | 'QST_system' => 'email', |
966 | 966 | 'QST_type' => 'EMAIL', |
967 | 967 | 'QST_required' => 1, |
968 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
968 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
969 | 969 | 'QST_order' => 3, |
970 | 970 | 'QST_admin_only' => 0, |
971 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
971 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
972 | 972 | 'QST_wp_user' => self::get_default_creator_id(), |
973 | 973 | 'QST_deleted' => 0 |
974 | 974 | ); |
@@ -976,15 +976,15 @@ discard block |
||
976 | 976 | |
977 | 977 | case 'address': |
978 | 978 | $QST_values = array( |
979 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
980 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
979 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
980 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
981 | 981 | 'QST_system' => 'address', |
982 | 982 | 'QST_type' => 'TEXT', |
983 | 983 | 'QST_required' => 0, |
984 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
984 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
985 | 985 | 'QST_order' => 4, |
986 | 986 | 'QST_admin_only' => 0, |
987 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
987 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
988 | 988 | 'QST_wp_user' => self::get_default_creator_id(), |
989 | 989 | 'QST_deleted' => 0 |
990 | 990 | ); |
@@ -992,15 +992,15 @@ discard block |
||
992 | 992 | |
993 | 993 | case 'address2': |
994 | 994 | $QST_values = array( |
995 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
996 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
995 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
996 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
997 | 997 | 'QST_system' => 'address2', |
998 | 998 | 'QST_type' => 'TEXT', |
999 | 999 | 'QST_required' => 0, |
1000 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1000 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1001 | 1001 | 'QST_order' => 5, |
1002 | 1002 | 'QST_admin_only' => 0, |
1003 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1003 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1004 | 1004 | 'QST_wp_user' => self::get_default_creator_id(), |
1005 | 1005 | 'QST_deleted' => 0 |
1006 | 1006 | ); |
@@ -1008,27 +1008,27 @@ discard block |
||
1008 | 1008 | |
1009 | 1009 | case 'city': |
1010 | 1010 | $QST_values = array( |
1011 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
1012 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
1011 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1012 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1013 | 1013 | 'QST_system' => 'city', |
1014 | 1014 | 'QST_type' => 'TEXT', |
1015 | 1015 | 'QST_required' => 0, |
1016 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1016 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1017 | 1017 | 'QST_order' => 6, |
1018 | 1018 | 'QST_admin_only' => 0, |
1019 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1019 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1020 | 1020 | 'QST_wp_user' => self::get_default_creator_id(), |
1021 | 1021 | 'QST_deleted' => 0 |
1022 | 1022 | ); |
1023 | 1023 | break; |
1024 | 1024 | case 'country' : |
1025 | 1025 | $QST_values = array( |
1026 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1027 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1026 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1027 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1028 | 1028 | 'QST_system' => 'country', |
1029 | 1029 | 'QST_type' => 'COUNTRY', |
1030 | 1030 | 'QST_required' => 0, |
1031 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1031 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1032 | 1032 | 'QST_order' => 7, |
1033 | 1033 | 'QST_admin_only' => 0, |
1034 | 1034 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1038,12 +1038,12 @@ discard block |
||
1038 | 1038 | |
1039 | 1039 | case 'state': |
1040 | 1040 | $QST_values = array( |
1041 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1042 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1041 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1042 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1043 | 1043 | 'QST_system' => 'state', |
1044 | 1044 | 'QST_type' => 'STATE', |
1045 | 1045 | 'QST_required' => 0, |
1046 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1046 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1047 | 1047 | 'QST_order' => 8, |
1048 | 1048 | 'QST_admin_only' => 0, |
1049 | 1049 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1053,15 +1053,15 @@ discard block |
||
1053 | 1053 | |
1054 | 1054 | case 'zip': |
1055 | 1055 | $QST_values = array( |
1056 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1057 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1056 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1057 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1058 | 1058 | 'QST_system' => 'zip', |
1059 | 1059 | 'QST_type' => 'TEXT', |
1060 | 1060 | 'QST_required' => 0, |
1061 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1061 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1062 | 1062 | 'QST_order' => 9, |
1063 | 1063 | 'QST_admin_only' => 0, |
1064 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1064 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1065 | 1065 | 'QST_wp_user' => self::get_default_creator_id(), |
1066 | 1066 | 'QST_deleted' => 0 |
1067 | 1067 | ); |
@@ -1069,49 +1069,49 @@ discard block |
||
1069 | 1069 | |
1070 | 1070 | case 'phone': |
1071 | 1071 | $QST_values = array( |
1072 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1073 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1072 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1073 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1074 | 1074 | 'QST_system' => 'phone', |
1075 | 1075 | 'QST_type' => 'TEXT', |
1076 | 1076 | 'QST_required' => 0, |
1077 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1077 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1078 | 1078 | 'QST_order' => 10, |
1079 | 1079 | 'QST_admin_only' => 0, |
1080 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1080 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1081 | 1081 | 'QST_wp_user' => self::get_default_creator_id(), |
1082 | 1082 | 'QST_deleted' => 0 |
1083 | 1083 | ); |
1084 | 1084 | break; |
1085 | 1085 | |
1086 | 1086 | } |
1087 | - if ( ! empty( $QST_values )) { |
|
1087 | + if ( ! empty($QST_values)) { |
|
1088 | 1088 | // insert system question |
1089 | 1089 | $wpdb->insert( |
1090 | 1090 | $table_name, |
1091 | 1091 | $QST_values, |
1092 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1092 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1093 | 1093 | ); |
1094 | 1094 | $QST_ID = $wpdb->insert_id; |
1095 | 1095 | |
1096 | 1096 | // QUESTION GROUP QUESTIONS |
1097 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
1097 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1098 | 1098 | $system_question_we_want = EEM_Question_Group::system_personal; |
1099 | 1099 | } else { |
1100 | 1100 | $system_question_we_want = EEM_Question_Group::system_address; |
1101 | 1101 | } |
1102 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
1103 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
1102 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1103 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1104 | 1104 | } else { |
1105 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
1106 | - if( is_array( $id_col ) ) { |
|
1107 | - $QSG_ID = reset( $id_col ); |
|
1105 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1106 | + if (is_array($id_col)) { |
|
1107 | + $QSG_ID = reset($id_col); |
|
1108 | 1108 | } else { |
1109 | 1109 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1110 | 1110 | EE_Log::instance()->log( |
1111 | 1111 | __FILE__, |
1112 | 1112 | __FUNCTION__, |
1113 | 1113 | sprintf( |
1114 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1114 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1115 | 1115 | $QST_ID ), |
1116 | 1116 | 'error' ); |
1117 | 1117 | continue; |
@@ -1120,12 +1120,12 @@ discard block |
||
1120 | 1120 | |
1121 | 1121 | // add system questions to groups |
1122 | 1122 | $wpdb->insert( |
1123 | - \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix( 'esp_question_group_question' ), |
|
1124 | - array( 'QSG_ID' => $QSG_ID, |
|
1123 | + \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'), |
|
1124 | + array('QSG_ID' => $QSG_ID, |
|
1125 | 1125 | 'QST_ID' => $QST_ID, |
1126 | - 'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++ |
|
1126 | + 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++ |
|
1127 | 1127 | ), |
1128 | - array( '%d', '%d', '%d' ) |
|
1128 | + array('%d', '%d', '%d') |
|
1129 | 1129 | ); |
1130 | 1130 | } |
1131 | 1131 | } |
@@ -1141,11 +1141,11 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @throws \EE_Error |
1143 | 1143 | */ |
1144 | - public static function insert_default_payment_methods(){ |
|
1145 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1146 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1147 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1148 | - }else{ |
|
1144 | + public static function insert_default_payment_methods() { |
|
1145 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1146 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1147 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1148 | + } else { |
|
1149 | 1149 | EEM_Payment_Method::instance()->verify_button_urls(); |
1150 | 1150 | } |
1151 | 1151 | } |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | |
1162 | 1162 | global $wpdb; |
1163 | 1163 | |
1164 | - if ( \EEH_Activation::getTableAnalysis()->tableExists( EEM_Status::instance()->table() ) ) { |
|
1164 | + if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) { |
|
1165 | 1165 | |
1166 | 1166 | $table_name = EEM_Status::instance()->table(); |
1167 | 1167 | |
@@ -1237,33 +1237,33 @@ discard block |
||
1237 | 1237 | $folders = array( |
1238 | 1238 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1239 | 1239 | EVENT_ESPRESSO_GATEWAY_DIR, |
1240 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1241 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1242 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1240 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1241 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1242 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1243 | 1243 | ); |
1244 | - foreach ( $folders as $folder ) { |
|
1244 | + foreach ($folders as $folder) { |
|
1245 | 1245 | try { |
1246 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1247 | - @ chmod( $folder, 0755 ); |
|
1248 | - } catch( EE_Error $e ){ |
|
1246 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1247 | + @ chmod($folder, 0755); |
|
1248 | + } catch (EE_Error $e) { |
|
1249 | 1249 | EE_Error::add_error( |
1250 | 1250 | sprintf( |
1251 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1251 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1252 | 1252 | $folder, |
1253 | - '<br />' . $e->getMessage() |
|
1253 | + '<br />'.$e->getMessage() |
|
1254 | 1254 | ), |
1255 | 1255 | __FILE__, __FUNCTION__, __LINE__ |
1256 | 1256 | ); |
1257 | 1257 | //indicate we'll need to fix this later |
1258 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1258 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1259 | 1259 | return FALSE; |
1260 | 1260 | } |
1261 | 1261 | } |
1262 | 1262 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1263 | 1263 | //is disabled, there might be activation errors recorded in there |
1264 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
1264 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1265 | 1265 | //remember EE's folders are all good |
1266 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1266 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1267 | 1267 | return TRUE; |
1268 | 1268 | } |
1269 | 1269 | |
@@ -1276,7 +1276,7 @@ discard block |
||
1276 | 1276 | * @return boolean |
1277 | 1277 | */ |
1278 | 1278 | public static function upload_directories_incomplete() { |
1279 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1279 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1280 | 1280 | } |
1281 | 1281 | |
1282 | 1282 | |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | */ |
1294 | 1294 | public static function generate_default_message_templates() { |
1295 | 1295 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1296 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1296 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1297 | 1297 | /* |
1298 | 1298 | * This first method is taking care of ensuring any default messengers |
1299 | 1299 | * that should be made active and have templates generated are done. |
@@ -1329,22 +1329,22 @@ discard block |
||
1329 | 1329 | $active_messengers = $message_resource_manager->active_messengers(); |
1330 | 1330 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1331 | 1331 | $templates_created = false; |
1332 | - foreach ( $active_messengers as $active_messenger ) { |
|
1332 | + foreach ($active_messengers as $active_messenger) { |
|
1333 | 1333 | $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
1334 | 1334 | $default_message_type_names_to_activate = array(); |
1335 | 1335 | // looping through each default message type reported by the messenger |
1336 | 1336 | // and setup the actual message types to activate. |
1337 | - foreach ( $default_message_type_names_for_messenger as $default_message_type_name_for_messenger ) { |
|
1337 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1338 | 1338 | // if already active or has already been activated before we skip |
1339 | 1339 | // (otherwise we might reactivate something user's intentionally deactivated.) |
1340 | 1340 | // we also skip if the message type is not installed. |
1341 | 1341 | if ( |
1342 | - $message_resource_manager->has_message_type_been_activated_for_messenger( $default_message_type_name_for_messenger, $active_messenger->name ) |
|
1342 | + $message_resource_manager->has_message_type_been_activated_for_messenger($default_message_type_name_for_messenger, $active_messenger->name) |
|
1343 | 1343 | || $message_resource_manager->is_message_type_active_for_messenger( |
1344 | 1344 | $active_messenger->name, |
1345 | 1345 | $default_message_type_name_for_messenger |
1346 | 1346 | ) |
1347 | - || ! isset( $installed_message_types[ $default_message_type_name_for_messenger ] ) |
|
1347 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1348 | 1348 | ) { |
1349 | 1349 | continue; |
1350 | 1350 | } |
@@ -1357,7 +1357,7 @@ discard block |
||
1357 | 1357 | false |
1358 | 1358 | ); |
1359 | 1359 | //activate the templates for these message types |
1360 | - if ( ! empty( $default_message_type_names_to_activate ) ) { |
|
1360 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
1361 | 1361 | $templates_created = EEH_MSG_Template::generate_new_templates( |
1362 | 1362 | $active_messenger->name, |
1363 | 1363 | $default_message_type_names_for_messenger, |
@@ -1384,18 +1384,18 @@ discard block |
||
1384 | 1384 | EE_Message_Resource_Manager $message_resource_manager |
1385 | 1385 | ) { |
1386 | 1386 | /** @type EE_messenger[] $messengers_to_generate */ |
1387 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation( $message_resource_manager ); |
|
1387 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1388 | 1388 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1389 | 1389 | $templates_generated = false; |
1390 | - foreach ( $messengers_to_generate as $messenger_to_generate ) { |
|
1390 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1391 | 1391 | $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
1392 | 1392 | //verify the default message types match an installed message type. |
1393 | - foreach ( $default_message_type_names_for_messenger as $key => $name ) { |
|
1393 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1394 | 1394 | if ( |
1395 | - ! isset( $installed_message_types[ $name ] ) |
|
1396 | - || $message_resource_manager->has_message_type_been_activated_for_messenger( $name, $messenger_to_generate->name ) |
|
1395 | + ! isset($installed_message_types[$name]) |
|
1396 | + || $message_resource_manager->has_message_type_been_activated_for_messenger($name, $messenger_to_generate->name) |
|
1397 | 1397 | ) { |
1398 | - unset( $default_message_type_names_for_messenger[ $key ] ); |
|
1398 | + unset($default_message_type_names_for_messenger[$key]); |
|
1399 | 1399 | } |
1400 | 1400 | } |
1401 | 1401 | // in previous iterations, the active_messengers option in the db |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | false |
1410 | 1410 | ); |
1411 | 1411 | //create any templates needing created (or will reactivate templates already generated as necessary). |
1412 | - if ( ! empty( $default_message_type_names_for_messenger ) ) { |
|
1412 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
1413 | 1413 | $templates_generated = EEH_MSG_Template::generate_new_templates( |
1414 | 1414 | $messenger_to_generate->name, |
1415 | 1415 | $default_message_type_names_for_messenger, |
@@ -1441,18 +1441,18 @@ discard block |
||
1441 | 1441 | $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
1442 | 1442 | |
1443 | 1443 | $messengers_to_generate = array(); |
1444 | - foreach ( $installed_messengers as $installed_messenger ) { |
|
1444 | + foreach ($installed_messengers as $installed_messenger) { |
|
1445 | 1445 | //if installed messenger is a messenger that should be activated on install |
1446 | 1446 | //and is not already active |
1447 | 1447 | //and has never been activated |
1448 | 1448 | if ( |
1449 | 1449 | ! $installed_messenger->activate_on_install |
1450 | - || isset( $active_messengers[ $installed_messenger->name ] ) |
|
1451 | - || isset( $has_activated[ $installed_messenger->name ] ) |
|
1450 | + || isset($active_messengers[$installed_messenger->name]) |
|
1451 | + || isset($has_activated[$installed_messenger->name]) |
|
1452 | 1452 | ) { |
1453 | 1453 | continue; |
1454 | 1454 | } |
1455 | - $messengers_to_generate[ $installed_messenger->name ] = $installed_messenger; |
|
1455 | + $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1456 | 1456 | } |
1457 | 1457 | return $messengers_to_generate; |
1458 | 1458 | } |
@@ -1477,9 +1477,9 @@ discard block |
||
1477 | 1477 | */ |
1478 | 1478 | public static function validate_messages_system() { |
1479 | 1479 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1480 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1480 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1481 | 1481 | $message_resource_manager->validate_active_message_types_are_installed(); |
1482 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1482 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | |
@@ -1492,12 +1492,12 @@ discard block |
||
1492 | 1492 | * @static |
1493 | 1493 | * @return void |
1494 | 1494 | */ |
1495 | - public static function create_no_ticket_prices_array(){ |
|
1495 | + public static function create_no_ticket_prices_array() { |
|
1496 | 1496 | // this creates an array for tracking events that have no active ticket prices created |
1497 | 1497 | // this allows us to warn admins of the situation so that it can be corrected |
1498 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1499 | - if ( ! $espresso_no_ticket_prices ) { |
|
1500 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1498 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1499 | + if ( ! $espresso_no_ticket_prices) { |
|
1500 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1501 | 1501 | } |
1502 | 1502 | } |
1503 | 1503 | |
@@ -1522,24 +1522,24 @@ discard block |
||
1522 | 1522 | * @global wpdb $wpdb |
1523 | 1523 | * @throws \EE_Error |
1524 | 1524 | */ |
1525 | - public static function delete_all_espresso_cpt_data(){ |
|
1525 | + public static function delete_all_espresso_cpt_data() { |
|
1526 | 1526 | global $wpdb; |
1527 | 1527 | //get all the CPT post_types |
1528 | 1528 | $ee_post_types = array(); |
1529 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1530 | - if ( method_exists( $model_name, 'instance' )) { |
|
1531 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1532 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1533 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1529 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1530 | + if (method_exists($model_name, 'instance')) { |
|
1531 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1532 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1533 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1534 | 1534 | } |
1535 | 1535 | } |
1536 | 1536 | } |
1537 | 1537 | //get all our CPTs |
1538 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1538 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1539 | 1539 | $cpt_ids = $wpdb->get_col($query); |
1540 | 1540 | //delete each post meta and term relations too |
1541 | - foreach($cpt_ids as $post_id){ |
|
1542 | - wp_delete_post($post_id,true); |
|
1541 | + foreach ($cpt_ids as $post_id) { |
|
1542 | + wp_delete_post($post_id, true); |
|
1543 | 1543 | } |
1544 | 1544 | } |
1545 | 1545 | |
@@ -1551,12 +1551,12 @@ discard block |
||
1551 | 1551 | public static function drop_espresso_tables() { |
1552 | 1552 | $tables = array(); |
1553 | 1553 | // load registry |
1554 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1555 | - if ( method_exists( $model_name, 'instance' )) { |
|
1556 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1557 | - if ( $model_obj instanceof EEM_Base ) { |
|
1558 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1559 | - if ( strpos( $table->get_table_name(), 'esp_' ) |
|
1554 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1555 | + if (method_exists($model_name, 'instance')) { |
|
1556 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1557 | + if ($model_obj instanceof EEM_Base) { |
|
1558 | + foreach ($model_obj->get_tables() as $table) { |
|
1559 | + if (strpos($table->get_table_name(), 'esp_') |
|
1560 | 1560 | && |
1561 | 1561 | ( |
1562 | 1562 | is_main_site()//main site? nuke them all |
@@ -1579,10 +1579,10 @@ discard block |
||
1579 | 1579 | 'esp_promotion_rule', |
1580 | 1580 | 'esp_rule' |
1581 | 1581 | ); |
1582 | - foreach( $tables_without_models as $table ){ |
|
1582 | + foreach ($tables_without_models as $table) { |
|
1583 | 1583 | $tables[] = $table; |
1584 | 1584 | } |
1585 | - return \EEH_Activation::getTableManager()->dropTables( $tables ); |
|
1585 | + return \EEH_Activation::getTableManager()->dropTables($tables); |
|
1586 | 1586 | } |
1587 | 1587 | |
1588 | 1588 | /** |
@@ -1594,8 +1594,8 @@ discard block |
||
1594 | 1594 | * @param array $table_names |
1595 | 1595 | * @return array of table names which we deleted |
1596 | 1596 | */ |
1597 | - public static function drop_tables( $table_names ) { |
|
1598 | - return \EEH_Activation::getTableManager()->dropTables( $table_names ); |
|
1597 | + public static function drop_tables($table_names) { |
|
1598 | + return \EEH_Activation::getTableManager()->dropTables($table_names); |
|
1599 | 1599 | } |
1600 | 1600 | /** |
1601 | 1601 | * plugin_uninstall |
@@ -1605,7 +1605,7 @@ discard block |
||
1605 | 1605 | * @param bool $remove_all |
1606 | 1606 | * @return void |
1607 | 1607 | */ |
1608 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1608 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1609 | 1609 | global $wpdb; |
1610 | 1610 | self::drop_espresso_tables(); |
1611 | 1611 | |
@@ -1643,50 +1643,50 @@ discard block |
||
1643 | 1643 | 'ee_job_parameters_' => false, |
1644 | 1644 | 'ee_upload_directories_incomplete' => true, |
1645 | 1645 | ); |
1646 | - if( is_main_site() ) { |
|
1647 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1646 | + if (is_main_site()) { |
|
1647 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1648 | 1648 | } |
1649 | 1649 | |
1650 | 1650 | $undeleted_options = array(); |
1651 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1651 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1652 | 1652 | |
1653 | - if( $no_wildcard ){ |
|
1654 | - if( ! delete_option( $option_name ) ){ |
|
1653 | + if ($no_wildcard) { |
|
1654 | + if ( ! delete_option($option_name)) { |
|
1655 | 1655 | $undeleted_options[] = $option_name; |
1656 | 1656 | } |
1657 | - }else{ |
|
1658 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1659 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1660 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1657 | + } else { |
|
1658 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1659 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1660 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1661 | 1661 | $undeleted_options[] = $option_name_from_wildcard; |
1662 | 1662 | } |
1663 | 1663 | } |
1664 | 1664 | } |
1665 | 1665 | } |
1666 | 1666 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1667 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1667 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1668 | 1668 | |
1669 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1669 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1670 | 1670 | $db_update_sans_ee4 = array(); |
1671 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1672 | - if( (string)$version[0] === '3'){//if its NON EE4 |
|
1671 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1672 | + if ((string) $version[0] === '3') {//if its NON EE4 |
|
1673 | 1673 | $db_update_sans_ee4[$version] = $times_activated; |
1674 | 1674 | } |
1675 | 1675 | } |
1676 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1676 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | $errors = ''; |
1680 | - if ( ! empty( $undeleted_options )) { |
|
1680 | + if ( ! empty($undeleted_options)) { |
|
1681 | 1681 | $errors .= sprintf( |
1682 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1682 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1683 | 1683 | '<br/>', |
1684 | - implode( ',<br/>', $undeleted_options ) |
|
1684 | + implode(',<br/>', $undeleted_options) |
|
1685 | 1685 | ); |
1686 | 1686 | |
1687 | 1687 | } |
1688 | - if ( ! empty( $errors ) ) { |
|
1689 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1688 | + if ( ! empty($errors)) { |
|
1689 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1690 | 1690 | } |
1691 | 1691 | } |
1692 | 1692 | |
@@ -1696,10 +1696,10 @@ discard block |
||
1696 | 1696 | */ |
1697 | 1697 | public static function last_wpdb_error_code() { |
1698 | 1698 | global $wpdb; |
1699 | - if( $wpdb->use_mysqli ) { |
|
1700 | - return mysqli_errno( $wpdb->dbh ); |
|
1699 | + if ($wpdb->use_mysqli) { |
|
1700 | + return mysqli_errno($wpdb->dbh); |
|
1701 | 1701 | } else { |
1702 | - return mysql_errno( $wpdb->dbh ); |
|
1702 | + return mysql_errno($wpdb->dbh); |
|
1703 | 1703 | } |
1704 | 1704 | } |
1705 | 1705 | |
@@ -1710,14 +1710,14 @@ discard block |
||
1710 | 1710 | * @param string $table_name with or without $wpdb->prefix |
1711 | 1711 | * @return boolean |
1712 | 1712 | */ |
1713 | - public static function table_exists( $table_name ){ |
|
1714 | - return \EEH_Activation::getTableAnalysis()->tableExists( $table_name ); |
|
1713 | + public static function table_exists($table_name) { |
|
1714 | + return \EEH_Activation::getTableAnalysis()->tableExists($table_name); |
|
1715 | 1715 | } |
1716 | 1716 | |
1717 | 1717 | /** |
1718 | 1718 | * Resets the cache on EEH_Activation |
1719 | 1719 | */ |
1720 | - public static function reset(){ |
|
1720 | + public static function reset() { |
|
1721 | 1721 | self::$_default_creator_id = NULL; |
1722 | 1722 | self::$_initialized_db_content_already_in_this_request = false; |
1723 | 1723 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -17,818 +17,818 @@ discard block |
||
17 | 17 | class EED_Core_Rest_Api extends \EED_Module |
18 | 18 | { |
19 | 19 | |
20 | - const ee_api_namespace = 'ee/v'; |
|
20 | + const ee_api_namespace = 'ee/v'; |
|
21 | 21 | |
22 | - const ee_api_namespace_for_regex = 'ee\/v([^/]*)\/'; |
|
22 | + const ee_api_namespace_for_regex = 'ee\/v([^/]*)\/'; |
|
23 | 23 | |
24 | - const saved_routes_option_names = 'ee_core_routes'; |
|
24 | + const saved_routes_option_names = 'ee_core_routes'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * string used in _links response bodies to make them globally unique. |
|
28 | - * |
|
29 | - * @see http://v2.wp-api.org/extending/linking/ |
|
30 | - */ |
|
31 | - const ee_api_link_namespace = 'https://api.eventespresso.com/'; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var Calculated_Model_Fields |
|
35 | - */ |
|
36 | - protected static $_field_calculator = null; |
|
37 | - |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @return EED_Core_Rest_Api |
|
42 | - */ |
|
43 | - public static function instance() |
|
44 | - { |
|
45 | - self::$_field_calculator = new Calculated_Model_Fields(); |
|
46 | - return parent::get_instance(__CLASS__); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
53 | - * |
|
54 | - * @access public |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public static function set_hooks() |
|
58 | - { |
|
59 | - self::set_hooks_both(); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
66 | - * |
|
67 | - * @access public |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - public static function set_hooks_admin() |
|
71 | - { |
|
72 | - self::set_hooks_both(); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - public static function set_hooks_both() |
|
78 | - { |
|
79 | - add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
80 | - add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
81 | - add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
82 | - add_filter('rest_index', |
|
83 | - array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
84 | - EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * sets up hooks which only need to be included as part of REST API requests; |
|
91 | - * other requests like to the frontend or admin etc don't need them |
|
92 | - */ |
|
93 | - public static function set_hooks_rest_api() |
|
94 | - { |
|
95 | - //set hooks which account for changes made to the API |
|
96 | - EED_Core_Rest_Api::_set_hooks_for_changes(); |
|
97 | - EED_Core_Rest_Api::maybe_notify_of_basic_auth_removal(); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * public wrapper of _set_hooks_for_changes. |
|
104 | - * Loads all the hooks which make requests to old versions of the API |
|
105 | - * appear the same as they always did |
|
106 | - */ |
|
107 | - public static function set_hooks_for_changes() |
|
108 | - { |
|
109 | - self::_set_hooks_for_changes(); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * If the user appears to be using WP API basic auth, tell them (via a persistent |
|
116 | - * admin notice and an email) that we're going to remove it soon, so they should |
|
117 | - * replace it with application passwords. |
|
118 | - */ |
|
119 | - public static function maybe_notify_of_basic_auth_removal() |
|
120 | - { |
|
121 | - if ( |
|
122 | - apply_filters( |
|
123 | - 'FHEE__EED_Core_Rest_Api__maybe_notify_of_basic_auth_removal__override', |
|
124 | - ! isset($_SERVER['PHP_AUTH_USER']) |
|
125 | - && ! isset($_SERVER['HTTP_AUTHORIZATION']) |
|
126 | - ) |
|
127 | - ) { |
|
128 | - //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
|
129 | - return; |
|
130 | - } |
|
131 | - //ok they're using the WP API with Basic Auth |
|
132 | - $message = sprintf( |
|
133 | - __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', |
|
134 | - 'event_espresso'), |
|
135 | - '<a href="https://wordpress.org/plugins/application-passwords/">', |
|
136 | - '</a>', |
|
137 | - '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
|
138 | - '<br/>' |
|
139 | - ); |
|
140 | - EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
141 | - if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
142 | - add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
143 | - //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
|
144 | - add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
145 | - //and send the message to the site admin too |
|
146 | - wp_mail(get_option('admin_email'), |
|
147 | - __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
148 | - remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * Loads all the hooks which make requests to old versions of the API |
|
156 | - * appear the same as they always did |
|
157 | - */ |
|
158 | - protected static function _set_hooks_for_changes() |
|
159 | - { |
|
160 | - $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES . 'rest_api' . DS . 'changes'), false); |
|
161 | - foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
162 | - //ignore the base parent class |
|
163 | - if ($classname_in_namespace === 'Changes_In_Base') { |
|
164 | - continue; |
|
165 | - } |
|
166 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
167 | - if (class_exists($full_classname)) { |
|
168 | - $instance_of_class = new $full_classname; |
|
169 | - if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
170 | - $instance_of_class->set_hooks(); |
|
171 | - } |
|
172 | - } |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * Filters the WP routes to add our EE-related ones. This takes a bit of time |
|
180 | - * so we actually prefer to only do it when an EE plugin is activated or upgraded |
|
181 | - */ |
|
182 | - public static function register_routes() |
|
183 | - { |
|
184 | - foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
185 | - foreach ($relative_urls as $endpoint => $routes) { |
|
186 | - foreach ($routes as $route) { |
|
187 | - register_rest_route( |
|
188 | - $namespace, |
|
189 | - $endpoint, |
|
190 | - array( |
|
191 | - 'callback' => $route['callback'], |
|
192 | - 'methods' => $route['methods'], |
|
193 | - 'args' => isset($route['args']) ? $route['args'] : array(), |
|
194 | - ) |
|
195 | - ); |
|
196 | - } |
|
197 | - } |
|
198 | - } |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * Checks if there was a version change or something that merits invalidating the cached |
|
205 | - * route data. If so, invalidates the cached route data so that it gets refreshed |
|
206 | - * next time the WP API is used |
|
207 | - */ |
|
208 | - public static function invalidate_cached_route_data_on_version_change() |
|
209 | - { |
|
210 | - if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
211 | - EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
212 | - } |
|
213 | - foreach (EE_Registry::instance()->addons as $addon) { |
|
214 | - if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
215 | - EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
216 | - } |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * Removes the cached route data so it will get refreshed next time the WP API is used |
|
224 | - */ |
|
225 | - public static function invalidate_cached_route_data() |
|
226 | - { |
|
227 | - //delete the saved EE REST API routes |
|
228 | - foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
|
229 | - delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version); |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * Gets the EE route data |
|
237 | - * |
|
238 | - * @return array top-level key is the namespace, next-level key is the route and its value is array{ |
|
239 | - * @type string|array $callback |
|
240 | - * @type string $methods |
|
241 | - * @type boolean $hidden_endpoint |
|
242 | - * } |
|
243 | - */ |
|
244 | - public static function get_ee_route_data() |
|
245 | - { |
|
246 | - $ee_routes = array(); |
|
247 | - foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
248 | - $ee_routes[self::ee_api_namespace . $version] = self::_get_ee_route_data_for_version($version, |
|
249 | - $hidden_endpoints); |
|
250 | - } |
|
251 | - return $ee_routes; |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * Gets the EE route data from the wp options if it exists already, |
|
258 | - * otherwise re-generates it and saves it to the option |
|
259 | - * |
|
260 | - * @param string $version |
|
261 | - * @param boolean $hidden_endpoints |
|
262 | - * @return array |
|
263 | - */ |
|
264 | - protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
265 | - { |
|
266 | - $ee_routes = get_option(self::saved_routes_option_names . $version, null); |
|
267 | - if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
268 | - $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
269 | - } |
|
270 | - return $ee_routes; |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * Saves the EE REST API route data to a wp option and returns it |
|
277 | - * |
|
278 | - * @param string $version |
|
279 | - * @param boolean $hidden_endpoints |
|
280 | - * @return mixed|null|void |
|
281 | - */ |
|
282 | - protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
283 | - { |
|
284 | - $instance = self::instance(); |
|
285 | - $routes = apply_filters( |
|
286 | - 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
|
287 | - array_replace_recursive( |
|
288 | - $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
289 | - $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
290 | - $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
291 | - $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
292 | - ) |
|
293 | - ); |
|
294 | - $option_name = self::saved_routes_option_names . $version; |
|
295 | - if (get_option($option_name)) { |
|
296 | - update_option($option_name, $routes, true); |
|
297 | - } else { |
|
298 | - add_option($option_name, $routes, null, 'no'); |
|
299 | - } |
|
300 | - return $routes; |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * Calculates all the EE routes and saves it to a wordpress option so we don't |
|
307 | - * need to calculate it on every request |
|
308 | - * |
|
309 | - * @deprecated since version 4.9.1 |
|
310 | - * @return void |
|
311 | - */ |
|
312 | - public static function save_ee_routes() |
|
313 | - { |
|
314 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
315 | - $instance = self::instance(); |
|
316 | - $routes = apply_filters( |
|
317 | - 'EED_Core_Rest_Api__save_ee_routes__routes', |
|
318 | - array_replace_recursive( |
|
319 | - $instance->_register_config_routes(), |
|
320 | - $instance->_register_meta_routes(), |
|
321 | - $instance->_register_model_routes(), |
|
322 | - $instance->_register_rpc_routes() |
|
323 | - ) |
|
324 | - ); |
|
325 | - update_option(self::saved_routes_option_names, $routes, true); |
|
326 | - } |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - |
|
331 | - /** |
|
332 | - * Gets all the route information relating to EE models |
|
333 | - * |
|
334 | - * @return array @see get_ee_route_data |
|
335 | - * @deprecated since version 4.9.1 |
|
336 | - */ |
|
337 | - protected function _register_model_routes() |
|
338 | - { |
|
339 | - $model_routes = array(); |
|
340 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
341 | - $model_routes[EED_Core_Rest_Api::ee_api_namespace |
|
342 | - . $version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
343 | - } |
|
344 | - return $model_routes; |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * Gets the route data for EE models in the specified version |
|
351 | - * |
|
352 | - * @param string $version |
|
353 | - * @param boolean $hidden_endpoint |
|
354 | - * @return array |
|
355 | - */ |
|
356 | - protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) |
|
357 | - { |
|
358 | - $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
359 | - $models_to_register = apply_filters( |
|
360 | - 'FHEE__EED_Core_REST_API___register_model_routes', |
|
361 | - $model_version_info->models_for_requested_version() |
|
362 | - ); |
|
363 | - //let's not bother having endpoints for extra metas |
|
364 | - unset($models_to_register['Extra_Meta']); |
|
365 | - unset($models_to_register['Extra_Join']); |
|
366 | - $model_routes = array(); |
|
367 | - foreach ($models_to_register as $model_name => $model_classname) { |
|
368 | - $model = \EE_Registry::instance()->load_model($model_name); |
|
369 | - //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
|
370 | - $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
371 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)'; |
|
372 | - $model_routes[$plural_model_route] = array( |
|
373 | - array( |
|
374 | - 'callback' => array( |
|
375 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
376 | - 'handle_request_get_all', |
|
377 | - ), |
|
378 | - 'methods' => WP_REST_Server::READABLE, |
|
379 | - 'hidden_endpoint' => $hidden_endpoint, |
|
380 | - 'args' => $this->_get_read_query_params($model, $version), |
|
381 | - '_links' => array( |
|
382 | - 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route), |
|
383 | - ), |
|
384 | - ), |
|
385 | - // array( |
|
386 | - // 'callback' => array( |
|
387 | - // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
388 | - // 'handle_request_create_one' ), |
|
389 | - // 'methods' => WP_REST_Server::CREATABLE, |
|
390 | - // 'hidden_endpoint' => $hidden_endpoint |
|
391 | - // ) |
|
392 | - ); |
|
393 | - $model_routes[$singular_model_route] = array( |
|
394 | - array( |
|
395 | - 'callback' => array( |
|
396 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
397 | - 'handle_request_get_one', |
|
398 | - ), |
|
399 | - 'methods' => WP_REST_Server::READABLE, |
|
400 | - 'hidden_endpoint' => $hidden_endpoint, |
|
401 | - 'args' => $this->_get_response_selection_query_params($model, $version), |
|
402 | - ), |
|
403 | - // array( |
|
404 | - // 'callback' => array( |
|
405 | - // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
406 | - // 'handle_request_edit_one' ), |
|
407 | - // 'methods' => WP_REST_Server::EDITABLE, |
|
408 | - // 'hidden_endpoint' => $hidden_endpoint |
|
409 | - // ), |
|
410 | - ); |
|
411 | - //@todo: also handle DELETE for a single item |
|
412 | - foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
413 | - $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
|
414 | - $relation_name, |
|
415 | - $relation_obj |
|
416 | - ); |
|
417 | - $model_routes[$singular_model_route . '/' . $related_model_name_endpoint_part] = array( |
|
418 | - array( |
|
419 | - 'callback' => array( |
|
420 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
421 | - 'handle_request_get_related', |
|
422 | - ), |
|
423 | - 'methods' => WP_REST_Server::READABLE, |
|
424 | - 'hidden_endpoint' => $hidden_endpoint, |
|
425 | - 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
426 | - ), |
|
427 | - // array( |
|
428 | - // 'callback' => array( |
|
429 | - // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
430 | - // 'handle_request_create_or_update_related' ), |
|
431 | - // 'methods' => WP_REST_Server::EDITABLE, |
|
432 | - // 'hidden_endpoint' => $hidden_endpoint |
|
433 | - // ) |
|
434 | - ); |
|
435 | - //@todo: handle delete related and possibly remove relation (not sure hwo to distinguish) |
|
436 | - } |
|
437 | - } |
|
438 | - return $model_routes; |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * Adds all the RPC-style routes (remote procedure call-like routes, ie |
|
445 | - * routes that don't conform to the traditional REST CRUD-style). |
|
446 | - * |
|
447 | - * @deprecated since 4.9.1 |
|
448 | - */ |
|
449 | - protected function _register_rpc_routes() |
|
450 | - { |
|
451 | - $routes = array(); |
|
452 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
453 | - $routes[self::ee_api_namespace . $version] = $this->_get_rpc_route_data_for_version($version, |
|
454 | - $hidden_endpoint); |
|
455 | - } |
|
456 | - return $routes; |
|
457 | - } |
|
458 | - |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * @param string $version |
|
463 | - * @param boolean $hidden_endpoint |
|
464 | - * @return array |
|
465 | - */ |
|
466 | - protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) |
|
467 | - { |
|
468 | - $this_versions_routes = array(); |
|
469 | - //checkin endpoint |
|
470 | - $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
471 | - array( |
|
472 | - 'callback' => array( |
|
473 | - 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
|
474 | - 'handle_request_toggle_checkin', |
|
475 | - ), |
|
476 | - 'methods' => WP_REST_Server::CREATABLE, |
|
477 | - 'hidden_endpoint' => $hidden_endpoint, |
|
478 | - 'args' => array( |
|
479 | - 'force' => array( |
|
480 | - 'required' => false, |
|
481 | - 'default' => false, |
|
482 | - 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', |
|
483 | - 'event_espresso'), |
|
484 | - ), |
|
485 | - ), |
|
486 | - ), |
|
487 | - ); |
|
488 | - return apply_filters( |
|
489 | - 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
|
490 | - $this_versions_routes, |
|
491 | - $version, |
|
492 | - $hidden_endpoint |
|
493 | - ); |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - |
|
498 | - /** |
|
499 | - * Gets the query params that can be used when request one or many |
|
500 | - * |
|
501 | - * @param EEM_Base $model |
|
502 | - * @param string $version |
|
503 | - * @return array |
|
504 | - */ |
|
505 | - protected function _get_response_selection_query_params(\EEM_Base $model, $version) |
|
506 | - { |
|
507 | - return apply_filters( |
|
508 | - 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
|
509 | - array( |
|
510 | - 'include' => array( |
|
511 | - 'required' => false, |
|
512 | - 'default' => '*', |
|
513 | - ), |
|
514 | - 'calculate' => array( |
|
515 | - 'required' => false, |
|
516 | - 'default' => '', |
|
517 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model), |
|
518 | - ), |
|
519 | - ), |
|
520 | - $model, |
|
521 | - $version |
|
522 | - ); |
|
523 | - } |
|
524 | - |
|
525 | - |
|
526 | - |
|
527 | - /** |
|
528 | - * Gets info about reading query params that are acceptable |
|
529 | - * |
|
530 | - * @param \EEM_Base $model eg 'Event' or 'Venue' |
|
531 | - * @param string $version |
|
532 | - * @return array describing the args acceptable when querying this model |
|
533 | - * @throws \EE_Error |
|
534 | - */ |
|
535 | - protected function _get_read_query_params(\EEM_Base $model, $version) |
|
536 | - { |
|
537 | - $default_orderby = array(); |
|
538 | - foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
539 | - $default_orderby[$key_field->get_name()] = 'ASC'; |
|
540 | - } |
|
541 | - return array_merge( |
|
542 | - $this->_get_response_selection_query_params($model, $version), |
|
543 | - array( |
|
544 | - 'where' => array( |
|
545 | - 'required' => false, |
|
546 | - 'default' => array(), |
|
547 | - ), |
|
548 | - 'limit' => array( |
|
549 | - 'required' => false, |
|
550 | - 'default' => EED_Core_Rest_Api::get_default_query_limit(), |
|
551 | - ), |
|
552 | - 'order_by' => array( |
|
553 | - 'required' => false, |
|
554 | - 'default' => $default_orderby, |
|
555 | - ), |
|
556 | - 'group_by' => array( |
|
557 | - 'required' => false, |
|
558 | - 'default' => null, |
|
559 | - ), |
|
560 | - 'having' => array( |
|
561 | - 'required' => false, |
|
562 | - 'default' => null, |
|
563 | - ), |
|
564 | - 'caps' => array( |
|
565 | - 'required' => false, |
|
566 | - 'default' => EEM_Base::caps_read, |
|
567 | - ), |
|
568 | - ) |
|
569 | - ); |
|
570 | - } |
|
571 | - |
|
572 | - |
|
573 | - |
|
574 | - /** |
|
575 | - * Gets routes for the config |
|
576 | - * |
|
577 | - * @return array @see _register_model_routes |
|
578 | - * @deprecated since version 4.9.1 |
|
579 | - */ |
|
580 | - protected function _register_config_routes() |
|
581 | - { |
|
582 | - $config_routes = array(); |
|
583 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
584 | - $config_routes[self::ee_api_namespace . $version] = $this->_get_config_route_data_for_version($version, |
|
585 | - $hidden_endpoint); |
|
586 | - } |
|
587 | - return $config_routes; |
|
588 | - } |
|
589 | - |
|
590 | - |
|
591 | - |
|
592 | - /** |
|
593 | - * Gets routes for the config for the specified version |
|
594 | - * |
|
595 | - * @param string $version |
|
596 | - * @param boolean $hidden_endpoint |
|
597 | - * @return array |
|
598 | - */ |
|
599 | - protected function _get_config_route_data_for_version($version, $hidden_endpoint) |
|
600 | - { |
|
601 | - return array( |
|
602 | - 'config' => array( |
|
603 | - array( |
|
604 | - 'callback' => array( |
|
605 | - 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
606 | - 'handle_request', |
|
607 | - ), |
|
608 | - 'methods' => WP_REST_Server::READABLE, |
|
609 | - 'hidden_endpoint' => $hidden_endpoint, |
|
610 | - ), |
|
611 | - ), |
|
612 | - 'site_info' => array( |
|
613 | - array( |
|
614 | - 'callback' => array( |
|
615 | - 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
616 | - 'handle_request_site_info', |
|
617 | - ), |
|
618 | - 'methods' => WP_REST_Server::READABLE, |
|
619 | - 'hidden_endpoint' => $hidden_endpoint, |
|
620 | - ), |
|
621 | - ), |
|
622 | - ); |
|
623 | - } |
|
624 | - |
|
625 | - |
|
626 | - |
|
627 | - /** |
|
628 | - * Gets the meta info routes |
|
629 | - * |
|
630 | - * @return array @see _register_model_routes |
|
631 | - * @deprecated since version 4.9.1 |
|
632 | - */ |
|
633 | - protected function _register_meta_routes() |
|
634 | - { |
|
635 | - $meta_routes = array(); |
|
636 | - foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
637 | - $meta_routes[self::ee_api_namespace . $version] = $this->_get_meta_route_data_for_version($version, |
|
638 | - $hidden_endpoint); |
|
639 | - } |
|
640 | - return $meta_routes; |
|
641 | - } |
|
642 | - |
|
643 | - |
|
644 | - |
|
645 | - /** |
|
646 | - * @param string $version |
|
647 | - * @param boolean $hidden_endpoint |
|
648 | - * @return array |
|
649 | - */ |
|
650 | - protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) |
|
651 | - { |
|
652 | - return array( |
|
653 | - 'resources' => array( |
|
654 | - array( |
|
655 | - 'callback' => array( |
|
656 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
|
657 | - 'handle_request_models_meta', |
|
658 | - ), |
|
659 | - 'methods' => WP_REST_Server::READABLE, |
|
660 | - 'hidden_endpoint' => $hidden_endpoint, |
|
661 | - ), |
|
662 | - ), |
|
663 | - ); |
|
664 | - } |
|
665 | - |
|
666 | - |
|
667 | - |
|
668 | - /** |
|
669 | - * Tries to hide old 4.6 endpoints from the |
|
670 | - * |
|
671 | - * @param array $route_data |
|
672 | - * @return array |
|
673 | - */ |
|
674 | - public static function hide_old_endpoints($route_data) |
|
675 | - { |
|
676 | - //allow API clients to override which endpoints get hidden, in case |
|
677 | - //they want to discover particular endpoints |
|
678 | - //also, we don't have access to the request so we have to just grab it from the superglobal |
|
679 | - $force_show_ee_namespace = ltrim( |
|
680 | - EEH_Array::is_set($_REQUEST, 'force_show_ee_namespace', ''), |
|
681 | - '/' |
|
682 | - ); |
|
683 | - foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
684 | - foreach ($relative_urls as $endpoint => $routes) { |
|
685 | - foreach ($routes as $route) { |
|
686 | - //by default, hide "hidden_endpoint"s, unless the request indicates |
|
687 | - //to $force_show_ee_namespace, in which case only show that one |
|
688 | - //namespace's endpoints (and hide all others) |
|
689 | - if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
|
690 | - || ($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace) |
|
691 | - ) { |
|
692 | - $full_route = '/' . ltrim($namespace, '/') . '/' . ltrim($endpoint, '/'); |
|
693 | - unset($route_data[$full_route]); |
|
694 | - } |
|
695 | - } |
|
696 | - } |
|
697 | - } |
|
698 | - return $route_data; |
|
699 | - } |
|
700 | - |
|
701 | - |
|
702 | - |
|
703 | - /** |
|
704 | - * Returns an array describing which versions of core support serving requests for. |
|
705 | - * Keys are core versions' major and minor version, and values are the |
|
706 | - * LOWEST requested version they can serve. Eg, 4.7 can serve requests for 4.6-like |
|
707 | - * data by just removing a few models and fields from the responses. However, 4.15 might remove |
|
708 | - * the answers table entirely, in which case it would be very difficult for |
|
709 | - * it to serve 4.6-style responses. |
|
710 | - * Versions of core that are missing from this array are unknowns. |
|
711 | - * previous ver |
|
712 | - * |
|
713 | - * @return array |
|
714 | - */ |
|
715 | - public static function version_compatibilities() |
|
716 | - { |
|
717 | - return apply_filters( |
|
718 | - 'FHEE__EED_Core_REST_API__version_compatibilities', |
|
719 | - array( |
|
720 | - '4.8.29' => '4.8.29', |
|
721 | - '4.8.33' => '4.8.29', |
|
722 | - '4.8.34' => '4.8.29', |
|
723 | - '4.8.36' => '4.8.29', |
|
724 | - ) |
|
725 | - ); |
|
726 | - } |
|
727 | - |
|
728 | - |
|
729 | - |
|
730 | - /** |
|
731 | - * Gets the latest API version served. Eg if there |
|
732 | - * are two versions served of the API, 4.8.29 and 4.8.32, and |
|
733 | - * we are on core version 4.8.34, it will return the string "4.8.32" |
|
734 | - * |
|
735 | - * @return string |
|
736 | - */ |
|
737 | - public static function latest_rest_api_version() |
|
738 | - { |
|
739 | - $versions_served = \EED_Core_Rest_Api::versions_served(); |
|
740 | - $versions_served_keys = array_keys($versions_served); |
|
741 | - return end($versions_served_keys); |
|
742 | - } |
|
743 | - |
|
744 | - |
|
745 | - |
|
746 | - /** |
|
747 | - * Using EED_Core_Rest_Api::version_compatibilities(), determines what version of |
|
748 | - * EE the API can serve requests for. Eg, if we are on 4.15 of core, and |
|
749 | - * we can serve requests from 4.12 or later, this will return array( '4.12', '4.13', '4.14', '4.15' ). |
|
750 | - * We also indicate whether or not this version should be put in the index or not |
|
751 | - * |
|
752 | - * @return array keys are API version numbers (just major and minor numbers), and values |
|
753 | - * are whether or not they should be hidden |
|
754 | - */ |
|
755 | - public static function versions_served() |
|
756 | - { |
|
757 | - $versions_served = array(); |
|
758 | - $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
|
759 | - $lowest_compatible_version = end($possibly_served_versions); |
|
760 | - reset($possibly_served_versions); |
|
761 | - $versions_served_historically = array_keys($possibly_served_versions); |
|
762 | - $latest_version = end($versions_served_historically); |
|
763 | - reset($versions_served_historically); |
|
764 | - //for each version of core we have ever served: |
|
765 | - foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
766 | - //if it's not above the current core version, and it's compatible with the current version of core |
|
767 | - if ($key_versioned_endpoint == $latest_version) { |
|
768 | - //don't hide the latest version in the index |
|
769 | - $versions_served[$key_versioned_endpoint] = false; |
|
770 | - } else if ( |
|
771 | - $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
|
772 | - && $key_versioned_endpoint >= $lowest_compatible_version |
|
773 | - ) { |
|
774 | - //include, but hide, previous versions which are still supported |
|
775 | - $versions_served[$key_versioned_endpoint] = true; |
|
776 | - } elseif ( |
|
777 | - apply_filters( |
|
778 | - 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
|
779 | - false, |
|
780 | - $possibly_served_versions |
|
781 | - ) |
|
782 | - ) { |
|
783 | - //if a version is no longer supported, don't include it in index or list of versions served |
|
784 | - $versions_served[$key_versioned_endpoint] = true; |
|
785 | - } |
|
786 | - } |
|
787 | - return $versions_served; |
|
788 | - } |
|
789 | - |
|
790 | - |
|
791 | - |
|
792 | - /** |
|
793 | - * Gets the major and minor version of EE core's version string |
|
794 | - * |
|
795 | - * @return string |
|
796 | - */ |
|
797 | - public static function core_version() |
|
798 | - { |
|
799 | - return apply_filters('FHEE__EED_Core_REST_API__core_version', |
|
800 | - implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
801 | - } |
|
802 | - |
|
803 | - |
|
804 | - |
|
805 | - /** |
|
806 | - * Gets the default limit that should be used when querying for resources |
|
807 | - * |
|
808 | - * @return int |
|
809 | - */ |
|
810 | - public static function get_default_query_limit() |
|
811 | - { |
|
812 | - //we actually don't use a const because we want folks to always use |
|
813 | - //this method, not the const directly |
|
814 | - return apply_filters( |
|
815 | - 'FHEE__EED_Core_Rest_Api__get_default_query_limit', |
|
816 | - 50 |
|
817 | - ); |
|
818 | - } |
|
819 | - |
|
820 | - |
|
821 | - |
|
822 | - /** |
|
823 | - * run - initial module setup |
|
824 | - * |
|
825 | - * @access public |
|
826 | - * @param WP $WP |
|
827 | - * @return void |
|
828 | - */ |
|
829 | - public function run($WP) |
|
830 | - { |
|
831 | - } |
|
26 | + /** |
|
27 | + * string used in _links response bodies to make them globally unique. |
|
28 | + * |
|
29 | + * @see http://v2.wp-api.org/extending/linking/ |
|
30 | + */ |
|
31 | + const ee_api_link_namespace = 'https://api.eventespresso.com/'; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var Calculated_Model_Fields |
|
35 | + */ |
|
36 | + protected static $_field_calculator = null; |
|
37 | + |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @return EED_Core_Rest_Api |
|
42 | + */ |
|
43 | + public static function instance() |
|
44 | + { |
|
45 | + self::$_field_calculator = new Calculated_Model_Fields(); |
|
46 | + return parent::get_instance(__CLASS__); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
53 | + * |
|
54 | + * @access public |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public static function set_hooks() |
|
58 | + { |
|
59 | + self::set_hooks_both(); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
66 | + * |
|
67 | + * @access public |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + public static function set_hooks_admin() |
|
71 | + { |
|
72 | + self::set_hooks_both(); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + public static function set_hooks_both() |
|
78 | + { |
|
79 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
80 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
81 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
82 | + add_filter('rest_index', |
|
83 | + array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
84 | + EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * sets up hooks which only need to be included as part of REST API requests; |
|
91 | + * other requests like to the frontend or admin etc don't need them |
|
92 | + */ |
|
93 | + public static function set_hooks_rest_api() |
|
94 | + { |
|
95 | + //set hooks which account for changes made to the API |
|
96 | + EED_Core_Rest_Api::_set_hooks_for_changes(); |
|
97 | + EED_Core_Rest_Api::maybe_notify_of_basic_auth_removal(); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * public wrapper of _set_hooks_for_changes. |
|
104 | + * Loads all the hooks which make requests to old versions of the API |
|
105 | + * appear the same as they always did |
|
106 | + */ |
|
107 | + public static function set_hooks_for_changes() |
|
108 | + { |
|
109 | + self::_set_hooks_for_changes(); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * If the user appears to be using WP API basic auth, tell them (via a persistent |
|
116 | + * admin notice and an email) that we're going to remove it soon, so they should |
|
117 | + * replace it with application passwords. |
|
118 | + */ |
|
119 | + public static function maybe_notify_of_basic_auth_removal() |
|
120 | + { |
|
121 | + if ( |
|
122 | + apply_filters( |
|
123 | + 'FHEE__EED_Core_Rest_Api__maybe_notify_of_basic_auth_removal__override', |
|
124 | + ! isset($_SERVER['PHP_AUTH_USER']) |
|
125 | + && ! isset($_SERVER['HTTP_AUTHORIZATION']) |
|
126 | + ) |
|
127 | + ) { |
|
128 | + //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
|
129 | + return; |
|
130 | + } |
|
131 | + //ok they're using the WP API with Basic Auth |
|
132 | + $message = sprintf( |
|
133 | + __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', |
|
134 | + 'event_espresso'), |
|
135 | + '<a href="https://wordpress.org/plugins/application-passwords/">', |
|
136 | + '</a>', |
|
137 | + '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
|
138 | + '<br/>' |
|
139 | + ); |
|
140 | + EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
141 | + if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
142 | + add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
143 | + //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
|
144 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
145 | + //and send the message to the site admin too |
|
146 | + wp_mail(get_option('admin_email'), |
|
147 | + __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
148 | + remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * Loads all the hooks which make requests to old versions of the API |
|
156 | + * appear the same as they always did |
|
157 | + */ |
|
158 | + protected static function _set_hooks_for_changes() |
|
159 | + { |
|
160 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES . 'rest_api' . DS . 'changes'), false); |
|
161 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
162 | + //ignore the base parent class |
|
163 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
164 | + continue; |
|
165 | + } |
|
166 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
167 | + if (class_exists($full_classname)) { |
|
168 | + $instance_of_class = new $full_classname; |
|
169 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
170 | + $instance_of_class->set_hooks(); |
|
171 | + } |
|
172 | + } |
|
173 | + } |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * Filters the WP routes to add our EE-related ones. This takes a bit of time |
|
180 | + * so we actually prefer to only do it when an EE plugin is activated or upgraded |
|
181 | + */ |
|
182 | + public static function register_routes() |
|
183 | + { |
|
184 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
185 | + foreach ($relative_urls as $endpoint => $routes) { |
|
186 | + foreach ($routes as $route) { |
|
187 | + register_rest_route( |
|
188 | + $namespace, |
|
189 | + $endpoint, |
|
190 | + array( |
|
191 | + 'callback' => $route['callback'], |
|
192 | + 'methods' => $route['methods'], |
|
193 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
194 | + ) |
|
195 | + ); |
|
196 | + } |
|
197 | + } |
|
198 | + } |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * Checks if there was a version change or something that merits invalidating the cached |
|
205 | + * route data. If so, invalidates the cached route data so that it gets refreshed |
|
206 | + * next time the WP API is used |
|
207 | + */ |
|
208 | + public static function invalidate_cached_route_data_on_version_change() |
|
209 | + { |
|
210 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
211 | + EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
212 | + } |
|
213 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
214 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
215 | + EED_Core_Rest_Api::invalidate_cached_route_data(); |
|
216 | + } |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * Removes the cached route data so it will get refreshed next time the WP API is used |
|
224 | + */ |
|
225 | + public static function invalidate_cached_route_data() |
|
226 | + { |
|
227 | + //delete the saved EE REST API routes |
|
228 | + foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
|
229 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version); |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * Gets the EE route data |
|
237 | + * |
|
238 | + * @return array top-level key is the namespace, next-level key is the route and its value is array{ |
|
239 | + * @type string|array $callback |
|
240 | + * @type string $methods |
|
241 | + * @type boolean $hidden_endpoint |
|
242 | + * } |
|
243 | + */ |
|
244 | + public static function get_ee_route_data() |
|
245 | + { |
|
246 | + $ee_routes = array(); |
|
247 | + foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
248 | + $ee_routes[self::ee_api_namespace . $version] = self::_get_ee_route_data_for_version($version, |
|
249 | + $hidden_endpoints); |
|
250 | + } |
|
251 | + return $ee_routes; |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * Gets the EE route data from the wp options if it exists already, |
|
258 | + * otherwise re-generates it and saves it to the option |
|
259 | + * |
|
260 | + * @param string $version |
|
261 | + * @param boolean $hidden_endpoints |
|
262 | + * @return array |
|
263 | + */ |
|
264 | + protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
265 | + { |
|
266 | + $ee_routes = get_option(self::saved_routes_option_names . $version, null); |
|
267 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
268 | + $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
269 | + } |
|
270 | + return $ee_routes; |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * Saves the EE REST API route data to a wp option and returns it |
|
277 | + * |
|
278 | + * @param string $version |
|
279 | + * @param boolean $hidden_endpoints |
|
280 | + * @return mixed|null|void |
|
281 | + */ |
|
282 | + protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) |
|
283 | + { |
|
284 | + $instance = self::instance(); |
|
285 | + $routes = apply_filters( |
|
286 | + 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
|
287 | + array_replace_recursive( |
|
288 | + $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
289 | + $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
290 | + $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
291 | + $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
292 | + ) |
|
293 | + ); |
|
294 | + $option_name = self::saved_routes_option_names . $version; |
|
295 | + if (get_option($option_name)) { |
|
296 | + update_option($option_name, $routes, true); |
|
297 | + } else { |
|
298 | + add_option($option_name, $routes, null, 'no'); |
|
299 | + } |
|
300 | + return $routes; |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * Calculates all the EE routes and saves it to a wordpress option so we don't |
|
307 | + * need to calculate it on every request |
|
308 | + * |
|
309 | + * @deprecated since version 4.9.1 |
|
310 | + * @return void |
|
311 | + */ |
|
312 | + public static function save_ee_routes() |
|
313 | + { |
|
314 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
315 | + $instance = self::instance(); |
|
316 | + $routes = apply_filters( |
|
317 | + 'EED_Core_Rest_Api__save_ee_routes__routes', |
|
318 | + array_replace_recursive( |
|
319 | + $instance->_register_config_routes(), |
|
320 | + $instance->_register_meta_routes(), |
|
321 | + $instance->_register_model_routes(), |
|
322 | + $instance->_register_rpc_routes() |
|
323 | + ) |
|
324 | + ); |
|
325 | + update_option(self::saved_routes_option_names, $routes, true); |
|
326 | + } |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + |
|
331 | + /** |
|
332 | + * Gets all the route information relating to EE models |
|
333 | + * |
|
334 | + * @return array @see get_ee_route_data |
|
335 | + * @deprecated since version 4.9.1 |
|
336 | + */ |
|
337 | + protected function _register_model_routes() |
|
338 | + { |
|
339 | + $model_routes = array(); |
|
340 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
341 | + $model_routes[EED_Core_Rest_Api::ee_api_namespace |
|
342 | + . $version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
343 | + } |
|
344 | + return $model_routes; |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * Gets the route data for EE models in the specified version |
|
351 | + * |
|
352 | + * @param string $version |
|
353 | + * @param boolean $hidden_endpoint |
|
354 | + * @return array |
|
355 | + */ |
|
356 | + protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) |
|
357 | + { |
|
358 | + $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
359 | + $models_to_register = apply_filters( |
|
360 | + 'FHEE__EED_Core_REST_API___register_model_routes', |
|
361 | + $model_version_info->models_for_requested_version() |
|
362 | + ); |
|
363 | + //let's not bother having endpoints for extra metas |
|
364 | + unset($models_to_register['Extra_Meta']); |
|
365 | + unset($models_to_register['Extra_Join']); |
|
366 | + $model_routes = array(); |
|
367 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
368 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
369 | + //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
|
370 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
371 | + $singular_model_route = $plural_model_route . '/(?P<id>\d+)'; |
|
372 | + $model_routes[$plural_model_route] = array( |
|
373 | + array( |
|
374 | + 'callback' => array( |
|
375 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
376 | + 'handle_request_get_all', |
|
377 | + ), |
|
378 | + 'methods' => WP_REST_Server::READABLE, |
|
379 | + 'hidden_endpoint' => $hidden_endpoint, |
|
380 | + 'args' => $this->_get_read_query_params($model, $version), |
|
381 | + '_links' => array( |
|
382 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route), |
|
383 | + ), |
|
384 | + ), |
|
385 | + // array( |
|
386 | + // 'callback' => array( |
|
387 | + // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
388 | + // 'handle_request_create_one' ), |
|
389 | + // 'methods' => WP_REST_Server::CREATABLE, |
|
390 | + // 'hidden_endpoint' => $hidden_endpoint |
|
391 | + // ) |
|
392 | + ); |
|
393 | + $model_routes[$singular_model_route] = array( |
|
394 | + array( |
|
395 | + 'callback' => array( |
|
396 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
397 | + 'handle_request_get_one', |
|
398 | + ), |
|
399 | + 'methods' => WP_REST_Server::READABLE, |
|
400 | + 'hidden_endpoint' => $hidden_endpoint, |
|
401 | + 'args' => $this->_get_response_selection_query_params($model, $version), |
|
402 | + ), |
|
403 | + // array( |
|
404 | + // 'callback' => array( |
|
405 | + // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
406 | + // 'handle_request_edit_one' ), |
|
407 | + // 'methods' => WP_REST_Server::EDITABLE, |
|
408 | + // 'hidden_endpoint' => $hidden_endpoint |
|
409 | + // ), |
|
410 | + ); |
|
411 | + //@todo: also handle DELETE for a single item |
|
412 | + foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
413 | + $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
|
414 | + $relation_name, |
|
415 | + $relation_obj |
|
416 | + ); |
|
417 | + $model_routes[$singular_model_route . '/' . $related_model_name_endpoint_part] = array( |
|
418 | + array( |
|
419 | + 'callback' => array( |
|
420 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
|
421 | + 'handle_request_get_related', |
|
422 | + ), |
|
423 | + 'methods' => WP_REST_Server::READABLE, |
|
424 | + 'hidden_endpoint' => $hidden_endpoint, |
|
425 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
426 | + ), |
|
427 | + // array( |
|
428 | + // 'callback' => array( |
|
429 | + // 'EventEspresso\core\libraries\rest_api\controllers\model\Write', |
|
430 | + // 'handle_request_create_or_update_related' ), |
|
431 | + // 'methods' => WP_REST_Server::EDITABLE, |
|
432 | + // 'hidden_endpoint' => $hidden_endpoint |
|
433 | + // ) |
|
434 | + ); |
|
435 | + //@todo: handle delete related and possibly remove relation (not sure hwo to distinguish) |
|
436 | + } |
|
437 | + } |
|
438 | + return $model_routes; |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * Adds all the RPC-style routes (remote procedure call-like routes, ie |
|
445 | + * routes that don't conform to the traditional REST CRUD-style). |
|
446 | + * |
|
447 | + * @deprecated since 4.9.1 |
|
448 | + */ |
|
449 | + protected function _register_rpc_routes() |
|
450 | + { |
|
451 | + $routes = array(); |
|
452 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
453 | + $routes[self::ee_api_namespace . $version] = $this->_get_rpc_route_data_for_version($version, |
|
454 | + $hidden_endpoint); |
|
455 | + } |
|
456 | + return $routes; |
|
457 | + } |
|
458 | + |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * @param string $version |
|
463 | + * @param boolean $hidden_endpoint |
|
464 | + * @return array |
|
465 | + */ |
|
466 | + protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) |
|
467 | + { |
|
468 | + $this_versions_routes = array(); |
|
469 | + //checkin endpoint |
|
470 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
471 | + array( |
|
472 | + 'callback' => array( |
|
473 | + 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
|
474 | + 'handle_request_toggle_checkin', |
|
475 | + ), |
|
476 | + 'methods' => WP_REST_Server::CREATABLE, |
|
477 | + 'hidden_endpoint' => $hidden_endpoint, |
|
478 | + 'args' => array( |
|
479 | + 'force' => array( |
|
480 | + 'required' => false, |
|
481 | + 'default' => false, |
|
482 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', |
|
483 | + 'event_espresso'), |
|
484 | + ), |
|
485 | + ), |
|
486 | + ), |
|
487 | + ); |
|
488 | + return apply_filters( |
|
489 | + 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
|
490 | + $this_versions_routes, |
|
491 | + $version, |
|
492 | + $hidden_endpoint |
|
493 | + ); |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + |
|
498 | + /** |
|
499 | + * Gets the query params that can be used when request one or many |
|
500 | + * |
|
501 | + * @param EEM_Base $model |
|
502 | + * @param string $version |
|
503 | + * @return array |
|
504 | + */ |
|
505 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) |
|
506 | + { |
|
507 | + return apply_filters( |
|
508 | + 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
|
509 | + array( |
|
510 | + 'include' => array( |
|
511 | + 'required' => false, |
|
512 | + 'default' => '*', |
|
513 | + ), |
|
514 | + 'calculate' => array( |
|
515 | + 'required' => false, |
|
516 | + 'default' => '', |
|
517 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model), |
|
518 | + ), |
|
519 | + ), |
|
520 | + $model, |
|
521 | + $version |
|
522 | + ); |
|
523 | + } |
|
524 | + |
|
525 | + |
|
526 | + |
|
527 | + /** |
|
528 | + * Gets info about reading query params that are acceptable |
|
529 | + * |
|
530 | + * @param \EEM_Base $model eg 'Event' or 'Venue' |
|
531 | + * @param string $version |
|
532 | + * @return array describing the args acceptable when querying this model |
|
533 | + * @throws \EE_Error |
|
534 | + */ |
|
535 | + protected function _get_read_query_params(\EEM_Base $model, $version) |
|
536 | + { |
|
537 | + $default_orderby = array(); |
|
538 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
539 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
540 | + } |
|
541 | + return array_merge( |
|
542 | + $this->_get_response_selection_query_params($model, $version), |
|
543 | + array( |
|
544 | + 'where' => array( |
|
545 | + 'required' => false, |
|
546 | + 'default' => array(), |
|
547 | + ), |
|
548 | + 'limit' => array( |
|
549 | + 'required' => false, |
|
550 | + 'default' => EED_Core_Rest_Api::get_default_query_limit(), |
|
551 | + ), |
|
552 | + 'order_by' => array( |
|
553 | + 'required' => false, |
|
554 | + 'default' => $default_orderby, |
|
555 | + ), |
|
556 | + 'group_by' => array( |
|
557 | + 'required' => false, |
|
558 | + 'default' => null, |
|
559 | + ), |
|
560 | + 'having' => array( |
|
561 | + 'required' => false, |
|
562 | + 'default' => null, |
|
563 | + ), |
|
564 | + 'caps' => array( |
|
565 | + 'required' => false, |
|
566 | + 'default' => EEM_Base::caps_read, |
|
567 | + ), |
|
568 | + ) |
|
569 | + ); |
|
570 | + } |
|
571 | + |
|
572 | + |
|
573 | + |
|
574 | + /** |
|
575 | + * Gets routes for the config |
|
576 | + * |
|
577 | + * @return array @see _register_model_routes |
|
578 | + * @deprecated since version 4.9.1 |
|
579 | + */ |
|
580 | + protected function _register_config_routes() |
|
581 | + { |
|
582 | + $config_routes = array(); |
|
583 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
584 | + $config_routes[self::ee_api_namespace . $version] = $this->_get_config_route_data_for_version($version, |
|
585 | + $hidden_endpoint); |
|
586 | + } |
|
587 | + return $config_routes; |
|
588 | + } |
|
589 | + |
|
590 | + |
|
591 | + |
|
592 | + /** |
|
593 | + * Gets routes for the config for the specified version |
|
594 | + * |
|
595 | + * @param string $version |
|
596 | + * @param boolean $hidden_endpoint |
|
597 | + * @return array |
|
598 | + */ |
|
599 | + protected function _get_config_route_data_for_version($version, $hidden_endpoint) |
|
600 | + { |
|
601 | + return array( |
|
602 | + 'config' => array( |
|
603 | + array( |
|
604 | + 'callback' => array( |
|
605 | + 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
606 | + 'handle_request', |
|
607 | + ), |
|
608 | + 'methods' => WP_REST_Server::READABLE, |
|
609 | + 'hidden_endpoint' => $hidden_endpoint, |
|
610 | + ), |
|
611 | + ), |
|
612 | + 'site_info' => array( |
|
613 | + array( |
|
614 | + 'callback' => array( |
|
615 | + 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
|
616 | + 'handle_request_site_info', |
|
617 | + ), |
|
618 | + 'methods' => WP_REST_Server::READABLE, |
|
619 | + 'hidden_endpoint' => $hidden_endpoint, |
|
620 | + ), |
|
621 | + ), |
|
622 | + ); |
|
623 | + } |
|
624 | + |
|
625 | + |
|
626 | + |
|
627 | + /** |
|
628 | + * Gets the meta info routes |
|
629 | + * |
|
630 | + * @return array @see _register_model_routes |
|
631 | + * @deprecated since version 4.9.1 |
|
632 | + */ |
|
633 | + protected function _register_meta_routes() |
|
634 | + { |
|
635 | + $meta_routes = array(); |
|
636 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
637 | + $meta_routes[self::ee_api_namespace . $version] = $this->_get_meta_route_data_for_version($version, |
|
638 | + $hidden_endpoint); |
|
639 | + } |
|
640 | + return $meta_routes; |
|
641 | + } |
|
642 | + |
|
643 | + |
|
644 | + |
|
645 | + /** |
|
646 | + * @param string $version |
|
647 | + * @param boolean $hidden_endpoint |
|
648 | + * @return array |
|
649 | + */ |
|
650 | + protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) |
|
651 | + { |
|
652 | + return array( |
|
653 | + 'resources' => array( |
|
654 | + array( |
|
655 | + 'callback' => array( |
|
656 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
|
657 | + 'handle_request_models_meta', |
|
658 | + ), |
|
659 | + 'methods' => WP_REST_Server::READABLE, |
|
660 | + 'hidden_endpoint' => $hidden_endpoint, |
|
661 | + ), |
|
662 | + ), |
|
663 | + ); |
|
664 | + } |
|
665 | + |
|
666 | + |
|
667 | + |
|
668 | + /** |
|
669 | + * Tries to hide old 4.6 endpoints from the |
|
670 | + * |
|
671 | + * @param array $route_data |
|
672 | + * @return array |
|
673 | + */ |
|
674 | + public static function hide_old_endpoints($route_data) |
|
675 | + { |
|
676 | + //allow API clients to override which endpoints get hidden, in case |
|
677 | + //they want to discover particular endpoints |
|
678 | + //also, we don't have access to the request so we have to just grab it from the superglobal |
|
679 | + $force_show_ee_namespace = ltrim( |
|
680 | + EEH_Array::is_set($_REQUEST, 'force_show_ee_namespace', ''), |
|
681 | + '/' |
|
682 | + ); |
|
683 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
684 | + foreach ($relative_urls as $endpoint => $routes) { |
|
685 | + foreach ($routes as $route) { |
|
686 | + //by default, hide "hidden_endpoint"s, unless the request indicates |
|
687 | + //to $force_show_ee_namespace, in which case only show that one |
|
688 | + //namespace's endpoints (and hide all others) |
|
689 | + if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
|
690 | + || ($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace) |
|
691 | + ) { |
|
692 | + $full_route = '/' . ltrim($namespace, '/') . '/' . ltrim($endpoint, '/'); |
|
693 | + unset($route_data[$full_route]); |
|
694 | + } |
|
695 | + } |
|
696 | + } |
|
697 | + } |
|
698 | + return $route_data; |
|
699 | + } |
|
700 | + |
|
701 | + |
|
702 | + |
|
703 | + /** |
|
704 | + * Returns an array describing which versions of core support serving requests for. |
|
705 | + * Keys are core versions' major and minor version, and values are the |
|
706 | + * LOWEST requested version they can serve. Eg, 4.7 can serve requests for 4.6-like |
|
707 | + * data by just removing a few models and fields from the responses. However, 4.15 might remove |
|
708 | + * the answers table entirely, in which case it would be very difficult for |
|
709 | + * it to serve 4.6-style responses. |
|
710 | + * Versions of core that are missing from this array are unknowns. |
|
711 | + * previous ver |
|
712 | + * |
|
713 | + * @return array |
|
714 | + */ |
|
715 | + public static function version_compatibilities() |
|
716 | + { |
|
717 | + return apply_filters( |
|
718 | + 'FHEE__EED_Core_REST_API__version_compatibilities', |
|
719 | + array( |
|
720 | + '4.8.29' => '4.8.29', |
|
721 | + '4.8.33' => '4.8.29', |
|
722 | + '4.8.34' => '4.8.29', |
|
723 | + '4.8.36' => '4.8.29', |
|
724 | + ) |
|
725 | + ); |
|
726 | + } |
|
727 | + |
|
728 | + |
|
729 | + |
|
730 | + /** |
|
731 | + * Gets the latest API version served. Eg if there |
|
732 | + * are two versions served of the API, 4.8.29 and 4.8.32, and |
|
733 | + * we are on core version 4.8.34, it will return the string "4.8.32" |
|
734 | + * |
|
735 | + * @return string |
|
736 | + */ |
|
737 | + public static function latest_rest_api_version() |
|
738 | + { |
|
739 | + $versions_served = \EED_Core_Rest_Api::versions_served(); |
|
740 | + $versions_served_keys = array_keys($versions_served); |
|
741 | + return end($versions_served_keys); |
|
742 | + } |
|
743 | + |
|
744 | + |
|
745 | + |
|
746 | + /** |
|
747 | + * Using EED_Core_Rest_Api::version_compatibilities(), determines what version of |
|
748 | + * EE the API can serve requests for. Eg, if we are on 4.15 of core, and |
|
749 | + * we can serve requests from 4.12 or later, this will return array( '4.12', '4.13', '4.14', '4.15' ). |
|
750 | + * We also indicate whether or not this version should be put in the index or not |
|
751 | + * |
|
752 | + * @return array keys are API version numbers (just major and minor numbers), and values |
|
753 | + * are whether or not they should be hidden |
|
754 | + */ |
|
755 | + public static function versions_served() |
|
756 | + { |
|
757 | + $versions_served = array(); |
|
758 | + $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
|
759 | + $lowest_compatible_version = end($possibly_served_versions); |
|
760 | + reset($possibly_served_versions); |
|
761 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
762 | + $latest_version = end($versions_served_historically); |
|
763 | + reset($versions_served_historically); |
|
764 | + //for each version of core we have ever served: |
|
765 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
766 | + //if it's not above the current core version, and it's compatible with the current version of core |
|
767 | + if ($key_versioned_endpoint == $latest_version) { |
|
768 | + //don't hide the latest version in the index |
|
769 | + $versions_served[$key_versioned_endpoint] = false; |
|
770 | + } else if ( |
|
771 | + $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
|
772 | + && $key_versioned_endpoint >= $lowest_compatible_version |
|
773 | + ) { |
|
774 | + //include, but hide, previous versions which are still supported |
|
775 | + $versions_served[$key_versioned_endpoint] = true; |
|
776 | + } elseif ( |
|
777 | + apply_filters( |
|
778 | + 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
|
779 | + false, |
|
780 | + $possibly_served_versions |
|
781 | + ) |
|
782 | + ) { |
|
783 | + //if a version is no longer supported, don't include it in index or list of versions served |
|
784 | + $versions_served[$key_versioned_endpoint] = true; |
|
785 | + } |
|
786 | + } |
|
787 | + return $versions_served; |
|
788 | + } |
|
789 | + |
|
790 | + |
|
791 | + |
|
792 | + /** |
|
793 | + * Gets the major and minor version of EE core's version string |
|
794 | + * |
|
795 | + * @return string |
|
796 | + */ |
|
797 | + public static function core_version() |
|
798 | + { |
|
799 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', |
|
800 | + implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
801 | + } |
|
802 | + |
|
803 | + |
|
804 | + |
|
805 | + /** |
|
806 | + * Gets the default limit that should be used when querying for resources |
|
807 | + * |
|
808 | + * @return int |
|
809 | + */ |
|
810 | + public static function get_default_query_limit() |
|
811 | + { |
|
812 | + //we actually don't use a const because we want folks to always use |
|
813 | + //this method, not the const directly |
|
814 | + return apply_filters( |
|
815 | + 'FHEE__EED_Core_Rest_Api__get_default_query_limit', |
|
816 | + 50 |
|
817 | + ); |
|
818 | + } |
|
819 | + |
|
820 | + |
|
821 | + |
|
822 | + /** |
|
823 | + * run - initial module setup |
|
824 | + * |
|
825 | + * @access public |
|
826 | + * @param WP $WP |
|
827 | + * @return void |
|
828 | + */ |
|
829 | + public function run($WP) |
|
830 | + { |
|
831 | + } |
|
832 | 832 | |
833 | 833 | |
834 | 834 |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected static function _set_hooks_for_changes() |
159 | 159 | { |
160 | - $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES . 'rest_api' . DS . 'changes'), false); |
|
160 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
161 | 161 | foreach ($folder_contents as $classname_in_namespace => $filepath) { |
162 | 162 | //ignore the base parent class |
163 | 163 | if ($classname_in_namespace === 'Changes_In_Base') { |
164 | 164 | continue; |
165 | 165 | } |
166 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
166 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
167 | 167 | if (class_exists($full_classname)) { |
168 | 168 | $instance_of_class = new $full_classname; |
169 | 169 | if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | //delete the saved EE REST API routes |
228 | 228 | foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
229 | - delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version); |
|
229 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names.$version); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | $ee_routes = array(); |
247 | 247 | foreach (self::versions_served() as $version => $hidden_endpoints) { |
248 | - $ee_routes[self::ee_api_namespace . $version] = self::_get_ee_route_data_for_version($version, |
|
248 | + $ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, |
|
249 | 249 | $hidden_endpoints); |
250 | 250 | } |
251 | 251 | return $ee_routes; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | */ |
264 | 264 | protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) |
265 | 265 | { |
266 | - $ee_routes = get_option(self::saved_routes_option_names . $version, null); |
|
266 | + $ee_routes = get_option(self::saved_routes_option_names.$version, null); |
|
267 | 267 | if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
268 | 268 | $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
269 | 269 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
292 | 292 | ) |
293 | 293 | ); |
294 | - $option_name = self::saved_routes_option_names . $version; |
|
294 | + $option_name = self::saved_routes_option_names.$version; |
|
295 | 295 | if (get_option($option_name)) { |
296 | 296 | update_option($option_name, $routes, true); |
297 | 297 | } else { |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | $model = \EE_Registry::instance()->load_model($model_name); |
369 | 369 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
370 | 370 | $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
371 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)'; |
|
371 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
372 | 372 | $model_routes[$plural_model_route] = array( |
373 | 373 | array( |
374 | 374 | 'callback' => array( |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | 'hidden_endpoint' => $hidden_endpoint, |
380 | 380 | 'args' => $this->_get_read_query_params($model, $version), |
381 | 381 | '_links' => array( |
382 | - 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route), |
|
382 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route), |
|
383 | 383 | ), |
384 | 384 | ), |
385 | 385 | // array( |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | $relation_name, |
415 | 415 | $relation_obj |
416 | 416 | ); |
417 | - $model_routes[$singular_model_route . '/' . $related_model_name_endpoint_part] = array( |
|
417 | + $model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
418 | 418 | array( |
419 | 419 | 'callback' => array( |
420 | 420 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | { |
451 | 451 | $routes = array(); |
452 | 452 | foreach (self::versions_served() as $version => $hidden_endpoint) { |
453 | - $routes[self::ee_api_namespace . $version] = $this->_get_rpc_route_data_for_version($version, |
|
453 | + $routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, |
|
454 | 454 | $hidden_endpoint); |
455 | 455 | } |
456 | 456 | return $routes; |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | { |
582 | 582 | $config_routes = array(); |
583 | 583 | foreach (self::versions_served() as $version => $hidden_endpoint) { |
584 | - $config_routes[self::ee_api_namespace . $version] = $this->_get_config_route_data_for_version($version, |
|
584 | + $config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, |
|
585 | 585 | $hidden_endpoint); |
586 | 586 | } |
587 | 587 | return $config_routes; |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | { |
635 | 635 | $meta_routes = array(); |
636 | 636 | foreach (self::versions_served() as $version => $hidden_endpoint) { |
637 | - $meta_routes[self::ee_api_namespace . $version] = $this->_get_meta_route_data_for_version($version, |
|
637 | + $meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, |
|
638 | 638 | $hidden_endpoint); |
639 | 639 | } |
640 | 640 | return $meta_routes; |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
690 | 690 | || ($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace) |
691 | 691 | ) { |
692 | - $full_route = '/' . ltrim($namespace, '/') . '/' . ltrim($endpoint, '/'); |
|
692 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
693 | 693 | unset($route_data[$full_route]); |
694 | 694 | } |
695 | 695 | } |
@@ -8,9 +8,9 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class EED_Ticket_Selector extends EED_Module { |
10 | 10 | |
11 | - const debug = false; // true false |
|
11 | + const debug = false; // true false |
|
12 | 12 | |
13 | - /** |
|
13 | + /** |
|
14 | 14 | * event that ticket selector is being generated for |
15 | 15 | * |
16 | 16 | * @access protected |
@@ -19,19 +19,19 @@ discard block |
||
19 | 19 | protected static $_event; |
20 | 20 | |
21 | 21 | /** |
22 | - * array of datetimes and the spaces available for them |
|
23 | - * |
|
24 | - * @access private |
|
25 | - * @var array |
|
26 | - */ |
|
22 | + * array of datetimes and the spaces available for them |
|
23 | + * |
|
24 | + * @access private |
|
25 | + * @var array |
|
26 | + */ |
|
27 | 27 | private static $_available_spaces = array(); |
28 | 28 | |
29 | 29 | /** |
30 | - * max attendees that can register for event at one time |
|
31 | - * |
|
32 | - * @access private |
|
33 | - * @var int |
|
34 | - */ |
|
30 | + * max attendees that can register for event at one time |
|
31 | + * |
|
32 | + * @access private |
|
33 | + * @var int |
|
34 | + */ |
|
35 | 35 | private static $_max_atndz = EE_INF; |
36 | 36 | |
37 | 37 | |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | return $permalink_string; |
201 | 201 | } |
202 | 202 | $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' |
203 | - . __( 'Embed', 'event_espresso' ) |
|
204 | - . '</a> '; |
|
203 | + . __( 'Embed', 'event_espresso' ) |
|
204 | + . '</a> '; |
|
205 | 205 | $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
206 | 206 | $iframe_string = esc_html( |
207 | 207 | '<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>' |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @throws \EE_Error |
423 | 423 | */ |
424 | 424 | public static function display_ticket_selector_submit() { |
425 | - $html = ''; |
|
425 | + $html = ''; |
|
426 | 426 | if ( ! is_admin() ) { |
427 | 427 | // standard TS displayed with submit button, ie: "Register Now" |
428 | 428 | if ( |
@@ -483,14 +483,14 @@ discard block |
||
483 | 483 | $html .= \EED_Ticket_Selector::display_register_now_button(); |
484 | 484 | } |
485 | 485 | // no submit or view details button, and no additional content |
486 | - $html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv(); |
|
486 | + $html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv(); |
|
487 | 487 | } |
488 | - if ( ! is_archive()) { |
|
489 | - $html .= \EEH_Template::powered_by_event_espresso('', '', array( 'utm_content' => 'ticket_selector' )); |
|
490 | - } |
|
491 | - } |
|
488 | + if ( ! is_archive()) { |
|
489 | + $html .= \EEH_Template::powered_by_event_espresso('', '', array( 'utm_content' => 'ticket_selector' )); |
|
490 | + } |
|
491 | + } |
|
492 | 492 | return $html; |
493 | - } |
|
493 | + } |
|
494 | 494 | |
495 | 495 | |
496 | 496 | |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | * @return array|boolean |
684 | 684 | */ |
685 | 685 | public function process_ticket_selections() { |
686 | - do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
686 | + do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
687 | 687 | // do we have an event id? |
688 | 688 | if ( ! EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) { |
689 | 689 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
@@ -793,10 +793,10 @@ discard block |
||
793 | 793 | if ( apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd ) ) { |
794 | 794 | if ( apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added ) ) { |
795 | 795 | do_action( |
796 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', |
|
797 | - EE_Registry::instance()->CART, |
|
798 | - $this |
|
799 | - ); |
|
796 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', |
|
797 | + EE_Registry::instance()->CART, |
|
798 | + $this |
|
799 | + ); |
|
800 | 800 | EE_Registry::instance()->CART->recalculate_all_cart_totals(); |
801 | 801 | EE_Registry::instance()->CART->save_cart( FALSE ); |
802 | 802 | EE_Registry::instance()->SSN->update(); |
@@ -809,20 +809,20 @@ discard block |
||
809 | 809 | |
810 | 810 | EE_Error::get_notices( false, true ); |
811 | 811 | wp_safe_redirect( |
812 | - apply_filters( |
|
813 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', |
|
814 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
815 | - ) |
|
816 | - ); |
|
812 | + apply_filters( |
|
813 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', |
|
814 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
815 | + ) |
|
816 | + ); |
|
817 | 817 | exit(); |
818 | 818 | |
819 | 819 | } else { |
820 | 820 | if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention') ) { |
821 | 821 | // nothing added to cart |
822 | 822 | EE_Error::add_attention( |
823 | - __( 'No tickets were added for the event.', 'event_espresso' ), |
|
824 | - __FILE__, __FUNCTION__, __LINE__ |
|
825 | - ); |
|
823 | + __( 'No tickets were added for the event.', 'event_espresso' ), |
|
824 | + __FILE__, __FUNCTION__, __LINE__ |
|
825 | + ); |
|
826 | 826 | } |
827 | 827 | } |
828 | 828 | } else { |
@@ -986,13 +986,13 @@ discard block |
||
986 | 986 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
987 | 987 | // get the number of spaces left for this datetime ticket |
988 | 988 | $available_spaces = self::_ticket_datetime_availability( $ticket ); |
989 | - if (self::debug) { |
|
990 | - echo "<br /><br /> " . __LINE__ . ") " . __METHOD__ . "()"; |
|
991 | - echo "<br /> . ticket->ID(): " . $ticket->ID(); |
|
992 | - echo "<br /> . requested qty: " . $qty; |
|
993 | - echo "<br /> . available_spaces: " . $available_spaces; |
|
994 | - } |
|
995 | - // compare available spaces against the number of tickets being purchased |
|
989 | + if (self::debug) { |
|
990 | + echo "<br /><br /> " . __LINE__ . ") " . __METHOD__ . "()"; |
|
991 | + echo "<br /> . ticket->ID(): " . $ticket->ID(); |
|
992 | + echo "<br /> . requested qty: " . $qty; |
|
993 | + echo "<br /> . available_spaces: " . $available_spaces; |
|
994 | + } |
|
995 | + // compare available spaces against the number of tickets being purchased |
|
996 | 996 | if ( $available_spaces >= $qty ) { |
997 | 997 | // allow addons to prevent a ticket from being added to cart |
998 | 998 | if ( |
@@ -1183,11 +1183,11 @@ discard block |
||
1183 | 1183 | |
1184 | 1184 | |
1185 | 1185 | /** |
1186 | - * load js |
|
1187 | - * |
|
1188 | - * @access public |
|
1189 | - * @return void |
|
1190 | - */ |
|
1186 | + * load js |
|
1187 | + * |
|
1188 | + * @access public |
|
1189 | + * @return void |
|
1190 | + */ |
|
1191 | 1191 | public static function load_tckt_slctr_assets() { |
1192 | 1192 | // add some style |
1193 | 1193 | if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')){ exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Ticket Selector class |
4 | 4 | * |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class EED_Ticket_Selector extends EED_Module { |
10 | 10 | |
11 | - const debug = false; // true false |
|
11 | + const debug = false; // true false |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * event that ticket selector is being generated for |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | * @return EED_Ticket_Selector |
50 | 50 | */ |
51 | 51 | public static function instance() { |
52 | - return parent::get_instance( __CLASS__ ); |
|
52 | + return parent::get_instance(__CLASS__); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | 56 | |
57 | - protected function set_config(){ |
|
58 | - $this->set_config_section( 'template_settings' ); |
|
59 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
60 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
57 | + protected function set_config() { |
|
58 | + $this->set_config_section('template_settings'); |
|
59 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
60 | + $this->set_config_name('EED_Ticket_Selector'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public static function set_hooks() { |
74 | 74 | // routing |
75 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
76 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
77 | - EE_Config::register_route( 'cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections' ); |
|
78 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
79 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
80 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
75 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
76 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
77 | + EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections'); |
|
78 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
79 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
80 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | * @return void |
90 | 90 | */ |
91 | 91 | public static function set_hooks_admin() { |
92 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
92 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
93 | 93 | //add button for iframe code to event editor. |
94 | - add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 ); |
|
95 | - add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 ); |
|
94 | + add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4); |
|
95 | + add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | * @return void |
105 | 105 | */ |
106 | 106 | public static function set_definitions() { |
107 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
108 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
107 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
108 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
109 | 109 | |
110 | 110 | //if config is not set, initialize |
111 | 111 | //If config is not set, set it. |
112 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) { |
|
112 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) { |
|
113 | 113 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
114 | 114 | } |
115 | - EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' ); |
|
115 | + EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso'); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param WP $WP |
124 | 124 | * @return void |
125 | 125 | */ |
126 | - public function run( $WP ) {} |
|
126 | + public function run($WP) {} |
|
127 | 127 | |
128 | 128 | |
129 | 129 | |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | public function ticket_selector_iframe() { |
138 | 138 | self::$_in_iframe = true; |
139 | 139 | /** @type EEM_Event $EEM_Event */ |
140 | - $EEM_Event = EE_Registry::instance()->load_model( 'Event' ); |
|
140 | + $EEM_Event = EE_Registry::instance()->load_model('Event'); |
|
141 | 141 | $event = $EEM_Event->get_one_by_ID( |
142 | - EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
142 | + EE_Registry::instance()->REQ->get('event', 0) |
|
143 | 143 | ); |
144 | - EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
145 | - $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event ); |
|
144 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
145 | + $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event); |
|
146 | 146 | $template_args['css'] = apply_filters( |
147 | 147 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
148 | 148 | array( |
149 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
150 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
151 | - includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ), |
|
152 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
|
149 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION, |
|
150 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION, |
|
151 | + includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']), |
|
152 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION |
|
153 | 153 | ) |
154 | 154 | ); |
155 | - EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true; |
|
156 | - EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = esc_html__( 'Please choose at least one ticket before continuing.', 'event_espresso' ); |
|
155 | + EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true; |
|
156 | + EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = esc_html__('Please choose at least one ticket before continuing.', 'event_espresso'); |
|
157 | 157 | $template_args['eei18n'] = apply_filters( |
158 | 158 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings', |
159 | 159 | EE_Registry::localize_i18n_js_strings() |
@@ -161,18 +161,18 @@ discard block |
||
161 | 161 | $template_args['js'] = apply_filters( |
162 | 162 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
163 | 163 | array( |
164 | - includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ), |
|
165 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
166 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION |
|
164 | + includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']), |
|
165 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION, |
|
166 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION |
|
167 | 167 | ) |
168 | 168 | ); |
169 | - $template_args[ 'notices' ] = EEH_Template::display_template( |
|
170 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
169 | + $template_args['notices'] = EEH_Template::display_template( |
|
170 | + EE_TEMPLATES.'espresso-ajax-notices.template.php', |
|
171 | 171 | array(), |
172 | 172 | true |
173 | 173 | ); |
174 | 174 | EEH_Template::display_template( |
175 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php', |
|
175 | + TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php', |
|
176 | 176 | $template_args |
177 | 177 | ); |
178 | 178 | exit; |
@@ -191,25 +191,25 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return string The new html string for the permalink area. |
193 | 193 | */ |
194 | - public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) { |
|
194 | + public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) { |
|
195 | 195 | //make sure this is ONLY when editing and the event id has been set. |
196 | - if ( ! empty( $id ) ) { |
|
197 | - $post = get_post( $id ); |
|
196 | + if ( ! empty($id)) { |
|
197 | + $post = get_post($id); |
|
198 | 198 | //if NOT event then let's get out. |
199 | - if ( $post->post_type !== 'espresso_events' ) { |
|
199 | + if ($post->post_type !== 'espresso_events') { |
|
200 | 200 | return $permalink_string; |
201 | 201 | } |
202 | 202 | $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' |
203 | - . __( 'Embed', 'event_espresso' ) |
|
203 | + . __('Embed', 'event_espresso') |
|
204 | 204 | . '</a> '; |
205 | - $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
|
205 | + $ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url()); |
|
206 | 206 | $iframe_string = esc_html( |
207 | - '<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>' |
|
207 | + '<iframe src="'.$ticket_selector_url.'" width="100%" height="100%"></iframe>' |
|
208 | 208 | ); |
209 | 209 | $permalink_string .= ' |
210 | 210 | <div id="js-ts-iframe" style="display:none"> |
211 | 211 | <div style="width:100%; height: 500px;"> |
212 | - ' . $iframe_string . ' |
|
212 | + ' . $iframe_string.' |
|
213 | 213 | </div> |
214 | 214 | </div>'; |
215 | 215 | } |
@@ -228,22 +228,22 @@ discard block |
||
228 | 228 | * @param mixed $event |
229 | 229 | * @return bool |
230 | 230 | */ |
231 | - protected static function set_event( $event = null ) { |
|
232 | - if( $event === null ) { |
|
231 | + protected static function set_event($event = null) { |
|
232 | + if ($event === null) { |
|
233 | 233 | global $post; |
234 | 234 | $event = $post; |
235 | 235 | } |
236 | - if ( $event instanceof EE_Event ) { |
|
236 | + if ($event instanceof EE_Event) { |
|
237 | 237 | self::$_event = $event; |
238 | - } else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) { |
|
238 | + } else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) { |
|
239 | 239 | self::$_event = $event->EE_Event; |
240 | - } else if ( $event instanceof WP_Post && $event->post_type === 'espresso_events' ) { |
|
241 | - $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
240 | + } else if ($event instanceof WP_Post && $event->post_type === 'espresso_events') { |
|
241 | + $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
242 | 242 | self::$_event = $event->EE_Event; |
243 | 243 | } else { |
244 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
245 | - $dev_msg = $user_msg . __( 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso' ); |
|
246 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
244 | + $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
245 | + $dev_msg = $user_msg.__('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso'); |
|
246 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
247 | 247 | return false; |
248 | 248 | } |
249 | 249 | return true; |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | * @return string |
261 | 261 | * @throws \EE_Error |
262 | 262 | */ |
263 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
263 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
264 | 264 | // reset filter for displaying submit button |
265 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
265 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
266 | 266 | // poke and prod incoming event till it tells us what it is |
267 | - if ( ! EED_Ticket_Selector::set_event( $event )) { |
|
267 | + if ( ! EED_Ticket_Selector::set_event($event)) { |
|
268 | 268 | return false; |
269 | 269 | } |
270 | 270 | $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | && ( |
276 | 276 | ! self::$_event->display_ticket_selector() |
277 | 277 | || $view_details |
278 | - || post_password_required( $event_post ) |
|
278 | + || post_password_required($event_post) |
|
279 | 279 | || ( |
280 | 280 | $_event_active_status !== EE_Datetime::active |
281 | 281 | && $_event_active_status !== EE_Datetime::upcoming |
@@ -293,34 +293,34 @@ discard block |
||
293 | 293 | $template_args = array(); |
294 | 294 | $template_args['event_status'] = $_event_active_status; |
295 | 295 | |
296 | - $template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) ); |
|
297 | - $template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) ); |
|
296 | + $template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format')); |
|
297 | + $template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format')); |
|
298 | 298 | |
299 | 299 | $template_args['EVT_ID'] = self::$_event->ID(); |
300 | 300 | $template_args['event'] = self::$_event; |
301 | 301 | |
302 | 302 | // is the event expired ? |
303 | 303 | $template_args['event_is_expired'] = self::$_event->is_expired(); |
304 | - if ( $template_args['event_is_expired'] ) { |
|
305 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>'; |
|
304 | + if ($template_args['event_is_expired']) { |
|
305 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso').'</span></div>'; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | $ticket_query_args = array( |
309 | - array( 'Datetime.EVT_ID' => self::$_event->ID() ), |
|
310 | - 'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' ) |
|
309 | + array('Datetime.EVT_ID' => self::$_event->ID()), |
|
310 | + 'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC') |
|
311 | 311 | ); |
312 | 312 | |
313 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) { |
|
313 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
314 | 314 | //use the correct applicable time query depending on what version of core is being run. |
315 | - $current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp'); |
|
316 | - $ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time ); |
|
315 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp'); |
|
316 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | // get all tickets for this event ordered by the datetime |
320 | - $template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args ); |
|
320 | + $template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args); |
|
321 | 321 | |
322 | - if ( count( $template_args['tickets'] ) < 1 ) { |
|
323 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>'; |
|
322 | + if (count($template_args['tickets']) < 1) { |
|
323 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>'; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
@@ -329,41 +329,41 @@ discard block |
||
329 | 329 | self::$_event->additional_limit() |
330 | 330 | ); |
331 | 331 | $template_args['max_atndz'] = \EED_Ticket_Selector::$_max_atndz; |
332 | - if ( $template_args['max_atndz'] < 1 ) { |
|
333 | - $sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' ); |
|
334 | - if ( current_user_can( 'edit_post', self::$_event->ID() )) { |
|
335 | - $sales_closed_msg .= sprintf( |
|
336 | - __( '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso' ), |
|
332 | + if ($template_args['max_atndz'] < 1) { |
|
333 | + $sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso'); |
|
334 | + if (current_user_can('edit_post', self::$_event->ID())) { |
|
335 | + $sales_closed_msg .= sprintf( |
|
336 | + __('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'), |
|
337 | 337 | '<div class="ee-attention" style="text-align: left;"><b>', |
338 | 338 | '</b><br />', |
339 | - $link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">', |
|
339 | + $link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">', |
|
340 | 340 | '</a></span></div>' |
341 | 341 | ); |
342 | 342 | } |
343 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
343 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
344 | 344 | } |
345 | 345 | |
346 | - $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php'; |
|
347 | - $templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event ); |
|
346 | + $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php'; |
|
347 | + $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event); |
|
348 | 348 | |
349 | 349 | // redirecting to another site for registration ?? |
350 | 350 | $external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE; |
351 | 351 | // if not redirecting to another site for registration |
352 | - if ( ! $external_url ) { |
|
352 | + if ( ! $external_url) { |
|
353 | 353 | // then display the ticket selector |
354 | - $ticket_selector = EEH_Template::locate_template( $templates['ticket_selector'], $template_args ); |
|
354 | + $ticket_selector = EEH_Template::locate_template($templates['ticket_selector'], $template_args); |
|
355 | 355 | } else { |
356 | 356 | // if not we still need to trigger the display of the submit button |
357 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
357 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
358 | 358 | //display notice to admin that registration is external |
359 | - $ticket_selector = ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' ); |
|
359 | + $ticket_selector = ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso'); |
|
360 | 360 | } |
361 | 361 | // now set up the form (but not for the admin) |
362 | 362 | $ticket_selector = ! is_admin() |
363 | 363 | ? EED_Ticket_Selector::ticket_selector_form_open( |
364 | 364 | self::$_event->ID(), |
365 | 365 | $external_url |
366 | - ) . $ticket_selector |
|
366 | + ).$ticket_selector |
|
367 | 367 | : $ticket_selector; |
368 | 368 | // submit button and form close tag |
369 | 369 | $ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : ''; |
@@ -383,31 +383,31 @@ discard block |
||
383 | 383 | * @param string $external_url |
384 | 384 | * @return string |
385 | 385 | */ |
386 | - public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) { |
|
386 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') { |
|
387 | 387 | // if redirecting, we don't need any anything else |
388 | - if ( $external_url ) { |
|
389 | - $html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">'; |
|
390 | - $query_args = (array) EEH_URL::get_query_string( $external_url ); |
|
391 | - foreach ( $query_args as $query_arg => $value ) { |
|
388 | + if ($external_url) { |
|
389 | + $html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">'; |
|
390 | + $query_args = (array) EEH_URL::get_query_string($external_url); |
|
391 | + foreach ($query_args as $query_arg => $value) { |
|
392 | 392 | $html .= ' |
393 | - <input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
393 | + <input type="hidden" name="' . $query_arg.'" value="'.$value.'">'; |
|
394 | 394 | } |
395 | 395 | return $html; |
396 | 396 | } |
397 | 397 | // if there is no submit button, then don't start building a form |
398 | 398 | // because the "View Details" button will build its own form |
399 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
399 | + if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
400 | 400 | return ''; |
401 | 401 | } |
402 | - $checkout_url = EEH_Event_View::event_link_url( $ID ); |
|
403 | - if ( ! $checkout_url ) { |
|
404 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
402 | + $checkout_url = EEH_Event_View::event_link_url($ID); |
|
403 | + if ( ! $checkout_url) { |
|
404 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
405 | 405 | } |
406 | 406 | $extra_params = self::$_in_iframe ? ' target="_blank"' : ''; |
407 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
408 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, TRUE, FALSE ); |
|
407 | + $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>'; |
|
408 | + $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_'.$ID, TRUE, FALSE); |
|
409 | 409 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
410 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event ); |
|
410 | + $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event); |
|
411 | 411 | return $html; |
412 | 412 | } |
413 | 413 | |
@@ -423,14 +423,14 @@ discard block |
||
423 | 423 | */ |
424 | 424 | public static function display_ticket_selector_submit() { |
425 | 425 | $html = ''; |
426 | - if ( ! is_admin() ) { |
|
426 | + if ( ! is_admin()) { |
|
427 | 427 | // standard TS displayed with submit button, ie: "Register Now" |
428 | 428 | if ( |
429 | - apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) |
|
429 | + apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false) |
|
430 | 430 | ) { |
431 | 431 | $html .= \EED_Ticket_Selector::display_register_now_button(); |
432 | 432 | $html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv(); |
433 | - $html .= '<br/>' . \EED_Ticket_Selector::ticket_selector_form_close(); |
|
433 | + $html .= '<br/>'.\EED_Ticket_Selector::ticket_selector_form_close(); |
|
434 | 434 | } else if ( |
435 | 435 | // a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
436 | 436 | EED_Ticket_Selector::$_max_atndz === 1 |
@@ -452,41 +452,41 @@ discard block |
||
452 | 452 | ), |
453 | 453 | EED_Ticket_Selector::$_event |
454 | 454 | ); |
455 | - if ( apply_filters( |
|
455 | + if (apply_filters( |
|
456 | 456 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
457 | 457 | false, |
458 | 458 | EED_Ticket_Selector::$_event |
459 | - ) ) { |
|
459 | + )) { |
|
460 | 460 | $html .= \EED_Ticket_Selector::display_register_now_button(); |
461 | 461 | } |
462 | 462 | // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
463 | 463 | $html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv(); |
464 | 464 | } else if ( |
465 | 465 | EED_Ticket_Selector::$_max_atndz === 1 |
466 | - && apply_filters( 'FHEE__EE_Ticket_Selector__hide_ticket_selector', false ) |
|
466 | + && apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false) |
|
467 | 467 | && ! is_single() |
468 | 468 | ) { |
469 | 469 | // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event, |
470 | 470 | // but no tickets are available, so display event's "View Details" button. |
471 | 471 | // it is being viewed via somewhere other than a single post |
472 | - $html .= EED_Ticket_Selector::display_view_details_btn( true ); |
|
473 | - } else if ( is_archive() ) { |
|
472 | + $html .= EED_Ticket_Selector::display_view_details_btn(true); |
|
473 | + } else if (is_archive()) { |
|
474 | 474 | // event list, no tickets available so display event's "View Details" button |
475 | 475 | $html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv(); |
476 | 476 | $html .= EED_Ticket_Selector::display_view_details_btn(); |
477 | 477 | } else { |
478 | - if ( apply_filters( |
|
478 | + if (apply_filters( |
|
479 | 479 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
480 | 480 | false, |
481 | 481 | EED_Ticket_Selector::$_event |
482 | - ) ) { |
|
482 | + )) { |
|
483 | 483 | $html .= \EED_Ticket_Selector::display_register_now_button(); |
484 | 484 | } |
485 | 485 | // no submit or view details button, and no additional content |
486 | 486 | $html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv(); |
487 | 487 | } |
488 | 488 | if ( ! is_archive()) { |
489 | - $html .= \EEH_Template::powered_by_event_espresso('', '', array( 'utm_content' => 'ticket_selector' )); |
|
489 | + $html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector')); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | return $html; |
@@ -545,14 +545,14 @@ discard block |
||
545 | 545 | public static function display_register_now_button( ) { |
546 | 546 | $btn_text = apply_filters( |
547 | 547 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
548 | - __( 'Register Now', 'event_espresso' ), |
|
548 | + __('Register Now', 'event_espresso'), |
|
549 | 549 | EED_Ticket_Selector::$_event |
550 | 550 | ); |
551 | 551 | $external_url = EED_Ticket_Selector::$_event->external_url(); |
552 | - $html = '<input id="ticket-selector-submit-' . EED_Ticket_Selector::$_event->ID() . '-btn"'; |
|
552 | + $html = '<input id="ticket-selector-submit-'.EED_Ticket_Selector::$_event->ID().'-btn"'; |
|
553 | 553 | $html .= ' class="ticket-selector-submit-btn '; |
554 | - $html .= empty( $external_url ) ? 'ticket-selector-submit-ajax"' : '"'; |
|
555 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
554 | + $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
555 | + $html .= ' type="submit" value="'.$btn_text.'" />'; |
|
556 | 556 | $html .= apply_filters( |
557 | 557 | 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
558 | 558 | '', |
@@ -574,10 +574,10 @@ discard block |
||
574 | 574 | * @return string |
575 | 575 | * @throws \EE_Error |
576 | 576 | */ |
577 | - public static function display_view_details_btn( $DWMTS = false) { |
|
578 | - if ( ! self::$_event->get_permalink() ) { |
|
577 | + public static function display_view_details_btn($DWMTS = false) { |
|
578 | + if ( ! self::$_event->get_permalink()) { |
|
579 | 579 | EE_Error::add_error( |
580 | - __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
580 | + __('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
|
581 | 581 | __FILE__, __FUNCTION__, __LINE__ |
582 | 582 | ); |
583 | 583 | } |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | $view_details_btn .= '">'; |
591 | 591 | $btn_text = apply_filters( |
592 | 592 | 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
593 | - __( 'View Details', 'event_espresso' ), |
|
593 | + __('View Details', 'event_espresso'), |
|
594 | 594 | self::$_event |
595 | 595 | ); |
596 | - $view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />'; |
|
597 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event ); |
|
598 | - if ( $DWMTS ) { |
|
596 | + $view_details_btn .= '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'.$btn_text.'" />'; |
|
597 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event); |
|
598 | + if ($DWMTS) { |
|
599 | 599 | $view_details_btn .= \EED_Ticket_Selector::ticket_selector_form_close(); |
600 | 600 | $view_details_btn .= \EED_Ticket_Selector::no_tkt_slctr_end_dv(); |
601 | 601 | $view_details_btn .= '<br/>'; |
@@ -618,19 +618,19 @@ discard block |
||
618 | 618 | */ |
619 | 619 | public static function cancel_ticket_selections() { |
620 | 620 | // check nonce |
621 | - if ( ! EED_Ticket_Selector::process_ticket_selector_nonce( 'cancel_ticket_selections_nonce' ) ) { |
|
621 | + if ( ! EED_Ticket_Selector::process_ticket_selector_nonce('cancel_ticket_selections_nonce')) { |
|
622 | 622 | return false; |
623 | 623 | } |
624 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__ ); |
|
625 | - if ( EE_Registry::instance()->REQ->is_set( 'event_id' ) ) { |
|
624 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
625 | + if (EE_Registry::instance()->REQ->is_set('event_id')) { |
|
626 | 626 | wp_safe_redirect( |
627 | 627 | EEH_Event_View::event_link_url( |
628 | - EE_Registry::instance()->REQ->get( 'event_id' ) |
|
628 | + EE_Registry::instance()->REQ->get('event_id') |
|
629 | 629 | ) |
630 | 630 | ); |
631 | 631 | } else { |
632 | 632 | wp_safe_redirect( |
633 | - site_url( '/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/' ) |
|
633 | + site_url('/'.EE_Registry::instance()->CFG->core->event_cpt_slug.'/') |
|
634 | 634 | ); |
635 | 635 | } |
636 | 636 | die(); |
@@ -645,15 +645,15 @@ discard block |
||
645 | 645 | * @param string $nonce_name |
646 | 646 | * @return bool |
647 | 647 | */ |
648 | - public static function process_ticket_selector_nonce( $nonce_name ) { |
|
648 | + public static function process_ticket_selector_nonce($nonce_name) { |
|
649 | 649 | if ( |
650 | 650 | ! is_admin() |
651 | 651 | && ( |
652 | - ! EE_Registry::instance()->REQ->is_set( $nonce_name ) |
|
652 | + ! EE_Registry::instance()->REQ->is_set($nonce_name) |
|
653 | 653 | || |
654 | 654 | ! wp_verify_nonce( |
655 | - EE_Registry::instance()->REQ->get( $nonce_name ), |
|
656 | - str_replace( '_nonce', '', $nonce_name ) |
|
655 | + EE_Registry::instance()->REQ->get($nonce_name), |
|
656 | + str_replace('_nonce', '', $nonce_name) |
|
657 | 657 | ) |
658 | 658 | ) |
659 | 659 | ) { |
@@ -683,9 +683,9 @@ discard block |
||
683 | 683 | * @return array|boolean |
684 | 684 | */ |
685 | 685 | public function process_ticket_selections() { |
686 | - do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
686 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
687 | 687 | // do we have an event id? |
688 | - if ( ! EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) { |
|
688 | + if ( ! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) { |
|
689 | 689 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
690 | 690 | EE_Error::add_error( |
691 | 691 | sprintf( |
@@ -701,17 +701,17 @@ discard block |
||
701 | 701 | ); |
702 | 702 | } |
703 | 703 | //if event id is valid |
704 | - $id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' ) ); |
|
704 | + $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id')); |
|
705 | 705 | // check nonce |
706 | 706 | if ( |
707 | 707 | ! is_admin() |
708 | 708 | && ( |
709 | - ! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce_' . $id ) |
|
710 | - || ! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce_' . $id ), 'process_ticket_selections' ) |
|
709 | + ! EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce_'.$id) |
|
710 | + || ! wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce_'.$id), 'process_ticket_selections') |
|
711 | 711 | ) |
712 | 712 | ) { |
713 | 713 | EE_Error::add_error( |
714 | - sprintf( __( 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
714 | + sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
715 | 715 | __FILE__, __FUNCTION__, __LINE__ |
716 | 716 | ); |
717 | 717 | return FALSE; |
@@ -723,16 +723,16 @@ discard block |
||
723 | 723 | ); |
724 | 724 | //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart. |
725 | 725 | // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc. |
726 | - EE_Registry::instance()->load_core( 'Session' ); |
|
726 | + EE_Registry::instance()->load_core('Session'); |
|
727 | 727 | // unless otherwise requested, clear the session |
728 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) { |
|
729 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
728 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) { |
|
729 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
730 | 730 | } |
731 | 731 | //d( EE_Registry::instance()->SSN ); |
732 | 732 | |
733 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
733 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
734 | 734 | // validate/sanitize data |
735 | - $valid = self::_validate_post_data( $id ); |
|
735 | + $valid = self::_validate_post_data($id); |
|
736 | 736 | |
737 | 737 | //EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
738 | 738 | //EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ ); |
@@ -740,42 +740,42 @@ discard block |
||
740 | 740 | //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ ); |
741 | 741 | |
742 | 742 | //check total tickets ordered vs max number of attendees that can register |
743 | - if ( $valid['total_tickets'] > $valid['max_atndz'] ) { |
|
743 | + if ($valid['total_tickets'] > $valid['max_atndz']) { |
|
744 | 744 | |
745 | 745 | // ordering too many tickets !!! |
746 | 746 | $total_tickets_string = _n('You have attempted to purchase %s ticket.', 'You have attempted to purchase %s tickets.', $valid['total_tickets'], 'event_espresso'); |
747 | - $limit_error_1 = sprintf( $total_tickets_string, $valid['total_tickets'] ); |
|
747 | + $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
748 | 748 | // dev only message |
749 | 749 | $max_atndz_string = _n('The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', $valid['max_atndz'], 'event_espresso'); |
750 | - $limit_error_2 = sprintf( $max_atndz_string, $valid['max_atndz'], $valid['max_atndz'] ); |
|
751 | - EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ ); |
|
750 | + $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']); |
|
751 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
752 | 752 | } else { |
753 | 753 | |
754 | 754 | // all data appears to be valid |
755 | 755 | $tckts_slctd = false; |
756 | 756 | $tickets_added = 0; |
757 | - $valid = apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid ); |
|
758 | - if ( $valid[ 'total_tickets' ] >0 ) { |
|
757 | + $valid = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid); |
|
758 | + if ($valid['total_tickets'] > 0) { |
|
759 | 759 | // load cart |
760 | - EE_Registry::instance()->load_core( 'Cart' ); |
|
760 | + EE_Registry::instance()->load_core('Cart'); |
|
761 | 761 | |
762 | 762 | // cycle thru the number of data rows sent from the event listing |
763 | - for ( $x = 0; $x < $valid['rows']; $x++ ) { |
|
763 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
764 | 764 | // does this row actually contain a ticket quantity? |
765 | - if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) { |
|
765 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
766 | 766 | // YES we have a ticket quantity |
767 | 767 | $tckts_slctd = true; |
768 | 768 | // d( $valid['ticket_obj'][$x] ); |
769 | - if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) { |
|
769 | + if ($valid['ticket_obj'][$x] instanceof EE_Ticket) { |
|
770 | 770 | // then add ticket to cart |
771 | - $tickets_added += self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] ); |
|
772 | - if ( EE_Error::has_error() ) { |
|
771 | + $tickets_added += self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]); |
|
772 | + if (EE_Error::has_error()) { |
|
773 | 773 | break; |
774 | 774 | } |
775 | 775 | } else { |
776 | 776 | // nothing added to cart retrieved |
777 | 777 | EE_Error::add_error( |
778 | - sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
778 | + sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
779 | 779 | __FILE__, __FUNCTION__, __LINE__ |
780 | 780 | ); |
781 | 781 | } |
@@ -790,24 +790,24 @@ discard block |
||
790 | 790 | //d( EE_Registry::instance()->CART ); |
791 | 791 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
792 | 792 | |
793 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd ) ) { |
|
794 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added ) ) { |
|
793 | + if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) { |
|
794 | + if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
|
795 | 795 | do_action( |
796 | 796 | 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', |
797 | 797 | EE_Registry::instance()->CART, |
798 | 798 | $this |
799 | 799 | ); |
800 | 800 | EE_Registry::instance()->CART->recalculate_all_cart_totals(); |
801 | - EE_Registry::instance()->CART->save_cart( FALSE ); |
|
801 | + EE_Registry::instance()->CART->save_cart(FALSE); |
|
802 | 802 | EE_Registry::instance()->SSN->update(); |
803 | 803 | //d( EE_Registry::instance()->CART ); |
804 | 804 | // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
805 | 805 | // just return TRUE for registrations being made from admin |
806 | - if ( is_admin() ) { |
|
806 | + if (is_admin()) { |
|
807 | 807 | return TRUE; |
808 | 808 | } |
809 | 809 | |
810 | - EE_Error::get_notices( false, true ); |
|
810 | + EE_Error::get_notices(false, true); |
|
811 | 811 | wp_safe_redirect( |
812 | 812 | apply_filters( |
813 | 813 | 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', |
@@ -817,32 +817,32 @@ discard block |
||
817 | 817 | exit(); |
818 | 818 | |
819 | 819 | } else { |
820 | - if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention') ) { |
|
820 | + if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
821 | 821 | // nothing added to cart |
822 | 822 | EE_Error::add_attention( |
823 | - __( 'No tickets were added for the event.', 'event_espresso' ), |
|
823 | + __('No tickets were added for the event.', 'event_espresso'), |
|
824 | 824 | __FILE__, __FUNCTION__, __LINE__ |
825 | 825 | ); |
826 | 826 | } |
827 | 827 | } |
828 | 828 | } else { |
829 | 829 | // no ticket quantities were selected |
830 | - EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
830 | + EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
831 | 831 | } |
832 | 832 | } |
833 | 833 | |
834 | 834 | // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
835 | 835 | // at this point, just return if registration is being made from admin |
836 | - if ( is_admin() ) { |
|
836 | + if (is_admin()) { |
|
837 | 837 | return FALSE; |
838 | 838 | } |
839 | - if ( $valid['return_url'] ) { |
|
840 | - EE_Error::get_notices( FALSE, TRUE ); |
|
841 | - wp_safe_redirect( $valid['return_url'] ); |
|
839 | + if ($valid['return_url']) { |
|
840 | + EE_Error::get_notices(FALSE, TRUE); |
|
841 | + wp_safe_redirect($valid['return_url']); |
|
842 | 842 | exit(); |
843 | - } elseif ( isset( $event_to_add['id'] )) { |
|
844 | - EE_Error::get_notices( FALSE, TRUE ); |
|
845 | - wp_safe_redirect( get_permalink( $event_to_add['id'] )); |
|
843 | + } elseif (isset($event_to_add['id'])) { |
|
844 | + EE_Error::get_notices(FALSE, TRUE); |
|
845 | + wp_safe_redirect(get_permalink($event_to_add['id'])); |
|
846 | 846 | exit(); |
847 | 847 | } else { |
848 | 848 | echo EE_Error::get_notices(); |
@@ -862,13 +862,13 @@ discard block |
||
862 | 862 | * @param int $id |
863 | 863 | * @return array|FALSE |
864 | 864 | */ |
865 | - private static function _validate_post_data( $id = 0 ) { |
|
866 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
865 | + private static function _validate_post_data($id = 0) { |
|
866 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
867 | 867 | |
868 | 868 | // d( $_POST ); |
869 | - if ( ! $id ) { |
|
869 | + if ( ! $id) { |
|
870 | 870 | EE_Error::add_error( |
871 | - __( 'The event id provided was not valid.', 'event_espresso' ), |
|
871 | + __('The event id provided was not valid.', 'event_espresso'), |
|
872 | 872 | __FILE__, |
873 | 873 | __FUNCTION__, |
874 | 874 | __LINE__ |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | // grab valid id |
881 | 881 | $valid_data['id'] = $id; |
882 | 882 | // grab and sanitize return-url |
883 | - $valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id )); |
|
883 | + $valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id)); |
|
884 | 884 | // array of other form names |
885 | 885 | $inputs_to_clean = array( |
886 | 886 | 'event_id' => 'tkt-slctr-event-id', |
@@ -893,22 +893,22 @@ discard block |
||
893 | 893 | // let's track the total number of tickets ordered.' |
894 | 894 | $valid_data['total_tickets'] = 0; |
895 | 895 | // cycle through $inputs_to_clean array |
896 | - foreach ( $inputs_to_clean as $what => $input_to_clean ) { |
|
896 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
897 | 897 | // check for POST data |
898 | - if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) { |
|
898 | + if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) { |
|
899 | 899 | // grab value |
900 | - $input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id ); |
|
900 | + $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id); |
|
901 | 901 | switch ($what) { |
902 | 902 | |
903 | 903 | // integers |
904 | 904 | case 'event_id': |
905 | - $valid_data[$what] = absint( $input_value ); |
|
905 | + $valid_data[$what] = absint($input_value); |
|
906 | 906 | // get event via the event id we put in the form |
907 | - $valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] ); |
|
907 | + $valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']); |
|
908 | 908 | break; |
909 | 909 | case 'rows': |
910 | 910 | case 'max_atndz': |
911 | - $valid_data[$what] = absint( $input_value ); |
|
911 | + $valid_data[$what] = absint($input_value); |
|
912 | 912 | break; |
913 | 913 | |
914 | 914 | // arrays of integers |
@@ -916,27 +916,27 @@ discard block |
||
916 | 916 | /** @var array $row_qty */ |
917 | 917 | $row_qty = $input_value; |
918 | 918 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
919 | - if( ! is_array( $row_qty )) { |
|
919 | + if ( ! is_array($row_qty)) { |
|
920 | 920 | // get number of rows |
921 | - $rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1; |
|
921 | + $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1; |
|
922 | 922 | // d( $rows ); |
923 | 923 | // explode ints by the dash |
924 | - $row_qty = explode( '-', $row_qty ); |
|
925 | - $row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1; |
|
926 | - $qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0; |
|
927 | - $row_qty = array( $row => $qty ); |
|
924 | + $row_qty = explode('-', $row_qty); |
|
925 | + $row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1; |
|
926 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
927 | + $row_qty = array($row => $qty); |
|
928 | 928 | // d( $row_qty ); |
929 | - for( $x = 1; $x <= $rows; $x++ ) { |
|
930 | - if ( ! isset( $row_qty[$x] )) { |
|
929 | + for ($x = 1; $x <= $rows; $x++) { |
|
930 | + if ( ! isset($row_qty[$x])) { |
|
931 | 931 | $row_qty[$x] = 0; |
932 | 932 | } |
933 | 933 | } |
934 | 934 | } |
935 | - ksort( $row_qty ); |
|
935 | + ksort($row_qty); |
|
936 | 936 | // d( $row_qty ); |
937 | 937 | // cycle thru values |
938 | - foreach ( $row_qty as $qty ) { |
|
939 | - $qty = absint( $qty ); |
|
938 | + foreach ($row_qty as $qty) { |
|
939 | + $qty = absint($qty); |
|
940 | 940 | // sanitize as integers |
941 | 941 | $valid_data[$what][] = $qty; |
942 | 942 | $valid_data['total_tickets'] += $qty; |
@@ -947,19 +947,19 @@ discard block |
||
947 | 947 | case 'ticket_id': |
948 | 948 | $value_array = array(); |
949 | 949 | // cycle thru values |
950 | - foreach ( (array) $input_value as $key => $value ) { |
|
950 | + foreach ((array) $input_value as $key => $value) { |
|
951 | 951 | // allow only numbers, letters, spaces, commas and dashes |
952 | - $value_array[ $key ] = wp_strip_all_tags( $value ); |
|
952 | + $value_array[$key] = wp_strip_all_tags($value); |
|
953 | 953 | // get ticket via the ticket id we put in the form |
954 | - $ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value ); |
|
955 | - $valid_data['ticket_obj'][ $key ] = $ticket_obj; |
|
954 | + $ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value); |
|
955 | + $valid_data['ticket_obj'][$key] = $ticket_obj; |
|
956 | 956 | } |
957 | - $valid_data[ $what ] = $value_array; |
|
957 | + $valid_data[$what] = $value_array; |
|
958 | 958 | break; |
959 | 959 | |
960 | 960 | case 'return_url' : |
961 | 961 | // grab and sanitize return-url |
962 | - $valid_data[$what] = esc_url_raw( $input_value ); |
|
962 | + $valid_data[$what] = esc_url_raw($input_value); |
|
963 | 963 | break; |
964 | 964 | |
965 | 965 | } // end switch $what |
@@ -982,18 +982,18 @@ discard block |
||
982 | 982 | * @return int quantity of tickets added |
983 | 983 | * @throws \EE_Error |
984 | 984 | */ |
985 | - private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) { |
|
986 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
985 | + private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) { |
|
986 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
987 | 987 | // get the number of spaces left for this datetime ticket |
988 | - $available_spaces = self::_ticket_datetime_availability( $ticket ); |
|
988 | + $available_spaces = self::_ticket_datetime_availability($ticket); |
|
989 | 989 | if (self::debug) { |
990 | - echo "<br /><br /> " . __LINE__ . ") " . __METHOD__ . "()"; |
|
991 | - echo "<br /> . ticket->ID(): " . $ticket->ID(); |
|
992 | - echo "<br /> . requested qty: " . $qty; |
|
993 | - echo "<br /> . available_spaces: " . $available_spaces; |
|
990 | + echo "<br /><br /> ".__LINE__.") ".__METHOD__."()"; |
|
991 | + echo "<br /> . ticket->ID(): ".$ticket->ID(); |
|
992 | + echo "<br /> . requested qty: ".$qty; |
|
993 | + echo "<br /> . available_spaces: ".$available_spaces; |
|
994 | 994 | } |
995 | 995 | // compare available spaces against the number of tickets being purchased |
996 | - if ( $available_spaces >= $qty ) { |
|
996 | + if ($available_spaces >= $qty) { |
|
997 | 997 | // allow addons to prevent a ticket from being added to cart |
998 | 998 | if ( |
999 | 999 | ! apply_filters( |
@@ -1006,10 +1006,10 @@ discard block |
||
1006 | 1006 | ) { |
1007 | 1007 | return 0; |
1008 | 1008 | } |
1009 | - $qty = apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket ); |
|
1009 | + $qty = apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket); |
|
1010 | 1010 | // add event to cart |
1011 | - if( $qty && EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) { |
|
1012 | - self::_recalculate_ticket_datetime_availability( $ticket, $qty ); |
|
1011 | + if ($qty && EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) { |
|
1012 | + self::_recalculate_ticket_datetime_availability($ticket, $qty); |
|
1013 | 1013 | return $qty; |
1014 | 1014 | } else { |
1015 | 1015 | return 0; |
@@ -1017,9 +1017,9 @@ discard block |
||
1017 | 1017 | } else { |
1018 | 1018 | // tickets can not be purchased but let's find the exact number left |
1019 | 1019 | // for the last ticket selected PRIOR to subtracting tickets |
1020 | - $available_spaces = self::_ticket_datetime_availability( $ticket, true ); |
|
1020 | + $available_spaces = self::_ticket_datetime_availability($ticket, true); |
|
1021 | 1021 | // greedy greedy greedy eh? |
1022 | - if ( $available_spaces > 0 ) { |
|
1022 | + if ($available_spaces > 0) { |
|
1023 | 1023 | if ( |
1024 | 1024 | apply_filters( |
1025 | 1025 | 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error', |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | $available_spaces |
1030 | 1030 | ) |
1031 | 1031 | ) { |
1032 | - EED_Ticket_Selector::_display_availability_error( $available_spaces ); |
|
1032 | + EED_Ticket_Selector::_display_availability_error($available_spaces); |
|
1033 | 1033 | } |
1034 | 1034 | } else { |
1035 | 1035 | EE_Error::add_error( |
@@ -1054,10 +1054,10 @@ discard block |
||
1054 | 1054 | * @access private |
1055 | 1055 | * @param int $available_spaces |
1056 | 1056 | */ |
1057 | - private static function _display_availability_error( $available_spaces = 1 ) { |
|
1057 | + private static function _display_availability_error($available_spaces = 1) { |
|
1058 | 1058 | // add error messaging - we're using the _n function that will generate |
1059 | 1059 | // the appropriate singular or plural message based on the number of $available_spaces |
1060 | - if ( EE_Registry::instance()->CART->all_ticket_quantity_count() ) { |
|
1060 | + if (EE_Registry::instance()->CART->all_ticket_quantity_count()) { |
|
1061 | 1061 | $msg = sprintf( |
1062 | 1062 | _n( |
1063 | 1063 | 'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.', |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | '<br />' |
1081 | 1081 | ); |
1082 | 1082 | } |
1083 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1083 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | |
@@ -1096,22 +1096,22 @@ discard block |
||
1096 | 1096 | * @return int |
1097 | 1097 | * @throws \EE_Error |
1098 | 1098 | */ |
1099 | - private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) { |
|
1099 | + private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) { |
|
1100 | 1100 | // if the $_available_spaces array has not been set up yet... |
1101 | - if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
1102 | - self::_set_initial_ticket_datetime_availability( $ticket ); |
|
1101 | + if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
1102 | + self::_set_initial_ticket_datetime_availability($ticket); |
|
1103 | 1103 | } |
1104 | 1104 | $available_spaces = $ticket->qty() - $ticket->sold(); |
1105 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
1105 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
1106 | 1106 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
1107 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
1107 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
1108 | 1108 | // if we want the original datetime availability BEFORE we started subtracting tickets ? |
1109 | - if ( $get_original_ticket_spaces ) { |
|
1109 | + if ($get_original_ticket_spaces) { |
|
1110 | 1110 | // then grab the available spaces from the "tickets" array and compare with the above to get the lowest number |
1111 | - $available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] ); |
|
1111 | + $available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]); |
|
1112 | 1112 | } else { |
1113 | 1113 | // we want the updated ticket availability as stored in the "datetimes" array |
1114 | - $available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] ); |
|
1114 | + $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]); |
|
1115 | 1115 | } |
1116 | 1116 | } |
1117 | 1117 | } |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | * @return void |
1129 | 1129 | * @throws \EE_Error |
1130 | 1130 | */ |
1131 | - private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) { |
|
1131 | + private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) { |
|
1132 | 1132 | // first, get all of the datetimes that are available to this ticket |
1133 | 1133 | $datetimes = $ticket->get_many_related( |
1134 | 1134 | 'Datetime', |
@@ -1136,23 +1136,23 @@ discard block |
||
1136 | 1136 | array( |
1137 | 1137 | 'DTT_EVT_end' => array( |
1138 | 1138 | '>=', |
1139 | - EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ), |
|
1139 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
1140 | 1140 | ), |
1141 | 1141 | ), |
1142 | - 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), |
|
1142 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
1143 | 1143 | ) |
1144 | 1144 | ); |
1145 | - if ( ! empty( $datetimes )) { |
|
1145 | + if ( ! empty($datetimes)) { |
|
1146 | 1146 | // now loop thru all of the datetimes |
1147 | - foreach ( $datetimes as $datetime ) { |
|
1148 | - if ( $datetime instanceof EE_Datetime ) { |
|
1147 | + foreach ($datetimes as $datetime) { |
|
1148 | + if ($datetime instanceof EE_Datetime) { |
|
1149 | 1149 | // the number of spaces available for the datetime without considering individual ticket quantities |
1150 | 1150 | $spaces_remaining = $datetime->spaces_remaining(); |
1151 | 1151 | // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key |
1152 | - self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining ); |
|
1152 | + self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining); |
|
1153 | 1153 | // if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number, |
1154 | 1154 | // else just take the datetime spaces remaining, and assign to the datetimes array |
1155 | - self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining; |
|
1155 | + self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining; |
|
1156 | 1156 | } |
1157 | 1157 | } |
1158 | 1158 | } |
@@ -1168,12 +1168,12 @@ discard block |
||
1168 | 1168 | * @param int $qty |
1169 | 1169 | * @return void |
1170 | 1170 | */ |
1171 | - private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) { |
|
1172 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
1171 | + private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) { |
|
1172 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
1173 | 1173 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
1174 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
1174 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
1175 | 1175 | // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to, |
1176 | - self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty; |
|
1176 | + self::$_available_spaces['datetimes'][$DTD_ID] -= $qty; |
|
1177 | 1177 | } |
1178 | 1178 | } |
1179 | 1179 | } |
@@ -1190,8 +1190,8 @@ discard block |
||
1190 | 1190 | */ |
1191 | 1191 | public static function load_tckt_slctr_assets() { |
1192 | 1192 | // add some style |
1193 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
1194 | - wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'); |
|
1193 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
1194 | + wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'); |
|
1195 | 1195 | wp_enqueue_style('ticket_selector'); |
1196 | 1196 | // make it dance |
1197 | 1197 | // wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
@@ -1205,9 +1205,9 @@ discard block |
||
1205 | 1205 | |
1206 | 1206 | public static function load_tckt_slctr_assets_admin() { |
1207 | 1207 | //iframe button js on admin event editor page |
1208 | - if ( EE_Registry::instance()->REQ->get('page') === 'espresso_events' && EE_Registry::instance()->REQ->get('action') === 'edit' ) { |
|
1209 | - wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true ); |
|
1210 | - wp_enqueue_script( 'ticket_selector_embed' ); |
|
1208 | + if (EE_Registry::instance()->REQ->get('page') === 'espresso_events' && EE_Registry::instance()->REQ->get('action') === 'edit') { |
|
1209 | + wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
1210 | + wp_enqueue_script('ticket_selector_embed'); |
|
1211 | 1211 | } |
1212 | 1212 | } |
1213 | 1213 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\domain\services\capabilities\PublicCapabilities; |
2 | 2 | use EventEspresso\core\exceptions\InvalidEntityException; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
5 | 5 | /** |
6 | 6 | * Single Page Checkout (SPCO) |
7 | 7 | * |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @return EED_Single_Page_Checkout |
51 | 51 | */ |
52 | 52 | public static function instance() { |
53 | - add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' ); |
|
54 | - return parent::get_instance( __CLASS__ ); |
|
53 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
54 | + return parent::get_instance(__CLASS__); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -96,22 +96,22 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public static function set_hooks_admin() { |
98 | 98 | EED_Single_Page_Checkout::set_definitions(); |
99 | - if ( defined( 'DOING_AJAX' )) { |
|
99 | + if (defined('DOING_AJAX')) { |
|
100 | 100 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
101 | 101 | ob_start(); |
102 | 102 | EED_Single_Page_Checkout::load_request_handler(); |
103 | 103 | EED_Single_Page_Checkout::load_reg_steps(); |
104 | 104 | } else { |
105 | 105 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
106 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
106 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
107 | 107 | } |
108 | 108 | // set ajax hooks |
109 | - add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
110 | - add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
111 | - add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
112 | - add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
113 | - add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
114 | - add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
109 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
110 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
111 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
112 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
113 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
114 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param string $ajax_action |
123 | 123 | * @throws \EE_Error |
124 | 124 | */ |
125 | - public static function process_ajax_request( $ajax_action ) { |
|
126 | - EE_Registry::instance()->REQ->set( 'action', $ajax_action ); |
|
125 | + public static function process_ajax_request($ajax_action) { |
|
126 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
127 | 127 | EED_Single_Page_Checkout::instance()->_initialize(); |
128 | 128 | } |
129 | 129 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @throws \EE_Error |
136 | 136 | */ |
137 | 137 | public static function display_reg_step() { |
138 | - EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' ); |
|
138 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @throws \EE_Error |
147 | 147 | */ |
148 | 148 | public static function process_reg_step() { |
149 | - EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' ); |
|
149 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @throws \EE_Error |
158 | 158 | */ |
159 | 159 | public static function update_reg_step() { |
160 | - EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' ); |
|
160 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @throws \EE_Error |
171 | 171 | */ |
172 | 172 | public static function update_checkout() { |
173 | - EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' ); |
|
173 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public static function load_request_handler() { |
185 | 185 | // load core Request_Handler class |
186 | - if ( ! isset( EE_Registry::instance()->REQ )) { |
|
187 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
186 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
187 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
@@ -198,21 +198,21 @@ discard block |
||
198 | 198 | * @throws \EE_Error |
199 | 199 | */ |
200 | 200 | public static function set_definitions() { |
201 | - define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
202 | - define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS ); |
|
203 | - define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS ); |
|
204 | - define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS ); |
|
205 | - define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS ); |
|
206 | - define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS ); |
|
207 | - define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS ); |
|
208 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE ); |
|
209 | - EE_Registry::$i18n_js_strings[ 'registration_expiration_notice' ] = sprintf( |
|
210 | - __( '%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
201 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
202 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
203 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
204 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
205 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
206 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
207 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
208 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE); |
|
209 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
210 | + __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
211 | 211 | '<h4 class="important-notice">', |
212 | 212 | '</h4>', |
213 | 213 | '<br />', |
214 | 214 | '<p>', |
215 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
215 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
216 | 216 | '">', |
217 | 217 | '</a>', |
218 | 218 | '</p>' |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public static function load_reg_steps() { |
233 | 233 | static $reg_steps_loaded = FALSE; |
234 | - if ( $reg_steps_loaded ) { |
|
234 | + if ($reg_steps_loaded) { |
|
235 | 235 | return; |
236 | 236 | } |
237 | 237 | // filter list of reg_steps |
@@ -240,24 +240,24 @@ discard block |
||
240 | 240 | EED_Single_Page_Checkout::get_reg_steps() |
241 | 241 | ); |
242 | 242 | // sort by key (order) |
243 | - ksort( $reg_steps_to_load ); |
|
243 | + ksort($reg_steps_to_load); |
|
244 | 244 | // loop through folders |
245 | - foreach ( $reg_steps_to_load as $order => $reg_step ) { |
|
245 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
246 | 246 | // we need a |
247 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
247 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
248 | 248 | // copy over to the reg_steps_array |
249 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
249 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
250 | 250 | // register custom key route for each reg step |
251 | 251 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
252 | - EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
|
252 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
253 | 253 | // add AJAX or other hooks |
254 | - if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
|
254 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
255 | 255 | // setup autoloaders if necessary |
256 | - if ( ! class_exists( $reg_step['class_name'] )) { |
|
257 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
|
256 | + if ( ! class_exists($reg_step['class_name'])) { |
|
257 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE); |
|
258 | 258 | } |
259 | - if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
|
260 | - call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
|
259 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
260 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | } |
@@ -276,28 +276,28 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public static function get_reg_steps() { |
278 | 278 | $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
279 | - if ( empty( $reg_steps )) { |
|
279 | + if (empty($reg_steps)) { |
|
280 | 280 | $reg_steps = array( |
281 | 281 | 10 => array( |
282 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
282 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
283 | 283 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
284 | 284 | 'slug' => 'attendee_information', |
285 | 285 | 'has_hooks' => FALSE |
286 | 286 | ), |
287 | 287 | 20 => array( |
288 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
288 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
289 | 289 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
290 | 290 | 'slug' => 'registration_confirmation', |
291 | 291 | 'has_hooks' => FALSE |
292 | 292 | ), |
293 | 293 | 30 => array( |
294 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
294 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
295 | 295 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
296 | 296 | 'slug' => 'payment_options', |
297 | 297 | 'has_hooks' => TRUE |
298 | 298 | ), |
299 | 299 | 999 => array( |
300 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
300 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
301 | 301 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
302 | 302 | 'slug' => 'finalize_registration', |
303 | 303 | 'has_hooks' => FALSE |
@@ -318,9 +318,9 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public static function registration_checkout_for_admin() { |
320 | 320 | EED_Single_Page_Checkout::load_reg_steps(); |
321 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
322 | - EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' ); |
|
323 | - EE_Registry::instance()->REQ->set( 'process_form_submission', false ); |
|
321 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
322 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
323 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
324 | 324 | EED_Single_Page_Checkout::instance()->_initialize(); |
325 | 325 | EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
326 | 326 | return EE_Registry::instance()->REQ->get_output(); |
@@ -337,15 +337,15 @@ discard block |
||
337 | 337 | */ |
338 | 338 | public static function process_registration_from_admin() { |
339 | 339 | EED_Single_Page_Checkout::load_reg_steps(); |
340 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
341 | - EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' ); |
|
342 | - EE_Registry::instance()->REQ->set( 'process_form_submission', true ); |
|
340 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
341 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
342 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
343 | 343 | EED_Single_Page_Checkout::instance()->_initialize(); |
344 | - if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) { |
|
345 | - $final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps ); |
|
346 | - if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
347 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated( $final_reg_step ); |
|
348 | - if ( $final_reg_step->process_reg_step() ) { |
|
344 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
345 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
346 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
347 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
348 | + if ($final_reg_step->process_reg_step()) { |
|
349 | 349 | $final_reg_step->set_completed(); |
350 | 350 | EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
351 | 351 | return EED_Single_Page_Checkout::instance()->checkout->transaction; |
@@ -365,11 +365,11 @@ discard block |
||
365 | 365 | * @return void |
366 | 366 | * @throws \EE_Error |
367 | 367 | */ |
368 | - public function run( $WP_Query ) { |
|
368 | + public function run($WP_Query) { |
|
369 | 369 | if ( |
370 | 370 | $WP_Query instanceof WP_Query |
371 | 371 | && $WP_Query->is_main_query() |
372 | - && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true ) |
|
372 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
373 | 373 | ) { |
374 | 374 | $this->_initialize(); |
375 | 375 | } |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | * @return void |
386 | 386 | * @throws \EE_Error |
387 | 387 | */ |
388 | - public static function init( $WP_Query ) { |
|
389 | - EED_Single_Page_Checkout::instance()->run( $WP_Query ); |
|
388 | + public static function init($WP_Query) { |
|
389 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | */ |
401 | 401 | private function _initialize() { |
402 | 402 | // ensure SPCO doesn't run twice |
403 | - if ( EED_Single_Page_Checkout::$_initialized ) { |
|
403 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
404 | 404 | return; |
405 | 405 | } |
406 | 406 | try { |
@@ -408,22 +408,22 @@ discard block |
||
408 | 408 | // setup the EE_Checkout object |
409 | 409 | $this->checkout = $this->_initialize_checkout(); |
410 | 410 | // filter checkout |
411 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
|
411 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
412 | 412 | // get the $_GET |
413 | 413 | $this->_get_request_vars(); |
414 | 414 | // filter continue_reg |
415 | - $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
|
415 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); |
|
416 | 416 | // load the reg steps array |
417 | - if ( ! $this->_load_and_instantiate_reg_steps() ) { |
|
417 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
418 | 418 | EED_Single_Page_Checkout::$_initialized = true; |
419 | 419 | return; |
420 | 420 | } |
421 | 421 | // set the current step |
422 | - $this->checkout->set_current_step( $this->checkout->step ); |
|
422 | + $this->checkout->set_current_step($this->checkout->step); |
|
423 | 423 | // and the next step |
424 | 424 | $this->checkout->set_next_step(); |
425 | 425 | // verify that everything has been setup correctly |
426 | - if ( ! ( $this->_verify_transaction_and_get_registrations() && $this->_final_verifications() ) ) { |
|
426 | + if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
427 | 427 | EED_Single_Page_Checkout::$_initialized = true; |
428 | 428 | return; |
429 | 429 | } |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | // set no cache headers and constants |
449 | 449 | EE_System::do_not_cache(); |
450 | 450 | // add anchor |
451 | - add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
|
451 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
452 | 452 | // remove transaction lock |
453 | - add_action( 'shutdown', array( $this, 'unlock_transaction' ), 1 ); |
|
454 | - } catch ( Exception $e ) { |
|
455 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
453 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
454 | + } catch (Exception $e) { |
|
455 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
@@ -466,16 +466,16 @@ discard block |
||
466 | 466 | * @throws EE_Error |
467 | 467 | */ |
468 | 468 | private function _verify_session() { |
469 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
470 | - throw new EE_Error( __( 'The EE_Session class could not be loaded.', 'event_espresso' ) ); |
|
469 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
470 | + throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
471 | 471 | } |
472 | 472 | // is session still valid ? |
473 | - if ( EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ) === '' ) { |
|
473 | + if (EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '') { |
|
474 | 474 | $this->checkout = new EE_Checkout(); |
475 | 475 | EE_Registry::instance()->SSN->reset_cart(); |
476 | 476 | EE_Registry::instance()->SSN->reset_checkout(); |
477 | 477 | EE_Registry::instance()->SSN->reset_transaction(); |
478 | - EE_Error::add_attention( EE_Registry::$i18n_js_strings[ 'registration_expiration_notice' ], __FILE__, __FUNCTION__, __LINE__ ); |
|
478 | + EE_Error::add_attention(EE_Registry::$i18n_js_strings['registration_expiration_notice'], __FILE__, __FUNCTION__, __LINE__); |
|
479 | 479 | EE_Registry::instance()->SSN->reset_expired(); |
480 | 480 | } |
481 | 481 | } |
@@ -495,20 +495,20 @@ discard block |
||
495 | 495 | /** @type EE_Checkout $checkout */ |
496 | 496 | $checkout = EE_Registry::instance()->SSN->checkout(); |
497 | 497 | // verify |
498 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
498 | + if ( ! $checkout instanceof EE_Checkout) { |
|
499 | 499 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
500 | - $checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE ); |
|
500 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE); |
|
501 | 501 | } else { |
502 | - if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true ) { |
|
502 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
503 | 503 | $this->unlock_transaction(); |
504 | - wp_safe_redirect( $checkout->redirect_url ); |
|
504 | + wp_safe_redirect($checkout->redirect_url); |
|
505 | 505 | exit(); |
506 | 506 | } |
507 | 507 | } |
508 | - $checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout ); |
|
508 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
509 | 509 | // verify again |
510 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
511 | - throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) ); |
|
510 | + if ( ! $checkout instanceof EE_Checkout) { |
|
511 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
512 | 512 | } |
513 | 513 | // reset anything that needs a clean slate for each request |
514 | 514 | $checkout->reset_for_current_request(); |
@@ -528,24 +528,24 @@ discard block |
||
528 | 528 | // load classes |
529 | 529 | EED_Single_Page_Checkout::load_request_handler(); |
530 | 530 | //make sure this request is marked as belonging to EE |
531 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
531 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
532 | 532 | // which step is being requested ? |
533 | - $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
|
533 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
534 | 534 | // which step is being edited ? |
535 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
|
535 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
536 | 536 | // and what we're doing on the current step |
537 | - $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
|
537 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
538 | 538 | // returning to edit ? |
539 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
|
539 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
540 | 540 | // or some other kind of revisit ? |
541 | - $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
|
541 | + $this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE); |
|
542 | 542 | // and whether or not to generate a reg form for this request |
543 | - $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
|
543 | + $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE FALSE |
|
544 | 544 | // and whether or not to process a reg form submission for this request |
545 | - $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
|
545 | + $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE FALSE |
|
546 | 546 | $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' |
547 | 547 | ? $this->checkout->process_form_submission |
548 | - : FALSE; // TRUE FALSE |
|
548 | + : FALSE; // TRUE FALSE |
|
549 | 549 | // $this->_display_request_vars(); |
550 | 550 | } |
551 | 551 | |
@@ -558,17 +558,17 @@ discard block |
||
558 | 558 | * @return void |
559 | 559 | */ |
560 | 560 | protected function _display_request_vars() { |
561 | - if ( ! WP_DEBUG ) { |
|
561 | + if ( ! WP_DEBUG) { |
|
562 | 562 | return; |
563 | 563 | } |
564 | - EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
565 | - EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ ); |
|
566 | - EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ ); |
|
567 | - EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ ); |
|
568 | - EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ ); |
|
569 | - EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ ); |
|
570 | - EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ ); |
|
571 | - EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ ); |
|
564 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
565 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
566 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
567 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
568 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
569 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
570 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
571 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | |
@@ -582,8 +582,8 @@ discard block |
||
582 | 582 | * @return array |
583 | 583 | */ |
584 | 584 | private function _get_first_step() { |
585 | - $first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array ); |
|
586 | - return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information'; |
|
585 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
586 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | |
@@ -599,27 +599,27 @@ discard block |
||
599 | 599 | private function _load_and_instantiate_reg_steps() { |
600 | 600 | // have reg_steps already been instantiated ? |
601 | 601 | if ( |
602 | - empty( $this->checkout->reg_steps ) || |
|
603 | - apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
|
602 | + empty($this->checkout->reg_steps) || |
|
603 | + apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
604 | 604 | ) { |
605 | 605 | // if not, then loop through raw reg steps array |
606 | - foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
|
607 | - if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
|
606 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
607 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
608 | 608 | return false; |
609 | 609 | } |
610 | 610 | } |
611 | 611 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
612 | 612 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
613 | 613 | // skip the registration_confirmation page ? |
614 | - if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
|
614 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
615 | 615 | // just remove it from the reg steps array |
616 | - $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
|
616 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
617 | 617 | } else if ( |
618 | - isset( $this->checkout->reg_steps['registration_confirmation'] ) |
|
618 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
619 | 619 | && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
620 | 620 | ) { |
621 | 621 | // set the order to something big like 100 |
622 | - $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
|
622 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
623 | 623 | } |
624 | 624 | // filter the array for good luck |
625 | 625 | $this->checkout->reg_steps = apply_filters( |
@@ -629,13 +629,13 @@ discard block |
||
629 | 629 | // finally re-sort based on the reg step class order properties |
630 | 630 | $this->checkout->sort_reg_steps(); |
631 | 631 | } else { |
632 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
632 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
633 | 633 | // set all current step stati to FALSE |
634 | - $reg_step->set_is_current_step( FALSE ); |
|
634 | + $reg_step->set_is_current_step(FALSE); |
|
635 | 635 | } |
636 | 636 | } |
637 | - if ( empty( $this->checkout->reg_steps )) { |
|
638 | - EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
637 | + if (empty($this->checkout->reg_steps)) { |
|
638 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
639 | 639 | return false; |
640 | 640 | } |
641 | 641 | // make reg step details available to JS |
@@ -653,10 +653,10 @@ discard block |
||
653 | 653 | * @param int $order |
654 | 654 | * @return bool |
655 | 655 | */ |
656 | - private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
|
656 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) { |
|
657 | 657 | |
658 | 658 | // we need a file_path, class_name, and slug to add a reg step |
659 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
659 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
660 | 660 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
661 | 661 | if ( |
662 | 662 | $this->checkout->reg_url_link |
@@ -674,26 +674,26 @@ discard block |
||
674 | 674 | FALSE |
675 | 675 | ); |
676 | 676 | // did we gets the goods ? |
677 | - if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
677 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
678 | 678 | // set reg step order based on config |
679 | - $reg_step_obj->set_order( $order ); |
|
679 | + $reg_step_obj->set_order($order); |
|
680 | 680 | // add instantiated reg step object to the master reg steps array |
681 | - $this->checkout->add_reg_step( $reg_step_obj ); |
|
681 | + $this->checkout->add_reg_step($reg_step_obj); |
|
682 | 682 | } else { |
683 | 683 | EE_Error::add_error( |
684 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
684 | + __('The current step could not be set.', 'event_espresso'), |
|
685 | 685 | __FILE__, __FUNCTION__, __LINE__ |
686 | 686 | ); |
687 | 687 | return false; |
688 | 688 | } |
689 | 689 | } else { |
690 | - if ( WP_DEBUG ) { |
|
690 | + if (WP_DEBUG) { |
|
691 | 691 | EE_Error::add_error( |
692 | 692 | sprintf( |
693 | - __( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ), |
|
694 | - isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
|
695 | - isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
|
696 | - isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
|
693 | + __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'), |
|
694 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
695 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
696 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
697 | 697 | '<ul>', |
698 | 698 | '<li>', |
699 | 699 | '</li>', |
@@ -717,15 +717,15 @@ discard block |
||
717 | 717 | */ |
718 | 718 | private function _verify_transaction_and_get_registrations() { |
719 | 719 | // was there already a valid transaction in the checkout from the session ? |
720 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
720 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
721 | 721 | // get transaction from db or session |
722 | 722 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
723 | 723 | ? $this->_get_transaction_and_cart_for_previous_visit() |
724 | 724 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
725 | 725 | |
726 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
726 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
727 | 727 | EE_Error::add_error( |
728 | - __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), |
|
728 | + __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
729 | 729 | __FILE__, __FUNCTION__, __LINE__ |
730 | 730 | ); |
731 | 731 | $this->checkout->transaction = EE_Transaction::new_instance(); |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | return false; |
736 | 736 | } |
737 | 737 | // and the registrations for the transaction |
738 | - $this->_get_registrations( $this->checkout->transaction ); |
|
738 | + $this->_get_registrations($this->checkout->transaction); |
|
739 | 739 | } |
740 | 740 | return true; |
741 | 741 | } |
@@ -750,16 +750,16 @@ discard block |
||
750 | 750 | */ |
751 | 751 | private function _get_transaction_and_cart_for_previous_visit() { |
752 | 752 | /** @var $TXN_model EEM_Transaction */ |
753 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
753 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
754 | 754 | // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
755 | - $transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link ); |
|
755 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
756 | 756 | // verify transaction |
757 | - if ( $transaction instanceof EE_Transaction ) { |
|
757 | + if ($transaction instanceof EE_Transaction) { |
|
758 | 758 | // and get the cart that was used for that transaction |
759 | - $this->checkout->cart = $this->_get_cart_for_transaction( $transaction ); |
|
759 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
760 | 760 | return $transaction; |
761 | 761 | } else { |
762 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
762 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
763 | 763 | return NULL; |
764 | 764 | } |
765 | 765 | } |
@@ -773,8 +773,8 @@ discard block |
||
773 | 773 | * @param EE_Transaction $transaction |
774 | 774 | * @return EE_Cart |
775 | 775 | */ |
776 | - private function _get_cart_for_transaction( $transaction ) { |
|
777 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
776 | + private function _get_cart_for_transaction($transaction) { |
|
777 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | |
@@ -786,8 +786,8 @@ discard block |
||
786 | 786 | * @param EE_Transaction $transaction |
787 | 787 | * @return EE_Cart |
788 | 788 | */ |
789 | - public function get_cart_for_transaction( EE_Transaction $transaction ) { |
|
790 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
789 | + public function get_cart_for_transaction(EE_Transaction $transaction) { |
|
790 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | |
@@ -803,15 +803,15 @@ discard block |
||
803 | 803 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
804 | 804 | // if there's no transaction, then this is the FIRST visit to SPCO |
805 | 805 | // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
806 | - $this->checkout->cart = $this->_get_cart_for_transaction( NULL ); |
|
806 | + $this->checkout->cart = $this->_get_cart_for_transaction(NULL); |
|
807 | 807 | // and then create a new transaction |
808 | 808 | $transaction = $this->_initialize_transaction(); |
809 | 809 | // verify transaction |
810 | - if ( $transaction instanceof EE_Transaction ) { |
|
810 | + if ($transaction instanceof EE_Transaction) { |
|
811 | 811 | // and save TXN data to the cart |
812 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
812 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
813 | 813 | } else { |
814 | - EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
814 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
815 | 815 | } |
816 | 816 | return $transaction; |
817 | 817 | } |
@@ -847,8 +847,8 @@ discard block |
||
847 | 847 | $transaction->ID() |
848 | 848 | ); |
849 | 849 | return $transaction; |
850 | - } catch( Exception $e ) { |
|
851 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
850 | + } catch (Exception $e) { |
|
851 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
852 | 852 | } |
853 | 853 | return NULL; |
854 | 854 | } |
@@ -863,38 +863,38 @@ discard block |
||
863 | 863 | * @return EE_Cart |
864 | 864 | * @throws \EE_Error |
865 | 865 | */ |
866 | - private function _get_registrations( EE_Transaction $transaction ) { |
|
866 | + private function _get_registrations(EE_Transaction $transaction) { |
|
867 | 867 | // first step: grab the registrants { : o |
868 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true ); |
|
868 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
869 | 869 | // verify registrations have been set |
870 | - if ( empty( $registrations )) { |
|
870 | + if (empty($registrations)) { |
|
871 | 871 | // if no cached registrations, then check the db |
872 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false ); |
|
872 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
873 | 873 | // still nothing ? well as long as this isn't a revisit |
874 | - if ( empty( $registrations ) && ! $this->checkout->revisit ) { |
|
874 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
875 | 875 | // generate new registrations from scratch |
876 | - $registrations = $this->_initialize_registrations( $transaction ); |
|
876 | + $registrations = $this->_initialize_registrations($transaction); |
|
877 | 877 | } |
878 | 878 | } |
879 | 879 | // sort by their original registration order |
880 | - usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' )); |
|
880 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
881 | 881 | // then loop thru the array |
882 | - foreach ( $registrations as $registration ) { |
|
882 | + foreach ($registrations as $registration) { |
|
883 | 883 | // verify each registration |
884 | - if ( $registration instanceof EE_Registration ) { |
|
884 | + if ($registration instanceof EE_Registration) { |
|
885 | 885 | // we display all attendee info for the primary registrant |
886 | - if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
|
886 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
887 | 887 | && $registration->is_primary_registrant() |
888 | 888 | ) { |
889 | 889 | $this->checkout->primary_revisit = true; |
890 | 890 | break; |
891 | - } else if ( $this->checkout->revisit |
|
891 | + } else if ($this->checkout->revisit |
|
892 | 892 | && $this->checkout->reg_url_link !== $registration->reg_url_link() |
893 | 893 | ) { |
894 | 894 | // but hide info if it doesn't belong to you |
895 | - $transaction->clear_cache( 'Registration', $registration->ID() ); |
|
895 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
896 | 896 | } |
897 | - $this->checkout->set_reg_status_updated( $registration->ID(), false ); |
|
897 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
898 | 898 | } |
899 | 899 | } |
900 | 900 | } |
@@ -909,17 +909,17 @@ discard block |
||
909 | 909 | * @return array |
910 | 910 | * @throws \EE_Error |
911 | 911 | */ |
912 | - private function _initialize_registrations( EE_Transaction $transaction ) { |
|
912 | + private function _initialize_registrations(EE_Transaction $transaction) { |
|
913 | 913 | $att_nmbr = 0; |
914 | 914 | $registrations = array(); |
915 | - if ( $transaction instanceof EE_Transaction ) { |
|
915 | + if ($transaction instanceof EE_Transaction) { |
|
916 | 916 | /** @type EE_Registration_Processor $registration_processor */ |
917 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
917 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
918 | 918 | $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
919 | 919 | // now let's add the cart items to the $transaction |
920 | - foreach ( $this->checkout->cart->get_tickets() as $line_item ) { |
|
920 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
921 | 921 | //do the following for each ticket of this type they selected |
922 | - for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
|
922 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
923 | 923 | $att_nmbr++; |
924 | 924 | /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
925 | 925 | $CreateRegistrationCommand = EE_Registry::instance() |
@@ -935,17 +935,17 @@ discard block |
||
935 | 935 | // override capabilities for frontend registrations |
936 | 936 | if ( ! is_admin()) { |
937 | 937 | $CreateRegistrationCommand->setCapCheck( |
938 | - new PublicCapabilities( '', 'create_new_registration' ) |
|
938 | + new PublicCapabilities('', 'create_new_registration') |
|
939 | 939 | ); |
940 | 940 | } |
941 | - $registration = EE_Registry::instance()->BUS->execute( $CreateRegistrationCommand ); |
|
942 | - if ( ! $registration instanceof EE_Registration ) { |
|
943 | - throw new InvalidEntityException( $registration, 'EE_Registration' ); |
|
941 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
942 | + if ( ! $registration instanceof EE_Registration) { |
|
943 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
944 | 944 | } |
945 | - $registrations[ $registration->ID() ] = $registration; |
|
945 | + $registrations[$registration->ID()] = $registration; |
|
946 | 946 | } |
947 | 947 | } |
948 | - $registration_processor->fix_reg_final_price_rounding_issue( $transaction ); |
|
948 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
949 | 949 | } |
950 | 950 | return $registrations; |
951 | 951 | } |
@@ -960,12 +960,12 @@ discard block |
||
960 | 960 | * @param EE_Registration $reg_B |
961 | 961 | * @return int |
962 | 962 | */ |
963 | - public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
|
963 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) { |
|
964 | 964 | // this shouldn't ever happen within the same TXN, but oh well |
965 | - if ( $reg_A->count() === $reg_B->count() ) { |
|
965 | + if ($reg_A->count() === $reg_B->count()) { |
|
966 | 966 | return 0; |
967 | 967 | } |
968 | - return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1; |
|
968 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | |
@@ -980,21 +980,21 @@ discard block |
||
980 | 980 | */ |
981 | 981 | private function _final_verifications() { |
982 | 982 | // filter checkout |
983 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout ); |
|
983 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
984 | 984 | //verify that current step is still set correctly |
985 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) { |
|
986 | - EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
985 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
986 | + EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
987 | 987 | return false; |
988 | 988 | } |
989 | 989 | // if returning to SPCO, then verify that primary registrant is set |
990 | - if ( ! empty( $this->checkout->reg_url_link )) { |
|
990 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
991 | 991 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
992 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
993 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
992 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
993 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
994 | 994 | return false; |
995 | 995 | } |
996 | 996 | $valid_registrant = null; |
997 | - foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) { |
|
997 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
998 | 998 | if ( |
999 | 999 | $registration instanceof EE_Registration |
1000 | 1000 | && $registration->reg_url_link() === $this->checkout->reg_url_link |
@@ -1002,9 +1002,9 @@ discard block |
||
1002 | 1002 | $valid_registrant = $registration; |
1003 | 1003 | } |
1004 | 1004 | } |
1005 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
1005 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
1006 | 1006 | // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
1007 | - if ( EED_Single_Page_Checkout::$_checkout_verified ) { |
|
1007 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1008 | 1008 | // clear the session, mark the checkout as unverified, and try again |
1009 | 1009 | EE_Registry::instance()->SSN->clear_session(); |
1010 | 1010 | EED_Single_Page_Checkout::$_initialized = false; |
@@ -1013,13 +1013,13 @@ discard block |
||
1013 | 1013 | EE_Error::reset_notices(); |
1014 | 1014 | return false; |
1015 | 1015 | } |
1016 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1016 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1017 | 1017 | return false; |
1018 | 1018 | } |
1019 | 1019 | } |
1020 | 1020 | // now that things have been kinda sufficiently verified, |
1021 | 1021 | // let's add the checkout to the session so that's available other systems |
1022 | - EE_Registry::instance()->SSN->set_checkout( $this->checkout ); |
|
1022 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1023 | 1023 | return true; |
1024 | 1024 | } |
1025 | 1025 | |
@@ -1034,15 +1034,15 @@ discard block |
||
1034 | 1034 | * @param bool $reinitializing |
1035 | 1035 | * @throws \EE_Error |
1036 | 1036 | */ |
1037 | - private function _initialize_reg_steps( $reinitializing = false ) { |
|
1038 | - $this->checkout->set_reg_step_initiated( $this->checkout->current_step ); |
|
1037 | + private function _initialize_reg_steps($reinitializing = false) { |
|
1038 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1039 | 1039 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
1040 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
1041 | - if ( ! $reg_step->initialize_reg_step() ) { |
|
1040 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
1041 | + if ( ! $reg_step->initialize_reg_step()) { |
|
1042 | 1042 | // if not initialized then maybe this step is being removed... |
1043 | - if ( ! $reinitializing && $reg_step->is_current_step() ) { |
|
1043 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
1044 | 1044 | // if it was the current step, then we need to start over here |
1045 | - $this->_initialize_reg_steps( true ); |
|
1045 | + $this->_initialize_reg_steps(true); |
|
1046 | 1046 | return; |
1047 | 1047 | } |
1048 | 1048 | continue; |
@@ -1051,13 +1051,13 @@ discard block |
||
1051 | 1051 | $reg_step->enqueue_styles_and_scripts(); |
1052 | 1052 | // i18n |
1053 | 1053 | $reg_step->translate_js_strings(); |
1054 | - if ( $reg_step->is_current_step() ) { |
|
1054 | + if ($reg_step->is_current_step()) { |
|
1055 | 1055 | // the text that appears on the reg step form submit button |
1056 | 1056 | $reg_step->set_submit_button_text(); |
1057 | 1057 | } |
1058 | 1058 | } |
1059 | 1059 | // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
1060 | - do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step ); |
|
1060 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | |
@@ -1070,43 +1070,43 @@ discard block |
||
1070 | 1070 | */ |
1071 | 1071 | private function _check_form_submission() { |
1072 | 1072 | //does this request require the reg form to be generated ? |
1073 | - if ( $this->checkout->generate_reg_form ) { |
|
1073 | + if ($this->checkout->generate_reg_form) { |
|
1074 | 1074 | // ever heard that song by Blue Rodeo ? |
1075 | 1075 | try { |
1076 | 1076 | $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
1077 | 1077 | // if not displaying a form, then check for form submission |
1078 | - if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) { |
|
1078 | + if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) { |
|
1079 | 1079 | // clear out any old data in case this step is being run again |
1080 | - $this->checkout->current_step->set_valid_data( array() ); |
|
1080 | + $this->checkout->current_step->set_valid_data(array()); |
|
1081 | 1081 | // capture submitted form data |
1082 | 1082 | $this->checkout->current_step->reg_form->receive_form_submission( |
1083 | - apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout ) |
|
1083 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
1084 | 1084 | ); |
1085 | 1085 | // validate submitted form data |
1086 | - if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid() ) { |
|
1086 | + if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1087 | 1087 | // thou shall not pass !!! |
1088 | 1088 | $this->checkout->continue_reg = FALSE; |
1089 | 1089 | // any form validation errors? |
1090 | - if ( $this->checkout->current_step->reg_form->submission_error_message() !== '' ) { |
|
1090 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1091 | 1091 | $submission_error_messages = array(); |
1092 | 1092 | // bad, bad, bad registrant |
1093 | - foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){ |
|
1094 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1093 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
1094 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1095 | 1095 | $submission_error_messages[] = sprintf( |
1096 | - __( '%s : %s', 'event_espresso' ), |
|
1096 | + __('%s : %s', 'event_espresso'), |
|
1097 | 1097 | $validation_error->get_form_section()->html_label_text(), |
1098 | 1098 | $validation_error->getMessage() |
1099 | 1099 | ); |
1100 | 1100 | } |
1101 | 1101 | } |
1102 | - EE_Error::add_error( implode( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1102 | + EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1103 | 1103 | } |
1104 | 1104 | // well not really... what will happen is we'll just get redirected back to redo the current step |
1105 | 1105 | $this->go_to_next_step(); |
1106 | 1106 | return; |
1107 | 1107 | } |
1108 | 1108 | } |
1109 | - } catch( EE_Error $e ) { |
|
1109 | + } catch (EE_Error $e) { |
|
1110 | 1110 | $e->get_error(); |
1111 | 1111 | } |
1112 | 1112 | } |
@@ -1123,22 +1123,22 @@ discard block |
||
1123 | 1123 | */ |
1124 | 1124 | private function _process_form_action() { |
1125 | 1125 | // what cha wanna do? |
1126 | - switch( $this->checkout->action ) { |
|
1126 | + switch ($this->checkout->action) { |
|
1127 | 1127 | // AJAX next step reg form |
1128 | 1128 | case 'display_spco_reg_step' : |
1129 | 1129 | $this->checkout->redirect = FALSE; |
1130 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1131 | - $this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() ); |
|
1130 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1131 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1132 | 1132 | } |
1133 | 1133 | break; |
1134 | 1134 | |
1135 | 1135 | default : |
1136 | 1136 | // meh... do one of those other steps first |
1137 | - if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) { |
|
1137 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1138 | 1138 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
1139 | - do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1139 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1140 | 1140 | // call action on current step |
1141 | - if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) { |
|
1141 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1142 | 1142 | // good registrant, you get to proceed |
1143 | 1143 | if ( |
1144 | 1144 | $this->checkout->current_step->success_message() !== '' |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | ) { |
1150 | 1150 | EE_Error::add_success( |
1151 | 1151 | $this->checkout->current_step->success_message() |
1152 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1152 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
1153 | 1153 | ); |
1154 | 1154 | |
1155 | 1155 | } |
@@ -1157,12 +1157,12 @@ discard block |
||
1157 | 1157 | $this->_setup_redirect(); |
1158 | 1158 | } |
1159 | 1159 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
1160 | - do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1160 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1161 | 1161 | |
1162 | 1162 | } else { |
1163 | 1163 | EE_Error::add_error( |
1164 | 1164 | sprintf( |
1165 | - __( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ), |
|
1165 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1166 | 1166 | $this->checkout->action, |
1167 | 1167 | $this->checkout->current_step->name() |
1168 | 1168 | ), |
@@ -1188,10 +1188,10 @@ discard block |
||
1188 | 1188 | public function add_styles_and_scripts() { |
1189 | 1189 | // i18n |
1190 | 1190 | $this->translate_js_strings(); |
1191 | - if ( $this->checkout->admin_request ) { |
|
1192 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 ); |
|
1191 | + if ($this->checkout->admin_request) { |
|
1192 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1193 | 1193 | } else { |
1194 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 ); |
|
1194 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1195 | 1195 | } |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1207,50 +1207,50 @@ discard block |
||
1207 | 1207 | EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
1208 | 1208 | EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
1209 | 1209 | EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
1210 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1211 | - EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
1212 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1210 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1211 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
1212 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1213 | 1213 | EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
1214 | 1214 | EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
1215 | 1215 | EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
1216 | - __( 'Please wait while we process your registration.%1$sDo not refresh the page or navigate away while this is happening.%1$sThank you for your patience.', 'event_espresso' ), |
|
1216 | + __('Please wait while we process your registration.%1$sDo not refresh the page or navigate away while this is happening.%1$sThank you for your patience.', 'event_espresso'), |
|
1217 | 1217 | '<br/>' |
1218 | 1218 | ); |
1219 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' ); |
|
1219 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1220 | 1220 | EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
1221 | 1221 | EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
1222 | 1222 | EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
1223 | - EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' ); |
|
1224 | - EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' ); |
|
1225 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' ); |
|
1226 | - EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' ); |
|
1227 | - EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' ); |
|
1228 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' ); |
|
1229 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' ); |
|
1230 | - EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' ); |
|
1231 | - EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' ); |
|
1232 | - EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' ); |
|
1233 | - EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' ); |
|
1234 | - EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' ); |
|
1235 | - EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' ); |
|
1236 | - EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' ); |
|
1223 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1224 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1225 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1226 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1227 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1228 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1229 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1230 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1231 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1232 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1233 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1234 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1235 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1236 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1237 | 1237 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
1238 | - __( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
1238 | + __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
1239 | 1239 | '<h4 class="important-notice">', |
1240 | 1240 | '</h4>', |
1241 | 1241 | '<br />', |
1242 | 1242 | '<p>', |
1243 | - '<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1243 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1244 | 1244 | '">', |
1245 | 1245 | '</a>', |
1246 | 1246 | '</p>' |
1247 | 1247 | ); |
1248 | - EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true ); |
|
1249 | - EE_Registry::$i18n_js_strings[ 'session_extension' ] = absint( |
|
1250 | - apply_filters( 'FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS ) |
|
1248 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1249 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1250 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1251 | 1251 | ); |
1252 | - EE_Registry::$i18n_js_strings[ 'session_expiration' ] = gmdate( |
|
1253 | - 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) |
|
1252 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1253 | + 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1254 | 1254 | ); |
1255 | 1255 | |
1256 | 1256 | |
@@ -1266,31 +1266,31 @@ discard block |
||
1266 | 1266 | */ |
1267 | 1267 | public function enqueue_styles_and_scripts() { |
1268 | 1268 | // load css |
1269 | - wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1270 | - wp_enqueue_style( 'single_page_checkout' ); |
|
1269 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1270 | + wp_enqueue_style('single_page_checkout'); |
|
1271 | 1271 | // load JS |
1272 | - wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array( 'jquery' ), '1.0.1', TRUE ); |
|
1273 | - wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE ); |
|
1272 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', TRUE); |
|
1273 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE); |
|
1274 | 1274 | wp_register_script( |
1275 | 1275 | 'single_page_checkout', |
1276 | - SPCO_JS_URL . 'single_page_checkout.js', |
|
1277 | - array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), |
|
1276 | + SPCO_JS_URL.'single_page_checkout.js', |
|
1277 | + array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), |
|
1278 | 1278 | EVENT_ESPRESSO_VERSION, |
1279 | 1279 | TRUE |
1280 | 1280 | ); |
1281 | - wp_enqueue_script( 'single_page_checkout' ); |
|
1281 | + wp_enqueue_script('single_page_checkout'); |
|
1282 | 1282 | |
1283 | 1283 | /** |
1284 | 1284 | * global action hook for enqueueing styles and scripts with |
1285 | 1285 | * spco calls. |
1286 | 1286 | */ |
1287 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this ); |
|
1287 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1288 | 1288 | |
1289 | 1289 | /** |
1290 | 1290 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
1291 | 1291 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1292 | 1292 | */ |
1293 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this ); |
|
1293 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
1294 | 1294 | |
1295 | 1295 | } |
1296 | 1296 | |
@@ -1305,20 +1305,20 @@ discard block |
||
1305 | 1305 | */ |
1306 | 1306 | private function _display_spco_reg_form() { |
1307 | 1307 | // if registering via the admin, just display the reg form for the current step |
1308 | - if ( $this->checkout->admin_request ) { |
|
1309 | - EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() ); |
|
1308 | + if ($this->checkout->admin_request) { |
|
1309 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1310 | 1310 | } else { |
1311 | 1311 | // add powered by EE msg |
1312 | - add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' )); |
|
1312 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1313 | 1313 | |
1314 | - $empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false; |
|
1315 | - EE_Registry::$i18n_js_strings[ 'empty_cart' ] = $empty_cart; |
|
1314 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false; |
|
1315 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1316 | 1316 | $cookies_not_set_msg = ''; |
1317 | - if ( $empty_cart && ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) { |
|
1317 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
1318 | 1318 | $cookies_not_set_msg = apply_filters( |
1319 | 1319 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
1320 | 1320 | sprintf( |
1321 | - __( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ), |
|
1321 | + __('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'), |
|
1322 | 1322 | '<div class="ee-attention">', |
1323 | 1323 | '</div>', |
1324 | 1324 | '<h6 class="important-notice">', |
@@ -1338,7 +1338,7 @@ discard block |
||
1338 | 1338 | 'layout_strategy' => |
1339 | 1339 | new EE_Template_Layout( |
1340 | 1340 | array( |
1341 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1341 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1342 | 1342 | 'template_args' => array( |
1343 | 1343 | 'empty_cart' => $empty_cart, |
1344 | 1344 | 'revisit' => $this->checkout->revisit, |
@@ -1350,8 +1350,8 @@ discard block |
||
1350 | 1350 | 'empty_msg' => apply_filters( |
1351 | 1351 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
1352 | 1352 | sprintf( |
1353 | - __( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ), |
|
1354 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1353 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'), |
|
1354 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1355 | 1355 | '">', |
1356 | 1356 | '</a>' |
1357 | 1357 | ) |
@@ -1369,7 +1369,7 @@ discard block |
||
1369 | 1369 | ) |
1370 | 1370 | ); |
1371 | 1371 | // load template and add to output sent that gets filtered into the_content() |
1372 | - EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() ); |
|
1372 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js()); |
|
1373 | 1373 | } |
1374 | 1374 | } |
1375 | 1375 | |
@@ -1383,8 +1383,8 @@ discard block |
||
1383 | 1383 | * @internal param string $label |
1384 | 1384 | * @return string |
1385 | 1385 | */ |
1386 | - public function add_extra_finalize_registration_inputs( $next_step ) { |
|
1387 | - if ( $next_step === 'finalize_registration' ) { |
|
1386 | + public function add_extra_finalize_registration_inputs($next_step) { |
|
1387 | + if ($next_step === 'finalize_registration') { |
|
1388 | 1388 | echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
1389 | 1389 | } |
1390 | 1390 | } |
@@ -1406,8 +1406,8 @@ discard block |
||
1406 | 1406 | ) { |
1407 | 1407 | add_filter( |
1408 | 1408 | 'FHEE__EEH_Template__powered_by_event_espresso__url', |
1409 | - function( $url) { |
|
1410 | - return apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url ); |
|
1409 | + function($url) { |
|
1410 | + return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1411 | 1411 | } |
1412 | 1412 | ); |
1413 | 1413 | echo apply_filters( |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | \EEH_Template::powered_by_event_espresso( |
1416 | 1416 | '', |
1417 | 1417 | 'espresso-registration-footer-dv', |
1418 | - array( 'utm_content' => 'registration_checkout' ) |
|
1418 | + array('utm_content' => 'registration_checkout') |
|
1419 | 1419 | ) |
1420 | 1420 | ); |
1421 | 1421 | } |
@@ -1432,7 +1432,7 @@ discard block |
||
1432 | 1432 | * @throws \EE_Error |
1433 | 1433 | */ |
1434 | 1434 | public function unlock_transaction() { |
1435 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
1435 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1436 | 1436 | $this->checkout->transaction->unlock(); |
1437 | 1437 | } |
1438 | 1438 | } |
@@ -1447,12 +1447,12 @@ discard block |
||
1447 | 1447 | * @return array |
1448 | 1448 | */ |
1449 | 1449 | private function _setup_redirect() { |
1450 | - if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
1450 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1451 | 1451 | $this->checkout->redirect = TRUE; |
1452 | - if ( empty( $this->checkout->redirect_url )) { |
|
1452 | + if (empty($this->checkout->redirect_url)) { |
|
1453 | 1453 | $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
1454 | 1454 | } |
1455 | - $this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout ); |
|
1455 | + $this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout); |
|
1456 | 1456 | } |
1457 | 1457 | } |
1458 | 1458 | |
@@ -1466,9 +1466,9 @@ discard block |
||
1466 | 1466 | * @throws \EE_Error |
1467 | 1467 | */ |
1468 | 1468 | public function go_to_next_step() { |
1469 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1469 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1470 | 1470 | // capture contents of output buffer we started earlier in the request, and insert into JSON response |
1471 | - $this->checkout->json_response->set_unexpected_errors( ob_get_clean() ); |
|
1471 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1472 | 1472 | } |
1473 | 1473 | $this->unlock_transaction(); |
1474 | 1474 | // just return for these conditions |
@@ -1497,7 +1497,7 @@ discard block |
||
1497 | 1497 | */ |
1498 | 1498 | protected function _handle_json_response() { |
1499 | 1499 | // if this is an ajax request |
1500 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1500 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1501 | 1501 | // DEBUG LOG |
1502 | 1502 | //$this->checkout->log( |
1503 | 1503 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1510,7 +1510,7 @@ discard block |
||
1510 | 1510 | $this->checkout->json_response->set_registration_time_limit( |
1511 | 1511 | $this->checkout->get_registration_time_limit() |
1512 | 1512 | ); |
1513 | - $this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing ); |
|
1513 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1514 | 1514 | // just send the ajax ( |
1515 | 1515 | $json_response = apply_filters( |
1516 | 1516 | 'FHEE__EE_Single_Page_Checkout__JSON_response', |
@@ -1531,9 +1531,9 @@ discard block |
||
1531 | 1531 | */ |
1532 | 1532 | protected function _handle_html_redirects() { |
1533 | 1533 | // going somewhere ? |
1534 | - if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) { |
|
1534 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1535 | 1535 | // store notices in a transient |
1536 | - EE_Error::get_notices( false, true, true ); |
|
1536 | + EE_Error::get_notices(false, true, true); |
|
1537 | 1537 | // DEBUG LOG |
1538 | 1538 | //$this->checkout->log( |
1539 | 1539 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | // 'headers_list' => headers_list(), |
1544 | 1544 | // ) |
1545 | 1545 | //); |
1546 | - wp_safe_redirect( $this->checkout->redirect_url ); |
|
1546 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1547 | 1547 | exit(); |
1548 | 1548 | } |
1549 | 1549 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('ABSPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @link {@link http://www.eventespresso.com} |
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | -if ( function_exists( 'espresso_version' ) ) { |
|
42 | +if (function_exists('espresso_version')) { |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * espresso_duplicate_plugin_error |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | 60 | } |
61 | - add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 ); |
|
61 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | 62 | |
63 | 63 | } else { |
64 | 64 | |
65 | - define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' ); |
|
65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.0'); |
|
66 | 66 | |
67 | - if ( ! version_compare( PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=' ) ) { |
|
67 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * espresso_minimum_php_version_error |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | </p> |
91 | 91 | </div> |
92 | 92 | <?php |
93 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
93 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
94 | 94 | } |
95 | - add_action( 'admin_notices', 'espresso_minimum_php_version_error', 1 ); |
|
95 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
96 | 96 | |
97 | 97 | } else { |
98 | 98 | |
@@ -103,99 +103,99 @@ discard block |
||
103 | 103 | * @return string |
104 | 104 | */ |
105 | 105 | function espresso_version() { |
106 | - return apply_filters( 'FHEE__espresso__espresso_version', '4.9.18.rc.006' ); |
|
106 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.18.rc.006'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // define versions |
110 | - define( 'EVENT_ESPRESSO_VERSION', espresso_version() ); |
|
111 | - define( 'EE_MIN_WP_VER_REQUIRED', '4.1' ); |
|
112 | - define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' ); |
|
113 | - define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' ); |
|
114 | - define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ ); |
|
110 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
111 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
112 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
113 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
114 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
115 | 115 | |
116 | 116 | //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
117 | - if ( ! defined( 'DS' ) ) { |
|
118 | - define( 'DS', '/' ); |
|
117 | + if ( ! defined('DS')) { |
|
118 | + define('DS', '/'); |
|
119 | 119 | } |
120 | - if ( ! defined( 'PS' ) ) { |
|
121 | - define( 'PS', PATH_SEPARATOR ); |
|
120 | + if ( ! defined('PS')) { |
|
121 | + define('PS', PATH_SEPARATOR); |
|
122 | 122 | } |
123 | - if ( ! defined( 'SP' ) ) { |
|
124 | - define( 'SP', ' ' ); |
|
123 | + if ( ! defined('SP')) { |
|
124 | + define('SP', ' '); |
|
125 | 125 | } |
126 | - if ( ! defined( 'EENL' ) ) { |
|
127 | - define( 'EENL', "\n" ); |
|
126 | + if ( ! defined('EENL')) { |
|
127 | + define('EENL', "\n"); |
|
128 | 128 | } |
129 | - define( 'EE_SUPPORT_EMAIL', '[email protected]' ); |
|
129 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
130 | 130 | // define the plugin directory and URL |
131 | - define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
132 | - define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
133 | - define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
131 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
132 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
133 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
134 | 134 | // main root folder paths |
135 | - define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS ); |
|
136 | - define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS ); |
|
137 | - define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS ); |
|
138 | - define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS ); |
|
139 | - define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS ); |
|
140 | - define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS ); |
|
141 | - define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS ); |
|
142 | - define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS ); |
|
135 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
136 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
137 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
138 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
139 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
140 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
141 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
142 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
143 | 143 | // core system paths |
144 | - define( 'EE_ADMIN', EE_CORE . 'admin' . DS ); |
|
145 | - define( 'EE_CPTS', EE_CORE . 'CPTs' . DS ); |
|
146 | - define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS ); |
|
147 | - define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS ); |
|
148 | - define( 'EE_BUSINESS', EE_CORE . 'business' . DS ); |
|
149 | - define( 'EE_MODELS', EE_CORE . 'db_models' . DS ); |
|
150 | - define( 'EE_HELPERS', EE_CORE . 'helpers' . DS ); |
|
151 | - define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS ); |
|
152 | - define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS ); |
|
153 | - define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS ); |
|
154 | - define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS ); |
|
155 | - define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS ); |
|
144 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
145 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
146 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
147 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
148 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
149 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
150 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
151 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
152 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
153 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
154 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
155 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
156 | 156 | // gateways |
157 | - define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS ); |
|
158 | - define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS ); |
|
157 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
158 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
159 | 159 | // asset URL paths |
160 | - define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS ); |
|
161 | - define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS ); |
|
162 | - define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS ); |
|
163 | - define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS ); |
|
164 | - define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' ); |
|
165 | - define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' ); |
|
160 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
161 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
162 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
163 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
164 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
165 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
166 | 166 | // define upload paths |
167 | 167 | $uploads = wp_upload_dir(); |
168 | 168 | // define the uploads directory and URL |
169 | - define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS ); |
|
170 | - define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS ); |
|
169 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
170 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
171 | 171 | // define the templates directory and URL |
172 | - define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS ); |
|
173 | - define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS ); |
|
172 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
173 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
174 | 174 | // define the gateway directory and URL |
175 | - define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
176 | - define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
175 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
176 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
177 | 177 | // languages folder/path |
178 | - define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS ); |
|
179 | - define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS ); |
|
178 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
179 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
180 | 180 | //check for dompdf fonts in uploads |
181 | - if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) { |
|
182 | - define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ); |
|
181 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
182 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
183 | 183 | } |
184 | 184 | //ajax constants |
185 | 185 | define( |
186 | 186 | 'EE_FRONT_AJAX', |
187 | - isset( $_REQUEST['ee_front_ajax'] ) || isset( $_REQUEST['data']['ee_front_ajax'] ) ? true : false |
|
187 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
188 | 188 | ); |
189 | 189 | define( |
190 | 190 | 'EE_ADMIN_AJAX', |
191 | - isset( $_REQUEST['ee_admin_ajax'] ) || isset( $_REQUEST['data']['ee_admin_ajax'] ) ? true : false |
|
191 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
192 | 192 | ); |
193 | 193 | //just a handy constant occasionally needed for finding values representing infinity in the DB |
194 | 194 | //you're better to use this than its straight value (currently -1) in case you ever |
195 | 195 | //want to change its default value! or find when -1 means infinity |
196 | - define( 'EE_INF_IN_DB', -1 ); |
|
197 | - define( 'EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX ); |
|
198 | - define( 'EE_DEBUG', false ); |
|
196 | + define('EE_INF_IN_DB', -1); |
|
197 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
198 | + define('EE_DEBUG', false); |
|
199 | 199 | |
200 | 200 | |
201 | 201 | /** |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
204 | 204 | */ |
205 | 205 | function espresso_plugin_activation() { |
206 | - update_option( 'ee_espresso_activation', true ); |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | 207 | } |
208 | - register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' ); |
|
208 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
209 | 209 | |
210 | 210 | |
211 | 211 | |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | */ |
216 | 216 | function espresso_load_error_handling() { |
217 | 217 | // load debugging tools |
218 | - if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) { |
|
219 | - require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ); |
|
218 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
219 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
220 | 220 | EEH_Debug_Tools::instance(); |
221 | 221 | } |
222 | 222 | // load error handling |
223 | - if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) { |
|
224 | - require_once( EE_CORE . 'EE_Error.core.php' ); |
|
223 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
224 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
225 | 225 | } else { |
226 | - wp_die( esc_html__( 'The EE_Error core class could not be loaded.', 'event_espresso' ) ); |
|
226 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
@@ -237,16 +237,16 @@ discard block |
||
237 | 237 | * @param string $full_path_to_file |
238 | 238 | * @throws EE_Error |
239 | 239 | */ |
240 | - function espresso_load_required( $classname, $full_path_to_file ) { |
|
240 | + function espresso_load_required($classname, $full_path_to_file) { |
|
241 | 241 | static $error_handling_loaded = false; |
242 | - if ( ! $error_handling_loaded ) { |
|
242 | + if ( ! $error_handling_loaded) { |
|
243 | 243 | espresso_load_error_handling(); |
244 | 244 | $error_handling_loaded = true; |
245 | 245 | } |
246 | - if ( is_readable( $full_path_to_file ) ) { |
|
247 | - require_once( $full_path_to_file ); |
|
246 | + if (is_readable($full_path_to_file)) { |
|
247 | + require_once($full_path_to_file); |
|
248 | 248 | } else { |
249 | - throw new EE_Error ( |
|
249 | + throw new EE_Error( |
|
250 | 250 | sprintf( |
251 | 251 | esc_html__( |
252 | 252 | 'The %s class file could not be located or is not readable due to file permissions.', |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' ); |
|
262 | - espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' ); |
|
263 | - espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' ); |
|
261 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
262 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
263 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
264 | 264 | new EE_Bootstrap(); |
265 | 265 | |
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | -if ( ! function_exists( 'espresso_deactivate_plugin' ) ) { |
|
269 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * deactivate_plugin |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
277 | 277 | * @return void |
278 | 278 | */ |
279 | - function espresso_deactivate_plugin( $plugin_basename = '' ) { |
|
280 | - if ( ! function_exists( 'deactivate_plugins' ) ) { |
|
281 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
279 | + function espresso_deactivate_plugin($plugin_basename = '') { |
|
280 | + if ( ! function_exists('deactivate_plugins')) { |
|
281 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
282 | 282 | } |
283 | - unset( $_GET['activate'], $_REQUEST['activate'] ); |
|
284 | - deactivate_plugins( $plugin_basename ); |
|
283 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
284 | + deactivate_plugins($plugin_basename); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | } |