@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Line_Item_Filter_Collection |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -717,8 +718,9 @@ discard block |
||
717 | 718 | $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type ); |
718 | 719 | |
719 | 720 | //check file exists and is readable |
720 | - if ( !is_readable( $wrapper_template ) ) |
|
721 | - throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
721 | + if ( !is_readable( $wrapper_template ) ) { |
|
722 | + throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
723 | + } |
|
722 | 724 | |
723 | 725 | //require template helper |
724 | 726 | EE_Registry::instance()->load_helper( 'Template' ); |
@@ -788,20 +790,24 @@ discard block |
||
788 | 790 | */ |
789 | 791 | public function get_field_label( $field ) { |
790 | 792 | //first let's see if the field requests is in the top level array. |
791 | - if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) |
|
792 | - return $this->_template[$field]['label']; |
|
793 | + if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) { |
|
794 | + return $this->_template[$field]['label']; |
|
795 | + } |
|
793 | 796 | |
794 | 797 | //nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index. |
795 | - if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) |
|
796 | - return $this->_template_fields['extra'][$field]['main']['label']; |
|
798 | + if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) { |
|
799 | + return $this->_template_fields['extra'][$field]['main']['label']; |
|
800 | + } |
|
797 | 801 | |
798 | 802 | //now it's possible this field may just be existing in any of the extra array items. |
799 | 803 | if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) { |
800 | 804 | foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) { |
801 | - if ( !is_array( $subfields ) ) |
|
802 | - continue; |
|
803 | - if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) |
|
804 | - return $subfields[$field]['label']; |
|
805 | + if ( !is_array( $subfields ) ) { |
|
806 | + continue; |
|
807 | + } |
|
808 | + if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) { |
|
809 | + return $subfields[$field]['label']; |
|
810 | + } |
|
805 | 811 | } |
806 | 812 | } |
807 | 813 |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | /** |
504 | 504 | * @param $message_types |
505 | 505 | * @param array $extra |
506 | - * @return mixed|string |
|
506 | + * @return string |
|
507 | 507 | */ |
508 | 508 | protected function _get_admin_content_events_edit( $message_types, $extra ) { |
509 | 509 | //defaults |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | * All this does is set the existing test settings (in the db) for the messenger |
772 | 772 | * |
773 | 773 | * @access public |
774 | - * @param $settings |
|
774 | + * @param string $settings |
|
775 | 775 | * @return bool success/fail |
776 | 776 | */ |
777 | 777 | public function set_existing_test_settings( $settings ) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @return void |
290 | 290 | */ |
291 | 291 | public function enqueue_scripts_styles() { |
292 | - do_action( 'AHEE__EE_messenger__enqueue_scripts_styles'); |
|
292 | + do_action('AHEE__EE_messenger__enqueue_scripts_styles'); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | $this->_supports_labels->template_variation_description = __('These are different styles to choose from for the selected template structure. Usually these affect things like font style, color, borders etc. In some cases the styles will also make minor layout changes.'); |
361 | 361 | |
362 | - $this->_supports_labels = apply_filters( 'FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this ); |
|
362 | + $this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | * @return stdClass |
375 | 375 | */ |
376 | 376 | public function get_supports_labels() { |
377 | - if ( empty( $this->_supports_labels->template_pack ) || empty( $this->_supports_labels->template_variation) ) { |
|
377 | + if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) { |
|
378 | 378 | $this->_set_supports_labels_defaults(); |
379 | 379 | } |
380 | - return apply_filters( 'FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this ); |
|
380 | + return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | * |
398 | 398 | * @return string path or url for the requested variation. |
399 | 399 | */ |
400 | - public function get_variation( EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE ) { |
|
400 | + public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE) { |
|
401 | 401 | $this->_tmp_pack = $pack; |
402 | - $variation_path = apply_filters( 'EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters ); |
|
403 | - $variation_path = empty( $variation_path ) ? $this->_tmp_pack->get_variation( $this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters ) : $variation_path; |
|
402 | + $variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters); |
|
403 | + $variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path; |
|
404 | 404 | return $variation_path; |
405 | 405 | |
406 | 406 | } |
@@ -418,13 +418,13 @@ discard block |
||
418 | 418 | * @return array |
419 | 419 | */ |
420 | 420 | public function get_default_message_types() { |
421 | - $class = get_class( $this ); |
|
421 | + $class = get_class($this); |
|
422 | 422 | |
423 | 423 | //messenger specific filter |
424 | - $default_types = apply_filters( 'FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this ); |
|
424 | + $default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this); |
|
425 | 425 | |
426 | 426 | //all messengers filter |
427 | - $default_types = apply_filters( 'FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this ); |
|
427 | + $default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this); |
|
428 | 428 | return $default_types; |
429 | 429 | } |
430 | 430 | |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | * @return array |
440 | 440 | */ |
441 | 441 | public function get_valid_message_types() { |
442 | - $class = get_class( $this ); |
|
442 | + $class = get_class($this); |
|
443 | 443 | |
444 | 444 | //messenger specific filter |
445 | 445 | //messenger specific filter |
446 | - $valid_types = apply_filters( 'FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this ); |
|
446 | + $valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this); |
|
447 | 447 | |
448 | 448 | //all messengers filter |
449 | - $valid_types = apply_filters( 'FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this ); |
|
449 | + $valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this); |
|
450 | 450 | return $valid_types; |
451 | 451 | } |
452 | 452 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @access public |
461 | 461 | * @param array $new_config Whatever is put in here will reset the _validator_config property |
462 | 462 | */ |
463 | - public function set_validator_config( $new_config ) { |
|
463 | + public function set_validator_config($new_config) { |
|
464 | 464 | $this->_validator_config = $new_config; |
465 | 465 | } |
466 | 466 | |
@@ -476,8 +476,8 @@ discard block |
||
476 | 476 | public function get_validator_config() { |
477 | 477 | $class = get_class($this); |
478 | 478 | |
479 | - $config = apply_filters( 'FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this ); |
|
480 | - $config = apply_filters( 'FHEE__EE_messenger__get_validator_config', $config, $this ); |
|
479 | + $config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this); |
|
480 | + $config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this); |
|
481 | 481 | return $config; |
482 | 482 | } |
483 | 483 | |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | * @access public |
495 | 495 | * @return string content for page |
496 | 496 | */ |
497 | - public function get_messenger_admin_page_content( $page, $action = null, $extra = array(), $message_types = array() ) { |
|
498 | - return $this->_get_admin_page_content( $page, $action, $extra, $message_types ); |
|
497 | + public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array()) { |
|
498 | + return $this->_get_admin_page_content($page, $action, $extra, $message_types); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -505,20 +505,20 @@ discard block |
||
505 | 505 | * @param array $extra |
506 | 506 | * @return mixed|string |
507 | 507 | */ |
508 | - protected function _get_admin_content_events_edit( $message_types, $extra ) { |
|
508 | + protected function _get_admin_content_events_edit($message_types, $extra) { |
|
509 | 509 | //defaults |
510 | 510 | $template_args = array(); |
511 | 511 | $selector_rows = ''; |
512 | 512 | |
513 | 513 | //we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event. |
514 | - $event_id = isset( $extra['event'] ) ? $extra['event'] : NULL; |
|
514 | + $event_id = isset($extra['event']) ? $extra['event'] : NULL; |
|
515 | 515 | |
516 | - $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
517 | - $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
516 | + $template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
517 | + $template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
518 | 518 | |
519 | 519 | //array of template objects for global and custom (non-trashed) (but remember just for this messenger!) |
520 | 520 | $global_templates = EEM_Message_Template_Group::instance()->get_all( |
521 | - array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) ) |
|
521 | + array(array('MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true)) |
|
522 | 522 | ); |
523 | 523 | $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event( |
524 | 524 | $event_id, |
@@ -527,55 +527,55 @@ discard block |
||
527 | 527 | 'MTP_is_active' => true |
528 | 528 | ) |
529 | 529 | ); |
530 | - $templates_for_event = !empty( $templates_for_event ) ? $templates_for_event : array(); |
|
530 | + $templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array(); |
|
531 | 531 | |
532 | 532 | //so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups) |
533 | - foreach ( $global_templates as $mtpgID => $mtpg ) { |
|
534 | - if ( $mtpg instanceof EE_Message_Template_Group ) { |
|
533 | + foreach ($global_templates as $mtpgID => $mtpg) { |
|
534 | + if ($mtpg instanceof EE_Message_Template_Group) { |
|
535 | 535 | //verify this message type is supposed to show on this page |
536 | 536 | $mtp_obj = $mtpg->message_type_obj(); |
537 | - if ( ! $mtp_obj instanceof EE_message_type ) { |
|
537 | + if ( ! $mtp_obj instanceof EE_message_type) { |
|
538 | 538 | continue; |
539 | 539 | } |
540 | - $mtp_obj->admin_registered_pages = (array)$mtp_obj->admin_registered_pages; |
|
541 | - if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) { |
|
540 | + $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages; |
|
541 | + if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) { |
|
542 | 542 | continue; |
543 | 543 | } |
544 | 544 | $select_values = array(); |
545 | - $select_values[ $mtpgID ] = __( 'Global', 'event_espresso' ); |
|
546 | - $default_value = array_key_exists( $mtpgID, $templates_for_event ) && ! $mtpg->get( 'MTP_is_override' ) ? $mtpgID : null; |
|
545 | + $select_values[$mtpgID] = __('Global', 'event_espresso'); |
|
546 | + $default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null; |
|
547 | 547 | //if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override. |
548 | - if ( ! $mtpg->get( 'MTP_is_override' ) ) { |
|
548 | + if ( ! $mtpg->get('MTP_is_override')) { |
|
549 | 549 | //any custom templates for this message type? |
550 | - $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt( $this->name, $mtpg->message_type() ); |
|
551 | - foreach ( $custom_templates as $cmtpgID => $cmtpg ) { |
|
552 | - $select_values[ $cmtpgID ] = $cmtpg->name(); |
|
553 | - $default_value = array_key_exists( $cmtpgID, $templates_for_event ) ? $cmtpgID : $default_value; |
|
550 | + $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type()); |
|
551 | + foreach ($custom_templates as $cmtpgID => $cmtpg) { |
|
552 | + $select_values[$cmtpgID] = $cmtpg->name(); |
|
553 | + $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value; |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | //if there is no $default_value then we set it as the global |
557 | - $default_value = empty( $default_value ) ? $mtpgID : $default_value; |
|
558 | - $edit_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value ), admin_url( 'admin.php' ) ); |
|
559 | - $create_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value ), admin_url( 'admin.php' ) ); |
|
560 | - $st_args[ 'mt_name' ] = ucwords( $mtp_obj->label[ 'singular' ] ); |
|
561 | - $st_args[ 'mt_slug' ] = $mtpg->message_type(); |
|
562 | - $st_args[ 'messenger_slug' ] = $this->name; |
|
563 | - $st_args[ 'selector' ] = EEH_Form_Fields::select_input( 'event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector' ); |
|
557 | + $default_value = empty($default_value) ? $mtpgID : $default_value; |
|
558 | + $edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php')); |
|
559 | + $create_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value), admin_url('admin.php')); |
|
560 | + $st_args['mt_name'] = ucwords($mtp_obj->label['singular']); |
|
561 | + $st_args['mt_slug'] = $mtpg->message_type(); |
|
562 | + $st_args['messenger_slug'] = $this->name; |
|
563 | + $st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation['.$mtpgID.']', $select_values, $default_value, 'data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'"', 'message-template-selector'); |
|
564 | 564 | //note that message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates). |
565 | - $st_args[ 'create_button' ] = $mtpg->get( 'MTP_is_override' ) ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . __( 'Create New Custom', 'event_espresso' ) . '</a>'; |
|
566 | - $st_args[ 'create_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ? $st_args[ 'create_button' ] : ''; |
|
567 | - $st_args[ 'edit_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID ) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . __( 'Edit', 'event_espresso' ) . '</a>' : ''; |
|
568 | - $selector_rows .= EEH_Template::display_template( $template_row_path, $st_args, true ); |
|
565 | + $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$create_url.'" class="button button-small create-mtpg-button">'.__('Create New Custom', 'event_espresso').'</a>'; |
|
566 | + $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template') ? $st_args['create_button'] : ''; |
|
567 | + $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$edit_url.'" class="button button-small edit-mtpg-button">'.__('Edit', 'event_espresso').'</a>' : ''; |
|
568 | + $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true); |
|
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
572 | 572 | //if no selectors present then get out. |
573 | - if ( empty( $selector_rows ) ) { |
|
573 | + if (empty($selector_rows)) { |
|
574 | 574 | return ''; |
575 | 575 | } |
576 | 576 | |
577 | 577 | $template_args['selector_rows'] = $selector_rows; |
578 | - return EEH_Template::display_template( $template_wrapper_path, $template_args, TRUE ); |
|
578 | + return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | * @return array $this->_template_fields |
591 | 591 | */ |
592 | 592 | public function get_template_fields() { |
593 | - $template_fields = apply_filters( 'FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this ); |
|
594 | - $template_fields = apply_filters( 'FHEE__EE_messenger__get_template_fields', $template_fields, $this ); |
|
593 | + $template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this); |
|
594 | + $template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this); |
|
595 | 595 | return $template_fields; |
596 | 596 | } |
597 | 597 | |
@@ -605,9 +605,9 @@ discard block |
||
605 | 605 | * @param mixed $value |
606 | 606 | */ |
607 | 607 | protected function _set_template_value($item, $value) { |
608 | - if ( array_key_exists($item, $this->_template_fields) ) { |
|
609 | - $prop = '_' . $item; |
|
610 | - $this->{$prop}= $value; |
|
608 | + if (array_key_exists($item, $this->_template_fields)) { |
|
609 | + $prop = '_'.$item; |
|
610 | + $this->{$prop} = $value; |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | |
@@ -618,8 +618,8 @@ discard block |
||
618 | 618 | * @return bool Very important that all messengers return bool for successful send or not. Error messages can be |
619 | 619 | * added to EE_Error. |
620 | 620 | */ |
621 | - public function send_message( $message, EE_message_type $message_type ) { |
|
622 | - $this->_validate_and_setup( $message ); |
|
621 | + public function send_message($message, EE_message_type $message_type) { |
|
622 | + $this->_validate_and_setup($message); |
|
623 | 623 | $this->_incoming_message_type = $message_type; |
624 | 624 | return $this->_send_message(); |
625 | 625 | } |
@@ -633,28 +633,28 @@ discard block |
||
633 | 633 | * @param bool $send true we will actually use the _send method (for test sends). FALSE we just return preview |
634 | 634 | * @return string return the message html content |
635 | 635 | */ |
636 | - public function get_preview( EE_Message $message, EE_message_type $message_type, $send = false ) { |
|
637 | - $this->_validate_and_setup( $message ); |
|
636 | + public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false) { |
|
637 | + $this->_validate_and_setup($message); |
|
638 | 638 | |
639 | 639 | $this->_incoming_message_type = $message_type; |
640 | 640 | |
641 | - if ( $send ) { |
|
641 | + if ($send) { |
|
642 | 642 | //are we overriding any existing template fields? |
643 | 643 | $settings = $this->get_existing_test_settings(); |
644 | - if ( ! empty( $settings ) ) { |
|
645 | - foreach ( $settings as $field => $value ) { |
|
646 | - $this->_set_template_value( $field, $value ); |
|
644 | + if ( ! empty($settings)) { |
|
645 | + foreach ($settings as $field => $value) { |
|
646 | + $this->_set_template_value($field, $value); |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
651 | 651 | //enqueue preview js so that any links/buttons on the page are disabled. |
652 | - if ( ! $send ) { |
|
652 | + if ( ! $send) { |
|
653 | 653 | // the below may seem like duplication. However, typically if a messenger enqueues scripts/styles, |
654 | 654 | // it deregisters all existing wp scripts and styles first. So the second hook ensures our previewer still gets setup. |
655 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
656 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
657 | - add_action( 'AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10 ); |
|
655 | + add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
656 | + add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
657 | + add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | return $send ? $this->_send_message() : $this->_preview(); |
@@ -672,10 +672,10 @@ discard block |
||
672 | 672 | */ |
673 | 673 | public function add_preview_script() { |
674 | 674 | //error message |
675 | - EE_Registry::$i18n_js_strings[ 'links_disabled' ] = __( 'All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso' ); |
|
676 | - wp_register_script( 'ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true ); |
|
677 | - wp_localize_script( 'ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
678 | - wp_enqueue_script( 'ee-messages-preview-js' ); |
|
675 | + EE_Registry::$i18n_js_strings['links_disabled'] = __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso'); |
|
676 | + wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
677 | + wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings); |
|
678 | + wp_enqueue_script('ee-messages-preview-js'); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | |
@@ -686,13 +686,13 @@ discard block |
||
686 | 686 | * @param EE_Message $message |
687 | 687 | * @throws EE_Error |
688 | 688 | */ |
689 | - protected function _validate_and_setup( EE_Message $message ) { |
|
689 | + protected function _validate_and_setup(EE_Message $message) { |
|
690 | 690 | $template_pack = $message->get_template_pack(); |
691 | 691 | $variation = $message->get_template_pack_variation(); |
692 | 692 | |
693 | 693 | //verify we have the required template pack value on the $message object. |
694 | - if ( ! $template_pack instanceof EE_Messages_Template_Pack ) { |
|
695 | - throw new EE_Error( __('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso' ) ); |
|
694 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack) { |
|
695 | + throw new EE_Error(__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso')); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | $this->_tmp_pack = $template_pack; |
@@ -701,11 +701,11 @@ discard block |
||
701 | 701 | |
702 | 702 | $template_fields = $this->get_template_fields(); |
703 | 703 | |
704 | - foreach ( $template_fields as $template => $value ) { |
|
705 | - if ( $template !== 'extra' ) { |
|
706 | - $column_value = $message->get_field_or_extra_meta( 'MSG_' . $template ); |
|
704 | + foreach ($template_fields as $template => $value) { |
|
705 | + if ($template !== 'extra') { |
|
706 | + $column_value = $message->get_field_or_extra_meta('MSG_'.$template); |
|
707 | 707 | $message_template_value = $column_value ? $column_value : null; |
708 | - $this->_set_template_value( $template, $message_template_value ); |
|
708 | + $this->_set_template_value($template, $message_template_value); |
|
709 | 709 | } |
710 | 710 | } |
711 | 711 | } |
@@ -720,19 +720,19 @@ discard block |
||
720 | 720 | * @return string |
721 | 721 | * @throws \EE_Error |
722 | 722 | */ |
723 | - protected function _get_main_template( $preview = FALSE ) { |
|
723 | + protected function _get_main_template($preview = FALSE) { |
|
724 | 724 | $type = $preview ? 'preview' : 'main'; |
725 | 725 | |
726 | - $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type ); |
|
726 | + $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type); |
|
727 | 727 | |
728 | 728 | //check file exists and is readable |
729 | - if ( !is_readable( $wrapper_template ) ) |
|
730 | - throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
729 | + if ( ! is_readable($wrapper_template)) |
|
730 | + throw new EE_Error(sprintf(__('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template)); |
|
731 | 731 | |
732 | 732 | //add message type to template args |
733 | 733 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
734 | 734 | |
735 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE ); |
|
735 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | |
@@ -768,9 +768,9 @@ discard block |
||
768 | 768 | */ |
769 | 769 | public function get_existing_test_settings() { |
770 | 770 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
771 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
771 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
772 | 772 | $settings = $Message_Resource_Manager->get_active_messengers_option(); |
773 | - return isset( $settings[ $this->name ]['test_settings'] ) ? $settings[ $this->name ]['test_settings'] : array(); |
|
773 | + return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array(); |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | |
@@ -782,12 +782,12 @@ discard block |
||
782 | 782 | * @param $settings |
783 | 783 | * @return bool success/fail |
784 | 784 | */ |
785 | - public function set_existing_test_settings( $settings ) { |
|
785 | + public function set_existing_test_settings($settings) { |
|
786 | 786 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
787 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
787 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
788 | 788 | $existing = $Message_Resource_Manager->get_active_messengers_option(); |
789 | - $existing[ $this->name ]['test_settings'] = $settings; |
|
790 | - return $Message_Resource_Manager->update_active_messengers_option( $existing ); |
|
789 | + $existing[$this->name]['test_settings'] = $settings; |
|
790 | + return $Message_Resource_Manager->update_active_messengers_option($existing); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | |
@@ -800,21 +800,21 @@ discard block |
||
800 | 800 | * @param string $field The field to retrieve the label for |
801 | 801 | * @return string The label |
802 | 802 | */ |
803 | - public function get_field_label( $field ) { |
|
803 | + public function get_field_label($field) { |
|
804 | 804 | //first let's see if the field requests is in the top level array. |
805 | - if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) |
|
805 | + if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label'])) |
|
806 | 806 | return $this->_template[$field]['label']; |
807 | 807 | |
808 | 808 | //nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index. |
809 | - if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) |
|
809 | + if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label'])) |
|
810 | 810 | return $this->_template_fields['extra'][$field]['main']['label']; |
811 | 811 | |
812 | 812 | //now it's possible this field may just be existing in any of the extra array items. |
813 | - if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) { |
|
814 | - foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) { |
|
815 | - if ( !is_array( $subfields ) ) |
|
813 | + if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) { |
|
814 | + foreach ($this->_template_fields['extra'] as $main_field => $subfields) { |
|
815 | + if ( ! is_array($subfields)) |
|
816 | 816 | continue; |
817 | - if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) |
|
817 | + if (isset($subfields[$field]) && ! empty($subfields[$field]['label'])) |
|
818 | 818 | return $subfields[$field]['label']; |
819 | 819 | } |
820 | 820 | } |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * |
836 | 836 | * @return void |
837 | 837 | */ |
838 | - public function do_secondary_messenger_hooks( $sending_messenger_name ) { |
|
838 | + public function do_secondary_messenger_hooks($sending_messenger_name) { |
|
839 | 839 | return; |
840 | 840 | } |
841 | 841 |
@@ -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 | /** |
@@ -43,25 +43,25 @@ discard block |
||
43 | 43 | * @param array $data |
44 | 44 | * @throws \EE_Error |
45 | 45 | */ |
46 | - public function __construct( $data ) { |
|
46 | + public function __construct($data) { |
|
47 | 47 | |
48 | 48 | //test for valid params |
49 | - if ( ! ( $data[0] instanceof EE_Transaction )) |
|
50 | - throw new EE_Error( __('Incoming data for the Gateways data handler must have an EE_Transaction object as the value for the first array index.', 'event_espresso') ); |
|
49 | + if ( ! ($data[0] instanceof EE_Transaction)) |
|
50 | + throw new EE_Error(__('Incoming data for the Gateways data handler must have an EE_Transaction object as the value for the first array index.', 'event_espresso')); |
|
51 | 51 | |
52 | - if ( empty( $data[1] ) || ! $data[1] instanceof EE_Payment ) |
|
53 | - $pmt_obj = $this->_get_empty_payment_obj( $data[0] ); |
|
52 | + if (empty($data[1]) || ! $data[1] instanceof EE_Payment) |
|
53 | + $pmt_obj = $this->_get_empty_payment_obj($data[0]); |
|
54 | 54 | |
55 | - if ( ! empty( $data[2] ) ) { |
|
55 | + if ( ! empty($data[2])) { |
|
56 | 56 | $filtered_reg_status = $data[2]; |
57 | 57 | } |
58 | 58 | |
59 | 59 | $data = array( |
60 | 60 | 'txn_obj' => $data[0], |
61 | 61 | 'pmt_obj' => isset($pmt_obj) ? $pmt_obj : $data[1], |
62 | - 'filtered_reg_status' => isset( $filtered_reg_status ) ? $filtered_reg_status : null |
|
62 | + 'filtered_reg_status' => isset($filtered_reg_status) ? $filtered_reg_status : null |
|
63 | 63 | ); |
64 | - parent::__construct( $data ); |
|
64 | + parent::__construct($data); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return array The prepped data for db |
77 | 77 | */ |
78 | - static public function convert_data_for_persistent_storage( $data ) { |
|
78 | + static public function convert_data_for_persistent_storage($data) { |
|
79 | 79 | $prepped_data = array(); |
80 | 80 | |
81 | - if ( $data[0] instanceof EE_Transaction ) { |
|
81 | + if ($data[0] instanceof EE_Transaction) { |
|
82 | 82 | $prepped_data['Transaction'] = $data[0]->ID(); |
83 | 83 | } |
84 | 84 | |
85 | - if ( isset( $data[1] ) && $data[1] instanceof EE_Payment ) { |
|
85 | + if (isset($data[1]) && $data[1] instanceof EE_Payment) { |
|
86 | 86 | $prepped_data['Payment'] = $data[1]->ID(); |
87 | 87 | } |
88 | 88 | |
89 | - if ( ! empty( $data[2] ) ) { |
|
89 | + if ( ! empty($data[2])) { |
|
90 | 90 | $prepped_data['filter'] = $data[2]; |
91 | 91 | } |
92 | 92 | |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return array |
108 | 108 | */ |
109 | - static public function convert_data_from_persistent_storage( $data ) { |
|
109 | + static public function convert_data_from_persistent_storage($data) { |
|
110 | 110 | $prepped_data = array( |
111 | - 0 => isset( $data['Transaction'] ) ? EEM_Transaction::instance()->get_one_by_ID( $data['Transaction'] ) : null, |
|
112 | - 1 => isset( $data['Payment'] ) ? EEM_Payment::instance()->get_one_by_ID( $data['Payment'] ) : null, |
|
113 | - 2 => isset( $data['filter'] ) ? $data['filter'] : null |
|
111 | + 0 => isset($data['Transaction']) ? EEM_Transaction::instance()->get_one_by_ID($data['Transaction']) : null, |
|
112 | + 1 => isset($data['Payment']) ? EEM_Payment::instance()->get_one_by_ID($data['Payment']) : null, |
|
113 | + 2 => isset($data['filter']) ? $data['filter'] : null |
|
114 | 114 | ); |
115 | 115 | return $prepped_data; |
116 | 116 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param \EE_Transaction $txn |
122 | 122 | * @return \EE_Payment |
123 | 123 | */ |
124 | - private function _get_empty_payment_obj( EE_Transaction $txn ) { |
|
125 | - $PMT = EE_Payment::new_instance( array( |
|
124 | + private function _get_empty_payment_obj(EE_Transaction $txn) { |
|
125 | + $PMT = EE_Payment::new_instance(array( |
|
126 | 126 | 'STS_ID' => EEM_Payment::status_id_pending, |
127 | 127 | 'PAY_timestamp' => time(), |
128 | 128 | 'PMD_ID' => $txn->payment_method_ID(), |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | |
151 | 151 | |
152 | 152 | //other data from the session (if possible) |
153 | - $this->user_id = isset( $session_data['user_id'] ) ? $session_data['user_id'] : ''; |
|
154 | - $this->ip_address = isset( $session_data['ip_address'] ) ? $session_data['ip_address'] : ''; |
|
155 | - $this->user_agent = isset( $session_data['user_agent'] ) ? $session_data['user_agent'] : ''; |
|
153 | + $this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : ''; |
|
154 | + $this->ip_address = isset($session_data['ip_address']) ? $session_data['ip_address'] : ''; |
|
155 | + $this->user_agent = isset($session_data['user_agent']) ? $session_data['user_agent'] : ''; |
|
156 | 156 | $this->init_access = $this->last_access = ''; |
157 | 157 | |
158 | 158 | $this->reg_objs = $this->txn->get_many_related('Registration'); |
@@ -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 | /** |
@@ -50,31 +50,31 @@ discard block |
||
50 | 50 | '[RECIPIENT_ADDRESS2]' => __('Whatever was in the address 2 field for the recipient of the message.', 'event_espresso'), |
51 | 51 | '[RECIPIENT_CITY]' => __('The city for the recipient of the message.', 'event_espresso'), |
52 | 52 | '[RECIPIENT_ZIP_PC]' => __('The ZIP (or Postal) Code for the recipient of the message.', 'event_espresso'), |
53 | - '[RECIPIENT_ADDRESS_STATE]' => __('The state/province for the recipient of the message.', 'event_espresso' ), |
|
53 | + '[RECIPIENT_ADDRESS_STATE]' => __('The state/province for the recipient of the message.', 'event_espresso'), |
|
54 | 54 | '[RECIPIENT_COUNTRY]' => __('The country for the recipient of the message.', 'event_espresso'), |
55 | - '[RECIPIENT_ANSWER_*]' => __('This is a special dynamic shortcode. After the "*", add the exact text of an existing question, and if there is an answer for that question for this recipient, then it will be output in place of this shortcode.', 'event_espresso' ) |
|
55 | + '[RECIPIENT_ANSWER_*]' => __('This is a special dynamic shortcode. After the "*", add the exact text of an existing question, and if there is an answer for that question for this recipient, then it will be output in place of this shortcode.', 'event_espresso') |
|
56 | 56 | ); |
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | - protected function _parser( $shortcode ) { |
|
61 | + protected function _parser($shortcode) { |
|
62 | 62 | |
63 | 63 | //make sure we end up with a copy of the EE_Messages_Addressee object |
64 | 64 | $this->_recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL; |
65 | - $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee && is_array($this->_data) && isset( $this->_data['data'] ) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] : $this->_recipient; |
|
66 | - $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee && !empty( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : $this->_recipient; |
|
65 | + $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee && is_array($this->_data) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] : $this->_recipient; |
|
66 | + $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : $this->_recipient; |
|
67 | 67 | |
68 | - if ( ! $this->_recipient instanceof EE_Messages_Addressee ) |
|
68 | + if ( ! $this->_recipient instanceof EE_Messages_Addressee) |
|
69 | 69 | return ''; |
70 | 70 | |
71 | 71 | $attendee = $this->_recipient->att_obj; |
72 | - if ( ! $attendee instanceof EE_Attendee ) |
|
72 | + if ( ! $attendee instanceof EE_Attendee) |
|
73 | 73 | return ''; |
74 | 74 | |
75 | - $this->_registrations_for_recipient = isset( $this->_recipient->attendees[ $attendee->ID() ]['reg_objs'] ) ? $this->_recipient->attendees[ $attendee->ID() ]['reg_objs'] : array(); |
|
75 | + $this->_registrations_for_recipient = isset($this->_recipient->attendees[$attendee->ID()]['reg_objs']) ? $this->_recipient->attendees[$attendee->ID()]['reg_objs'] : array(); |
|
76 | 76 | |
77 | - switch ( $shortcode ) { |
|
77 | + switch ($shortcode) { |
|
78 | 78 | case '[RECIPIENT_FNAME]' : |
79 | 79 | return $attendee->fname(); |
80 | 80 | break; |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | break; |
89 | 89 | |
90 | 90 | case '[RECIPIENT_REGISTRATION_CODE]' : |
91 | - if ( ! $this->_recipient->reg_obj instanceof EE_Registration ) |
|
91 | + if ( ! $this->_recipient->reg_obj instanceof EE_Registration) |
|
92 | 92 | return ''; |
93 | 93 | return $this->_get_reg_code(); |
94 | 94 | break; |
95 | 95 | |
96 | 96 | case '[RECIPIENT_EDIT_REGISTRATION_LINK]' : |
97 | - if ( ! $this->_recipient->reg_obj instanceof EE_Registration ) |
|
97 | + if ( ! $this->_recipient->reg_obj instanceof EE_Registration) |
|
98 | 98 | return ''; |
99 | 99 | return $this->_recipient->reg_obj->edit_attendee_information_url(); |
100 | 100 | break; |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | break; |
131 | 131 | } |
132 | 132 | |
133 | - if ( strpos( $shortcode, '[RECIPIENT_ANSWER_*' ) !== false ) { |
|
134 | - $shortcode = str_replace( '[RECIPIENT_ANSWER_*', '', $shortcode ); |
|
135 | - $shortcode = trim( str_replace( ']', '', $shortcode ) ); |
|
133 | + if (strpos($shortcode, '[RECIPIENT_ANSWER_*') !== false) { |
|
134 | + $shortcode = str_replace('[RECIPIENT_ANSWER_*', '', $shortcode); |
|
135 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
136 | 136 | |
137 | 137 | |
138 | 138 | //now let's figure out what question has this text |
139 | - if ( empty( $this->_recipient->questions ) || ! $this->_recipient->reg_obj instanceof EE_Registration ) { |
|
139 | + if (empty($this->_recipient->questions) || ! $this->_recipient->reg_obj instanceof EE_Registration) { |
|
140 | 140 | return ''; |
141 | 141 | } |
142 | 142 | |
143 | - foreach ( $this->_recipient->questions as $ansid => $question ) { |
|
144 | - if ( $question instanceof EE_Question && $question->display_text() == $shortcode && isset( $this->_recipient->registrations[$this->_recipient->reg_obj->ID()]['ans_objs'][$ansid] ) ) { |
|
145 | - return $this->_recipient->registrations[$this->_recipient->reg_obj->ID()]['ans_objs'][$ansid]->get_pretty( 'ANS_value', 'no_wpautop' ); |
|
143 | + foreach ($this->_recipient->questions as $ansid => $question) { |
|
144 | + if ($question instanceof EE_Question && $question->display_text() == $shortcode && isset($this->_recipient->registrations[$this->_recipient->reg_obj->ID()]['ans_objs'][$ansid])) { |
|
145 | + return $this->_recipient->registrations[$this->_recipient->reg_obj->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', 'no_wpautop'); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | } |
@@ -173,53 +173,53 @@ discard block |
||
173 | 173 | protected function _get_reg_code() { |
174 | 174 | |
175 | 175 | //if only one related registration for the recipient then just return that reg code. |
176 | - if ( count( $this->_registrations_for_recipient ) <= 1 ) { |
|
176 | + if (count($this->_registrations_for_recipient) <= 1) { |
|
177 | 177 | return $this->_recipient->reg_obj->reg_code(); |
178 | 178 | } |
179 | 179 | |
180 | 180 | //k more than one registration so let's see if we can get specific to context |
181 | 181 | //are we parsing event_list? |
182 | - if ( $this->_data instanceof EE_Event ) { |
|
182 | + if ($this->_data instanceof EE_Event) { |
|
183 | 183 | $reg_code = array(); |
184 | 184 | //loop through registrations for recipient and see if there is a match for this event |
185 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
186 | - if ( $reg instanceof EE_Registration && $reg->event_ID() == $this->_data->ID() ) { |
|
185 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
186 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $this->_data->ID()) { |
|
187 | 187 | $reg_code[] = $reg->reg_code(); |
188 | 188 | } |
189 | 189 | } |
190 | - return implode( ', ', $reg_code ); |
|
190 | + return implode(', ', $reg_code); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | //are we parsing ticket list? |
194 | - if ( $this->_data instanceof EE_Ticket ) { |
|
194 | + if ($this->_data instanceof EE_Ticket) { |
|
195 | 195 | $reg_code = array(); |
196 | 196 | //loop through each registration for recipient and see if there is a match for this ticket |
197 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
198 | - if ( $reg instanceof EE_Registration && $reg->ticket_ID() == $this->_data->ID() ) { |
|
197 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
198 | + if ($reg instanceof EE_Registration && $reg->ticket_ID() == $this->_data->ID()) { |
|
199 | 199 | $reg_code = $reg->reg_code(); |
200 | 200 | } |
201 | 201 | } |
202 | - return implode( ', ', $reg_code ); |
|
202 | + return implode(', ', $reg_code); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | //do we have a specific reg_obj? Let's use it |
206 | - if ( $this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration ) { |
|
206 | + if ($this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration) { |
|
207 | 207 | return $this->_data->reg_obj->reg_code(); |
208 | 208 | } |
209 | 209 | |
210 | 210 | //do we have a specific reg_obj? Let's use it |
211 | - if ( $this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration ) { |
|
211 | + if ($this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration) { |
|
212 | 212 | return $this->_data->reg_obj->reg_code(); |
213 | 213 | } |
214 | 214 | |
215 | 215 | //not able to determine the single reg code so let's return a comma delimited list of reg codes. |
216 | 216 | $reg_code = array(); |
217 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
218 | - if ( $reg instanceof EE_Registration ) { |
|
217 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
218 | + if ($reg instanceof EE_Registration) { |
|
219 | 219 | $reg_code[] = $reg->reg_code(); |
220 | 220 | } |
221 | 221 | } |
222 | - return implode(', ', $reg_code ); |
|
222 | + return implode(', ', $reg_code); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 |
@@ -912,11 +912,11 @@ |
||
912 | 912 | sprintf( |
913 | 913 | _n( |
914 | 914 | '%d message successfully queued for resending.', |
915 | - '%d messages successfully queued for resending.', |
|
916 | - $queue_count, |
|
917 | - 'event_espresso' |
|
918 | - ), |
|
919 | - $queue_count |
|
915 | + '%d messages successfully queued for resending.', |
|
916 | + $queue_count, |
|
917 | + 'event_espresso' |
|
918 | + ), |
|
919 | + $queue_count |
|
920 | 920 | ) |
921 | 921 | ); |
922 | 922 | } else { |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * |
561 | 561 | * @param string $payment_status The payment status being matched. |
562 | 562 | * |
563 | - * @return string|bool The payment message type slug matching the status or false if no match. |
|
563 | + * @return string|false The payment message type slug matching the status or false if no match. |
|
564 | 564 | */ |
565 | 565 | protected static function _get_payment_message_type( $payment_status ) { |
566 | 566 | EE_Registry::instance()->load_helper( 'MSG_Template' ); |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | * @param string $context This should correspond with a valid context for the message type |
805 | 805 | * @param string $messenger This should correspond with a valid messenger. |
806 | 806 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
807 | - * @return string|bool The body of the message or if send is requested, sends. |
|
807 | + * @return string The body of the message or if send is requested, sends. |
|
808 | 808 | */ |
809 | 809 | public static function preview_message( $type, $context, $messenger, $send = false ) { |
810 | 810 | self::_load_controller(); |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | * @since 4.9.0 |
901 | 901 | * @param $message_ids |
902 | 902 | * |
903 | - * @return bool | EE_Messages_Queue false if no messages sent. |
|
903 | + * @return EE_Messages_Queue | EE_Messages_Queue false if no messages sent. |
|
904 | 904 | */ |
905 | 905 | public static function send_now( $message_ids ) { |
906 | 906 | self::_load_controller(); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return EED_Module |
70 | 70 | */ |
71 | 71 | public static function instance() { |
72 | - return parent::get_instance( __CLASS__ ); |
|
72 | + return parent::get_instance(__CLASS__); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public static function set_hooks() { |
86 | 86 | //actions |
87 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
88 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 2 ); |
|
87 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
88 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 2); |
|
89 | 89 | //filters |
90 | - add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
91 | - add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
90 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
91 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
92 | 92 | //register routes |
93 | 93 | self::_register_routes(); |
94 | 94 | } |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public static function set_hooks_admin() { |
103 | 103 | //actions |
104 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
105 | - add_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array( 'EED_Messages', 'payment_reminder' ), 10 ); |
|
106 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 3 ); |
|
107 | - add_action( 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', array( 'EED_Messages', 'send_newsletter_message' ), 10, 2 ); |
|
108 | - add_action( 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array( 'EED_Messages', 'cancelled_registration' ), 10 ); |
|
109 | - add_action( 'AHEE__EE_Admin_Page___process_admin_payment_notification', array( 'EED_Messages', 'process_admin_payment' ), 10, 1 ); |
|
104 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
105 | + add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array('EED_Messages', 'payment_reminder'), 10); |
|
106 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 3); |
|
107 | + add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', array('EED_Messages', 'send_newsletter_message'), 10, 2); |
|
108 | + add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array('EED_Messages', 'cancelled_registration'), 10); |
|
109 | + add_action('AHEE__EE_Admin_Page___process_admin_payment_notification', array('EED_Messages', 'process_admin_payment'), 10, 1); |
|
110 | 110 | //filters |
111 | - add_filter( 'FHEE__EE_Admin_Page___process_resend_registration__success', array( 'EED_Messages', 'process_resend' ), 10, 2 ); |
|
112 | - add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
113 | - add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
111 | + add_filter('FHEE__EE_Admin_Page___process_resend_registration__success', array('EED_Messages', 'process_resend'), 10, 2); |
|
112 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
113 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | * @return void |
125 | 125 | */ |
126 | 126 | protected static function _register_routes() { |
127 | - EE_Config::register_route( 'msg_url_trigger', 'Messages', 'run' ); |
|
128 | - EE_Config::register_route( 'msg_cron_trigger', 'Messages', 'execute_batch_request' ); |
|
129 | - EE_Config::register_route( 'msg_browser_trigger', 'Messages', 'browser_trigger' ); |
|
130 | - EE_Config::register_route( 'msg_browser_error_trigger', 'Messages', 'browser_error_trigger' ); |
|
131 | - do_action( 'AHEE__EED_Messages___register_routes' ); |
|
127 | + EE_Config::register_route('msg_url_trigger', 'Messages', 'run'); |
|
128 | + EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request'); |
|
129 | + EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
130 | + EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
131 | + do_action('AHEE__EED_Messages___register_routes'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -139,18 +139,18 @@ discard block |
||
139 | 139 | * @since 4.9.0 |
140 | 140 | * @param WP $WP |
141 | 141 | */ |
142 | - public function browser_trigger( $WP ) { |
|
142 | + public function browser_trigger($WP) { |
|
143 | 143 | //ensure controller is loaded |
144 | 144 | self::_load_controller(); |
145 | - $token = EE_Registry::instance()->REQ->get( 'token' ); |
|
145 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
146 | 146 | try { |
147 | - $mtg = new EE_Message_Generated_From_Token( $token, 'html', self::$_message_resource_manager ); |
|
148 | - self::$_MSG_PROCESSOR->generate_and_send_now( $mtg ); |
|
149 | - } catch( EE_Error $e ) { |
|
150 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
147 | + $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
148 | + self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
149 | + } catch (EE_Error $e) { |
|
150 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
151 | 151 | // add specific message for developers if WP_DEBUG in on |
152 | - $error_msg .= '||' . $e->getMessage(); |
|
153 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
152 | + $error_msg .= '||'.$e->getMessage(); |
|
153 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -166,20 +166,20 @@ discard block |
||
166 | 166 | * @since 4.9.0 |
167 | 167 | * @param $WP |
168 | 168 | */ |
169 | - public function browser_error_trigger( $WP ) { |
|
170 | - $token = EE_Registry::instance()->REQ->get( 'token' ); |
|
171 | - if ( $token ) { |
|
172 | - $message = EEM_Message::instance()->get_one_by_token( $token ); |
|
173 | - if ( $message instanceof EE_Message ) { |
|
174 | - header( 'HTTP/1.1 200 OK' ); |
|
175 | - $error_msg = nl2br( $message->error_message() ); |
|
169 | + public function browser_error_trigger($WP) { |
|
170 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
171 | + if ($token) { |
|
172 | + $message = EEM_Message::instance()->get_one_by_token($token); |
|
173 | + if ($message instanceof EE_Message) { |
|
174 | + header('HTTP/1.1 200 OK'); |
|
175 | + $error_msg = nl2br($message->error_message()); |
|
176 | 176 | ?> |
177 | 177 | <!DOCTYPE html> |
178 | 178 | <html> |
179 | 179 | <head></head> |
180 | 180 | <body> |
181 | - <?php echo empty( $error_msg ) |
|
182 | - ? esc_html__( 'Unfortunately, we were unable to capture the error message for this message.', 'event_espresso' ) |
|
181 | + <?php echo empty($error_msg) |
|
182 | + ? esc_html__('Unfortunately, we were unable to capture the error message for this message.', 'event_espresso') |
|
183 | 183 | : wp_kses( |
184 | 184 | $error_msg, |
185 | 185 | array( |
@@ -214,19 +214,19 @@ discard block |
||
214 | 214 | * @throws EE_Error |
215 | 215 | * @return void |
216 | 216 | */ |
217 | - public function run( $WP ) { |
|
217 | + public function run($WP) { |
|
218 | 218 | //ensure controller is loaded |
219 | 219 | self::_load_controller(); |
220 | 220 | // attempt to process message |
221 | 221 | try { |
222 | 222 | /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
223 | - $message_to_generate = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
224 | - self::$_MSG_PROCESSOR->generate_and_send_now( $message_to_generate ); |
|
225 | - } catch ( EE_Error $e ) { |
|
226 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
223 | + $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
224 | + self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
225 | + } catch (EE_Error $e) { |
|
226 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
227 | 227 | // add specific message for developers if WP_DEBUG in on |
228 | - $error_msg .= '||' . $e->getMessage(); |
|
229 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
228 | + $error_msg .= '||'.$e->getMessage(); |
|
229 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | * This is triggered by the 'msg_cron_trigger' route. |
236 | 236 | * @param WP $WP |
237 | 237 | */ |
238 | - public function execute_batch_request( $WP ) { |
|
238 | + public function execute_batch_request($WP) { |
|
239 | 239 | $this->run_cron(); |
240 | - header( 'HTTP/1.1 200 OK' ); |
|
240 | + header('HTTP/1.1 200 OK'); |
|
241 | 241 | exit(); |
242 | 242 | } |
243 | 243 | |
@@ -251,35 +251,35 @@ discard block |
||
251 | 251 | public function run_cron() { |
252 | 252 | self::_load_controller(); |
253 | 253 | //get required vars |
254 | - $cron_type = EE_Registry::instance()->REQ->get( 'type' ); |
|
255 | - $transient_key = EE_Registry::instance()->REQ->get( 'key' ); |
|
254 | + $cron_type = EE_Registry::instance()->REQ->get('type'); |
|
255 | + $transient_key = EE_Registry::instance()->REQ->get('key'); |
|
256 | 256 | |
257 | 257 | //now let's verify transient, if not valid exit immediately |
258 | - if ( ! get_transient( $transient_key ) ) { |
|
258 | + if ( ! get_transient($transient_key)) { |
|
259 | 259 | /** |
260 | 260 | * trigger error so this gets in the error logs. This is important because it happens on a non-user request. |
261 | 261 | */ |
262 | - trigger_error( esc_attr__( 'Invalid Request (Transient does not exist)', 'event_espresso' ) ); |
|
262 | + trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso')); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | //if made it here, lets' delete the transient to keep the db clean |
266 | - delete_transient( $transient_key ); |
|
266 | + delete_transient($transient_key); |
|
267 | 267 | |
268 | - if ( apply_filters( 'FHEE__EED_Messages__run_cron__use_wp_cron', true ) ) { |
|
268 | + if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
|
269 | 269 | |
270 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
271 | - if ( method_exists( self::$_MSG_PROCESSOR, $method ) ) { |
|
270 | + $method = 'batch_'.$cron_type.'_from_queue'; |
|
271 | + if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
272 | 272 | self::$_MSG_PROCESSOR->$method(); |
273 | 273 | } else { |
274 | 274 | //no matching task |
275 | 275 | /** |
276 | 276 | * trigger error so this gets in the error logs. This is important because it happens on a non user request. |
277 | 277 | */ |
278 | - trigger_error( esc_attr( sprintf( __( 'There is no task corresponding to this route %s', 'event_espresso' ), $cron_type ) ) ); |
|
278 | + trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'), $cron_type))); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
282 | - do_action( 'FHEE__EED_Messages__run_cron__end' ); |
|
282 | + do_action('FHEE__EED_Messages__run_cron__end'); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @return EE_Messages_Template_Pack |
297 | 297 | */ |
298 | - public static function get_template_pack( $template_pack_name ) { |
|
299 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
300 | - return EEH_MSG_Template::get_template_pack( $template_pack_name ); |
|
298 | + public static function get_template_pack($template_pack_name) { |
|
299 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
300 | + return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | * @return EE_Messages_Template_Pack[] |
312 | 312 | */ |
313 | 313 | public static function get_template_packs() { |
314 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
314 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
315 | 315 | |
316 | 316 | //for backward compat, let's make sure this returns in the same format as originally. |
317 | 317 | $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
318 | 318 | $template_pack_collection->rewind(); |
319 | 319 | $template_packs = array(); |
320 | - while ( $template_pack_collection->valid() ) { |
|
321 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
320 | + while ($template_pack_collection->valid()) { |
|
321 | + $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current(); |
|
322 | 322 | $template_pack_collection->next(); |
323 | 323 | } |
324 | 324 | return $template_packs; |
@@ -334,14 +334,14 @@ discard block |
||
334 | 334 | * @return void |
335 | 335 | */ |
336 | 336 | public static function set_autoloaders() { |
337 | - if ( empty( self::$_MSG_PATHS ) ) { |
|
337 | + if (empty(self::$_MSG_PATHS)) { |
|
338 | 338 | self::_set_messages_paths(); |
339 | - foreach ( self::$_MSG_PATHS as $path ) { |
|
340 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $path ); |
|
339 | + foreach (self::$_MSG_PATHS as $path) { |
|
340 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
341 | 341 | } |
342 | 342 | // add aliases |
343 | - EEH_Autoloader::add_alias( 'EE_messages', 'EE_messages' ); |
|
344 | - EEH_Autoloader::add_alias( 'EE_messenger', 'EE_messenger' ); |
|
343 | + EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
344 | + EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
@@ -369,10 +369,10 @@ discard block |
||
369 | 369 | 'shortcodes', |
370 | 370 | ); |
371 | 371 | $paths = array(); |
372 | - foreach ( $dir_ref as $index => $dir ) { |
|
373 | - $paths[ $index ] = EE_LIBRARIES . $dir; |
|
372 | + foreach ($dir_ref as $index => $dir) { |
|
373 | + $paths[$index] = EE_LIBRARIES.$dir; |
|
374 | 374 | } |
375 | - self::$_MSG_PATHS = apply_filters( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths ); |
|
375 | + self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -383,12 +383,12 @@ discard block |
||
383 | 383 | * @return void |
384 | 384 | */ |
385 | 385 | protected static function _load_controller() { |
386 | - if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor ) { |
|
387 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
386 | + if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
387 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
388 | 388 | self::set_autoloaders(); |
389 | - self::$_EEMSG = EE_Registry::instance()->load_lib( 'messages' ); |
|
390 | - self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
391 | - self::$_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
389 | + self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
390 | + self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
391 | + self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
392 | 392 | } |
393 | 393 | } |
394 | 394 | |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | /** |
398 | 398 | * @param EE_Transaction $transaction |
399 | 399 | */ |
400 | - public static function payment_reminder( EE_Transaction $transaction ) { |
|
400 | + public static function payment_reminder(EE_Transaction $transaction) { |
|
401 | 401 | self::_load_controller(); |
402 | - $data = array( $transaction, null ); |
|
403 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'payment_reminder', $data ); |
|
402 | + $data = array($transaction, null); |
|
403 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -411,14 +411,14 @@ discard block |
||
411 | 411 | * @param EE_Payment object |
412 | 412 | * @return void |
413 | 413 | */ |
414 | - public static function payment( EE_Transaction $transaction, EE_Payment $payment ) { |
|
414 | + public static function payment(EE_Transaction $transaction, EE_Payment $payment) { |
|
415 | 415 | self::_load_controller(); |
416 | - $data = array( $transaction, $payment ); |
|
417 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
418 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
416 | + $data = array($transaction, $payment); |
|
417 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
418 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
419 | 419 | //if payment amount is less than 0 then switch to payment_refund message type. |
420 | 420 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
421 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
421 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | /** |
427 | 427 | * @param EE_Transaction $transaction |
428 | 428 | */ |
429 | - public static function cancelled_registration( EE_Transaction $transaction ) { |
|
429 | + public static function cancelled_registration(EE_Transaction $transaction) { |
|
430 | 430 | self::_load_controller(); |
431 | - $data = array( $transaction, null ); |
|
432 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'cancelled_registration', $data ); |
|
431 | + $data = array($transaction, null); |
|
432 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | * @param array $extra_details |
443 | 443 | * @return void |
444 | 444 | */ |
445 | - public static function maybe_registration( EE_Registration $registration, $extra_details = array() ) { |
|
445 | + public static function maybe_registration(EE_Registration $registration, $extra_details = array()) { |
|
446 | 446 | |
447 | - if ( ! self::_verify_registration_notification_send( $registration, $extra_details ) ) { |
|
447 | + if ( ! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
448 | 448 | //no messages please |
449 | 449 | return; |
450 | 450 | } |
@@ -459,22 +459,22 @@ discard block |
||
459 | 459 | $mtgs = array(); |
460 | 460 | |
461 | 461 | //loop through registrations and trigger messages once per status. |
462 | - foreach ( $all_registrations as $reg ) { |
|
462 | + foreach ($all_registrations as $reg) { |
|
463 | 463 | |
464 | 464 | //already triggered? |
465 | - if ( in_array( $reg->status_ID(), $statuses_sent ) ) { |
|
465 | + if (in_array($reg->status_ID(), $statuses_sent)) { |
|
466 | 466 | continue; |
467 | 467 | } |
468 | 468 | |
469 | - $message_type = EEH_MSG_Template::convert_reg_status_to_message_type( $reg->status_ID() ); |
|
470 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( $message_type, array( $registration->transaction(), null, $reg->status_ID() ) ); |
|
469 | + $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
470 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers($message_type, array($registration->transaction(), null, $reg->status_ID())); |
|
471 | 471 | $statuses_sent[] = $reg->status_ID(); |
472 | 472 | } |
473 | 473 | |
474 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( 'registration_summary', array( $registration->transaction(), null ) ); |
|
474 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers('registration_summary', array($registration->transaction(), null)); |
|
475 | 475 | |
476 | 476 | //batch queue and initiate request |
477 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $mtgs ); |
|
477 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
478 | 478 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
479 | 479 | } |
480 | 480 | |
@@ -489,39 +489,39 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return bool true = send away, false = nope halt the presses. |
491 | 491 | */ |
492 | - protected static function _verify_registration_notification_send( EE_Registration $registration, $extra_details = array() ) { |
|
492 | + protected static function _verify_registration_notification_send(EE_Registration $registration, $extra_details = array()) { |
|
493 | 493 | //self::log( |
494 | 494 | // __CLASS__, __FUNCTION__, __LINE__, |
495 | 495 | // $registration->transaction(), |
496 | 496 | // array( '$extra_details' => $extra_details ) |
497 | 497 | //); |
498 | 498 | // currently only using this to send messages for the primary registrant |
499 | - if ( ! $registration->is_primary_registrant() ) { |
|
499 | + if ( ! $registration->is_primary_registrant()) { |
|
500 | 500 | return false; |
501 | 501 | } |
502 | 502 | // first we check if we're in admin and not doing front ajax |
503 | - if ( is_admin() && ! EE_FRONT_AJAX ) { |
|
503 | + if (is_admin() && ! EE_FRONT_AJAX) { |
|
504 | 504 | //make sure appropriate admin params are set for sending messages |
505 | - if ( empty( $_REQUEST['txn_reg_status_change']['send_notifications'] ) || ! absint( $_REQUEST['txn_reg_status_change']['send_notifications'] ) ) { |
|
505 | + if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) { |
|
506 | 506 | //no messages sent please. |
507 | 507 | return false; |
508 | 508 | } |
509 | 509 | } else { |
510 | 510 | // frontend request (either regular or via AJAX) |
511 | 511 | // TXN is NOT finalized ? |
512 | - if ( ! isset( $extra_details['finalized'] ) || $extra_details['finalized'] === false ) { |
|
512 | + if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
513 | 513 | return false; |
514 | 514 | } |
515 | 515 | // return visit but nothing changed ??? |
516 | 516 | if ( |
517 | - isset( $extra_details['revisit'], $extra_details['status_updates'] ) && |
|
517 | + isset($extra_details['revisit'], $extra_details['status_updates']) && |
|
518 | 518 | $extra_details['revisit'] && ! $extra_details['status_updates'] |
519 | 519 | ) { |
520 | 520 | return false; |
521 | 521 | } |
522 | 522 | // NOT sending messages && reg status is something other than "Not-Approved" |
523 | 523 | if ( |
524 | - ! apply_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', false ) && |
|
524 | + ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
525 | 525 | $registration->status_ID() !== EEM_Registration::status_id_not_approved |
526 | 526 | ) { |
527 | 527 | return false; |
@@ -543,10 +543,10 @@ discard block |
||
543 | 543 | * |
544 | 544 | * @return array |
545 | 545 | */ |
546 | - protected static function _get_reg_status_array( $reg_status = '' ) { |
|
547 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
548 | - return EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
549 | - ? EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
546 | + protected static function _get_reg_status_array($reg_status = '') { |
|
547 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
548 | + return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
549 | + ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
550 | 550 | : EEH_MSG_Template::reg_status_to_message_type_array(); |
551 | 551 | } |
552 | 552 | |
@@ -562,10 +562,10 @@ discard block |
||
562 | 562 | * |
563 | 563 | * @return string|bool The payment message type slug matching the status or false if no match. |
564 | 564 | */ |
565 | - protected static function _get_payment_message_type( $payment_status ) { |
|
566 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
567 | - return EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
568 | - ? EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
565 | + protected static function _get_payment_message_type($payment_status) { |
|
566 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
567 | + return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
568 | + ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
569 | 569 | : false; |
570 | 570 | } |
571 | 571 | |
@@ -579,33 +579,33 @@ discard block |
||
579 | 579 | * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
580 | 580 | * @return bool success/fail |
581 | 581 | */ |
582 | - public static function process_resend( $req_data ) { |
|
582 | + public static function process_resend($req_data) { |
|
583 | 583 | self::_load_controller(); |
584 | 584 | |
585 | 585 | //if $msgID in this request then skip to the new resend_message |
586 | - if ( EE_Registry::instance()->REQ->get( 'MSG_ID' ) ) { |
|
586 | + if (EE_Registry::instance()->REQ->get('MSG_ID')) { |
|
587 | 587 | return self::resend_message(); |
588 | 588 | } |
589 | 589 | |
590 | 590 | //make sure any incoming request data is set on the REQ so that it gets picked up later. |
591 | 591 | $req_data = (array) $req_data; |
592 | - foreach( $req_data as $request_key => $request_value ) { |
|
593 | - EE_Registry::instance()->REQ->set( $request_key, $request_value ); |
|
592 | + foreach ($req_data as $request_key => $request_value) { |
|
593 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
594 | 594 | } |
595 | 595 | |
596 | - if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() ) { |
|
596 | + if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) { |
|
597 | 597 | return false; |
598 | 598 | } |
599 | 599 | |
600 | 600 | try { |
601 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $messages_to_send ); |
|
601 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
602 | 602 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
603 | - } catch( EE_Error $e ) { |
|
604 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
603 | + } catch (EE_Error $e) { |
|
604 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
605 | 605 | return false; |
606 | 606 | } |
607 | 607 | EE_Error::add_success( |
608 | - __( 'Messages have been successfully queued for generation and sending.', 'event_espresso' ) |
|
608 | + __('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
609 | 609 | ); |
610 | 610 | return true; //everything got queued. |
611 | 611 | } |
@@ -618,17 +618,17 @@ discard block |
||
618 | 618 | public static function resend_message() { |
619 | 619 | self::_load_controller(); |
620 | 620 | |
621 | - $msgID = EE_Registry::instance()->REQ->get( 'MSG_ID' ); |
|
622 | - if ( ! $msgID ) { |
|
623 | - EE_Error::add_error( __( 'Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
621 | + $msgID = EE_Registry::instance()->REQ->get('MSG_ID'); |
|
622 | + if ( ! $msgID) { |
|
623 | + EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
624 | 624 | return false; |
625 | 625 | } |
626 | 626 | |
627 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( (array) $msgID ); |
|
627 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
628 | 628 | |
629 | 629 | //setup success message. |
630 | - $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
631 | - EE_Error::add_success( sprintf( |
|
630 | + $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
631 | + EE_Error::add_success(sprintf( |
|
632 | 632 | _n( |
633 | 633 | 'There was %d message queued for resending.', |
634 | 634 | 'There were %d messages queued for resending.', |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | 'event_espresso' |
637 | 637 | ), |
638 | 638 | $count_ready_for_resend |
639 | - ) ); |
|
639 | + )); |
|
640 | 640 | return true; |
641 | 641 | } |
642 | 642 | |
@@ -649,13 +649,13 @@ discard block |
||
649 | 649 | * @param EE_Payment $payment EE_payment object |
650 | 650 | * @return bool success/fail |
651 | 651 | */ |
652 | - public static function process_admin_payment( EE_Payment $payment ) { |
|
653 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
652 | + public static function process_admin_payment(EE_Payment $payment) { |
|
653 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
654 | 654 | //we need to get the transaction object |
655 | 655 | $transaction = $payment->transaction(); |
656 | - if ( $transaction instanceof EE_Transaction ) { |
|
657 | - $data = array( $transaction, $payment ); |
|
658 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
656 | + if ($transaction instanceof EE_Transaction) { |
|
657 | + $data = array($transaction, $payment); |
|
658 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
659 | 659 | |
660 | 660 | //if payment amount is less than 0 then switch to payment_refund message type. |
661 | 661 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
@@ -665,22 +665,22 @@ discard block |
||
665 | 665 | |
666 | 666 | self::_load_controller(); |
667 | 667 | |
668 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
668 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
669 | 669 | |
670 | 670 | //get count of queued for generation |
671 | - $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( array( EEM_Message::status_incomplete, EEM_Message::status_idle ) ); |
|
671 | + $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(array(EEM_Message::status_incomplete, EEM_Message::status_idle)); |
|
672 | 672 | |
673 | - if ( $count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0 ) { |
|
674 | - add_filter( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true' ); |
|
673 | + if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) { |
|
674 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
675 | 675 | return true; |
676 | 676 | } else { |
677 | - $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::instance()->stati_indicating_failed_sending() ); |
|
677 | + $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending()); |
|
678 | 678 | /** |
679 | 679 | * Verify that there are actually errors. If not then we return a success message because the queue might have been emptied due to successful |
680 | 680 | * IMMEDIATE generation. |
681 | 681 | */ |
682 | - if ( $count_failed > 0 ) { |
|
683 | - EE_Error::add_error( sprintf( |
|
682 | + if ($count_failed > 0) { |
|
683 | + EE_Error::add_error(sprintf( |
|
684 | 684 | _n( |
685 | 685 | 'The payment notification generation failed.', |
686 | 686 | '%d payment notifications failed being sent.', |
@@ -688,11 +688,11 @@ discard block |
||
688 | 688 | 'event_espresso' |
689 | 689 | ), |
690 | 690 | $count_failed |
691 | - ), __FILE__, __FUNCTION__, __LINE__ ); |
|
691 | + ), __FILE__, __FUNCTION__, __LINE__); |
|
692 | 692 | |
693 | 693 | return false; |
694 | 694 | } else { |
695 | - add_filter( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true' ); |
|
695 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
696 | 696 | return true; |
697 | 697 | } |
698 | 698 | } |
@@ -716,11 +716,11 @@ discard block |
||
716 | 716 | * @param int $grp_id a specific message template group id. |
717 | 717 | * @return void |
718 | 718 | */ |
719 | - public static function send_newsletter_message( $registrations, $grp_id ) { |
|
719 | + public static function send_newsletter_message($registrations, $grp_id) { |
|
720 | 720 | //make sure mtp is id and set it in the EE_Request Handler later messages setup. |
721 | - EE_Registry::instance()->REQ->set( 'GRP_ID', (int) $grp_id ); |
|
721 | + EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id); |
|
722 | 722 | self::_load_controller(); |
723 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'newsletter', $registrations ); |
|
723 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | |
@@ -735,9 +735,9 @@ discard block |
||
735 | 735 | * @param string $message_type |
736 | 736 | * @return string |
737 | 737 | */ |
738 | - public static function registration_message_trigger_url( $registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice' ) { |
|
738 | + public static function registration_message_trigger_url($registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice') { |
|
739 | 739 | // whitelist $messenger |
740 | - switch ( $messenger ) { |
|
740 | + switch ($messenger) { |
|
741 | 741 | case 'pdf' : |
742 | 742 | $sending_messenger = 'pdf'; |
743 | 743 | $generating_messenger = 'html'; |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | break; |
750 | 750 | } |
751 | 751 | // whitelist $message_type |
752 | - switch ( $message_type ) { |
|
752 | + switch ($message_type) { |
|
753 | 753 | case 'receipt' : |
754 | 754 | $message_type = 'receipt'; |
755 | 755 | break; |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | break; |
760 | 760 | } |
761 | 761 | // verify that both the messenger AND the message type are active |
762 | - if ( EEH_MSG_Template::is_messenger_active( $sending_messenger ) && EEH_MSG_Template::is_mt_active( $message_type ) ) { |
|
762 | + if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) { |
|
763 | 763 | //need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?) |
764 | 764 | $template_query_params = array( |
765 | 765 | 'MTP_is_active' => true, |
@@ -768,16 +768,16 @@ discard block |
||
768 | 768 | 'Event.EVT_ID' => $registration->event_ID() |
769 | 769 | ); |
770 | 770 | //get the message template group. |
771 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
771 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
772 | 772 | //if we don't have an EE_Message_Template_Group then return |
773 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
773 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
774 | 774 | // remove EVT_ID from query params so that global templates get picked up |
775 | - unset( $template_query_params['Event.EVT_ID'] ); |
|
775 | + unset($template_query_params['Event.EVT_ID']); |
|
776 | 776 | //get global template as the fallback |
777 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
777 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
778 | 778 | } |
779 | 779 | //if we don't have an EE_Message_Template_Group then return |
780 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
780 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
781 | 781 | return ''; |
782 | 782 | } |
783 | 783 | // generate the URL |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
807 | 807 | * @return string|bool The body of the message or if send is requested, sends. |
808 | 808 | */ |
809 | - public static function preview_message( $type, $context, $messenger, $send = false ) { |
|
809 | + public static function preview_message($type, $context, $messenger, $send = false) { |
|
810 | 810 | self::_load_controller(); |
811 | 811 | $mtg = new EE_Message_To_Generate( |
812 | 812 | $messenger, |
@@ -815,8 +815,8 @@ discard block |
||
815 | 815 | $context, |
816 | 816 | true |
817 | 817 | ); |
818 | - $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview( $mtg, $send ); |
|
819 | - if ( $generated_preview_queue instanceof EE_Messages_Queue ) { |
|
818 | + $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send); |
|
819 | + if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
820 | 820 | return $generated_preview_queue->get_message_repository()->current()->content(); |
821 | 821 | } else { |
822 | 822 | return $generated_preview_queue; |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * |
844 | 844 | * @return bool success or fail. |
845 | 845 | */ |
846 | - public static function send_message_with_messenger_only( $messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '' ) { |
|
846 | + public static function send_message_with_messenger_only($messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '') { |
|
847 | 847 | self::_load_controller(); |
848 | 848 | /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
849 | 849 | $message_to_generate = EE_Registry::instance()->load_lib( |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | $custom_subject, |
856 | 856 | ) |
857 | 857 | ); |
858 | - return self::$_MSG_PROCESSOR->queue_for_sending( $message_to_generate ); |
|
858 | + return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | |
@@ -868,22 +868,22 @@ discard block |
||
868 | 868 | * @param array $message_ids An array of message ids |
869 | 869 | * @return bool | EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated messages. |
870 | 870 | */ |
871 | - public static function generate_now( $message_ids ) { |
|
871 | + public static function generate_now($message_ids) { |
|
872 | 872 | self::_load_controller(); |
873 | 873 | $messages = EEM_Message::instance()->get_all( |
874 | 874 | array( |
875 | 875 | 0 => array( |
876 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
876 | + 'MSG_ID' => array('IN', $message_ids), |
|
877 | 877 | 'STS_ID' => EEM_Message::status_incomplete, |
878 | 878 | ) |
879 | 879 | ) |
880 | 880 | ); |
881 | 881 | |
882 | - $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue( $messages ); |
|
882 | + $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
883 | 883 | |
884 | - if ( ! $generated_queue instanceof EE_Messages_Queue ) { |
|
884 | + if ( ! $generated_queue instanceof EE_Messages_Queue) { |
|
885 | 885 | EE_Error::add_error( |
886 | - __( 'The messages were not generated. This is usually because there is already a batch being generated on a separate request. You can wait a minute or two and try again.', 'event_espresso' ), |
|
886 | + __('The messages were not generated. This is usually because there is already a batch being generated on a separate request. You can wait a minute or two and try again.', 'event_espresso'), |
|
887 | 887 | __FILE__, __FUNCTION__, __LINE__ |
888 | 888 | ); |
889 | 889 | } |
@@ -902,28 +902,28 @@ discard block |
||
902 | 902 | * |
903 | 903 | * @return bool | EE_Messages_Queue false if no messages sent. |
904 | 904 | */ |
905 | - public static function send_now( $message_ids ) { |
|
905 | + public static function send_now($message_ids) { |
|
906 | 906 | self::_load_controller(); |
907 | 907 | $messages = EEM_Message::instance()->get_all( |
908 | 908 | array( |
909 | 909 | 0 => array( |
910 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
911 | - 'STS_ID' => array( 'IN', array( EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry ) ) |
|
910 | + 'MSG_ID' => array('IN', $message_ids), |
|
911 | + 'STS_ID' => array('IN', array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry)) |
|
912 | 912 | ) |
913 | 913 | ) |
914 | 914 | ); |
915 | 915 | |
916 | - $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue( $messages ); |
|
916 | + $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
917 | 917 | |
918 | - if ( ! $sent_queue instanceof EE_Messages_Queue ) { |
|
918 | + if ( ! $sent_queue instanceof EE_Messages_Queue) { |
|
919 | 919 | EE_Error::add_error( |
920 | - __( 'The messages were not sent. This is usually because there is already a batch being sent on a separate request. You can wait a minute or two and try again.', 'event_espresso' ), |
|
920 | + __('The messages were not sent. This is usually because there is already a batch being sent on a separate request. You can wait a minute or two and try again.', 'event_espresso'), |
|
921 | 921 | __FILE__, __FUNCTION__, __LINE__ |
922 | 922 | ); |
923 | 923 | } else { |
924 | 924 | //can count how many sent by using the messages in the queue |
925 | - $sent_count = $sent_queue->count_STS_in_queue( EEM_Message::instance()->stati_indicating_sent() ); |
|
926 | - if ( $sent_count > 0 ) { |
|
925 | + $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
926 | + if ($sent_count > 0) { |
|
927 | 927 | EE_Error::add_success( |
928 | 928 | sprintf( |
929 | 929 | _n( |
@@ -938,8 +938,8 @@ discard block |
||
938 | 938 | } else { |
939 | 939 | EE_Error::overwrite_errors(); |
940 | 940 | EE_Error::add_error( |
941 | - __( 'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
942 | - If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso' ), |
|
941 | + __('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
942 | + If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso'), |
|
943 | 943 | __FILE__, __FUNCTION__, __LINE__ |
944 | 944 | ); |
945 | 945 | } |
@@ -960,13 +960,13 @@ discard block |
||
960 | 960 | * |
961 | 961 | * @return bool true means messages were successfully queued for resending, false means none were queued for resending. |
962 | 962 | */ |
963 | - public static function queue_for_resending( $message_ids ) { |
|
963 | + public static function queue_for_resending($message_ids) { |
|
964 | 964 | self::_load_controller(); |
965 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( $message_ids ); |
|
965 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
966 | 966 | |
967 | 967 | //get queue and count |
968 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
969 | - if ( $queue_count > 0 ) { |
|
968 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
969 | + if ($queue_count > 0) { |
|
970 | 970 | EE_Error::add_success( |
971 | 971 | sprintf( |
972 | 972 | _n( |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | ); |
981 | 981 | } else { |
982 | 982 | EE_Error::add_error( |
983 | - __( 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso' ), |
|
983 | + __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso'), |
|
984 | 984 | __FILE__, __FUNCTION__, __LINE__ |
985 | 985 | ); |
986 | 986 | } |
@@ -1002,16 +1002,16 @@ discard block |
||
1002 | 1002 | * @param array $info |
1003 | 1003 | * @param bool $display_request |
1004 | 1004 | */ |
1005 | - protected static function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) { |
|
1006 | - if ( WP_DEBUG && false ) { |
|
1007 | - if ( $transaction instanceof EE_Transaction ) { |
|
1005 | + protected static function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) { |
|
1006 | + if (WP_DEBUG && false) { |
|
1007 | + if ($transaction instanceof EE_Transaction) { |
|
1008 | 1008 | // don't serialize objects |
1009 | - $info = EEH_Debug_Tools::strip_objects( $info ); |
|
1009 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
1010 | 1010 | $info['TXN_status'] = $transaction->status_ID(); |
1011 | 1011 | $info['TXN_reg_steps'] = $transaction->reg_steps(); |
1012 | - if ( $transaction->ID() ) { |
|
1013 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1014 | - EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index ); |
|
1012 | + if ($transaction->ID()) { |
|
1013 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
1014 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | |
121 | 121 | /** |
122 | - * @param mixed $min_core_version |
|
122 | + * @param string $min_core_version |
|
123 | 123 | */ |
124 | 124 | public function set_min_core_version( $min_core_version = NULL ) { |
125 | 125 | $this->_min_core_version = $min_core_version; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * Sets addon_name |
142 | 142 | * @param string $addon_name |
143 | - * @return boolean |
|
143 | + * @return string |
|
144 | 144 | */ |
145 | 145 | function set_name( $addon_name ) { |
146 | 146 | return $this->_addon_name = $addon_name; |
@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @author Brent Christensen |
14 | 14 | * |
15 | 15 | */ |
16 | -class EE_DMS_4_9_0_Email_System_Question extends EE_Data_Migration_Script_Stage_Table{ |
|
16 | +class EE_DMS_4_9_0_Email_System_Question extends EE_Data_Migration_Script_Stage_Table { |
|
17 | 17 | |
18 | 18 | |
19 | 19 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function __construct() { |
26 | 26 | global $wpdb; |
27 | - $this->_pretty_name = __( 'Email - System Question', 'event_espresso' ); |
|
27 | + $this->_pretty_name = __('Email - System Question', 'event_espresso'); |
|
28 | 28 | $this->_old_table = $wpdb->prefix.'esp_question'; |
29 | 29 | $this->_extra_where_sql = "WHERE QST_system = 'email'"; |
30 | 30 | parent::__construct(); |
@@ -37,21 +37,21 @@ discard block |
||
37 | 37 | * @param array $question an associative array where keys are column names and values are their values. |
38 | 38 | * @return null |
39 | 39 | */ |
40 | - protected function _migrate_old_row( $question ) { |
|
41 | - if ( $question['QST_ID'] && $question['QST_system'] == 'email' ) { |
|
40 | + protected function _migrate_old_row($question) { |
|
41 | + if ($question['QST_ID'] && $question['QST_system'] == 'email') { |
|
42 | 42 | global $wpdb; |
43 | 43 | $success = $wpdb->update( |
44 | 44 | $this->_old_table, |
45 | - array( 'QST_type' => 'EMAIL' ), // data |
|
46 | - array( 'QST_ID' => $question['QST_ID'] ), // where |
|
47 | - array( '%s' ), // data format |
|
48 | - array( '%d' ) // where format |
|
45 | + array('QST_type' => 'EMAIL'), // data |
|
46 | + array('QST_ID' => $question['QST_ID']), // where |
|
47 | + array('%s'), // data format |
|
48 | + array('%d') // where format |
|
49 | 49 | ); |
50 | - if ( ! $success ) { |
|
50 | + if ( ! $success) { |
|
51 | 51 | $this->add_error( |
52 | 52 | sprintf( |
53 | - __( 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso' ), |
|
54 | - json_encode( $question['QST_system'] ), |
|
53 | + __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'), |
|
54 | + json_encode($question['QST_system']), |
|
55 | 55 | $question['QST_ID'], |
56 | 56 | $wpdb->last_error |
57 | 57 | ) |
@@ -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 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @author Brent Christensen |
15 | 15 | * |
16 | 16 | */ |
17 | -class EE_DMS_4_9_0_Answers_With_No_Registration extends EE_Data_Migration_Script_Stage{ |
|
17 | +class EE_DMS_4_9_0_Answers_With_No_Registration extends EE_Data_Migration_Script_Stage { |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @return EE_DMS_4_9_0_Answers_With_No_Registration |
25 | 25 | */ |
26 | 26 | public function __construct() { |
27 | - $this->_pretty_name = __( 'Answer Cleanup', 'event_espresso' ); |
|
27 | + $this->_pretty_name = __('Answer Cleanup', 'event_espresso'); |
|
28 | 28 | parent::__construct(); |
29 | 29 | } |
30 | 30 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | protected function _migration_step($num_items_to_migrate = 50) { |
49 | 49 | global $wpdb; |
50 | 50 | $wpdb->delete( |
51 | - $wpdb->prefix . 'esp_answer', |
|
52 | - array( 'REG_ID' => 0 ), |
|
53 | - array( '%d' ) |
|
51 | + $wpdb->prefix.'esp_answer', |
|
52 | + array('REG_ID' => 0), |
|
53 | + array('%d') |
|
54 | 54 | ); |
55 | 55 | $this->set_completed(); |
56 | 56 | return 1; |
@@ -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 | * |
4 | 4 | * Event Espresso |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * array for defining default session vars |
105 | 105 | * @var array |
106 | 106 | */ |
107 | - private $_default_session_vars = array ( |
|
107 | + private $_default_session_vars = array( |
|
108 | 108 | 'id' => NULL, |
109 | 109 | 'user_id' => NULL, |
110 | 110 | 'ip_address' => NULL, |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | * @param \EE_Encryption $encryption |
128 | 128 | * @return EE_Session |
129 | 129 | */ |
130 | - public static function instance( EE_Encryption $encryption = null ) { |
|
130 | + public static function instance(EE_Encryption $encryption = null) { |
|
131 | 131 | // check if class object is instantiated |
132 | 132 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: |
133 | 133 | // add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
134 | - if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
135 | - self::$_instance = new self( $encryption ); |
|
134 | + if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) { |
|
135 | + self::$_instance = new self($encryption); |
|
136 | 136 | } |
137 | 137 | return self::$_instance; |
138 | 138 | } |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | * @access protected |
146 | 146 | * @param \EE_Encryption $encryption |
147 | 147 | */ |
148 | - protected function __construct( EE_Encryption $encryption = null ) { |
|
148 | + protected function __construct(EE_Encryption $encryption = null) { |
|
149 | 149 | |
150 | 150 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
151 | - if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) { |
|
151 | + if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) { |
|
152 | 152 | return NULL; |
153 | 153 | } |
154 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
155 | - if ( ! defined( 'ESPRESSO_SESSION' ) ) { |
|
156 | - define( 'ESPRESSO_SESSION', true ); |
|
154 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
155 | + if ( ! defined('ESPRESSO_SESSION')) { |
|
156 | + define('ESPRESSO_SESSION', true); |
|
157 | 157 | } |
158 | 158 | // default session lifespan in seconds |
159 | 159 | $this->_lifespan = apply_filters( |
@@ -167,35 +167,35 @@ discard block |
||
167 | 167 | * } |
168 | 168 | */ |
169 | 169 | // retrieve session options from db |
170 | - $session_settings = get_option( 'ee_session_settings' ); |
|
171 | - if ( $session_settings !== FALSE ) { |
|
170 | + $session_settings = get_option('ee_session_settings'); |
|
171 | + if ($session_settings !== FALSE) { |
|
172 | 172 | // cycle though existing session options |
173 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
173 | + foreach ($session_settings as $var_name => $session_setting) { |
|
174 | 174 | // set values for class properties |
175 | - $var_name = '_' . $var_name; |
|
175 | + $var_name = '_'.$var_name; |
|
176 | 176 | $this->{$var_name} = $session_setting; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | // are we using encryption? |
180 | - if ( $this->_use_encryption && $encryption instanceof EE_Encryption ) { |
|
180 | + if ($this->_use_encryption && $encryption instanceof EE_Encryption) { |
|
181 | 181 | // encrypt data via: $this->encryption->encrypt(); |
182 | 182 | $this->encryption = $encryption; |
183 | 183 | } |
184 | 184 | // filter hook allows outside functions/classes/plugins to change default empty cart |
185 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
186 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
185 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
186 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
187 | 187 | // apply default session vars |
188 | 188 | $this->_set_defaults(); |
189 | 189 | // check for existing session and retrieve it from db |
190 | - if ( ! $this->_espresso_session() ) { |
|
190 | + if ( ! $this->_espresso_session()) { |
|
191 | 191 | // or just start a new one |
192 | 192 | $this->_create_espresso_session(); |
193 | 193 | } |
194 | 194 | // check request for 'clear_session' param |
195 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
195 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
196 | 196 | // once everything is all said and done, |
197 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
198 | - add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 ); |
|
197 | + add_action('shutdown', array($this, 'update'), 100); |
|
198 | + add_action('shutdown', array($this, 'garbage_collection'), 999); |
|
199 | 199 | |
200 | 200 | } |
201 | 201 | |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | */ |
228 | 228 | private function _set_defaults() { |
229 | 229 | // set some defaults |
230 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
231 | - if ( is_array( $default_var )) { |
|
232 | - $this->_session_data[ $key ] = array(); |
|
230 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
231 | + if (is_array($default_var)) { |
|
232 | + $this->_session_data[$key] = array(); |
|
233 | 233 | } else { |
234 | - $this->_session_data[ $key ] = ''; |
|
234 | + $this->_session_data[$key] = ''; |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @param \EE_Cart $cart |
254 | 254 | * @return bool |
255 | 255 | */ |
256 | - public function set_cart( EE_Cart $cart ) { |
|
256 | + public function set_cart(EE_Cart $cart) { |
|
257 | 257 | $this->_session_data['cart'] = $cart; |
258 | 258 | return TRUE; |
259 | 259 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return \EE_Cart |
274 | 274 | */ |
275 | 275 | public function cart() { |
276 | - return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL; |
|
276 | + return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param \EE_Checkout $checkout |
283 | 283 | * @return bool |
284 | 284 | */ |
285 | - public function set_checkout( EE_Checkout $checkout ) { |
|
285 | + public function set_checkout(EE_Checkout $checkout) { |
|
286 | 286 | $this->_session_data['checkout'] = $checkout; |
287 | 287 | return TRUE; |
288 | 288 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return \EE_Checkout |
303 | 303 | */ |
304 | 304 | public function checkout() { |
305 | - return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL; |
|
305 | + return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @param \EE_Transaction $transaction |
312 | 312 | * @return bool |
313 | 313 | */ |
314 | - public function set_transaction( EE_Transaction $transaction ) { |
|
314 | + public function set_transaction(EE_Transaction $transaction) { |
|
315 | 315 | // first remove the session from the transaction before we save the transaction in the session |
316 | - $transaction->set_txn_session_data( NULL ); |
|
316 | + $transaction->set_txn_session_data(NULL); |
|
317 | 317 | $this->_session_data['transaction'] = $transaction; |
318 | 318 | return TRUE; |
319 | 319 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @return \EE_Transaction |
334 | 334 | */ |
335 | 335 | public function transaction() { |
336 | - return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL; |
|
336 | + return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
@@ -345,15 +345,15 @@ discard block |
||
345 | 345 | * @param bool $reset_cache |
346 | 346 | * @return array |
347 | 347 | */ |
348 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
349 | - if ( $reset_cache ) { |
|
348 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
349 | + if ($reset_cache) { |
|
350 | 350 | $this->reset_cart(); |
351 | 351 | $this->reset_checkout(); |
352 | 352 | $this->reset_transaction(); |
353 | 353 | } |
354 | - if ( ! empty( $key )) { |
|
355 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
356 | - } else { |
|
354 | + if ( ! empty($key)) { |
|
355 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
356 | + } else { |
|
357 | 357 | return $this->_session_data; |
358 | 358 | } |
359 | 359 | } |
@@ -366,20 +366,20 @@ discard block |
||
366 | 366 | * @param array $data |
367 | 367 | * @return TRUE on success, FALSE on fail |
368 | 368 | */ |
369 | - public function set_session_data( $data ) { |
|
369 | + public function set_session_data($data) { |
|
370 | 370 | |
371 | 371 | // nothing ??? bad data ??? go home! |
372 | - if ( empty( $data ) || ! is_array( $data )) { |
|
373 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
372 | + if (empty($data) || ! is_array($data)) { |
|
373 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
374 | 374 | return FALSE; |
375 | 375 | } |
376 | 376 | |
377 | - foreach ( $data as $key =>$value ) { |
|
378 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
379 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
377 | + foreach ($data as $key =>$value) { |
|
378 | + if (isset($this->_default_session_vars[$key])) { |
|
379 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
380 | 380 | return FALSE; |
381 | 381 | } else { |
382 | - $this->_session_data[ $key ] = $value; |
|
382 | + $this->_session_data[$key] = $value; |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | * @throws \EE_Error |
397 | 397 | */ |
398 | 398 | private function _espresso_session() { |
399 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
399 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
400 | 400 | // check that session has started |
401 | - if ( session_id() === '' ) { |
|
401 | + if (session_id() === '') { |
|
402 | 402 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
403 | 403 | session_start(); |
404 | 404 | } |
@@ -407,57 +407,57 @@ discard block |
||
407 | 407 | // and the visitors IP |
408 | 408 | $this->_ip_address = $this->_visitor_ip(); |
409 | 409 | // set the "user agent" |
410 | - $this->_user_agent = ( isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
410 | + $this->_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
411 | 411 | // now let's retrieve what's in the db |
412 | 412 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
413 | - $session_data = get_transient( EE_Session::session_id_prefix . $this->_sid ); |
|
414 | - if ( $session_data ) { |
|
415 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
416 | - $hash_check = get_transient( EE_Session::hash_check_prefix . $this->_sid ); |
|
417 | - if ( $hash_check && $hash_check !== md5( $session_data ) ) { |
|
413 | + $session_data = get_transient(EE_Session::session_id_prefix.$this->_sid); |
|
414 | + if ($session_data) { |
|
415 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
416 | + $hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid); |
|
417 | + if ($hash_check && $hash_check !== md5($session_data)) { |
|
418 | 418 | EE_Error::add_error( |
419 | 419 | sprintf( |
420 | - __( 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso' ), |
|
421 | - EE_Session::session_id_prefix . $this->_sid |
|
420 | + __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'), |
|
421 | + EE_Session::session_id_prefix.$this->_sid |
|
422 | 422 | ), |
423 | 423 | __FILE__, __FUNCTION__, __LINE__ |
424 | 424 | ); |
425 | 425 | } |
426 | 426 | } |
427 | 427 | // un-encrypt the data |
428 | - $session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data; |
|
428 | + $session_data = $this->_use_encryption ? $this->encryption->decrypt($session_data) : $session_data; |
|
429 | 429 | // unserialize |
430 | - $session_data = maybe_unserialize( $session_data ); |
|
430 | + $session_data = maybe_unserialize($session_data); |
|
431 | 431 | // just a check to make sure the session array is indeed an array |
432 | - if ( ! is_array( $session_data ) ) { |
|
432 | + if ( ! is_array($session_data)) { |
|
433 | 433 | // no?!?! then something is wrong |
434 | 434 | return FALSE; |
435 | 435 | } |
436 | 436 | // get the current time in UTC |
437 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
437 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
438 | 438 | // and reset the session expiration |
439 | - $this->_expiration = isset( $session_data['expiration'] ) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
439 | + $this->_expiration = isset($session_data['expiration']) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
440 | 440 | |
441 | 441 | } else { |
442 | 442 | // set initial site access time and the session expiration |
443 | 443 | $this->_set_init_access_and_expiration(); |
444 | 444 | // set referer |
445 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) ? esc_attr( $_SERVER['HTTP_REFERER'] ) : ''; |
|
445 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) ? esc_attr($_SERVER['HTTP_REFERER']) : ''; |
|
446 | 446 | // no previous session = go back and create one (on top of the data above) |
447 | 447 | return FALSE; |
448 | 448 | } |
449 | 449 | // now the user agent |
450 | - if ( $session_data['user_agent'] != $this->_user_agent ) { |
|
450 | + if ($session_data['user_agent'] != $this->_user_agent) { |
|
451 | 451 | return FALSE; |
452 | 452 | } |
453 | 453 | // wait a minute... how old are you? |
454 | - if ( $this->_time > $this->_expiration ) { |
|
454 | + if ($this->_time > $this->_expiration) { |
|
455 | 455 | // yer too old fer me! |
456 | 456 | // wipe out everything that isn't a default session datum |
457 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
457 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
458 | 458 | } |
459 | 459 | // make event espresso session data available to plugin |
460 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
460 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
461 | 461 | return TRUE; |
462 | 462 | |
463 | 463 | } |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | */ |
476 | 476 | protected function _generate_session_id() { |
477 | 477 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
478 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
479 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
478 | + if (isset($_REQUEST['EESID'])) { |
|
479 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
480 | 480 | } else { |
481 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
481 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
482 | 482 | } |
483 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
483 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | |
@@ -492,20 +492,20 @@ discard block |
||
492 | 492 | */ |
493 | 493 | protected function _get_sid_salt() { |
494 | 494 | // was session id salt already saved to db ? |
495 | - if ( empty( $this->_sid_salt ) ) { |
|
495 | + if (empty($this->_sid_salt)) { |
|
496 | 496 | // no? then maybe use WP defined constant |
497 | - if ( defined( 'AUTH_SALT' ) ) { |
|
497 | + if (defined('AUTH_SALT')) { |
|
498 | 498 | $this->_sid_salt = AUTH_SALT; |
499 | 499 | } |
500 | 500 | // if salt doesn't exist or is too short |
501 | - if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) { |
|
501 | + if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) { |
|
502 | 502 | // create a new one |
503 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
503 | + $this->_sid_salt = wp_generate_password(64); |
|
504 | 504 | } |
505 | 505 | // and save it as a permanent session setting |
506 | - $session_settings = get_option( 'ee_session_settings' ); |
|
507 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
508 | - update_option( 'ee_session_settings', $session_settings ); |
|
506 | + $session_settings = get_option('ee_session_settings'); |
|
507 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
508 | + update_option('ee_session_settings', $session_settings); |
|
509 | 509 | } |
510 | 510 | return $this->_sid_salt; |
511 | 511 | } |
@@ -533,19 +533,19 @@ discard block |
||
533 | 533 | * @param bool $new_session |
534 | 534 | * @return TRUE on success, FALSE on fail |
535 | 535 | */ |
536 | - public function update( $new_session = FALSE ) { |
|
537 | - $this->_session_data = isset( $this->_session_data ) |
|
538 | - && is_array( $this->_session_data ) |
|
539 | - && isset( $this->_session_data['id']) |
|
536 | + public function update($new_session = FALSE) { |
|
537 | + $this->_session_data = isset($this->_session_data) |
|
538 | + && is_array($this->_session_data) |
|
539 | + && isset($this->_session_data['id']) |
|
540 | 540 | ? $this->_session_data |
541 | 541 | : NULL; |
542 | - if ( empty( $this->_session_data )) { |
|
542 | + if (empty($this->_session_data)) { |
|
543 | 543 | $this->_set_defaults(); |
544 | 544 | } |
545 | 545 | $session_data = array(); |
546 | - foreach ( $this->_session_data as $key => $value ) { |
|
546 | + foreach ($this->_session_data as $key => $value) { |
|
547 | 547 | |
548 | - switch( $key ) { |
|
548 | + switch ($key) { |
|
549 | 549 | |
550 | 550 | case 'id' : |
551 | 551 | // session ID |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | break; |
564 | 564 | |
565 | 565 | case 'init_access' : |
566 | - $session_data['init_access'] = absint( $value ); |
|
566 | + $session_data['init_access'] = absint($value); |
|
567 | 567 | break; |
568 | 568 | |
569 | 569 | case 'last_access' : |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | |
574 | 574 | case 'expiration' : |
575 | 575 | // when the session expires |
576 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
576 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
577 | 577 | ? $this->_expiration |
578 | 578 | : $session_data['init_access'] + $this->_lifespan; |
579 | 579 | break; |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | |
586 | 586 | case 'pages_visited' : |
587 | 587 | $page_visit = $this->_get_page_visit(); |
588 | - if ( $page_visit ) { |
|
588 | + if ($page_visit) { |
|
589 | 589 | // set pages visited where the first will be the http referrer |
590 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
590 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
591 | 591 | // we'll only save the last 10 page visits. |
592 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
592 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
593 | 593 | } |
594 | 594 | break; |
595 | 595 | |
@@ -603,9 +603,9 @@ discard block |
||
603 | 603 | |
604 | 604 | $this->_session_data = $session_data; |
605 | 605 | // creating a new session does not require saving to the db just yet |
606 | - if ( ! $new_session ) { |
|
606 | + if ( ! $new_session) { |
|
607 | 607 | // ready? let's save |
608 | - if ( $this->_save_session_to_db() ) { |
|
608 | + if ($this->_save_session_to_db()) { |
|
609 | 609 | return TRUE; |
610 | 610 | } else { |
611 | 611 | return FALSE; |
@@ -626,9 +626,9 @@ discard block |
||
626 | 626 | * @return bool |
627 | 627 | */ |
628 | 628 | private function _create_espresso_session( ) { |
629 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
629 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
630 | 630 | // use the update function for now with $new_session arg set to TRUE |
631 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
631 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | |
@@ -652,15 +652,15 @@ discard block |
||
652 | 652 | return FALSE; |
653 | 653 | } |
654 | 654 | // first serialize all of our session data |
655 | - $session_data = serialize( $this->_session_data ); |
|
655 | + $session_data = serialize($this->_session_data); |
|
656 | 656 | // encrypt it if we are using encryption |
657 | - $session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data; |
|
657 | + $session_data = $this->_use_encryption ? $this->encryption->encrypt($session_data) : $session_data; |
|
658 | 658 | // maybe save hash check |
659 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
660 | - set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan ); |
|
659 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
660 | + set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan); |
|
661 | 661 | } |
662 | 662 | // we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient( transient ID, data, expiry ) |
663 | - return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan ); |
|
663 | + return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | |
@@ -686,10 +686,10 @@ discard block |
||
686 | 686 | 'HTTP_FORWARDED', |
687 | 687 | 'REMOTE_ADDR' |
688 | 688 | ); |
689 | - foreach ( $server_keys as $key ){ |
|
690 | - if ( isset( $_SERVER[ $key ] )) { |
|
691 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
692 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
689 | + foreach ($server_keys as $key) { |
|
690 | + if (isset($_SERVER[$key])) { |
|
691 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
692 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
693 | 693 | $visitor_ip = $ip; |
694 | 694 | } |
695 | 695 | } |
@@ -710,45 +710,45 @@ discard block |
||
710 | 710 | public function _get_page_visit() { |
711 | 711 | |
712 | 712 | // echo '<h3>'. __CLASS__ .'->'.__FUNCTION__.' ( line no: ' . __LINE__ . ' )</h3>'; |
713 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
713 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
714 | 714 | |
715 | 715 | // check for request url |
716 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
716 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
717 | 717 | |
718 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
718 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
719 | 719 | |
720 | - $ru_bits = explode( '?', $request_uri ); |
|
720 | + $ru_bits = explode('?', $request_uri); |
|
721 | 721 | $request_uri = $ru_bits[0]; |
722 | 722 | //echo '<h1>$request_uri ' . $request_uri . '</h1>'; |
723 | 723 | |
724 | 724 | // check for and grab host as well |
725 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
726 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
725 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
726 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
727 | 727 | } else { |
728 | 728 | $http_host = ''; |
729 | 729 | } |
730 | 730 | //echo '<h1>$http_host ' . $http_host . '</h1>'; |
731 | 731 | |
732 | 732 | // check for page_id in SERVER REQUEST |
733 | - if ( isset( $_REQUEST['page_id'] )) { |
|
733 | + if (isset($_REQUEST['page_id'])) { |
|
734 | 734 | // rebuild $e_reg without any of the extra parameters |
735 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
735 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
736 | 736 | } else { |
737 | 737 | $page_id = '?'; |
738 | 738 | } |
739 | 739 | // check for $e_reg in SERVER REQUEST |
740 | - if ( isset( $_REQUEST['ee'] )) { |
|
740 | + if (isset($_REQUEST['ee'])) { |
|
741 | 741 | // rebuild $e_reg without any of the extra parameters |
742 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
742 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
743 | 743 | } else { |
744 | 744 | $e_reg = ''; |
745 | 745 | } |
746 | 746 | |
747 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
747 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
748 | 748 | |
749 | 749 | } |
750 | 750 | |
751 | - return $page_visit != home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
751 | + return $page_visit != home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
752 | 752 | |
753 | 753 | } |
754 | 754 | |
@@ -777,14 +777,14 @@ discard block |
||
777 | 777 | * @param string $function |
778 | 778 | * @return void |
779 | 779 | */ |
780 | - public function clear_session( $class = '', $function = '' ) { |
|
780 | + public function clear_session($class = '', $function = '') { |
|
781 | 781 | //echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span> <b style="font-size:10px;"> ' . __LINE__ . ' </b></h3>'; |
782 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
782 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
783 | 783 | $this->reset_cart(); |
784 | 784 | $this->reset_checkout(); |
785 | 785 | $this->reset_transaction(); |
786 | 786 | // wipe out everything that isn't a default session datum |
787 | - $this->reset_data( array_keys( $this->_session_data )); |
|
787 | + $this->reset_data(array_keys($this->_session_data)); |
|
788 | 788 | // reset initial site access time and the session expiration |
789 | 789 | $this->_set_init_access_and_expiration(); |
790 | 790 | $this->_save_session_to_db(); |
@@ -799,42 +799,42 @@ discard block |
||
799 | 799 | * @param bool $show_all_notices |
800 | 800 | * @return TRUE on success, FALSE on fail |
801 | 801 | */ |
802 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
802 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
803 | 803 | // if $data_to_reset is not in an array, then put it in one |
804 | - if ( ! is_array( $data_to_reset ) ) { |
|
805 | - $data_to_reset = array ( $data_to_reset ); |
|
804 | + if ( ! is_array($data_to_reset)) { |
|
805 | + $data_to_reset = array($data_to_reset); |
|
806 | 806 | } |
807 | 807 | // nothing ??? go home! |
808 | - if ( empty( $data_to_reset )) { |
|
809 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
808 | + if (empty($data_to_reset)) { |
|
809 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
810 | 810 | return FALSE; |
811 | 811 | } |
812 | 812 | $return_value = TRUE; |
813 | 813 | // since $data_to_reset is an array, cycle through the values |
814 | - foreach ( $data_to_reset as $reset ) { |
|
814 | + foreach ($data_to_reset as $reset) { |
|
815 | 815 | |
816 | 816 | // first check to make sure it is a valid session var |
817 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
817 | + if (isset($this->_session_data[$reset])) { |
|
818 | 818 | // then check to make sure it is not a default var |
819 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
819 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
820 | 820 | // remove session var |
821 | - unset( $this->_session_data[ $reset ] ); |
|
822 | - if ( $show_all_notices ) { |
|
823 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
821 | + unset($this->_session_data[$reset]); |
|
822 | + if ($show_all_notices) { |
|
823 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
824 | 824 | } |
825 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
825 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
826 | 826 | |
827 | 827 | } else { |
828 | 828 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
829 | - if ( $show_all_notices ) { |
|
830 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
829 | + if ($show_all_notices) { |
|
830 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
831 | 831 | } |
832 | 832 | $return_value = FALSE; |
833 | 833 | } |
834 | 834 | |
835 | - } else if ( $show_all_notices ) { |
|
835 | + } else if ($show_all_notices) { |
|
836 | 836 | // oops! that session var does not exist! |
837 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
837 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
838 | 838 | $return_value = FALSE; |
839 | 839 | } |
840 | 840 | |
@@ -855,8 +855,8 @@ discard block |
||
855 | 855 | * @return string |
856 | 856 | */ |
857 | 857 | public function wp_loaded() { |
858 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
859 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
858 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
859 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | |
@@ -881,24 +881,24 @@ discard block |
||
881 | 881 | */ |
882 | 882 | public function garbage_collection() { |
883 | 883 | // only perform during regular requests |
884 | - if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) { |
|
884 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
885 | 885 | /** @type WPDB $wpdb */ |
886 | 886 | global $wpdb; |
887 | 887 | // since transient expiration timestamps are set in the future, we can compare against NOW |
888 | 888 | $expiration = time(); |
889 | - $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 ); |
|
889 | + $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2); |
|
890 | 890 | // filter the query limit. Set to 0 to turn off garbage collection |
891 | - $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 )); |
|
891 | + $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50)); |
|
892 | 892 | // non-zero LIMIT means take out the trash |
893 | - if ( $expired_session_transient_delete_query_limit ) { |
|
893 | + if ($expired_session_transient_delete_query_limit) { |
|
894 | 894 | //array of transient keys that require garbage collection |
895 | 895 | $session_keys = array( |
896 | 896 | EE_Session::session_id_prefix, |
897 | 897 | EE_Session::hash_check_prefix, |
898 | 898 | ); |
899 | - foreach ( $session_keys as $session_key ) { |
|
900 | - $session_key = str_replace( '_', '\_', $session_key ); |
|
901 | - $session_key = '\_transient\_timeout\_' . $session_key . '%'; |
|
899 | + foreach ($session_keys as $session_key) { |
|
900 | + $session_key = str_replace('_', '\_', $session_key); |
|
901 | + $session_key = '\_transient\_timeout\_'.$session_key.'%'; |
|
902 | 902 | $SQL = " |
903 | 903 | SELECT option_name |
904 | 904 | FROM {$wpdb->options} |
@@ -908,28 +908,28 @@ discard block |
||
908 | 908 | OR option_value > {$too_far_in_the_the_future} ) |
909 | 909 | LIMIT {$expired_session_transient_delete_query_limit} |
910 | 910 | "; |
911 | - $expired_sessions = $wpdb->get_col( $SQL ); |
|
911 | + $expired_sessions = $wpdb->get_col($SQL); |
|
912 | 912 | // valid results? |
913 | - if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) { |
|
913 | + if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) { |
|
914 | 914 | // format array of results into something usable within the actual DELETE query's IN clause |
915 | 915 | $expired = array(); |
916 | - foreach ( $expired_sessions as $expired_session ) { |
|
917 | - $expired[ ] = "'" . $expired_session . "'"; |
|
918 | - $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'"; |
|
916 | + foreach ($expired_sessions as $expired_session) { |
|
917 | + $expired[] = "'".$expired_session."'"; |
|
918 | + $expired[] = "'".str_replace('timeout_', '', $expired_session)."'"; |
|
919 | 919 | } |
920 | - $expired = implode( ', ', $expired ); |
|
920 | + $expired = implode(', ', $expired); |
|
921 | 921 | $SQL = " |
922 | 922 | DELETE FROM {$wpdb->options} |
923 | 923 | WHERE option_name |
924 | 924 | IN ( $expired ); |
925 | 925 | "; |
926 | - $results = $wpdb->query( $SQL ); |
|
926 | + $results = $wpdb->query($SQL); |
|
927 | 927 | // if something went wrong, then notify the admin |
928 | - if ( $results instanceof WP_Error && is_admin() ) { |
|
929 | - EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
928 | + if ($results instanceof WP_Error && is_admin()) { |
|
929 | + EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
930 | 930 | } |
931 | 931 | } |
932 | - do_action( 'FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit ); |
|
932 | + do_action('FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit); |
|
933 | 933 | } |
934 | 934 | } |
935 | 935 | } |