@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | - {exit('NO direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
2 | + {exit('NO direct script access allowed'); } |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * @param bool $routing |
74 | 74 | */ |
75 | - public function __construct( $routing = true ) { |
|
75 | + public function __construct($routing = true) { |
|
76 | 76 | //make sure messages autoloader is running |
77 | 77 | EED_Messages::set_autoloaders(); |
78 | - parent::__construct( $routing ); |
|
78 | + parent::__construct($routing); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array(); |
91 | 91 | |
92 | - $this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : null; |
|
92 | + $this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null; |
|
93 | 93 | $this->_load_message_resource_manager(); |
94 | 94 | } |
95 | 95 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @throws EE_Error |
104 | 104 | */ |
105 | 105 | protected function _load_message_resource_manager() { |
106 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
106 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | $messengers = $this->_message_resource_manager->active_messengers(); |
120 | 120 | //setup messengers for selects |
121 | 121 | $i = 1; |
122 | - foreach ( $messengers as $messenger_name => $messenger ) { |
|
123 | - if ( $messenger instanceof EE_messenger ) { |
|
124 | - $m_values[ $i ][ 'id' ] = $messenger_name; |
|
125 | - $m_values[ $i ][ 'text' ] = ucwords( $messenger->label[ 'singular' ] ); |
|
122 | + foreach ($messengers as $messenger_name => $messenger) { |
|
123 | + if ($messenger instanceof EE_messenger) { |
|
124 | + $m_values[$i]['id'] = $messenger_name; |
|
125 | + $m_values[$i]['text'] = ucwords($messenger->label['singular']); |
|
126 | 126 | $i++; |
127 | 127 | } |
128 | 128 | } |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | $mt_values = array(); |
142 | 142 | $message_types = $this->_message_resource_manager->installed_message_types(); |
143 | 143 | $i = 1; |
144 | - foreach ( $message_types as $message_type_name => $message_type ) { |
|
145 | - if ( $message_type instanceof EE_message_type ) { |
|
146 | - $mt_values[ $i ][ 'id' ] = $message_type_name; |
|
147 | - $mt_values[ $i ][ 'text' ] = ucwords( $message_type->label[ 'singular' ] ); |
|
144 | + foreach ($message_types as $message_type_name => $message_type) { |
|
145 | + if ($message_type instanceof EE_message_type) { |
|
146 | + $mt_values[$i]['id'] = $message_type_name; |
|
147 | + $mt_values[$i]['text'] = ucwords($message_type->label['singular']); |
|
148 | 148 | $i++; |
149 | 149 | } |
150 | 150 | } |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | |
155 | 155 | |
156 | 156 | protected function _ajax_hooks() { |
157 | - add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) ); |
|
158 | - add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') ); |
|
159 | - add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') ); |
|
160 | - add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) ); |
|
161 | - add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) ); |
|
157 | + add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle')); |
|
158 | + add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle')); |
|
159 | + add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings')); |
|
160 | + add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form')); |
|
161 | + add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | * @return void |
191 | 191 | */ |
192 | 192 | protected function _set_page_routes() { |
193 | - $grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] ) |
|
193 | + $grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID']) |
|
194 | 194 | ? $this->_req_data['GRP_ID'] |
195 | 195 | : 0; |
196 | - $grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] ) |
|
196 | + $grp_id = empty($grp_id) && ! empty($this->_req_data['id']) |
|
197 | 197 | ? $this->_req_data['id'] |
198 | 198 | : $grp_id; |
199 | - $msg_id = ! empty( $this->_req_data['MSG_ID'] ) && ! is_array( $this->_req_data['MSG_ID'] ) |
|
199 | + $msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID']) |
|
200 | 200 | ? $this->_req_data['MSG_ID'] |
201 | 201 | : 0; |
202 | 202 | |
@@ -238,35 +238,35 @@ discard block |
||
238 | 238 | 'insert_message_template' => array( |
239 | 239 | 'func' => '_insert_or_update_message_template', |
240 | 240 | 'capability' => 'ee_edit_messages', |
241 | - 'args' => array( 'new_template' => true ), |
|
241 | + 'args' => array('new_template' => true), |
|
242 | 242 | 'noheader' => true |
243 | 243 | ), |
244 | 244 | 'update_message_template' => array( |
245 | 245 | 'func' => '_insert_or_update_message_template', |
246 | 246 | 'capability' => 'ee_edit_message', |
247 | 247 | 'obj_id' => $grp_id, |
248 | - 'args' => array( 'new_template' => false ), |
|
248 | + 'args' => array('new_template' => false), |
|
249 | 249 | 'noheader' => true |
250 | 250 | ), |
251 | 251 | 'trash_message_template' => array( |
252 | 252 | 'func' => '_trash_or_restore_message_template', |
253 | 253 | 'capability' => 'ee_delete_message', |
254 | 254 | 'obj_id' => $grp_id, |
255 | - 'args' => array( 'trash' => true, 'all' => true ), |
|
255 | + 'args' => array('trash' => true, 'all' => true), |
|
256 | 256 | 'noheader' => true |
257 | 257 | ), |
258 | 258 | 'trash_message_template_context' => array( |
259 | 259 | 'func' => '_trash_or_restore_message_template', |
260 | 260 | 'capability' => 'ee_delete_message', |
261 | 261 | 'obj_id' => $grp_id, |
262 | - 'args' => array( 'trash' => true ), |
|
262 | + 'args' => array('trash' => true), |
|
263 | 263 | 'noheader' => true |
264 | 264 | ), |
265 | 265 | 'restore_message_template' => array( |
266 | 266 | 'func' => '_trash_or_restore_message_template', |
267 | 267 | 'capability' => 'ee_delete_message', |
268 | 268 | 'obj_id' => $grp_id, |
269 | - 'args' => array( 'trash' => false, 'all' => true ), |
|
269 | + 'args' => array('trash' => false, 'all' => true), |
|
270 | 270 | 'noheader' => true |
271 | 271 | ), |
272 | 272 | 'restore_message_template_context' => array( |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | 'order' => 10 |
342 | 342 | ), |
343 | 343 | 'list_table' => 'EE_Message_List_Table', |
344 | - 'qtips' => array( 'EE_Message_List_Table_Tips' ), |
|
344 | + 'qtips' => array('EE_Message_List_Table_Tips'), |
|
345 | 345 | 'require_nonce' => false |
346 | 346 | ), |
347 | 347 | 'global_mtps' => array( |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | 'filename' => 'messages_overview_other', |
381 | 381 | ), |
382 | 382 | ), |
383 | - 'help_tour' => array( 'Messages_Overview_Help_Tour' ), |
|
383 | + 'help_tour' => array('Messages_Overview_Help_Tour'), |
|
384 | 384 | 'require_nonce' => false |
385 | 385 | ), |
386 | 386 | 'custom_mtps' => array( |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | ), |
416 | 416 | 'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'), |
417 | 417 | 'has_metaboxes' => true, |
418 | - 'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ), |
|
418 | + 'help_tour' => array('Message_Templates_Edit_Help_Tour'), |
|
419 | 419 | 'help_tabs' => array( |
420 | 420 | 'edit_message_template' => array( |
421 | 421 | 'title' => __('Message Template Editor', 'event_espresso'), |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | 'filename' => 'messages_settings_messengers' |
472 | 472 | ), |
473 | 473 | ), |
474 | - 'help_tour' => array( 'Messages_Settings_Help_Tour' ), |
|
474 | + 'help_tour' => array('Messages_Settings_Help_Tour'), |
|
475 | 475 | 'require_nonce' => false |
476 | 476 | ) |
477 | 477 | ); |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | |
505 | 505 | |
506 | 506 | protected function _add_screen_options_default() { |
507 | - $this->_admin_page_title = __( 'Message Activity', 'event_espresso' ); |
|
507 | + $this->_admin_page_title = __('Message Activity', 'event_espresso'); |
|
508 | 508 | $this->_per_page_screen_option(); |
509 | 509 | } |
510 | 510 | |
@@ -526,37 +526,37 @@ discard block |
||
526 | 526 | |
527 | 527 | |
528 | 528 | public function messages_help_tab() { |
529 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php' ); |
|
529 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php'); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | |
533 | 533 | public function messengers_help_tab() { |
534 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php' ); |
|
534 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php'); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
538 | 538 | public function message_types_help_tab() { |
539 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php' ); |
|
539 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php'); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | |
543 | 543 | public function messages_overview_help_tab() { |
544 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php' ); |
|
544 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php'); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | |
548 | 548 | public function message_templates_help_tab() { |
549 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php' ); |
|
549 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php'); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | |
553 | 553 | public function edit_message_template_help_tab() { |
554 | - $args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />'; |
|
555 | - $args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />'; |
|
556 | - $args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />'; |
|
557 | - $args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />'; |
|
558 | - $args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />'; |
|
559 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
554 | + $args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />'; |
|
555 | + $args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />'; |
|
556 | + $args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />'; |
|
557 | + $args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />'; |
|
558 | + $args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />'; |
|
559 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | |
@@ -564,22 +564,22 @@ discard block |
||
564 | 564 | public function message_template_shortcodes_help_tab() { |
565 | 565 | $this->_set_shortcodes(); |
566 | 566 | $args['shortcodes'] = $this->_shortcodes; |
567 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', $args ); |
|
567 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', $args); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | |
571 | 571 | |
572 | 572 | public function preview_message_help_tab() { |
573 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php' ); |
|
573 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php'); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | |
577 | 577 | public function settings_help_tab() { |
578 | - $args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'; |
|
579 | - $args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'; |
|
578 | + $args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />'; |
|
579 | + $args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />'; |
|
580 | 580 | $args['img3'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked"><label for="ee-on-off-toggle-on"></label>'; |
581 | 581 | $args['img4'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox"><label for="ee-on-off-toggle-on"></label>'; |
582 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args); |
|
582 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | |
@@ -587,31 +587,31 @@ discard block |
||
587 | 587 | |
588 | 588 | |
589 | 589 | public function load_scripts_styles() { |
590 | - wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION ); |
|
590 | + wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION); |
|
591 | 591 | wp_enqueue_style('espresso_ee_msg'); |
592 | 592 | |
593 | - wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true ); |
|
594 | - wp_register_script( 'ee-msg-list-table-js', EE_MSG_ASSETS_URL. 'ee_message_admin_list_table.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION ); |
|
593 | + wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL.'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true); |
|
594 | + wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | |
598 | 598 | |
599 | 599 | public function load_scripts_styles_default() { |
600 | - wp_enqueue_script( 'ee-msg-list-table-js' ); |
|
600 | + wp_enqueue_script('ee-msg-list-table-js'); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
604 | 604 | |
605 | 605 | |
606 | 606 | |
607 | - public function wp_editor_css( $mce_css ) { |
|
607 | + public function wp_editor_css($mce_css) { |
|
608 | 608 | //if we're on the edit_message_template route |
609 | - if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger ) { |
|
609 | + if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) { |
|
610 | 610 | $message_type_name = $this->_active_message_type_name; |
611 | 611 | |
612 | 612 | //we're going to REPLACE the existing mce css |
613 | 613 | //we need to get the css file location from the active messenger |
614 | - $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation ); |
|
614 | + $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | return $mce_css; |
@@ -629,15 +629,15 @@ discard block |
||
629 | 629 | $this->_message_template_group->messenger_obj()->label['singular'], |
630 | 630 | $this->_message_template_group->message_type_obj()->label['singular'] |
631 | 631 | ); |
632 | - EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded. Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso' ); |
|
632 | + EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded. Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso'); |
|
633 | 633 | |
634 | - wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION ); |
|
634 | + wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION); |
|
635 | 635 | |
636 | 636 | wp_enqueue_script('ee_admin_js'); |
637 | 637 | wp_enqueue_script('ee_msgs_edit_js'); |
638 | 638 | |
639 | 639 | //add in special css for tiny_mce |
640 | - add_filter( 'mce_css', array( $this, 'wp_editor_css' ) ); |
|
640 | + add_filter('mce_css', array($this, 'wp_editor_css')); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | |
@@ -646,22 +646,22 @@ discard block |
||
646 | 646 | |
647 | 647 | $this->_set_message_template_group(); |
648 | 648 | |
649 | - if ( isset( $this->_req_data['messenger'] ) ) { |
|
650 | - $this->_active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
649 | + if (isset($this->_req_data['messenger'])) { |
|
650 | + $this->_active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
651 | 651 | } |
652 | 652 | |
653 | - $message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : ''; |
|
653 | + $message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : ''; |
|
654 | 654 | |
655 | 655 | |
656 | - wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, true, 'preview', $this->_variation ) ); |
|
656 | + wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'preview', $this->_variation)); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | |
660 | 660 | |
661 | 661 | public function load_scripts_styles_settings() { |
662 | - wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION ); |
|
663 | - wp_enqueue_style( 'ee-text-links' ); |
|
664 | - wp_enqueue_style( 'ee-message-settings' ); |
|
662 | + wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION); |
|
663 | + wp_enqueue_style('ee-text-links'); |
|
664 | + wp_enqueue_style('ee-message-settings'); |
|
665 | 665 | |
666 | 666 | wp_enqueue_script('ee-messages-settings'); |
667 | 667 | } |
@@ -691,40 +691,40 @@ discard block |
||
691 | 691 | * set views array for message queue list table |
692 | 692 | */ |
693 | 693 | public function _set_list_table_views_default() { |
694 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
694 | + EE_Registry::instance()->load_helper('Template'); |
|
695 | 695 | |
696 | - $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' ) |
|
696 | + $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'message_list_table_bulk_actions') |
|
697 | 697 | ? array( |
698 | - 'generate_now' => __( 'Generate Now', 'event_espresso' ), |
|
699 | - 'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ), |
|
700 | - 'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ), |
|
701 | - 'send_now' => __( 'Send Now', 'event_espresso' ) |
|
698 | + 'generate_now' => __('Generate Now', 'event_espresso'), |
|
699 | + 'generate_and_send_now' => __('Generate and Send Now', 'event_espresso'), |
|
700 | + 'queue_for_resending' => __('Queue for Resending', 'event_espresso'), |
|
701 | + 'send_now' => __('Send Now', 'event_espresso') |
|
702 | 702 | ) |
703 | 703 | : array(); |
704 | 704 | |
705 | - $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'message_list_table_bulk_actions' ) |
|
706 | - ? array( 'delete_ee_messages' => __( 'Delete Messages', 'event_espresso' ) ) |
|
705 | + $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'message_list_table_bulk_actions') |
|
706 | + ? array('delete_ee_messages' => __('Delete Messages', 'event_espresso')) |
|
707 | 707 | : array(); |
708 | 708 | |
709 | 709 | |
710 | 710 | $this->_views = array( |
711 | 711 | 'all' => array( |
712 | 712 | 'slug' => 'all', |
713 | - 'label' => __( 'All', 'event_espresso' ), |
|
713 | + 'label' => __('All', 'event_espresso'), |
|
714 | 714 | 'count' => 0, |
715 | - 'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action ) |
|
715 | + 'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action) |
|
716 | 716 | ) |
717 | 717 | ); |
718 | 718 | |
719 | 719 | |
720 | - foreach ( EEM_Message::instance()->all_statuses() as $status ) { |
|
721 | - if ( $status === EEM_Message::status_debug_only && ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) ) { |
|
720 | + foreach (EEM_Message::instance()->all_statuses() as $status) { |
|
721 | + if ($status === EEM_Message::status_debug_only && ( ! defined('WP_DEBUG') || ! WP_DEBUG)) { |
|
722 | 722 | continue; |
723 | 723 | } |
724 | 724 | $status_bulk_actions = $common_bulk_actions; |
725 | 725 | //unset bulk actions not applying to status |
726 | - if ( ! empty( $status_bulk_actions ) ) { |
|
727 | - switch ( $status ) { |
|
726 | + if ( ! empty($status_bulk_actions)) { |
|
727 | + switch ($status) { |
|
728 | 728 | case EEM_Message::status_idle : |
729 | 729 | case EEM_Message::status_resend : |
730 | 730 | $status_bulk_actions['send_now'] = $common_bulk_actions['send_now']; |
@@ -736,21 +736,21 @@ discard block |
||
736 | 736 | break; |
737 | 737 | |
738 | 738 | case EEM_Message::status_incomplete : |
739 | - unset( $status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now'] ); |
|
739 | + unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']); |
|
740 | 740 | break; |
741 | 741 | |
742 | 742 | case EEM_Message::status_retry : |
743 | 743 | case EEM_Message::status_sent : |
744 | - unset( $status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now'] ); |
|
744 | + unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']); |
|
745 | 745 | break; |
746 | 746 | } |
747 | 747 | } |
748 | 748 | |
749 | - $this->_views[ strtolower( $status ) ] = array( |
|
750 | - 'slug' => strtolower( $status ), |
|
751 | - 'label' => EEH_Template::pretty_status( $status, false, 'sentence' ), |
|
749 | + $this->_views[strtolower($status)] = array( |
|
750 | + 'slug' => strtolower($status), |
|
751 | + 'label' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
752 | 752 | 'count' => 0, |
753 | - 'bulk_action' => array_merge( $status_bulk_actions, $delete_bulk_action ) |
|
753 | + 'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action) |
|
754 | 754 | ); |
755 | 755 | } |
756 | 756 | } |
@@ -769,8 +769,8 @@ discard block |
||
769 | 769 | protected function _message_queue_list_table() { |
770 | 770 | $this->_search_btn_label = __('Message Activity', 'event_espresso'); |
771 | 771 | $this->_template_args['per_column'] = 6; |
772 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_message_legend_items() ); |
|
773 | - $this->_template_args['before_list_table'] = '<h3>' . EEM_Message::instance()->get_pretty_label_for_results() . '</h3>'; |
|
772 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items()); |
|
773 | + $this->_template_args['before_list_table'] = '<h3>'.EEM_Message::instance()->get_pretty_label_for_results().'</h3>'; |
|
774 | 774 | $this->display_admin_list_table_page_with_no_sidebar(); |
775 | 775 | } |
776 | 776 | |
@@ -783,8 +783,8 @@ discard block |
||
783 | 783 | $action_css_classes = EEH_MSG_Template::get_message_action_icons(); |
784 | 784 | $action_items = array(); |
785 | 785 | |
786 | - foreach( $action_css_classes as $action_item => $action_details ) { |
|
787 | - if ( $action_item === 'see_notifications_for' ) { |
|
786 | + foreach ($action_css_classes as $action_item => $action_details) { |
|
787 | + if ($action_item === 'see_notifications_for') { |
|
788 | 788 | continue; |
789 | 789 | } |
790 | 790 | $action_items[$action_item] = array( |
@@ -796,37 +796,37 @@ discard block |
||
796 | 796 | /** @type array $status_items status legend setup*/ |
797 | 797 | $status_items = array( |
798 | 798 | 'sent_status' => array( |
799 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent, |
|
800 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_sent, false, 'sentence' ) |
|
799 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent, |
|
800 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence') |
|
801 | 801 | ), |
802 | 802 | 'idle_status' => array( |
803 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle, |
|
804 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_idle, false, 'sentence' ) |
|
803 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle, |
|
804 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence') |
|
805 | 805 | ), |
806 | 806 | 'failed_status' => array( |
807 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed, |
|
808 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_failed, false, 'sentence' ) |
|
807 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed, |
|
808 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence') |
|
809 | 809 | ), |
810 | 810 | 'resend_status' => array( |
811 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend, |
|
812 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_resend, false, 'sentence' ) |
|
811 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend, |
|
812 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence') |
|
813 | 813 | ), |
814 | 814 | 'incomplete_status' => array( |
815 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete, |
|
816 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_incomplete, false, 'sentence' ) |
|
815 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete, |
|
816 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence') |
|
817 | 817 | ), |
818 | 818 | 'retry_status' => array( |
819 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry, |
|
820 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_retry, false, 'sentence' ) |
|
819 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry, |
|
820 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence') |
|
821 | 821 | ) |
822 | 822 | ); |
823 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
823 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
824 | 824 | $status_items['debug_only_status'] = array( |
825 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_debug_only, |
|
826 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_debug_only, false, 'sentence' ) |
|
825 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_debug_only, |
|
826 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence') |
|
827 | 827 | ); |
828 | 828 | } |
829 | - return array_merge( $action_items, $status_items ); |
|
829 | + return array_merge($action_items, $status_items); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | |
@@ -836,9 +836,9 @@ discard block |
||
836 | 836 | |
837 | 837 | protected function _custom_mtps_preview() { |
838 | 838 | $this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso'); |
839 | - $this->_template_args['preview_img'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png" alt="' . esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso' ) . '" />'; |
|
839 | + $this->_template_args['preview_img'] = '<img src="'.EE_MSG_ASSETS_URL.'images/custom_mtps_preview.png" alt="'.esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso').'" />'; |
|
840 | 840 | $this->_template_args['preview_text'] = '<strong>'.__('Custom Message Templates is a feature that is only available in the caffeinated version of Event Espresso. With the Custom Message Templates feature, you are able to create custom templates and set them per event.', 'event_espresso').'</strong>'; |
841 | - $this->display_admin_caf_preview_page( 'custom_message_types', false ); |
|
841 | + $this->display_admin_caf_preview_page('custom_message_types', false); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | |
@@ -862,31 +862,31 @@ discard block |
||
862 | 862 | * |
863 | 863 | * @return array |
864 | 864 | */ |
865 | - public function get_message_templates( $perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true ) { |
|
865 | + public function get_message_templates($perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true) { |
|
866 | 866 | |
867 | 867 | $MTP = EEM_Message_Template_Group::instance(); |
868 | 868 | |
869 | 869 | $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby']; |
870 | 870 | $orderby = $this->_req_data['orderby']; |
871 | 871 | |
872 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC'; |
|
872 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
873 | 873 | |
874 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
875 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage; |
|
874 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
875 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage; |
|
876 | 876 | |
877 | - $offset = ($current_page-1)*$per_page; |
|
878 | - $limit = $all ? null : array( $offset, $per_page ); |
|
877 | + $offset = ($current_page - 1) * $per_page; |
|
878 | + $limit = $all ? null : array($offset, $per_page); |
|
879 | 879 | |
880 | 880 | |
881 | 881 | //options will match what is in the _views array property |
882 | - switch( $type ) { |
|
882 | + switch ($type) { |
|
883 | 883 | |
884 | 884 | case 'in_use': |
885 | - $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true ); |
|
885 | + $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true); |
|
886 | 886 | break; |
887 | 887 | |
888 | 888 | default: |
889 | - $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global ); |
|
889 | + $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global); |
|
890 | 890 | |
891 | 891 | } |
892 | 892 | |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | $installed_message_types = $this->_message_resource_manager->installed_message_types(); |
906 | 906 | $installed = array(); |
907 | 907 | |
908 | - foreach ( $installed_message_types as $message_type ) { |
|
909 | - $installed[ $message_type->name ] = $message_type; |
|
908 | + foreach ($installed_message_types as $message_type) { |
|
909 | + $installed[$message_type->name] = $message_type; |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | return $installed; |
@@ -925,24 +925,24 @@ discard block |
||
925 | 925 | * |
926 | 926 | * @throws EE_error |
927 | 927 | */ |
928 | - protected function _add_message_template( $message_type = '', $messenger='', $GRP_ID = '' ) { |
|
928 | + protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') { |
|
929 | 929 | //set values override any request data |
930 | - $message_type = !empty( $message_type ) ? $message_type : ''; |
|
931 | - $message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type; |
|
930 | + $message_type = ! empty($message_type) ? $message_type : ''; |
|
931 | + $message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type; |
|
932 | 932 | |
933 | - $messenger = !empty( $messenger ) ? $messenger : ''; |
|
934 | - $messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger; |
|
933 | + $messenger = ! empty($messenger) ? $messenger : ''; |
|
934 | + $messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger; |
|
935 | 935 | |
936 | - $GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : ''; |
|
937 | - $GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
936 | + $GRP_ID = ! empty($GRP_ID) ? $GRP_ID : ''; |
|
937 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
938 | 938 | |
939 | 939 | //we need messenger and message type. They should be coming from the event editor. If not here then return error |
940 | - if ( empty( $message_type ) || empty( $messenger ) ) |
|
941 | - {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));} |
|
940 | + if (empty($message_type) || empty($messenger)) |
|
941 | + {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso')); } |
|
942 | 942 | |
943 | 943 | //we need the GRP_ID for the template being used as the base for the new template |
944 | - if ( empty( $GRP_ID ) ) |
|
945 | - {throw new EE_Error( __('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso' ) );} |
|
944 | + if (empty($GRP_ID)) |
|
945 | + {throw new EE_Error(__('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso')); } |
|
946 | 946 | |
947 | 947 | //let's just make sure the template gets generated! |
948 | 948 | |
@@ -963,8 +963,8 @@ discard block |
||
963 | 963 | * @param int $GRP_ID GRP_ID for the related message template group this new template will be based |
964 | 964 | * off of. |
965 | 965 | */ |
966 | - public function add_message_template( $message_type, $messenger, $GRP_ID ) { |
|
967 | - $this->_add_message_template( $message_type, $messenger, $GRP_ID ); |
|
966 | + public function add_message_template($message_type, $messenger, $GRP_ID) { |
|
967 | + $this->_add_message_template($message_type, $messenger, $GRP_ID); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | |
@@ -975,14 +975,14 @@ discard block |
||
975 | 975 | * @return void |
976 | 976 | */ |
977 | 977 | protected function _edit_message_template() { |
978 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
978 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
979 | 979 | $template_fields = ''; |
980 | 980 | $sidebar_fields = ''; |
981 | 981 | //we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates. |
982 | - add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 ); |
|
982 | + add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2); |
|
983 | 983 | |
984 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) |
|
985 | - ? absint( $this->_req_data['id'] ) |
|
984 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) |
|
985 | + ? absint($this->_req_data['id']) |
|
986 | 986 | : false; |
987 | 987 | |
988 | 988 | $this->_set_shortcodes(); //this also sets the _message_template property. |
@@ -990,20 +990,20 @@ discard block |
||
990 | 990 | $c_label = $message_template_group->context_label(); |
991 | 991 | $c_config = $message_template_group->contexts_config(); |
992 | 992 | |
993 | - reset( $c_config ); |
|
994 | - $context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] ) |
|
993 | + reset($c_config); |
|
994 | + $context = isset($this->_req_data['context']) && ! empty($this->_req_data['context']) |
|
995 | 995 | ? strtolower($this->_req_data['context']) |
996 | 996 | : key($c_config); |
997 | 997 | |
998 | 998 | |
999 | - if ( empty($GRP_ID) ) { |
|
999 | + if (empty($GRP_ID)) { |
|
1000 | 1000 | $action = 'insert_message_template'; |
1001 | 1001 | //$button_both = false; |
1002 | 1002 | //$button_text = array( __( 'Save','event_espresso') ); |
1003 | 1003 | //$button_actions = array('something_different'); |
1004 | 1004 | //$referrer = false; |
1005 | 1005 | $edit_message_template_form_url = add_query_arg( |
1006 | - array( 'action' => $action, 'noheader' => true ), |
|
1006 | + array('action' => $action, 'noheader' => true), |
|
1007 | 1007 | EE_MSG_ADMIN_URL |
1008 | 1008 | ); |
1009 | 1009 | } else { |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | //$button_actions = array(); |
1014 | 1014 | //$referrer = $this->_admin_base_url; |
1015 | 1015 | $edit_message_template_form_url = add_query_arg( |
1016 | - array( 'action' => $action, 'noheader' => true ), |
|
1016 | + array('action' => $action, 'noheader' => true), |
|
1017 | 1017 | EE_MSG_ADMIN_URL |
1018 | 1018 | ); |
1019 | 1019 | } |
@@ -1027,14 +1027,14 @@ discard block |
||
1027 | 1027 | |
1028 | 1028 | //Do we have any validation errors? |
1029 | 1029 | $validators = $this->_get_transient(); |
1030 | - $v_fields = !empty($validators) ? array_keys($validators) : array(); |
|
1030 | + $v_fields = ! empty($validators) ? array_keys($validators) : array(); |
|
1031 | 1031 | |
1032 | 1032 | |
1033 | 1033 | //we need to assemble the title from Various details |
1034 | 1034 | $context_label = sprintf( |
1035 | 1035 | __('(%s %s)', 'event_espresso'), |
1036 | 1036 | $c_config[$context]['label'], |
1037 | - ucwords($c_label['label'] ) |
|
1037 | + ucwords($c_label['label']) |
|
1038 | 1038 | ); |
1039 | 1039 | |
1040 | 1040 | $title = sprintf( |
@@ -1055,7 +1055,7 @@ discard block |
||
1055 | 1055 | $message_template_group->message_type() |
1056 | 1056 | ); |
1057 | 1057 | |
1058 | - if ( !$template_field_structure ) { |
|
1058 | + if ( ! $template_field_structure) { |
|
1059 | 1059 | $template_field_structure = false; |
1060 | 1060 | $template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso'); |
1061 | 1061 | } |
@@ -1065,51 +1065,51 @@ discard block |
||
1065 | 1065 | |
1066 | 1066 | |
1067 | 1067 | //if we have the extra key.. then we need to remove the content index from the template_field_structure as it will get handled in the "extra" array. |
1068 | - if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) { |
|
1069 | - foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) { |
|
1070 | - unset( $template_field_structure[$context][$reference_field] ); |
|
1068 | + if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) { |
|
1069 | + foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) { |
|
1070 | + unset($template_field_structure[$context][$reference_field]); |
|
1071 | 1071 | } |
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | //let's loop through the template_field_structure and actually assemble the input fields! |
1075 | - if ( !empty($template_field_structure) ) { |
|
1076 | - foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) { |
|
1075 | + if ( ! empty($template_field_structure)) { |
|
1076 | + foreach ($template_field_structure[$context] as $template_field => $field_setup_array) { |
|
1077 | 1077 | //if this is an 'extra' template field then we need to remove any existing fields that are keyed up in the extra array and reset them. |
1078 | - if ( $template_field == 'extra' ) { |
|
1078 | + if ($template_field == 'extra') { |
|
1079 | 1079 | $this->_template_args['is_extra_fields'] = true; |
1080 | - foreach ( $field_setup_array as $reference_field => $new_fields_array ) { |
|
1081 | - $message_template = $message_templates[ $context ][ $reference_field ]; |
|
1080 | + foreach ($field_setup_array as $reference_field => $new_fields_array) { |
|
1081 | + $message_template = $message_templates[$context][$reference_field]; |
|
1082 | 1082 | $content = $message_template instanceof EE_Message_Template |
1083 | - ? $message_template->get( 'MTP_content' ) |
|
1083 | + ? $message_template->get('MTP_content') |
|
1084 | 1084 | : ''; |
1085 | - foreach ( $new_fields_array as $extra_field => $extra_array ) { |
|
1085 | + foreach ($new_fields_array as $extra_field => $extra_array) { |
|
1086 | 1086 | //let's verify if we need this extra field via the shortcodes parameter. |
1087 | 1087 | $continue = false; |
1088 | - if ( isset( $extra_array['shortcodes_required'] ) ) { |
|
1089 | - foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) { |
|
1090 | - if ( !array_key_exists( $shortcode, $this->_shortcodes ) ) |
|
1091 | - {$continue = true;} |
|
1088 | + if (isset($extra_array['shortcodes_required'])) { |
|
1089 | + foreach ((array) $extra_array['shortcodes_required'] as $shortcode) { |
|
1090 | + if ( ! array_key_exists($shortcode, $this->_shortcodes)) |
|
1091 | + {$continue = true; } |
|
1092 | 1092 | } |
1093 | - if ( $continue ) {continue;} |
|
1093 | + if ($continue) {continue; } |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | - $field_id = $reference_field . '-' . $extra_field . '-content'; |
|
1096 | + $field_id = $reference_field.'-'.$extra_field.'-content'; |
|
1097 | 1097 | $template_form_fields[$field_id] = $extra_array; |
1098 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']'; |
|
1099 | - $css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : ''; |
|
1098 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']'; |
|
1099 | + $css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : ''; |
|
1100 | 1100 | |
1101 | - $template_form_fields[$field_id]['css_class'] = ! empty( $v_fields ) |
|
1101 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
|
1102 | 1102 | && in_array($extra_field, $v_fields) |
1103 | 1103 | && |
1104 | 1104 | ( |
1105 | - is_array($validators[$extra_field] ) |
|
1106 | - && isset( $validators[$extra_field]['msg'] ) |
|
1105 | + is_array($validators[$extra_field]) |
|
1106 | + && isset($validators[$extra_field]['msg']) |
|
1107 | 1107 | ) |
1108 | - ? 'validate-error ' . $css_class |
|
1108 | + ? 'validate-error '.$css_class |
|
1109 | 1109 | : $css_class; |
1110 | 1110 | |
1111 | - $template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field]) |
|
1112 | - ? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") ) |
|
1111 | + $template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field]) |
|
1112 | + ? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8")) |
|
1113 | 1113 | : ''; |
1114 | 1114 | |
1115 | 1115 | //do we have a validation error? if we do then let's use that value instead |
@@ -1125,32 +1125,32 @@ discard block |
||
1125 | 1125 | $field_id |
1126 | 1126 | ); |
1127 | 1127 | |
1128 | - if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) { |
|
1128 | + if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') { |
|
1129 | 1129 | //we want to decode the entities |
1130 | 1130 | $template_form_fields[$field_id]['value'] = stripslashes( |
1131 | - html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") |
|
1131 | + html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") |
|
1132 | 1132 | ); |
1133 | 1133 | |
1134 | 1134 | }/**/ |
1135 | 1135 | } |
1136 | - $templatefield_MTP_id = $reference_field . '-MTP_ID'; |
|
1137 | - $templatefield_templatename_id = $reference_field . '-name'; |
|
1136 | + $templatefield_MTP_id = $reference_field.'-MTP_ID'; |
|
1137 | + $templatefield_templatename_id = $reference_field.'-name'; |
|
1138 | 1138 | |
1139 | 1139 | $template_form_fields[$templatefield_MTP_id] = array( |
1140 | - 'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]', |
|
1140 | + 'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]', |
|
1141 | 1141 | 'label' => null, |
1142 | 1142 | 'input' => 'hidden', |
1143 | 1143 | 'type' => 'int', |
1144 | 1144 | 'required' => false, |
1145 | 1145 | 'validation' => false, |
1146 | - 'value' => !empty($message_templates) ? $message_template->ID() : '', |
|
1146 | + 'value' => ! empty($message_templates) ? $message_template->ID() : '', |
|
1147 | 1147 | 'css_class' => '', |
1148 | 1148 | 'format' => '%d', |
1149 | 1149 | 'db-col' => 'MTP_ID' |
1150 | 1150 | ); |
1151 | 1151 | |
1152 | 1152 | $template_form_fields[$templatefield_templatename_id] = array( |
1153 | - 'name' => 'MTP_template_fields[' . $reference_field . '][name]', |
|
1153 | + 'name' => 'MTP_template_fields['.$reference_field.'][name]', |
|
1154 | 1154 | 'label' => null, |
1155 | 1155 | 'input' => 'hidden', |
1156 | 1156 | 'type' => 'string', |
@@ -1164,14 +1164,14 @@ discard block |
||
1164 | 1164 | } |
1165 | 1165 | continue; //skip the next stuff, we got the necessary fields here for this dataset. |
1166 | 1166 | } else { |
1167 | - $field_id = $template_field . '-content'; |
|
1167 | + $field_id = $template_field.'-content'; |
|
1168 | 1168 | $template_form_fields[$field_id] = $field_setup_array; |
1169 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]'; |
|
1170 | - $message_template = isset( $message_templates[ $context ][ $template_field ] ) |
|
1171 | - ? $message_templates[ $context ][ $template_field ] |
|
1169 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]'; |
|
1170 | + $message_template = isset($message_templates[$context][$template_field]) |
|
1171 | + ? $message_templates[$context][$template_field] |
|
1172 | 1172 | : null; |
1173 | - $template_form_fields[$field_id]['value'] = ! empty( $message_templates ) |
|
1174 | - && is_array( $message_templates[$context] ) |
|
1173 | + $template_form_fields[$field_id]['value'] = ! empty($message_templates) |
|
1174 | + && is_array($message_templates[$context]) |
|
1175 | 1175 | && $message_template instanceof EE_Message_Template |
1176 | 1176 | ? $message_template->get('MTP_content') |
1177 | 1177 | : ''; |
@@ -1184,10 +1184,10 @@ discard block |
||
1184 | 1184 | |
1185 | 1185 | $template_form_fields[$field_id]['db-col'] = 'MTP_content'; |
1186 | 1186 | $css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : ''; |
1187 | - $template_form_fields[$field_id]['css_class'] = ! empty( $v_fields ) |
|
1188 | - && in_array( $template_field, $v_fields ) |
|
1189 | - && isset( $validators[$template_field]['msg'] ) |
|
1190 | - ? 'validate-error ' . $css_class |
|
1187 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
|
1188 | + && in_array($template_field, $v_fields) |
|
1189 | + && isset($validators[$template_field]['msg']) |
|
1190 | + ? 'validate-error '.$css_class |
|
1191 | 1191 | : $css_class; |
1192 | 1192 | |
1193 | 1193 | //shortcode selector |
@@ -1198,12 +1198,12 @@ discard block |
||
1198 | 1198 | |
1199 | 1199 | //k took care of content field(s) now let's take care of others. |
1200 | 1200 | |
1201 | - $templatefield_MTP_id = $template_field . '-MTP_ID'; |
|
1202 | - $templatefield_field_templatename_id = $template_field . '-name'; |
|
1201 | + $templatefield_MTP_id = $template_field.'-MTP_ID'; |
|
1202 | + $templatefield_field_templatename_id = $template_field.'-name'; |
|
1203 | 1203 | |
1204 | 1204 | //foreach template field there are actually two form fields created |
1205 | 1205 | $template_form_fields[$templatefield_MTP_id] = array( |
1206 | - 'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]', |
|
1206 | + 'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]', |
|
1207 | 1207 | 'label' => null, |
1208 | 1208 | 'input' => 'hidden', |
1209 | 1209 | 'type' => 'int', |
@@ -1216,7 +1216,7 @@ discard block |
||
1216 | 1216 | ); |
1217 | 1217 | |
1218 | 1218 | $template_form_fields[$templatefield_field_templatename_id] = array( |
1219 | - 'name' => 'MTP_template_fields[' . $template_field . '][name]', |
|
1219 | + 'name' => 'MTP_template_fields['.$template_field.'][name]', |
|
1220 | 1220 | 'label' => null, |
1221 | 1221 | 'input' => 'hidden', |
1222 | 1222 | 'type' => 'string', |
@@ -1360,13 +1360,13 @@ discard block |
||
1360 | 1360 | 'value' => $GRP_ID |
1361 | 1361 | ); |
1362 | 1362 | $sidebar_form_fields['ee-msg-evt-nonce'] = array( |
1363 | - 'name' => $action . '_nonce', |
|
1363 | + 'name' => $action.'_nonce', |
|
1364 | 1364 | 'input' => 'hidden', |
1365 | 1365 | 'type' => 'string', |
1366 | - 'value' => wp_create_nonce( $action . '_nonce') |
|
1366 | + 'value' => wp_create_nonce($action.'_nonce') |
|
1367 | 1367 | ); |
1368 | 1368 | |
1369 | - if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) { |
|
1369 | + if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) { |
|
1370 | 1370 | $sidebar_form_fields['ee-msg-template-switch'] = array( |
1371 | 1371 | 'name' => 'template_switch', |
1372 | 1372 | 'input' => 'hidden', |
@@ -1376,8 +1376,8 @@ discard block |
||
1376 | 1376 | } |
1377 | 1377 | |
1378 | 1378 | |
1379 | - $template_fields = $this->_generate_admin_form_fields( $template_form_fields ); |
|
1380 | - $sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields ); |
|
1379 | + $template_fields = $this->_generate_admin_form_fields($template_form_fields); |
|
1380 | + $sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields); |
|
1381 | 1381 | |
1382 | 1382 | |
1383 | 1383 | } //end if ( !empty($template_field_structure) ) |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | $GRP_ID, |
1390 | 1390 | false, |
1391 | 1391 | add_query_arg( |
1392 | - array( 'action' => 'global_mtps' ), |
|
1392 | + array('action' => 'global_mtps'), |
|
1393 | 1393 | $this->_admin_base_url |
1394 | 1394 | ) |
1395 | 1395 | ); |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | ), |
1406 | 1406 | $this->_admin_base_url |
1407 | 1407 | ); |
1408 | - $preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>'; |
|
1408 | + $preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>'; |
|
1409 | 1409 | |
1410 | 1410 | |
1411 | 1411 | //setup context switcher |
@@ -1433,17 +1433,17 @@ discard block |
||
1433 | 1433 | $this->_template_args['after_admin_page_content'] = $this->_add_form_element_after(); |
1434 | 1434 | |
1435 | 1435 | $this->_template_path = $this->_template_args['GRP_ID'] |
1436 | - ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php' |
|
1437 | - : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php'; |
|
1436 | + ? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php' |
|
1437 | + : EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php'; |
|
1438 | 1438 | |
1439 | 1439 | //send along EE_Message_Template_Group object for further template use. |
1440 | 1440 | $this->_template_args['MTP'] = $message_template_group; |
1441 | 1441 | |
1442 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, true ); |
|
1442 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, true); |
|
1443 | 1443 | |
1444 | 1444 | |
1445 | 1445 | //finally, let's set the admin_page title |
1446 | - $this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title ); |
|
1446 | + $this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title); |
|
1447 | 1447 | |
1448 | 1448 | |
1449 | 1449 | //we need to take care of setting the shortcodes property for use elsewhere. |
@@ -1456,7 +1456,7 @@ discard block |
||
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | |
1459 | - public function filter_tinymce_init( $mceInit, $editor_id ) { |
|
1459 | + public function filter_tinymce_init($mceInit, $editor_id) { |
|
1460 | 1460 | return $mceInit; |
1461 | 1461 | } |
1462 | 1462 | |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | public function _add_form_element_before() { |
1470 | - return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">'; |
|
1470 | + return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">'; |
|
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | public function _add_form_element_after() { |
@@ -1484,25 +1484,25 @@ discard block |
||
1484 | 1484 | * |
1485 | 1485 | */ |
1486 | 1486 | public function switch_template_pack() { |
1487 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1488 | - $template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : ''; |
|
1487 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1488 | + $template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : ''; |
|
1489 | 1489 | |
1490 | 1490 | //verify we have needed values. |
1491 | - if ( empty( $GRP_ID ) || empty( $template_pack ) ) { |
|
1491 | + if (empty($GRP_ID) || empty($template_pack)) { |
|
1492 | 1492 | $this->_template_args['error'] = true; |
1493 | - EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1493 | + EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1494 | 1494 | } else { |
1495 | 1495 | //get template, set the new template_pack and then reset to default |
1496 | 1496 | /** @type EE_Message_Template_Group $message_template_group */ |
1497 | - $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1497 | + $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1498 | 1498 | |
1499 | - $message_template_group->set_template_pack_name( $template_pack ); |
|
1499 | + $message_template_group->set_template_pack_name($template_pack); |
|
1500 | 1500 | $this->_req_data['msgr'] = $message_template_group->messenger(); |
1501 | 1501 | $this->_req_data['mt'] = $message_template_group->message_type(); |
1502 | 1502 | |
1503 | 1503 | $query_args = $this->_reset_to_default_template(); |
1504 | 1504 | |
1505 | - if ( empty( $query_args['id'] ) ) { |
|
1505 | + if (empty($query_args['id'])) { |
|
1506 | 1506 | EE_Error::add_error( |
1507 | 1507 | __( |
1508 | 1508 | 'Something went wrong with switching the template pack. Please try again or contact EE support', |
@@ -1512,7 +1512,7 @@ discard block |
||
1512 | 1512 | ); |
1513 | 1513 | $this->_template_args['error'] = true; |
1514 | 1514 | } else { |
1515 | - $template_label =$message_template_group->get_template_pack()->label; |
|
1515 | + $template_label = $message_template_group->get_template_pack()->label; |
|
1516 | 1516 | $template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels(); |
1517 | 1517 | EE_Error::add_success( |
1518 | 1518 | sprintf( |
@@ -1525,7 +1525,7 @@ discard block |
||
1525 | 1525 | ) |
1526 | 1526 | ); |
1527 | 1527 | //generate the redirect url for js. |
1528 | - $url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1528 | + $url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1529 | 1529 | $this->_template_args['data']['redirect_url'] = $url; |
1530 | 1530 | $this->_template_args['success'] = true; |
1531 | 1531 | } |
@@ -1547,9 +1547,9 @@ discard block |
||
1547 | 1547 | protected function _reset_to_default_template() { |
1548 | 1548 | |
1549 | 1549 | $templates = array(); |
1550 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1550 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1551 | 1551 | //we need to make sure we've got the info we need. |
1552 | - if ( ! isset( $this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'] ) ) { |
|
1552 | + if ( ! isset($this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'])) { |
|
1553 | 1553 | EE_Error::add_error( |
1554 | 1554 | __( |
1555 | 1555 | 'In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset. At least one of these is missing.', |
@@ -1561,9 +1561,9 @@ discard block |
||
1561 | 1561 | |
1562 | 1562 | // all templates will be reset to whatever the defaults are |
1563 | 1563 | // for the global template matching the messenger and message type. |
1564 | - $success = !empty( $GRP_ID ) ? true : false; |
|
1564 | + $success = ! empty($GRP_ID) ? true : false; |
|
1565 | 1565 | |
1566 | - if ( $success ) { |
|
1566 | + if ($success) { |
|
1567 | 1567 | |
1568 | 1568 | //let's first determine if the incoming template is a global template, |
1569 | 1569 | // if it isn't then we need to get the global template matching messenger and message type. |
@@ -1571,9 +1571,9 @@ discard block |
||
1571 | 1571 | |
1572 | 1572 | |
1573 | 1573 | //note this is ONLY deleting the template fields (Message Template rows) NOT the message template group. |
1574 | - $success = $this->_delete_mtp_permanently( $GRP_ID, false ); |
|
1574 | + $success = $this->_delete_mtp_permanently($GRP_ID, false); |
|
1575 | 1575 | |
1576 | - if ( $success ) { |
|
1576 | + if ($success) { |
|
1577 | 1577 | // if successfully deleted, lets generate the new ones. |
1578 | 1578 | // Note. We set GLOBAL to true, because resets on ANY template |
1579 | 1579 | // will use the related global template defaults for regeneration. |
@@ -1591,32 +1591,32 @@ discard block |
||
1591 | 1591 | } |
1592 | 1592 | |
1593 | 1593 | //any error messages? |
1594 | - if ( !$success ) { |
|
1594 | + if ( ! $success) { |
|
1595 | 1595 | EE_Error::add_error( |
1596 | - __( 'Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso' ), |
|
1596 | + __('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), |
|
1597 | 1597 | __FILE__, __FUNCTION__, __LINE__ |
1598 | 1598 | ); |
1599 | 1599 | } |
1600 | 1600 | |
1601 | 1601 | //all good, let's add a success message! |
1602 | - if ( $success && ! empty( $templates ) ) { |
|
1602 | + if ($success && ! empty($templates)) { |
|
1603 | 1603 | $templates = $templates[0]; //the info for the template we generated is the first element in the returned array. |
1604 | 1604 | EE_Error::overwrite_success(); |
1605 | - EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') ); |
|
1605 | + EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso')); |
|
1606 | 1606 | } |
1607 | 1607 | |
1608 | 1608 | |
1609 | 1609 | $query_args = array( |
1610 | - 'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : null, |
|
1611 | - 'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : null, |
|
1612 | - 'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'global_mtps' |
|
1610 | + 'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null, |
|
1611 | + 'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null, |
|
1612 | + 'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps' |
|
1613 | 1613 | ); |
1614 | 1614 | |
1615 | 1615 | //if called via ajax then we return query args otherwise redirect |
1616 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
1616 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
1617 | 1617 | return $query_args; |
1618 | 1618 | } else { |
1619 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
1619 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1620 | 1620 | return null; |
1621 | 1621 | } |
1622 | 1622 | } |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview. |
1630 | 1630 | * @return string |
1631 | 1631 | */ |
1632 | - public function _preview_message( $send = false ) { |
|
1632 | + public function _preview_message($send = false) { |
|
1633 | 1633 | //first make sure we've got the necessary parameters |
1634 | 1634 | if ( |
1635 | 1635 | ! isset( |
@@ -1645,13 +1645,13 @@ discard block |
||
1645 | 1645 | ); |
1646 | 1646 | } |
1647 | 1647 | |
1648 | - EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] ); |
|
1648 | + EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']); |
|
1649 | 1649 | |
1650 | 1650 | |
1651 | 1651 | //get the preview! |
1652 | - $preview = EED_Messages::preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send ); |
|
1652 | + $preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send); |
|
1653 | 1653 | |
1654 | - if ( $send ) { |
|
1654 | + if ($send) { |
|
1655 | 1655 | return $preview; |
1656 | 1656 | } |
1657 | 1657 | |
@@ -1661,22 +1661,22 @@ discard block |
||
1661 | 1661 | 'context' => $this->_req_data['context'], |
1662 | 1662 | 'action' => 'edit_message_template' |
1663 | 1663 | ); |
1664 | - $go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1665 | - $preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>'; |
|
1664 | + $go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1665 | + $preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>'; |
|
1666 | 1666 | $message_types = $this->get_installed_message_types(); |
1667 | - $active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
1667 | + $active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
1668 | 1668 | $active_messenger_label = $active_messenger instanceof EE_messenger |
1669 | - ? ucwords( $active_messenger->label['singular'] ) |
|
1670 | - : esc_html__( 'Unknown Messenger', 'event_espresso' ); |
|
1669 | + ? ucwords($active_messenger->label['singular']) |
|
1670 | + : esc_html__('Unknown Messenger', 'event_espresso'); |
|
1671 | 1671 | //let's provide a helpful title for context |
1672 | 1672 | $preview_title = sprintf( |
1673 | - __( 'Viewing Preview for %s %s Message Template', 'event_espresso' ), |
|
1673 | + __('Viewing Preview for %s %s Message Template', 'event_espresso'), |
|
1674 | 1674 | $active_messenger_label, |
1675 | - ucwords( $message_types[ $this->_req_data[ 'message_type' ] ]->label[ 'singular' ] ) |
|
1675 | + ucwords($message_types[$this->_req_data['message_type']]->label['singular']) |
|
1676 | 1676 | ); |
1677 | 1677 | //setup display of preview. |
1678 | 1678 | $this->_admin_page_title = $preview_title; |
1679 | - $this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview); |
|
1679 | + $this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview); |
|
1680 | 1680 | $this->_template_args['data']['force_json'] = true; |
1681 | 1681 | return ''; |
1682 | 1682 | } |
@@ -1706,9 +1706,9 @@ discard block |
||
1706 | 1706 | * @return void |
1707 | 1707 | */ |
1708 | 1708 | protected function _register_edit_meta_boxes() { |
1709 | - add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' ); |
|
1710 | - add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1711 | - add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1709 | + add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default'); |
|
1710 | + add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1711 | + add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1712 | 1712 | } |
1713 | 1713 | |
1714 | 1714 | |
@@ -1727,14 +1727,14 @@ discard block |
||
1727 | 1727 | |
1728 | 1728 | $tp_select_values = array(); |
1729 | 1729 | |
1730 | - foreach ( $tp_collection as $tp ) { |
|
1730 | + foreach ($tp_collection as $tp) { |
|
1731 | 1731 | //only include template packs that support this messenger and message type! |
1732 | 1732 | $supports = $tp->get_supports(); |
1733 | 1733 | if ( |
1734 | - ! isset( $supports[ $this->_message_template_group->messenger() ] ) |
|
1734 | + ! isset($supports[$this->_message_template_group->messenger()]) |
|
1735 | 1735 | || ! in_array( |
1736 | 1736 | $this->_message_template_group->message_type(), |
1737 | - $supports[ $this->_message_template_group->messenger() ] |
|
1737 | + $supports[$this->_message_template_group->messenger()] |
|
1738 | 1738 | ) |
1739 | 1739 | ) { |
1740 | 1740 | //not supported |
@@ -1748,7 +1748,7 @@ discard block |
||
1748 | 1748 | } |
1749 | 1749 | |
1750 | 1750 | //if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by the default template pack. This still allows for the odd template pack to override. |
1751 | - if ( empty( $tp_select_values ) ) { |
|
1751 | + if (empty($tp_select_values)) { |
|
1752 | 1752 | $tp_select_values[] = array( |
1753 | 1753 | 'text' => __('Default', 'event_espresso'), |
1754 | 1754 | 'id' => 'default' |
@@ -1761,14 +1761,14 @@ discard block |
||
1761 | 1761 | $this->_message_template_group->message_type() |
1762 | 1762 | ); |
1763 | 1763 | $variations_select_values = array(); |
1764 | - foreach ( $variations as $variation => $label ) { |
|
1764 | + foreach ($variations as $variation => $label) { |
|
1765 | 1765 | $variations_select_values[] = array( |
1766 | 1766 | 'text' => $label, |
1767 | 1767 | 'id' => $variation |
1768 | 1768 | ); |
1769 | 1769 | } |
1770 | 1770 | |
1771 | - $template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1771 | + $template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1772 | 1772 | |
1773 | 1773 | $template_args['template_packs_selector'] = EEH_Form_Fields::select_input( |
1774 | 1774 | 'MTP_template_pack', |
@@ -1785,9 +1785,9 @@ discard block |
||
1785 | 1785 | $template_args['template_pack_description'] = $template_pack_labels->template_pack_description; |
1786 | 1786 | $template_args['template_variation_description'] = $template_pack_labels->template_variation_description; |
1787 | 1787 | |
1788 | - $template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php'; |
|
1788 | + $template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php'; |
|
1789 | 1789 | |
1790 | - EEH_Template::display_template( $template, $template_args ); |
|
1790 | + EEH_Template::display_template($template, $template_args); |
|
1791 | 1791 | } |
1792 | 1792 | |
1793 | 1793 | |
@@ -1818,47 +1818,47 @@ discard block |
||
1818 | 1818 | //first we need to see if there are any fields |
1819 | 1819 | $fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields(); |
1820 | 1820 | |
1821 | - if ( !empty( $fields ) ) { |
|
1821 | + if ( ! empty($fields)) { |
|
1822 | 1822 | //yup there be fields |
1823 | - foreach ( $fields as $field => $config ) { |
|
1824 | - $field_id = $this->_message_template_group->messenger() . '_' . $field; |
|
1823 | + foreach ($fields as $field => $config) { |
|
1824 | + $field_id = $this->_message_template_group->messenger().'_'.$field; |
|
1825 | 1825 | $existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings(); |
1826 | - $default = isset( $config['default'] ) ? $config['default'] : ''; |
|
1827 | - $default = isset( $config['value'] ) ? $config['value'] : $default; |
|
1826 | + $default = isset($config['default']) ? $config['default'] : ''; |
|
1827 | + $default = isset($config['value']) ? $config['value'] : $default; |
|
1828 | 1828 | |
1829 | 1829 | //if type is hidden and the value is empty something may have gone wrong so let's correct with the defaults |
1830 | 1830 | $fix = $config['input'] == 'hidden' && isset($existing[$field]) && empty($existing[$field]) ? $default : ''; |
1831 | - $existing[$field] = isset( $existing[$field] ) && empty( $fix ) ? $existing[$field] : $fix; |
|
1831 | + $existing[$field] = isset($existing[$field]) && empty($fix) ? $existing[$field] : $fix; |
|
1832 | 1832 | |
1833 | 1833 | $template_form_fields[$field_id] = array( |
1834 | - 'name' => 'test_settings_fld[' . $field . ']', |
|
1834 | + 'name' => 'test_settings_fld['.$field.']', |
|
1835 | 1835 | 'label' => $config['label'], |
1836 | 1836 | 'input' => $config['input'], |
1837 | 1837 | 'type' => $config['type'], |
1838 | 1838 | 'required' => $config['required'], |
1839 | 1839 | 'validation' => $config['validation'], |
1840 | - 'value' => isset( $existing[$field] ) ? $existing[$field] : $default, |
|
1840 | + 'value' => isset($existing[$field]) ? $existing[$field] : $default, |
|
1841 | 1841 | 'css_class' => $config['css_class'], |
1842 | - 'options' => isset( $config['options'] ) ? $config['options'] : array(), |
|
1842 | + 'options' => isset($config['options']) ? $config['options'] : array(), |
|
1843 | 1843 | 'default' => $default, |
1844 | 1844 | 'format' => $config['format'] |
1845 | 1845 | ); |
1846 | 1846 | } |
1847 | 1847 | } |
1848 | 1848 | |
1849 | - $test_settings_fields = !empty( $template_form_fields) |
|
1850 | - ? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' ) |
|
1849 | + $test_settings_fields = ! empty($template_form_fields) |
|
1850 | + ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds') |
|
1851 | 1851 | : ''; |
1852 | 1852 | |
1853 | 1853 | $test_settings_html = ''; |
1854 | 1854 | //print out $test_settings_fields |
1855 | - if ( !empty( $test_settings_fields ) ) { |
|
1855 | + if ( ! empty($test_settings_fields)) { |
|
1856 | 1856 | echo $test_settings_fields; |
1857 | - $test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="' . __('Test Send', 'event_espresso') . '" /><div style="clear:both"></div>'; |
|
1857 | + $test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="'.__('Test Send', 'event_espresso').'" /><div style="clear:both"></div>'; |
|
1858 | 1858 | } |
1859 | 1859 | |
1860 | 1860 | //and button |
1861 | - echo $test_settings_html . '<p>' . __('Need to reset this message type and start over?', 'event_espresso') . '</p>' . '<div class="publishing-action alignright resetbutton">' . $button . '</div><div style="clear:both"></div>'; |
|
1861 | + echo $test_settings_html.'<p>'.__('Need to reset this message type and start over?', 'event_espresso').'</p>'.'<div class="publishing-action alignright resetbutton">'.$button.'</div><div style="clear:both"></div>'; |
|
1862 | 1862 | } |
1863 | 1863 | |
1864 | 1864 | |
@@ -1873,13 +1873,13 @@ discard block |
||
1873 | 1873 | * @param string $linked_input_id The css id of the input that the shortcodes get added to. |
1874 | 1874 | * @return string |
1875 | 1875 | */ |
1876 | - protected function _get_shortcode_selector( $field, $linked_input_id ) { |
|
1876 | + protected function _get_shortcode_selector($field, $linked_input_id) { |
|
1877 | 1877 | $template_args = array( |
1878 | - 'shortcodes' => $this->_get_shortcodes( array( $field ), true ), |
|
1878 | + 'shortcodes' => $this->_get_shortcodes(array($field), true), |
|
1879 | 1879 | 'fieldname' => $field, |
1880 | 1880 | 'linked_input_id' => $linked_input_id |
1881 | 1881 | ); |
1882 | - return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true ); |
|
1882 | + return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true); |
|
1883 | 1883 | } |
1884 | 1884 | |
1885 | 1885 | |
@@ -1894,13 +1894,13 @@ discard block |
||
1894 | 1894 | $shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set |
1895 | 1895 | //$messenger = $this->_message_template_group->messenger_obj(); |
1896 | 1896 | //now let's set the content depending on the status of the shortcodes array |
1897 | - if ( empty( $shortcodes ) ) { |
|
1898 | - $content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>'; |
|
1897 | + if (empty($shortcodes)) { |
|
1898 | + $content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>'; |
|
1899 | 1899 | echo $content; |
1900 | 1900 | } else { |
1901 | 1901 | //$alt = 0; |
1902 | 1902 | ?> |
1903 | - <div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf( __('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso' ), '<span class="dashicons dashicons-menu"></span>' ); ?></p> |
|
1903 | + <div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf(__('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso'), '<span class="dashicons dashicons-menu"></span>'); ?></p> |
|
1904 | 1904 | <?php |
1905 | 1905 | } |
1906 | 1906 | |
@@ -1917,7 +1917,7 @@ discard block |
||
1917 | 1917 | protected function _set_shortcodes() { |
1918 | 1918 | |
1919 | 1919 | //no need to run this if the property is already set |
1920 | - if ( !empty($this->_shortcodes ) ) {return;} |
|
1920 | + if ( ! empty($this->_shortcodes)) {return; } |
|
1921 | 1921 | |
1922 | 1922 | $this->_shortcodes = $this->_get_shortcodes(); |
1923 | 1923 | } |
@@ -1939,14 +1939,14 @@ discard block |
||
1939 | 1939 | * @return array Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true |
1940 | 1940 | * just an array of shortcode/label pairs. |
1941 | 1941 | */ |
1942 | - protected function _get_shortcodes( $fields = array(), $merged = true ) { |
|
1942 | + protected function _get_shortcodes($fields = array(), $merged = true) { |
|
1943 | 1943 | $this->_set_message_template_group(); |
1944 | 1944 | |
1945 | 1945 | //we need the messenger and message template to retrieve the valid shortcodes array. |
1946 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false; |
|
1947 | - $context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() ); |
|
1946 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false; |
|
1947 | + $context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config()); |
|
1948 | 1948 | |
1949 | - return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array(); |
|
1949 | + return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array(); |
|
1950 | 1950 | } |
1951 | 1951 | |
1952 | 1952 | |
@@ -1959,19 +1959,19 @@ discard block |
||
1959 | 1959 | */ |
1960 | 1960 | protected function _set_message_template_group() { |
1961 | 1961 | |
1962 | - if ( !empty( $this->_message_template_group ) ) |
|
1963 | - {return;} //get out if this is already set. |
|
1962 | + if ( ! empty($this->_message_template_group)) |
|
1963 | + {return; } //get out if this is already set. |
|
1964 | 1964 | |
1965 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : false; |
|
1966 | - $GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID; |
|
1965 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false; |
|
1966 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID; |
|
1967 | 1967 | |
1968 | 1968 | //let's get the message templates |
1969 | 1969 | $MTP = EEM_Message_Template_Group::instance(); |
1970 | 1970 | |
1971 | - if ( empty($GRP_ID) ) |
|
1972 | - {$this->_message_template_group = $MTP->create_default_object();} |
|
1971 | + if (empty($GRP_ID)) |
|
1972 | + {$this->_message_template_group = $MTP->create_default_object(); } |
|
1973 | 1973 | else |
1974 | - {$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );} |
|
1974 | + {$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID); } |
|
1975 | 1975 | |
1976 | 1976 | $this->_template_pack = $this->_message_template_group->get_template_pack(); |
1977 | 1977 | $this->_variation = $this->_message_template_group->get_template_pack_variation(); |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | * @param array $args various things the context switcher needs. |
1991 | 1991 | * |
1992 | 1992 | */ |
1993 | - protected function _set_context_switcher( EE_Message_Template_Group $template_group_object, $args) { |
|
1993 | + protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args) { |
|
1994 | 1994 | $context_details = $template_group_object->contexts_config(); |
1995 | 1995 | $context_label = $template_group_object->context_label(); |
1996 | 1996 | ob_start(); |
@@ -1998,20 +1998,20 @@ discard block |
||
1998 | 1998 | <div class="ee-msg-switcher-container"> |
1999 | 1999 | <form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm"> |
2000 | 2000 | <?php |
2001 | - foreach ( $args as $name => $value ) { |
|
2002 | - if ( $name == 'context' || empty($value) || $name == 'extra' ) {continue;} |
|
2001 | + foreach ($args as $name => $value) { |
|
2002 | + if ($name == 'context' || empty($value) || $name == 'extra') {continue; } |
|
2003 | 2003 | ?> |
2004 | 2004 | <input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" /> |
2005 | 2005 | <?php |
2006 | 2006 | } |
2007 | 2007 | //setup nonce_url |
2008 | - wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false); |
|
2008 | + wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false); |
|
2009 | 2009 | ?> |
2010 | 2010 | <select name="context"> |
2011 | 2011 | <?php |
2012 | 2012 | $context_templates = $template_group_object->context_templates(); |
2013 | - if ( is_array($context_templates) ) : |
|
2014 | - foreach ( $context_templates as $context => $template_fields ) : |
|
2013 | + if (is_array($context_templates)) : |
|
2014 | + foreach ($context_templates as $context => $template_fields) : |
|
2015 | 2015 | $checked = ($context == $args['context']) ? 'selected="selected"' : ''; |
2016 | 2016 | ?> |
2017 | 2017 | <option value="<?php echo $context; ?>" <?php echo $checked; ?>> |
@@ -2019,7 +2019,7 @@ discard block |
||
2019 | 2019 | </option> |
2020 | 2020 | <?php endforeach; endif; ?> |
2021 | 2021 | </select> |
2022 | - <?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?> |
|
2022 | + <?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?> |
|
2023 | 2023 | <input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>"> |
2024 | 2024 | </form> |
2025 | 2025 | <?php echo $args['extra']; ?> |
@@ -2046,8 +2046,8 @@ discard block |
||
2046 | 2046 | * @return array |
2047 | 2047 | */ |
2048 | 2048 | protected function _set_message_template_column_values($index) { |
2049 | - if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) { |
|
2050 | - foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) { |
|
2049 | + if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) { |
|
2050 | + foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) { |
|
2051 | 2051 | $this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value; |
2052 | 2052 | } |
2053 | 2053 | } /*else { |
@@ -2056,22 +2056,22 @@ discard block |
||
2056 | 2056 | |
2057 | 2057 | |
2058 | 2058 | $set_column_values = array( |
2059 | - 'MTP_ID' => absint( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'MTP_ID' ] ), |
|
2060 | - 'GRP_ID' => absint( $this->_req_data[ 'GRP_ID' ] ), |
|
2061 | - 'MTP_user_id' => absint( $this->_req_data[ 'MTP_user_id' ] ), |
|
2062 | - 'MTP_messenger' => strtolower( $this->_req_data[ 'MTP_messenger' ] ), |
|
2063 | - 'MTP_message_type' => strtolower( $this->_req_data[ 'MTP_message_type' ] ), |
|
2064 | - 'MTP_template_field' => strtolower( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'name' ] ), |
|
2065 | - 'MTP_context' => strtolower( $this->_req_data[ 'MTP_context' ] ), |
|
2066 | - 'MTP_content' => $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'content' ], |
|
2067 | - 'MTP_is_global' => isset( $this->_req_data[ 'MTP_is_global' ] ) |
|
2068 | - ? absint( $this->_req_data[ 'MTP_is_global' ] ) |
|
2059 | + 'MTP_ID' => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']), |
|
2060 | + 'GRP_ID' => absint($this->_req_data['GRP_ID']), |
|
2061 | + 'MTP_user_id' => absint($this->_req_data['MTP_user_id']), |
|
2062 | + 'MTP_messenger' => strtolower($this->_req_data['MTP_messenger']), |
|
2063 | + 'MTP_message_type' => strtolower($this->_req_data['MTP_message_type']), |
|
2064 | + 'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']), |
|
2065 | + 'MTP_context' => strtolower($this->_req_data['MTP_context']), |
|
2066 | + 'MTP_content' => $this->_req_data['MTP_template_fields'][$index]['content'], |
|
2067 | + 'MTP_is_global' => isset($this->_req_data['MTP_is_global']) |
|
2068 | + ? absint($this->_req_data['MTP_is_global']) |
|
2069 | 2069 | : 0, |
2070 | - 'MTP_is_override' => isset( $this->_req_data[ 'MTP_is_override' ] ) |
|
2071 | - ? absint( $this->_req_data[ 'MTP_is_override' ] ) |
|
2070 | + 'MTP_is_override' => isset($this->_req_data['MTP_is_override']) |
|
2071 | + ? absint($this->_req_data['MTP_is_override']) |
|
2072 | 2072 | : 0, |
2073 | - 'MTP_deleted' => absint( $this->_req_data[ 'MTP_deleted' ] ), |
|
2074 | - 'MTP_is_active' => absint( $this->_req_data[ 'MTP_is_active' ] ) |
|
2073 | + 'MTP_deleted' => absint($this->_req_data['MTP_deleted']), |
|
2074 | + 'MTP_is_active' => absint($this->_req_data['MTP_is_active']) |
|
2075 | 2075 | ); |
2076 | 2076 | |
2077 | 2077 | |
@@ -2083,36 +2083,36 @@ discard block |
||
2083 | 2083 | |
2084 | 2084 | |
2085 | 2085 | |
2086 | - protected function _insert_or_update_message_template($new = false ) { |
|
2086 | + protected function _insert_or_update_message_template($new = false) { |
|
2087 | 2087 | |
2088 | - do_action ( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2088 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2089 | 2089 | $success = 0; |
2090 | 2090 | $override = false; |
2091 | 2091 | |
2092 | 2092 | //setup notices description |
2093 | - $messenger = ! empty( $this->_req_data['MTP_messenger'] ) |
|
2094 | - ? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_messenger'] ) ) |
|
2093 | + $messenger = ! empty($this->_req_data['MTP_messenger']) |
|
2094 | + ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'])) |
|
2095 | 2095 | : false; |
2096 | 2096 | |
2097 | - $message_type = ! empty( $this->_req_data['MTP_message_type'] ) |
|
2098 | - ? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_message_type'] ) ) |
|
2097 | + $message_type = ! empty($this->_req_data['MTP_message_type']) |
|
2098 | + ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'])) |
|
2099 | 2099 | : false; |
2100 | 2100 | |
2101 | - $context = ! empty( $this->_req_data['MTP_context'] ) |
|
2102 | - ? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_context'] ) ) |
|
2101 | + $context = ! empty($this->_req_data['MTP_context']) |
|
2102 | + ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'])) |
|
2103 | 2103 | : false; |
2104 | 2104 | |
2105 | - $item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : ''; |
|
2105 | + $item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : ''; |
|
2106 | 2106 | $item_desc .= 'Message Template'; |
2107 | 2107 | $query_args = array(); |
2108 | 2108 | $edit_array = array(); |
2109 | 2109 | $action_desc = ''; |
2110 | 2110 | |
2111 | 2111 | //if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit. |
2112 | - if ( $new ) { |
|
2113 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
2114 | - if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) { |
|
2115 | - if ( empty($edit_array) ) { |
|
2112 | + if ($new) { |
|
2113 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
2114 | + if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) { |
|
2115 | + if (empty($edit_array)) { |
|
2116 | 2116 | $success = 0; |
2117 | 2117 | } else { |
2118 | 2118 | $success = 1; |
@@ -2131,7 +2131,7 @@ discard block |
||
2131 | 2131 | |
2132 | 2132 | |
2133 | 2133 | //run update for each template field in displayed context |
2134 | - if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) { |
|
2134 | + if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) { |
|
2135 | 2135 | EE_Error::add_error( |
2136 | 2136 | __('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), |
2137 | 2137 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2140,25 +2140,25 @@ discard block |
||
2140 | 2140 | |
2141 | 2141 | } else { |
2142 | 2142 | //first validate all fields! |
2143 | - $validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2143 | + $validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2144 | 2144 | |
2145 | 2145 | //if $validate returned error messages (i.e. is_array()) then we need to process them and setup an appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array. WE need to make sure there is no actual error messages in validates. |
2146 | - if ( is_array($validates) && !empty($validates) ) { |
|
2146 | + if (is_array($validates) && ! empty($validates)) { |
|
2147 | 2147 | //add the transient so when the form loads we know which fields to highlight |
2148 | - $this->_add_transient( 'edit_message_template', $validates ); |
|
2148 | + $this->_add_transient('edit_message_template', $validates); |
|
2149 | 2149 | |
2150 | 2150 | $success = 0; |
2151 | 2151 | |
2152 | 2152 | //setup notices |
2153 | - foreach ( $validates as $field => $error ) { |
|
2154 | - if ( isset($error['msg'] ) ) { |
|
2155 | - EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ ); |
|
2153 | + foreach ($validates as $field => $error) { |
|
2154 | + if (isset($error['msg'])) { |
|
2155 | + EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__); |
|
2156 | 2156 | } |
2157 | 2157 | } |
2158 | 2158 | |
2159 | 2159 | } else { |
2160 | 2160 | $set_column_values = array(); |
2161 | - foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) { |
|
2161 | + foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) { |
|
2162 | 2162 | $set_column_values = $this->_set_message_template_column_values($template_field); |
2163 | 2163 | |
2164 | 2164 | $where_cols_n_values = array( |
@@ -2171,11 +2171,11 @@ discard block |
||
2171 | 2171 | 'MTP_context' => $set_column_values['MTP_context'], |
2172 | 2172 | 'MTP_content' => $set_column_values['MTP_content'] |
2173 | 2173 | ); |
2174 | - if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) { |
|
2175 | - if ( $updated === false ) { |
|
2174 | + if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) { |
|
2175 | + if ($updated === false) { |
|
2176 | 2176 | EE_Error::add_error( |
2177 | 2177 | sprintf( |
2178 | - __( '%s field was NOT updated for some reason', 'event_espresso' ), |
|
2178 | + __('%s field was NOT updated for some reason', 'event_espresso'), |
|
2179 | 2179 | $template_field |
2180 | 2180 | ), |
2181 | 2181 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2189,46 +2189,46 @@ discard block |
||
2189 | 2189 | |
2190 | 2190 | //we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs) |
2191 | 2191 | $mtpg_fields = array( |
2192 | - 'MTP_user_id' => $set_column_values[ 'MTP_user_id' ], |
|
2193 | - 'MTP_messenger' => $set_column_values[ 'MTP_messenger' ], |
|
2194 | - 'MTP_message_type' => $set_column_values[ 'MTP_message_type' ], |
|
2195 | - 'MTP_is_global' => $set_column_values[ 'MTP_is_global' ], |
|
2196 | - 'MTP_is_override' => $set_column_values[ 'MTP_is_override' ], |
|
2197 | - 'MTP_deleted' => $set_column_values[ 'MTP_deleted' ], |
|
2198 | - 'MTP_is_active' => $set_column_values[ 'MTP_is_active' ], |
|
2199 | - 'MTP_name' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] ) |
|
2200 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] |
|
2192 | + 'MTP_user_id' => $set_column_values['MTP_user_id'], |
|
2193 | + 'MTP_messenger' => $set_column_values['MTP_messenger'], |
|
2194 | + 'MTP_message_type' => $set_column_values['MTP_message_type'], |
|
2195 | + 'MTP_is_global' => $set_column_values['MTP_is_global'], |
|
2196 | + 'MTP_is_override' => $set_column_values['MTP_is_override'], |
|
2197 | + 'MTP_deleted' => $set_column_values['MTP_deleted'], |
|
2198 | + 'MTP_is_active' => $set_column_values['MTP_is_active'], |
|
2199 | + 'MTP_name' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name']) |
|
2200 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] |
|
2201 | 2201 | : '', |
2202 | - 'MTP_description' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] ) |
|
2203 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] |
|
2202 | + 'MTP_description' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description']) |
|
2203 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] |
|
2204 | 2204 | : '' |
2205 | 2205 | ); |
2206 | 2206 | |
2207 | - $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] ); |
|
2208 | - $updated = $MTPG->update( $mtpg_fields, array($mtpg_where) ); |
|
2207 | + $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']); |
|
2208 | + $updated = $MTPG->update($mtpg_fields, array($mtpg_where)); |
|
2209 | 2209 | |
2210 | - if ( $updated === false ) { |
|
2210 | + if ($updated === false) { |
|
2211 | 2211 | EE_Error::add_error( |
2212 | 2212 | sprintf( |
2213 | - __( 'The Message Template Group (%d) was NOT updated for some reason', 'event_espresso' ), |
|
2214 | - $set_column_values[ 'GRP_ID' ] |
|
2213 | + __('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), |
|
2214 | + $set_column_values['GRP_ID'] |
|
2215 | 2215 | ), |
2216 | 2216 | __FILE__, __FUNCTION__, __LINE__ |
2217 | 2217 | ); |
2218 | 2218 | } else { |
2219 | 2219 | //k now we need to ensure the template_pack and template_variation fields are set. |
2220 | - $template_pack = ! empty( $this->_req_data['MTP_template_pack' ] ) |
|
2220 | + $template_pack = ! empty($this->_req_data['MTP_template_pack']) |
|
2221 | 2221 | ? $this->_req_data['MTP_template_pack'] |
2222 | 2222 | : 'default'; |
2223 | 2223 | |
2224 | - $template_variation = ! empty( $this->_req_data['MTP_template_variation'] ) |
|
2224 | + $template_variation = ! empty($this->_req_data['MTP_template_variation']) |
|
2225 | 2225 | ? $this->_req_data['MTP_template_variation'] |
2226 | 2226 | : 'default'; |
2227 | 2227 | |
2228 | - $mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] ); |
|
2229 | - if ( $mtpg_obj instanceof EE_Message_Template_Group ) { |
|
2230 | - $mtpg_obj->set_template_pack_name( $template_pack ); |
|
2231 | - $mtpg_obj->set_template_pack_variation( $template_variation ); |
|
2228 | + $mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']); |
|
2229 | + if ($mtpg_obj instanceof EE_Message_Template_Group) { |
|
2230 | + $mtpg_obj->set_template_pack_name($template_pack); |
|
2231 | + $mtpg_obj->set_template_pack_variation($template_variation); |
|
2232 | 2232 | } |
2233 | 2233 | $success = 1; |
2234 | 2234 | } |
@@ -2238,7 +2238,7 @@ discard block |
||
2238 | 2238 | } |
2239 | 2239 | |
2240 | 2240 | //we return things differently if doing ajax |
2241 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
2241 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2242 | 2242 | $this->_template_args['success'] = $success; |
2243 | 2243 | $this->_template_args['error'] = ! $success ? true : false; |
2244 | 2244 | $this->_template_args['content'] = ''; |
@@ -2246,9 +2246,9 @@ discard block |
||
2246 | 2246 | 'grpID' => $edit_array['GRP_ID'], |
2247 | 2247 | 'templateName' => $edit_array['template_name'] |
2248 | 2248 | ); |
2249 | - if ( $success ) { |
|
2249 | + if ($success) { |
|
2250 | 2250 | EE_Error::overwrite_success(); |
2251 | - EE_Error::add_success( __('The new template has been created and automatically selected for this event. You can edit the new template by clicking the edit button. Note before this template is assigned to this event, the event must be saved.', 'event_espresso') ); |
|
2251 | + EE_Error::add_success(__('The new template has been created and automatically selected for this event. You can edit the new template by clicking the edit button. Note before this template is assigned to this event, the event must be saved.', 'event_espresso')); |
|
2252 | 2252 | } |
2253 | 2253 | |
2254 | 2254 | $this->_return_json(); |
@@ -2256,13 +2256,13 @@ discard block |
||
2256 | 2256 | |
2257 | 2257 | |
2258 | 2258 | //was a test send triggered? |
2259 | - if ( isset( $this->_req_data['test_button'] ) ) { |
|
2259 | + if (isset($this->_req_data['test_button'])) { |
|
2260 | 2260 | EE_Error::overwrite_success(); |
2261 | - $this->_do_test_send( $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] ); |
|
2261 | + $this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2262 | 2262 | $override = true; |
2263 | 2263 | } |
2264 | 2264 | |
2265 | - if ( empty( $query_args ) ) { |
|
2265 | + if (empty($query_args)) { |
|
2266 | 2266 | $query_args = array( |
2267 | 2267 | 'id' => $this->_req_data['GRP_ID'], |
2268 | 2268 | 'context' => $this->_req_data['MTP_context'], |
@@ -2270,7 +2270,7 @@ discard block |
||
2270 | 2270 | ); |
2271 | 2271 | } |
2272 | 2272 | |
2273 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override ); |
|
2273 | + $this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override); |
|
2274 | 2274 | } |
2275 | 2275 | |
2276 | 2276 | |
@@ -2284,28 +2284,28 @@ discard block |
||
2284 | 2284 | * @param string $message_type message type being tested |
2285 | 2285 | * |
2286 | 2286 | */ |
2287 | - protected function _do_test_send( $context, $messenger, $message_type ) { |
|
2287 | + protected function _do_test_send($context, $messenger, $message_type) { |
|
2288 | 2288 | //set things up for preview |
2289 | 2289 | $this->_req_data['messenger'] = $messenger; |
2290 | 2290 | $this->_req_data['message_type'] = $message_type; |
2291 | 2291 | $this->_req_data['context'] = $context; |
2292 | - $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : ''; |
|
2293 | - $active_messenger = $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
2292 | + $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : ''; |
|
2293 | + $active_messenger = $this->_message_resource_manager->get_active_messenger($messenger); |
|
2294 | 2294 | |
2295 | 2295 | //let's save any existing fields that might be required by the messenger |
2296 | 2296 | if ( |
2297 | - isset( $this->_req_data['test_settings_fld'] ) |
|
2297 | + isset($this->_req_data['test_settings_fld']) |
|
2298 | 2298 | && $active_messenger instanceof EE_messenger |
2299 | 2299 | ) { |
2300 | - $active_messenger->set_existing_test_settings( $this->_req_data['test_settings_fld'] ); |
|
2300 | + $active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']); |
|
2301 | 2301 | } |
2302 | 2302 | |
2303 | 2303 | $success = $this->_preview_message(true); |
2304 | 2304 | |
2305 | - if ( $success ) { |
|
2306 | - EE_Error::add_success( __('Test message sent', 'event_espresso') ); |
|
2305 | + if ($success) { |
|
2306 | + EE_Error::add_success(__('Test message sent', 'event_espresso')); |
|
2307 | 2307 | } else { |
2308 | - EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2308 | + EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2309 | 2309 | } |
2310 | 2310 | } |
2311 | 2311 | |
@@ -2331,11 +2331,11 @@ discard block |
||
2331 | 2331 | protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
2332 | 2332 | |
2333 | 2333 | //if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we just don't generate any templates. |
2334 | - if ( empty( $message_types ) ) { |
|
2334 | + if (empty($message_types)) { |
|
2335 | 2335 | return true; |
2336 | 2336 | } |
2337 | 2337 | |
2338 | - return EEH_MSG_Template::generate_new_templates( $messenger, $message_types, $GRP_ID, $global ); |
|
2338 | + return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global); |
|
2339 | 2339 | } |
2340 | 2340 | |
2341 | 2341 | |
@@ -2351,33 +2351,33 @@ discard block |
||
2351 | 2351 | * |
2352 | 2352 | * @return void |
2353 | 2353 | */ |
2354 | - protected function _trash_or_restore_message_template($trash = true, $all = false ) { |
|
2355 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2354 | + protected function _trash_or_restore_message_template($trash = true, $all = false) { |
|
2355 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2356 | 2356 | $MTP = EEM_Message_Template_Group::instance(); |
2357 | 2357 | |
2358 | 2358 | $success = 1; |
2359 | 2359 | |
2360 | 2360 | //incoming GRP_IDs |
2361 | - if ( $all ) { |
|
2361 | + if ($all) { |
|
2362 | 2362 | //Checkboxes |
2363 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) { |
|
2363 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2364 | 2364 | //if array has more than one element then success message should be plural. |
2365 | 2365 | //todo: what about nonce? |
2366 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2366 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2367 | 2367 | |
2368 | 2368 | //cycle through checkboxes |
2369 | - while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) { |
|
2370 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2371 | - if ( ! $trashed_or_restored ) { |
|
2369 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2370 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2371 | + if ( ! $trashed_or_restored) { |
|
2372 | 2372 | $success = 0; |
2373 | 2373 | } |
2374 | 2374 | } |
2375 | 2375 | } else { |
2376 | 2376 | //grab single GRP_ID and handle |
2377 | - $GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0; |
|
2378 | - if ( ! empty( $GRP_ID ) ) { |
|
2379 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2380 | - if ( ! $trashed_or_restored ) { |
|
2377 | + $GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0; |
|
2378 | + if ( ! empty($GRP_ID)) { |
|
2379 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2380 | + if ( ! $trashed_or_restored) { |
|
2381 | 2381 | $success = 0; |
2382 | 2382 | } |
2383 | 2383 | } else { |
@@ -2389,13 +2389,13 @@ discard block |
||
2389 | 2389 | |
2390 | 2390 | $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
2391 | 2391 | |
2392 | - $action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc; |
|
2392 | + $action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc; |
|
2393 | 2393 | |
2394 | 2394 | $item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso'); |
2395 | 2395 | |
2396 | - $item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2396 | + $item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2397 | 2397 | |
2398 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, array() ); |
|
2398 | + $this->_redirect_after_action($success, $item_desc, $action_desc, array()); |
|
2399 | 2399 | |
2400 | 2400 | } |
2401 | 2401 | |
@@ -2411,24 +2411,24 @@ discard block |
||
2411 | 2411 | * @return void |
2412 | 2412 | */ |
2413 | 2413 | protected function _delete_message_template() { |
2414 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2414 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2415 | 2415 | |
2416 | 2416 | //checkboxes |
2417 | - if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) { |
|
2417 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2418 | 2418 | //if array has more than one element then success message should be plural |
2419 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2419 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2420 | 2420 | |
2421 | 2421 | //cycle through bulk action checkboxes |
2422 | - while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) { |
|
2423 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2422 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2423 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2424 | 2424 | } |
2425 | 2425 | } else { |
2426 | 2426 | //grab single grp_id and delete |
2427 | - $GRP_ID = absint($this->_req_data['id'] ); |
|
2428 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2427 | + $GRP_ID = absint($this->_req_data['id']); |
|
2428 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2429 | 2429 | } |
2430 | 2430 | |
2431 | - $this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() ); |
|
2431 | + $this->_redirect_after_action($success, 'Message Templates', 'deleted', array()); |
|
2432 | 2432 | |
2433 | 2433 | } |
2434 | 2434 | |
@@ -2443,20 +2443,20 @@ discard block |
||
2443 | 2443 | * |
2444 | 2444 | * @return bool boolean to indicate the success of the deletes or not. |
2445 | 2445 | */ |
2446 | - private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) { |
|
2446 | + private function _delete_mtp_permanently($GRP_ID, $include_group = true) { |
|
2447 | 2447 | $success = 1; |
2448 | 2448 | $MTPG = EEM_Message_Template_Group::instance(); |
2449 | 2449 | //first let's GET this group |
2450 | - $MTG = $MTPG->get_one_by_ID( $GRP_ID ); |
|
2450 | + $MTG = $MTPG->get_one_by_ID($GRP_ID); |
|
2451 | 2451 | //then delete permanently all the related Message Templates |
2452 | - $deleted = $MTG->delete_related_permanently( 'Message_Template' ); |
|
2452 | + $deleted = $MTG->delete_related_permanently('Message_Template'); |
|
2453 | 2453 | |
2454 | - if ( $deleted === 0 ) |
|
2455 | - {$success = 0;} |
|
2454 | + if ($deleted === 0) |
|
2455 | + {$success = 0; } |
|
2456 | 2456 | |
2457 | 2457 | //now delete permanently this particular group |
2458 | 2458 | |
2459 | - if ( $include_group && ! $MTG->delete_permanently() ) { |
|
2459 | + if ($include_group && ! $MTG->delete_permanently()) { |
|
2460 | 2460 | $success = 0; |
2461 | 2461 | } |
2462 | 2462 | return $success; |
@@ -2474,7 +2474,7 @@ discard block |
||
2474 | 2474 | * @return string |
2475 | 2475 | */ |
2476 | 2476 | protected function _learn_more_about_message_templates_link() { |
2477 | - return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>'; |
|
2477 | + return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>'; |
|
2478 | 2478 | } |
2479 | 2479 | |
2480 | 2480 | |
@@ -2489,14 +2489,14 @@ discard block |
||
2489 | 2489 | */ |
2490 | 2490 | protected function _settings() { |
2491 | 2491 | |
2492 | - EE_Registry::instance()->load_helper( 'Tabbed_Content' ); |
|
2492 | + EE_Registry::instance()->load_helper('Tabbed_Content'); |
|
2493 | 2493 | |
2494 | 2494 | $this->_set_m_mt_settings(); |
2495 | 2495 | |
2496 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2496 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2497 | 2497 | |
2498 | 2498 | //let's setup the messenger tabs |
2499 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger ); |
|
2499 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger); |
|
2500 | 2500 | $this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">'; |
2501 | 2501 | $this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->'; |
2502 | 2502 | |
@@ -2515,7 +2515,7 @@ discard block |
||
2515 | 2515 | */ |
2516 | 2516 | protected function _set_m_mt_settings() { |
2517 | 2517 | //first if this is already set then lets get out no need to regenerate data. |
2518 | - if ( !empty($this->_m_mt_settings) ) { |
|
2518 | + if ( ! empty($this->_m_mt_settings)) { |
|
2519 | 2519 | return; |
2520 | 2520 | } |
2521 | 2521 | |
@@ -2530,10 +2530,10 @@ discard block |
||
2530 | 2530 | |
2531 | 2531 | //assemble the array for the _tab_text_links helper |
2532 | 2532 | |
2533 | - foreach ( $messengers as $messenger ) { |
|
2533 | + foreach ($messengers as $messenger) { |
|
2534 | 2534 | $this->_m_mt_settings['messenger_tabs'][$messenger->name] = array( |
2535 | 2535 | 'label' => ucwords($messenger->label['singular']), |
2536 | - 'class' => $this->_message_resource_manager->is_messenger_active( $messenger->name ) ? 'messenger-active' : '', |
|
2536 | + 'class' => $this->_message_resource_manager->is_messenger_active($messenger->name) ? 'messenger-active' : '', |
|
2537 | 2537 | 'href' => $messenger->name, |
2538 | 2538 | 'title' => __('Modify this Messenger', 'event_espresso'), |
2539 | 2539 | 'slug' => $messenger->name, |
@@ -2543,26 +2543,26 @@ discard block |
||
2543 | 2543 | |
2544 | 2544 | $message_types_for_messenger = $messenger->get_valid_message_types(); |
2545 | 2545 | |
2546 | - foreach ( $message_types as $message_type ) { |
|
2546 | + foreach ($message_types as $message_type) { |
|
2547 | 2547 | //first we need to verify that this message type is valid with this messenger. Cause if it isn't then it shouldn't show in either the inactive OR active metabox. |
2548 | - if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) { |
|
2548 | + if ( ! in_array($message_type->name, $message_types_for_messenger)) { |
|
2549 | 2549 | continue; |
2550 | 2550 | } |
2551 | 2551 | |
2552 | - $a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) ? 'active' : 'inactive'; |
|
2552 | + $a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger($messenger->name, $message_type->name) ? 'active' : 'inactive'; |
|
2553 | 2553 | |
2554 | 2554 | $this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array( |
2555 | - 'label' => ucwords( $message_type->label[ 'singular' ] ), |
|
2556 | - 'class' => 'message-type-' . $a_or_i, |
|
2557 | - 'slug_id' => $message_type->name . '-messagetype-' . $messenger->name, |
|
2558 | - 'mt_nonce' => wp_create_nonce( $message_type->name . '_nonce' ), |
|
2559 | - 'href' => 'espresso_' . $message_type->name . '_message_type_settings', |
|
2555 | + 'label' => ucwords($message_type->label['singular']), |
|
2556 | + 'class' => 'message-type-'.$a_or_i, |
|
2557 | + 'slug_id' => $message_type->name.'-messagetype-'.$messenger->name, |
|
2558 | + 'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'), |
|
2559 | + 'href' => 'espresso_'.$message_type->name.'_message_type_settings', |
|
2560 | 2560 | 'title' => $a_or_i == 'active' |
2561 | - ? __( 'Drag this message type to the Inactive window to deactivate', 'event_espresso' ) |
|
2562 | - : __( 'Drag this message type to the messenger to activate', 'event_espresso' ), |
|
2561 | + ? __('Drag this message type to the Inactive window to deactivate', 'event_espresso') |
|
2562 | + : __('Drag this message type to the messenger to activate', 'event_espresso'), |
|
2563 | 2563 | 'content' => $a_or_i == 'active' |
2564 | - ? $this->_message_type_settings_content( $message_type, $messenger, true ) |
|
2565 | - : $this->_message_type_settings_content( $message_type, $messenger ), |
|
2564 | + ? $this->_message_type_settings_content($message_type, $messenger, true) |
|
2565 | + : $this->_message_type_settings_content($message_type, $messenger), |
|
2566 | 2566 | 'slug' => $message_type->name, |
2567 | 2567 | 'active' => $a_or_i == 'active' ? true : false, |
2568 | 2568 | 'obj' => $message_type |
@@ -2581,34 +2581,34 @@ discard block |
||
2581 | 2581 | * |
2582 | 2582 | * @return string html output for the content |
2583 | 2583 | */ |
2584 | - protected function _message_type_settings_content( $message_type, $messenger, $active = false ) { |
|
2584 | + protected function _message_type_settings_content($message_type, $messenger, $active = false) { |
|
2585 | 2585 | //get message type fields |
2586 | 2586 | $fields = $message_type->get_admin_settings_fields(); |
2587 | - $settings_template_args['template_form_fields']= ''; |
|
2587 | + $settings_template_args['template_form_fields'] = ''; |
|
2588 | 2588 | |
2589 | - if ( !empty( $fields ) && $active ) { |
|
2589 | + if ( ! empty($fields) && $active) { |
|
2590 | 2590 | |
2591 | - $existing_settings = $message_type->get_existing_admin_settings( $messenger->name ); |
|
2591 | + $existing_settings = $message_type->get_existing_admin_settings($messenger->name); |
|
2592 | 2592 | |
2593 | - foreach( $fields as $fldname => $fldprops ) { |
|
2594 | - $field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname; |
|
2593 | + foreach ($fields as $fldname => $fldprops) { |
|
2594 | + $field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname; |
|
2595 | 2595 | $template_form_field[$field_id] = array( |
2596 | - 'name' => 'message_type_settings[' . $fldname . ']', |
|
2596 | + 'name' => 'message_type_settings['.$fldname.']', |
|
2597 | 2597 | 'label' => $fldprops['label'], |
2598 | 2598 | 'input' => $fldprops['field_type'], |
2599 | 2599 | 'type' => $fldprops['value_type'], |
2600 | 2600 | 'required' => $fldprops['required'], |
2601 | 2601 | 'validation' => $fldprops['validation'], |
2602 | - 'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2603 | - 'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(), |
|
2604 | - 'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2602 | + 'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2603 | + 'options' => isset($fldprops['options']) ? $fldprops['options'] : array(), |
|
2604 | + 'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2605 | 2605 | 'css_class' => 'no-drag', |
2606 | 2606 | 'format' => $fldprops['format'] |
2607 | 2607 | ); |
2608 | 2608 | } |
2609 | 2609 | |
2610 | 2610 | |
2611 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : ''; |
|
2611 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : ''; |
|
2612 | 2612 | } |
2613 | 2613 | |
2614 | 2614 | $settings_template_args['description'] = $message_type->description; |
@@ -2628,13 +2628,13 @@ discard block |
||
2628 | 2628 | ) |
2629 | 2629 | ); |
2630 | 2630 | |
2631 | - $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' ); |
|
2632 | - $settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : ''; |
|
2631 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array'); |
|
2632 | + $settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : ''; |
|
2633 | 2633 | |
2634 | 2634 | |
2635 | 2635 | |
2636 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php'; |
|
2637 | - $content = EEH_Template::display_template( $template, $settings_template_args, true ); |
|
2636 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php'; |
|
2637 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2638 | 2638 | return $content; |
2639 | 2639 | } |
2640 | 2640 | |
@@ -2651,27 +2651,27 @@ discard block |
||
2651 | 2651 | $m_boxes = $mt_boxes = array(); |
2652 | 2652 | $m_template_args = $mt_template_args = array(); |
2653 | 2653 | |
2654 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2654 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2655 | 2655 | |
2656 | - if ( isset( $this->_m_mt_settings[ 'messenger_tabs' ] ) ) { |
|
2657 | - foreach ( $this->_m_mt_settings[ 'messenger_tabs' ] as $messenger => $tab_array ) { |
|
2658 | - $hide_on_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? '' : 'hidden'; |
|
2659 | - $hide_off_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? 'hidden' : ''; |
|
2656 | + if (isset($this->_m_mt_settings['messenger_tabs'])) { |
|
2657 | + foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) { |
|
2658 | + $hide_on_message = $this->_message_resource_manager->is_messenger_active($messenger) ? '' : 'hidden'; |
|
2659 | + $hide_off_message = $this->_message_resource_manager->is_messenger_active($messenger) ? 'hidden' : ''; |
|
2660 | 2660 | //messenger meta boxes |
2661 | 2661 | $active = $selected_messenger == $messenger ? true : false; |
2662 | - $active_mt_tabs = isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ] ) |
|
2663 | - ? $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ] |
|
2662 | + $active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active']) |
|
2663 | + ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] |
|
2664 | 2664 | : ''; |
2665 | - $m_boxes[ $messenger . '_a_box' ] = sprintf( |
|
2666 | - __( '%s Settings', 'event_espresso' ), |
|
2667 | - $tab_array[ 'label' ] |
|
2665 | + $m_boxes[$messenger.'_a_box'] = sprintf( |
|
2666 | + __('%s Settings', 'event_espresso'), |
|
2667 | + $tab_array['label'] |
|
2668 | 2668 | ); |
2669 | - $m_template_args[ $messenger . '_a_box' ] = array( |
|
2670 | - 'active_message_types' => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2671 | - 'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2672 | - ? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2669 | + $m_template_args[$messenger.'_a_box'] = array( |
|
2670 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2671 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2672 | + ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2673 | 2673 | : '', |
2674 | - 'content' => $this->_get_messenger_box_content( $tab_array[ 'obj' ] ), |
|
2674 | + 'content' => $this->_get_messenger_box_content($tab_array['obj']), |
|
2675 | 2675 | 'hidden' => $active ? '' : ' hidden', |
2676 | 2676 | 'hide_on_message' => $hide_on_message, |
2677 | 2677 | 'messenger' => $messenger, |
@@ -2680,11 +2680,11 @@ discard block |
||
2680 | 2680 | // message type meta boxes |
2681 | 2681 | // (which is really just the inactive container for each messenger |
2682 | 2682 | // showing inactive message types for that messenger) |
2683 | - $mt_boxes[ $messenger . '_i_box' ] = __( 'Inactive Message Types', 'event_espresso' ); |
|
2684 | - $mt_template_args[ $messenger . '_i_box' ] = array( |
|
2685 | - 'active_message_types' => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2686 | - 'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2687 | - ? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2683 | + $mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
2684 | + $mt_template_args[$messenger.'_i_box'] = array( |
|
2685 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2686 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2687 | + ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2688 | 2688 | : '', |
2689 | 2689 | 'hidden' => $active ? '' : ' hidden', |
2690 | 2690 | 'hide_on_message' => $hide_on_message, |
@@ -2697,12 +2697,12 @@ discard block |
||
2697 | 2697 | |
2698 | 2698 | |
2699 | 2699 | //register messenger metaboxes |
2700 | - $m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2701 | - foreach ( $m_boxes as $box => $label ) { |
|
2702 | - $callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] ); |
|
2703 | - $msgr = str_replace( '_a_box', '', $box ); |
|
2700 | + $m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2701 | + foreach ($m_boxes as $box => $label) { |
|
2702 | + $callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]); |
|
2703 | + $msgr = str_replace('_a_box', '', $box); |
|
2704 | 2704 | add_meta_box( |
2705 | - 'espresso_' . $msgr . '_settings', |
|
2705 | + 'espresso_'.$msgr.'_settings', |
|
2706 | 2706 | $label, |
2707 | 2707 | create_function( |
2708 | 2708 | '$post, $metabox', |
@@ -2716,14 +2716,14 @@ discard block |
||
2716 | 2716 | } |
2717 | 2717 | |
2718 | 2718 | //register message type metaboxes |
2719 | - $mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php'; |
|
2720 | - foreach ( $mt_boxes as $box => $label ) { |
|
2719 | + $mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php'; |
|
2720 | + foreach ($mt_boxes as $box => $label) { |
|
2721 | 2721 | $callback_args = array( |
2722 | - 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[ $box ] |
|
2722 | + 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box] |
|
2723 | 2723 | ); |
2724 | - $mt = str_replace( '_i_box', '', $box ); |
|
2724 | + $mt = str_replace('_i_box', '', $box); |
|
2725 | 2725 | add_meta_box( |
2726 | - 'espresso_' . $mt . '_inactive_mts', |
|
2726 | + 'espresso_'.$mt.'_inactive_mts', |
|
2727 | 2727 | $label, |
2728 | 2728 | create_function( |
2729 | 2729 | '$post, $metabox', |
@@ -2746,13 +2746,13 @@ discard block |
||
2746 | 2746 | * |
2747 | 2747 | * @return string html formatted tabs |
2748 | 2748 | */ |
2749 | - protected function _get_mt_tabs( $tab_array ) { |
|
2749 | + protected function _get_mt_tabs($tab_array) { |
|
2750 | 2750 | $tab_array = (array) $tab_array; |
2751 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2751 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2752 | 2752 | $tabs = ''; |
2753 | 2753 | |
2754 | - foreach ( $tab_array as $tab ) { |
|
2755 | - $tabs .= EEH_Template::display_template( $template, $tab, true ); |
|
2754 | + foreach ($tab_array as $tab) { |
|
2755 | + $tabs .= EEH_Template::display_template($template, $tab, true); |
|
2756 | 2756 | } |
2757 | 2757 | |
2758 | 2758 | return $tabs; |
@@ -2768,29 +2768,29 @@ discard block |
||
2768 | 2768 | * |
2769 | 2769 | * @return string html formatted content |
2770 | 2770 | */ |
2771 | - protected function _get_messenger_box_content( EE_messenger $messenger ) { |
|
2771 | + protected function _get_messenger_box_content(EE_messenger $messenger) { |
|
2772 | 2772 | |
2773 | 2773 | $fields = $messenger->get_admin_settings_fields(); |
2774 | 2774 | $settings_template_args['template_form_fields'] = ''; |
2775 | 2775 | |
2776 | 2776 | //is $messenger active? |
2777 | - $settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active( $messenger->name ); |
|
2777 | + $settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active($messenger->name); |
|
2778 | 2778 | |
2779 | 2779 | |
2780 | - if ( ! empty( $fields ) ) { |
|
2780 | + if ( ! empty($fields)) { |
|
2781 | 2781 | |
2782 | 2782 | $existing_settings = $messenger->get_existing_admin_settings(); |
2783 | 2783 | |
2784 | - foreach( $fields as $fldname => $fldprops ) { |
|
2785 | - $field_id = $messenger->name . '-' . $fldname; |
|
2784 | + foreach ($fields as $fldname => $fldprops) { |
|
2785 | + $field_id = $messenger->name.'-'.$fldname; |
|
2786 | 2786 | $template_form_field[$field_id] = array( |
2787 | - 'name' => 'messenger_settings[' . $field_id . ']', |
|
2787 | + 'name' => 'messenger_settings['.$field_id.']', |
|
2788 | 2788 | 'label' => $fldprops['label'], |
2789 | 2789 | 'input' => $fldprops['field_type'], |
2790 | 2790 | 'type' => $fldprops['value_type'], |
2791 | 2791 | 'required' => $fldprops['required'], |
2792 | 2792 | 'validation' => $fldprops['validation'], |
2793 | - 'value' => isset( $existing_settings[$field_id]) |
|
2793 | + 'value' => isset($existing_settings[$field_id]) |
|
2794 | 2794 | ? $existing_settings[$field_id] |
2795 | 2795 | : $fldprops['default'], |
2796 | 2796 | 'css_class' => '', |
@@ -2799,8 +2799,8 @@ discard block |
||
2799 | 2799 | } |
2800 | 2800 | |
2801 | 2801 | |
2802 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) |
|
2803 | - ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' ) |
|
2802 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) |
|
2803 | + ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form') |
|
2804 | 2804 | : ''; |
2805 | 2805 | } |
2806 | 2806 | |
@@ -2817,39 +2817,39 @@ discard block |
||
2817 | 2817 | ); |
2818 | 2818 | |
2819 | 2819 | //make sure any active message types that are existing are included in the hidden fields |
2820 | - if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) { |
|
2821 | - foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) { |
|
2820 | + if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) { |
|
2821 | + foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) { |
|
2822 | 2822 | $settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array( |
2823 | 2823 | 'type' => 'hidden', |
2824 | 2824 | 'value' => $mt |
2825 | 2825 | ); |
2826 | 2826 | } |
2827 | 2827 | } |
2828 | - $settings_template_args[ 'hidden_fields' ] = $this->_generate_admin_form_fields( |
|
2829 | - $settings_template_args[ 'hidden_fields' ], |
|
2828 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( |
|
2829 | + $settings_template_args['hidden_fields'], |
|
2830 | 2830 | 'array' |
2831 | 2831 | ); |
2832 | - $active = $this->_message_resource_manager->is_messenger_active( $messenger->name ); |
|
2832 | + $active = $this->_message_resource_manager->is_messenger_active($messenger->name); |
|
2833 | 2833 | |
2834 | 2834 | $settings_template_args['messenger'] = $messenger->name; |
2835 | 2835 | $settings_template_args['description'] = $messenger->description; |
2836 | 2836 | $settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden'; |
2837 | 2837 | |
2838 | 2838 | |
2839 | - $settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active( $messenger->name ) |
|
2839 | + $settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active($messenger->name) |
|
2840 | 2840 | ? $settings_template_args['show_hide_edit_form'] |
2841 | 2841 | : ' hidden'; |
2842 | 2842 | |
2843 | - $settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] ) |
|
2843 | + $settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields']) |
|
2844 | 2844 | ? ' hidden' |
2845 | 2845 | : $settings_template_args['show_hide_edit_form']; |
2846 | 2846 | |
2847 | 2847 | |
2848 | 2848 | $settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on'; |
2849 | - $settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce'); |
|
2849 | + $settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce'); |
|
2850 | 2850 | $settings_template_args['on_off_status'] = $active ? true : false; |
2851 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php'; |
|
2852 | - $content = EEH_Template::display_template( $template, $settings_template_args, true); |
|
2851 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php'; |
|
2852 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2853 | 2853 | return $content; |
2854 | 2854 | } |
2855 | 2855 | |
@@ -2863,9 +2863,9 @@ discard block |
||
2863 | 2863 | $success = true; |
2864 | 2864 | $this->_prep_default_response_for_messenger_or_message_type_toggle(); |
2865 | 2865 | //let's check that we have required data |
2866 | - if ( !isset( $this->_req_data[ 'messenger' ] ) ) { |
|
2866 | + if ( ! isset($this->_req_data['messenger'])) { |
|
2867 | 2867 | EE_Error::add_error( |
2868 | - __( 'Messenger name needed to toggle activation. None given', 'event_espresso' ), |
|
2868 | + __('Messenger name needed to toggle activation. None given', 'event_espresso'), |
|
2869 | 2869 | __FILE__, |
2870 | 2870 | __FUNCTION__, |
2871 | 2871 | __LINE__ |
@@ -2874,14 +2874,14 @@ discard block |
||
2874 | 2874 | } |
2875 | 2875 | |
2876 | 2876 | //do a nonce check here since we're not arriving via a normal route |
2877 | - $nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : ''; |
|
2878 | - $nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce'; |
|
2877 | + $nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : ''; |
|
2878 | + $nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce'; |
|
2879 | 2879 | |
2880 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
2880 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
2881 | 2881 | |
2882 | 2882 | |
2883 | 2883 | |
2884 | - if ( !isset( $this->_req_data[ 'status' ])) { |
|
2884 | + if ( ! isset($this->_req_data['status'])) { |
|
2885 | 2885 | EE_Error::add_error( |
2886 | 2886 | __( |
2887 | 2887 | 'Messenger status needed to know whether activation or deactivation is happening. No status is given', |
@@ -2897,11 +2897,11 @@ discard block |
||
2897 | 2897 | //do check to verify we have a valid status. |
2898 | 2898 | $status = $this->_req_data['status']; |
2899 | 2899 | |
2900 | - if ( $status != 'off' && $status != 'on' ) { |
|
2900 | + if ($status != 'off' && $status != 'on') { |
|
2901 | 2901 | EE_Error::add_error( |
2902 | 2902 | sprintf( |
2903 | - __( 'The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso' ), |
|
2904 | - $this->_req_data[ 'status' ] |
|
2903 | + __('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), |
|
2904 | + $this->_req_data['status'] |
|
2905 | 2905 | ), |
2906 | 2906 | __FILE__, |
2907 | 2907 | __FUNCTION__, |
@@ -2910,11 +2910,11 @@ discard block |
||
2910 | 2910 | $success = false; |
2911 | 2911 | } |
2912 | 2912 | |
2913 | - if ( $success ) { |
|
2913 | + if ($success) { |
|
2914 | 2914 | //made it here? Stop dawdling then!! |
2915 | 2915 | $success = $status == 'off' |
2916 | - ? $this->_deactivate_messenger( $this->_req_data['messenger'] ) |
|
2917 | - : $this->_activate_messenger( $this->_req_data['messenger'] ); |
|
2916 | + ? $this->_deactivate_messenger($this->_req_data['messenger']) |
|
2917 | + : $this->_activate_messenger($this->_req_data['messenger']); |
|
2918 | 2918 | } |
2919 | 2919 | |
2920 | 2920 | $this->_template_args['success'] = $success; |
@@ -2937,7 +2937,7 @@ discard block |
||
2937 | 2937 | $this->_prep_default_response_for_messenger_or_message_type_toggle(); |
2938 | 2938 | |
2939 | 2939 | //let's make sure we have the necessary data |
2940 | - if ( ! isset( $this->_req_data[ 'message_type' ] ) ) { |
|
2940 | + if ( ! isset($this->_req_data['message_type'])) { |
|
2941 | 2941 | EE_Error::add_error( |
2942 | 2942 | __('Message Type name needed to toggle activation. None given', 'event_espresso'), |
2943 | 2943 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2945,7 +2945,7 @@ discard block |
||
2945 | 2945 | $success = false; |
2946 | 2946 | } |
2947 | 2947 | |
2948 | - if ( ! isset( $this->_req_data[ 'messenger' ] ) ) { |
|
2948 | + if ( ! isset($this->_req_data['messenger'])) { |
|
2949 | 2949 | EE_Error::add_error( |
2950 | 2950 | __('Messenger name needed to toggle activation. None given', 'event_espresso'), |
2951 | 2951 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2953,7 +2953,7 @@ discard block |
||
2953 | 2953 | $success = false; |
2954 | 2954 | } |
2955 | 2955 | |
2956 | - if ( ! isset( $this->_req_data[ 'status' ])) { |
|
2956 | + if ( ! isset($this->_req_data['status'])) { |
|
2957 | 2957 | EE_Error::add_error( |
2958 | 2958 | __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), |
2959 | 2959 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2965,7 +2965,7 @@ discard block |
||
2965 | 2965 | //do check to verify we have a valid status. |
2966 | 2966 | $status = $this->_req_data['status']; |
2967 | 2967 | |
2968 | - if ( $status != 'activate' && $status != 'deactivate' ) { |
|
2968 | + if ($status != 'activate' && $status != 'deactivate') { |
|
2969 | 2969 | EE_Error::add_error( |
2970 | 2970 | sprintf( |
2971 | 2971 | __('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), |
@@ -2978,16 +2978,16 @@ discard block |
||
2978 | 2978 | |
2979 | 2979 | |
2980 | 2980 | //do a nonce check here since we're not arriving via a normal route |
2981 | - $nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : ''; |
|
2982 | - $nonce_ref = $this->_req_data['message_type'] . '_nonce'; |
|
2981 | + $nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : ''; |
|
2982 | + $nonce_ref = $this->_req_data['message_type'].'_nonce'; |
|
2983 | 2983 | |
2984 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
2984 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
2985 | 2985 | |
2986 | - if ( $success ) { |
|
2986 | + if ($success) { |
|
2987 | 2987 | //made it here? um, what are you waiting for then? |
2988 | 2988 | $success = $status == 'deactivate' |
2989 | - ? $this->_deactivate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] ) |
|
2990 | - : $this->_activate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] ); |
|
2989 | + ? $this->_deactivate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type']) |
|
2990 | + : $this->_activate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type']); |
|
2991 | 2991 | } |
2992 | 2992 | |
2993 | 2993 | $this->_template_args['success'] = $success; |
@@ -3001,30 +3001,30 @@ discard block |
||
3001 | 3001 | * @param string $messenger_name The name of the messenger being activated |
3002 | 3002 | * @return bool |
3003 | 3003 | */ |
3004 | - protected function _activate_messenger( $messenger_name ) { |
|
3004 | + protected function _activate_messenger($messenger_name) { |
|
3005 | 3005 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3006 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3006 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3007 | 3007 | $message_types_to_activate = $active_messenger instanceof EE_Messenger ? $active_messenger->get_default_message_types() : array(); |
3008 | 3008 | |
3009 | 3009 | //ensure is active |
3010 | - $this->_message_resource_manager->activate_messenger( $messenger_name, $message_types_to_activate ); |
|
3010 | + $this->_message_resource_manager->activate_messenger($messenger_name, $message_types_to_activate); |
|
3011 | 3011 | |
3012 | 3012 | //set response_data for reload |
3013 | - foreach( $message_types_to_activate as $message_type_name ) { |
|
3013 | + foreach ($message_types_to_activate as $message_type_name) { |
|
3014 | 3014 | /** @var EE_message_type $message_type */ |
3015 | - $message_type = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3016 | - if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) |
|
3015 | + $message_type = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3016 | + if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name) |
|
3017 | 3017 | && $message_type instanceof EE_message_type |
3018 | 3018 | ) { |
3019 | 3019 | $this->_template_args['data']['active_mts'][] = $message_type_name; |
3020 | - if ( $message_type->get_admin_settings_fields() ) { |
|
3020 | + if ($message_type->get_admin_settings_fields()) { |
|
3021 | 3021 | $this->_template_args['data']['mt_reload'][] = $message_type_name; |
3022 | 3022 | } |
3023 | 3023 | } |
3024 | 3024 | } |
3025 | 3025 | |
3026 | 3026 | //add success message for activating messenger |
3027 | - return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger ); |
|
3027 | + return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger); |
|
3028 | 3028 | |
3029 | 3029 | } |
3030 | 3030 | |
@@ -3035,11 +3035,11 @@ discard block |
||
3035 | 3035 | * @param string $messenger_name The name of the messenger being activated |
3036 | 3036 | * @return bool |
3037 | 3037 | */ |
3038 | - protected function _deactivate_messenger( $messenger_name ) { |
|
3038 | + protected function _deactivate_messenger($messenger_name) { |
|
3039 | 3039 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3040 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3041 | - $this->_message_resource_manager->deactivate_messenger( $messenger_name ); |
|
3042 | - return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger ); |
|
3040 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3041 | + $this->_message_resource_manager->deactivate_messenger($messenger_name); |
|
3042 | + return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger); |
|
3043 | 3043 | } |
3044 | 3044 | |
3045 | 3045 | |
@@ -3050,23 +3050,23 @@ discard block |
||
3050 | 3050 | * @param string $message_type_name The name of the message type being activated for the messenger |
3051 | 3051 | * @return bool |
3052 | 3052 | */ |
3053 | - protected function _activate_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
3053 | + protected function _activate_message_type_for_messenger($messenger_name, $message_type_name) { |
|
3054 | 3054 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3055 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3055 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3056 | 3056 | /** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/ |
3057 | - $message_type_to_activate = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3057 | + $message_type_to_activate = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3058 | 3058 | |
3059 | 3059 | //ensure is active |
3060 | - $this->_message_resource_manager->activate_messenger( $messenger_name, $message_type_name ); |
|
3060 | + $this->_message_resource_manager->activate_messenger($messenger_name, $message_type_name); |
|
3061 | 3061 | |
3062 | 3062 | //set response for load |
3063 | - if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
3063 | + if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
3064 | 3064 | $this->_template_args['data']['active_mts'][] = $message_type_name; |
3065 | - if ( $message_type_to_activate->get_admin_settings_fields() ) { |
|
3065 | + if ($message_type_to_activate->get_admin_settings_fields()) { |
|
3066 | 3066 | $this->_template_args['data']['mt_reload'][] = $message_type_name; |
3067 | 3067 | } |
3068 | 3068 | } |
3069 | - return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger, $message_type_to_activate ); |
|
3069 | + return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger, $message_type_to_activate); |
|
3070 | 3070 | } |
3071 | 3071 | |
3072 | 3072 | |
@@ -3078,13 +3078,13 @@ discard block |
||
3078 | 3078 | * @param string $message_type_name The name of the message type being deactivated for the messenger |
3079 | 3079 | * @return bool |
3080 | 3080 | */ |
3081 | - protected function _deactivate_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
3081 | + protected function _deactivate_message_type_for_messenger($messenger_name, $message_type_name) { |
|
3082 | 3082 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3083 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3083 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3084 | 3084 | /** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/ |
3085 | - $message_type_to_deactivate = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3086 | - $this->_message_resource_manager->deactivate_message_type_for_messenger( $message_type_name, $messenger_name ); |
|
3087 | - return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger, $message_type_to_deactivate ); |
|
3085 | + $message_type_to_deactivate = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3086 | + $this->_message_resource_manager->deactivate_message_type_for_messenger($message_type_name, $messenger_name); |
|
3087 | + return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger, $message_type_to_deactivate); |
|
3088 | 3088 | } |
3089 | 3089 | |
3090 | 3090 | |
@@ -3115,9 +3115,9 @@ discard block |
||
3115 | 3115 | EE_Message_Type $message_type = null |
3116 | 3116 | ) { |
3117 | 3117 | //if $messenger isn't a valid messenger object then get out. |
3118 | - if ( ! $messenger instanceof EE_Messenger ) { |
|
3118 | + if ( ! $messenger instanceof EE_Messenger) { |
|
3119 | 3119 | EE_Error::add_error( |
3120 | - __( 'The messenger being activated is not a valid messenger', 'event_espresso' ), |
|
3120 | + __('The messenger being activated is not a valid messenger', 'event_espresso'), |
|
3121 | 3121 | __FILE__, |
3122 | 3122 | __FUNCTION__, |
3123 | 3123 | __LINE__ |
@@ -3125,32 +3125,32 @@ discard block |
||
3125 | 3125 | return false; |
3126 | 3126 | } |
3127 | 3127 | //activated |
3128 | - if ( $this->_template_args['data']['active_mts'] ) { |
|
3128 | + if ($this->_template_args['data']['active_mts']) { |
|
3129 | 3129 | EE_Error::overwrite_success(); |
3130 | 3130 | //activated a message type with the messenger |
3131 | - if ( $message_type instanceof EE_message_type ) { |
|
3131 | + if ($message_type instanceof EE_message_type) { |
|
3132 | 3132 | EE_Error::add_success( |
3133 | 3133 | sprintf( |
3134 | 3134 | __('%s message type has been successfully activated with the %s messenger', 'event_espresso'), |
3135 | - ucwords( $message_type->label['singular'] ), |
|
3136 | - ucwords( $messenger->label['singular'] ) |
|
3135 | + ucwords($message_type->label['singular']), |
|
3136 | + ucwords($messenger->label['singular']) |
|
3137 | 3137 | ) |
3138 | 3138 | ); |
3139 | 3139 | |
3140 | 3140 | //if message type was invoice then let's make sure we activate the invoice payment method. |
3141 | - if ( $message_type->name == 'invoice' ) { |
|
3142 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
3143 | - $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
3144 | - if ( $pm instanceof EE_Payment_Method ) { |
|
3145 | - EE_Error::add_attention( __('Activating the invoice message type also automatically activates the invoice payment method. If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso' ) ); |
|
3141 | + if ($message_type->name == 'invoice') { |
|
3142 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
3143 | + $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
3144 | + if ($pm instanceof EE_Payment_Method) { |
|
3145 | + EE_Error::add_attention(__('Activating the invoice message type also automatically activates the invoice payment method. If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso')); |
|
3146 | 3146 | } |
3147 | 3147 | } |
3148 | 3148 | //just toggles the entire messenger |
3149 | 3149 | } else { |
3150 | 3150 | EE_Error::add_success( |
3151 | 3151 | sprintf( |
3152 | - __( '%s messenger has been successfully activated', 'event_espresso' ), |
|
3153 | - ucwords( $messenger->label[ 'singular' ] ) |
|
3152 | + __('%s messenger has been successfully activated', 'event_espresso'), |
|
3153 | + ucwords($messenger->label['singular']) |
|
3154 | 3154 | ) |
3155 | 3155 | ); |
3156 | 3156 | } |
@@ -3160,12 +3160,12 @@ discard block |
||
3160 | 3160 | //message types after the activation process. However its possible some messengers don't HAVE any default_message_types |
3161 | 3161 | //in which case we just give a success message for the messenger being successfully activated. |
3162 | 3162 | } else { |
3163 | - if ( ! $messenger->get_default_message_types() ) { |
|
3163 | + if ( ! $messenger->get_default_message_types()) { |
|
3164 | 3164 | //messenger doesn't have any default message types so still a success. |
3165 | 3165 | EE_Error::add_success( |
3166 | 3166 | sprintf( |
3167 | - __('%s messenger was successfully activated.', 'event_espresso' ), |
|
3168 | - ucwords( $messenger->label['singular'] ) |
|
3167 | + __('%s messenger was successfully activated.', 'event_espresso'), |
|
3168 | + ucwords($messenger->label['singular']) |
|
3169 | 3169 | ) |
3170 | 3170 | ); |
3171 | 3171 | return true; |
@@ -3173,13 +3173,13 @@ discard block |
||
3173 | 3173 | EE_Error::add_error( |
3174 | 3174 | $message_type instanceof EE_message_type |
3175 | 3175 | ? sprintf( |
3176 | - __( '%s message type was not successfully activated with the %s messenger', 'event_espresso' ), |
|
3177 | - ucwords( $message_type->label['singular'] ), |
|
3178 | - ucwords( $messenger->label['singular'] ) |
|
3176 | + __('%s message type was not successfully activated with the %s messenger', 'event_espresso'), |
|
3177 | + ucwords($message_type->label['singular']), |
|
3178 | + ucwords($messenger->label['singular']) |
|
3179 | 3179 | ) |
3180 | 3180 | : sprintf( |
3181 | - __( '%s messenger was not successfully activated', 'event_espresso' ), |
|
3182 | - ucwords( $messenger->label['singular'] ) |
|
3181 | + __('%s messenger was not successfully activated', 'event_espresso'), |
|
3182 | + ucwords($messenger->label['singular']) |
|
3183 | 3183 | ), |
3184 | 3184 | __FILE__, |
3185 | 3185 | __FUNCTION__, |
@@ -3207,9 +3207,9 @@ discard block |
||
3207 | 3207 | EE_Error::overwrite_success(); |
3208 | 3208 | |
3209 | 3209 | //if $messenger isn't a valid messenger object then get out. |
3210 | - if ( ! $messenger instanceof EE_Messenger ) { |
|
3210 | + if ( ! $messenger instanceof EE_Messenger) { |
|
3211 | 3211 | EE_Error::add_error( |
3212 | - __( 'The messenger being deactivated is not a valid messenger', 'event_espresso' ), |
|
3212 | + __('The messenger being deactivated is not a valid messenger', 'event_espresso'), |
|
3213 | 3213 | __FILE__, |
3214 | 3214 | __FUNCTION__, |
3215 | 3215 | __LINE__ |
@@ -3217,13 +3217,13 @@ discard block |
||
3217 | 3217 | return false; |
3218 | 3218 | } |
3219 | 3219 | |
3220 | - if ( $message_type instanceof EE_message_type ) { |
|
3220 | + if ($message_type instanceof EE_message_type) { |
|
3221 | 3221 | $message_type_name = $message_type->name; |
3222 | 3222 | EE_Error::add_success( |
3223 | 3223 | sprintf( |
3224 | 3224 | __('%s message type has been successfully deactivated for the %s messenger.', 'event_espresso'), |
3225 | - ucwords( $message_type->label['singular'] ), |
|
3226 | - ucwords ( $messenger->label['singular'] ) |
|
3225 | + ucwords($message_type->label['singular']), |
|
3226 | + ucwords($messenger->label['singular']) |
|
3227 | 3227 | ) |
3228 | 3228 | ); |
3229 | 3229 | } else { |
@@ -3231,20 +3231,20 @@ discard block |
||
3231 | 3231 | EE_Error::add_success( |
3232 | 3232 | sprintf( |
3233 | 3233 | __('%s messenger has been successfully deactivated.', 'event_espresso'), |
3234 | - ucwords( $messenger->label['singular'] ) |
|
3234 | + ucwords($messenger->label['singular']) |
|
3235 | 3235 | ) |
3236 | 3236 | ); |
3237 | 3237 | } |
3238 | 3238 | |
3239 | 3239 | //if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method. |
3240 | - if ( $messenger->name == 'html' || $message_type_name == 'invoice') { |
|
3241 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
3242 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' ); |
|
3243 | - if ( $count_updated > 0 ) { |
|
3240 | + if ($messenger->name == 'html' || $message_type_name == 'invoice') { |
|
3241 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
3242 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice'); |
|
3243 | + if ($count_updated > 0) { |
|
3244 | 3244 | $msg = $message_type_name == 'invoice' |
3245 | - ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' ) |
|
3246 | - : __('Deactivating the html messenger also automatically deactivates the invoice payment method. In order for invoices to be generated the html messenger must be be active. If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' ); |
|
3247 | - EE_Error::add_attention( $msg ); |
|
3245 | + ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso') |
|
3246 | + : __('Deactivating the html messenger also automatically deactivates the invoice payment method. In order for invoices to be generated the html messenger must be be active. If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso'); |
|
3247 | + EE_Error::add_attention($msg); |
|
3248 | 3248 | } |
3249 | 3249 | } |
3250 | 3250 | return true; |
@@ -3255,17 +3255,17 @@ discard block |
||
3255 | 3255 | * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax) |
3256 | 3256 | */ |
3257 | 3257 | public function update_mt_form() { |
3258 | - if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) { |
|
3259 | - EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3258 | + if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) { |
|
3259 | + EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__); |
|
3260 | 3260 | $this->_return_json(); |
3261 | 3261 | } |
3262 | 3262 | |
3263 | 3263 | $message_types = $this->get_installed_message_types(); |
3264 | 3264 | |
3265 | - $message_type = $message_types[ $this->_req_data['message_type'] ]; |
|
3266 | - $messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
3265 | + $message_type = $message_types[$this->_req_data['message_type']]; |
|
3266 | + $messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
3267 | 3267 | |
3268 | - $content = $this->_message_type_settings_content ( $message_type, $messenger, true ); |
|
3268 | + $content = $this->_message_type_settings_content($message_type, $messenger, true); |
|
3269 | 3269 | $this->_template_args['success'] = true; |
3270 | 3270 | $this->_template_args['content'] = $content; |
3271 | 3271 | $this->_return_json(); |
@@ -3279,45 +3279,45 @@ discard block |
||
3279 | 3279 | * |
3280 | 3280 | */ |
3281 | 3281 | public function save_settings() { |
3282 | - if ( !isset( $this->_req_data['type'] ) ) { |
|
3283 | - EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3282 | + if ( ! isset($this->_req_data['type'])) { |
|
3283 | + EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3284 | 3284 | $this->_template_args['error'] = true; |
3285 | 3285 | $this->_return_json(); |
3286 | 3286 | } |
3287 | 3287 | |
3288 | 3288 | |
3289 | - if ( $this->_req_data['type'] == 'messenger' ) { |
|
3289 | + if ($this->_req_data['type'] == 'messenger') { |
|
3290 | 3290 | $settings = $this->_req_data['messenger_settings']; //this should be an array. |
3291 | 3291 | $messenger = $settings['messenger']; |
3292 | 3292 | //let's setup the settings data |
3293 | - foreach ( $settings as $key => $value ) { |
|
3294 | - switch ( $key ) { |
|
3293 | + foreach ($settings as $key => $value) { |
|
3294 | + switch ($key) { |
|
3295 | 3295 | case 'messenger' : |
3296 | - unset( $settings['messenger'] ); |
|
3296 | + unset($settings['messenger']); |
|
3297 | 3297 | break; |
3298 | 3298 | case 'message_types' : |
3299 | - unset( $settings['message_types'] ); |
|
3299 | + unset($settings['message_types']); |
|
3300 | 3300 | break; |
3301 | 3301 | default : |
3302 | 3302 | $settings[$key] = $value; |
3303 | 3303 | break; |
3304 | 3304 | } |
3305 | 3305 | } |
3306 | - $this->_message_resource_manager->add_settings_for_messenger( $messenger, $settings ); |
|
3306 | + $this->_message_resource_manager->add_settings_for_messenger($messenger, $settings); |
|
3307 | 3307 | } |
3308 | 3308 | |
3309 | - else if ( $this->_req_data['type'] == 'message_type' ) { |
|
3309 | + else if ($this->_req_data['type'] == 'message_type') { |
|
3310 | 3310 | $settings = $this->_req_data['message_type_settings']; |
3311 | 3311 | $messenger = $settings['messenger']; |
3312 | 3312 | $message_type = $settings['message_type']; |
3313 | 3313 | |
3314 | - foreach ( $settings as $key => $value ) { |
|
3315 | - switch ( $key ) { |
|
3314 | + foreach ($settings as $key => $value) { |
|
3315 | + switch ($key) { |
|
3316 | 3316 | case 'messenger' : |
3317 | - unset( $settings['messenger'] ); |
|
3317 | + unset($settings['messenger']); |
|
3318 | 3318 | break; |
3319 | 3319 | case 'message_type' : |
3320 | - unset( $settings['message_type'] ); |
|
3320 | + unset($settings['message_type']); |
|
3321 | 3321 | break; |
3322 | 3322 | default : |
3323 | 3323 | $settings[$key] = $value; |
@@ -3325,16 +3325,16 @@ discard block |
||
3325 | 3325 | } |
3326 | 3326 | } |
3327 | 3327 | |
3328 | - $this->_message_resource_manager->add_settings_for_message_type( $messenger, $message_type, $settings ); |
|
3328 | + $this->_message_resource_manager->add_settings_for_message_type($messenger, $message_type, $settings); |
|
3329 | 3329 | } |
3330 | 3330 | |
3331 | 3331 | //okay we should have the data all setup. Now we just update! |
3332 | 3332 | $success = $this->_message_resource_manager->update_active_messengers_option(); |
3333 | 3333 | |
3334 | - if ( $success ) { |
|
3335 | - EE_Error::add_success( __('Settings updated', 'event_espresso') ); |
|
3334 | + if ($success) { |
|
3335 | + EE_Error::add_success(__('Settings updated', 'event_espresso')); |
|
3336 | 3336 | } else { |
3337 | - EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3337 | + EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3338 | 3338 | } |
3339 | 3339 | |
3340 | 3340 | $this->_template_args['success'] = $success; |
@@ -3356,8 +3356,8 @@ discard block |
||
3356 | 3356 | */ |
3357 | 3357 | protected function _generate_now() { |
3358 | 3358 | $msg_ids = $this->_get_msg_ids_from_request(); |
3359 | - EED_Messages::generate_now( $msg_ids ); |
|
3360 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3359 | + EED_Messages::generate_now($msg_ids); |
|
3360 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3361 | 3361 | } |
3362 | 3362 | |
3363 | 3363 | |
@@ -3372,7 +3372,7 @@ discard block |
||
3372 | 3372 | protected function _generate_and_send_now() { |
3373 | 3373 | $this->_generate_now(); |
3374 | 3374 | $this->_send_now(); |
3375 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3375 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3376 | 3376 | } |
3377 | 3377 | |
3378 | 3378 | |
@@ -3386,8 +3386,8 @@ discard block |
||
3386 | 3386 | */ |
3387 | 3387 | protected function _queue_for_resending() { |
3388 | 3388 | $msg_ids = $this->_get_msg_ids_from_request(); |
3389 | - EED_Messages::queue_for_resending( $msg_ids ); |
|
3390 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3389 | + EED_Messages::queue_for_resending($msg_ids); |
|
3390 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3391 | 3391 | } |
3392 | 3392 | |
3393 | 3393 | |
@@ -3400,8 +3400,8 @@ discard block |
||
3400 | 3400 | */ |
3401 | 3401 | protected function _send_now() { |
3402 | 3402 | $msg_ids = $this->_get_msg_ids_from_request(); |
3403 | - EED_Messages::send_now( $msg_ids ); |
|
3404 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3403 | + EED_Messages::send_now($msg_ids); |
|
3404 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3405 | 3405 | } |
3406 | 3406 | |
3407 | 3407 | |
@@ -3415,23 +3415,23 @@ discard block |
||
3415 | 3415 | protected function _delete_ee_messages() { |
3416 | 3416 | $msg_ids = $this->_get_msg_ids_from_request(); |
3417 | 3417 | $deleted_count = 0; |
3418 | - foreach ( $msg_ids as $msg_id ) { |
|
3419 | - if ( EEM_Message::instance()->delete_by_ID( $msg_id ) ) { |
|
3418 | + foreach ($msg_ids as $msg_id) { |
|
3419 | + if (EEM_Message::instance()->delete_by_ID($msg_id)) { |
|
3420 | 3420 | $deleted_count++; |
3421 | 3421 | } |
3422 | 3422 | } |
3423 | - if ( $deleted_count ) { |
|
3423 | + if ($deleted_count) { |
|
3424 | 3424 | $this->_redirect_after_action( |
3425 | 3425 | true, |
3426 | - _n( 'message', 'messages', $deleted_count, 'event_espresso' ), |
|
3426 | + _n('message', 'messages', $deleted_count, 'event_espresso'), |
|
3427 | 3427 | __('deleted', 'event_espresso') |
3428 | 3428 | ); |
3429 | 3429 | } else { |
3430 | 3430 | EE_Error::add_error( |
3431 | - _n( 'The message was not deleted.', 'The messages were not deleted', count( $msg_ids ), 'event_espresso' ), |
|
3431 | + _n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'), |
|
3432 | 3432 | __FILE__, __FUNCTION__, __LINE__ |
3433 | 3433 | ); |
3434 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3434 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3435 | 3435 | } |
3436 | 3436 | } |
3437 | 3437 | |
@@ -3444,10 +3444,10 @@ discard block |
||
3444 | 3444 | * @return array |
3445 | 3445 | */ |
3446 | 3446 | protected function _get_msg_ids_from_request() { |
3447 | - if ( ! isset( $this->_req_data['MSG_ID'] ) ) { |
|
3447 | + if ( ! isset($this->_req_data['MSG_ID'])) { |
|
3448 | 3448 | return array(); |
3449 | 3449 | } |
3450 | - return is_array( $this->_req_data['MSG_ID'] ) ? array_keys( $this->_req_data['MSG_ID'] ) : array( $this->_req_data['MSG_ID'] ); |
|
3450 | + return is_array($this->_req_data['MSG_ID']) ? array_keys($this->_req_data['MSG_ID']) : array($this->_req_data['MSG_ID']); |
|
3451 | 3451 | } |
3452 | 3452 | |
3453 | 3453 |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | protected function _set_tips_array() { |
19 | 19 | $this->_qtipsa = array( |
20 | 20 | 0 => array( |
21 | - 'content_id' => 'message_status-' . EEM_Message::status_sent, |
|
22 | - 'target' => '.msg-status-' . EEM_Message::status_sent, |
|
23 | - 'content' => $this->_message_status_legend( EEM_Message::status_sent ), |
|
21 | + 'content_id' => 'message_status-'.EEM_Message::status_sent, |
|
22 | + 'target' => '.msg-status-'.EEM_Message::status_sent, |
|
23 | + 'content' => $this->_message_status_legend(EEM_Message::status_sent), |
|
24 | 24 | 'options' => array( |
25 | 25 | 'position' => array( |
26 | 26 | 'target' => 'mouse', |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | ) |
29 | 29 | ), |
30 | 30 | 1 => array( |
31 | - 'content_id' => 'message_status-' . EEM_Message::status_idle, |
|
32 | - 'target' => '.msg-status-' . EEM_Message::status_idle, |
|
33 | - 'content' => $this->_message_status_legend( EEM_Message::status_idle ), |
|
31 | + 'content_id' => 'message_status-'.EEM_Message::status_idle, |
|
32 | + 'target' => '.msg-status-'.EEM_Message::status_idle, |
|
33 | + 'content' => $this->_message_status_legend(EEM_Message::status_idle), |
|
34 | 34 | 'options' => array( |
35 | 35 | 'position' => array( |
36 | 36 | 'target' => 'mouse', |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | ) |
39 | 39 | ), |
40 | 40 | 2 => array( |
41 | - 'content_id' => 'message_status-' . EEM_Message::status_failed, |
|
42 | - 'target' => '.msg-status-' . EEM_Message::status_failed, |
|
43 | - 'content' => $this->_message_status_legend( EEM_Message::status_failed ), |
|
41 | + 'content_id' => 'message_status-'.EEM_Message::status_failed, |
|
42 | + 'target' => '.msg-status-'.EEM_Message::status_failed, |
|
43 | + 'content' => $this->_message_status_legend(EEM_Message::status_failed), |
|
44 | 44 | 'options' => array( |
45 | 45 | 'position' => array( |
46 | 46 | 'target' => 'mouse', |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | ) |
49 | 49 | ), |
50 | 50 | 3 => array( |
51 | - 'content_id' => 'message_status-' . EEM_Message::status_resend, |
|
52 | - 'target' => '.msg-status-' . EEM_Message::status_resend, |
|
53 | - 'content' => $this->_message_status_legend( EEM_Message::status_resend ), |
|
51 | + 'content_id' => 'message_status-'.EEM_Message::status_resend, |
|
52 | + 'target' => '.msg-status-'.EEM_Message::status_resend, |
|
53 | + 'content' => $this->_message_status_legend(EEM_Message::status_resend), |
|
54 | 54 | 'options' => array( |
55 | 55 | 'position' => array( |
56 | 56 | 'target' => 'mouse', |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | ) |
59 | 59 | ), |
60 | 60 | 4 => array( |
61 | - 'content_id' => 'message_status-' . EEM_Message::status_incomplete, |
|
62 | - 'target' => '.msg-status-' . EEM_Message::status_incomplete, |
|
63 | - 'content' => $this->_message_status_legend( EEM_Message::status_incomplete ), |
|
61 | + 'content_id' => 'message_status-'.EEM_Message::status_incomplete, |
|
62 | + 'target' => '.msg-status-'.EEM_Message::status_incomplete, |
|
63 | + 'content' => $this->_message_status_legend(EEM_Message::status_incomplete), |
|
64 | 64 | 'options' => array( |
65 | 65 | 'position' => array( |
66 | 66 | 'target' => 'mouse', |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | ) |
69 | 69 | ), |
70 | 70 | 5 => array( |
71 | - 'content_id' => 'message_status-' . EEM_Message::status_retry, |
|
72 | - 'target' => '.msg-status-' . EEM_Message::status_retry, |
|
73 | - 'content' => $this->_message_status_legend( EEM_Message::status_retry ), |
|
71 | + 'content_id' => 'message_status-'.EEM_Message::status_retry, |
|
72 | + 'target' => '.msg-status-'.EEM_Message::status_retry, |
|
73 | + 'content' => $this->_message_status_legend(EEM_Message::status_retry), |
|
74 | 74 | 'options' => array( |
75 | 75 | 'position' => array( |
76 | 76 | 'target' => 'mouse', |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | ) |
79 | 79 | ), |
80 | 80 | 6 => array( |
81 | - 'content_id' => 'message_status-' . EEM_Message::status_debug_only, |
|
82 | - 'target' => '.msg-status-' . EEM_Message::status_debug_only, |
|
83 | - 'content' => $this->_message_status_legend( EEM_Message::status_debug_only ), |
|
81 | + 'content_id' => 'message_status-'.EEM_Message::status_debug_only, |
|
82 | + 'target' => '.msg-status-'.EEM_Message::status_debug_only, |
|
83 | + 'content' => $this->_message_status_legend(EEM_Message::status_debug_only), |
|
84 | 84 | 'options' => array( |
85 | 85 | 'position' => array( |
86 | 86 | 'target' => 'mouse', |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @param EEM_Message constant $status What status is set (by class) |
100 | 100 | * @return string The status legend with the related status highlighted |
101 | 101 | */ |
102 | - private function _message_status_legend( $status ) { |
|
102 | + private function _message_status_legend($status) { |
|
103 | 103 | |
104 | 104 | $status_array = array( |
105 | 105 | 'sent_status' => EEM_Message::status_sent, |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | 'retry_status' => EEM_Message::status_retry, |
111 | 111 | ); |
112 | 112 | |
113 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
113 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
114 | 114 | $status_array['debug_only_status'] = EEM_Message::status_debug_only; |
115 | 115 | } |
116 | 116 | |
117 | - return EEH_Template::status_legend( $status_array, $status ); |
|
117 | + return EEH_Template::status_legend($status_array, $status); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | |
28 | 28 | protected function _setup_data() { |
29 | - $this->_data = $this->_get_messages( $this->_per_page, $this->_view ); |
|
30 | - $this->_all_data_count = $this->_get_messages( $this->_per_page, $this->_view, true ); |
|
29 | + $this->_data = $this->_get_messages($this->_per_page, $this->_view); |
|
30 | + $this->_all_data_count = $this->_get_messages($this->_per_page, $this->_view, true); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | protected function _set_properties() { |
37 | 37 | $this->_wp_list_args = array( |
38 | - 'singular' => __( 'Message', 'event_espresso' ), |
|
39 | - 'plural' => __( 'Messages', 'event_espresso' ), |
|
38 | + 'singular' => __('Message', 'event_espresso'), |
|
39 | + 'plural' => __('Messages', 'event_espresso'), |
|
40 | 40 | 'ajax' => true, |
41 | 41 | 'screen' => $this->get_admin_page()->get_current_screen()->id |
42 | 42 | ); |
@@ -44,24 +44,24 @@ discard block |
||
44 | 44 | $this->_columns = array( |
45 | 45 | 'msg_status' => '', |
46 | 46 | 'cb' => '<input type="checkbox" />', |
47 | - 'msg_id' => __( 'ID', 'event_espresso' ), |
|
48 | - 'to' => __( 'To', 'event_espresso' ), |
|
49 | - 'from' => __( 'From', 'event_espresso' ), |
|
50 | - 'messenger' => __( 'Messenger', 'event_espresso' ), |
|
51 | - 'message_type' => __( 'Message Type', 'event_espresso' ), |
|
52 | - 'context' => __( 'Context', 'event_espresso' ), |
|
53 | - 'modified' => __( 'Modified', 'event_espresso' ), |
|
54 | - 'action' => __( 'Actions', 'event_espresso' ) |
|
47 | + 'msg_id' => __('ID', 'event_espresso'), |
|
48 | + 'to' => __('To', 'event_espresso'), |
|
49 | + 'from' => __('From', 'event_espresso'), |
|
50 | + 'messenger' => __('Messenger', 'event_espresso'), |
|
51 | + 'message_type' => __('Message Type', 'event_espresso'), |
|
52 | + 'context' => __('Context', 'event_espresso'), |
|
53 | + 'modified' => __('Modified', 'event_espresso'), |
|
54 | + 'action' => __('Actions', 'event_espresso') |
|
55 | 55 | ); |
56 | 56 | |
57 | 57 | $this->_sortable_columns = array( |
58 | - 'modified' => array( 'MSG_modified' => true ), |
|
59 | - 'msg_id' => array( 'MSG_ID', false ), |
|
60 | - 'message_type' => array( 'MSG_message_type' => false ), |
|
61 | - 'messenger' => array( 'MSG_messenger' => false ), |
|
62 | - 'to' => array( 'MSG_to' => false ), |
|
63 | - 'from' => array( 'MSG_from' => false ), |
|
64 | - 'context' => array( 'MSG_context' => false ) |
|
58 | + 'modified' => array('MSG_modified' => true), |
|
59 | + 'msg_id' => array('MSG_ID', false), |
|
60 | + 'message_type' => array('MSG_message_type' => false), |
|
61 | + 'messenger' => array('MSG_messenger' => false), |
|
62 | + 'to' => array('MSG_to' => false), |
|
63 | + 'from' => array('MSG_from' => false), |
|
64 | + 'context' => array('MSG_context' => false) |
|
65 | 65 | ); |
66 | 66 | |
67 | 67 | $this->_hidden_columns = array( |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | |
74 | 74 | protected function _get_table_filters() { |
75 | 75 | $filters = array(); |
76 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
76 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
77 | 77 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
78 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
78 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
79 | 79 | $contexts = $message_resource_manager->get_all_contexts(); |
80 | 80 | //setup messengers for selects |
81 | 81 | $m_values = $this->get_admin_page()->get_messengers_for_list_table(); |
@@ -84,70 +84,70 @@ discard block |
||
84 | 84 | //and the same for contexts |
85 | 85 | $i = 1; |
86 | 86 | $labels = $c_values = array(); |
87 | - foreach ( $contexts as $context => $label ) { |
|
87 | + foreach ($contexts as $context => $label) { |
|
88 | 88 | //some message types may have the same label for a different context, so we're grouping these together so the end user |
89 | 89 | //doesn't get confused. |
90 | - if ( isset( $labels[ $label ] ) ) { |
|
91 | - $c_values[ $labels[ $label ] ]['id'] .= ',' . $context; |
|
90 | + if (isset($labels[$label])) { |
|
91 | + $c_values[$labels[$label]]['id'] .= ','.$context; |
|
92 | 92 | continue; |
93 | 93 | } |
94 | - $c_values[ $i ]['id'] = $context; |
|
95 | - $c_values[ $i ]['text'] = $label; |
|
96 | - $labels[ $label ] = $i; |
|
94 | + $c_values[$i]['id'] = $context; |
|
95 | + $c_values[$i]['text'] = $label; |
|
96 | + $labels[$label] = $i; |
|
97 | 97 | $i++; |
98 | 98 | } |
99 | 99 | |
100 | 100 | $msgr_default[0] = array( |
101 | 101 | 'id' => 'none_selected', |
102 | - 'text' => __( 'All Messengers', 'event_espresso' ) |
|
102 | + 'text' => __('All Messengers', 'event_espresso') |
|
103 | 103 | ); |
104 | 104 | |
105 | 105 | $mt_default[0] = array( |
106 | 106 | 'id' => 'none_selected', |
107 | - 'text' => __( 'All Message Types', 'event_espresso' ) |
|
107 | + 'text' => __('All Message Types', 'event_espresso') |
|
108 | 108 | ); |
109 | 109 | |
110 | 110 | $c_default[0] = array( |
111 | 111 | 'id' => 'none_selected', |
112 | - 'text' => __( 'All Contexts', 'event_espresso ' ) |
|
112 | + 'text' => __('All Contexts', 'event_espresso ') |
|
113 | 113 | ); |
114 | 114 | |
115 | - $msgr_filters = ! empty( $m_values ) ? array_merge( $msgr_default, $m_values ) : array(); |
|
116 | - $mt_filters = ! empty( $mt_values ) ? array_merge( $mt_default, $mt_values ) : array(); |
|
117 | - $c_filters = ! empty( $c_values ) ? array_merge( $c_default, $c_values ): array(); |
|
115 | + $msgr_filters = ! empty($m_values) ? array_merge($msgr_default, $m_values) : array(); |
|
116 | + $mt_filters = ! empty($mt_values) ? array_merge($mt_default, $mt_values) : array(); |
|
117 | + $c_filters = ! empty($c_values) ? array_merge($c_default, $c_values) : array(); |
|
118 | 118 | |
119 | - if ( empty( $m_values ) ) { |
|
119 | + if (empty($m_values)) { |
|
120 | 120 | $msgr_filters[0] = array( |
121 | 121 | 'id' => 'none_selected', |
122 | - 'text' => __( 'No Messengers active', 'event_espresso' ) |
|
122 | + 'text' => __('No Messengers active', 'event_espresso') |
|
123 | 123 | ); |
124 | 124 | } |
125 | 125 | |
126 | - if ( empty( $mt_values ) ) { |
|
126 | + if (empty($mt_values)) { |
|
127 | 127 | $mt_filters[0] = array( |
128 | 128 | 'id' => 'none_selected', |
129 | - 'text' => __( 'No Message Types active', 'event_espresso' ) |
|
129 | + 'text' => __('No Message Types active', 'event_espresso') |
|
130 | 130 | ); |
131 | 131 | } |
132 | 132 | |
133 | - if ( empty( $c_values ) ) { |
|
133 | + if (empty($c_values)) { |
|
134 | 134 | $c_filters[0] = array( |
135 | 135 | 'id' => 'none_selected', |
136 | - 'text' => __( 'No Contexts (because no message types active)', 'event_espresso' ) |
|
136 | + 'text' => __('No Contexts (because no message types active)', 'event_espresso') |
|
137 | 137 | ); |
138 | 138 | } |
139 | 139 | |
140 | - $filters[] = EEH_Form_Fields::select_input( 'ee_messenger_filter_by', $msgr_filters, isset( $this->_req_data['ee_messenger_filter_by'] ) ? sanitize_title( $this->_req_data['ee_messenger_filter_by'] ) : '' ); |
|
141 | - $filters[] = EEH_Form_Fields::select_input( 'ee_message_type_filter_by', $mt_filters, isset( $this->_req_data['ee_message_type_filter_by'] ) ? sanitize_title( $this->_req_data['ee_message_type_filter_by'] ) : '' ); |
|
142 | - $filters[] = EEH_Form_Fields::select_input( 'ee_context_filter_by', $c_filters, isset( $this->_req_data['ee_context_filter_by'] ) ? sanitize_text_field( $this->_req_data['ee_context_filter_by'] ) : '' ); |
|
140 | + $filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_title($this->_req_data['ee_messenger_filter_by']) : ''); |
|
141 | + $filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_title($this->_req_data['ee_message_type_filter_by']) : ''); |
|
142 | + $filters[] = EEH_Form_Fields::select_input('ee_context_filter_by', $c_filters, isset($this->_req_data['ee_context_filter_by']) ? sanitize_text_field($this->_req_data['ee_context_filter_by']) : ''); |
|
143 | 143 | return $filters; |
144 | 144 | } |
145 | 145 | |
146 | 146 | |
147 | 147 | |
148 | 148 | protected function _add_view_counts() { |
149 | - foreach ( $this->_views as $view => $args ) { |
|
150 | - $this->_views[ $view ]['count'] = $this->_get_messages( $this->_per_page, $view, true, true ); |
|
149 | + foreach ($this->_views as $view => $args) { |
|
150 | + $this->_views[$view]['count'] = $this->_get_messages($this->_per_page, $view, true, true); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @return string EE_Message status. |
159 | 159 | */ |
160 | - public function column_msg_status( EE_Message $message ) { |
|
161 | - return '<span class="ee-status-strip ee-status-strip-td msg-status-' . $message->STS_ID() . '"></span>'; |
|
160 | + public function column_msg_status(EE_Message $message) { |
|
161 | + return '<span class="ee-status-strip ee-status-strip-td msg-status-'.$message->STS_ID().'"></span>'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return string checkbox |
169 | 169 | */ |
170 | - public function column_cb( $message ) { |
|
171 | - return sprintf( '<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID() ); |
|
170 | + public function column_cb($message) { |
|
171 | + return sprintf('<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID()); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param EE_Message $message |
178 | 178 | * @return string |
179 | 179 | */ |
180 | - public function column_msg_id( EE_Message $message ) { |
|
180 | + public function column_msg_id(EE_Message $message) { |
|
181 | 181 | return $message->ID(); |
182 | 182 | } |
183 | 183 | |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | * @param EE_Message $message |
188 | 188 | * @return string The recipient of the message |
189 | 189 | */ |
190 | - public function column_to( EE_Message $message ) { |
|
191 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
190 | + public function column_to(EE_Message $message) { |
|
191 | + EE_Registry::instance()->load_helper('URL'); |
|
192 | 192 | $actions = array(); |
193 | - if ( $recipient_object = $message->recipient_object() ) { |
|
193 | + if ($recipient_object = $message->recipient_object()) { |
|
194 | 194 | $view_details_link = $recipient_object instanceof EEI_Admin_Links ? $recipient_object->get_admin_details_link() : ''; |
195 | - if ( ! empty( $view_details_link ) ) { |
|
196 | - $actions['view'] = '<a href="' . $view_details_link . '">' . __( 'View Recipient Details', 'event_espresso' ) . '</a>'; |
|
195 | + if ( ! empty($view_details_link)) { |
|
196 | + $actions['view'] = '<a href="'.$view_details_link.'">'.__('View Recipient Details', 'event_espresso').'</a>'; |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
@@ -204,10 +204,10 @@ discard block |
||
204 | 204 | 'action' => 'delete_ee_message', |
205 | 205 | 'MSG_ID' => $message->ID() |
206 | 206 | ), |
207 | - admin_url( 'admin.php' ) |
|
207 | + admin_url('admin.php') |
|
208 | 208 | ) |
209 | - . '">' . __( 'Delete', 'event_espresso' ) . '</a>'; |
|
210 | - return $message->to() . $this->row_actions( $actions ); |
|
209 | + . '">'.__('Delete', 'event_espresso').'</a>'; |
|
210 | + return $message->to().$this->row_actions($actions); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param EE_Message $message |
216 | 216 | * @return string The sender of the message |
217 | 217 | */ |
218 | - public function column_from( EE_Message $message ) { |
|
218 | + public function column_from(EE_Message $message) { |
|
219 | 219 | return $message->from(); |
220 | 220 | } |
221 | 221 | |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | * @param EE_Message $message |
226 | 226 | * @return string The messenger used to send the message. |
227 | 227 | */ |
228 | - public function column_messenger( EE_Message $message ) { |
|
229 | - return ucwords( $message->messenger_label() ); |
|
228 | + public function column_messenger(EE_Message $message) { |
|
229 | + return ucwords($message->messenger_label()); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | * @param EE_Message $message |
235 | 235 | * @return string The message type used to generate the message. |
236 | 236 | */ |
237 | - public function column_message_type( EE_Message $message ) { |
|
238 | - return ucwords( $message->message_type_label() ); |
|
237 | + public function column_message_type(EE_Message $message) { |
|
238 | + return ucwords($message->message_type_label()); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @param EE_Message $message |
244 | 244 | * @return string The context the message was generated for. |
245 | 245 | */ |
246 | - public function column_context( EE_Message $message ) { |
|
246 | + public function column_context(EE_Message $message) { |
|
247 | 247 | return $message->context_label(); |
248 | 248 | } |
249 | 249 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param EE_Message $message |
253 | 253 | * @return string The timestamp when this message was last modified. |
254 | 254 | */ |
255 | - public function column_modified( EE_Message $message ) { |
|
255 | + public function column_modified(EE_Message $message) { |
|
256 | 256 | return $message->modified(); |
257 | 257 | } |
258 | 258 | |
@@ -261,36 +261,36 @@ discard block |
||
261 | 261 | * @param EE_Message $message |
262 | 262 | * @return string Actions that can be done on the current message. |
263 | 263 | */ |
264 | - public function column_action( EE_Message $message ) { |
|
265 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
264 | + public function column_action(EE_Message $message) { |
|
265 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
266 | 266 | $action_links = array( |
267 | - 'view' => EEH_MSG_Template::get_message_action_link( 'view', $message ), |
|
268 | - 'error' => EEH_MSG_Template::get_message_action_link( 'error', $message ), |
|
269 | - 'generate_now' => EEH_MSG_Template::get_message_action_link( 'generate_now', $message ), |
|
270 | - 'send_now' => EEH_MSG_Template::get_message_action_link( 'send_now', $message ), |
|
271 | - 'queue_for_resending' => EEH_MSG_Template::get_message_action_link( 'queue_for_resending', $message ), |
|
272 | - 'view_transaction' => EEH_MSG_Template::get_message_action_link( 'view_transaction', $message ), |
|
267 | + 'view' => EEH_MSG_Template::get_message_action_link('view', $message), |
|
268 | + 'error' => EEH_MSG_Template::get_message_action_link('error', $message), |
|
269 | + 'generate_now' => EEH_MSG_Template::get_message_action_link('generate_now', $message), |
|
270 | + 'send_now' => EEH_MSG_Template::get_message_action_link('send_now', $message), |
|
271 | + 'queue_for_resending' => EEH_MSG_Template::get_message_action_link('queue_for_resending', $message), |
|
272 | + 'view_transaction' => EEH_MSG_Template::get_message_action_link('view_transaction', $message), |
|
273 | 273 | ); |
274 | 274 | $content = ''; |
275 | - switch ( $message->STS_ID() ) { |
|
275 | + switch ($message->STS_ID()) { |
|
276 | 276 | case EEM_Message::status_sent : |
277 | - $content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction']; |
|
277 | + $content = $action_links['view'].$action_links['queue_for_resending'].$action_links['view_transaction']; |
|
278 | 278 | break; |
279 | 279 | case EEM_Message::status_resend : |
280 | - $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction']; |
|
280 | + $content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction']; |
|
281 | 281 | break; |
282 | 282 | case EEM_Message::status_retry : |
283 | - $content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction']; |
|
283 | + $content = $action_links['view'].$action_links['send_now'].$action_links['error'].$action_links['view_transaction']; |
|
284 | 284 | break; |
285 | 285 | case EEM_Message::status_failed : |
286 | 286 | case EEM_Message::status_debug_only : |
287 | - $content = $action_links['error'] . $action_links['view_transaction']; |
|
287 | + $content = $action_links['error'].$action_links['view_transaction']; |
|
288 | 288 | break; |
289 | 289 | case EEM_Message::status_idle : |
290 | - $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction']; |
|
290 | + $content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction']; |
|
291 | 291 | break; |
292 | 292 | case EEM_Message::status_incomplete; |
293 | - $content = $action_links['generate_now'] . $action_links['view_transaction']; |
|
293 | + $content = $action_links['generate_now'].$action_links['view_transaction']; |
|
294 | 294 | break; |
295 | 295 | } |
296 | 296 | return $content; |
@@ -305,69 +305,69 @@ discard block |
||
305 | 305 | * @param bool $all Disregard any paging info (no limit on data returned). |
306 | 306 | * @return int | EE_Message[] |
307 | 307 | */ |
308 | - protected function _get_messages( $perpage = 10, $view = 'all', $count = false, $all = false ) { |
|
308 | + protected function _get_messages($perpage = 10, $view = 'all', $count = false, $all = false) { |
|
309 | 309 | |
310 | - $current_page = isset( $this->_req_data['paged'] ) && ! empty( $this->_req_data['paged'] ) |
|
310 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
311 | 311 | ? $this->_req_data['paged'] |
312 | 312 | : 1; |
313 | 313 | |
314 | - $per_page = isset( $this->_req_data['perpage'] ) && ! empty( $this->_req_data['perpage'] ) |
|
314 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
315 | 315 | ? $this->_req_data['perpage'] |
316 | 316 | : $perpage; |
317 | 317 | |
318 | - $offset = ( $current_page - 1 ) * $per_page; |
|
319 | - $limit = $all || $count ? null : array( $offset, $per_page ); |
|
318 | + $offset = ($current_page - 1) * $per_page; |
|
319 | + $limit = $all || $count ? null : array($offset, $per_page); |
|
320 | 320 | $query_params = array( |
321 | - 'order_by' => empty( $this->_req_data[ 'orderby' ] ) ? 'MSG_modified' : $this->_req_data[ 'orderby' ], |
|
322 | - 'order' => empty( $this->_req_data[ 'order' ] ) ? 'DESC' : $this->_req_data[ 'order' ], |
|
321 | + 'order_by' => empty($this->_req_data['orderby']) ? 'MSG_modified' : $this->_req_data['orderby'], |
|
322 | + 'order' => empty($this->_req_data['order']) ? 'DESC' : $this->_req_data['order'], |
|
323 | 323 | 'limit' => $limit, |
324 | 324 | ); |
325 | 325 | |
326 | 326 | /** |
327 | 327 | * Any filters coming in from other routes? |
328 | 328 | */ |
329 | - if ( isset( $this->_req_data['filterby'] ) ) { |
|
330 | - $query_params = array_merge( $query_params, EEM_Message::instance()->filter_by_query_params() ); |
|
331 | - if ( ! $count ) { |
|
329 | + if (isset($this->_req_data['filterby'])) { |
|
330 | + $query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params()); |
|
331 | + if ( ! $count) { |
|
332 | 332 | $query_params['group_by'] = 'MSG_ID'; |
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | 336 | //view conditionals |
337 | - if ( $view !== 'all' && $count && $all ) { |
|
337 | + if ($view !== 'all' && $count && $all) { |
|
338 | 338 | $query_params[0]['AND*view_conditional'] = array( |
339 | - 'STS_ID' => strtoupper( $view ), |
|
339 | + 'STS_ID' => strtoupper($view), |
|
340 | 340 | ); |
341 | 341 | } |
342 | 342 | |
343 | - if ( ! empty( $this->_req_data['status'] ) && ! $all && $this->_req_data['status'] !== 'all' ) { |
|
343 | + if ( ! empty($this->_req_data['status']) && ! $all && $this->_req_data['status'] !== 'all') { |
|
344 | 344 | $query_params[0]['AND*view_conditional'] = array( |
345 | - 'STS_ID' => strtoupper( $this->_req_data['status'] ), |
|
345 | + 'STS_ID' => strtoupper($this->_req_data['status']), |
|
346 | 346 | ); |
347 | 347 | } |
348 | 348 | |
349 | - if ( ! $all && ! empty( $this->_req_data['s'] ) ) { |
|
350 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
349 | + if ( ! $all && ! empty($this->_req_data['s'])) { |
|
350 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
351 | 351 | $query_params[0]['OR'] = array( |
352 | - 'MSG_to' => array( 'LIKE', $search_string ), |
|
353 | - 'MSG_from' => array( 'LIKE', $search_string ), |
|
354 | - 'MSG_subject' => array( 'LIKE', $search_string ), |
|
355 | - 'MSG_content' => array( 'LIKE', $search_string ), |
|
352 | + 'MSG_to' => array('LIKE', $search_string), |
|
353 | + 'MSG_from' => array('LIKE', $search_string), |
|
354 | + 'MSG_subject' => array('LIKE', $search_string), |
|
355 | + 'MSG_content' => array('LIKE', $search_string), |
|
356 | 356 | ); |
357 | 357 | } |
358 | 358 | |
359 | 359 | //account for debug only status. We don't show Messages with the EEM_Message::status_debug_only to clients when |
360 | 360 | //`WP_DEBUG` is false. |
361 | - if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) { |
|
361 | + if ( ! defined('WP_DEBUG') || ! WP_DEBUG) { |
|
362 | 362 | $query_params[0]['AND*debug_only_conditional'] = array( |
363 | - 'STS_ID' => array( '!=', EEM_Message::status_debug_only ) |
|
363 | + 'STS_ID' => array('!=', EEM_Message::status_debug_only) |
|
364 | 364 | ); |
365 | 365 | } |
366 | 366 | |
367 | 367 | //account for filters |
368 | 368 | if ( |
369 | 369 | ! $all |
370 | - && isset( $this->_req_data['ee_messenger_filter_by'] ) |
|
370 | + && isset($this->_req_data['ee_messenger_filter_by']) |
|
371 | 371 | && $this->_req_data['ee_messenger_filter_by'] !== 'none_selected' |
372 | 372 | ) { |
373 | 373 | $query_params[0]['AND*messenger_filter'] = array( |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | } |
377 | 377 | if ( |
378 | 378 | ! $all |
379 | - && ! empty( $this->_req_data['ee_message_type_filter_by'] ) |
|
379 | + && ! empty($this->_req_data['ee_message_type_filter_by']) |
|
380 | 380 | && $this->_req_data['ee_message_type_filter_by'] !== 'none_selected' |
381 | 381 | ) { |
382 | 382 | $query_params[0]['AND*message_type_filter'] = array( |
@@ -386,17 +386,17 @@ discard block |
||
386 | 386 | |
387 | 387 | if ( |
388 | 388 | ! $all |
389 | - && ! empty( $this->_req_data['ee_context_filter_by'] ) |
|
389 | + && ! empty($this->_req_data['ee_context_filter_by']) |
|
390 | 390 | && $this->_req_data['ee_context_filter_by'] !== 'none_selected' |
391 | 391 | ) { |
392 | 392 | $query_params[0]['AND*context_filter'] = array( |
393 | - 'MSG_context' => array( 'IN', explode( ',', $this->_req_data['ee_context_filter_by'] ) ) |
|
393 | + 'MSG_context' => array('IN', explode(',', $this->_req_data['ee_context_filter_by'])) |
|
394 | 394 | ); |
395 | 395 | } |
396 | 396 | |
397 | 397 | return $count |
398 | - ? EEM_Message::instance()->count( $query_params, null, true ) |
|
399 | - : EEM_Message::instance()->get_all( $query_params ); |
|
398 | + ? EEM_Message::instance()->count($query_params, null, true) |
|
399 | + : EEM_Message::instance()->get_all($query_params); |
|
400 | 400 | |
401 | 401 | } |
402 | 402 | } //end EE_Message_List_Table class |
403 | 403 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
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 | * ************************************************************************ |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param \EE_Checkout $checkout |
32 | 32 | * @return string |
33 | 33 | */ |
34 | -function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) { |
|
34 | +function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) { |
|
35 | 35 | // list of old filters |
36 | 36 | $deprecated_filters = array( |
37 | 37 | 'update_registration_details' => true, |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | 'proceed_to' => true, |
42 | 42 | ); |
43 | 43 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
44 | - foreach ( $deprecated_filters as $deprecated_filter => $on ) { |
|
44 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
45 | 45 | // was this filter called ? |
46 | - if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) { |
|
46 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
47 | 47 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
48 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) { |
|
48 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) { |
|
49 | 49 | EE_Error::doing_it_wrong( |
50 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
50 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
51 | 51 | sprintf( |
52 | - __( 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ), |
|
53 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
52 | + __('The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'), |
|
53 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
54 | 54 | '<br />', |
55 | 55 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
56 | 56 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -60,24 +60,24 @@ discard block |
||
60 | 60 | ); |
61 | 61 | } |
62 | 62 | } else { |
63 | - unset( $deprecated_filters[ $deprecated_filter ] ); |
|
63 | + unset($deprecated_filters[$deprecated_filter]); |
|
64 | 64 | } |
65 | 65 | } |
66 | - if ( ! empty( $deprecated_filters )) { |
|
67 | - |
|
68 | - if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) { |
|
69 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text ); |
|
70 | - } else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) { |
|
71 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text ); |
|
72 | - } else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) { |
|
73 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text ); |
|
66 | + if ( ! empty($deprecated_filters)) { |
|
67 | + |
|
68 | + if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
69 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text); |
|
70 | + } else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
71 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text); |
|
72 | + } else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
73 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text); |
|
74 | 74 | } |
75 | - if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
76 | - if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) { |
|
77 | - $submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text ); |
|
75 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
76 | + if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
77 | + $submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text); |
|
78 | 78 | } |
79 | - if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) { |
|
80 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name(); |
|
79 | + if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
80 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name(); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | return $submit_button_text; |
86 | 86 | |
87 | 87 | } |
88 | -add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 ); |
|
88 | +add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2); |
|
89 | 89 | |
90 | 90 | |
91 | 91 | |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | * @param \EE_Checkout $checkout |
97 | 97 | * @param boolean $status_updates |
98 | 98 | */ |
99 | -function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) { |
|
99 | +function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) { |
|
100 | 100 | $action_ref = NULL; |
101 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
102 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
103 | - if ( $action_ref ) { |
|
101 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
102 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
103 | + if ($action_ref) { |
|
104 | 104 | |
105 | 105 | EE_Error::doing_it_wrong( |
106 | 106 | $action_ref, |
107 | 107 | sprintf( |
108 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ), |
|
108 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'), |
|
109 | 109 | '<br />', |
110 | 110 | '/core/business/EE_Transaction_Processor.class.php', |
111 | 111 | 'AHEE__EE_Transaction_Processor__finalize', |
@@ -116,29 +116,29 @@ discard block |
||
116 | 116 | '4.6.0', |
117 | 117 | E_USER_DEPRECATED |
118 | 118 | ); |
119 | - switch ( $action_ref ) { |
|
119 | + switch ($action_ref) { |
|
120 | 120 | case 'AHEE__EE_Transaction__finalize__new_transaction' : |
121 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request ); |
|
121 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request); |
|
122 | 122 | break; |
123 | 123 | case 'AHEE__EE_Transaction__finalize__all_transaction' : |
124 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request ); |
|
124 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request); |
|
125 | 125 | break; |
126 | 126 | } |
127 | 127 | } |
128 | 128 | } |
129 | -add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 ); |
|
129 | +add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2); |
|
130 | 130 | /** |
131 | 131 | * ee_deprecated_finalize_registration |
132 | 132 | * |
133 | 133 | * @param EE_Registration $registration |
134 | 134 | */ |
135 | -function ee_deprecated_finalize_registration( EE_Registration $registration ) { |
|
136 | - $action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
137 | - if ( $action_ref ) { |
|
135 | +function ee_deprecated_finalize_registration(EE_Registration $registration) { |
|
136 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
137 | + if ($action_ref) { |
|
138 | 138 | EE_Error::doing_it_wrong( |
139 | 139 | $action_ref, |
140 | 140 | sprintf( |
141 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ), |
|
141 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'), |
|
142 | 142 | '<br />', |
143 | 143 | '/core/business/EE_Registration_Processor.class.php', |
144 | 144 | 'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook' |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | '4.6.0', |
147 | 147 | E_USER_DEPRECATED |
148 | 148 | ); |
149 | - do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ))); |
|
149 | + do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))); |
|
150 | 150 | } |
151 | 151 | } |
152 | -add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 ); |
|
152 | +add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1); |
|
153 | 153 | |
154 | 154 | |
155 | 155 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return array |
172 | 172 | */ |
173 | -function ee_deprecated_get_templates( $templates, EE_messenger $messenger, EE_message_type $message_type, EE_Messages_Template_Pack $template_pack ) { |
|
173 | +function ee_deprecated_get_templates($templates, EE_messenger $messenger, EE_message_type $message_type, EE_Messages_Template_Pack $template_pack) { |
|
174 | 174 | $old_default_classnames = array( |
175 | 175 | 'EE_Messages_Email_Cancelled_Registration_Defaults', |
176 | 176 | 'EE_Messages_Email_Declined_Registration_Defaults', |
@@ -186,23 +186,23 @@ discard block |
||
186 | 186 | |
187 | 187 | $old_class_instance = new stdClass(); |
188 | 188 | |
189 | - foreach ( $old_default_classnames as $classname ) { |
|
190 | - $filter_ref = 'FHEE__' . $classname . '___create_new_templates___templates'; |
|
191 | - if ( has_filter( $filter_ref ) ) { |
|
192 | - EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the new filter provided which is "FHEE__EE_Template_Pack___get_templates__templates" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED ); |
|
189 | + foreach ($old_default_classnames as $classname) { |
|
190 | + $filter_ref = 'FHEE__'.$classname.'___create_new_templates___templates'; |
|
191 | + if (has_filter($filter_ref)) { |
|
192 | + EE_Error::doing_it_wrong($filter_ref, __('This filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the new filter provided which is "FHEE__EE_Template_Pack___get_templates__templates" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED); |
|
193 | 193 | } |
194 | - $templates = apply_filters( $filter_ref, $templates, $old_class_instance ); |
|
194 | + $templates = apply_filters($filter_ref, $templates, $old_class_instance); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return $templates; |
198 | 198 | } |
199 | -add_filter( 'FHEE__EE_Template_Pack___get_templates__templates', 'ee_deprecated_get_templates', 10, 4 ); |
|
199 | +add_filter('FHEE__EE_Template_Pack___get_templates__templates', 'ee_deprecated_get_templates', 10, 4); |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called. |
203 | 203 | * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately. |
204 | 204 | */ |
205 | -function ee_deprecated_hooks(){ |
|
205 | +function ee_deprecated_hooks() { |
|
206 | 206 | /** |
207 | 207 | * @var $hooks array where keys are hook names, and their values are array{ |
208 | 208 | * @type string $version when deprecated |
@@ -213,26 +213,26 @@ discard block |
||
213 | 213 | $hooks = array( |
214 | 214 | 'AHEE__EE_System___do_setup_validations' => array( |
215 | 215 | 'version' => '4.6.0', |
216 | - 'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ), |
|
216 | + 'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'), |
|
217 | 217 | 'still_works' => FALSE |
218 | 218 | ) |
219 | 219 | ); |
220 | - foreach( $hooks as $name => $deprecation_info ){ |
|
221 | - if( has_action( $name ) ){ |
|
220 | + foreach ($hooks as $name => $deprecation_info) { |
|
221 | + if (has_action($name)) { |
|
222 | 222 | EE_Error::doing_it_wrong( |
223 | 223 | $name, |
224 | 224 | sprintf( |
225 | - __('This filter is deprecated. %1$s%2$s','event_espresso'), |
|
226 | - $deprecation_info[ 'still_works' ] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ), |
|
227 | - isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' ) |
|
225 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
226 | + $deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'), |
|
227 | + isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso') |
|
228 | 228 | ), |
229 | - isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ), |
|
229 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso'), |
|
230 | 230 | E_USER_DEPRECATED |
231 | 231 | ); |
232 | 232 | } |
233 | 233 | } |
234 | 234 | } |
235 | -add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' ); |
|
235 | +add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
|
236 | 236 | |
237 | 237 | |
238 | 238 | |
@@ -255,25 +255,25 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @return string The default contents for the messenger, message type, context and field. |
257 | 257 | */ |
258 | -function ee_deprecated_get_default_field_content( $contents, $actual_path, EE_messenger $messenger, EE_message_type $message_type, $field, $context, EE_Messages_Template_Pack $template_pack ) { |
|
258 | +function ee_deprecated_get_default_field_content($contents, $actual_path, EE_messenger $messenger, EE_message_type $message_type, $field, $context, EE_Messages_Template_Pack $template_pack) { |
|
259 | 259 | |
260 | 260 | $classnames_to_try = array( |
261 | - get_class( $messenger ) => $messenger, |
|
262 | - get_class( $message_type ) => $message_type, |
|
261 | + get_class($messenger) => $messenger, |
|
262 | + get_class($message_type) => $message_type, |
|
263 | 263 | 'EE_Messages_Base' => $message_type |
264 | 264 | ); |
265 | 265 | |
266 | - foreach ( $classnames_to_try as $classname => $obj ) { |
|
267 | - $filter_ref = 'FHEE__' . $classname . '__get_default_field_content'; |
|
268 | - if ( has_filter( $filter_ref ) ) { |
|
269 | - EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_specific_template__contents" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED ); |
|
266 | + foreach ($classnames_to_try as $classname => $obj) { |
|
267 | + $filter_ref = 'FHEE__'.$classname.'__get_default_field_content'; |
|
268 | + if (has_filter($filter_ref)) { |
|
269 | + EE_Error::doing_it_wrong($filter_ref, __('This filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_specific_template__contents" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED); |
|
270 | 270 | } |
271 | - $contents = apply_filters( $filter_ref, $contents, $obj ); |
|
271 | + $contents = apply_filters($filter_ref, $contents, $obj); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | return $contents; |
275 | 275 | } |
276 | -add_filter( 'FHEE__EE_Messages_Template_Pack__get_specific_template__contents', 'ee_deprecated_get_default_field_content', 10, 7 ); |
|
276 | +add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', 'ee_deprecated_get_default_field_content', 10, 7); |
|
277 | 277 | |
278 | 278 | |
279 | 279 | |
@@ -301,23 +301,23 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @return string The path to the file being used. |
303 | 303 | */ |
304 | -function ee_deprecated_get_inline_css_template_filters( $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack ) { |
|
304 | +function ee_deprecated_get_inline_css_template_filters($variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack) { |
|
305 | 305 | |
306 | - if ( $messenger == 'email' ) { |
|
306 | + if ($messenger == 'email') { |
|
307 | 307 | $filter_ref = $url ? 'FHEE__EE_Email_messenger__get_inline_css_template__css_url' : 'FHEE__EE_Email_messenger__get_inline_css_template__css_path'; |
308 | - } elseif ( $messenger == 'html' ) { |
|
308 | + } elseif ($messenger == 'html') { |
|
309 | 309 | $filter_ref = $url ? 'FHEE__EE_Html_messenger__get_inline_css_template__css_url' : 'FHEE__EE_Html_messenger__get_inline_css_template__css_path'; |
310 | 310 | } else { |
311 | 311 | return $variation_path; |
312 | 312 | } |
313 | 313 | |
314 | - if ( has_filter( $filter_ref ) ) { |
|
315 | - EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated. It is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_variation" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED ); |
|
314 | + if (has_filter($filter_ref)) { |
|
315 | + EE_Error::doing_it_wrong($filter_ref, __('This filter is deprecated. It is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_variation" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED); |
|
316 | 316 | } |
317 | 317 | |
318 | - return apply_filters( $filter_ref, $variation_path, $url, $type ); |
|
318 | + return apply_filters($filter_ref, $variation_path, $url, $type); |
|
319 | 319 | } |
320 | -add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', 'ee_deprecated_get_inline_css_template_filters', 10, 8 ); |
|
320 | +add_filter('FHEE__EE_Messages_Template_Pack__get_variation', 'ee_deprecated_get_inline_css_template_filters', 10, 8); |
|
321 | 321 | |
322 | 322 | |
323 | 323 | |
@@ -333,78 +333,78 @@ discard block |
||
333 | 333 | class EE_Messages_Init extends EE_Base { |
334 | 334 | |
335 | 335 | public function __construct() { |
336 | - self::doing_it_wrong_call( __METHOD__ ); |
|
336 | + self::doing_it_wrong_call(__METHOD__); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | 340 | * @param $method_name |
341 | 341 | */ |
342 | - public static function doing_it_wrong_call( $method_name ) { |
|
343 | - EE_Error::doing_it_wrong( __CLASS__, sprintf( __('The %s in this class is deprecated as of EE4.5.0. All functionality formerly in this class is now in the EED_Messages module.', 'event_espresso'), $method_name ), '4.5.0', E_USER_DEPRECATED ); |
|
342 | + public static function doing_it_wrong_call($method_name) { |
|
343 | + EE_Error::doing_it_wrong(__CLASS__, sprintf(__('The %s in this class is deprecated as of EE4.5.0. All functionality formerly in this class is now in the EED_Messages module.', 'event_espresso'), $method_name), '4.5.0', E_USER_DEPRECATED); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
347 | 347 | * @deprecated 4.5.0 |
348 | 348 | */ |
349 | 349 | public static function set_autoloaders() { |
350 | - self::doing_it_wrong_call( __METHOD__ ); |
|
350 | + self::doing_it_wrong_call(__METHOD__); |
|
351 | 351 | EED_Messages::set_autoloaders(); |
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
355 | 355 | * @deprecated 4.5.0 |
356 | 356 | */ |
357 | - public function payment_reminder( $transaction ) { |
|
358 | - self::doing_it_wrong_call( __METHOD__ ); |
|
359 | - EED_Messages::payment_reminder( $transaction ); |
|
357 | + public function payment_reminder($transaction) { |
|
358 | + self::doing_it_wrong_call(__METHOD__); |
|
359 | + EED_Messages::payment_reminder($transaction); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
363 | 363 | * @deprecated 4.5.0 |
364 | 364 | */ |
365 | - public function payment( $transaction, $payment ) { |
|
366 | - self::doing_it_wrong_call( __METHOD__ ); |
|
367 | - EED_Messages::payment( $transaction, $payment ); |
|
365 | + public function payment($transaction, $payment) { |
|
366 | + self::doing_it_wrong_call(__METHOD__); |
|
367 | + EED_Messages::payment($transaction, $payment); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
371 | 371 | * @deprecated 4.5.0 |
372 | 372 | */ |
373 | - public function cancelled_registration( $transaction ) { |
|
374 | - self::doing_it_wrong_call( __METHOD__ ); |
|
375 | - EED_Messages::cancelled_registration( $transaction ); |
|
373 | + public function cancelled_registration($transaction) { |
|
374 | + self::doing_it_wrong_call(__METHOD__); |
|
375 | + EED_Messages::cancelled_registration($transaction); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
379 | 379 | * @deprecated 4.5.0 |
380 | 380 | */ |
381 | - public function maybe_registration( $transaction, $reg_msg, $from_admin ) { |
|
382 | - self::doing_it_wrong_call( __METHOD__ ); |
|
383 | - EED_Messages::maybe_registration( $transaction, $reg_msg, $from_admin ); |
|
381 | + public function maybe_registration($transaction, $reg_msg, $from_admin) { |
|
382 | + self::doing_it_wrong_call(__METHOD__); |
|
383 | + EED_Messages::maybe_registration($transaction, $reg_msg, $from_admin); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
387 | 387 | * @deprecated 4.5.0 |
388 | 388 | */ |
389 | - public function process_resend( $success, $req_data ) { |
|
390 | - self::doing_it_wrong_call( __METHOD__ ); |
|
391 | - EED_Messages::process_resend( $req_data ); |
|
389 | + public function process_resend($success, $req_data) { |
|
390 | + self::doing_it_wrong_call(__METHOD__); |
|
391 | + EED_Messages::process_resend($req_data); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
395 | 395 | * @deprecated 4.5.0 |
396 | 396 | */ |
397 | - public function process_admin_payment( $success, $payment ) { |
|
398 | - self::doing_it_wrong_call( __METHOD__ ); |
|
399 | - EED_Messages::process_admin_payment( $payment ); |
|
397 | + public function process_admin_payment($success, $payment) { |
|
398 | + self::doing_it_wrong_call(__METHOD__); |
|
399 | + EED_Messages::process_admin_payment($payment); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
403 | 403 | * @deprecated 4.5.0 |
404 | 404 | */ |
405 | - public function send_newsletter_message( $contacts, $grp_id ) { |
|
406 | - self::doing_it_wrong_call( __METHOD__ ); |
|
407 | - EED_Messages::send_newsletter_message( $contacts, $grp_id ); |
|
405 | + public function send_newsletter_message($contacts, $grp_id) { |
|
406 | + self::doing_it_wrong_call(__METHOD__); |
|
407 | + EED_Messages::send_newsletter_message($contacts, $grp_id); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | * |
426 | 426 | * @return array additional cpts. |
427 | 427 | */ |
428 | -function ee_deprecated_get_cpts( $cpts ) { |
|
429 | - if ( has_filter( 'FHEE__EE_Register_CPTs__construct__CPTs' ) ) { |
|
430 | - EE_Error::doing_it_wrong( 'FHEE__EE_Register_CPTs__construct__CPTs', __('This filter is deprecated. It will still work for the time being. However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_CPTs__cpts" found in EE_Register_CPTs::get_CPTs()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED ); |
|
428 | +function ee_deprecated_get_cpts($cpts) { |
|
429 | + if (has_filter('FHEE__EE_Register_CPTs__construct__CPTs')) { |
|
430 | + EE_Error::doing_it_wrong('FHEE__EE_Register_CPTs__construct__CPTs', __('This filter is deprecated. It will still work for the time being. However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_CPTs__cpts" found in EE_Register_CPTs::get_CPTs()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED); |
|
431 | 431 | } |
432 | - return apply_filters( 'FHEE__EE_Register_CPTs__construct__CPTs', $cpts ); |
|
432 | + return apply_filters('FHEE__EE_Register_CPTs__construct__CPTs', $cpts); |
|
433 | 433 | } |
434 | -add_filter( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', 'ee_deprecated_get_cpts', 10 ); |
|
434 | +add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', 'ee_deprecated_get_cpts', 10); |
|
435 | 435 | |
436 | 436 | |
437 | 437 | |
@@ -445,13 +445,13 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @return array additional custom taxonomies. |
447 | 447 | */ |
448 | -function ee_deprecated_get_taxonomies( $cts ) { |
|
449 | - if ( has_filter( 'FHEE__EE_Register_CPTs__construct__taxonomies' ) ) { |
|
450 | - EE_Error::doing_it_wrong( 'FHEE__EE_Register_CPTs__construct__taxonomies', __('This filter is deprecated. It will still work for the time being. However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_taxonomies__taxonomies" found in EE_Register_CPTs::get_taxonomies()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED ); |
|
448 | +function ee_deprecated_get_taxonomies($cts) { |
|
449 | + if (has_filter('FHEE__EE_Register_CPTs__construct__taxonomies')) { |
|
450 | + EE_Error::doing_it_wrong('FHEE__EE_Register_CPTs__construct__taxonomies', __('This filter is deprecated. It will still work for the time being. However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_taxonomies__taxonomies" found in EE_Register_CPTs::get_taxonomies()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED); |
|
451 | 451 | } |
452 | - return apply_filters( 'FHEE__EE_Register_CPTs__construct__taxonomies', $cts ); |
|
452 | + return apply_filters('FHEE__EE_Register_CPTs__construct__taxonomies', $cts); |
|
453 | 453 | } |
454 | -add_filter( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', 'ee_deprecated_get_taxonomies', 10 ); |
|
454 | +add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', 'ee_deprecated_get_taxonomies', 10); |
|
455 | 455 | |
456 | 456 | |
457 | 457 | |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | * @return boolean |
464 | 464 | */ |
465 | 465 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() { |
466 | - $in_use = has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' ) |
|
467 | - || has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' ); |
|
468 | - if( $in_use ) { |
|
466 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
467 | + || has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'); |
|
468 | + if ($in_use) { |
|
469 | 469 | $msg = __( |
470 | 470 | 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
471 | 471 | . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
@@ -474,18 +474,18 @@ discard block |
||
474 | 474 | 'event_espresso' ) |
475 | 475 | ; |
476 | 476 | EE_Error::doing_it_wrong( |
477 | - __CLASS__ . '::' . __FUNCTION__, |
|
477 | + __CLASS__.'::'.__FUNCTION__, |
|
478 | 478 | $msg, |
479 | 479 | '4.8.32.rc.000' |
480 | 480 | ); |
481 | 481 | //it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
482 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
483 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
482 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
483 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | return $in_use; |
487 | 487 | } |
488 | -add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' ); |
|
488 | +add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'); |
|
489 | 489 | |
490 | 490 | /** |
491 | 491 | * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165 |
@@ -494,34 +494,34 @@ discard block |
||
494 | 494 | * @param EE_Admin_Page $admin_page |
495 | 495 | * @return void |
496 | 496 | */ |
497 | -function ee_deprecated_update_attendee_registration_form_old( $admin_page ) { |
|
497 | +function ee_deprecated_update_attendee_registration_form_old($admin_page) { |
|
498 | 498 | //check if the old hooks are in use. If not, do the default |
499 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
500 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
499 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
500 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
501 | 501 | return; |
502 | 502 | } |
503 | 503 | $req_data = $admin_page->get_request_data(); |
504 | - $qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE; |
|
505 | - $REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE; |
|
506 | - $qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns ); |
|
507 | - if ( ! $REG_ID || ! $qstns ) { |
|
508 | - EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
504 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE; |
|
505 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE; |
|
506 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
507 | + if ( ! $REG_ID || ! $qstns) { |
|
508 | + EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
509 | 509 | } |
510 | 510 | $success = TRUE; |
511 | 511 | |
512 | 512 | // allow others to get in on this awesome fun :D |
513 | - do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns ); |
|
513 | + do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns); |
|
514 | 514 | // loop thru questions... FINALLY!!! |
515 | 515 | |
516 | - foreach ( $qstns as $QST_ID => $qstn ) { |
|
516 | + foreach ($qstns as $QST_ID => $qstn) { |
|
517 | 517 | //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
518 | - if ( !is_array($qstn) ) { |
|
519 | - $success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn); |
|
518 | + if ( ! is_array($qstn)) { |
|
519 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
520 | 520 | continue; |
521 | 521 | } |
522 | 522 | |
523 | 523 | |
524 | - foreach ( $qstn as $ANS_ID => $ANS_value ) { |
|
524 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
525 | 525 | //get answer |
526 | 526 | $query_params = array( |
527 | 527 | 0 => array( |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | ); |
533 | 533 | $answer = EEM_Answer::instance()->get_one($query_params); |
534 | 534 | //this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
535 | - if ( ! $answer instanceof EE_Answer ) { |
|
535 | + if ( ! $answer instanceof EE_Answer) { |
|
536 | 536 | $set_values = array( |
537 | 537 | 'QST_ID' => $QST_ID, |
538 | 538 | 'REG_ID' => $REG_ID, |
@@ -547,11 +547,11 @@ discard block |
||
547 | 547 | } |
548 | 548 | } |
549 | 549 | $what = __('Registration Form', 'event_espresso'); |
550 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
551 | - $admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
550 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
551 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
552 | 552 | exit; |
553 | 553 | } |
554 | -add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 ); |
|
554 | +add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1); |
|
555 | 555 | /** |
556 | 556 | * Render the registration admin page's custom questions area in the old fashion |
557 | 557 | * and firing the old hooks. When this method is removed, we can probably also |
@@ -564,31 +564,31 @@ discard block |
||
564 | 564 | * @return bool |
565 | 565 | * @throws \EE_Error |
566 | 566 | */ |
567 | -function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) { |
|
567 | +function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) { |
|
568 | 568 | //check if the old hooks are in use. If not, do the default |
569 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
570 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
569 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
570 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
571 | 571 | return $do_default_action; |
572 | 572 | } |
573 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 ); |
|
574 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 ); |
|
575 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 ); |
|
576 | - add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 ); |
|
573 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1); |
|
574 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1); |
|
575 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
576 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
577 | 577 | |
578 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') ); |
|
578 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID')); |
|
579 | 579 | |
580 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
580 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
581 | 581 | $template_args = array( |
582 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ), |
|
582 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
583 | 583 | 'reg_questions_form_action' => 'edit_registration', |
584 | 584 | 'REG_ID' => $registration->ID() |
585 | 585 | ); |
586 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
587 | - echo EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
586 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
587 | + echo EEH_Template::display_template($template_path, $template_args, TRUE); |
|
588 | 588 | //indicate that we should not do the default admin page code |
589 | 589 | return false; |
590 | 590 | } |
591 | -add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 ); |
|
591 | +add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3); |
|
592 | 592 | |
593 | 593 | |
594 | 594 | |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | '4.9.0' |
629 | 629 | ); |
630 | 630 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
631 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
632 | - $messenger = $message_resource_manager->get_messenger( $messenger_name ); |
|
633 | - $message_type = $message_resource_manager->get_message_type( $message_type_name ); |
|
631 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
632 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
633 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
634 | 634 | return EE_Registry::instance()->load_lib( |
635 | 635 | 'Messages_Template_Defaults', |
636 | 636 | array( |
@@ -694,15 +694,15 @@ discard block |
||
694 | 694 | /** |
695 | 695 | * @param string $method |
696 | 696 | */ |
697 | - public function _class_is_deprecated( $method ) { |
|
697 | + public function _class_is_deprecated($method) { |
|
698 | 698 | // EE_messages has been deprecated |
699 | 699 | EE_Error::doing_it_wrong( |
700 | - 'EE_messages::' . $method, |
|
701 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
700 | + 'EE_messages::'.$method, |
|
701 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
702 | 702 | '4.9.0' |
703 | 703 | ); |
704 | 704 | // Please use EE_Message_Resource_Manager instead |
705 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
705 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | |
@@ -712,10 +712,10 @@ discard block |
||
712 | 712 | * @param string $messenger_name |
713 | 713 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
714 | 714 | */ |
715 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
715 | + public function ensure_messenger_is_active($messenger_name) { |
|
716 | 716 | // EE_messages has been deprecated |
717 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
718 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
717 | + $this->_class_is_deprecated(__FUNCTION__); |
|
718 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | |
@@ -727,10 +727,10 @@ discard block |
||
727 | 727 | * @return bool true if it got activated (or was active) and false if not. |
728 | 728 | * @throws \EE_Error |
729 | 729 | */ |
730 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
730 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
731 | 731 | // EE_messages has been deprecated |
732 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
733 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
732 | + $this->_class_is_deprecated(__FUNCTION__); |
|
733 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | |
@@ -743,10 +743,10 @@ discard block |
||
743 | 743 | * they are already setup.) |
744 | 744 | * @return boolean an array of generated templates or false if nothing generated/activated. |
745 | 745 | */ |
746 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ) { |
|
746 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
747 | 747 | // EE_messages has been deprecated |
748 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
749 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
748 | + $this->_class_is_deprecated(__FUNCTION__); |
|
749 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | |
@@ -758,10 +758,10 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
760 | 760 | */ |
761 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
761 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
762 | 762 | // EE_messages has been deprecated |
763 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
764 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
763 | + $this->_class_is_deprecated(__FUNCTION__); |
|
764 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | |
@@ -771,10 +771,10 @@ discard block |
||
771 | 771 | * @param string $messenger |
772 | 772 | * @return EE_messenger | null |
773 | 773 | */ |
774 | - public function get_messenger_if_active( $messenger ) { |
|
774 | + public function get_messenger_if_active($messenger) { |
|
775 | 775 | // EE_messages has been deprecated |
776 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
777 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
776 | + $this->_class_is_deprecated(__FUNCTION__); |
|
777 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | |
@@ -795,9 +795,9 @@ discard block |
||
795 | 795 | * 'message_type' => null |
796 | 796 | * ) |
797 | 797 | */ |
798 | - public function validate_for_use( EE_Message $message ) { |
|
798 | + public function validate_for_use(EE_Message $message) { |
|
799 | 799 | // EE_messages has been deprecated |
800 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
800 | + $this->_class_is_deprecated(__FUNCTION__); |
|
801 | 801 | return array( |
802 | 802 | 'messenger' => $message->messenger_object(), |
803 | 803 | 'message_type' => $message->message_type_object(), |
@@ -825,41 +825,41 @@ discard block |
||
825 | 825 | $send = true |
826 | 826 | ) { |
827 | 827 | // EE_messages has been deprecated |
828 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
828 | + $this->_class_is_deprecated(__FUNCTION__); |
|
829 | 829 | /** @type EE_Messages_Processor $processor */ |
830 | - $processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
830 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
831 | 831 | $error = false; |
832 | 832 | //try to intelligently determine what method we'll call based on the incoming data. |
833 | 833 | //if generating and sending are different then generate and send immediately. |
834 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
834 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
835 | 835 | //in the legacy system, when generating and sending were different, that means all the |
836 | 836 | //vars are already in the request object. So let's just use that. |
837 | 837 | try { |
838 | 838 | /** @type EE_Message_To_Generate_From_Request $mtg */ |
839 | - $mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
840 | - $processor->generate_and_send_now( $mtg ); |
|
841 | - } catch ( EE_Error $e ) { |
|
839 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
840 | + $processor->generate_and_send_now($mtg); |
|
841 | + } catch (EE_Error $e) { |
|
842 | 842 | $error_msg = __( |
843 | 843 | 'Please note that a system message failed to send due to a technical issue.', |
844 | 844 | 'event_espresso' |
845 | 845 | ); |
846 | 846 | // add specific message for developers if WP_DEBUG in on |
847 | - $error_msg .= '||' . $e->getMessage(); |
|
848 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
847 | + $error_msg .= '||'.$e->getMessage(); |
|
848 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
849 | 849 | $error = true; |
850 | 850 | } |
851 | 851 | } else { |
852 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
852 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
853 | 853 | //let's find out if there were any errors and how many successfully were queued. |
854 | 854 | $count_errors = $processor->get_queue()->count_STS_in_queue( |
855 | - array( EEM_Message::status_failed, EEM_Message::status_debug_only ) |
|
855 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
856 | 856 | ); |
857 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
858 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
857 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
858 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
859 | 859 | $count_errors = $count_errors + $count_retry; |
860 | - if ( $count_errors > 0 ) { |
|
860 | + if ($count_errors > 0) { |
|
861 | 861 | $error = true; |
862 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
862 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
863 | 863 | $message = sprintf( |
864 | 864 | __( |
865 | 865 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | $count_errors, |
869 | 869 | $count_queued |
870 | 870 | ); |
871 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
871 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
872 | 872 | $message = sprintf( |
873 | 873 | __( |
874 | 874 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | $count_errors, |
878 | 878 | $count_queued |
879 | 879 | ); |
880 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
880 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
881 | 881 | $message = sprintf( |
882 | 882 | __( |
883 | 883 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -895,9 +895,9 @@ discard block |
||
895 | 895 | $count_errors |
896 | 896 | ); |
897 | 897 | } |
898 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
898 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
899 | 899 | } else { |
900 | - if ( $count_queued === 1 ) { |
|
900 | + if ($count_queued === 1) { |
|
901 | 901 | $message = sprintf( |
902 | 902 | __( |
903 | 903 | '%d message successfully queued for generation.', |
@@ -914,18 +914,18 @@ discard block |
||
914 | 914 | $count_queued |
915 | 915 | ); |
916 | 916 | } |
917 | - EE_Error::add_success( $message ); |
|
917 | + EE_Error::add_success($message); |
|
918 | 918 | } |
919 | 919 | } |
920 | 920 | //if no error then return the generated message(s). |
921 | - if ( ! $error && ! $send ) { |
|
922 | - $generated_queue = $processor->generate_queue( false ); |
|
921 | + if ( ! $error && ! $send) { |
|
922 | + $generated_queue = $processor->generate_queue(false); |
|
923 | 923 | //get message and return. |
924 | 924 | $generated_queue->get_queue()->rewind(); |
925 | 925 | $messages = array(); |
926 | - while ( $generated_queue->get_queue()->valid() ) { |
|
926 | + while ($generated_queue->get_queue()->valid()) { |
|
927 | 927 | $message = $generated_queue->get_queue()->current(); |
928 | - if ( $message instanceof EE_Message ) { |
|
928 | + if ($message instanceof EE_Message) { |
|
929 | 929 | //set properties that might be expected by add-ons (backward compat) |
930 | 930 | $message->content = $message->content(); |
931 | 931 | $message->template_pack = $message->get_template_pack(); |
@@ -950,10 +950,10 @@ discard block |
||
950 | 950 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
951 | 951 | * @return string The body of the message. |
952 | 952 | */ |
953 | - public function preview_message( $type, $context, $messenger, $send = false ) { |
|
953 | + public function preview_message($type, $context, $messenger, $send = false) { |
|
954 | 954 | // EE_messages has been deprecated |
955 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
956 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
955 | + $this->_class_is_deprecated(__FUNCTION__); |
|
956 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | |
@@ -967,14 +967,14 @@ discard block |
||
967 | 967 | * |
968 | 968 | * @return bool success or fail. |
969 | 969 | */ |
970 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
970 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
971 | 971 | // EE_messages has been deprecated |
972 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
972 | + $this->_class_is_deprecated(__FUNCTION__); |
|
973 | 973 | //setup for sending to new method. |
974 | 974 | /** @type EE_Messages_Queue $queue */ |
975 | - $queue = EE_Registry::instance()->load_lib( 'Messages_Queue' ); |
|
975 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
976 | 976 | //make sure we have a proper message object |
977 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
977 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
978 | 978 | $msg = EE_Message_Factory::create( |
979 | 979 | array( |
980 | 980 | 'MSG_messenger' => $messenger, |
@@ -986,15 +986,15 @@ discard block |
||
986 | 986 | } else { |
987 | 987 | $msg = $message; |
988 | 988 | } |
989 | - if ( ! $msg instanceof EE_Message ) { |
|
989 | + if ( ! $msg instanceof EE_Message) { |
|
990 | 990 | return false; |
991 | 991 | } |
992 | 992 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
993 | - if ( ! empty( $msg->content ) ) { |
|
994 | - $msg->set( 'MSG_content', $msg->content ); |
|
993 | + if ( ! empty($msg->content)) { |
|
994 | + $msg->set('MSG_content', $msg->content); |
|
995 | 995 | } |
996 | - $queue->add( $msg ); |
|
997 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
996 | + $queue->add($msg); |
|
997 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | |
@@ -1008,11 +1008,11 @@ discard block |
||
1008 | 1008 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
1009 | 1009 | * @throws \EE_Error |
1010 | 1010 | */ |
1011 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
1011 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
1012 | 1012 | // EE_messages has been deprecated |
1013 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1014 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1015 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
1013 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1014 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1015 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | |
@@ -1023,11 +1023,11 @@ discard block |
||
1023 | 1023 | * @param string $message_type_name name of EE_message_type |
1024 | 1024 | * @return array |
1025 | 1025 | */ |
1026 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
1026 | + public function get_fields($messenger_name, $message_type_name) { |
|
1027 | 1027 | // EE_messages has been deprecated |
1028 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1029 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1030 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
1028 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1029 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1030 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | |
@@ -1041,13 +1041,13 @@ discard block |
||
1041 | 1041 | * @return array multidimensional array of messenger and message_type objects |
1042 | 1042 | * (messengers index, and message_type index); |
1043 | 1043 | */ |
1044 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
1044 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
1045 | 1045 | // EE_messages has been deprecated |
1046 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1047 | - if ( $skip_cache ) { |
|
1046 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1047 | + if ($skip_cache) { |
|
1048 | 1048 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
1049 | 1049 | } |
1050 | - switch ( $type ) { |
|
1050 | + switch ($type) { |
|
1051 | 1051 | case 'messengers' : |
1052 | 1052 | return array( |
1053 | 1053 | 'messenger' => $this->_message_resource_manager->installed_messengers(), |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | */ |
1077 | 1077 | public function get_active_messengers() { |
1078 | 1078 | // EE_messages has been deprecated |
1079 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1079 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1080 | 1080 | return $this->_message_resource_manager->active_messengers(); |
1081 | 1081 | } |
1082 | 1082 | |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | */ |
1089 | 1089 | public function get_active_message_types() { |
1090 | 1090 | // EE_messages has been deprecated |
1091 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1091 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1092 | 1092 | return $this->_message_resource_manager->list_of_active_message_types(); |
1093 | 1093 | } |
1094 | 1094 | |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | */ |
1101 | 1101 | public function get_active_message_type_objects() { |
1102 | 1102 | // EE_messages has been deprecated |
1103 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1103 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1104 | 1104 | return $this->_message_resource_manager->get_active_message_type_objects(); |
1105 | 1105 | } |
1106 | 1106 | |
@@ -1112,10 +1112,10 @@ discard block |
||
1112 | 1112 | * @param string $messenger The messenger being checked |
1113 | 1113 | * @return EE_message_type[] (or empty array if none present) |
1114 | 1114 | */ |
1115 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
1115 | + public function get_active_message_types_per_messenger($messenger) { |
|
1116 | 1116 | // EE_messages has been deprecated |
1117 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1118 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
1117 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1118 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | |
@@ -1126,10 +1126,10 @@ discard block |
||
1126 | 1126 | * @param string $message_type The string should correspond to a message type. |
1127 | 1127 | * @return EE_message_type|null |
1128 | 1128 | */ |
1129 | - public function get_active_message_type( $messenger, $message_type ) { |
|
1129 | + public function get_active_message_type($messenger, $message_type) { |
|
1130 | 1130 | // EE_messages has been deprecated |
1131 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1132 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
1131 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1132 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | */ |
1141 | 1141 | public function get_installed_message_types() { |
1142 | 1142 | // EE_messages has been deprecated |
1143 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1143 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1144 | 1144 | return $this->_message_resource_manager->installed_message_types(); |
1145 | 1145 | } |
1146 | 1146 | |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | */ |
1153 | 1153 | public function get_installed_messengers() { |
1154 | 1154 | // EE_messages has been deprecated |
1155 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1155 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1156 | 1156 | return $this->_message_resource_manager->installed_messengers(); |
1157 | 1157 | } |
1158 | 1158 | |
@@ -1163,10 +1163,10 @@ discard block |
||
1163 | 1163 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
1164 | 1164 | * @return array |
1165 | 1165 | */ |
1166 | - public function get_all_contexts( $slugs_only = true ) { |
|
1166 | + public function get_all_contexts($slugs_only = true) { |
|
1167 | 1167 | // EE_messages has been deprecated |
1168 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
1169 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
1168 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1169 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
1170 | 1170 | } |
1171 | 1171 | |
1172 | 1172 |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param \EE_Message_Repository $message_repository |
73 | 73 | */ |
74 | - public function __construct( EE_Message_Repository $message_repository ) { |
|
75 | - $this->_batch_count = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 ); |
|
74 | + public function __construct(EE_Message_Repository $message_repository) { |
|
75 | + $this->_batch_count = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50); |
|
76 | 76 | $this->_rate_limit = $this->get_rate_limit(); |
77 | 77 | $this->_queue = $message_repository; |
78 | 78 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * use the messenger send method but typically is based on preview data. |
92 | 92 | * @return bool Whether the message was successfully added to the repository or not. |
93 | 93 | */ |
94 | - public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) { |
|
94 | + public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) { |
|
95 | 95 | $data['preview'] = $preview; |
96 | 96 | $data['test_send'] = $test_send; |
97 | - return $this->_queue->add( $message, $data ); |
|
97 | + return $this->_queue->add($message, $data); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param bool $persist This flag indicates whether to attempt to delete the object from the db as well. |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function remove( EE_Message $message, $persist = false ) { |
|
110 | - if ( $persist && $this->_queue->current() !== $message ) { |
|
109 | + public function remove(EE_Message $message, $persist = false) { |
|
110 | + if ($persist && $this->_queue->current() !== $message) { |
|
111 | 111 | //get pointer on right message |
112 | - if ( $this->_queue->has( $message ) ) { |
|
112 | + if ($this->_queue->has($message)) { |
|
113 | 113 | $this->_queue->rewind(); |
114 | - while( $this->_queue->valid() ) { |
|
115 | - if ( $this->_queue->current() === $message ) { |
|
114 | + while ($this->_queue->valid()) { |
|
115 | + if ($this->_queue->current() === $message) { |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | $this->_queue->next(); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | } |
124 | - return $persist ? $this->_queue->delete() : $this->_queue->remove( $message ); |
|
124 | + return $persist ? $this->_queue->delete() : $this->_queue->remove($message); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | * @return bool true if successfully retrieved batch, false no batch ready. |
162 | 162 | */ |
163 | 163 | public function get_batch_to_generate() { |
164 | - if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) { |
|
164 | + if ($this->is_locked(EE_Messages_Queue::action_generating)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | //lock batch generation to prevent race conditions. |
169 | - $this->lock_queue( EE_Messages_Queue::action_generating ); |
|
169 | + $this->lock_queue(EE_Messages_Queue::action_generating); |
|
170 | 170 | |
171 | 171 | $query_args = array( |
172 | 172 | // key 0 = where conditions |
173 | - 0 => array( 'STS_ID' => EEM_Message::status_incomplete ), |
|
173 | + 0 => array('STS_ID' => EEM_Message::status_incomplete), |
|
174 | 174 | 'order_by' => $this->_get_priority_orderby(), |
175 | 175 | 'limit' => $this->_batch_count |
176 | 176 | ); |
177 | - $messages = EEM_Message::instance()->get_all( $query_args ); |
|
177 | + $messages = EEM_Message::instance()->get_all($query_args); |
|
178 | 178 | |
179 | - if ( ! $messages ) { |
|
179 | + if ( ! $messages) { |
|
180 | 180 | return false; //nothing to generate |
181 | 181 | } |
182 | 182 | |
183 | - foreach ( $messages as $message ) { |
|
184 | - if ( $message instanceof EE_Message ) { |
|
183 | + foreach ($messages as $message) { |
|
184 | + if ($message instanceof EE_Message) { |
|
185 | 185 | $data = $message->all_extra_meta_array(); |
186 | - $this->add( $message, $data ); |
|
186 | + $this->add($message, $data); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | return true; |
@@ -206,34 +206,34 @@ discard block |
||
206 | 206 | * to assist with notifying user. |
207 | 207 | */ |
208 | 208 | public function get_to_send_batch_and_send() { |
209 | - if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) { |
|
209 | + if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | |
213 | - $this->lock_queue( EE_Messages_Queue::action_sending ); |
|
213 | + $this->lock_queue(EE_Messages_Queue::action_sending); |
|
214 | 214 | |
215 | 215 | $batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit; |
216 | 216 | |
217 | 217 | $query_args = array( |
218 | 218 | // key 0 = where conditions |
219 | - 0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ), |
|
219 | + 0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())), |
|
220 | 220 | 'order_by' => $this->_get_priority_orderby(), |
221 | 221 | 'limit' => $batch |
222 | 222 | ); |
223 | 223 | |
224 | - $messages_to_send = EEM_Message::instance()->get_all( $query_args ); |
|
224 | + $messages_to_send = EEM_Message::instance()->get_all($query_args); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | //any to send? |
228 | - if ( ! $messages_to_send ) { |
|
229 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
228 | + if ( ! $messages_to_send) { |
|
229 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
230 | 230 | return false; |
231 | 231 | } |
232 | 232 | |
233 | 233 | //add to queue. |
234 | - foreach ( $messages_to_send as $message ) { |
|
235 | - if ( $message instanceof EE_Message ) { |
|
236 | - $this->add( $message ); |
|
234 | + foreach ($messages_to_send as $message) { |
|
235 | + if ($message instanceof EE_Message) { |
|
236 | + $this->add($message); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $this->execute(); |
242 | 242 | |
243 | 243 | //release lock |
244 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
244 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param string $type The type of queue being locked. |
255 | 255 | */ |
256 | - public function lock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
257 | - set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) ); |
|
256 | + public function lock_queue($type = EE_Messages_Queue::action_generating) { |
|
257 | + set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param string $type The type of queue being unlocked. |
267 | 267 | */ |
268 | - public function unlock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
269 | - delete_transient( $this->_get_lock_key( $type ) ); |
|
268 | + public function unlock_queue($type = EE_Messages_Queue::action_generating) { |
|
269 | + delete_transient($this->_get_lock_key($type)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $type The type of lock. |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) { |
|
281 | - return '_ee_lock_' . $type; |
|
280 | + protected function _get_lock_key($type = EE_Messages_Queue::action_generating) { |
|
281 | + return '_ee_lock_'.$type; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param string $type The type of lock |
290 | 290 | * @return int time to expiry in seconds. |
291 | 291 | */ |
292 | - protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) { |
|
293 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type ); |
|
292 | + protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) { |
|
293 | + return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return int |
309 | 309 | */ |
310 | 310 | protected function _get_rate_limit_expiry() { |
311 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS ); |
|
311 | + return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return int |
320 | 320 | */ |
321 | 321 | protected function _default_rate_limit() { |
322 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 ); |
|
322 | + return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param string $type The type of lock being checked for. |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | - public function is_locked( $type = EE_Messages_Queue::action_generating ) { |
|
349 | - return (bool) get_transient( $this->_get_lock_key( $type ) ); |
|
348 | + public function is_locked($type = EE_Messages_Queue::action_generating) { |
|
349 | + return (bool) get_transient($this->_get_lock_key($type)); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | |
@@ -361,9 +361,9 @@ discard block |
||
361 | 361 | * @return int |
362 | 362 | */ |
363 | 363 | public function get_rate_limit() { |
364 | - if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) { |
|
364 | + if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) { |
|
365 | 365 | $rate_limit = $this->_default_rate_limit(); |
366 | - set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() ); |
|
366 | + set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key()); |
|
367 | 367 | } |
368 | 368 | return $rate_limit; |
369 | 369 | } |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | * This updates existing rate limit with the new limit which is the old minus the batch. |
376 | 376 | * @param int $batch_completed This sets the new rate limit based on the given batch that was completed. |
377 | 377 | */ |
378 | - public function set_rate_limit( $batch_completed ) { |
|
378 | + public function set_rate_limit($batch_completed) { |
|
379 | 379 | //first get the most up to date rate limit (in case its expired and reset) |
380 | 380 | $rate_limit = $this->get_rate_limit(); |
381 | 381 | $new_limit = $rate_limit - $batch_completed; |
382 | 382 | //updating the transient option directly to avoid resetting the expiry. |
383 | - update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit ); |
|
383 | + update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param string $task This indicates what type of request is going to be initiated. |
394 | 394 | * @param int $priority This indicates the priority that triggers initiating the request. |
395 | 395 | */ |
396 | - public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) { |
|
396 | + public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { |
|
397 | 397 | //determine what status is matched with the priority as part of the trigger conditions. |
398 | 398 | $status = $task == 'generate' |
399 | 399 | ? EEM_Message::status_incomplete |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | // always make sure we save because either this will get executed immediately on a separate request |
402 | 402 | // or remains in the queue for the regularly scheduled queue batch. |
403 | 403 | $this->save(); |
404 | - if ( $this->_queue->count_by_priority_and_status( $priority, $status ) ) { |
|
405 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task ); |
|
404 | + if ($this->_queue->count_by_priority_and_status($priority, $status)) { |
|
405 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -427,50 +427,50 @@ discard block |
||
427 | 427 | * Also, if the messenger is an request type messenger (or a preview), |
428 | 428 | * its entirely possible that the messenger will exit before |
429 | 429 | */ |
430 | - public function execute( $save = true, $sending_messenger = null, $by_priority = false ) { |
|
430 | + public function execute($save = true, $sending_messenger = null, $by_priority = false) { |
|
431 | 431 | $messages_sent = 0; |
432 | 432 | $this->_did_hook = array(); |
433 | 433 | $this->_queue->rewind(); |
434 | - while ( $this->_queue->valid() ) { |
|
434 | + while ($this->_queue->valid()) { |
|
435 | 435 | $error_messages = array(); |
436 | 436 | /** @type EE_Message $message */ |
437 | 437 | $message = $this->_queue->current(); |
438 | 438 | //if the message in the queue has a sent status, then skip |
439 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_sent() ) ) { |
|
439 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_sent())) { |
|
440 | 440 | continue; |
441 | 441 | } |
442 | 442 | //if $by_priority is set and does not match then continue; |
443 | - if ( $by_priority && $by_priority != $message->priority() ) { |
|
443 | + if ($by_priority && $by_priority != $message->priority()) { |
|
444 | 444 | continue; |
445 | 445 | } |
446 | 446 | //error checking |
447 | - if ( ! $message->valid_messenger() ) { |
|
447 | + if ( ! $message->valid_messenger()) { |
|
448 | 448 | $error_messages[] = sprintf( |
449 | - __( 'The %s messenger is not active at time of sending.', 'event_espresso' ), |
|
449 | + __('The %s messenger is not active at time of sending.', 'event_espresso'), |
|
450 | 450 | $message->messenger() |
451 | 451 | ); |
452 | 452 | } |
453 | - if ( ! $message->valid_message_type() ) { |
|
453 | + if ( ! $message->valid_message_type()) { |
|
454 | 454 | $error_messages[] = sprintf( |
455 | - __( 'The %s message type is not active at the time of sending.', 'event_espresso' ), |
|
455 | + __('The %s message type is not active at the time of sending.', 'event_espresso'), |
|
456 | 456 | $message->message_type() |
457 | 457 | ); |
458 | 458 | } |
459 | 459 | // if there was supposed to be a sending messenger for this message, but it was invalid/inactive, |
460 | 460 | // then it will instead be an EE_Error object, so let's check for that |
461 | - if ( $sending_messenger instanceof EE_Error ) { |
|
461 | + if ($sending_messenger instanceof EE_Error) { |
|
462 | 462 | $error_messages[] = $sending_messenger->getMessage(); |
463 | 463 | } |
464 | 464 | // if there are no errors, then let's process the message |
465 | - if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) { |
|
465 | + if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) { |
|
466 | 466 | $messages_sent++; |
467 | 467 | } |
468 | - $this->_set_error_message( $message, $error_messages ); |
|
468 | + $this->_set_error_message($message, $error_messages); |
|
469 | 469 | //add modified time |
470 | - $message->set_modified( time() ); |
|
470 | + $message->set_modified(time()); |
|
471 | 471 | $this->_queue->next(); |
472 | 472 | } |
473 | - if ( $save ) { |
|
473 | + if ($save) { |
|
474 | 474 | $this->save(); |
475 | 475 | } |
476 | 476 | return $messages_sent; |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * @param mixed $sending_messenger (optional) |
486 | 486 | * @return bool |
487 | 487 | */ |
488 | - protected function _process_message( EE_Message $message, $sending_messenger = null ) { |
|
488 | + protected function _process_message(EE_Message $message, $sending_messenger = null) { |
|
489 | 489 | // these *should* have been validated in the execute() method above |
490 | 490 | $messenger = $message->messenger_object(); |
491 | 491 | $message_type = $message->message_type_object(); |
@@ -495,20 +495,20 @@ discard block |
||
495 | 495 | && $messenger instanceof EE_messenger |
496 | 496 | && $sending_messenger->name != $messenger->name |
497 | 497 | ) { |
498 | - $messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
498 | + $messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
499 | 499 | $messenger = $sending_messenger; |
500 | 500 | } |
501 | 501 | // send using messenger, but double check objects |
502 | - if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) { |
|
502 | + if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) { |
|
503 | 503 | //set hook for message type (but only if not using another messenger to send). |
504 | - if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) { |
|
505 | - $message_type->do_messenger_hooks( $messenger ); |
|
506 | - $this->_did_hook[ $message_type->name ] = 1; |
|
504 | + if ( ! isset($this->_did_hook[$message_type->name])) { |
|
505 | + $message_type->do_messenger_hooks($messenger); |
|
506 | + $this->_did_hook[$message_type->name] = 1; |
|
507 | 507 | } |
508 | 508 | //if preview then use preview method |
509 | 509 | return $this->_queue->is_preview() |
510 | - ? $this->_do_preview( $message, $messenger, $message_type, $this->_queue->is_test_send() ) |
|
511 | - : $this->_do_send( $message, $messenger, $message_type ); |
|
510 | + ? $this->_do_preview($message, $messenger, $message_type, $this->_queue->is_test_send()) |
|
511 | + : $this->_do_send($message, $messenger, $message_type); |
|
512 | 512 | } |
513 | 513 | return false; |
514 | 514 | } |
@@ -526,12 +526,12 @@ discard block |
||
526 | 526 | * @param array $status Stati to check for in queue |
527 | 527 | * @return int Count of EE_Message's matching the given status. |
528 | 528 | */ |
529 | - public function count_STS_in_queue( $status ) { |
|
529 | + public function count_STS_in_queue($status) { |
|
530 | 530 | $count = 0; |
531 | - $status = is_array( $status ) ? $status : array( $status ); |
|
531 | + $status = is_array($status) ? $status : array($status); |
|
532 | 532 | $this->_queue->rewind(); |
533 | - foreach( $this->_queue as $message ) { |
|
534 | - if ( in_array( $message->STS_ID(), $status ) ) { |
|
533 | + foreach ($this->_queue as $message) { |
|
534 | + if (in_array($message->STS_ID(), $status)) { |
|
535 | 535 | $count++; |
536 | 536 | } |
537 | 537 | } |
@@ -548,15 +548,15 @@ discard block |
||
548 | 548 | * @param $test_send |
549 | 549 | * @return bool true means all went well, false means, not so much. |
550 | 550 | */ |
551 | - protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
|
552 | - if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) { |
|
553 | - if ( ! $test_send ) { |
|
554 | - $message->set_content( $preview ); |
|
551 | + protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) { |
|
552 | + if ($preview = $messenger->get_preview($message, $message_type, $test_send)) { |
|
553 | + if ( ! $test_send) { |
|
554 | + $message->set_content($preview); |
|
555 | 555 | } |
556 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
556 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
557 | 557 | return true; |
558 | 558 | } else { |
559 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
559 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
560 | 560 | return false; |
561 | 561 | } |
562 | 562 | } |
@@ -572,12 +572,12 @@ discard block |
||
572 | 572 | * @param EE_message_type $message_type |
573 | 573 | * @return bool true means all went well, false means, not so much. |
574 | 574 | */ |
575 | - protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) { |
|
576 | - if ( $messenger->send_message( $message, $message_type ) ) { |
|
577 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
575 | + protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) { |
|
576 | + if ($messenger->send_message($message, $message_type)) { |
|
577 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
578 | 578 | return true; |
579 | 579 | } else { |
580 | - $message->set_STS_ID( EEM_Message::status_retry ); |
|
580 | + $message->set_STS_ID(EEM_Message::status_retry); |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | } |
@@ -591,21 +591,21 @@ discard block |
||
591 | 591 | * @param EE_Message $message |
592 | 592 | * @param array $error_messages the response from the messenger. |
593 | 593 | */ |
594 | - protected function _set_error_message( EE_Message $message, $error_messages ) { |
|
594 | + protected function _set_error_message(EE_Message $message, $error_messages) { |
|
595 | 595 | $error_messages = (array) $error_messages; |
596 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending() ) ) { |
|
596 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) { |
|
597 | 597 | $notices = EE_Error::has_notices(); |
598 | - $error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' ); |
|
599 | - if ( $notices === 1 ) { |
|
598 | + $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); |
|
599 | + if ($notices === 1) { |
|
600 | 600 | $notices = EE_Error::get_vanilla_notices(); |
601 | - $notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array(); |
|
602 | - $error_messages[] = implode( "\n", $notices['errors'] ); |
|
601 | + $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); |
|
602 | + $error_messages[] = implode("\n", $notices['errors']); |
|
603 | 603 | } |
604 | 604 | } |
605 | - if ( count( $error_messages ) > 0 ) { |
|
606 | - $msg = __( 'Message was not executed successfully.', 'event_espresso' ); |
|
607 | - $msg = $msg . "\n" . implode( "\n", $error_messages ); |
|
608 | - $message->set_error_message( $msg ); |
|
605 | + if (count($error_messages) > 0) { |
|
606 | + $msg = __('Message was not executed successfully.', 'event_espresso'); |
|
607 | + $msg = $msg."\n".implode("\n", $error_messages); |
|
608 | + $message->set_error_message($msg); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 |
@@ -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 | * This class is used for generating EE_Message objects with given info. |
@@ -116,17 +116,17 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return EE_Messages_Queue The new queue for holding generated EE_Message objects. |
118 | 118 | */ |
119 | - public function generate( $save = true ) { |
|
119 | + public function generate($save = true) { |
|
120 | 120 | //iterate through the messages in the queue, generate, and add to new queue. |
121 | 121 | $this->_generation_queue->get_queue()->rewind(); |
122 | - while ( $this->_generation_queue->get_queue()->valid() ) { |
|
122 | + while ($this->_generation_queue->get_queue()->valid()) { |
|
123 | 123 | //reset "current" properties |
124 | 124 | $this->_reset_current_properties(); |
125 | 125 | |
126 | 126 | /** @type EE_Message $msg */ |
127 | 127 | $msg = $this->_generation_queue->get_queue()->current(); |
128 | 128 | |
129 | - if ( $this->_verify() ) { |
|
129 | + if ($this->_verify()) { |
|
130 | 130 | //let's get generating! |
131 | 131 | $this->_generate(); |
132 | 132 | } |
@@ -138,26 +138,26 @@ discard block |
||
138 | 138 | $this->_generation_queue->get_queue()->next(); |
139 | 139 | $next_msg = $this->_generation_queue->get_queue()->current(); |
140 | 140 | //restore pointer to current item |
141 | - $this->_generation_queue->get_queue()->set_current( $msg ); |
|
141 | + $this->_generation_queue->get_queue()->set_current($msg); |
|
142 | 142 | |
143 | 143 | //if there are error messages then let's set the status and the error message. |
144 | - if ( $this->_error_msg ) { |
|
144 | + if ($this->_error_msg) { |
|
145 | 145 | //if the status is already debug only, then let's leave it at that. |
146 | - if ( $msg->STS_ID() !== EEM_Message::status_debug_only ) { |
|
147 | - $msg->set_STS_ID( EEM_Message::status_failed ); |
|
146 | + if ($msg->STS_ID() !== EEM_Message::status_debug_only) { |
|
147 | + $msg->set_STS_ID(EEM_Message::status_failed); |
|
148 | 148 | } |
149 | 149 | $msg->set_error_message( |
150 | - __( 'Message failed to generate for the following reasons: ' ) |
|
150 | + __('Message failed to generate for the following reasons: ') |
|
151 | 151 | . "\n" |
152 | - . implode( "\n", $this->_error_msg ) |
|
152 | + . implode("\n", $this->_error_msg) |
|
153 | 153 | ); |
154 | - $msg->set_modified( time() ); |
|
154 | + $msg->set_modified(time()); |
|
155 | 155 | } else { |
156 | 156 | //remove from db |
157 | 157 | $this->_generation_queue->get_queue()->delete(); |
158 | 158 | } |
159 | 159 | //next item |
160 | - $this->_generation_queue->get_queue()->set_current( $next_msg ); |
|
160 | + $this->_generation_queue->get_queue()->set_current($next_msg); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | //generation queue is ALWAYS saved to record any errors in the generation process. |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * so a EE_Extra_Meta entry could be created and attached to the EE_Message. In those cases the save flag is |
171 | 171 | * irrelevant. |
172 | 172 | */ |
173 | - if ( $save ) { |
|
173 | + if ($save) { |
|
174 | 174 | $this->_ready_queue->save(); |
175 | 175 | } |
176 | 176 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | protected function _reset_current_properties() { |
189 | 189 | $this->_verified = false; |
190 | 190 | //make sure any _data value in the current message type is reset |
191 | - if ( $this->_current_message_type instanceof EE_message_type ) { |
|
191 | + if ($this->_current_message_type instanceof EE_message_type) { |
|
192 | 192 | $this->_current_message_type->reset_data(); |
193 | 193 | } |
194 | 194 | $this->_current_messenger = $this->_current_message_type = $this->_current_data_handler = null; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | protected function _generate() { |
209 | 209 | //double check verification has run and that everything is ready to work with (saves us having to validate everything again). |
210 | - if ( ! $this->_verified ) { |
|
210 | + if ( ! $this->_verified) { |
|
211 | 211 | return false; //get out because we don't have a valid setup to work with. |
212 | 212 | } |
213 | 213 | |
@@ -217,34 +217,34 @@ discard block |
||
217 | 217 | $this->_current_data_handler, |
218 | 218 | $this->_generation_queue->get_queue()->current()->context() |
219 | 219 | ); |
220 | - } catch ( EE_Error $e ) { |
|
220 | + } catch (EE_Error $e) { |
|
221 | 221 | $this->_error_msg[] = $e->getMessage(); |
222 | 222 | return false; |
223 | 223 | } |
224 | 224 | |
225 | 225 | |
226 | 226 | //if no addressees then get out because there is nothing to generation (possible bad data). |
227 | - if ( ! $this->_valid_addressees( $addressees ) ) { |
|
228 | - $this->_generation_queue->get_queue()->current()->set_STS_ID( EEM_Message::status_debug_only ); |
|
229 | - $this->_error_msg[] = __( 'This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects. There were no attendees prepared by the data handler. |
|
230 | - Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso' ); |
|
227 | + if ( ! $this->_valid_addressees($addressees)) { |
|
228 | + $this->_generation_queue->get_queue()->current()->set_STS_ID(EEM_Message::status_debug_only); |
|
229 | + $this->_error_msg[] = __('This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects. There were no attendees prepared by the data handler. |
|
230 | + Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso'); |
|
231 | 231 | return false; |
232 | 232 | } |
233 | 233 | |
234 | 234 | $message_template_group = $this->_get_message_template_group(); |
235 | 235 | |
236 | 236 | //in the unlikely event there is no EE_Message_Template_Group available, get out! |
237 | - if ( ! $message_template_group instanceof EE_Message_Template_Group ) { |
|
238 | - $this->_error_msg[] = __( 'Unable to get the Message Templates for the Message being generated. No message template group accessible.', 'event_espresso' ); |
|
237 | + if ( ! $message_template_group instanceof EE_Message_Template_Group) { |
|
238 | + $this->_error_msg[] = __('Unable to get the Message Templates for the Message being generated. No message template group accessible.', 'event_espresso'); |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
242 | 242 | //get formatted templates for using to parse and setup EE_Message objects. |
243 | - $templates = $this->_get_templates( $message_template_group ); |
|
243 | + $templates = $this->_get_templates($message_template_group); |
|
244 | 244 | |
245 | 245 | |
246 | 246 | //setup new EE_Message objects (and add to _ready_queue) |
247 | - return $this->_assemble_messages( $addressees, $templates, $message_template_group ); |
|
247 | + return $this->_assemble_messages($addressees, $templates, $message_template_group); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -262,17 +262,17 @@ discard block |
||
262 | 262 | //so let's use that. |
263 | 263 | $GRP_ID = $this->_generation_queue->get_queue()->current()->GRP_ID(); |
264 | 264 | |
265 | - if ( $GRP_ID ) { |
|
265 | + if ($GRP_ID) { |
|
266 | 266 | //attempt to retrieve from repo first |
267 | - $GRP = $this->_template_collection->get_by_ID( $GRP_ID ); |
|
268 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
269 | - return $GRP; //got it! |
|
267 | + $GRP = $this->_template_collection->get_by_ID($GRP_ID); |
|
268 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
269 | + return $GRP; //got it! |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | //nope don't have it yet. Get from DB then add to repo |
273 | - $GRP = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
274 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
275 | - $this->_template_collection->add( $GRP ); |
|
273 | + $GRP = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
274 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
275 | + $this->_template_collection->add($GRP); |
|
276 | 276 | } |
277 | 277 | return $GRP; |
278 | 278 | } |
@@ -291,41 +291,41 @@ discard block |
||
291 | 291 | //in vanilla EE we're assuming there's only one event. |
292 | 292 | //However, if there are multiple events then we'll just use the default templates instead of different |
293 | 293 | // templates per event (which could create problems). |
294 | - if ( count( $this->_current_data_handler->events ) === 1 ) { |
|
295 | - foreach ( $this->_current_data_handler->events as $event ) { |
|
294 | + if (count($this->_current_data_handler->events) === 1) { |
|
295 | + foreach ($this->_current_data_handler->events as $event) { |
|
296 | 296 | $EVT_ID = $event['ID']; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | 300 | //before going any further, let's see if its in the queue |
301 | - $GRP = $this->_template_collection->get_by_key( $this->_template_collection->get_key( $this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID ) ); |
|
301 | + $GRP = $this->_template_collection->get_by_key($this->_template_collection->get_key($this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID)); |
|
302 | 302 | |
303 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
303 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
304 | 304 | return $GRP; |
305 | 305 | } |
306 | 306 | |
307 | 307 | //nope still no GRP? |
308 | 308 | //first we get the global template in case it has an override set. |
309 | - $global_template_qa = array_merge( array( 'MTP_is_global' => true ), $template_qa ); |
|
310 | - $global_GRP = EEM_Message_Template_Group::instance()->get_one( array( $global_template_qa ) ); |
|
309 | + $global_template_qa = array_merge(array('MTP_is_global' => true), $template_qa); |
|
310 | + $global_GRP = EEM_Message_Template_Group::instance()->get_one(array($global_template_qa)); |
|
311 | 311 | |
312 | 312 | //if this is an override, then we just return it. |
313 | - if ( $global_GRP instanceof EE_Message_Template_Group && $global_GRP->get( 'MTP_is_override' ) ) { |
|
314 | - $this->_template_collection->add( $global_GRP, $EVT_ID ); |
|
313 | + if ($global_GRP instanceof EE_Message_Template_Group && $global_GRP->get('MTP_is_override')) { |
|
314 | + $this->_template_collection->add($global_GRP, $EVT_ID); |
|
315 | 315 | return $global_GRP; |
316 | 316 | } |
317 | 317 | |
318 | 318 | //STILL here? Okay that means we want to see if there is event specific group and if there is we return it, |
319 | 319 | //otherwise we return the global group we retrieved. |
320 | - if ( $EVT_ID ) { |
|
320 | + if ($EVT_ID) { |
|
321 | 321 | $template_qa['Event.EVT_ID'] = $EVT_ID; |
322 | 322 | } |
323 | 323 | |
324 | - $GRP = EEM_Message_Template_Group::instance()->get_one( array( $template_qa ) ); |
|
324 | + $GRP = EEM_Message_Template_Group::instance()->get_one(array($template_qa)); |
|
325 | 325 | $GRP = $GRP instanceof EE_Message_Template_Group ? $GRP : $global_GRP; |
326 | 326 | |
327 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
328 | - $this->_template_collection->add( $GRP, $EVT_ID ); |
|
327 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
328 | + $this->_template_collection->add($GRP, $EVT_ID); |
|
329 | 329 | return $GRP; |
330 | 330 | } |
331 | 331 | |
@@ -349,15 +349,15 @@ discard block |
||
349 | 349 | * ) |
350 | 350 | * ) |
351 | 351 | */ |
352 | - protected function _get_templates( EE_Message_Template_Group $message_template_group ) { |
|
352 | + protected function _get_templates(EE_Message_Template_Group $message_template_group) { |
|
353 | 353 | $templates = array(); |
354 | 354 | $context_templates = $message_template_group->context_templates(); |
355 | - foreach ( $context_templates as $context => $template_fields ) { |
|
356 | - foreach ( $template_fields as $template_field => $template_obj ) { |
|
357 | - if ( ! $template_obj instanceof EE_Message_Template ) { |
|
355 | + foreach ($context_templates as $context => $template_fields) { |
|
356 | + foreach ($template_fields as $template_field => $template_obj) { |
|
357 | + if ( ! $template_obj instanceof EE_Message_Template) { |
|
358 | 358 | continue; |
359 | 359 | } |
360 | - $templates[ $template_field ][ $context ] = $template_obj->get( 'MTP_content' ); |
|
360 | + $templates[$template_field][$context] = $template_obj->get('MTP_content'); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | return $templates; |
@@ -379,20 +379,20 @@ discard block |
||
379 | 379 | * get added to the queue with EEM_Message::status_idle, unsuccessfully generated messages will get added |
380 | 380 | * to the queue as EEM_Message::status_failed. Very rarely should "false" be returned from this method. |
381 | 381 | */ |
382 | - protected function _assemble_messages( $addressees, $templates, EE_Message_Template_Group $message_template_group ) { |
|
382 | + protected function _assemble_messages($addressees, $templates, EE_Message_Template_Group $message_template_group) { |
|
383 | 383 | |
384 | 384 | //if templates are empty then get out because we can't generate anything. |
385 | - if ( ! $templates ) { |
|
385 | + if ( ! $templates) { |
|
386 | 386 | return false; |
387 | 387 | } |
388 | 388 | |
389 | 389 | //We use this as the counter for generated messages because don't forget we may be executing this inside of a |
390 | 390 | //generation_queue. So _ready_queue may have generated EE_Message objects already. |
391 | 391 | $generated_count = 0; |
392 | - foreach ( $addressees as $context => $recipients ) { |
|
393 | - foreach ( $recipients as $recipient ) { |
|
394 | - $message = $this->_setup_message_object( $context, $recipient, $templates, $message_template_group ); |
|
395 | - if ( $message instanceof EE_Message ) { |
|
392 | + foreach ($addressees as $context => $recipients) { |
|
393 | + foreach ($recipients as $recipient) { |
|
394 | + $message = $this->_setup_message_object($context, $recipient, $templates, $message_template_group); |
|
395 | + if ($message instanceof EE_Message) { |
|
396 | 396 | $this->_ready_queue->add( |
397 | 397 | $message, |
398 | 398 | array(), |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | ) { |
428 | 428 | //stuff we already know |
429 | 429 | $transaction_id = $recipient->txn instanceof EE_Transaction ? $recipient->txn->ID() : 0; |
430 | - $transaction_id = empty( $transaction_id ) && $this->_current_data_handler->txn instanceof EE_Transaction |
|
430 | + $transaction_id = empty($transaction_id) && $this->_current_data_handler->txn instanceof EE_Transaction |
|
431 | 431 | ? $this->_current_data_handler->txn->ID() |
432 | 432 | : $transaction_id; |
433 | 433 | $message_fields = array( |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | |
441 | 441 | //recipient id and type should be on the EE_Messages_Addressee object but if this is empty, let's try to grab the |
442 | 442 | //info from the att_obj found in the EE_Messages_Addressee object. |
443 | - if ( empty( $recipient->recipient_id ) || empty( $recipient->recipient_type ) ) { |
|
443 | + if (empty($recipient->recipient_id) || empty($recipient->recipient_type)) { |
|
444 | 444 | $message_fields['MSG_recipient_ID'] = $recipient->att_obj instanceof EE_Attendee |
445 | 445 | ? $recipient->att_obj->ID() |
446 | 446 | : 0; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | $message_fields['MSG_recipient_ID'] = $recipient->recipient_id; |
450 | 450 | $message_fields['MSG_recipient_type'] = $recipient->recipient_type; |
451 | 451 | } |
452 | - $message = EE_Message_Factory::create( $message_fields ); |
|
452 | + $message = EE_Message_Factory::create($message_fields); |
|
453 | 453 | |
454 | 454 | //grab valid shortcodes for shortcode parser |
455 | 455 | $mt_shortcodes = $this->_current_message_type->get_valid_shortcodes(); |
@@ -457,43 +457,43 @@ discard block |
||
457 | 457 | |
458 | 458 | //if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because that means this |
459 | 459 | //context is turned off) EXCEPT if we're previewing |
460 | - if ( empty( $templates['to'][ $context ] ) |
|
460 | + if (empty($templates['to'][$context]) |
|
461 | 461 | && ! $this->_generation_queue->get_queue()->is_preview() |
462 | - && ! $this->_current_messenger->allow_empty_to_field() ) { |
|
462 | + && ! $this->_current_messenger->allow_empty_to_field()) { |
|
463 | 463 | //we silently exit here and do NOT record a fail because the message is "turned off" by having no "to" field. |
464 | 464 | return false; |
465 | 465 | } |
466 | 466 | $error_msg = array(); |
467 | - foreach ( $templates as $field => $field_context ) { |
|
467 | + foreach ($templates as $field => $field_context) { |
|
468 | 468 | $error_msg = array(); |
469 | 469 | //let's setup the valid shortcodes for the incoming context. |
470 | - $valid_shortcodes = $mt_shortcodes[ $context ]; |
|
470 | + $valid_shortcodes = $mt_shortcodes[$context]; |
|
471 | 471 | //merge in valid shortcodes for the field. |
472 | - $shortcodes = isset($m_shortcodes[ $field ]) ? $m_shortcodes[ $field ] : $valid_shortcodes; |
|
473 | - if ( isset( $templates[ $field ][ $context ] ) ) { |
|
472 | + $shortcodes = isset($m_shortcodes[$field]) ? $m_shortcodes[$field] : $valid_shortcodes; |
|
473 | + if (isset($templates[$field][$context])) { |
|
474 | 474 | //prefix field. |
475 | - $column_name = 'MSG_' . $field; |
|
475 | + $column_name = 'MSG_'.$field; |
|
476 | 476 | try { |
477 | 477 | $content = $this->_shortcode_parser->parse_message_template( |
478 | - $templates[ $field ][ $context ], |
|
478 | + $templates[$field][$context], |
|
479 | 479 | $recipient, |
480 | 480 | $shortcodes, |
481 | 481 | $this->_current_message_type, |
482 | 482 | $this->_current_messenger, |
483 | 483 | $message ); |
484 | - $message->set_field_or_extra_meta( $column_name, $content ); |
|
485 | - } catch ( EE_Error $e ) { |
|
486 | - $error_msg[] = sprintf( __( 'There was a problem generating the content for the field %s: %s', 'event_espresso' ), $field, $e->getMessage() ); |
|
487 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
484 | + $message->set_field_or_extra_meta($column_name, $content); |
|
485 | + } catch (EE_Error $e) { |
|
486 | + $error_msg[] = sprintf(__('There was a problem generating the content for the field %s: %s', 'event_espresso'), $field, $e->getMessage()); |
|
487 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | - if ( $message->STS_ID() === EEM_Message::status_failed ) { |
|
493 | - $error_msg = __( 'There were problems generating this message:', 'event_espresso' ) . "\n" . implode( "\n", $error_msg ); |
|
494 | - $message->set_error_message( $error_msg ); |
|
492 | + if ($message->STS_ID() === EEM_Message::status_failed) { |
|
493 | + $error_msg = __('There were problems generating this message:', 'event_espresso')."\n".implode("\n", $error_msg); |
|
494 | + $message->set_error_message($error_msg); |
|
495 | 495 | } else { |
496 | - $message->set_STS_ID( EEM_Message::status_idle ); |
|
496 | + $message->set_STS_ID(EEM_Message::status_idle); |
|
497 | 497 | } |
498 | 498 | return $message; |
499 | 499 | } |
@@ -527,14 +527,14 @@ discard block |
||
527 | 527 | * @param array $addressees Keys correspond to contexts for the message type and values are EE_Messages_Addressee[] |
528 | 528 | * @return bool |
529 | 529 | */ |
530 | - protected function _valid_addressees( $addressees ) { |
|
531 | - if ( ! $addressees || ! is_array( $addressees ) ) { |
|
530 | + protected function _valid_addressees($addressees) { |
|
531 | + if ( ! $addressees || ! is_array($addressees)) { |
|
532 | 532 | return false; |
533 | 533 | } |
534 | 534 | |
535 | - foreach( $addressees as $addressee_array ) { |
|
536 | - foreach ( $addressee_array as $addressee ) { |
|
537 | - if ( ! $addressee instanceof EE_Messages_Addressee ) { |
|
535 | + foreach ($addressees as $addressee_array) { |
|
536 | + foreach ($addressee_array as $addressee) { |
|
537 | + if ( ! $addressee instanceof EE_Messages_Addressee) { |
|
538 | 538 | return false; |
539 | 539 | } |
540 | 540 | } |
@@ -555,19 +555,19 @@ discard block |
||
555 | 555 | protected function _validate_messenger_and_message_type() { |
556 | 556 | |
557 | 557 | //first are there any existing error messages? If so then return. |
558 | - if ( $this->_error_msg ) { |
|
558 | + if ($this->_error_msg) { |
|
559 | 559 | return false; |
560 | 560 | } |
561 | 561 | /** @type EE_Message $message */ |
562 | 562 | $message = $this->_generation_queue->get_queue()->current(); |
563 | 563 | try { |
564 | - $this->_current_messenger = $message->valid_messenger( true ) ? $message->messenger_object() : null; |
|
565 | - } catch ( Exception $e ) { |
|
564 | + $this->_current_messenger = $message->valid_messenger(true) ? $message->messenger_object() : null; |
|
565 | + } catch (Exception $e) { |
|
566 | 566 | $this->_error_msg[] = $e->getMessage(); |
567 | 567 | } |
568 | 568 | try { |
569 | - $this->_current_message_type = $message->valid_message_type( true ) ? $message->message_type_object() : null; |
|
570 | - } catch ( Exception $e ) { |
|
569 | + $this->_current_message_type = $message->valid_message_type(true) ? $message->message_type_object() : null; |
|
570 | + } catch (Exception $e) { |
|
571 | 571 | $this->_error_msg[] = $e->getMessage(); |
572 | 572 | } |
573 | 573 | |
@@ -579,10 +579,10 @@ discard block |
||
579 | 579 | ! $this->_generation_queue->get_queue()->is_preview() |
580 | 580 | && $this->_generation_queue->get_queue()->get_data_handler() !== 'EE_Messages_Preview_incoming_data' ) |
581 | 581 | ) { |
582 | - $this->_error_msg[] = __( 'There is no generation data for this message. Unable to generate.' ); |
|
582 | + $this->_error_msg[] = __('There is no generation data for this message. Unable to generate.'); |
|
583 | 583 | } |
584 | 584 | |
585 | - return empty( $this->_error_msg ); |
|
585 | + return empty($this->_error_msg); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | |
600 | 600 | //First, are there any existing error messages? If so, return because if there were errors elsewhere this can't |
601 | 601 | //be used anyways. |
602 | - if ( $this->_error_msg ) { |
|
602 | + if ($this->_error_msg) { |
|
603 | 603 | return false; |
604 | 604 | } |
605 | 605 | |
@@ -608,29 +608,29 @@ discard block |
||
608 | 608 | /** @type EE_Messages_incoming_data $data_handler_class_name - well not really... just the class name actually */ |
609 | 609 | $data_handler_class_name = $this->_generation_queue->get_queue()->get_data_handler() |
610 | 610 | ? $this->_generation_queue->get_queue()->get_data_handler() |
611 | - : 'EE_Messages_' . $this->_current_message_type->get_data_handler( $generation_data ) . '_incoming_data'; |
|
611 | + : 'EE_Messages_'.$this->_current_message_type->get_data_handler($generation_data).'_incoming_data'; |
|
612 | 612 | |
613 | 613 | //If this EE_Message is for a preview, then let's switch out to the preview data handler. |
614 | - if ( $this->_generation_queue->get_queue()->is_preview() ) { |
|
615 | - $data_handler_class_name = 'EE_Messages_Preview_incoming_data'; |
|
614 | + if ($this->_generation_queue->get_queue()->is_preview()) { |
|
615 | + $data_handler_class_name = 'EE_Messages_Preview_incoming_data'; |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | //First get the class name for the data handler (and also verifies it exists. |
619 | - if ( ! class_exists( $data_handler_class_name ) ) { |
|
619 | + if ( ! class_exists($data_handler_class_name)) { |
|
620 | 620 | $this->_error_msg[] = sprintf( |
621 | - __( 'The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes. Looking for %s.', 'event_espresso' ), |
|
621 | + __('The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes. Looking for %s.', 'event_espresso'), |
|
622 | 622 | $data_handler_class_name |
623 | 623 | ); |
624 | 624 | return false; |
625 | 625 | } |
626 | 626 | |
627 | 627 | //convert generation_data for data_handler_instantiation. |
628 | - $generation_data = $data_handler_class_name::convert_data_from_persistent_storage( $generation_data ); |
|
628 | + $generation_data = $data_handler_class_name::convert_data_from_persistent_storage($generation_data); |
|
629 | 629 | |
630 | 630 | //note, this may set error messages as well. |
631 | - $this->_set_data_handler( $generation_data, $data_handler_class_name ); |
|
631 | + $this->_set_data_handler($generation_data, $data_handler_class_name); |
|
632 | 632 | |
633 | - return empty( $this->_error_msg ); |
|
633 | + return empty($this->_error_msg); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | |
@@ -647,16 +647,16 @@ discard block |
||
647 | 647 | * |
648 | 648 | * @return void. |
649 | 649 | */ |
650 | - protected function _set_data_handler( $generating_data, $data_handler_class_name ) { |
|
650 | + protected function _set_data_handler($generating_data, $data_handler_class_name) { |
|
651 | 651 | //valid classname for the data handler. Now let's setup the key for the data handler repository to see if there |
652 | 652 | //is already a ready data handler in the repository. |
653 | - $this->_current_data_handler = $this->_data_handler_collection->get_by_key( $this->_data_handler_collection->get_key( $data_handler_class_name, $generating_data ) ); |
|
654 | - if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data ) { |
|
653 | + $this->_current_data_handler = $this->_data_handler_collection->get_by_key($this->_data_handler_collection->get_key($data_handler_class_name, $generating_data)); |
|
654 | + if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data) { |
|
655 | 655 | //no saved data_handler in the repo so let's set one up and add it to the repo. |
656 | 656 | try { |
657 | - $this->_current_data_handler = new $data_handler_class_name( $generating_data ); |
|
658 | - $this->_data_handler_collection->add( $this->_current_data_handler, $generating_data ); |
|
659 | - } catch( EE_Error $e ) { |
|
657 | + $this->_current_data_handler = new $data_handler_class_name($generating_data); |
|
658 | + $this->_data_handler_collection->add($this->_current_data_handler, $generating_data); |
|
659 | + } catch (EE_Error $e) { |
|
660 | 660 | $this->_error_msg[] = $e->get_error(); |
661 | 661 | } |
662 | 662 | } |
@@ -676,13 +676,13 @@ discard block |
||
676 | 676 | * @param bool $preview Indicate whether this is being used for a preview or not. |
677 | 677 | * @return mixed Prepped data for persisting to the queue. false is returned if unable to prep data. |
678 | 678 | */ |
679 | - protected function _prepare_data_for_queue( EE_Message_To_Generate $message_to_generate, $preview ) { |
|
679 | + protected function _prepare_data_for_queue(EE_Message_To_Generate $message_to_generate, $preview) { |
|
680 | 680 | /** @type EE_Messages_incoming_data $data_handler - well not really... just the class name actually */ |
681 | - $data_handler = $message_to_generate->get_data_handler_class_name( $preview ); |
|
682 | - if ( ! $message_to_generate->valid() ) { |
|
681 | + $data_handler = $message_to_generate->get_data_handler_class_name($preview); |
|
682 | + if ( ! $message_to_generate->valid()) { |
|
683 | 683 | return false; //unable to get the data because the info in the EE_Message_To_Generate class is invalid. |
684 | 684 | } |
685 | - return $data_handler::convert_data_for_persistent_storage( $message_to_generate->data() ); |
|
685 | + return $data_handler::convert_data_for_persistent_storage($message_to_generate->data()); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | |
@@ -695,26 +695,26 @@ discard block |
||
695 | 695 | * @param EE_Message_To_Generate $message_to_generate |
696 | 696 | * @param bool $test_send Whether this is just a test send or not. Typically used for previews. |
697 | 697 | */ |
698 | - public function create_and_add_message_to_queue( EE_Message_To_Generate $message_to_generate, $test_send = false ) { |
|
698 | + public function create_and_add_message_to_queue(EE_Message_To_Generate $message_to_generate, $test_send = false) { |
|
699 | 699 | //prep data |
700 | - $data = $this->_prepare_data_for_queue( $message_to_generate, $message_to_generate->preview() ); |
|
700 | + $data = $this->_prepare_data_for_queue($message_to_generate, $message_to_generate->preview()); |
|
701 | 701 | |
702 | 702 | $message = $message_to_generate->get_EE_Message(); |
703 | 703 | |
704 | 704 | //is there a GRP_ID in the request? |
705 | - if ( $GRP_ID = EE_Registry::instance()->REQ->get( 'GRP_ID' ) ) { |
|
706 | - $message->set_GRP_ID( $GRP_ID ); |
|
705 | + if ($GRP_ID = EE_Registry::instance()->REQ->get('GRP_ID')) { |
|
706 | + $message->set_GRP_ID($GRP_ID); |
|
707 | 707 | } |
708 | 708 | |
709 | - if ( $data === false ) { |
|
710 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
711 | - $message->set_error_message( __( 'Unable to prepare data for persistence to the database.', 'event_espresso' ) ); |
|
709 | + if ($data === false) { |
|
710 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
711 | + $message->set_error_message(__('Unable to prepare data for persistence to the database.', 'event_espresso')); |
|
712 | 712 | } else { |
713 | 713 | //make sure that the data handler is cached on the message as well |
714 | 714 | $data['data_handler_class_name'] = $message_to_generate->get_data_handler_class_name(); |
715 | 715 | } |
716 | 716 | |
717 | - $this->_generation_queue->add( $message, $data, $message_to_generate->preview(), $test_send ); |
|
717 | + $this->_generation_queue->add($message, $data, $message_to_generate->preview(), $test_send); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 |
@@ -101,42 +101,42 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return EEM_Message |
103 | 103 | */ |
104 | - protected function __construct( $timezone = null ) { |
|
105 | - $this->singular_item = __('Message','event_espresso'); |
|
106 | - $this->plural_item = __('Messages','event_espresso'); |
|
104 | + protected function __construct($timezone = null) { |
|
105 | + $this->singular_item = __('Message', 'event_espresso'); |
|
106 | + $this->plural_item = __('Messages', 'event_espresso'); |
|
107 | 107 | |
108 | 108 | //used for token generator |
109 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
109 | + EE_Registry::instance()->load_helper('URL'); |
|
110 | 110 | |
111 | 111 | $this->_tables = array( |
112 | - 'Message'=>new EE_Primary_Table('esp_message','MSG_ID') |
|
112 | + 'Message'=>new EE_Primary_Table('esp_message', 'MSG_ID') |
|
113 | 113 | ); |
114 | 114 | |
115 | 115 | $allowed_priority = array( |
116 | - self::priority_high => __( 'high', 'event_espresso' ), |
|
117 | - self::priority_medium => __( 'medium', 'event_espresso' ), |
|
118 | - self::priority_low => __( 'low', 'event_espresso' ) |
|
116 | + self::priority_high => __('high', 'event_espresso'), |
|
117 | + self::priority_medium => __('medium', 'event_espresso'), |
|
118 | + self::priority_low => __('low', 'event_espresso') |
|
119 | 119 | ); |
120 | 120 | |
121 | 121 | $this->_fields = array( |
122 | 122 | 'Message'=>array( |
123 | - 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID','event_espresso')), |
|
124 | - 'MSG_token' => new EE_Plain_Text_Field( 'MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso' ), false, EEH_URL::generate_unique_token() ), |
|
125 | - 'GRP_ID'=>new EE_Foreign_Key_Int_Field( 'GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso' ), true, 0, 'Message_Template_Group' ), |
|
126 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( 'Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso' ), true, 0, 'Transaction' ), |
|
127 | - 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __( 'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso' ), false, 'email' ), |
|
128 | - 'MSG_message_type' => new EE_Plain_Text_Field( 'MSG_message_type', __( 'Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso' ), false, 'receipt' ), |
|
129 | - 'MSG_context' => new EE_Plain_Text_Field( 'MSG_context', __( 'Context', 'event_espresso' ), false ), |
|
130 | - 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field( 'MSG_recipient_ID', __( 'Recipient ID', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
131 | - 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field( 'MSG_recipient_type', __( 'Recipient Type', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
132 | - 'MSG_content' => new EE_Maybe_Serialized_Text_Field( 'MSG_content', __( 'Content', 'event_espresso' ), true, '' ), |
|
133 | - 'MSG_to' => new EE_Maybe_Serialized_Text_Field( 'MSG_to', __( 'Address To', 'event_espresso' ), true ), |
|
134 | - 'MSG_from' => new EE_Maybe_Serialized_Text_Field( 'MSG_from', __( 'Address From', 'event_espresso' ), true ), |
|
135 | - 'MSG_subject' => new EE_Maybe_Serialized_Text_Field( 'MSG_subject', __( 'Subject', 'event_espresso' ), true, '' ), |
|
136 | - 'MSG_priority' => new EE_Enum_Integer_Field( 'MSG_priority', __( 'Priority', 'event_espresso' ), false, self::priority_low, $allowed_priority ), |
|
137 | - 'STS_ID' => new EE_Foreign_Key_String_Field( 'STS_ID', __( 'Status', 'event_espresso' ), false, self::status_incomplete, 'Status' ), |
|
138 | - 'MSG_created' => new EE_Datetime_Field( 'MSG_created', __( 'Created', 'event_espresso' ), false, time() ), |
|
139 | - 'MSG_modified' => new EE_Datetime_Field( 'MSG_modified', __( 'Modified', 'event_espresso' ), true, time() ) |
|
123 | + 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')), |
|
124 | + 'MSG_token' => new EE_Plain_Text_Field('MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso'), false, EEH_URL::generate_unique_token()), |
|
125 | + 'GRP_ID'=>new EE_Foreign_Key_Int_Field('GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, 'Message_Template_Group'), |
|
126 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso'), true, 0, 'Transaction'), |
|
127 | + 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso'), false, 'email'), |
|
128 | + 'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), false, 'receipt'), |
|
129 | + 'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false), |
|
130 | + 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
131 | + 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
132 | + 'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', __('Content', 'event_espresso'), true, ''), |
|
133 | + 'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), true), |
|
134 | + 'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', __('Address From', 'event_espresso'), true), |
|
135 | + 'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', __('Subject', 'event_espresso'), true, ''), |
|
136 | + 'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), false, self::priority_low, $allowed_priority), |
|
137 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, self::status_incomplete, 'Status'), |
|
138 | + 'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, time()), |
|
139 | + 'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, time()) |
|
140 | 140 | ) |
141 | 141 | ); |
142 | 142 | $this->_model_relations = array( |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
147 | 147 | 'Transaction' => new EE_Belongs_To_Relation() |
148 | 148 | ); |
149 | - parent::__construct( $timezone ); |
|
149 | + parent::__construct($timezone); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | public function create_default_object() { |
158 | 158 | /** @type EE_Message $message */ |
159 | 159 | $message = parent::create_default_object(); |
160 | - if ( $message instanceof EE_Message ) { |
|
161 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
160 | + if ($message instanceof EE_Message) { |
|
161 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
162 | 162 | } |
163 | 163 | return null; |
164 | 164 | } |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param mixed $cols_n_values |
170 | 170 | * @return \EE_Message |
171 | 171 | */ |
172 | - public function instantiate_class_from_array_or_object( $cols_n_values ) { |
|
172 | + public function instantiate_class_from_array_or_object($cols_n_values) { |
|
173 | 173 | /** @type EE_Message $message */ |
174 | - $message = parent::instantiate_class_from_array_or_object( $cols_n_values ); |
|
175 | - if ( $message instanceof EE_Message ) { |
|
176 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
174 | + $message = parent::instantiate_class_from_array_or_object($cols_n_values); |
|
175 | + if ($message instanceof EE_Message) { |
|
176 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
177 | 177 | } |
178 | 178 | return null; |
179 | 179 | } |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | * @param string $message_type the message type slug |
187 | 187 | * @return boolean |
188 | 188 | */ |
189 | - public function message_sent_for_attendee( $attendee, $message_type ) { |
|
190 | - $attendee_ID = EEM_Attendee::instance()->ensure_is_ID( $attendee ); |
|
191 | - return $this->exists( array( array( |
|
189 | + public function message_sent_for_attendee($attendee, $message_type) { |
|
190 | + $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee); |
|
191 | + return $this->exists(array(array( |
|
192 | 192 | 'Attendee.ATT_ID' => $attendee_ID, |
193 | 193 | 'MSG_message_type' => $message_type, |
194 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
195 | - ) ) ); |
|
194 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
195 | + ))); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | * @param string $message_type the message type slug |
205 | 205 | * @return boolean |
206 | 206 | */ |
207 | - public function message_sent_for_registration( $registration, $message_type ) { |
|
208 | - $registrationID = EEM_Registration::instance()->ensure_is_ID( $registration ); |
|
209 | - return $this->exists( array( array( |
|
207 | + public function message_sent_for_registration($registration, $message_type) { |
|
208 | + $registrationID = EEM_Registration::instance()->ensure_is_ID($registration); |
|
209 | + return $this->exists(array(array( |
|
210 | 210 | 'Registration.REG_ID' => $registrationID, |
211 | 211 | 'MSG_message_type' => $message_type, |
212 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
213 | - ) ) ); |
|
212 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
213 | + ))); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * @param string $token |
222 | 222 | * @return EE_Message |
223 | 223 | */ |
224 | - public function get_one_by_token( $token ) { |
|
225 | - return $this->get_one( array( array( |
|
224 | + public function get_one_by_token($token) { |
|
225 | + return $this->get_one(array(array( |
|
226 | 226 | 'MSG_token' => $token |
227 | - ) ) ); |
|
227 | + ))); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | * Returns stati that indicate the message HAS been sent |
233 | 233 | * @return array of strings for possible stati |
234 | 234 | */ |
235 | - public function stati_indicating_sent(){ |
|
236 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_sent', array( self::status_sent ) ); |
|
235 | + public function stati_indicating_sent() { |
|
236 | + return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent)); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | * @return array of strings for possible stati. |
245 | 245 | */ |
246 | 246 | public function stati_indicating_to_send() { |
247 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_to_send', array( self::status_idle, self::status_resend ) ); |
|
247 | + return apply_filters('FHEE__EEM_Message__stati_indicating_to_send', array(self::status_idle, self::status_resend)); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
251 | 251 | |
252 | 252 | public function stati_indicating_failed_sending() { |
253 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_failed_sending', array( self::status_failed, self::status_retry, self::status_debug_only ) ); |
|
253 | + return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', array(self::status_failed, self::status_retry, self::status_debug_only)); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -285,11 +285,11 @@ discard block |
||
285 | 285 | // the value, matches the corresponding EEM_Base child reference. |
286 | 286 | $expected_vars = $this->_expected_vars_for_query_inject(); |
287 | 287 | $query_params[0] = array(); |
288 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
289 | - $request_value = EE_Registry::instance()->REQ->get( $request_key ); |
|
290 | - if ( $request_value ) { |
|
288 | + foreach ($expected_vars as $request_key => $model_name) { |
|
289 | + $request_value = EE_Registry::instance()->REQ->get($request_key); |
|
290 | + if ($request_value) { |
|
291 | 291 | //special case |
292 | - switch ( $request_key ) { |
|
292 | + switch ($request_key) { |
|
293 | 293 | case '_REG_ID' : |
294 | 294 | $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array( |
295 | 295 | 'Transaction.Registration.REG_ID' => $request_value, |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | ); |
302 | 302 | break; |
303 | 303 | default : |
304 | - $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value; |
|
304 | + $query_params[0]['AND**filter_by']['OR**filter_by_'.$request_key][$model_name.'.'.$request_key] = $request_value; |
|
305 | 305 | break; |
306 | 306 | } |
307 | 307 | } |
@@ -317,53 +317,53 @@ discard block |
||
317 | 317 | $expected_vars = $this->_expected_vars_for_query_inject(); |
318 | 318 | $pretty_label = ''; |
319 | 319 | $label_parts = array(); |
320 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
321 | - $model = EE_Registry::instance()->load_model( $model_name ); |
|
322 | - if ( $model_field_value = EE_Registry::instance()->REQ->get( $request_key ) ) { |
|
323 | - switch ( $request_key ) { |
|
320 | + foreach ($expected_vars as $request_key => $model_name) { |
|
321 | + $model = EE_Registry::instance()->load_model($model_name); |
|
322 | + if ($model_field_value = EE_Registry::instance()->REQ->get($request_key)) { |
|
323 | + switch ($request_key) { |
|
324 | 324 | case '_REG_ID' : |
325 | 325 | $label_parts[] = sprintf( |
326 | - esc_html__( 'Registration with the ID: %s', 'event_espresso' ), |
|
326 | + esc_html__('Registration with the ID: %s', 'event_espresso'), |
|
327 | 327 | $model_field_value |
328 | 328 | ); |
329 | 329 | break; |
330 | 330 | case 'ATT_ID' : |
331 | 331 | /** @var EE_Attendee $attendee */ |
332 | - $attendee = $model->get_one_by_ID( $model_field_value ); |
|
332 | + $attendee = $model->get_one_by_ID($model_field_value); |
|
333 | 333 | $label_parts[] = $attendee instanceof EE_Attendee |
334 | - ? sprintf( esc_html__( 'Attendee %s', 'event_espresso' ), $attendee->full_name() ) |
|
335 | - : sprintf( esc_html__( 'Attendee ID: %s', 'event_espresso' ), $model_field_value ); |
|
334 | + ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name()) |
|
335 | + : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value); |
|
336 | 336 | break; |
337 | 337 | case 'ID' : |
338 | 338 | /** @var EE_WP_User $wpUser */ |
339 | - $wpUser = $model->get_one_by_ID( $model_field_value ); |
|
339 | + $wpUser = $model->get_one_by_ID($model_field_value); |
|
340 | 340 | $label_parts[] = $wpUser instanceof EE_WP_User |
341 | - ? sprintf( esc_html__( 'WP User: %s', 'event_espresso' ), $wpUser->name() ) |
|
342 | - : sprintf( esc_html__( 'WP User ID: %s', 'event_espresso' ), $model_field_value ); |
|
341 | + ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name()) |
|
342 | + : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value); |
|
343 | 343 | break; |
344 | 344 | case 'TXN_ID' : |
345 | 345 | $label_parts[] = sprintf( |
346 | - esc_html__( 'Transaction with the ID: %s', 'event_espresso' ), |
|
346 | + esc_html__('Transaction with the ID: %s', 'event_espresso'), |
|
347 | 347 | $model_field_value |
348 | 348 | ); |
349 | 349 | break; |
350 | 350 | case 'EVT_ID' : |
351 | 351 | /** @var EE_Event $Event */ |
352 | - $Event = $model->get_one_by_ID( $model_field_value ); |
|
352 | + $Event = $model->get_one_by_ID($model_field_value); |
|
353 | 353 | $label_parts[] = $Event instanceof EE_Event |
354 | - ? sprintf( esc_html__( 'for the Event: %s', 'event_espresso' ), $Event->name() ) |
|
355 | - : sprintf( esc_html__( 'for the Event with ID: %s', 'event_espresso' ), $model_field_value ); |
|
354 | + ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name()) |
|
355 | + : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value); |
|
356 | 356 | break; |
357 | 357 | } |
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | - if ( $label_parts ) { |
|
361 | + if ($label_parts) { |
|
362 | 362 | |
363 | 363 | //prepend to the last element of $label_parts an "and". |
364 | - if ( count( $label_parts ) > 1 ) { |
|
365 | - $label_parts_index_to_prepend = count( $label_parts ) - 1; |
|
366 | - $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ]; |
|
364 | + if (count($label_parts) > 1) { |
|
365 | + $label_parts_index_to_prepend = count($label_parts) - 1; |
|
366 | + $label_parts[$label_parts_index_to_prepend] = 'and'.$label_parts[$label_parts_index_to_prepend]; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | $pretty_label .= sprintf( |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | 'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.', |
373 | 373 | 'event_espresso' |
374 | 374 | ), |
375 | - implode( ', ', $label_parts ) |
|
375 | + implode(', ', $label_parts) |
|
376 | 376 | ); |
377 | 377 | } |
378 | 378 | return $pretty_label; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | public function localized_status( $statuses, $plural = FALSE, $schema = 'upper' ) { |
84 | 84 | //note these are all in lower case because ucwords() on upper case will NOT convert. |
85 | 85 | $translation_array = array( |
86 | - EEM_Registration::status_id_pending_payment => array( |
|
86 | + EEM_Registration::status_id_pending_payment => array( |
|
87 | 87 | __('pending payment', 'event_espresso'), //singular |
88 | 88 | __('pending payments', 'event_espresso') //plural |
89 | 89 | ), |
@@ -217,22 +217,22 @@ discard block |
||
217 | 217 | __('queued for sending', 'event_espresso'), |
218 | 218 | __('queued for sending', 'event_espresso'), |
219 | 219 | ), |
220 | - EEM_Message::status_failed => array( |
|
221 | - __('failed', 'event_espresso'), |
|
222 | - __('failed', 'event_espresso'), |
|
223 | - ), |
|
220 | + EEM_Message::status_failed => array( |
|
221 | + __('failed', 'event_espresso'), |
|
222 | + __('failed', 'event_espresso'), |
|
223 | + ), |
|
224 | 224 | EEM_Message::status_debug_only => array( |
225 | 225 | __( 'debug only', 'event_espresso' ), |
226 | 226 | __( 'debug only', 'event_espresso' ) |
227 | 227 | ), |
228 | - EEM_Message::status_resend => array( |
|
229 | - __('queued for resending', 'event_espresso'), |
|
230 | - __('queued for resending', 'event_espresso'), |
|
231 | - ), |
|
232 | - EEM_Message::status_incomplete => array( |
|
233 | - __('queued for generating', 'event_espresso'), |
|
234 | - __('queued for generating', 'event_espresso'), |
|
235 | - ), |
|
228 | + EEM_Message::status_resend => array( |
|
229 | + __('queued for resending', 'event_espresso'), |
|
230 | + __('queued for resending', 'event_espresso'), |
|
231 | + ), |
|
232 | + EEM_Message::status_incomplete => array( |
|
233 | + __('queued for generating', 'event_espresso'), |
|
234 | + __('queued for generating', 'event_espresso'), |
|
235 | + ), |
|
236 | 236 | EEM_Message::status_retry => array( |
237 | 237 | __('failed sending, can be retried', 'event_espresso'), |
238 | 238 | __('failed sending, can be retried', 'event_espresso'), |
@@ -261,37 +261,37 @@ discard block |
||
261 | 261 | __('trashed', 'event_espresso'), |
262 | 262 | __('trashed', 'event_espresso') |
263 | 263 | ), |
264 | - ); |
|
264 | + ); |
|
265 | 265 | |
266 | 266 | $translation_array = apply_filters( 'FHEE__EEM_Status__localized_status__translation_array', $translation_array ); |
267 | 267 | |
268 | 268 | if ( !is_array($statuses) ) |
269 | 269 | throw new EE_Error( __('The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', 'event_espresso') ); |
270 | 270 | |
271 | - $translation = array(); |
|
271 | + $translation = array(); |
|
272 | 272 | |
273 | - foreach ( $statuses as $id => $code ) { |
|
274 | - if ( isset( $translation_array[$id] ) ) { |
|
275 | - $translation[$id] = $plural ? $translation_array[$id][1] : $translation_array[$id][0]; |
|
276 | - } else { |
|
277 | - $translation[$id] = $code; |
|
278 | - } |
|
273 | + foreach ( $statuses as $id => $code ) { |
|
274 | + if ( isset( $translation_array[$id] ) ) { |
|
275 | + $translation[$id] = $plural ? $translation_array[$id][1] : $translation_array[$id][0]; |
|
276 | + } else { |
|
277 | + $translation[$id] = $code; |
|
278 | + } |
|
279 | 279 | |
280 | - //schema |
|
281 | - switch ( $schema ) { |
|
282 | - case 'lower' : |
|
283 | - $translation[$id] = strtolower( $translation[$id] ); //even though these start in lower case, this will catch any statuses added via filter. |
|
284 | - break; |
|
285 | - case 'sentence' : |
|
286 | - $translation[$id] = ucwords( $translation[$id] ); |
|
287 | - break; |
|
288 | - case 'upper' : |
|
289 | - $translation[$id] = strtoupper( $translation[$id] ); |
|
290 | - break; |
|
291 | - } |
|
292 | - } |
|
280 | + //schema |
|
281 | + switch ( $schema ) { |
|
282 | + case 'lower' : |
|
283 | + $translation[$id] = strtolower( $translation[$id] ); //even though these start in lower case, this will catch any statuses added via filter. |
|
284 | + break; |
|
285 | + case 'sentence' : |
|
286 | + $translation[$id] = ucwords( $translation[$id] ); |
|
287 | + break; |
|
288 | + case 'upper' : |
|
289 | + $translation[$id] = strtoupper( $translation[$id] ); |
|
290 | + break; |
|
291 | + } |
|
292 | + } |
|
293 | 293 | |
294 | - return $translation; |
|
294 | + return $translation; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * |
14 | 14 | * ------------------------------------------------------------------------ |
15 | 15 | */ |
16 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
16 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
17 | 17 | /** |
18 | 18 | * |
19 | 19 | * Class EEM_Status |
@@ -32,32 +32,32 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @return EEM_Status |
34 | 34 | */ |
35 | - protected function __construct( $timezone = NULL ) { |
|
36 | - $this->singular_item = __('Status','event_espresso'); |
|
37 | - $this->plural_item = __('Stati','event_espresso'); |
|
35 | + protected function __construct($timezone = NULL) { |
|
36 | + $this->singular_item = __('Status', 'event_espresso'); |
|
37 | + $this->plural_item = __('Stati', 'event_espresso'); |
|
38 | 38 | $this->_tables = array( |
39 | 39 | 'Status'=> new EE_Primary_Table('esp_status', 'STS_ID') |
40 | 40 | ); |
41 | 41 | $this->_fields = array( |
42 | 42 | 'Status'=>array( |
43 | - 'STS_ID'=> new EE_Primary_Key_String_Field('STS_ID', __('Status ID','event_espresso')), |
|
44 | - 'STS_code'=>new EE_Plain_Text_Field('STS_code',__('Status Code','event_espresso'),false, ''), |
|
43 | + 'STS_ID'=> new EE_Primary_Key_String_Field('STS_ID', __('Status ID', 'event_espresso')), |
|
44 | + 'STS_code'=>new EE_Plain_Text_Field('STS_code', __('Status Code', 'event_espresso'), false, ''), |
|
45 | 45 | 'STS_type'=>new EE_Enum_Text_Field( |
46 | 46 | 'STS_type', |
47 | 47 | __("Type", "event_espresso"), |
48 | 48 | false, |
49 | 49 | 'event', |
50 | 50 | array( |
51 | - 'event'=> __("Event", "event_espresso"),//deprecated |
|
51 | + 'event'=> __("Event", "event_espresso"), //deprecated |
|
52 | 52 | 'registration'=> __("Registration", "event_espresso"), |
53 | 53 | 'transaction'=> __("Transaction", "event_espresso"), |
54 | 54 | 'payment'=> __("Payment", "event_espresso"), |
55 | 55 | 'email'=> __("Email", "event_espresso"), |
56 | 56 | 'message' => __("Message", "event_espresso") |
57 | 57 | )), |
58 | - 'STS_can_edit'=>new EE_Boolean_Field('STS_can_edit', __('Editable?','event_espresso'), false), |
|
58 | + 'STS_can_edit'=>new EE_Boolean_Field('STS_can_edit', __('Editable?', 'event_espresso'), false), |
|
59 | 59 | 'STS_desc'=>new EE_Simple_HTML_Field('STS_desc', __("Description", "event_espresso"), false, ''), |
60 | - 'STS_open'=>new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false,false) |
|
60 | + 'STS_open'=>new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false, false) |
|
61 | 61 | )); |
62 | 62 | $this->_model_relations = array( |
63 | 63 | 'Registration'=>new EE_Has_Many_Relation(), |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | 'Payment'=>new EE_Has_Many_Relation() |
66 | 66 | ); |
67 | 67 | //this model is generally available for reading |
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
68 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
69 | 69 | |
70 | - parent::__construct( $timezone ); |
|
70 | + parent::__construct($timezone); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @throws EE_Error |
81 | 81 | * @return array an array of translated strings for the incoming status id. |
82 | 82 | */ |
83 | - public function localized_status( $statuses, $plural = FALSE, $schema = 'upper' ) { |
|
83 | + public function localized_status($statuses, $plural = FALSE, $schema = 'upper') { |
|
84 | 84 | //note these are all in lower case because ucwords() on upper case will NOT convert. |
85 | 85 | $translation_array = array( |
86 | 86 | EEM_Registration::status_id_pending_payment => array( |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | __('failed', 'event_espresso'), |
223 | 223 | ), |
224 | 224 | EEM_Message::status_debug_only => array( |
225 | - __( 'debug only', 'event_espresso' ), |
|
226 | - __( 'debug only', 'event_espresso' ) |
|
225 | + __('debug only', 'event_espresso'), |
|
226 | + __('debug only', 'event_espresso') |
|
227 | 227 | ), |
228 | 228 | EEM_Message::status_resend => array( |
229 | 229 | __('queued for resending', 'event_espresso'), |
@@ -263,30 +263,30 @@ discard block |
||
263 | 263 | ), |
264 | 264 | ); |
265 | 265 | |
266 | - $translation_array = apply_filters( 'FHEE__EEM_Status__localized_status__translation_array', $translation_array ); |
|
266 | + $translation_array = apply_filters('FHEE__EEM_Status__localized_status__translation_array', $translation_array); |
|
267 | 267 | |
268 | - if ( !is_array($statuses) ) |
|
269 | - throw new EE_Error( __('The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', 'event_espresso') ); |
|
268 | + if ( ! is_array($statuses)) |
|
269 | + throw new EE_Error(__('The incoming statuses argument must be an array with keys as the $status_id and values as the $status_code', 'event_espresso')); |
|
270 | 270 | |
271 | 271 | $translation = array(); |
272 | 272 | |
273 | - foreach ( $statuses as $id => $code ) { |
|
274 | - if ( isset( $translation_array[$id] ) ) { |
|
273 | + foreach ($statuses as $id => $code) { |
|
274 | + if (isset($translation_array[$id])) { |
|
275 | 275 | $translation[$id] = $plural ? $translation_array[$id][1] : $translation_array[$id][0]; |
276 | 276 | } else { |
277 | 277 | $translation[$id] = $code; |
278 | 278 | } |
279 | 279 | |
280 | 280 | //schema |
281 | - switch ( $schema ) { |
|
281 | + switch ($schema) { |
|
282 | 282 | case 'lower' : |
283 | - $translation[$id] = strtolower( $translation[$id] ); //even though these start in lower case, this will catch any statuses added via filter. |
|
283 | + $translation[$id] = strtolower($translation[$id]); //even though these start in lower case, this will catch any statuses added via filter. |
|
284 | 284 | break; |
285 | 285 | case 'sentence' : |
286 | - $translation[$id] = ucwords( $translation[$id] ); |
|
286 | + $translation[$id] = ucwords($translation[$id]); |
|
287 | 287 | break; |
288 | 288 | case 'upper' : |
289 | - $translation[$id] = strtoupper( $translation[$id] ); |
|
289 | + $translation[$id] = strtoupper($translation[$id]); |
|
290 | 290 | break; |
291 | 291 | } |
292 | 292 | } |