@@ -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 | * Event Espresso |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @param bool $routing |
96 | 96 | */ |
97 | - public function __construct( $routing = true ) { |
|
97 | + public function __construct($routing = true) { |
|
98 | 98 | //make sure messages autoloader is running |
99 | 99 | EED_Messages::set_autoloaders(); |
100 | - parent::__construct( $routing ); |
|
100 | + parent::__construct($routing); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | $this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array(); |
113 | 113 | |
114 | - $this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : null; |
|
114 | + $this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null; |
|
115 | 115 | $this->_load_message_resource_manager(); |
116 | 116 | //we're also going to set the active messengers and active message types in here. |
117 | 117 | $this->_active_messengers = $this->_message_resource_manager->active_messengers(); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @throws EE_Error |
132 | 132 | */ |
133 | 133 | protected function _load_message_resource_manager() { |
134 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
134 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | $messengers = $this->_message_resource_manager->active_messengers(); |
148 | 148 | //setup messengers for selects |
149 | 149 | $i = 1; |
150 | - foreach ( $messengers as $messenger_name => $messenger ) { |
|
151 | - if ( $messenger instanceof EE_Messenger ) { |
|
152 | - $m_values[ $i ][ 'id' ] = $messenger_name; |
|
153 | - $m_values[ $i ][ 'text' ] = ucwords( $messenger->label[ 'singular' ] ); |
|
150 | + foreach ($messengers as $messenger_name => $messenger) { |
|
151 | + if ($messenger instanceof EE_Messenger) { |
|
152 | + $m_values[$i]['id'] = $messenger_name; |
|
153 | + $m_values[$i]['text'] = ucwords($messenger->label['singular']); |
|
154 | 154 | $i++; |
155 | 155 | } |
156 | 156 | } |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | $mt_values = array(); |
170 | 170 | $message_types = $this->_message_resource_manager->active_message_types(); |
171 | 171 | $i = 1; |
172 | - foreach ( $message_types as $messenger_name => $message_type ) { |
|
173 | - foreach ( $message_type as $message_type_name => $args ) { |
|
174 | - $message_type = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
175 | - if ( $message_type instanceof EE_Message_Type ) { |
|
176 | - $mt_values[ $i ][ 'id' ] = $message_type_name; |
|
177 | - $mt_values[ $i ][ 'text' ] = ucwords( $message_type->label[ 'singular' ] ); |
|
172 | + foreach ($message_types as $messenger_name => $message_type) { |
|
173 | + foreach ($message_type as $message_type_name => $args) { |
|
174 | + $message_type = $this->_message_resource_manager->get_message_type($message_type_name); |
|
175 | + if ($message_type instanceof EE_Message_Type) { |
|
176 | + $mt_values[$i]['id'] = $message_type_name; |
|
177 | + $mt_values[$i]['text'] = ucwords($message_type->label['singular']); |
|
178 | 178 | $i++; |
179 | 179 | } |
180 | 180 | } |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | |
186 | 186 | |
187 | 187 | protected function _ajax_hooks() { |
188 | - add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) ); |
|
189 | - add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') ); |
|
190 | - add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') ); |
|
191 | - add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) ); |
|
192 | - add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) ); |
|
188 | + add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle')); |
|
189 | + add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle')); |
|
190 | + add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings')); |
|
191 | + add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form')); |
|
192 | + add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack')); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | * @return void |
222 | 222 | */ |
223 | 223 | protected function _set_page_routes() { |
224 | - $grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] ) |
|
224 | + $grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID']) |
|
225 | 225 | ? $this->_req_data['GRP_ID'] |
226 | 226 | : 0; |
227 | - $grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] ) |
|
227 | + $grp_id = empty($grp_id) && ! empty($this->_req_data['id']) |
|
228 | 228 | ? $this->_req_data['id'] |
229 | 229 | : $grp_id; |
230 | - $msg_id = ! empty( $this->_req_data['MSG_ID'] ) && ! is_array( $this->_req_data['MSG_ID'] ) |
|
230 | + $msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID']) |
|
231 | 231 | ? $this->_req_data['MSG_ID'] |
232 | 232 | : 0; |
233 | 233 | |
@@ -269,35 +269,35 @@ discard block |
||
269 | 269 | 'insert_message_template' => array( |
270 | 270 | 'func' => '_insert_or_update_message_template', |
271 | 271 | 'capability' => 'ee_edit_messages', |
272 | - 'args' => array( 'new_template' => true ), |
|
272 | + 'args' => array('new_template' => true), |
|
273 | 273 | 'noheader' => true |
274 | 274 | ), |
275 | 275 | 'update_message_template' => array( |
276 | 276 | 'func' => '_insert_or_update_message_template', |
277 | 277 | 'capability' => 'ee_edit_message', |
278 | 278 | 'obj_id' => $grp_id, |
279 | - 'args' => array( 'new_template' => false ), |
|
279 | + 'args' => array('new_template' => false), |
|
280 | 280 | 'noheader' => true |
281 | 281 | ), |
282 | 282 | 'trash_message_template' => array( |
283 | 283 | 'func' => '_trash_or_restore_message_template', |
284 | 284 | 'capability' => 'ee_delete_message', |
285 | 285 | 'obj_id' => $grp_id, |
286 | - 'args' => array( 'trash' => true, 'all' => true ), |
|
286 | + 'args' => array('trash' => true, 'all' => true), |
|
287 | 287 | 'noheader' => true |
288 | 288 | ), |
289 | 289 | 'trash_message_template_context' => array( |
290 | 290 | 'func' => '_trash_or_restore_message_template', |
291 | 291 | 'capability' => 'ee_delete_message', |
292 | 292 | 'obj_id' => $grp_id, |
293 | - 'args' => array( 'trash' => true ), |
|
293 | + 'args' => array('trash' => true), |
|
294 | 294 | 'noheader' => true |
295 | 295 | ), |
296 | 296 | 'restore_message_template' => array( |
297 | 297 | 'func' => '_trash_or_restore_message_template', |
298 | 298 | 'capability' => 'ee_delete_message', |
299 | 299 | 'obj_id' => $grp_id, |
300 | - 'args' => array( 'trash' => false, 'all' => true ), |
|
300 | + 'args' => array('trash' => false, 'all' => true), |
|
301 | 301 | 'noheader' => true |
302 | 302 | ), |
303 | 303 | 'restore_message_template_context' => array( |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | 'order' => 10 |
373 | 373 | ), |
374 | 374 | 'list_table' => 'EE_Message_List_Table', |
375 | - 'qtips' => array( 'EE_Message_List_Table_Tips' ), |
|
375 | + 'qtips' => array('EE_Message_List_Table_Tips'), |
|
376 | 376 | 'require_nonce' => false |
377 | 377 | ), |
378 | 378 | 'global_mtps' => array( |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | 'filename' => 'messages_overview_other', |
412 | 412 | ), |
413 | 413 | ), |
414 | - 'help_tour' => array( 'Messages_Overview_Help_Tour' ), |
|
414 | + 'help_tour' => array('Messages_Overview_Help_Tour'), |
|
415 | 415 | 'require_nonce' => false |
416 | 416 | ), |
417 | 417 | 'custom_mtps' => array( |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | ), |
447 | 447 | 'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'), |
448 | 448 | 'has_metaboxes' => true, |
449 | - 'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ), |
|
449 | + 'help_tour' => array('Message_Templates_Edit_Help_Tour'), |
|
450 | 450 | 'help_tabs' => array( |
451 | 451 | 'edit_message_template' => array( |
452 | 452 | 'title' => __('Message Template Editor', 'event_espresso'), |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | 'filename' => 'messages_settings_messengers' |
503 | 503 | ), |
504 | 504 | ), |
505 | - 'help_tour' => array( 'Messages_Settings_Help_Tour' ), |
|
505 | + 'help_tour' => array('Messages_Settings_Help_Tour'), |
|
506 | 506 | 'require_nonce' => false |
507 | 507 | ) |
508 | 508 | ); |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | |
536 | 536 | |
537 | 537 | protected function _add_screen_options_default() { |
538 | - $this->_admin_page_title = __( 'Message Activity', 'event_espresso' ); |
|
538 | + $this->_admin_page_title = __('Message Activity', 'event_espresso'); |
|
539 | 539 | $this->_per_page_screen_option(); |
540 | 540 | } |
541 | 541 | |
@@ -557,37 +557,37 @@ discard block |
||
557 | 557 | |
558 | 558 | |
559 | 559 | public function messages_help_tab() { |
560 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php' ); |
|
560 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php'); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
564 | 564 | public function messengers_help_tab() { |
565 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php' ); |
|
565 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php'); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | |
569 | 569 | public function message_types_help_tab() { |
570 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php' ); |
|
570 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php'); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | |
574 | 574 | public function messages_overview_help_tab() { |
575 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php' ); |
|
575 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php'); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
579 | 579 | public function message_templates_help_tab() { |
580 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php' ); |
|
580 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php'); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | |
584 | 584 | public function edit_message_template_help_tab() { |
585 | - $args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />'; |
|
586 | - $args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />'; |
|
587 | - $args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />'; |
|
588 | - $args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />'; |
|
589 | - $args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />'; |
|
590 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
585 | + $args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />'; |
|
586 | + $args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />'; |
|
587 | + $args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />'; |
|
588 | + $args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />'; |
|
589 | + $args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />'; |
|
590 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | |
@@ -595,22 +595,22 @@ discard block |
||
595 | 595 | public function message_template_shortcodes_help_tab() { |
596 | 596 | $this->_set_shortcodes(); |
597 | 597 | $args['shortcodes'] = $this->_shortcodes; |
598 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', $args ); |
|
598 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', $args); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | |
602 | 602 | |
603 | 603 | public function preview_message_help_tab() { |
604 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php' ); |
|
604 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php'); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | |
608 | 608 | public function settings_help_tab() { |
609 | - $args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'; |
|
610 | - $args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'; |
|
609 | + $args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />'; |
|
610 | + $args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />'; |
|
611 | 611 | $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>'; |
612 | 612 | $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>'; |
613 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args); |
|
613 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | |
@@ -618,31 +618,31 @@ discard block |
||
618 | 618 | |
619 | 619 | |
620 | 620 | public function load_scripts_styles() { |
621 | - wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION ); |
|
621 | + wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION); |
|
622 | 622 | wp_enqueue_style('espresso_ee_msg'); |
623 | 623 | |
624 | - 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 ); |
|
625 | - wp_register_script( 'ee-msg-list-table-js', EE_MSG_ASSETS_URL. 'ee_message_admin_list_table.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION ); |
|
624 | + 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); |
|
625 | + wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | |
629 | 629 | |
630 | 630 | public function load_scripts_styles_default() { |
631 | - wp_enqueue_script( 'ee-msg-list-table-js' ); |
|
631 | + wp_enqueue_script('ee-msg-list-table-js'); |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | |
635 | 635 | |
636 | 636 | |
637 | 637 | |
638 | - public function wp_editor_css( $mce_css ) { |
|
638 | + public function wp_editor_css($mce_css) { |
|
639 | 639 | //if we're on the edit_message_template route |
640 | - if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_Messenger ) { |
|
640 | + if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_Messenger) { |
|
641 | 641 | $message_type_name = $this->_active_message_type_name; |
642 | 642 | |
643 | 643 | //we're going to REPLACE the existing mce css |
644 | 644 | //we need to get the css file location from the active messenger |
645 | - $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation ); |
|
645 | + $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | return $mce_css; |
@@ -660,37 +660,37 @@ discard block |
||
660 | 660 | $this->_message_template_group->messenger_obj()->label['singular'], |
661 | 661 | $this->_message_template_group->message_type_obj()->label['singular'] |
662 | 662 | ); |
663 | - 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' ); |
|
663 | + 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'); |
|
664 | 664 | |
665 | - wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION ); |
|
665 | + wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION); |
|
666 | 666 | |
667 | 667 | wp_enqueue_script('ee_admin_js'); |
668 | 668 | wp_enqueue_script('ee_msgs_edit_js'); |
669 | 669 | |
670 | 670 | //add in special css for tiny_mce |
671 | - add_filter( 'mce_css', array( $this, 'wp_editor_css' ) ); |
|
671 | + add_filter('mce_css', array($this, 'wp_editor_css')); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | |
675 | 675 | |
676 | 676 | public function load_scripts_styles_display_preview_message() { |
677 | 677 | $this->_set_message_template_group(); |
678 | - if ( isset( $this->_req_data['messenger'] ) ) { |
|
678 | + if (isset($this->_req_data['messenger'])) { |
|
679 | 679 | $this->_active_messenger = $this->_active_messengers[$this->_req_data['messenger']]; |
680 | 680 | } |
681 | 681 | |
682 | - $message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : ''; |
|
682 | + $message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : ''; |
|
683 | 683 | |
684 | 684 | |
685 | - wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, true, 'preview', $this->_variation ) ); |
|
685 | + wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'preview', $this->_variation)); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | |
689 | 689 | |
690 | 690 | public function load_scripts_styles_settings() { |
691 | - wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION ); |
|
692 | - wp_enqueue_style( 'ee-text-links' ); |
|
693 | - wp_enqueue_style( 'ee-message-settings' ); |
|
691 | + wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION); |
|
692 | + wp_enqueue_style('ee-text-links'); |
|
693 | + wp_enqueue_style('ee-message-settings'); |
|
694 | 694 | |
695 | 695 | wp_enqueue_script('ee-messages-settings'); |
696 | 696 | } |
@@ -720,37 +720,37 @@ discard block |
||
720 | 720 | * set views array for message queue list table |
721 | 721 | */ |
722 | 722 | public function _set_list_table_views_default() { |
723 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
723 | + EE_Registry::instance()->load_helper('Template'); |
|
724 | 724 | |
725 | - $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' ) |
|
725 | + $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'message_list_table_bulk_actions') |
|
726 | 726 | ? array( |
727 | - 'generate_now' => __( 'Generate Now', 'event_espresso' ), |
|
728 | - 'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ), |
|
729 | - 'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ), |
|
730 | - 'send_now' => __( 'Send Now', 'event_espresso' ) |
|
727 | + 'generate_now' => __('Generate Now', 'event_espresso'), |
|
728 | + 'generate_and_send_now' => __('Generate and Send Now', 'event_espresso'), |
|
729 | + 'queue_for_resending' => __('Queue for Resending', 'event_espresso'), |
|
730 | + 'send_now' => __('Send Now', 'event_espresso') |
|
731 | 731 | ) |
732 | 732 | : array(); |
733 | 733 | |
734 | - $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'message_list_table_bulk_actions' ) |
|
735 | - ? array( 'delete_ee_messages' => __( 'Delete Messages', 'event_espresso' ) ) |
|
734 | + $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'message_list_table_bulk_actions') |
|
735 | + ? array('delete_ee_messages' => __('Delete Messages', 'event_espresso')) |
|
736 | 736 | : array(); |
737 | 737 | |
738 | 738 | |
739 | 739 | $this->_views = array( |
740 | 740 | 'all' => array( |
741 | 741 | 'slug' => 'all', |
742 | - 'label' => __( 'All', 'event_espresso' ), |
|
742 | + 'label' => __('All', 'event_espresso'), |
|
743 | 743 | 'count' => 0, |
744 | - 'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action ) |
|
744 | + 'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action) |
|
745 | 745 | ) |
746 | 746 | ); |
747 | 747 | |
748 | 748 | |
749 | - foreach ( EEM_Message::instance()->all_statuses() as $status ) { |
|
749 | + foreach (EEM_Message::instance()->all_statuses() as $status) { |
|
750 | 750 | $status_bulk_actions = $common_bulk_actions; |
751 | 751 | //unset bulk actions not applying to status |
752 | - if ( ! empty( $status_bulk_actions ) ) { |
|
753 | - switch ( $status ) { |
|
752 | + if ( ! empty($status_bulk_actions)) { |
|
753 | + switch ($status) { |
|
754 | 754 | case EEM_Message::status_idle : |
755 | 755 | case EEM_Message::status_resend : |
756 | 756 | $status_bulk_actions['send_now'] = $common_bulk_actions['send_now']; |
@@ -761,20 +761,20 @@ discard block |
||
761 | 761 | break; |
762 | 762 | |
763 | 763 | case EEM_Message::status_incomplete : |
764 | - unset( $status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now'] ); |
|
764 | + unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']); |
|
765 | 765 | break; |
766 | 766 | |
767 | 767 | case EEM_Message::status_retry : |
768 | 768 | case EEM_Message::status_sent : |
769 | - unset( $status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now'] ); |
|
769 | + unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']); |
|
770 | 770 | break; |
771 | 771 | } |
772 | 772 | } |
773 | - $this->_views[ strtolower( $status ) ] = array( |
|
774 | - 'slug' => strtolower( $status ), |
|
775 | - 'label' => EEH_Template::pretty_status( $status, false, 'sentence' ), |
|
773 | + $this->_views[strtolower($status)] = array( |
|
774 | + 'slug' => strtolower($status), |
|
775 | + 'label' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
776 | 776 | 'count' => 0, |
777 | - 'bulk_action' => array_merge( $status_bulk_actions, $delete_bulk_action ) |
|
777 | + 'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action) |
|
778 | 778 | ); |
779 | 779 | } |
780 | 780 | } |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | protected function _message_queue_list_table() { |
794 | 794 | $this->_search_btn_label = __('Message Activity', 'event_espresso'); |
795 | 795 | $this->_template_args['per_column'] = 6; |
796 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_message_legend_items() ); |
|
796 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items()); |
|
797 | 797 | $this->display_admin_list_table_page_with_no_sidebar(); |
798 | 798 | } |
799 | 799 | |
@@ -805,8 +805,8 @@ discard block |
||
805 | 805 | $action_css_classes = EEH_MSG_Template::get_message_action_icons(); |
806 | 806 | $action_items = array(); |
807 | 807 | |
808 | - foreach( $action_css_classes as $action_item => $action_details ) { |
|
809 | - if ( $action_item === 'see_notifications_for' ) { |
|
808 | + foreach ($action_css_classes as $action_item => $action_details) { |
|
809 | + if ($action_item === 'see_notifications_for') { |
|
810 | 810 | continue; |
811 | 811 | } |
812 | 812 | $action_items[$action_item] = array( |
@@ -818,31 +818,31 @@ discard block |
||
818 | 818 | /** @type array $status_items status legend setup*/ |
819 | 819 | $status_items = array( |
820 | 820 | 'sent_status' => array( |
821 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent, |
|
822 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_sent, FALSE, 'sentence' ) |
|
821 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent, |
|
822 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, FALSE, 'sentence') |
|
823 | 823 | ), |
824 | 824 | 'idle_status' => array( |
825 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle, |
|
826 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_idle, FALSE, 'sentence' ) |
|
825 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle, |
|
826 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, FALSE, 'sentence') |
|
827 | 827 | ), |
828 | 828 | 'failed_status' => array( |
829 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed, |
|
830 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_failed, FALSE, 'sentence' ) |
|
829 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed, |
|
830 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, FALSE, 'sentence') |
|
831 | 831 | ), |
832 | 832 | 'resend_status' => array( |
833 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend, |
|
834 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_resend, FALSE, 'sentence' ) |
|
833 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend, |
|
834 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, FALSE, 'sentence') |
|
835 | 835 | ), |
836 | 836 | 'incomplete_status' => array( |
837 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete, |
|
838 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_incomplete, FALSE, 'sentence' ) |
|
837 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete, |
|
838 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, FALSE, 'sentence') |
|
839 | 839 | ), |
840 | 840 | 'retry_status' => array( |
841 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry, |
|
842 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_retry, FALSE, 'sentence' ) |
|
841 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry, |
|
842 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, FALSE, 'sentence') |
|
843 | 843 | ) |
844 | 844 | ); |
845 | - return array_merge( $action_items, $status_items ); |
|
845 | + return array_merge($action_items, $status_items); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | |
@@ -852,9 +852,9 @@ discard block |
||
852 | 852 | |
853 | 853 | protected function _custom_mtps_preview() { |
854 | 854 | $this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso'); |
855 | - $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' ) . '" />'; |
|
855 | + $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').'" />'; |
|
856 | 856 | $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>'; |
857 | - $this->display_admin_caf_preview_page( 'custom_message_types', false ); |
|
857 | + $this->display_admin_caf_preview_page('custom_message_types', false); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | |
@@ -878,31 +878,31 @@ discard block |
||
878 | 878 | * |
879 | 879 | * @return array |
880 | 880 | */ |
881 | - public function get_message_templates( $perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true ) { |
|
881 | + public function get_message_templates($perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true) { |
|
882 | 882 | |
883 | 883 | $MTP = EEM_Message_Template_Group::instance(); |
884 | 884 | |
885 | 885 | $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby']; |
886 | 886 | $orderby = $this->_req_data['orderby']; |
887 | 887 | |
888 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC'; |
|
888 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
889 | 889 | |
890 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
891 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage; |
|
890 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
891 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage; |
|
892 | 892 | |
893 | - $offset = ($current_page-1)*$per_page; |
|
894 | - $limit = $all ? null : array( $offset, $per_page ); |
|
893 | + $offset = ($current_page - 1) * $per_page; |
|
894 | + $limit = $all ? null : array($offset, $per_page); |
|
895 | 895 | |
896 | 896 | |
897 | 897 | //options will match what is in the _views array property |
898 | - switch( $type ) { |
|
898 | + switch ($type) { |
|
899 | 899 | |
900 | 900 | case 'in_use': |
901 | - $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true ); |
|
901 | + $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true); |
|
902 | 902 | break; |
903 | 903 | |
904 | 904 | default: |
905 | - $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global ); |
|
905 | + $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global); |
|
906 | 906 | |
907 | 907 | } |
908 | 908 | |
@@ -937,8 +937,8 @@ discard block |
||
937 | 937 | $installed_message_types = $this->_message_resource_manager->installed_message_types(); |
938 | 938 | $installed = array(); |
939 | 939 | |
940 | - foreach ( $installed_message_types as $message_type ) { |
|
941 | - $installed[ $message_type->name ] = $message_type; |
|
940 | + foreach ($installed_message_types as $message_type) { |
|
941 | + $installed[$message_type->name] = $message_type; |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | return $installed; |
@@ -957,24 +957,24 @@ discard block |
||
957 | 957 | * |
958 | 958 | * @throws EE_error |
959 | 959 | */ |
960 | - protected function _add_message_template( $message_type = '', $messenger='', $GRP_ID = '' ) { |
|
960 | + protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') { |
|
961 | 961 | //set values override any request data |
962 | - $message_type = !empty( $message_type ) ? $message_type : ''; |
|
963 | - $message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type; |
|
962 | + $message_type = ! empty($message_type) ? $message_type : ''; |
|
963 | + $message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type; |
|
964 | 964 | |
965 | - $messenger = !empty( $messenger ) ? $messenger : ''; |
|
966 | - $messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger; |
|
965 | + $messenger = ! empty($messenger) ? $messenger : ''; |
|
966 | + $messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger; |
|
967 | 967 | |
968 | - $GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : ''; |
|
969 | - $GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
968 | + $GRP_ID = ! empty($GRP_ID) ? $GRP_ID : ''; |
|
969 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
970 | 970 | |
971 | 971 | //we need messenger and message type. They should be coming from the event editor. If not here then return error |
972 | - if ( empty( $message_type ) || empty( $messenger ) ) |
|
973 | - {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));} |
|
972 | + if (empty($message_type) || empty($messenger)) |
|
973 | + {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso')); } |
|
974 | 974 | |
975 | 975 | //we need the GRP_ID for the template being used as the base for the new template |
976 | - if ( empty( $GRP_ID ) ) |
|
977 | - {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' ) );} |
|
976 | + if (empty($GRP_ID)) |
|
977 | + {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')); } |
|
978 | 978 | |
979 | 979 | //let's just make sure the template gets generated! |
980 | 980 | |
@@ -995,8 +995,8 @@ discard block |
||
995 | 995 | * @param int $GRP_ID GRP_ID for the related message template group this new template will be based |
996 | 996 | * off of. |
997 | 997 | */ |
998 | - public function add_message_template( $message_type, $messenger, $GRP_ID ) { |
|
999 | - $this->_add_message_template( $message_type, $messenger, $GRP_ID ); |
|
998 | + public function add_message_template($message_type, $messenger, $GRP_ID) { |
|
999 | + $this->_add_message_template($message_type, $messenger, $GRP_ID); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | |
@@ -1007,53 +1007,53 @@ discard block |
||
1007 | 1007 | * @return void |
1008 | 1008 | */ |
1009 | 1009 | protected function _edit_message_template() { |
1010 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1010 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1011 | 1011 | $template_fields = ''; |
1012 | 1012 | $sidebar_fields = ''; |
1013 | 1013 | //we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates. |
1014 | - add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 ); |
|
1014 | + add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2); |
|
1015 | 1015 | |
1016 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false; |
|
1016 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false; |
|
1017 | 1017 | |
1018 | 1018 | $this->_set_shortcodes(); //this also sets the _message_template property. |
1019 | 1019 | $message_template_group = $this->_message_template_group; |
1020 | 1020 | $c_label = $message_template_group->context_label(); |
1021 | 1021 | $c_config = $message_template_group->contexts_config(); |
1022 | 1022 | |
1023 | - reset( $c_config ); |
|
1024 | - $context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] ) ? strtolower($this->_req_data['context']) : key($c_config); |
|
1023 | + reset($c_config); |
|
1024 | + $context = isset($this->_req_data['context']) && ! empty($this->_req_data['context']) ? strtolower($this->_req_data['context']) : key($c_config); |
|
1025 | 1025 | |
1026 | 1026 | |
1027 | - if ( empty($GRP_ID) ) { |
|
1027 | + if (empty($GRP_ID)) { |
|
1028 | 1028 | $action = 'insert_message_template'; |
1029 | 1029 | //$button_both = false; |
1030 | 1030 | //$button_text = array( __( 'Save','event_espresso') ); |
1031 | 1031 | //$button_actions = array('something_different'); |
1032 | 1032 | //$referrer = false; |
1033 | - $edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => true ), EE_MSG_ADMIN_URL ); |
|
1033 | + $edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => true), EE_MSG_ADMIN_URL); |
|
1034 | 1034 | } else { |
1035 | 1035 | $action = 'update_message_template'; |
1036 | 1036 | //$button_both = true; |
1037 | 1037 | //$button_text = array(); |
1038 | 1038 | //$button_actions = array(); |
1039 | 1039 | //$referrer = $this->_admin_base_url; |
1040 | - $edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => true ), EE_MSG_ADMIN_URL ); |
|
1040 | + $edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => true), EE_MSG_ADMIN_URL); |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | //set active messenger for this view |
1044 | - $this->_active_messenger = $this->_active_messengers[ $message_template_group->messenger() ]; |
|
1044 | + $this->_active_messenger = $this->_active_messengers[$message_template_group->messenger()]; |
|
1045 | 1045 | $this->_active_message_type_name = $message_template_group->message_type(); |
1046 | 1046 | |
1047 | 1047 | |
1048 | 1048 | //Do we have any validation errors? |
1049 | 1049 | $validators = $this->_get_transient(); |
1050 | - $v_fields = !empty($validators) ? array_keys($validators) : array(); |
|
1050 | + $v_fields = ! empty($validators) ? array_keys($validators) : array(); |
|
1051 | 1051 | |
1052 | 1052 | |
1053 | 1053 | //we need to assemble the title from Various details |
1054 | - $context_label = sprintf( __('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label'] )); |
|
1054 | + $context_label = sprintf(__('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label'])); |
|
1055 | 1055 | |
1056 | - $title = sprintf( __(' %s %s Template %s', 'event_espresso'), ucwords($message_template_group->messenger_obj()->label['singular']), ucwords($message_template_group->message_type_obj()->label['singular']), $context_label ); |
|
1056 | + $title = sprintf(__(' %s %s Template %s', 'event_espresso'), ucwords($message_template_group->messenger_obj()->label['singular']), ucwords($message_template_group->message_type_obj()->label['singular']), $context_label); |
|
1057 | 1057 | |
1058 | 1058 | $this->_template_args['GRP_ID'] = $GRP_ID; |
1059 | 1059 | $this->_template_args['message_template'] = $message_template_group; |
@@ -1061,9 +1061,9 @@ discard block |
||
1061 | 1061 | |
1062 | 1062 | |
1063 | 1063 | //let's get EEH_MSG_Template so we can get template form fields |
1064 | - $template_field_structure = EEH_MSG_Template::get_fields( $message_template_group->messenger(), $message_template_group->message_type()); |
|
1064 | + $template_field_structure = EEH_MSG_Template::get_fields($message_template_group->messenger(), $message_template_group->message_type()); |
|
1065 | 1065 | |
1066 | - if ( !$template_field_structure ) { |
|
1066 | + if ( ! $template_field_structure) { |
|
1067 | 1067 | $template_field_structure = false; |
1068 | 1068 | $template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso'); |
1069 | 1069 | } |
@@ -1073,47 +1073,47 @@ discard block |
||
1073 | 1073 | |
1074 | 1074 | |
1075 | 1075 | //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. |
1076 | - if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) { |
|
1077 | - foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) { |
|
1078 | - unset( $template_field_structure[$context][$reference_field] ); |
|
1076 | + if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) { |
|
1077 | + foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) { |
|
1078 | + unset($template_field_structure[$context][$reference_field]); |
|
1079 | 1079 | } |
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | //let's loop through the template_field_structure and actually assemble the input fields! |
1083 | - if ( !empty($template_field_structure) ) { |
|
1083 | + if ( ! empty($template_field_structure)) { |
|
1084 | 1084 | //$id_prefix= 'ee-msg-edit-template-fields-'; |
1085 | - foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) { |
|
1085 | + foreach ($template_field_structure[$context] as $template_field => $field_setup_array) { |
|
1086 | 1086 | //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. |
1087 | - if ( $template_field == 'extra' ) { |
|
1087 | + if ($template_field == 'extra') { |
|
1088 | 1088 | $this->_template_args['is_extra_fields'] = true; |
1089 | - foreach ( $field_setup_array as $reference_field => $new_fields_array ) { |
|
1090 | - $message_template = $message_templates[ $context ][ $reference_field ]; |
|
1089 | + foreach ($field_setup_array as $reference_field => $new_fields_array) { |
|
1090 | + $message_template = $message_templates[$context][$reference_field]; |
|
1091 | 1091 | $content = $message_template instanceof EE_Message_Template |
1092 | - ? $message_template->get( 'MTP_content' ) |
|
1092 | + ? $message_template->get('MTP_content') |
|
1093 | 1093 | : ''; |
1094 | - foreach ( $new_fields_array as $extra_field => $extra_array ) { |
|
1094 | + foreach ($new_fields_array as $extra_field => $extra_array) { |
|
1095 | 1095 | //let's verify if we need this extra field via the shortcodes parameter. |
1096 | 1096 | $continue = false; |
1097 | - if ( isset( $extra_array['shortcodes_required'] ) ) { |
|
1098 | - foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) { |
|
1099 | - if ( !array_key_exists( $shortcode, $this->_shortcodes ) ) |
|
1100 | - {$continue = true;} |
|
1097 | + if (isset($extra_array['shortcodes_required'])) { |
|
1098 | + foreach ((array) $extra_array['shortcodes_required'] as $shortcode) { |
|
1099 | + if ( ! array_key_exists($shortcode, $this->_shortcodes)) |
|
1100 | + {$continue = true; } |
|
1101 | 1101 | } |
1102 | - if ( $continue ) {continue;} |
|
1102 | + if ($continue) {continue; } |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | - $field_id = $reference_field . '-' . $extra_field . '-content'; |
|
1105 | + $field_id = $reference_field.'-'.$extra_field.'-content'; |
|
1106 | 1106 | $template_form_fields[$field_id] = $extra_array; |
1107 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']'; |
|
1108 | - $css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : ''; |
|
1109 | - $template_form_fields[$field_id]['css_class'] = ! empty( $v_fields ) |
|
1107 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']'; |
|
1108 | + $css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : ''; |
|
1109 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
|
1110 | 1110 | && in_array($extra_field, $v_fields) |
1111 | - && ( is_array($validators[$extra_field] ) |
|
1112 | - && isset( $validators[$extra_field]['msg'] ) ) |
|
1113 | - ? 'validate-error ' . $css_class |
|
1111 | + && (is_array($validators[$extra_field]) |
|
1112 | + && isset($validators[$extra_field]['msg'])) |
|
1113 | + ? 'validate-error '.$css_class |
|
1114 | 1114 | : $css_class; |
1115 | - $template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field]) |
|
1116 | - ? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") ) |
|
1115 | + $template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field]) |
|
1116 | + ? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8")) |
|
1117 | 1117 | : ''; |
1118 | 1118 | |
1119 | 1119 | //do we have a validation error? if we do then let's use that value instead |
@@ -1124,32 +1124,32 @@ discard block |
||
1124 | 1124 | |
1125 | 1125 | //shortcode selector |
1126 | 1126 | $field_name_to_use = $extra_field == 'main' ? 'content' : $extra_field; |
1127 | - $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $field_name_to_use, $field_id ); |
|
1127 | + $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($field_name_to_use, $field_id); |
|
1128 | 1128 | |
1129 | - if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) { |
|
1129 | + if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') { |
|
1130 | 1130 | //we want to decode the entities |
1131 | - $template_form_fields[$field_id]['value'] = stripslashes( html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") ); |
|
1131 | + $template_form_fields[$field_id]['value'] = stripslashes(html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8")); |
|
1132 | 1132 | |
1133 | 1133 | }/**/ |
1134 | 1134 | } |
1135 | - $templatefield_MTP_id = $reference_field . '-MTP_ID'; |
|
1136 | - $templatefield_templatename_id = $reference_field . '-name'; |
|
1135 | + $templatefield_MTP_id = $reference_field.'-MTP_ID'; |
|
1136 | + $templatefield_templatename_id = $reference_field.'-name'; |
|
1137 | 1137 | |
1138 | 1138 | $template_form_fields[$templatefield_MTP_id] = array( |
1139 | - 'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]', |
|
1139 | + 'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]', |
|
1140 | 1140 | 'label' => null, |
1141 | 1141 | 'input' => 'hidden', |
1142 | 1142 | 'type' => 'int', |
1143 | 1143 | 'required' => false, |
1144 | 1144 | 'validation' => false, |
1145 | - 'value' => !empty($message_templates) ? $message_template->ID() : '', |
|
1145 | + 'value' => ! empty($message_templates) ? $message_template->ID() : '', |
|
1146 | 1146 | 'css_class' => '', |
1147 | 1147 | 'format' => '%d', |
1148 | 1148 | 'db-col' => 'MTP_ID' |
1149 | 1149 | ); |
1150 | 1150 | |
1151 | 1151 | $template_form_fields[$templatefield_templatename_id] = array( |
1152 | - 'name' => 'MTP_template_fields[' . $reference_field . '][name]', |
|
1152 | + 'name' => 'MTP_template_fields['.$reference_field.'][name]', |
|
1153 | 1153 | 'label' => null, |
1154 | 1154 | 'input' => 'hidden', |
1155 | 1155 | 'type' => 'string', |
@@ -1163,11 +1163,11 @@ discard block |
||
1163 | 1163 | } |
1164 | 1164 | continue; //skip the next stuff, we got the necessary fields here for this dataset. |
1165 | 1165 | } else { |
1166 | - $field_id = $template_field . '-content'; |
|
1166 | + $field_id = $template_field.'-content'; |
|
1167 | 1167 | $template_form_fields[$field_id] = $field_setup_array; |
1168 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]'; |
|
1169 | - $message_template = isset( $message_templates[ $context ][ $template_field ] ) |
|
1170 | - ? isset( $message_templates[ $context ][ $template_field ] ) |
|
1168 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]'; |
|
1169 | + $message_template = isset($message_templates[$context][$template_field]) |
|
1170 | + ? isset($message_templates[$context][$template_field]) |
|
1171 | 1171 | : null; |
1172 | 1172 | $template_form_fields[$field_id]['value'] = ! empty($message_templates) |
1173 | 1173 | && is_array($message_templates[$context]) |
@@ -1181,10 +1181,10 @@ discard block |
||
1181 | 1181 | |
1182 | 1182 | $template_form_fields[$field_id]['db-col'] = 'MTP_content'; |
1183 | 1183 | $css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : ''; |
1184 | - $template_form_fields[$field_id]['css_class'] = !empty( $v_fields ) && in_array( $template_field, $v_fields ) && isset( $validators[$template_field]['msg'] ) ? 'validate-error ' . $css_class : $css_class; |
|
1184 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) && in_array($template_field, $v_fields) && isset($validators[$template_field]['msg']) ? 'validate-error '.$css_class : $css_class; |
|
1185 | 1185 | |
1186 | 1186 | //shortcode selector |
1187 | - $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $template_field, $field_id ); |
|
1187 | + $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($template_field, $field_id); |
|
1188 | 1188 | |
1189 | 1189 | //if ( isset( $field_setup_array['input'] ) && $field_setup_array['input'] == 'wp_editor' ) { |
1190 | 1190 | // //we want to decode the entities |
@@ -1194,12 +1194,12 @@ discard block |
||
1194 | 1194 | |
1195 | 1195 | //k took care of content field(s) now let's take care of others. |
1196 | 1196 | |
1197 | - $templatefield_MTP_id = $template_field . '-MTP_ID'; |
|
1198 | - $templatefield_field_templatename_id = $template_field . '-name'; |
|
1197 | + $templatefield_MTP_id = $template_field.'-MTP_ID'; |
|
1198 | + $templatefield_field_templatename_id = $template_field.'-name'; |
|
1199 | 1199 | |
1200 | 1200 | //foreach template field there are actually two form fields created |
1201 | 1201 | $template_form_fields[$templatefield_MTP_id] = array( |
1202 | - 'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]', |
|
1202 | + 'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]', |
|
1203 | 1203 | 'label' => null, |
1204 | 1204 | 'input' => 'hidden', |
1205 | 1205 | 'type' => 'int', |
@@ -1212,7 +1212,7 @@ discard block |
||
1212 | 1212 | ); |
1213 | 1213 | |
1214 | 1214 | $template_form_fields[$templatefield_field_templatename_id] = array( |
1215 | - 'name' => 'MTP_template_fields[' . $template_field . '][name]', |
|
1215 | + 'name' => 'MTP_template_fields['.$template_field.'][name]', |
|
1216 | 1216 | 'label' => null, |
1217 | 1217 | 'input' => 'hidden', |
1218 | 1218 | 'type' => 'string', |
@@ -1356,15 +1356,15 @@ discard block |
||
1356 | 1356 | 'value' => $GRP_ID |
1357 | 1357 | ); |
1358 | 1358 | $sidebar_form_fields['ee-msg-evt-nonce'] = array( |
1359 | - 'name' => $action . '_nonce', |
|
1359 | + 'name' => $action.'_nonce', |
|
1360 | 1360 | 'input' => 'hidden', |
1361 | 1361 | 'type' => 'string', |
1362 | - 'value' => wp_create_nonce( $action . '_nonce') |
|
1362 | + 'value' => wp_create_nonce($action.'_nonce') |
|
1363 | 1363 | ); |
1364 | 1364 | |
1365 | 1365 | //$sidebar_array = array('ee-msg-is-global', 'ee-msg-is-override', 'ee-msg-deleted', 'ee-msg-is-active'); |
1366 | 1366 | |
1367 | - if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) { |
|
1367 | + if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) { |
|
1368 | 1368 | $sidebar_form_fields['ee-msg-template-switch'] = array( |
1369 | 1369 | 'name' => 'template_switch', |
1370 | 1370 | 'input' => 'hidden', |
@@ -1374,8 +1374,8 @@ discard block |
||
1374 | 1374 | } |
1375 | 1375 | |
1376 | 1376 | |
1377 | - $template_fields = $this->_generate_admin_form_fields( $template_form_fields ); |
|
1378 | - $sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields ); |
|
1377 | + $template_fields = $this->_generate_admin_form_fields($template_form_fields); |
|
1378 | + $sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields); |
|
1379 | 1379 | |
1380 | 1380 | |
1381 | 1381 | } //end if ( !empty($template_field_structure) ) |
@@ -1387,14 +1387,14 @@ discard block |
||
1387 | 1387 | $GRP_ID, |
1388 | 1388 | false, |
1389 | 1389 | add_query_arg( |
1390 | - array( 'action' => 'global_mtps' ), |
|
1390 | + array('action' => 'global_mtps'), |
|
1391 | 1391 | $this->_admin_base_url |
1392 | 1392 | ) |
1393 | 1393 | ); |
1394 | 1394 | |
1395 | 1395 | //add preview button |
1396 | - $preview_url = parent::add_query_args_and_nonce( array( 'message_type' => $message_template_group->message_type(), 'messenger' => $message_template_group->messenger(), 'context' => $context,'GRP_ID' => $GRP_ID, 'action' => 'preview_message' ), $this->_admin_base_url ); |
|
1397 | - $preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>'; |
|
1396 | + $preview_url = parent::add_query_args_and_nonce(array('message_type' => $message_template_group->message_type(), 'messenger' => $message_template_group->messenger(), 'context' => $context, 'GRP_ID' => $GRP_ID, 'action' => 'preview_message'), $this->_admin_base_url); |
|
1397 | + $preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>'; |
|
1398 | 1398 | |
1399 | 1399 | |
1400 | 1400 | //setup context switcher |
@@ -1422,17 +1422,17 @@ discard block |
||
1422 | 1422 | $this->_template_args['after_admin_page_content'] = $this->_add_form_element_after(); |
1423 | 1423 | |
1424 | 1424 | $this->_template_path = $this->_template_args['GRP_ID'] |
1425 | - ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php' |
|
1426 | - : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php'; |
|
1425 | + ? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php' |
|
1426 | + : EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php'; |
|
1427 | 1427 | |
1428 | 1428 | //send along EE_Message_Template_Group object for further template use. |
1429 | 1429 | $this->_template_args['MTP'] = $message_template_group; |
1430 | 1430 | |
1431 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, true ); |
|
1431 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, true); |
|
1432 | 1432 | |
1433 | 1433 | |
1434 | 1434 | //finally, let's set the admin_page title |
1435 | - $this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title ); |
|
1435 | + $this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title); |
|
1436 | 1436 | |
1437 | 1437 | |
1438 | 1438 | //we need to take care of setting the shortcodes property for use elsewhere. |
@@ -1445,7 +1445,7 @@ discard block |
||
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | |
1448 | - public function filter_tinymce_init( $mceInit, $editor_id ) { |
|
1448 | + public function filter_tinymce_init($mceInit, $editor_id) { |
|
1449 | 1449 | return $mceInit; |
1450 | 1450 | } |
1451 | 1451 | |
@@ -1456,7 +1456,7 @@ discard block |
||
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | public function _add_form_element_before() { |
1459 | - return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">'; |
|
1459 | + return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">'; |
|
1460 | 1460 | } |
1461 | 1461 | |
1462 | 1462 | public function _add_form_element_after() { |
@@ -1473,33 +1473,33 @@ discard block |
||
1473 | 1473 | * |
1474 | 1474 | */ |
1475 | 1475 | public function switch_template_pack() { |
1476 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1477 | - $template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : ''; |
|
1476 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1477 | + $template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : ''; |
|
1478 | 1478 | |
1479 | 1479 | //verify we have needed values. |
1480 | - if ( empty( $GRP_ID ) || empty( $template_pack ) ) { |
|
1480 | + if (empty($GRP_ID) || empty($template_pack)) { |
|
1481 | 1481 | $this->_template_args['error'] = true; |
1482 | - EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1482 | + EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1483 | 1483 | } else { |
1484 | 1484 | //get template, set the new template_pack and then reset to default |
1485 | 1485 | /** @type EE_Message_Template_Group $message_template_group */ |
1486 | - $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1486 | + $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1487 | 1487 | |
1488 | - $message_template_group->set_template_pack_name( $template_pack ); |
|
1488 | + $message_template_group->set_template_pack_name($template_pack); |
|
1489 | 1489 | $this->_req_data['msgr'] = $message_template_group->messenger(); |
1490 | 1490 | $this->_req_data['mt'] = $message_template_group->message_type(); |
1491 | 1491 | |
1492 | 1492 | $query_args = $this->_reset_to_default_template(); |
1493 | 1493 | |
1494 | - if ( empty( $query_args['id'] ) ) { |
|
1495 | - EE_Error::add_error( __('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1494 | + if (empty($query_args['id'])) { |
|
1495 | + EE_Error::add_error(__('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1496 | 1496 | $this->_template_args['error'] = true; |
1497 | 1497 | } else { |
1498 | - $template_label =$message_template_group->get_template_pack()->label; |
|
1498 | + $template_label = $message_template_group->get_template_pack()->label; |
|
1499 | 1499 | $template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels(); |
1500 | - EE_Error::add_success( sprintf( __('This message template has been successfully switched to use the %s %s. Please wait while the page reloads with your new template.', 'event_espresso'), $template_label, $template_pack_labels->template_pack ) ); |
|
1500 | + EE_Error::add_success(sprintf(__('This message template has been successfully switched to use the %s %s. Please wait while the page reloads with your new template.', 'event_espresso'), $template_label, $template_pack_labels->template_pack)); |
|
1501 | 1501 | //generate the redirect url for js. |
1502 | - $url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1502 | + $url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1503 | 1503 | $this->_template_args['data']['redirect_url'] = $url; |
1504 | 1504 | $this->_template_args['success'] = true; |
1505 | 1505 | } |
@@ -1521,16 +1521,16 @@ discard block |
||
1521 | 1521 | protected function _reset_to_default_template() { |
1522 | 1522 | |
1523 | 1523 | $templates = array(); |
1524 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1524 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1525 | 1525 | //we need to make sure we've got the info we need. |
1526 | - if ( !isset( $this->_req_data['msgr'] ) && !isset( $this->_req_data['mt'] ) && !isset( $this->_req_data['GRP_ID'] ) ) { |
|
1527 | - EE_Error::add_error( __('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.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1526 | + if ( ! isset($this->_req_data['msgr']) && ! isset($this->_req_data['mt']) && ! isset($this->_req_data['GRP_ID'])) { |
|
1527 | + EE_Error::add_error(__('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.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1528 | 1528 | } |
1529 | 1529 | |
1530 | 1530 | //all templates will be reset to whatever the defaults are for the global template matching the messenger and message type. |
1531 | - $success = !empty( $GRP_ID ) ? true : false; |
|
1531 | + $success = ! empty($GRP_ID) ? true : false; |
|
1532 | 1532 | |
1533 | - if ( $success ) { |
|
1533 | + if ($success) { |
|
1534 | 1534 | |
1535 | 1535 | //let's first determine if the incoming template is a global template, |
1536 | 1536 | // if it isn't then we need to get the global template matching messenger and message type. |
@@ -1538,39 +1538,39 @@ discard block |
||
1538 | 1538 | |
1539 | 1539 | |
1540 | 1540 | //note this is ONLY deleting the template fields (Message Template rows) NOT the message template group. |
1541 | - $success = $this->_delete_mtp_permanently( $GRP_ID, false ); |
|
1541 | + $success = $this->_delete_mtp_permanently($GRP_ID, false); |
|
1542 | 1542 | |
1543 | - if ( $success ) { |
|
1543 | + if ($success) { |
|
1544 | 1544 | //if successfully deleted, lets generate the new ones. Note. We set GLOBAL to true, because resets on ANY template will use the related global template defaults for regeneration. This means that if a custom template is reset it resets to whatever the related global template is. HOWEVER, we DO keep the template pack and template variation set for the current custom template when resetting. |
1545 | - $templates = $this->_generate_new_templates( $this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, true ); |
|
1545 | + $templates = $this->_generate_new_templates($this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, true); |
|
1546 | 1546 | } |
1547 | 1547 | |
1548 | 1548 | } |
1549 | 1549 | |
1550 | 1550 | //any error messages? |
1551 | - if ( !$success ) { |
|
1552 | - EE_Error::add_error( __('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1551 | + if ( ! $success) { |
|
1552 | + EE_Error::add_error(__('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1553 | 1553 | } |
1554 | 1554 | |
1555 | 1555 | //all good, let's add a success message! |
1556 | - if ( $success && ! empty( $templates ) ) { |
|
1556 | + if ($success && ! empty($templates)) { |
|
1557 | 1557 | $templates = $templates[0]; //the info for the template we generated is the first element in the returned array. |
1558 | 1558 | EE_Error::overwrite_success(); |
1559 | - EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') ); |
|
1559 | + EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso')); |
|
1560 | 1560 | } |
1561 | 1561 | |
1562 | 1562 | |
1563 | 1563 | $query_args = array( |
1564 | - 'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : null, |
|
1565 | - 'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : null, |
|
1566 | - 'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'global_mtps' |
|
1564 | + 'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null, |
|
1565 | + 'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null, |
|
1566 | + 'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps' |
|
1567 | 1567 | ); |
1568 | 1568 | |
1569 | 1569 | //if called via ajax then we return query args otherwise redirect |
1570 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
1570 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
1571 | 1571 | return $query_args; |
1572 | 1572 | } else { |
1573 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
1573 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1574 | 1574 | return null; |
1575 | 1575 | } |
1576 | 1576 | } |
@@ -1583,19 +1583,19 @@ discard block |
||
1583 | 1583 | * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview. |
1584 | 1584 | * @return string |
1585 | 1585 | */ |
1586 | - public function _preview_message( $send = false ) { |
|
1586 | + public function _preview_message($send = false) { |
|
1587 | 1587 | //first make sure we've got the necessary parameters |
1588 | - if ( !isset( $this->_req_data['message_type'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['GRP_ID'] ) ) { |
|
1589 | - EE_Error::add_error( __('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1588 | + if ( ! isset($this->_req_data['message_type']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['GRP_ID'])) { |
|
1589 | + EE_Error::add_error(__('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1590 | 1590 | } |
1591 | 1591 | |
1592 | - EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] ); |
|
1592 | + EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']); |
|
1593 | 1593 | |
1594 | 1594 | |
1595 | 1595 | //get the preview! |
1596 | - $preview = EED_Messages::preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send ); |
|
1596 | + $preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send); |
|
1597 | 1597 | |
1598 | - if ( $send ) { |
|
1598 | + if ($send) { |
|
1599 | 1599 | return $preview; |
1600 | 1600 | } |
1601 | 1601 | |
@@ -1605,18 +1605,18 @@ discard block |
||
1605 | 1605 | 'context' => $this->_req_data['context'], |
1606 | 1606 | 'action' => 'edit_message_template' |
1607 | 1607 | ); |
1608 | - $go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1609 | - $preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>'; |
|
1608 | + $go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1609 | + $preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>'; |
|
1610 | 1610 | $message_types = $this->get_installed_message_types(); |
1611 | 1611 | //let's provide a helpful title for context |
1612 | 1612 | $preview_title = sprintf( |
1613 | - __( 'Viewing Preview for %s %s Message Template', 'event_espresso' ), |
|
1614 | - ucwords( $this->_active_messengers[ $this->_req_data[ 'messenger' ] ]->label[ 'singular' ] ), |
|
1615 | - ucwords( $message_types[ $this->_req_data[ 'message_type' ] ]->label[ 'singular' ] ) |
|
1613 | + __('Viewing Preview for %s %s Message Template', 'event_espresso'), |
|
1614 | + ucwords($this->_active_messengers[$this->_req_data['messenger']]->label['singular']), |
|
1615 | + ucwords($message_types[$this->_req_data['message_type']]->label['singular']) |
|
1616 | 1616 | ); |
1617 | 1617 | //setup display of preview. |
1618 | 1618 | $this->_admin_page_title = $preview_title; |
1619 | - $this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview); |
|
1619 | + $this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview); |
|
1620 | 1620 | $this->_template_args['data']['force_json'] = true; |
1621 | 1621 | return ''; |
1622 | 1622 | } |
@@ -1646,9 +1646,9 @@ discard block |
||
1646 | 1646 | * @return void |
1647 | 1647 | */ |
1648 | 1648 | protected function _register_edit_meta_boxes() { |
1649 | - add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' ); |
|
1650 | - add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1651 | - add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1649 | + add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default'); |
|
1650 | + add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1651 | + add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1652 | 1652 | } |
1653 | 1653 | |
1654 | 1654 | |
@@ -1667,10 +1667,10 @@ discard block |
||
1667 | 1667 | |
1668 | 1668 | $tp_select_values = array(); |
1669 | 1669 | |
1670 | - foreach ( $tp_collection as $tp ) { |
|
1670 | + foreach ($tp_collection as $tp) { |
|
1671 | 1671 | //only include template packs that support this messenger and message type! |
1672 | 1672 | $supports = $tp->get_supports(); |
1673 | - if ( ! isset( $supports[$this->_message_template_group->messenger()] ) || ! in_array( $this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()] ) ) { |
|
1673 | + if ( ! isset($supports[$this->_message_template_group->messenger()]) || ! in_array($this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()])) { |
|
1674 | 1674 | //not supported |
1675 | 1675 | continue; |
1676 | 1676 | } |
@@ -1682,7 +1682,7 @@ discard block |
||
1682 | 1682 | } |
1683 | 1683 | |
1684 | 1684 | //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. |
1685 | - if ( empty( $tp_select_values ) ) { |
|
1685 | + if (empty($tp_select_values)) { |
|
1686 | 1686 | $tp_select_values[] = array( |
1687 | 1687 | 'text' => __('Default', 'event_espresso'), |
1688 | 1688 | 'id' => 'default' |
@@ -1690,27 +1690,27 @@ discard block |
||
1690 | 1690 | } |
1691 | 1691 | |
1692 | 1692 | //setup variation select values for the currently selected template. |
1693 | - $variations = $this->_message_template_group->get_template_pack()->get_variations( $this->_message_template_group->messenger(), $this->_message_template_group->message_type() ); |
|
1693 | + $variations = $this->_message_template_group->get_template_pack()->get_variations($this->_message_template_group->messenger(), $this->_message_template_group->message_type()); |
|
1694 | 1694 | $variations_select_values = array(); |
1695 | - foreach ( $variations as $variation => $label ) { |
|
1695 | + foreach ($variations as $variation => $label) { |
|
1696 | 1696 | $variations_select_values[] = array( |
1697 | 1697 | 'text' => $label, |
1698 | 1698 | 'id' => $variation |
1699 | 1699 | ); |
1700 | 1700 | } |
1701 | 1701 | |
1702 | - $template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1702 | + $template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1703 | 1703 | |
1704 | - $template_args['template_packs_selector'] = EEH_Form_Fields::select_input( 'MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name() ); |
|
1705 | - $template_args['variations_selector'] = EEH_Form_Fields::select_input( 'MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation() ); |
|
1704 | + $template_args['template_packs_selector'] = EEH_Form_Fields::select_input('MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name()); |
|
1705 | + $template_args['variations_selector'] = EEH_Form_Fields::select_input('MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation()); |
|
1706 | 1706 | $template_args['template_pack_label'] = $template_pack_labels->template_pack; |
1707 | 1707 | $template_args['template_variation_label'] = $template_pack_labels->template_variation; |
1708 | 1708 | $template_args['template_pack_description'] = $template_pack_labels->template_pack_description; |
1709 | 1709 | $template_args['template_variation_description'] = $template_pack_labels->template_variation_description; |
1710 | 1710 | |
1711 | - $template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php'; |
|
1711 | + $template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php'; |
|
1712 | 1712 | |
1713 | - EEH_Template::display_template( $template, $template_args ); |
|
1713 | + EEH_Template::display_template($template, $template_args); |
|
1714 | 1714 | } |
1715 | 1715 | |
1716 | 1716 | |
@@ -1731,52 +1731,52 @@ discard block |
||
1731 | 1731 | 'GRP_ID' => $this->_message_template_group->GRP_ID() |
1732 | 1732 | ); |
1733 | 1733 | |
1734 | - $button = $this->get_action_link_or_button( 'reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button' ); |
|
1734 | + $button = $this->get_action_link_or_button('reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button'); |
|
1735 | 1735 | |
1736 | 1736 | |
1737 | 1737 | //test button |
1738 | 1738 | //first we need to see if there are any fields |
1739 | 1739 | $fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields(); |
1740 | 1740 | |
1741 | - if ( !empty( $fields ) ) { |
|
1741 | + if ( ! empty($fields)) { |
|
1742 | 1742 | //yup there be fields |
1743 | - foreach ( $fields as $field => $config ) { |
|
1744 | - $field_id = $this->_message_template_group->messenger() . '_' . $field; |
|
1743 | + foreach ($fields as $field => $config) { |
|
1744 | + $field_id = $this->_message_template_group->messenger().'_'.$field; |
|
1745 | 1745 | $existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings(); |
1746 | - $default = isset( $config['default'] ) ? $config['default'] : ''; |
|
1747 | - $default = isset( $config['value'] ) ? $config['value'] : $default; |
|
1746 | + $default = isset($config['default']) ? $config['default'] : ''; |
|
1747 | + $default = isset($config['value']) ? $config['value'] : $default; |
|
1748 | 1748 | |
1749 | 1749 | //if type is hidden and the value is empty something may have gone wrong so let's correct with the defaults |
1750 | 1750 | $fix = $config['input'] == 'hidden' && isset($existing[$field]) && empty($existing[$field]) ? $default : ''; |
1751 | - $existing[$field] = isset( $existing[$field] ) && empty( $fix ) ? $existing[$field] : $fix; |
|
1751 | + $existing[$field] = isset($existing[$field]) && empty($fix) ? $existing[$field] : $fix; |
|
1752 | 1752 | |
1753 | 1753 | $template_form_fields[$field_id] = array( |
1754 | - 'name' => 'test_settings_fld[' . $field . ']', |
|
1754 | + 'name' => 'test_settings_fld['.$field.']', |
|
1755 | 1755 | 'label' => $config['label'], |
1756 | 1756 | 'input' => $config['input'], |
1757 | 1757 | 'type' => $config['type'], |
1758 | 1758 | 'required' => $config['required'], |
1759 | 1759 | 'validation' => $config['validation'], |
1760 | - 'value' => isset( $existing[$field] ) ? $existing[$field] : $default, |
|
1760 | + 'value' => isset($existing[$field]) ? $existing[$field] : $default, |
|
1761 | 1761 | 'css_class' => $config['css_class'], |
1762 | - 'options' => isset( $config['options'] ) ? $config['options'] : array(), |
|
1762 | + 'options' => isset($config['options']) ? $config['options'] : array(), |
|
1763 | 1763 | 'default' => $default, |
1764 | 1764 | 'format' => $config['format'] |
1765 | 1765 | ); |
1766 | 1766 | } |
1767 | 1767 | } |
1768 | 1768 | |
1769 | - $test_settings_fields = !empty( $template_form_fields) ? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' ) : ''; |
|
1769 | + $test_settings_fields = ! empty($template_form_fields) ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds') : ''; |
|
1770 | 1770 | |
1771 | 1771 | $test_settings_html = ''; |
1772 | 1772 | //print out $test_settings_fields |
1773 | - if ( !empty( $test_settings_fields ) ) { |
|
1773 | + if ( ! empty($test_settings_fields)) { |
|
1774 | 1774 | echo $test_settings_fields; |
1775 | - $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>'; |
|
1775 | + $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>'; |
|
1776 | 1776 | } |
1777 | 1777 | |
1778 | 1778 | //and button |
1779 | - 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>'; |
|
1779 | + 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>'; |
|
1780 | 1780 | } |
1781 | 1781 | |
1782 | 1782 | |
@@ -1791,13 +1791,13 @@ discard block |
||
1791 | 1791 | * @param string $linked_input_id The css id of the input that the shortcodes get added to. |
1792 | 1792 | * @return string |
1793 | 1793 | */ |
1794 | - protected function _get_shortcode_selector( $field, $linked_input_id ) { |
|
1794 | + protected function _get_shortcode_selector($field, $linked_input_id) { |
|
1795 | 1795 | $template_args = array( |
1796 | - 'shortcodes' => $this->_get_shortcodes( array( $field ), true ), |
|
1796 | + 'shortcodes' => $this->_get_shortcodes(array($field), true), |
|
1797 | 1797 | 'fieldname' => $field, |
1798 | 1798 | 'linked_input_id' => $linked_input_id |
1799 | 1799 | ); |
1800 | - return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true ); |
|
1800 | + return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true); |
|
1801 | 1801 | } |
1802 | 1802 | |
1803 | 1803 | |
@@ -1812,13 +1812,13 @@ discard block |
||
1812 | 1812 | $shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set |
1813 | 1813 | //$messenger = $this->_message_template_group->messenger_obj(); |
1814 | 1814 | //now let's set the content depending on the status of the shortcodes array |
1815 | - if ( empty( $shortcodes ) ) { |
|
1816 | - $content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>'; |
|
1815 | + if (empty($shortcodes)) { |
|
1816 | + $content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>'; |
|
1817 | 1817 | echo $content; |
1818 | 1818 | } else { |
1819 | 1819 | //$alt = 0; |
1820 | 1820 | ?> |
1821 | - <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> |
|
1821 | + <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> |
|
1822 | 1822 | <?php |
1823 | 1823 | } |
1824 | 1824 | |
@@ -1835,7 +1835,7 @@ discard block |
||
1835 | 1835 | protected function _set_shortcodes() { |
1836 | 1836 | |
1837 | 1837 | //no need to run this if the property is already set |
1838 | - if ( !empty($this->_shortcodes ) ) {return;} |
|
1838 | + if ( ! empty($this->_shortcodes)) {return; } |
|
1839 | 1839 | |
1840 | 1840 | $this->_shortcodes = $this->_get_shortcodes(); |
1841 | 1841 | } |
@@ -1857,14 +1857,14 @@ discard block |
||
1857 | 1857 | * @return array Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true |
1858 | 1858 | * just an array of shortcode/label pairs. |
1859 | 1859 | */ |
1860 | - protected function _get_shortcodes( $fields = array(), $merged = true ) { |
|
1860 | + protected function _get_shortcodes($fields = array(), $merged = true) { |
|
1861 | 1861 | $this->_set_message_template_group(); |
1862 | 1862 | |
1863 | 1863 | //we need the messenger and message template to retrieve the valid shortcodes array. |
1864 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false; |
|
1865 | - $context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() ); |
|
1864 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false; |
|
1865 | + $context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config()); |
|
1866 | 1866 | |
1867 | - return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array(); |
|
1867 | + return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array(); |
|
1868 | 1868 | } |
1869 | 1869 | |
1870 | 1870 | |
@@ -1877,19 +1877,19 @@ discard block |
||
1877 | 1877 | */ |
1878 | 1878 | protected function _set_message_template_group() { |
1879 | 1879 | |
1880 | - if ( !empty( $this->_message_template_group ) ) |
|
1881 | - {return;} //get out if this is already set. |
|
1880 | + if ( ! empty($this->_message_template_group)) |
|
1881 | + {return; } //get out if this is already set. |
|
1882 | 1882 | |
1883 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : false; |
|
1884 | - $GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID; |
|
1883 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false; |
|
1884 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID; |
|
1885 | 1885 | |
1886 | 1886 | //let's get the message templates |
1887 | 1887 | $MTP = EEM_Message_Template_Group::instance(); |
1888 | 1888 | |
1889 | - if ( empty($GRP_ID) ) |
|
1890 | - {$this->_message_template_group = $MTP->create_default_object();} |
|
1889 | + if (empty($GRP_ID)) |
|
1890 | + {$this->_message_template_group = $MTP->create_default_object(); } |
|
1891 | 1891 | else |
1892 | - {$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );} |
|
1892 | + {$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID); } |
|
1893 | 1893 | |
1894 | 1894 | $this->_template_pack = $this->_message_template_group->get_template_pack(); |
1895 | 1895 | $this->_variation = $this->_message_template_group->get_template_pack_variation(); |
@@ -1908,7 +1908,7 @@ discard block |
||
1908 | 1908 | * @param array $args various things the context switcher needs. |
1909 | 1909 | * |
1910 | 1910 | */ |
1911 | - protected function _set_context_switcher( EE_Message_Template_Group $template_group_object, $args) { |
|
1911 | + protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args) { |
|
1912 | 1912 | $context_details = $template_group_object->contexts_config(); |
1913 | 1913 | $context_label = $template_group_object->context_label(); |
1914 | 1914 | ob_start(); |
@@ -1916,26 +1916,26 @@ discard block |
||
1916 | 1916 | <div class="ee-msg-switcher-container"> |
1917 | 1917 | <form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm"> |
1918 | 1918 | <?php |
1919 | - foreach ( $args as $name => $value ) { |
|
1920 | - if ( $name == 'context' || empty($value) || $name == 'extra' ) {continue;} |
|
1919 | + foreach ($args as $name => $value) { |
|
1920 | + if ($name == 'context' || empty($value) || $name == 'extra') {continue; } |
|
1921 | 1921 | ?> |
1922 | 1922 | <input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" /> |
1923 | 1923 | <?php |
1924 | 1924 | } |
1925 | 1925 | //setup nonce_url |
1926 | - wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false); |
|
1926 | + wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false); |
|
1927 | 1927 | ?> |
1928 | 1928 | <select name="context"> |
1929 | 1929 | <?php |
1930 | 1930 | $context_templates = $template_group_object->context_templates(); |
1931 | - if ( is_array($context_templates) ) : |
|
1932 | - foreach ( $context_templates as $context => $template_fields ) : |
|
1931 | + if (is_array($context_templates)) : |
|
1932 | + foreach ($context_templates as $context => $template_fields) : |
|
1933 | 1933 | $checked = ($context == $args['context']) ? 'selected="selected"' : ''; |
1934 | 1934 | ?> |
1935 | 1935 | <option value="<?php echo $context; ?>" <?php echo $checked; ?>><?php echo $context_details[$context]['label']; ?></option> |
1936 | 1936 | <?php endforeach; endif; ?> |
1937 | 1937 | </select> |
1938 | - <?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?> |
|
1938 | + <?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?> |
|
1939 | 1939 | <input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>"> |
1940 | 1940 | </form> |
1941 | 1941 | <?php echo $args['extra']; ?> |
@@ -1962,8 +1962,8 @@ discard block |
||
1962 | 1962 | * @return array |
1963 | 1963 | */ |
1964 | 1964 | protected function _set_message_template_column_values($index) { |
1965 | - if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) { |
|
1966 | - foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) { |
|
1965 | + if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) { |
|
1966 | + foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) { |
|
1967 | 1967 | $this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value; |
1968 | 1968 | } |
1969 | 1969 | } /*else { |
@@ -1972,22 +1972,22 @@ discard block |
||
1972 | 1972 | |
1973 | 1973 | |
1974 | 1974 | $set_column_values = array( |
1975 | - 'MTP_ID' => absint( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'MTP_ID' ] ), |
|
1976 | - 'GRP_ID' => absint( $this->_req_data[ 'GRP_ID' ] ), |
|
1977 | - 'MTP_user_id' => absint( $this->_req_data[ 'MTP_user_id' ] ), |
|
1978 | - 'MTP_messenger' => strtolower( $this->_req_data[ 'MTP_messenger' ] ), |
|
1979 | - 'MTP_message_type' => strtolower( $this->_req_data[ 'MTP_message_type' ] ), |
|
1980 | - 'MTP_template_field' => strtolower( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'name' ] ), |
|
1981 | - 'MTP_context' => strtolower( $this->_req_data[ 'MTP_context' ] ), |
|
1982 | - 'MTP_content' => $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'content' ], |
|
1983 | - 'MTP_is_global' => isset( $this->_req_data[ 'MTP_is_global' ] ) |
|
1984 | - ? absint( $this->_req_data[ 'MTP_is_global' ] ) |
|
1975 | + 'MTP_ID' => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']), |
|
1976 | + 'GRP_ID' => absint($this->_req_data['GRP_ID']), |
|
1977 | + 'MTP_user_id' => absint($this->_req_data['MTP_user_id']), |
|
1978 | + 'MTP_messenger' => strtolower($this->_req_data['MTP_messenger']), |
|
1979 | + 'MTP_message_type' => strtolower($this->_req_data['MTP_message_type']), |
|
1980 | + 'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']), |
|
1981 | + 'MTP_context' => strtolower($this->_req_data['MTP_context']), |
|
1982 | + 'MTP_content' => $this->_req_data['MTP_template_fields'][$index]['content'], |
|
1983 | + 'MTP_is_global' => isset($this->_req_data['MTP_is_global']) |
|
1984 | + ? absint($this->_req_data['MTP_is_global']) |
|
1985 | 1985 | : 0, |
1986 | - 'MTP_is_override' => isset( $this->_req_data[ 'MTP_is_override' ] ) |
|
1987 | - ? absint( $this->_req_data[ 'MTP_is_override' ] ) |
|
1986 | + 'MTP_is_override' => isset($this->_req_data['MTP_is_override']) |
|
1987 | + ? absint($this->_req_data['MTP_is_override']) |
|
1988 | 1988 | : 0, |
1989 | - 'MTP_deleted' => absint( $this->_req_data[ 'MTP_deleted' ] ), |
|
1990 | - 'MTP_is_active' => absint( $this->_req_data[ 'MTP_is_active' ] ) |
|
1989 | + 'MTP_deleted' => absint($this->_req_data['MTP_deleted']), |
|
1990 | + 'MTP_is_active' => absint($this->_req_data['MTP_is_active']) |
|
1991 | 1991 | ); |
1992 | 1992 | |
1993 | 1993 | |
@@ -1999,28 +1999,28 @@ discard block |
||
1999 | 1999 | |
2000 | 2000 | |
2001 | 2001 | |
2002 | - protected function _insert_or_update_message_template($new = false ) { |
|
2002 | + protected function _insert_or_update_message_template($new = false) { |
|
2003 | 2003 | |
2004 | - do_action ( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2004 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2005 | 2005 | $success = 0; |
2006 | 2006 | $override = false; |
2007 | 2007 | |
2008 | 2008 | //setup notices description |
2009 | - $messenger = !empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'] ) ) : false; |
|
2010 | - $message_type = !empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'] ) ) : false; |
|
2011 | - $context = !empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'] ) ) : false; |
|
2009 | + $messenger = ! empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'])) : false; |
|
2010 | + $message_type = ! empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'])) : false; |
|
2011 | + $context = ! empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'])) : false; |
|
2012 | 2012 | |
2013 | - $item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : ''; |
|
2013 | + $item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : ''; |
|
2014 | 2014 | $item_desc .= 'Message Template'; |
2015 | 2015 | $query_args = array(); |
2016 | 2016 | $edit_array = array(); |
2017 | 2017 | $action_desc = ''; |
2018 | 2018 | |
2019 | 2019 | //if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit. |
2020 | - if ( $new ) { |
|
2021 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
2022 | - if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) { |
|
2023 | - if ( empty($edit_array) ) { |
|
2020 | + if ($new) { |
|
2021 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
2022 | + if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) { |
|
2023 | + if (empty($edit_array)) { |
|
2024 | 2024 | $success = 0; |
2025 | 2025 | } else { |
2026 | 2026 | $success = 1; |
@@ -2039,33 +2039,33 @@ discard block |
||
2039 | 2039 | |
2040 | 2040 | |
2041 | 2041 | //run update for each template field in displayed context |
2042 | - if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) { |
|
2043 | - EE_Error::add_error( __('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2042 | + if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) { |
|
2043 | + EE_Error::add_error(__('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2044 | 2044 | $success = 0; |
2045 | 2045 | |
2046 | 2046 | } else { |
2047 | 2047 | //first validate all fields! |
2048 | - $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']); |
|
2048 | + $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']); |
|
2049 | 2049 | |
2050 | 2050 | //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. |
2051 | - if ( is_array($validates) && !empty($validates) ) { |
|
2051 | + if (is_array($validates) && ! empty($validates)) { |
|
2052 | 2052 | //add the transient so when the form loads we know which fields to highlight |
2053 | - $this->_add_transient( 'edit_message_template', $validates ); |
|
2053 | + $this->_add_transient('edit_message_template', $validates); |
|
2054 | 2054 | |
2055 | 2055 | $success = 0; |
2056 | 2056 | |
2057 | 2057 | //setup notices |
2058 | - foreach ( $validates as $field => $error ) { |
|
2059 | - if ( isset($error['msg'] ) ) |
|
2060 | - {EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ );} |
|
2058 | + foreach ($validates as $field => $error) { |
|
2059 | + if (isset($error['msg'])) |
|
2060 | + {EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__); } |
|
2061 | 2061 | } |
2062 | 2062 | |
2063 | 2063 | } else { |
2064 | 2064 | $set_column_values = array(); |
2065 | - foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) { |
|
2065 | + foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) { |
|
2066 | 2066 | $set_column_values = $this->_set_message_template_column_values($template_field); |
2067 | 2067 | |
2068 | - $where_cols_n_values = array( 'MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']); |
|
2068 | + $where_cols_n_values = array('MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']); |
|
2069 | 2069 | |
2070 | 2070 | $message_template_fields = array( |
2071 | 2071 | 'GRP_ID' => $set_column_values['GRP_ID'], |
@@ -2073,10 +2073,10 @@ discard block |
||
2073 | 2073 | 'MTP_context' => $set_column_values['MTP_context'], |
2074 | 2074 | 'MTP_content' => $set_column_values['MTP_content'] |
2075 | 2075 | ); |
2076 | - if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) { |
|
2077 | - if ( $updated === false ) { |
|
2078 | - $msg = sprintf( __('%s field was NOT updated for some reason', 'event_espresso'), $template_field ); |
|
2079 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2076 | + if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) { |
|
2077 | + if ($updated === false) { |
|
2078 | + $msg = sprintf(__('%s field was NOT updated for some reason', 'event_espresso'), $template_field); |
|
2079 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2080 | 2080 | } else { |
2081 | 2081 | $success = 1; |
2082 | 2082 | } |
@@ -2086,40 +2086,40 @@ discard block |
||
2086 | 2086 | |
2087 | 2087 | //we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs) |
2088 | 2088 | $mtpg_fields = array( |
2089 | - 'MTP_user_id' => $set_column_values[ 'MTP_user_id' ], |
|
2090 | - 'MTP_messenger' => $set_column_values[ 'MTP_messenger' ], |
|
2091 | - 'MTP_message_type' => $set_column_values[ 'MTP_message_type' ], |
|
2092 | - 'MTP_is_global' => $set_column_values[ 'MTP_is_global' ], |
|
2093 | - 'MTP_is_override' => $set_column_values[ 'MTP_is_override' ], |
|
2094 | - 'MTP_deleted' => $set_column_values[ 'MTP_deleted' ], |
|
2095 | - 'MTP_is_active' => $set_column_values[ 'MTP_is_active' ], |
|
2096 | - 'MTP_name' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] ) |
|
2097 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] |
|
2089 | + 'MTP_user_id' => $set_column_values['MTP_user_id'], |
|
2090 | + 'MTP_messenger' => $set_column_values['MTP_messenger'], |
|
2091 | + 'MTP_message_type' => $set_column_values['MTP_message_type'], |
|
2092 | + 'MTP_is_global' => $set_column_values['MTP_is_global'], |
|
2093 | + 'MTP_is_override' => $set_column_values['MTP_is_override'], |
|
2094 | + 'MTP_deleted' => $set_column_values['MTP_deleted'], |
|
2095 | + 'MTP_is_active' => $set_column_values['MTP_is_active'], |
|
2096 | + 'MTP_name' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name']) |
|
2097 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] |
|
2098 | 2098 | : '', |
2099 | - 'MTP_description' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] ) |
|
2100 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] |
|
2099 | + 'MTP_description' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description']) |
|
2100 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] |
|
2101 | 2101 | : '' |
2102 | 2102 | ); |
2103 | 2103 | |
2104 | - $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] ); |
|
2105 | - $updated = $MTPG->update( $mtpg_fields, array($mtpg_where) ); |
|
2104 | + $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']); |
|
2105 | + $updated = $MTPG->update($mtpg_fields, array($mtpg_where)); |
|
2106 | 2106 | |
2107 | - if ( $updated === false ) { |
|
2107 | + if ($updated === false) { |
|
2108 | 2108 | EE_Error::add_error( |
2109 | 2109 | sprintf( |
2110 | - __( 'The Message Template Group (%d) was NOT updated for some reason', 'event_espresso' ), |
|
2111 | - $set_column_values[ 'GRP_ID' ] |
|
2110 | + __('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), |
|
2111 | + $set_column_values['GRP_ID'] |
|
2112 | 2112 | ), |
2113 | 2113 | __FILE__, __FUNCTION__, __LINE__ |
2114 | 2114 | ); |
2115 | 2115 | } else { |
2116 | 2116 | //k now we need to ensure the template_pack and template_variation fields are set. |
2117 | - $template_pack = ! empty( $this->_req_data['MTP_template_pack' ] ) ? $this->_req_data['MTP_template_pack'] : 'default'; |
|
2118 | - $template_variation = ! empty( $this->_req_data['MTP_template_variation'] ) ? $this->_req_data['MTP_template_variation'] : 'default'; |
|
2119 | - $mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] ); |
|
2120 | - if ( $mtpg_obj instanceof EE_Message_Template_Group ) { |
|
2121 | - $mtpg_obj->set_template_pack_name( $template_pack ); |
|
2122 | - $mtpg_obj->set_template_pack_variation( $template_variation ); |
|
2117 | + $template_pack = ! empty($this->_req_data['MTP_template_pack']) ? $this->_req_data['MTP_template_pack'] : 'default'; |
|
2118 | + $template_variation = ! empty($this->_req_data['MTP_template_variation']) ? $this->_req_data['MTP_template_variation'] : 'default'; |
|
2119 | + $mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']); |
|
2120 | + if ($mtpg_obj instanceof EE_Message_Template_Group) { |
|
2121 | + $mtpg_obj->set_template_pack_name($template_pack); |
|
2122 | + $mtpg_obj->set_template_pack_variation($template_variation); |
|
2123 | 2123 | } |
2124 | 2124 | $success = 1; |
2125 | 2125 | } |
@@ -2129,7 +2129,7 @@ discard block |
||
2129 | 2129 | } |
2130 | 2130 | |
2131 | 2131 | //we return things differently if doing ajax |
2132 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
2132 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2133 | 2133 | $this->_template_args['success'] = $success; |
2134 | 2134 | $this->_template_args['error'] = ! $success ? true : false; |
2135 | 2135 | $this->_template_args['content'] = ''; |
@@ -2137,9 +2137,9 @@ discard block |
||
2137 | 2137 | 'grpID' => $edit_array['GRP_ID'], |
2138 | 2138 | 'templateName' => $edit_array['template_name'] |
2139 | 2139 | ); |
2140 | - if ( $success ) { |
|
2140 | + if ($success) { |
|
2141 | 2141 | EE_Error::overwrite_success(); |
2142 | - 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') ); |
|
2142 | + 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')); |
|
2143 | 2143 | } |
2144 | 2144 | |
2145 | 2145 | $this->_return_json(); |
@@ -2147,13 +2147,13 @@ discard block |
||
2147 | 2147 | |
2148 | 2148 | |
2149 | 2149 | //was a test send triggered? |
2150 | - if ( isset( $this->_req_data['test_button'] ) ) { |
|
2150 | + if (isset($this->_req_data['test_button'])) { |
|
2151 | 2151 | EE_Error::overwrite_success(); |
2152 | - $this->_do_test_send( $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] ); |
|
2152 | + $this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2153 | 2153 | $override = true; |
2154 | 2154 | } |
2155 | 2155 | |
2156 | - if ( empty( $query_args ) ) { |
|
2156 | + if (empty($query_args)) { |
|
2157 | 2157 | $query_args = array( |
2158 | 2158 | 'id' => $this->_req_data['GRP_ID'], |
2159 | 2159 | 'context' => $this->_req_data['MTP_context'], |
@@ -2161,7 +2161,7 @@ discard block |
||
2161 | 2161 | ); |
2162 | 2162 | } |
2163 | 2163 | |
2164 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override ); |
|
2164 | + $this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override); |
|
2165 | 2165 | } |
2166 | 2166 | |
2167 | 2167 | |
@@ -2175,28 +2175,28 @@ discard block |
||
2175 | 2175 | * @param string $message_type message type being tested |
2176 | 2176 | * |
2177 | 2177 | */ |
2178 | - protected function _do_test_send( $context, $messenger, $message_type ) { |
|
2178 | + protected function _do_test_send($context, $messenger, $message_type) { |
|
2179 | 2179 | //set things up for preview |
2180 | 2180 | $this->_req_data['messenger'] = $messenger; |
2181 | 2181 | $this->_req_data['message_type'] = $message_type; |
2182 | 2182 | $this->_req_data['context'] = $context; |
2183 | - $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : ''; |
|
2184 | - $active_messenger = $this->_active_messengers[ $messenger ]; |
|
2183 | + $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : ''; |
|
2184 | + $active_messenger = $this->_active_messengers[$messenger]; |
|
2185 | 2185 | |
2186 | 2186 | //let's save any existing fields that might be required by the messenger |
2187 | 2187 | if ( |
2188 | - isset( $this->_req_data['test_settings_fld'] ) |
|
2188 | + isset($this->_req_data['test_settings_fld']) |
|
2189 | 2189 | && $active_messenger instanceof EE_Messenger |
2190 | 2190 | ) { |
2191 | - $active_messenger->set_existing_test_settings( $this->_req_data['test_settings_fld'] ); |
|
2191 | + $active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']); |
|
2192 | 2192 | } |
2193 | 2193 | |
2194 | 2194 | $success = $this->_preview_message(true); |
2195 | 2195 | |
2196 | - if ( $success ) { |
|
2197 | - EE_Error::add_success( __('Test message sent', 'event_espresso') ); |
|
2196 | + if ($success) { |
|
2197 | + EE_Error::add_success(__('Test message sent', 'event_espresso')); |
|
2198 | 2198 | } else { |
2199 | - EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2199 | + EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2200 | 2200 | } |
2201 | 2201 | } |
2202 | 2202 | |
@@ -2222,11 +2222,11 @@ discard block |
||
2222 | 2222 | protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
2223 | 2223 | |
2224 | 2224 | //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. |
2225 | - if ( empty( $message_types ) ) { |
|
2225 | + if (empty($message_types)) { |
|
2226 | 2226 | return true; |
2227 | 2227 | } |
2228 | 2228 | |
2229 | - return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global); |
|
2229 | + return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global); |
|
2230 | 2230 | |
2231 | 2231 | } |
2232 | 2232 | |
@@ -2243,33 +2243,33 @@ discard block |
||
2243 | 2243 | * |
2244 | 2244 | * @return void |
2245 | 2245 | */ |
2246 | - protected function _trash_or_restore_message_template($trash = true, $all = false ) { |
|
2247 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2246 | + protected function _trash_or_restore_message_template($trash = true, $all = false) { |
|
2247 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2248 | 2248 | $MTP = EEM_Message_Template_Group::instance(); |
2249 | 2249 | |
2250 | 2250 | $success = 1; |
2251 | 2251 | |
2252 | 2252 | //incoming GRP_IDs |
2253 | - if ( $all ) { |
|
2253 | + if ($all) { |
|
2254 | 2254 | //Checkboxes |
2255 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) { |
|
2255 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2256 | 2256 | //if array has more than one element then success message should be plural. |
2257 | 2257 | //todo: what about nonce? |
2258 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2258 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2259 | 2259 | |
2260 | 2260 | //cycle through checkboxes |
2261 | - while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) { |
|
2262 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2263 | - if ( ! $trashed_or_restored ) { |
|
2261 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2262 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2263 | + if ( ! $trashed_or_restored) { |
|
2264 | 2264 | $success = 0; |
2265 | 2265 | } |
2266 | 2266 | } |
2267 | 2267 | } else { |
2268 | 2268 | //grab single GRP_ID and handle |
2269 | - $GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0; |
|
2270 | - if ( ! empty( $GRP_ID ) ) { |
|
2271 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2272 | - if ( ! $trashed_or_restored ) { |
|
2269 | + $GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0; |
|
2270 | + if ( ! empty($GRP_ID)) { |
|
2271 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2272 | + if ( ! $trashed_or_restored) { |
|
2273 | 2273 | $success = 0; |
2274 | 2274 | } |
2275 | 2275 | } else { |
@@ -2281,13 +2281,13 @@ discard block |
||
2281 | 2281 | |
2282 | 2282 | $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
2283 | 2283 | |
2284 | - $action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc; |
|
2284 | + $action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc; |
|
2285 | 2285 | |
2286 | 2286 | $item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso'); |
2287 | 2287 | |
2288 | - $item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2288 | + $item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2289 | 2289 | |
2290 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, array() ); |
|
2290 | + $this->_redirect_after_action($success, $item_desc, $action_desc, array()); |
|
2291 | 2291 | |
2292 | 2292 | } |
2293 | 2293 | |
@@ -2303,24 +2303,24 @@ discard block |
||
2303 | 2303 | * @return void |
2304 | 2304 | */ |
2305 | 2305 | protected function _delete_message_template() { |
2306 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2306 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2307 | 2307 | |
2308 | 2308 | //checkboxes |
2309 | - if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) { |
|
2309 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2310 | 2310 | //if array has more than one element then success message should be plural |
2311 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2311 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2312 | 2312 | |
2313 | 2313 | //cycle through bulk action checkboxes |
2314 | - while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) { |
|
2315 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2314 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2315 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2316 | 2316 | } |
2317 | 2317 | } else { |
2318 | 2318 | //grab single grp_id and delete |
2319 | - $GRP_ID = absint($this->_req_data['id'] ); |
|
2320 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2319 | + $GRP_ID = absint($this->_req_data['id']); |
|
2320 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2321 | 2321 | } |
2322 | 2322 | |
2323 | - $this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() ); |
|
2323 | + $this->_redirect_after_action($success, 'Message Templates', 'deleted', array()); |
|
2324 | 2324 | |
2325 | 2325 | } |
2326 | 2326 | |
@@ -2335,20 +2335,20 @@ discard block |
||
2335 | 2335 | * |
2336 | 2336 | * @return bool boolean to indicate the success of the deletes or not. |
2337 | 2337 | */ |
2338 | - private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) { |
|
2338 | + private function _delete_mtp_permanently($GRP_ID, $include_group = true) { |
|
2339 | 2339 | $success = 1; |
2340 | 2340 | $MTPG = EEM_Message_Template_Group::instance(); |
2341 | 2341 | //first let's GET this group |
2342 | - $MTG = $MTPG->get_one_by_ID( $GRP_ID ); |
|
2342 | + $MTG = $MTPG->get_one_by_ID($GRP_ID); |
|
2343 | 2343 | //then delete permanently all the related Message Templates |
2344 | - $deleted = $MTG->delete_related_permanently( 'Message_Template' ); |
|
2344 | + $deleted = $MTG->delete_related_permanently('Message_Template'); |
|
2345 | 2345 | |
2346 | - if ( $deleted === 0 ) |
|
2347 | - {$success = 0;} |
|
2346 | + if ($deleted === 0) |
|
2347 | + {$success = 0; } |
|
2348 | 2348 | |
2349 | 2349 | //now delete permanently this particular group |
2350 | 2350 | |
2351 | - if ( $include_group && ! $MTG->delete_permanently() ) { |
|
2351 | + if ($include_group && ! $MTG->delete_permanently()) { |
|
2352 | 2352 | $success = 0; |
2353 | 2353 | } |
2354 | 2354 | return $success; |
@@ -2366,7 +2366,7 @@ discard block |
||
2366 | 2366 | * @return string |
2367 | 2367 | */ |
2368 | 2368 | protected function _learn_more_about_message_templates_link() { |
2369 | - return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>'; |
|
2369 | + return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>'; |
|
2370 | 2370 | } |
2371 | 2371 | |
2372 | 2372 | |
@@ -2381,14 +2381,14 @@ discard block |
||
2381 | 2381 | */ |
2382 | 2382 | protected function _settings() { |
2383 | 2383 | |
2384 | - EE_Registry::instance()->load_helper( 'Tabbed_Content' ); |
|
2384 | + EE_Registry::instance()->load_helper('Tabbed_Content'); |
|
2385 | 2385 | |
2386 | 2386 | $this->_set_m_mt_settings(); |
2387 | 2387 | |
2388 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2388 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2389 | 2389 | |
2390 | 2390 | //let's setup the messenger tabs |
2391 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger ); |
|
2391 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger); |
|
2392 | 2392 | $this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">'; |
2393 | 2393 | $this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->'; |
2394 | 2394 | |
@@ -2407,7 +2407,7 @@ discard block |
||
2407 | 2407 | */ |
2408 | 2408 | protected function _set_m_mt_settings() { |
2409 | 2409 | //first if this is already set then lets get out no need to regenerate data. |
2410 | - if ( !empty($this->_m_mt_settings) ) { |
|
2410 | + if ( ! empty($this->_m_mt_settings)) { |
|
2411 | 2411 | return; |
2412 | 2412 | } |
2413 | 2413 | |
@@ -2421,10 +2421,10 @@ discard block |
||
2421 | 2421 | |
2422 | 2422 | //assemble the array for the _tab_text_links helper |
2423 | 2423 | |
2424 | - foreach ( $messengers as $messenger ) { |
|
2424 | + foreach ($messengers as $messenger) { |
|
2425 | 2425 | $this->_m_mt_settings['messenger_tabs'][$messenger->name] = array( |
2426 | 2426 | 'label' => ucwords($messenger->label['singular']), |
2427 | - 'class' => isset( $this->_active_messengers[$messenger->name] ) ? 'messenger-active' : '', |
|
2427 | + 'class' => isset($this->_active_messengers[$messenger->name]) ? 'messenger-active' : '', |
|
2428 | 2428 | 'href' => $messenger->name, |
2429 | 2429 | 'title' => __('Modify this Messenger', 'event_espresso'), |
2430 | 2430 | 'slug' => $messenger->name, |
@@ -2435,29 +2435,29 @@ discard block |
||
2435 | 2435 | $message_types_for_messenger = $messenger->get_valid_message_types(); |
2436 | 2436 | |
2437 | 2437 | //assemble the array for the ACTIVE and INACTIVE message types with the selected messenger //note that all message types will be in the inactive box if the messenger is NOT active. |
2438 | - $selected_settings = isset( $this->_active_message_types[$messenger->name]['settings'] ) |
|
2438 | + $selected_settings = isset($this->_active_message_types[$messenger->name]['settings']) |
|
2439 | 2439 | ? $this->_active_message_types[$messenger->name]['settings'] |
2440 | 2440 | : array(); |
2441 | - foreach ( $message_types as $message_type ) { |
|
2441 | + foreach ($message_types as $message_type) { |
|
2442 | 2442 | //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. |
2443 | - if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) { |
|
2443 | + if ( ! in_array($message_type->name, $message_types_for_messenger)) { |
|
2444 | 2444 | continue; |
2445 | 2445 | } |
2446 | 2446 | |
2447 | - $a_or_i = isset( $selected_settings[$messenger->name . '-message_types'][$message_type->name] ) && $selected_settings[$messenger->name . '-message_types'][$message_type->name] ? 'active' : 'inactive'; |
|
2447 | + $a_or_i = isset($selected_settings[$messenger->name.'-message_types'][$message_type->name]) && $selected_settings[$messenger->name.'-message_types'][$message_type->name] ? 'active' : 'inactive'; |
|
2448 | 2448 | |
2449 | 2449 | $this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array( |
2450 | - 'label' => ucwords( $message_type->label[ 'singular' ] ), |
|
2451 | - 'class' => 'message-type-' . $a_or_i, |
|
2452 | - 'slug_id' => $message_type->name . '-messagetype-' . $messenger->name, |
|
2453 | - 'mt_nonce' => wp_create_nonce( $message_type->name . '_nonce' ), |
|
2454 | - 'href' => 'espresso_' . $message_type->name . '_message_type_settings', |
|
2450 | + 'label' => ucwords($message_type->label['singular']), |
|
2451 | + 'class' => 'message-type-'.$a_or_i, |
|
2452 | + 'slug_id' => $message_type->name.'-messagetype-'.$messenger->name, |
|
2453 | + 'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'), |
|
2454 | + 'href' => 'espresso_'.$message_type->name.'_message_type_settings', |
|
2455 | 2455 | 'title' => $a_or_i == 'active' |
2456 | - ? __( 'Drag this message type to the Inactive window to deactivate', 'event_espresso' ) |
|
2457 | - : __( 'Drag this message type to the messenger to activate', 'event_espresso' ), |
|
2456 | + ? __('Drag this message type to the Inactive window to deactivate', 'event_espresso') |
|
2457 | + : __('Drag this message type to the messenger to activate', 'event_espresso'), |
|
2458 | 2458 | 'content' => $a_or_i == 'active' |
2459 | - ? $this->_message_type_settings_content( $message_type, $messenger, true ) |
|
2460 | - : $this->_message_type_settings_content( $message_type, $messenger ), |
|
2459 | + ? $this->_message_type_settings_content($message_type, $messenger, true) |
|
2460 | + : $this->_message_type_settings_content($message_type, $messenger), |
|
2461 | 2461 | 'slug' => $message_type->name, |
2462 | 2462 | 'active' => $a_or_i == 'active' ? true : false, |
2463 | 2463 | 'obj' => $message_type |
@@ -2476,34 +2476,34 @@ discard block |
||
2476 | 2476 | * |
2477 | 2477 | * @return string html output for the content |
2478 | 2478 | */ |
2479 | - protected function _message_type_settings_content( $message_type, $messenger, $active = false ) { |
|
2479 | + protected function _message_type_settings_content($message_type, $messenger, $active = false) { |
|
2480 | 2480 | //get message type fields |
2481 | 2481 | $fields = $message_type->get_admin_settings_fields(); |
2482 | - $settings_template_args['template_form_fields']= ''; |
|
2482 | + $settings_template_args['template_form_fields'] = ''; |
|
2483 | 2483 | |
2484 | - if ( !empty( $fields ) && $active ) { |
|
2484 | + if ( ! empty($fields) && $active) { |
|
2485 | 2485 | |
2486 | - $existing_settings = $message_type->get_existing_admin_settings( $messenger->name ); |
|
2486 | + $existing_settings = $message_type->get_existing_admin_settings($messenger->name); |
|
2487 | 2487 | |
2488 | - foreach( $fields as $fldname => $fldprops ) { |
|
2489 | - $field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname; |
|
2488 | + foreach ($fields as $fldname => $fldprops) { |
|
2489 | + $field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname; |
|
2490 | 2490 | $template_form_field[$field_id] = array( |
2491 | - 'name' => 'message_type_settings[' . $fldname . ']', |
|
2491 | + 'name' => 'message_type_settings['.$fldname.']', |
|
2492 | 2492 | 'label' => $fldprops['label'], |
2493 | 2493 | 'input' => $fldprops['field_type'], |
2494 | 2494 | 'type' => $fldprops['value_type'], |
2495 | 2495 | 'required' => $fldprops['required'], |
2496 | 2496 | 'validation' => $fldprops['validation'], |
2497 | - 'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2498 | - 'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(), |
|
2499 | - 'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2497 | + 'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2498 | + 'options' => isset($fldprops['options']) ? $fldprops['options'] : array(), |
|
2499 | + 'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2500 | 2500 | 'css_class' => 'no-drag', |
2501 | 2501 | 'format' => $fldprops['format'] |
2502 | 2502 | ); |
2503 | 2503 | } |
2504 | 2504 | |
2505 | 2505 | |
2506 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : ''; |
|
2506 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : ''; |
|
2507 | 2507 | } |
2508 | 2508 | |
2509 | 2509 | $settings_template_args['description'] = $message_type->description; |
@@ -2523,13 +2523,13 @@ discard block |
||
2523 | 2523 | ) |
2524 | 2524 | ); |
2525 | 2525 | |
2526 | - $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' ); |
|
2527 | - $settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : ''; |
|
2526 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array'); |
|
2527 | + $settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : ''; |
|
2528 | 2528 | |
2529 | 2529 | |
2530 | 2530 | |
2531 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php'; |
|
2532 | - $content = EEH_Template::display_template( $template, $settings_template_args, true ); |
|
2531 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php'; |
|
2532 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2533 | 2533 | return $content; |
2534 | 2534 | } |
2535 | 2535 | |
@@ -2546,21 +2546,21 @@ discard block |
||
2546 | 2546 | $m_boxes = $mt_boxes = array(); |
2547 | 2547 | $m_template_args = $mt_template_args = array(); |
2548 | 2548 | |
2549 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2549 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2550 | 2550 | |
2551 | - foreach ( $this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array ) { |
|
2551 | + foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) { |
|
2552 | 2552 | |
2553 | - $hide_on_message = isset( $this->_active_messengers[$messenger] ) ? '' : 'hidden'; |
|
2554 | - $hide_off_message = isset( $this->_active_messengers[$messenger] ) ? 'hidden' : ''; |
|
2553 | + $hide_on_message = isset($this->_active_messengers[$messenger]) ? '' : 'hidden'; |
|
2554 | + $hide_off_message = isset($this->_active_messengers[$messenger]) ? 'hidden' : ''; |
|
2555 | 2555 | |
2556 | 2556 | //messenger meta boxes |
2557 | 2557 | $active = $selected_messenger == $messenger ? true : false; |
2558 | - $active_mt_tabs = isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] ) ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : ''; |
|
2559 | - $m_boxes[$messenger . '_a_box'] = sprintf( __('%s Settings', 'event_espresso'), $tab_array['label'] ); |
|
2560 | - $m_template_args[$messenger . '_a_box'] = array( |
|
2561 | - 'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2562 | - 'inactive_message_types' => isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) ? $this->_get_mt_tabs( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) : '', |
|
2563 | - 'content' => $this->_get_messenger_box_content( $tab_array['obj'] ), |
|
2558 | + $active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active']) ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : ''; |
|
2559 | + $m_boxes[$messenger.'_a_box'] = sprintf(__('%s Settings', 'event_espresso'), $tab_array['label']); |
|
2560 | + $m_template_args[$messenger.'_a_box'] = array( |
|
2561 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2562 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) : '', |
|
2563 | + 'content' => $this->_get_messenger_box_content($tab_array['obj']), |
|
2564 | 2564 | 'hidden' => $active ? '' : ' hidden', |
2565 | 2565 | 'hide_on_message' => $hide_on_message, |
2566 | 2566 | 'messenger' => $messenger, |
@@ -2569,10 +2569,10 @@ discard block |
||
2569 | 2569 | |
2570 | 2570 | |
2571 | 2571 | //message type meta boxes (which is really just the inactive container for each messenger showing inactive message types for that messenger) |
2572 | - $mt_boxes[$messenger . '_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
2573 | - $mt_template_args[$messenger . '_i_box'] = array( |
|
2574 | - 'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2575 | - 'inactive_message_types' => isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) ? $this->_get_mt_tabs( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) : '', |
|
2572 | + $mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
2573 | + $mt_template_args[$messenger.'_i_box'] = array( |
|
2574 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2575 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) : '', |
|
2576 | 2576 | 'hidden' => $active ? '' : ' hidden', |
2577 | 2577 | 'hide_on_message' => $hide_on_message, |
2578 | 2578 | 'hide_off_message' => $hide_off_message, |
@@ -2582,19 +2582,19 @@ discard block |
||
2582 | 2582 | } |
2583 | 2583 | |
2584 | 2584 | //register messenger metaboxes |
2585 | - $m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2586 | - foreach ( $m_boxes as $box => $label ) { |
|
2587 | - $callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] ); |
|
2588 | - $msgr = str_replace( '_a_box', '', $box ); |
|
2589 | - add_meta_box( 'espresso_' . $msgr . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args ); |
|
2585 | + $m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2586 | + foreach ($m_boxes as $box => $label) { |
|
2587 | + $callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]); |
|
2588 | + $msgr = str_replace('_a_box', '', $box); |
|
2589 | + add_meta_box('espresso_'.$msgr.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args); |
|
2590 | 2590 | } |
2591 | 2591 | |
2592 | 2592 | //register message type metaboxes |
2593 | - $mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php'; |
|
2594 | - foreach ( $mt_boxes as $box => $label ) { |
|
2595 | - $callback_args = array( 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box] ); |
|
2596 | - $mt = str_replace( '_i_box', '', $box ); |
|
2597 | - add_meta_box( 'espresso_' . $mt . '_inactive_mts', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'side', 'high', $callback_args ); |
|
2593 | + $mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php'; |
|
2594 | + foreach ($mt_boxes as $box => $label) { |
|
2595 | + $callback_args = array('template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box]); |
|
2596 | + $mt = str_replace('_i_box', '', $box); |
|
2597 | + add_meta_box('espresso_'.$mt.'_inactive_mts', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'side', 'high', $callback_args); |
|
2598 | 2598 | } |
2599 | 2599 | |
2600 | 2600 | } |
@@ -2607,13 +2607,13 @@ discard block |
||
2607 | 2607 | * |
2608 | 2608 | * @return string html formatted tabs |
2609 | 2609 | */ |
2610 | - protected function _get_mt_tabs( $tab_array ) { |
|
2610 | + protected function _get_mt_tabs($tab_array) { |
|
2611 | 2611 | $tab_array = (array) $tab_array; |
2612 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2612 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2613 | 2613 | $tabs = ''; |
2614 | 2614 | |
2615 | - foreach ( $tab_array as $tab ) { |
|
2616 | - $tabs .= EEH_Template::display_template( $template, $tab, true ); |
|
2615 | + foreach ($tab_array as $tab) { |
|
2616 | + $tabs .= EEH_Template::display_template($template, $tab, true); |
|
2617 | 2617 | } |
2618 | 2618 | |
2619 | 2619 | return $tabs; |
@@ -2629,7 +2629,7 @@ discard block |
||
2629 | 2629 | * |
2630 | 2630 | * @return string html formatted content |
2631 | 2631 | */ |
2632 | - protected function _get_messenger_box_content( $messenger ) { |
|
2632 | + protected function _get_messenger_box_content($messenger) { |
|
2633 | 2633 | |
2634 | 2634 | $fields = $messenger->get_admin_settings_fields(); |
2635 | 2635 | $settings_template_args['template_form_fields'] = ''; |
@@ -2638,27 +2638,27 @@ discard block |
||
2638 | 2638 | $settings_template_args['active'] = isset($this->_active_messengers[$messenger->name]) ? true : false; |
2639 | 2639 | |
2640 | 2640 | |
2641 | - if ( !empty( $fields ) ) { |
|
2641 | + if ( ! empty($fields)) { |
|
2642 | 2642 | |
2643 | 2643 | $existing_settings = $messenger->get_existing_admin_settings(); |
2644 | 2644 | |
2645 | - foreach( $fields as $fldname => $fldprops ) { |
|
2646 | - $field_id = $messenger->name . '-' . $fldname; |
|
2645 | + foreach ($fields as $fldname => $fldprops) { |
|
2646 | + $field_id = $messenger->name.'-'.$fldname; |
|
2647 | 2647 | $template_form_field[$field_id] = array( |
2648 | - 'name' => 'messenger_settings[' . $field_id . ']', |
|
2648 | + 'name' => 'messenger_settings['.$field_id.']', |
|
2649 | 2649 | 'label' => $fldprops['label'], |
2650 | 2650 | 'input' => $fldprops['field_type'], |
2651 | 2651 | 'type' => $fldprops['value_type'], |
2652 | 2652 | 'required' => $fldprops['required'], |
2653 | 2653 | 'validation' => $fldprops['validation'], |
2654 | - 'value' => isset( $existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'], |
|
2654 | + 'value' => isset($existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'], |
|
2655 | 2655 | 'css_class' => '', |
2656 | 2656 | 'format' => $fldprops['format'] |
2657 | 2657 | ); |
2658 | 2658 | } |
2659 | 2659 | |
2660 | 2660 | |
2661 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' ) : ''; |
|
2661 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form') : ''; |
|
2662 | 2662 | } |
2663 | 2663 | |
2664 | 2664 | //we also need some hidden fields |
@@ -2674,8 +2674,8 @@ discard block |
||
2674 | 2674 | ); |
2675 | 2675 | |
2676 | 2676 | //make sure any active message types that are existing are included in the hidden fields |
2677 | - if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) { |
|
2678 | - foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) { |
|
2677 | + if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) { |
|
2678 | + foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) { |
|
2679 | 2679 | $settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array( |
2680 | 2680 | 'type' => 'hidden', |
2681 | 2681 | 'value' => $mt |
@@ -2683,25 +2683,25 @@ discard block |
||
2683 | 2683 | } |
2684 | 2684 | } |
2685 | 2685 | |
2686 | - $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' ); |
|
2686 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array'); |
|
2687 | 2687 | |
2688 | - $active = isset( $this->_active_messengers[$messenger->name] ) ? true : false; |
|
2688 | + $active = isset($this->_active_messengers[$messenger->name]) ? true : false; |
|
2689 | 2689 | |
2690 | 2690 | $settings_template_args['messenger'] = $messenger->name; |
2691 | 2691 | $settings_template_args['description'] = $messenger->description; |
2692 | 2692 | $settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden'; |
2693 | 2693 | |
2694 | 2694 | |
2695 | - $settings_template_args['show_hide_edit_form'] = isset( $this->_active_messengers[$messenger->name] ) ? $settings_template_args['show_hide_edit_form'] : ' hidden'; |
|
2695 | + $settings_template_args['show_hide_edit_form'] = isset($this->_active_messengers[$messenger->name]) ? $settings_template_args['show_hide_edit_form'] : ' hidden'; |
|
2696 | 2696 | |
2697 | - $settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : $settings_template_args['show_hide_edit_form']; |
|
2697 | + $settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : $settings_template_args['show_hide_edit_form']; |
|
2698 | 2698 | |
2699 | 2699 | |
2700 | 2700 | $settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on'; |
2701 | - $settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce'); |
|
2701 | + $settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce'); |
|
2702 | 2702 | $settings_template_args['on_off_status'] = $active ? true : false; |
2703 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php'; |
|
2704 | - $content = EEH_Template::display_template( $template, $settings_template_args, true); |
|
2703 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php'; |
|
2704 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2705 | 2705 | return $content; |
2706 | 2706 | } |
2707 | 2707 | |
@@ -2714,39 +2714,39 @@ discard block |
||
2714 | 2714 | public function activate_messenger_toggle() { |
2715 | 2715 | $success = true; |
2716 | 2716 | //let's check that we have required data |
2717 | - if ( !isset( $this->_req_data[ 'messenger' ] ) ) { |
|
2718 | - EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2717 | + if ( ! isset($this->_req_data['messenger'])) { |
|
2718 | + EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2719 | 2719 | $success = false; |
2720 | 2720 | } |
2721 | 2721 | |
2722 | 2722 | //do a nonce check here since we're not arriving via a normal route |
2723 | - $nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : ''; |
|
2724 | - $nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce'; |
|
2723 | + $nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : ''; |
|
2724 | + $nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce'; |
|
2725 | 2725 | |
2726 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
2726 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
2727 | 2727 | |
2728 | 2728 | |
2729 | 2729 | |
2730 | - if ( !isset( $this->_req_data[ 'status' ])) { |
|
2731 | - EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2730 | + if ( ! isset($this->_req_data['status'])) { |
|
2731 | + EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2732 | 2732 | $success = false; |
2733 | 2733 | } |
2734 | 2734 | |
2735 | 2735 | //do check to verify we have a valid status. |
2736 | 2736 | $status = $this->_req_data['status']; |
2737 | 2737 | |
2738 | - if ( $status != 'off' && $status != 'on' ) { |
|
2739 | - EE_Error::add_error( sprintf( __('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), $this->_req_data['status'] ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2738 | + if ($status != 'off' && $status != 'on') { |
|
2739 | + EE_Error::add_error(sprintf(__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), $this->_req_data['status']), __FILE__, __FUNCTION__, __LINE__); |
|
2740 | 2740 | $success = false; |
2741 | 2741 | } |
2742 | 2742 | |
2743 | - if ( $success ) { |
|
2743 | + if ($success) { |
|
2744 | 2744 | //made it here? Stop dawdling then!! |
2745 | - if ( $status == 'off' ) { |
|
2745 | + if ($status == 'off') { |
|
2746 | 2746 | //off = deactivate. get it? |
2747 | - $success = $this->_activate_messenger( $this->_req_data['messenger'], true ); |
|
2747 | + $success = $this->_activate_messenger($this->_req_data['messenger'], true); |
|
2748 | 2748 | } else { |
2749 | - $success = $this->_activate_messenger( $this->_req_data['messenger'] ); |
|
2749 | + $success = $this->_activate_messenger($this->_req_data['messenger']); |
|
2750 | 2750 | } |
2751 | 2751 | } |
2752 | 2752 | |
@@ -2770,26 +2770,26 @@ discard block |
||
2770 | 2770 | |
2771 | 2771 | |
2772 | 2772 | //let's make sure we have the necessary data |
2773 | - if ( !isset( $this->_req_data[ 'message_type' ] ) ) { |
|
2774 | - EE_Error::add_error( __('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2773 | + if ( ! isset($this->_req_data['message_type'])) { |
|
2774 | + EE_Error::add_error(__('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2775 | 2775 | $success = false; |
2776 | 2776 | } |
2777 | 2777 | |
2778 | 2778 | |
2779 | 2779 | //do a nonce check here since we're not arriving via a normal route |
2780 | - $nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : ''; |
|
2781 | - $nonce_ref = $this->_req_data['message_type'] . '_nonce'; |
|
2780 | + $nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : ''; |
|
2781 | + $nonce_ref = $this->_req_data['message_type'].'_nonce'; |
|
2782 | 2782 | |
2783 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
2783 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
2784 | 2784 | |
2785 | 2785 | |
2786 | - if ( !isset( $this->_req_data[ 'messenger' ] ) ) { |
|
2787 | - EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2786 | + if ( ! isset($this->_req_data['messenger'])) { |
|
2787 | + EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2788 | 2788 | $success = false; |
2789 | 2789 | } |
2790 | 2790 | |
2791 | - if ( !isset( $this->_req_data[ 'status' ])) { |
|
2792 | - EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2791 | + if ( ! isset($this->_req_data['status'])) { |
|
2792 | + EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2793 | 2793 | $success = false; |
2794 | 2794 | } |
2795 | 2795 | |
@@ -2797,16 +2797,16 @@ discard block |
||
2797 | 2797 | //do check to verify we have a valid status. |
2798 | 2798 | $status = $this->_req_data['status']; |
2799 | 2799 | |
2800 | - if ( $status != 'activate' && $status != 'deactivate' ) { |
|
2801 | - EE_Error::add_error( sprintf( __('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), $this->_req_data['status'] ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2800 | + if ($status != 'activate' && $status != 'deactivate') { |
|
2801 | + EE_Error::add_error(sprintf(__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), $this->_req_data['status']), __FILE__, __FUNCTION__, __LINE__); |
|
2802 | 2802 | $success = false; |
2803 | 2803 | } |
2804 | 2804 | |
2805 | 2805 | |
2806 | - if ( $success ) { |
|
2806 | + if ($success) { |
|
2807 | 2807 | //made it here? um, what are you waiting for then? |
2808 | 2808 | $deactivate = $status == 'deactivate' ? true : false; |
2809 | - $success = $this->_activate_messenger( $this->_req_data['messenger'], $deactivate, $this->_req_data['message_type'] ); |
|
2809 | + $success = $this->_activate_messenger($this->_req_data['messenger'], $deactivate, $this->_req_data['message_type']); |
|
2810 | 2810 | } |
2811 | 2811 | |
2812 | 2812 | $this->_template_args['success'] = $success; |
@@ -2836,18 +2836,18 @@ discard block |
||
2836 | 2836 | |
2837 | 2837 | $this->_set_m_mt_settings(); |
2838 | 2838 | |
2839 | - if ( !$deactivate ) { |
|
2839 | + if ( ! $deactivate) { |
|
2840 | 2840 | |
2841 | 2841 | |
2842 | 2842 | //we are activating. we can use $this->_m_mt_settings to get all the installed messengers |
2843 | - $this->_active_message_types[$messenger]['settings'] = !isset($this->_active_message_types[$messenger]['settings']) ? array() : $this->_active_message_types[$messenger]['settings']; |
|
2843 | + $this->_active_message_types[$messenger]['settings'] = ! isset($this->_active_message_types[$messenger]['settings']) ? array() : $this->_active_message_types[$messenger]['settings']; |
|
2844 | 2844 | /** @type EE_Messenger $active_messenger */ |
2845 | - $active_messenger = $this->_m_mt_settings[ 'messenger_tabs' ][ $messenger ][ 'obj' ]; |
|
2845 | + $active_messenger = $this->_m_mt_settings['messenger_tabs'][$messenger]['obj']; |
|
2846 | 2846 | |
2847 | 2847 | //get has_active so we can sure its kept up to date. |
2848 | - $has_activated = get_option( 'ee_has_activated_messages' ); |
|
2848 | + $has_activated = get_option('ee_has_activated_messages'); |
|
2849 | 2849 | |
2850 | - if ( empty( $has_activated[$messenger] ) ) { |
|
2850 | + if (empty($has_activated[$messenger])) { |
|
2851 | 2851 | $has_activated[$messenger] = array(); |
2852 | 2852 | } |
2853 | 2853 | |
@@ -2856,22 +2856,22 @@ discard block |
||
2856 | 2856 | ? (array) $message_type |
2857 | 2857 | : $active_messenger->get_default_message_types(); |
2858 | 2858 | |
2859 | - foreach ( $default_types as $type ) { |
|
2859 | + foreach ($default_types as $type) { |
|
2860 | 2860 | /** @type EE_Message_Type $active_message_type */ |
2861 | - $active_message_type = $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ][ $type ][ 'obj' ]; |
|
2861 | + $active_message_type = $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$type]['obj']; |
|
2862 | 2862 | $settings_fields = $active_message_type->get_admin_settings_fields(); |
2863 | 2863 | $settings = array(); |
2864 | - if ( !empty( $settings_fields ) ) { |
|
2864 | + if ( ! empty($settings_fields)) { |
|
2865 | 2865 | //we have fields for this message type so let's get the defaults for saving. |
2866 | - foreach ( $settings_fields as $field => $values ) { |
|
2866 | + foreach ($settings_fields as $field => $values) { |
|
2867 | 2867 | $settings[$field] = $values['default']; |
2868 | 2868 | } |
2869 | 2869 | //let's set the data for reloading this message type form in ajax |
2870 | 2870 | $this->_template_args['data']['mt_reload'][] = $type; |
2871 | 2871 | } |
2872 | - $this->_active_message_types[$messenger]['settings'][$messenger . '-message_types'][$type]['settings'] = $settings; |
|
2872 | + $this->_active_message_types[$messenger]['settings'][$messenger.'-message_types'][$type]['settings'] = $settings; |
|
2873 | 2873 | |
2874 | - if ( ! in_array( $type, $has_activated[$messenger] ) ) { |
|
2874 | + if ( ! in_array($type, $has_activated[$messenger])) { |
|
2875 | 2875 | $has_activated[$messenger][] = $type; |
2876 | 2876 | } |
2877 | 2877 | } |
@@ -2879,45 +2879,45 @@ discard block |
||
2879 | 2879 | //any default settings for the messenger? |
2880 | 2880 | $msgr_settings = $active_messenger->get_admin_settings_fields(); |
2881 | 2881 | |
2882 | - if ( !empty( $msgr_settings ) ) { |
|
2883 | - foreach ( $msgr_settings as $field => $value ) { |
|
2882 | + if ( ! empty($msgr_settings)) { |
|
2883 | + foreach ($msgr_settings as $field => $value) { |
|
2884 | 2884 | $this->_active_message_types[$messenger]['settings'][$field] = $value; |
2885 | 2885 | } |
2886 | 2886 | } |
2887 | 2887 | |
2888 | 2888 | //update settings in database |
2889 | - EEH_MSG_Template::update_active_messengers_in_db( $this->_active_message_types ); |
|
2890 | - update_option( 'ee_has_activated_messages', $has_activated ); |
|
2889 | + EEH_MSG_Template::update_active_messengers_in_db($this->_active_message_types); |
|
2890 | + update_option('ee_has_activated_messages', $has_activated); |
|
2891 | 2891 | |
2892 | 2892 | |
2893 | 2893 | //generate new templates (if necessary) |
2894 | - $templates = $this->_generate_new_templates( $messenger, $default_types, 0, true ); |
|
2894 | + $templates = $this->_generate_new_templates($messenger, $default_types, 0, true); |
|
2895 | 2895 | |
2896 | 2896 | EE_Error::overwrite_success(); |
2897 | 2897 | |
2898 | 2898 | //if generation failed then we need to remove the active messenger. |
2899 | - if ( !$templates ) { |
|
2899 | + if ( ! $templates) { |
|
2900 | 2900 | unset($this->_active_message_types[$messenger]); |
2901 | - EEH_MSG_Template::update_active_messengers_in_db( $this->_active_message_types ); |
|
2901 | + EEH_MSG_Template::update_active_messengers_in_db($this->_active_message_types); |
|
2902 | 2902 | } else { |
2903 | 2903 | //all is good let's do a success message |
2904 | - if ( $message_type ) { |
|
2905 | - EE_Error::add_success( sprintf( __('%s message type has been successfully activated with the %s messenger', 'event_espresso'),ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$message_type]['obj']->label['singular']), ucwords( $this->_active_messengers[$messenger]->label['singular'] ) ) ); |
|
2904 | + if ($message_type) { |
|
2905 | + EE_Error::add_success(sprintf(__('%s message type has been successfully activated with the %s messenger', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$message_type]['obj']->label['singular']), ucwords($this->_active_messengers[$messenger]->label['singular']))); |
|
2906 | 2906 | |
2907 | 2907 | //if message type was invoice then let's make sure we activate the invoice payment method. |
2908 | - if ( $message_type == 'invoice' ) { |
|
2909 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
2910 | - $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
2911 | - if ( $pm instanceof EE_Payment_Method ) { |
|
2912 | - 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' ) ); |
|
2908 | + if ($message_type == 'invoice') { |
|
2909 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
2910 | + $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
2911 | + if ($pm instanceof EE_Payment_Method) { |
|
2912 | + 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')); |
|
2913 | 2913 | } |
2914 | 2914 | } |
2915 | 2915 | } else { |
2916 | 2916 | $installed_messengers = $this->_message_resource_manager->installed_messengers(); |
2917 | 2917 | EE_Error::add_success( |
2918 | 2918 | sprintf( |
2919 | - __( '%s messenger has been successfully activated', 'event_espresso' ), |
|
2920 | - ucwords( $installed_messengers[ $messenger ]->label[ 'singular' ] ) |
|
2919 | + __('%s messenger has been successfully activated', 'event_espresso'), |
|
2920 | + ucwords($installed_messengers[$messenger]->label['singular']) |
|
2921 | 2921 | ) |
2922 | 2922 | ); |
2923 | 2923 | } |
@@ -2932,37 +2932,37 @@ discard block |
||
2932 | 2932 | $update_array = array( |
2933 | 2933 | 'MTP_messenger' => $messenger); |
2934 | 2934 | |
2935 | - if ( $message_type ) { |
|
2935 | + if ($message_type) { |
|
2936 | 2936 | $update_array['MTP_message_type'] = $message_type; |
2937 | 2937 | } |
2938 | - EEM_Message_Template_Group::instance()->update( array( 'MTP_is_active' => 0 ), array($update_array) ); |
|
2938 | + EEM_Message_Template_Group::instance()->update(array('MTP_is_active' => 0), array($update_array)); |
|
2939 | 2939 | |
2940 | 2940 | $messenger_obj = $this->_active_messengers[$messenger]; |
2941 | 2941 | |
2942 | 2942 | //if this is a message type deactivation then we're only unsetting the message type otherwise unset the messenger |
2943 | - if ( $message_type ) { |
|
2944 | - unset( $this->_active_message_types[$messenger]['settings'][$messenger . '-message_types'][$message_type] ); |
|
2943 | + if ($message_type) { |
|
2944 | + unset($this->_active_message_types[$messenger]['settings'][$messenger.'-message_types'][$message_type]); |
|
2945 | 2945 | } else { |
2946 | - unset( $this->_active_message_types[$messenger] ); |
|
2946 | + unset($this->_active_message_types[$messenger]); |
|
2947 | 2947 | } |
2948 | 2948 | |
2949 | - EEH_MSG_Template::update_active_messengers_in_db( $this->_active_message_types ); |
|
2949 | + EEH_MSG_Template::update_active_messengers_in_db($this->_active_message_types); |
|
2950 | 2950 | EE_Error::overwrite_success(); |
2951 | - if ( $message_type ) { |
|
2952 | - EE_Error::add_success( sprintf( __('%s message type has been successfully deactivated', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['active'][$message_type]['obj']->label['singular']) ) ); |
|
2951 | + if ($message_type) { |
|
2952 | + EE_Error::add_success(sprintf(__('%s message type has been successfully deactivated', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['active'][$message_type]['obj']->label['singular']))); |
|
2953 | 2953 | } else { |
2954 | - EE_Error::add_success( sprintf( __('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular'] ) ) ); |
|
2954 | + EE_Error::add_success(sprintf(__('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular']))); |
|
2955 | 2955 | } |
2956 | 2956 | |
2957 | 2957 | //if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method. |
2958 | - if ( $messenger == 'html' || $message_type == 'invoice') { |
|
2959 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
2960 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' ); |
|
2961 | - if ( $count_updated > 0 ) { |
|
2958 | + if ($messenger == 'html' || $message_type == 'invoice') { |
|
2959 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
2960 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice'); |
|
2961 | + if ($count_updated > 0) { |
|
2962 | 2962 | $msg = $message_type == 'invoice' |
2963 | - ? __('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' ) |
|
2964 | - : __('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' ); |
|
2965 | - EE_Error::add_attention( $msg ); |
|
2963 | + ? __('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') |
|
2964 | + : __('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'); |
|
2965 | + EE_Error::add_attention($msg); |
|
2966 | 2966 | } |
2967 | 2967 | } |
2968 | 2968 | |
@@ -2978,17 +2978,17 @@ discard block |
||
2978 | 2978 | * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax) |
2979 | 2979 | */ |
2980 | 2980 | public function update_mt_form() { |
2981 | - if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) { |
|
2982 | - EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2981 | + if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) { |
|
2982 | + EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__); |
|
2983 | 2983 | $this->_return_json(); |
2984 | 2984 | } |
2985 | 2985 | |
2986 | 2986 | $message_types = $this->get_installed_message_types(); |
2987 | 2987 | |
2988 | - $message_type = $message_types[ $this->_req_data['message_type'] ]; |
|
2989 | - $messenger = $this->_active_messengers[ $this->_req_data['messenger'] ]; |
|
2988 | + $message_type = $message_types[$this->_req_data['message_type']]; |
|
2989 | + $messenger = $this->_active_messengers[$this->_req_data['messenger']]; |
|
2990 | 2990 | |
2991 | - $content = $this->_message_type_settings_content ( $message_type, $messenger, true ); |
|
2991 | + $content = $this->_message_type_settings_content($message_type, $messenger, true); |
|
2992 | 2992 | $this->_template_args['success'] = true; |
2993 | 2993 | $this->_template_args['content'] = $content; |
2994 | 2994 | $this->_return_json(); |
@@ -3002,42 +3002,42 @@ discard block |
||
3002 | 3002 | * |
3003 | 3003 | */ |
3004 | 3004 | public function save_settings() { |
3005 | - if ( !isset( $this->_req_data['type'] ) ) { |
|
3006 | - EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3005 | + if ( ! isset($this->_req_data['type'])) { |
|
3006 | + EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3007 | 3007 | $this->_template_args['error'] = true; |
3008 | 3008 | $this->_return_json(); |
3009 | 3009 | } |
3010 | 3010 | |
3011 | 3011 | |
3012 | - if ( $this->_req_data['type'] == 'messenger' ) { |
|
3012 | + if ($this->_req_data['type'] == 'messenger') { |
|
3013 | 3013 | $settings = $this->_req_data['messenger_settings']; //this should be an array. |
3014 | 3014 | $messenger = $settings['messenger']; |
3015 | 3015 | //let's setup the settings data |
3016 | - foreach ( $settings as $key => $value ) { |
|
3017 | - switch ( $key ) { |
|
3016 | + foreach ($settings as $key => $value) { |
|
3017 | + switch ($key) { |
|
3018 | 3018 | case 'messenger' : |
3019 | - unset( $settings['messenger'] ); |
|
3019 | + unset($settings['messenger']); |
|
3020 | 3020 | break; |
3021 | 3021 | case 'message_types' : |
3022 | 3022 | if ( |
3023 | - isset( $this->_active_message_types[$messenger]['settings'][$messenger . '-message_types'] ) |
|
3023 | + isset($this->_active_message_types[$messenger]['settings'][$messenger.'-message_types']) |
|
3024 | 3024 | ) { |
3025 | - foreach ( $this->_active_message_types[$messenger]['settings'][$messenger . '-message_types'] as $mt => $v ) { |
|
3026 | - if ( isset( $settings['message_types'][$mt] ) ) { |
|
3027 | - $settings[$messenger . '-message_types'][$mt]['settings'] |
|
3028 | - = isset( $this->_active_message_types[$messenger]['settings'][$messenger . '-message_types'][$mt] ) |
|
3029 | - ? $this->_active_message_types[$messenger]['settings'][$messenger . '-message_types'][$mt] |
|
3025 | + foreach ($this->_active_message_types[$messenger]['settings'][$messenger.'-message_types'] as $mt => $v) { |
|
3026 | + if (isset($settings['message_types'][$mt])) { |
|
3027 | + $settings[$messenger.'-message_types'][$mt]['settings'] |
|
3028 | + = isset($this->_active_message_types[$messenger]['settings'][$messenger.'-message_types'][$mt]) |
|
3029 | + ? $this->_active_message_types[$messenger]['settings'][$messenger.'-message_types'][$mt] |
|
3030 | 3030 | : array(); |
3031 | 3031 | } |
3032 | 3032 | } |
3033 | 3033 | } else { |
3034 | - foreach ( $value as $mt => $v ) { |
|
3034 | + foreach ($value as $mt => $v) { |
|
3035 | 3035 | //let's see if this message type is already present and has settings. |
3036 | - $settings[$messenger . '-message_types'][$mt]['settings'] = array(); |
|
3036 | + $settings[$messenger.'-message_types'][$mt]['settings'] = array(); |
|
3037 | 3037 | } |
3038 | 3038 | } |
3039 | 3039 | //k settings are set let's get rid of the message types index |
3040 | - unset( $settings['message_types'] ); |
|
3040 | + unset($settings['message_types']); |
|
3041 | 3041 | break; |
3042 | 3042 | default : |
3043 | 3043 | $settings[$key] = $value; |
@@ -3047,36 +3047,36 @@ discard block |
||
3047 | 3047 | $this->_active_message_types[$messenger]['settings'] = $settings; |
3048 | 3048 | } |
3049 | 3049 | |
3050 | - else if ( $this->_req_data['type'] == 'message_type' ) { |
|
3050 | + else if ($this->_req_data['type'] == 'message_type') { |
|
3051 | 3051 | $settings = $this->_req_data['message_type_settings']; |
3052 | 3052 | $messenger = $settings['messenger']; |
3053 | 3053 | $message_type = $settings['message_type']; |
3054 | 3054 | |
3055 | - foreach ( $settings as $key => $value ) { |
|
3056 | - switch ( $key ) { |
|
3055 | + foreach ($settings as $key => $value) { |
|
3056 | + switch ($key) { |
|
3057 | 3057 | case 'messenger' : |
3058 | - unset( $settings['messenger'] ); |
|
3058 | + unset($settings['messenger']); |
|
3059 | 3059 | break; |
3060 | 3060 | case 'message_type' : |
3061 | - unset( $settings['message_type'] ); |
|
3061 | + unset($settings['message_type']); |
|
3062 | 3062 | break; |
3063 | 3063 | default : |
3064 | 3064 | $settings['settings'][$key] = $value; |
3065 | - unset( $settings[$key] ); |
|
3065 | + unset($settings[$key]); |
|
3066 | 3066 | break; |
3067 | 3067 | } |
3068 | 3068 | } |
3069 | 3069 | |
3070 | - $this->_active_message_types[$messenger]['settings'][$messenger . '-message_types'][$message_type] = $settings; |
|
3070 | + $this->_active_message_types[$messenger]['settings'][$messenger.'-message_types'][$message_type] = $settings; |
|
3071 | 3071 | } |
3072 | 3072 | |
3073 | 3073 | //okay we should have the data all setup. Now we just update! |
3074 | - $success = EEH_MSG_Template::update_active_messengers_in_db( $this->_active_message_types ); |
|
3074 | + $success = EEH_MSG_Template::update_active_messengers_in_db($this->_active_message_types); |
|
3075 | 3075 | |
3076 | - if ( $success ) { |
|
3077 | - EE_Error::add_success( __('Settings updated', 'event_espresso') ); |
|
3076 | + if ($success) { |
|
3077 | + EE_Error::add_success(__('Settings updated', 'event_espresso')); |
|
3078 | 3078 | } else { |
3079 | - EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3079 | + EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3080 | 3080 | } |
3081 | 3081 | |
3082 | 3082 | $this->_template_args['success'] = $success; |
@@ -3098,8 +3098,8 @@ discard block |
||
3098 | 3098 | */ |
3099 | 3099 | protected function _generate_now() { |
3100 | 3100 | $msg_ids = $this->_get_msg_ids_from_request(); |
3101 | - EED_Messages::generate_now( $msg_ids ); |
|
3102 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3101 | + EED_Messages::generate_now($msg_ids); |
|
3102 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3103 | 3103 | } |
3104 | 3104 | |
3105 | 3105 | |
@@ -3114,7 +3114,7 @@ discard block |
||
3114 | 3114 | protected function _generate_and_send_now() { |
3115 | 3115 | $this->_generate_now(); |
3116 | 3116 | $this->_send_now(); |
3117 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3117 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3118 | 3118 | } |
3119 | 3119 | |
3120 | 3120 | |
@@ -3128,8 +3128,8 @@ discard block |
||
3128 | 3128 | */ |
3129 | 3129 | protected function _queue_for_resending() { |
3130 | 3130 | $msg_ids = $this->_get_msg_ids_from_request(); |
3131 | - EED_Messages::queue_for_resending( $msg_ids ); |
|
3132 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3131 | + EED_Messages::queue_for_resending($msg_ids); |
|
3132 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3133 | 3133 | } |
3134 | 3134 | |
3135 | 3135 | |
@@ -3142,8 +3142,8 @@ discard block |
||
3142 | 3142 | */ |
3143 | 3143 | protected function _send_now() { |
3144 | 3144 | $msg_ids = $this->_get_msg_ids_from_request(); |
3145 | - EED_Messages::send_now( $msg_ids ); |
|
3146 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3145 | + EED_Messages::send_now($msg_ids); |
|
3146 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3147 | 3147 | } |
3148 | 3148 | |
3149 | 3149 | |
@@ -3157,23 +3157,23 @@ discard block |
||
3157 | 3157 | protected function _delete_ee_messages() { |
3158 | 3158 | $msg_ids = $this->_get_msg_ids_from_request(); |
3159 | 3159 | $deleted_count = 0; |
3160 | - foreach ( $msg_ids as $msg_id ) { |
|
3161 | - if ( EEM_Message::instance()->delete_by_ID( $msg_id ) ) { |
|
3160 | + foreach ($msg_ids as $msg_id) { |
|
3161 | + if (EEM_Message::instance()->delete_by_ID($msg_id)) { |
|
3162 | 3162 | $deleted_count++; |
3163 | 3163 | } |
3164 | 3164 | } |
3165 | - if ( $deleted_count ) { |
|
3165 | + if ($deleted_count) { |
|
3166 | 3166 | $this->_redirect_after_action( |
3167 | 3167 | true, |
3168 | - _n( 'message', 'messages', $deleted_count, 'event_espresso' ), |
|
3168 | + _n('message', 'messages', $deleted_count, 'event_espresso'), |
|
3169 | 3169 | __('deleted', 'event_espresso') |
3170 | 3170 | ); |
3171 | 3171 | } else { |
3172 | 3172 | EE_Error::add_error( |
3173 | - _n( 'The message was not deleted.', 'The messages were not deleted', count( $msg_ids ), 'event_espresso' ), |
|
3173 | + _n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'), |
|
3174 | 3174 | __FILE__, __FUNCTION__, __LINE__ |
3175 | 3175 | ); |
3176 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3176 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3177 | 3177 | } |
3178 | 3178 | } |
3179 | 3179 | |
@@ -3186,10 +3186,10 @@ discard block |
||
3186 | 3186 | * @return array |
3187 | 3187 | */ |
3188 | 3188 | protected function _get_msg_ids_from_request() { |
3189 | - if ( ! isset( $this->_req_data['MSG_ID'] ) ) { |
|
3189 | + if ( ! isset($this->_req_data['MSG_ID'])) { |
|
3190 | 3190 | return array(); |
3191 | 3191 | } |
3192 | - return is_array( $this->_req_data['MSG_ID'] ) ? array_keys( $this->_req_data['MSG_ID'] ) : array( $this->_req_data['MSG_ID'] ); |
|
3192 | + return is_array($this->_req_data['MSG_ID']) ? array_keys($this->_req_data['MSG_ID']) : array($this->_req_data['MSG_ID']); |
|
3193 | 3193 | } |
3194 | 3194 | |
3195 | 3195 |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param $table_name |
58 | 58 | * @return string |
59 | 59 | */ |
60 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
60 | + public static function ensure_table_name_has_prefix($table_name) { |
|
61 | 61 | global $wpdb; |
62 | - return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
62 | + return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * be called on plugin activation and reactivation |
86 | 86 | * @return boolean success, whether the database and folders are setup properly |
87 | 87 | */ |
88 | - public static function initialize_db_and_folders(){ |
|
88 | + public static function initialize_db_and_folders() { |
|
89 | 89 | $good_filesystem = EEH_Activation::create_upload_directories(); |
90 | 90 | $good_db = EEH_Activation::create_database_tables(); |
91 | 91 | return $good_filesystem && $good_db; |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * upon activation of a new plugin, reactivation, and at the end |
100 | 100 | * of running migration scripts |
101 | 101 | */ |
102 | - public static function initialize_db_content(){ |
|
102 | + public static function initialize_db_content() { |
|
103 | 103 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
104 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
104 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | EEH_Activation::remove_cron_tasks(); |
119 | 119 | EEH_Activation::create_cron_tasks(); |
120 | 120 | //also, check for CAF default db content |
121 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
121 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
122 | 122 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
123 | 123 | //which users really won't care about on initial activation |
124 | 124 | EE_Error::overwrite_success(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return array |
139 | 139 | * @throws \EE_Error |
140 | 140 | */ |
141 | - public static function get_cron_tasks( $which_to_include ) { |
|
141 | + public static function get_cron_tasks($which_to_include) { |
|
142 | 142 | $cron_tasks = apply_filters( |
143 | 143 | 'FHEE__EEH_Activation__get_cron_tasks', |
144 | 144 | array( |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
148 | 148 | ) |
149 | 149 | ); |
150 | - if( $which_to_include === 'all' ) { |
|
150 | + if ($which_to_include === 'all') { |
|
151 | 151 | //leave as-is |
152 | - }elseif( $which_to_include === 'old' ) { |
|
153 | - $cron_tasks = array_filter( $cron_tasks, function ( $value ) { |
|
152 | + }elseif ($which_to_include === 'old') { |
|
153 | + $cron_tasks = array_filter($cron_tasks, function($value) { |
|
154 | 154 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
155 | 155 | }); |
156 | - }elseif( $which_to_include === 'current' ) { |
|
157 | - $cron_tasks = array_filter( $cron_tasks ); |
|
158 | - }elseif( WP_DEBUG ) { |
|
159 | - throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) ); |
|
160 | - }else{ |
|
156 | + }elseif ($which_to_include === 'current') { |
|
157 | + $cron_tasks = array_filter($cron_tasks); |
|
158 | + }elseif (WP_DEBUG) { |
|
159 | + throw new EE_Error(sprintf(__('Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso'), $which_to_include)); |
|
160 | + } else { |
|
161 | 161 | //leave as-is |
162 | 162 | } |
163 | 163 | return $cron_tasks; |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public static function create_cron_tasks() { |
170 | 170 | |
171 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
172 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
173 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
171 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
172 | + if ( ! wp_next_scheduled($hook_name)) { |
|
173 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | * Remove the currently-existing and now-removed cron tasks. |
181 | 181 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
182 | 182 | */ |
183 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
183 | + public static function remove_cron_tasks($remove_all = true) { |
|
184 | 184 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
185 | 185 | $crons = _get_cron_array(); |
186 | - $crons = is_array( $crons ) ? $crons : array(); |
|
186 | + $crons = is_array($crons) ? $crons : array(); |
|
187 | 187 | /* reminder that $crons looks like: top-level keys are timestamps, |
188 | 188 | * and their values are arrays. |
189 | 189 | * The 2nd level arrays have keys with each of the cron task hooknames to run at that time |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | * ... |
202 | 202 | * ... |
203 | 203 | */ |
204 | - foreach( EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ) as $hook_name => $frequency ) { |
|
205 | - foreach( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
206 | - if ( array_key_exists( $hook_name, $hooks_to_fire_at_time ) ) { |
|
207 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
204 | + foreach (EEH_Activation::get_cron_tasks($cron_tasks_to_remove) as $hook_name => $frequency) { |
|
205 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
206 | + if (array_key_exists($hook_name, $hooks_to_fire_at_time)) { |
|
207 | + unset($crons[$timestamp][$hook_name]); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
211 | - _set_cron_array( $crons ); |
|
211 | + _set_cron_array($crons); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public static function CPT_initialization() { |
225 | 225 | // register Custom Post Types |
226 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
226 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
227 | 227 | flush_rewrite_rules(); |
228 | 228 | } |
229 | 229 | |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * @return void |
242 | 242 | */ |
243 | 243 | public static function reset_and_update_config() { |
244 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
245 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
244 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
245 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
246 | 246 | //EE_Config::reset(); |
247 | 247 | } |
248 | 248 | |
@@ -255,23 +255,23 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public static function load_calendar_config() { |
257 | 257 | // grab array of all plugin folders and loop thru it |
258 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
259 | - if ( empty( $plugins ) ) { |
|
258 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
259 | + if (empty($plugins)) { |
|
260 | 260 | return; |
261 | 261 | } |
262 | - foreach ( $plugins as $plugin_path ) { |
|
262 | + foreach ($plugins as $plugin_path) { |
|
263 | 263 | // grab plugin folder name from path |
264 | - $plugin = basename( $plugin_path ); |
|
264 | + $plugin = basename($plugin_path); |
|
265 | 265 | // drill down to Espresso plugins |
266 | - if ( strpos( $plugin, 'espresso' ) !== FALSE || strpos( $plugin, 'Espresso' ) !== FALSE || strpos( $plugin, 'ee4' ) !== FALSE || strpos( $plugin, 'EE4' ) !== FALSE ) { |
|
266 | + if (strpos($plugin, 'espresso') !== FALSE || strpos($plugin, 'Espresso') !== FALSE || strpos($plugin, 'ee4') !== FALSE || strpos($plugin, 'EE4') !== FALSE) { |
|
267 | 267 | // then to calendar related plugins |
268 | - if ( strpos( $plugin, 'calendar' ) !== FALSE ) { |
|
268 | + if (strpos($plugin, 'calendar') !== FALSE) { |
|
269 | 269 | // this is what we are looking for |
270 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
270 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
271 | 271 | // does it exist in this folder ? |
272 | - if ( is_readable( $calendar_config )) { |
|
272 | + if (is_readable($calendar_config)) { |
|
273 | 273 | // YEAH! let's load it |
274 | - require_once( $calendar_config ); |
|
274 | + require_once($calendar_config); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | } |
@@ -288,21 +288,21 @@ discard block |
||
288 | 288 | * @param \EE_Config $EE_Config |
289 | 289 | * @return \stdClass |
290 | 290 | */ |
291 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
292 | - $convert_from_array = array( 'addons' ); |
|
291 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
292 | + $convert_from_array = array('addons'); |
|
293 | 293 | // in case old settings were saved as an array |
294 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
294 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
295 | 295 | // convert existing settings to an object |
296 | 296 | $config_array = $settings; |
297 | 297 | $settings = new stdClass(); |
298 | - foreach ( $config_array as $key => $value ){ |
|
299 | - if ( $key == 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
300 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
298 | + foreach ($config_array as $key => $value) { |
|
299 | + if ($key == 'calendar' && class_exists('EE_Calendar_Config')) { |
|
300 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
301 | 301 | } else { |
302 | 302 | $settings->$key = $value; |
303 | 303 | } |
304 | 304 | } |
305 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
305 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
306 | 306 | } |
307 | 307 | return $settings; |
308 | 308 | } |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public static function deactivate_event_espresso() { |
320 | 320 | // check permissions |
321 | - if ( current_user_can( 'activate_plugins' )) { |
|
322 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
321 | + if (current_user_can('activate_plugins')) { |
|
322 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
@@ -341,79 +341,79 @@ discard block |
||
341 | 341 | $critical_pages = array( |
342 | 342 | array( |
343 | 343 | 'id' =>'reg_page_id', |
344 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
344 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
345 | 345 | 'post' => NULL, |
346 | 346 | 'code' => 'ESPRESSO_CHECKOUT' |
347 | 347 | ), |
348 | 348 | array( |
349 | 349 | 'id' => 'txn_page_id', |
350 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
350 | + 'name' => __('Transactions', 'event_espresso'), |
|
351 | 351 | 'post' => NULL, |
352 | 352 | 'code' => 'ESPRESSO_TXN_PAGE' |
353 | 353 | ), |
354 | 354 | array( |
355 | 355 | 'id' => 'thank_you_page_id', |
356 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
356 | + 'name' => __('Thank You', 'event_espresso'), |
|
357 | 357 | 'post' => NULL, |
358 | 358 | 'code' => 'ESPRESSO_THANK_YOU' |
359 | 359 | ), |
360 | 360 | array( |
361 | 361 | 'id' => 'cancel_page_id', |
362 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
362 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
363 | 363 | 'post' => NULL, |
364 | 364 | 'code' => 'ESPRESSO_CANCELLED' |
365 | 365 | ), |
366 | 366 | ); |
367 | 367 | |
368 | - foreach ( $critical_pages as $critical_page ) { |
|
368 | + foreach ($critical_pages as $critical_page) { |
|
369 | 369 | // is critical page ID set in config ? |
370 | - if ( EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE ) { |
|
370 | + if (EE_Registry::instance()->CFG->core->$critical_page['id'] !== FALSE) { |
|
371 | 371 | // attempt to find post by ID |
372 | - $critical_page['post'] = get_post( EE_Registry::instance()->CFG->core->$critical_page['id'] ); |
|
372 | + $critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->$critical_page['id']); |
|
373 | 373 | } |
374 | 374 | // no dice? |
375 | - if ( $critical_page['post'] == NULL ) { |
|
375 | + if ($critical_page['post'] == NULL) { |
|
376 | 376 | // attempt to find post by title |
377 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
377 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
378 | 378 | // still nothing? |
379 | - if ( $critical_page['post'] == NULL ) { |
|
380 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
379 | + if ($critical_page['post'] == NULL) { |
|
380 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
381 | 381 | // REALLY? Still nothing ??!?!? |
382 | - if ( $critical_page['post'] == NULL ) { |
|
383 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
384 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
382 | + if ($critical_page['post'] == NULL) { |
|
383 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
384 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
385 | 385 | break; |
386 | 386 | } |
387 | 387 | } |
388 | 388 | } |
389 | 389 | // track post_shortcodes |
390 | - if ( $critical_page['post'] ) { |
|
391 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
390 | + if ($critical_page['post']) { |
|
391 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
392 | 392 | } |
393 | 393 | // check that Post ID matches critical page ID in config |
394 | - if ( isset( $critical_page['post']->ID ) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id'] ) { |
|
394 | + if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->$critical_page['id']) { |
|
395 | 395 | //update Config with post ID |
396 | 396 | EE_Registry::instance()->CFG->core->$critical_page['id'] = $critical_page['post']->ID; |
397 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
398 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
399 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
397 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
398 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
399 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
403 | - $critical_page_problem = ! isset( $critical_page['post']->post_status ) || $critical_page['post']->post_status != 'publish' || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE ? TRUE : $critical_page_problem; |
|
403 | + $critical_page_problem = ! isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem; |
|
404 | 404 | |
405 | 405 | } |
406 | 406 | |
407 | - if ( $critical_page_problem ) { |
|
407 | + if ($critical_page_problem) { |
|
408 | 408 | $msg = sprintf( |
409 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
410 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
409 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
410 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
411 | 411 | ); |
412 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
412 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
413 | 413 | } |
414 | 414 | |
415 | - if ( EE_Error::has_notices() ) { |
|
416 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
415 | + if (EE_Error::has_notices()) { |
|
416 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | } |
@@ -426,13 +426,13 @@ discard block |
||
426 | 426 | * parameter to the shortcode |
427 | 427 | * @return WP_Post or NULl |
428 | 428 | */ |
429 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
429 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
430 | 430 | global $wpdb; |
431 | 431 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
432 | 432 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
433 | - if($post_id){ |
|
433 | + if ($post_id) { |
|
434 | 434 | return get_post($post_id); |
435 | - }else{ |
|
435 | + } else { |
|
436 | 436 | return NULL; |
437 | 437 | } |
438 | 438 | |
@@ -449,32 +449,32 @@ discard block |
||
449 | 449 | * @param array $critical_page |
450 | 450 | * @return array |
451 | 451 | */ |
452 | - public static function create_critical_page( $critical_page ) { |
|
452 | + public static function create_critical_page($critical_page) { |
|
453 | 453 | |
454 | 454 | $post_args = array( |
455 | 455 | 'post_title' => $critical_page['name'], |
456 | 456 | 'post_status' => 'publish', |
457 | 457 | 'post_type' => 'page', |
458 | 458 | 'comment_status' => 'closed', |
459 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
459 | + 'post_content' => '['.$critical_page['code'].']' |
|
460 | 460 | ); |
461 | 461 | |
462 | - $post_id = wp_insert_post( $post_args ); |
|
463 | - if ( ! $post_id ) { |
|
462 | + $post_id = wp_insert_post($post_args); |
|
463 | + if ( ! $post_id) { |
|
464 | 464 | $msg = sprintf( |
465 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
465 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
466 | 466 | $critical_page['name'] |
467 | 467 | ); |
468 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
468 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
469 | 469 | return $critical_page; |
470 | 470 | } |
471 | 471 | // get newly created post's details |
472 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
472 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
473 | 473 | $msg = sprintf( |
474 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
474 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
475 | 475 | $critical_page['name'] |
476 | 476 | ); |
477 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
477 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | return $critical_page; |
@@ -493,34 +493,34 @@ discard block |
||
493 | 493 | * @param array $critical_page |
494 | 494 | * @return void |
495 | 495 | */ |
496 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
496 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
497 | 497 | // check the goods |
498 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
498 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
499 | 499 | $msg = sprintf( |
500 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
500 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
501 | 501 | $critical_page['name'] |
502 | 502 | ); |
503 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
503 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
504 | 504 | return; |
505 | 505 | } |
506 | 506 | // map shortcode to post |
507 | - EE_Registry::instance()->CFG->core->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
507 | + EE_Registry::instance()->CFG->core->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
508 | 508 | // and make sure it's NOT added to the WP "Posts Page" |
509 | 509 | // name of the WP Posts Page |
510 | 510 | $posts_page = EE_Registry::instance()->CFG->get_page_for_posts(); |
511 | - if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ] )) { |
|
512 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
511 | + if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page])) { |
|
512 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes[$posts_page][$critical_page['code']]); |
|
513 | 513 | } |
514 | - if ( $posts_page != 'posts' && isset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'] )) { |
|
515 | - unset( EE_Registry::instance()->CFG->core->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
514 | + if ($posts_page != 'posts' && isset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'])) { |
|
515 | + unset(EE_Registry::instance()->CFG->core->post_shortcodes['posts'][$critical_page['code']]); |
|
516 | 516 | } |
517 | 517 | // update post_shortcode CFG |
518 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
518 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
519 | 519 | $msg = sprintf( |
520 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
520 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
521 | 521 | $critical_page['name'] |
522 | 522 | ); |
523 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
523 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
@@ -538,24 +538,24 @@ discard block |
||
538 | 538 | public static function get_default_creator_id() { |
539 | 539 | global $wpdb; |
540 | 540 | |
541 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
541 | + if ( ! empty(self::$_default_creator_id)) { |
|
542 | 542 | return self::$_default_creator_id; |
543 | 543 | }/**/ |
544 | 544 | |
545 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
545 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
546 | 546 | |
547 | 547 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
548 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
549 | - if ( $pre_filtered_id !== false ) { |
|
548 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
549 | + if ($pre_filtered_id !== false) { |
|
550 | 550 | return (int) $pre_filtered_id; |
551 | 551 | } |
552 | 552 | |
553 | - $capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' ); |
|
554 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
555 | - $user_id = $wpdb->get_var( $query ); |
|
556 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
557 | - if ( $user_id && intval( $user_id ) ) { |
|
558 | - self::$_default_creator_id = intval( $user_id ); |
|
553 | + $capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities'); |
|
554 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
555 | + $user_id = $wpdb->get_var($query); |
|
556 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
557 | + if ($user_id && intval($user_id)) { |
|
558 | + self::$_default_creator_id = intval($user_id); |
|
559 | 559 | return self::$_default_creator_id; |
560 | 560 | } else { |
561 | 561 | return NULL; |
@@ -582,29 +582,29 @@ discard block |
||
582 | 582 | * @return void |
583 | 583 | * @throws EE_Error if there are database errors |
584 | 584 | */ |
585 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
586 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
585 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
586 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
587 | 587 | return; |
588 | 588 | } |
589 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
590 | - if ( ! function_exists( 'dbDelta' )) { |
|
591 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
589 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
590 | + if ( ! function_exists('dbDelta')) { |
|
591 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
592 | 592 | } |
593 | 593 | /** @var WPDB $wpdb */ |
594 | 594 | global $wpdb; |
595 | - $wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
595 | + $wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
596 | 596 | // do we need to first delete an existing version of this table ? |
597 | - if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){ |
|
597 | + if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) { |
|
598 | 598 | // ok, delete the table... but ONLY if it's empty |
599 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
599 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
600 | 600 | // table is NOT empty, are you SURE you want to delete this table ??? |
601 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
602 | - EEH_Activation::delete_unused_db_table( $wp_table_name ); |
|
603 | - } else if ( ! $deleted_safely ) { |
|
601 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
602 | + EEH_Activation::delete_unused_db_table($wp_table_name); |
|
603 | + } else if ( ! $deleted_safely) { |
|
604 | 604 | // so we should be more cautious rather than just dropping tables so easily |
605 | 605 | EE_Error::add_persistent_admin_notice( |
606 | - 'bad_table_' . $wp_table_name . '_detected', |
|
607 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
606 | + 'bad_table_'.$wp_table_name.'_detected', |
|
607 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
608 | 608 | $wp_table_name, |
609 | 609 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
610 | 610 | '<b>wp-config.php</b>', |
@@ -613,25 +613,25 @@ discard block |
||
613 | 613 | } |
614 | 614 | } |
615 | 615 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
616 | - if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) { |
|
616 | + if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) { |
|
617 | 617 | $SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
618 | 618 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
619 | 619 | //happened. And then we can choose to tell the end user |
620 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
621 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
620 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
621 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
622 | 622 | ob_start(); |
623 | - dbDelta( $SQL ); |
|
623 | + dbDelta($SQL); |
|
624 | 624 | $output = ob_get_contents(); |
625 | 625 | ob_end_clean(); |
626 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
627 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
628 | - if( ! empty( $output ) ){ |
|
629 | - throw new EE_Error( $output ); |
|
626 | + $wpdb->show_errors($old_show_errors_policy); |
|
627 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
628 | + if ( ! empty($output)) { |
|
629 | + throw new EE_Error($output); |
|
630 | 630 | } |
631 | 631 | } else { |
632 | 632 | throw new EE_Error( |
633 | 633 | sprintf( |
634 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
634 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
635 | 635 | '<br />', |
636 | 636 | $sql |
637 | 637 | ) |
@@ -654,15 +654,15 @@ discard block |
||
654 | 654 | * 'VARCHAR(10)' |
655 | 655 | * @return bool|int |
656 | 656 | */ |
657 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
658 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
657 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
658 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
659 | 659 | return FALSE; |
660 | 660 | } |
661 | 661 | global $wpdb; |
662 | - $full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
662 | + $full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
663 | 663 | $fields = self::get_fields_on_table($table_name); |
664 | - if (!in_array($column_name, $fields)){ |
|
665 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
664 | + if ( ! in_array($column_name, $fields)) { |
|
665 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
666 | 666 | //echo "alter query:$alter_query"; |
667 | 667 | return $wpdb->query($alter_query); |
668 | 668 | } |
@@ -681,15 +681,15 @@ discard block |
||
681 | 681 | * @param string $table_name, without prefixed $wpdb->prefix |
682 | 682 | * @return array of database column names |
683 | 683 | */ |
684 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
684 | + public static function get_fields_on_table($table_name = NULL) { |
|
685 | 685 | global $wpdb; |
686 | - $table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
687 | - if ( ! empty( $table_name )) { |
|
686 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
687 | + if ( ! empty($table_name)) { |
|
688 | 688 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
689 | 689 | if ($columns !== FALSE) { |
690 | 690 | $field_array = array(); |
691 | - foreach($columns as $column ){ |
|
692 | - $field_array[] = $column->Field;; |
|
691 | + foreach ($columns as $column) { |
|
692 | + $field_array[] = $column->Field; ; |
|
693 | 693 | } |
694 | 694 | return $field_array; |
695 | 695 | } |
@@ -707,12 +707,12 @@ discard block |
||
707 | 707 | * @param string $table_name |
708 | 708 | * @return bool |
709 | 709 | */ |
710 | - public static function db_table_is_empty( $table_name ) { |
|
710 | + public static function db_table_is_empty($table_name) { |
|
711 | 711 | global $wpdb; |
712 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
713 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
714 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
715 | - return absint( $count ) === 0 ? true : false; |
|
712 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
713 | + if (EEH_Activation::table_exists($table_name)) { |
|
714 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
715 | + return absint($count) === 0 ? true : false; |
|
716 | 716 | } |
717 | 717 | return false; |
718 | 718 | } |
@@ -727,9 +727,9 @@ discard block |
||
727 | 727 | * @param string $table_name |
728 | 728 | * @return bool | int |
729 | 729 | */ |
730 | - public static function delete_db_table_if_empty( $table_name ) { |
|
731 | - if ( EEH_Activation::db_table_is_empty( $table_name ) ) { |
|
732 | - return EEH_Activation::delete_unused_db_table( $table_name ); |
|
730 | + public static function delete_db_table_if_empty($table_name) { |
|
731 | + if (EEH_Activation::db_table_is_empty($table_name)) { |
|
732 | + return EEH_Activation::delete_unused_db_table($table_name); |
|
733 | 733 | } |
734 | 734 | return false; |
735 | 735 | } |
@@ -744,11 +744,11 @@ discard block |
||
744 | 744 | * @param string $table_name |
745 | 745 | * @return bool | int |
746 | 746 | */ |
747 | - public static function delete_unused_db_table( $table_name ) { |
|
747 | + public static function delete_unused_db_table($table_name) { |
|
748 | 748 | global $wpdb; |
749 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
750 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
751 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
749 | + if (EEH_Activation::table_exists($table_name)) { |
|
750 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
751 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
752 | 752 | } |
753 | 753 | return false; |
754 | 754 | } |
@@ -764,18 +764,18 @@ discard block |
||
764 | 764 | * @param string $index_name |
765 | 765 | * @return bool | int |
766 | 766 | */ |
767 | - public static function drop_index( $table_name, $index_name ) { |
|
768 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
767 | + public static function drop_index($table_name, $index_name) { |
|
768 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
769 | 769 | return FALSE; |
770 | 770 | } |
771 | 771 | global $wpdb; |
772 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
772 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
773 | 773 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'"; |
774 | 774 | if ( |
775 | - $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name |
|
776 | - && $wpdb->get_var( $index_exists_query ) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
775 | + $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name |
|
776 | + && $wpdb->get_var($index_exists_query) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
777 | 777 | ) { |
778 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" ); |
|
778 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name"); |
|
779 | 779 | } |
780 | 780 | return TRUE; |
781 | 781 | } |
@@ -791,27 +791,27 @@ discard block |
||
791 | 791 | * @return boolean success (whether database is setup properly or not) |
792 | 792 | */ |
793 | 793 | public static function create_database_tables() { |
794 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
794 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
795 | 795 | //find the migration script that sets the database to be compatible with the code |
796 | 796 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
797 | - if( $dms_name ){ |
|
798 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
799 | - $current_data_migration_script->set_migrating( false ); |
|
797 | + if ($dms_name) { |
|
798 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
799 | + $current_data_migration_script->set_migrating(false); |
|
800 | 800 | $current_data_migration_script->schema_changes_before_migration(); |
801 | 801 | $current_data_migration_script->schema_changes_after_migration(); |
802 | - if( $current_data_migration_script->get_errors() ){ |
|
803 | - if( WP_DEBUG ){ |
|
804 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
805 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
802 | + if ($current_data_migration_script->get_errors()) { |
|
803 | + if (WP_DEBUG) { |
|
804 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
805 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
806 | 806 | } |
807 | - }else{ |
|
808 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
807 | + } else { |
|
808 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
809 | 809 | } |
810 | 810 | return false; |
811 | 811 | } |
812 | 812 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
813 | - }else{ |
|
814 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
813 | + } else { |
|
814 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
815 | 815 | return false; |
816 | 816 | } |
817 | 817 | return true; |
@@ -831,27 +831,27 @@ discard block |
||
831 | 831 | public static function initialize_system_questions() { |
832 | 832 | // QUESTION GROUPS |
833 | 833 | global $wpdb; |
834 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' ); |
|
834 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group'); |
|
835 | 835 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
836 | 836 | // what we have |
837 | - $question_groups = $wpdb->get_col( $SQL ); |
|
837 | + $question_groups = $wpdb->get_col($SQL); |
|
838 | 838 | // check the response |
839 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
839 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
840 | 840 | // what we should have |
841 | - $QSG_systems = array( 1, 2 ); |
|
841 | + $QSG_systems = array(1, 2); |
|
842 | 842 | // loop thru what we should have and compare to what we have |
843 | - foreach ( $QSG_systems as $QSG_system ) { |
|
843 | + foreach ($QSG_systems as $QSG_system) { |
|
844 | 844 | // reset values array |
845 | 845 | $QSG_values = array(); |
846 | 846 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
847 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
847 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
848 | 848 | // add it |
849 | - switch ( $QSG_system ) { |
|
849 | + switch ($QSG_system) { |
|
850 | 850 | |
851 | 851 | case 1: |
852 | 852 | $QSG_values = array( |
853 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
854 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
853 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
854 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
855 | 855 | 'QSG_desc' => '', |
856 | 856 | 'QSG_order' => 1, |
857 | 857 | 'QSG_show_group_name' => 1, |
@@ -863,8 +863,8 @@ discard block |
||
863 | 863 | |
864 | 864 | case 2: |
865 | 865 | $QSG_values = array( |
866 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
867 | - 'QSG_identifier' => 'address-information-' . time(), |
|
866 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
867 | + 'QSG_identifier' => 'address-information-'.time(), |
|
868 | 868 | 'QSG_desc' => '', |
869 | 869 | 'QSG_order' => 2, |
870 | 870 | 'QSG_show_group_name' => 1, |
@@ -876,14 +876,14 @@ discard block |
||
876 | 876 | |
877 | 877 | } |
878 | 878 | // make sure we have some values before inserting them |
879 | - if ( ! empty( $QSG_values )) { |
|
879 | + if ( ! empty($QSG_values)) { |
|
880 | 880 | // insert system question |
881 | 881 | $wpdb->insert( |
882 | 882 | $table_name, |
883 | 883 | $QSG_values, |
884 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
884 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
885 | 885 | ); |
886 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
886 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
887 | 887 | } |
888 | 888 | } |
889 | 889 | } |
@@ -892,10 +892,10 @@ discard block |
||
892 | 892 | |
893 | 893 | // QUESTIONS |
894 | 894 | global $wpdb; |
895 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' ); |
|
895 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question'); |
|
896 | 896 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
897 | 897 | // what we have |
898 | - $questions = $wpdb->get_col( $SQL ); |
|
898 | + $questions = $wpdb->get_col($SQL); |
|
899 | 899 | // what we should have |
900 | 900 | $QST_systems = array( |
901 | 901 | 'fname', |
@@ -912,25 +912,25 @@ discard block |
||
912 | 912 | $order_for_group_1 = 1; |
913 | 913 | $order_for_group_2 = 1; |
914 | 914 | // loop thru what we should have and compare to what we have |
915 | - foreach ( $QST_systems as $QST_system ) { |
|
915 | + foreach ($QST_systems as $QST_system) { |
|
916 | 916 | // reset values array |
917 | 917 | $QST_values = array(); |
918 | 918 | // if we don't have what we should have |
919 | - if ( ! in_array( $QST_system, $questions )) { |
|
919 | + if ( ! in_array($QST_system, $questions)) { |
|
920 | 920 | // add it |
921 | - switch ( $QST_system ) { |
|
921 | + switch ($QST_system) { |
|
922 | 922 | |
923 | 923 | case 'fname': |
924 | 924 | $QST_values = array( |
925 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
926 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
925 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
926 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
927 | 927 | 'QST_system' => 'fname', |
928 | 928 | 'QST_type' => 'TEXT', |
929 | 929 | 'QST_required' => 1, |
930 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
930 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
931 | 931 | 'QST_order' => 1, |
932 | 932 | 'QST_admin_only' => 0, |
933 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
933 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
934 | 934 | 'QST_wp_user' => self::get_default_creator_id(), |
935 | 935 | 'QST_deleted' => 0 |
936 | 936 | ); |
@@ -938,15 +938,15 @@ discard block |
||
938 | 938 | |
939 | 939 | case 'lname': |
940 | 940 | $QST_values = array( |
941 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
942 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
941 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
942 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
943 | 943 | 'QST_system' => 'lname', |
944 | 944 | 'QST_type' => 'TEXT', |
945 | 945 | 'QST_required' => 1, |
946 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
946 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
947 | 947 | 'QST_order' => 2, |
948 | 948 | 'QST_admin_only' => 0, |
949 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
949 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
950 | 950 | 'QST_wp_user' => self::get_default_creator_id(), |
951 | 951 | 'QST_deleted' => 0 |
952 | 952 | ); |
@@ -954,15 +954,15 @@ discard block |
||
954 | 954 | |
955 | 955 | case 'email': |
956 | 956 | $QST_values = array( |
957 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
958 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
957 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
958 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
959 | 959 | 'QST_system' => 'email', |
960 | 960 | 'QST_type' => 'TEXT', |
961 | 961 | 'QST_required' => 1, |
962 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
962 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
963 | 963 | 'QST_order' => 3, |
964 | 964 | 'QST_admin_only' => 0, |
965 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
965 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
966 | 966 | 'QST_wp_user' => self::get_default_creator_id(), |
967 | 967 | 'QST_deleted' => 0 |
968 | 968 | ); |
@@ -970,15 +970,15 @@ discard block |
||
970 | 970 | |
971 | 971 | case 'address': |
972 | 972 | $QST_values = array( |
973 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
974 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
973 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
974 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
975 | 975 | 'QST_system' => 'address', |
976 | 976 | 'QST_type' => 'TEXT', |
977 | 977 | 'QST_required' => 0, |
978 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
978 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
979 | 979 | 'QST_order' => 4, |
980 | 980 | 'QST_admin_only' => 0, |
981 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
981 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
982 | 982 | 'QST_wp_user' => self::get_default_creator_id(), |
983 | 983 | 'QST_deleted' => 0 |
984 | 984 | ); |
@@ -986,15 +986,15 @@ discard block |
||
986 | 986 | |
987 | 987 | case 'address2': |
988 | 988 | $QST_values = array( |
989 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
990 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
989 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
990 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
991 | 991 | 'QST_system' => 'address2', |
992 | 992 | 'QST_type' => 'TEXT', |
993 | 993 | 'QST_required' => 0, |
994 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
994 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
995 | 995 | 'QST_order' => 5, |
996 | 996 | 'QST_admin_only' => 0, |
997 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
997 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
998 | 998 | 'QST_wp_user' => self::get_default_creator_id(), |
999 | 999 | 'QST_deleted' => 0 |
1000 | 1000 | ); |
@@ -1002,15 +1002,15 @@ discard block |
||
1002 | 1002 | |
1003 | 1003 | case 'city': |
1004 | 1004 | $QST_values = array( |
1005 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
1006 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
1005 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1006 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1007 | 1007 | 'QST_system' => 'city', |
1008 | 1008 | 'QST_type' => 'TEXT', |
1009 | 1009 | 'QST_required' => 0, |
1010 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1010 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1011 | 1011 | 'QST_order' => 6, |
1012 | 1012 | 'QST_admin_only' => 0, |
1013 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1013 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1014 | 1014 | 'QST_wp_user' => self::get_default_creator_id(), |
1015 | 1015 | 'QST_deleted' => 0 |
1016 | 1016 | ); |
@@ -1018,12 +1018,12 @@ discard block |
||
1018 | 1018 | |
1019 | 1019 | case 'state': |
1020 | 1020 | $QST_values = array( |
1021 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1022 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1021 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1022 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1023 | 1023 | 'QST_system' => 'state', |
1024 | 1024 | 'QST_type' => 'STATE', |
1025 | 1025 | 'QST_required' => 0, |
1026 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1026 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1027 | 1027 | 'QST_order' => 7, |
1028 | 1028 | 'QST_admin_only' => 0, |
1029 | 1029 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1033,12 +1033,12 @@ discard block |
||
1033 | 1033 | |
1034 | 1034 | case 'country' : |
1035 | 1035 | $QST_values = array( |
1036 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1037 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1036 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1037 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1038 | 1038 | 'QST_system' => 'country', |
1039 | 1039 | 'QST_type' => 'COUNTRY', |
1040 | 1040 | 'QST_required' => 0, |
1041 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1041 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1042 | 1042 | 'QST_order' => 8, |
1043 | 1043 | 'QST_admin_only' => 0, |
1044 | 1044 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1048,15 +1048,15 @@ discard block |
||
1048 | 1048 | |
1049 | 1049 | case 'zip': |
1050 | 1050 | $QST_values = array( |
1051 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1052 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1051 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1052 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1053 | 1053 | 'QST_system' => 'zip', |
1054 | 1054 | 'QST_type' => 'TEXT', |
1055 | 1055 | 'QST_required' => 0, |
1056 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1056 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1057 | 1057 | 'QST_order' => 9, |
1058 | 1058 | 'QST_admin_only' => 0, |
1059 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1059 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1060 | 1060 | 'QST_wp_user' => self::get_default_creator_id(), |
1061 | 1061 | 'QST_deleted' => 0 |
1062 | 1062 | ); |
@@ -1064,49 +1064,49 @@ discard block |
||
1064 | 1064 | |
1065 | 1065 | case 'phone': |
1066 | 1066 | $QST_values = array( |
1067 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1068 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1067 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1068 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1069 | 1069 | 'QST_system' => 'phone', |
1070 | 1070 | 'QST_type' => 'TEXT', |
1071 | 1071 | 'QST_required' => 0, |
1072 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1072 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1073 | 1073 | 'QST_order' => 10, |
1074 | 1074 | 'QST_admin_only' => 0, |
1075 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1075 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1076 | 1076 | 'QST_wp_user' => self::get_default_creator_id(), |
1077 | 1077 | 'QST_deleted' => 0 |
1078 | 1078 | ); |
1079 | 1079 | break; |
1080 | 1080 | |
1081 | 1081 | } |
1082 | - if ( ! empty( $QST_values )) { |
|
1082 | + if ( ! empty($QST_values)) { |
|
1083 | 1083 | // insert system question |
1084 | 1084 | $wpdb->insert( |
1085 | 1085 | $table_name, |
1086 | 1086 | $QST_values, |
1087 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1087 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1088 | 1088 | ); |
1089 | 1089 | $QST_ID = $wpdb->insert_id; |
1090 | 1090 | |
1091 | 1091 | // QUESTION GROUP QUESTIONS |
1092 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
1092 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1093 | 1093 | $system_question_we_want = EEM_Question_Group::system_personal; |
1094 | 1094 | } else { |
1095 | 1095 | $system_question_we_want = EEM_Question_Group::system_address; |
1096 | 1096 | } |
1097 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
1098 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
1097 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1098 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1099 | 1099 | } else { |
1100 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
1101 | - if( is_array( $id_col ) ) { |
|
1102 | - $QSG_ID = reset( $id_col ); |
|
1100 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1101 | + if (is_array($id_col)) { |
|
1102 | + $QSG_ID = reset($id_col); |
|
1103 | 1103 | } else { |
1104 | 1104 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1105 | 1105 | EE_Log::instance()->log( |
1106 | 1106 | __FILE__, |
1107 | 1107 | __FUNCTION__, |
1108 | 1108 | sprintf( |
1109 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1109 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1110 | 1110 | $QST_ID ), |
1111 | 1111 | 'error' ); |
1112 | 1112 | continue; |
@@ -1115,9 +1115,9 @@ discard block |
||
1115 | 1115 | |
1116 | 1116 | // add system questions to groups |
1117 | 1117 | $wpdb->insert( |
1118 | - EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ), |
|
1119 | - array( 'QSG_ID' => $QSG_ID , 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID==1)? $order_for_group_1++ : $order_for_group_2++ ), |
|
1120 | - array( '%d', '%d','%d' ) |
|
1118 | + EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'), |
|
1119 | + array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID == 1) ? $order_for_group_1++ : $order_for_group_2++), |
|
1120 | + array('%d', '%d', '%d') |
|
1121 | 1121 | ); |
1122 | 1122 | } |
1123 | 1123 | } |
@@ -1129,11 +1129,11 @@ discard block |
||
1129 | 1129 | * Makes sure the default payment method (Invoice) is active. |
1130 | 1130 | * This used to be done automatically as part of constructing the old gateways config |
1131 | 1131 | */ |
1132 | - public static function insert_default_payment_methods(){ |
|
1133 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1134 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1135 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1136 | - }else{ |
|
1132 | + public static function insert_default_payment_methods() { |
|
1133 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1134 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1135 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1136 | + } else { |
|
1137 | 1137 | EEM_Payment_Method::instance()->verify_button_urls(); |
1138 | 1138 | } |
1139 | 1139 | } |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | |
1150 | 1150 | global $wpdb; |
1151 | 1151 | |
1152 | - if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) { |
|
1152 | + if (EEH_Activation::table_exists(EEM_Status::instance()->table())) { |
|
1153 | 1153 | |
1154 | 1154 | $table_name = EEM_Status::instance()->table(); |
1155 | 1155 | |
@@ -1220,38 +1220,38 @@ discard block |
||
1220 | 1220 | * @return boolean success of verifying upload directories exist |
1221 | 1221 | */ |
1222 | 1222 | public static function create_upload_directories() { |
1223 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1223 | + EE_Registry::instance()->load_helper('File'); |
|
1224 | 1224 | // Create the required folders |
1225 | 1225 | $folders = array( |
1226 | 1226 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1227 | 1227 | EVENT_ESPRESSO_GATEWAY_DIR, |
1228 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1229 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1230 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1228 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1229 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1230 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1231 | 1231 | ); |
1232 | - foreach ( $folders as $folder ) { |
|
1232 | + foreach ($folders as $folder) { |
|
1233 | 1233 | try { |
1234 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1235 | - @ chmod( $folder, 0755 ); |
|
1236 | - } catch( EE_Error $e ){ |
|
1234 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1235 | + @ chmod($folder, 0755); |
|
1236 | + } catch (EE_Error $e) { |
|
1237 | 1237 | EE_Error::add_error( |
1238 | 1238 | sprintf( |
1239 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1239 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1240 | 1240 | $folder, |
1241 | - '<br />' . $e->getMessage() |
|
1241 | + '<br />'.$e->getMessage() |
|
1242 | 1242 | ), |
1243 | 1243 | __FILE__, __FUNCTION__, __LINE__ |
1244 | 1244 | ); |
1245 | 1245 | //indicate we'll need to fix this later |
1246 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1246 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1247 | 1247 | return FALSE; |
1248 | 1248 | } |
1249 | 1249 | } |
1250 | 1250 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1251 | 1251 | //is disabled, there might be activation errors recorded in there |
1252 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
1252 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1253 | 1253 | //remember EE's folders are all good |
1254 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1254 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1255 | 1255 | return TRUE; |
1256 | 1256 | } |
1257 | 1257 | |
@@ -1264,7 +1264,7 @@ discard block |
||
1264 | 1264 | * @return boolean |
1265 | 1265 | */ |
1266 | 1266 | public static function upload_directories_incomplete() { |
1267 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1267 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | |
@@ -1280,9 +1280,9 @@ discard block |
||
1280 | 1280 | * to use either EE_Error or a try catch for an EE_Error exception. |
1281 | 1281 | */ |
1282 | 1282 | public static function generate_default_message_templates() { |
1283 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1283 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1284 | 1284 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1285 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1285 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1286 | 1286 | /* |
1287 | 1287 | * This first method is taking care of ensuring any default messengers |
1288 | 1288 | * that should be made active and have templates generated are done. |
@@ -1318,28 +1318,28 @@ discard block |
||
1318 | 1318 | $active_messengers = $message_resource_manager->active_messengers(); |
1319 | 1319 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1320 | 1320 | $templates_created = false; |
1321 | - foreach ( $active_messengers as $active_messenger ) { |
|
1321 | + foreach ($active_messengers as $active_messenger) { |
|
1322 | 1322 | $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
1323 | 1323 | $default_message_type_names_to_activate = array(); |
1324 | 1324 | // looping through each default message type reported by the messenger |
1325 | 1325 | // and setup the actual message types to activate. |
1326 | - foreach ( $default_message_type_names_for_messenger as $default_message_type_name_for_messenger ) { |
|
1326 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1327 | 1327 | // if already active or has already been activated before we skip |
1328 | 1328 | // (otherwise we might reactivate something user's intentionally deactivated.) |
1329 | 1329 | // we also skip if the message type is not installed. |
1330 | 1330 | if ( |
1331 | 1331 | ( |
1332 | - isset( $has_activated[ $active_messenger->name ] ) |
|
1332 | + isset($has_activated[$active_messenger->name]) |
|
1333 | 1333 | && in_array( |
1334 | 1334 | $default_message_type_name_for_messenger, |
1335 | - $has_activated[ $active_messenger->name ] |
|
1335 | + $has_activated[$active_messenger->name] |
|
1336 | 1336 | ) |
1337 | 1337 | ) |
1338 | 1338 | || $message_resource_manager->is_message_type_active_for_messenger( |
1339 | 1339 | $active_messenger->name, |
1340 | 1340 | $default_message_type_name_for_messenger |
1341 | 1341 | ) |
1342 | - || ! isset( $installed_message_types[ $default_message_type_name_for_messenger ] ) |
|
1342 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1343 | 1343 | ) { |
1344 | 1344 | continue; |
1345 | 1345 | } |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | false |
1353 | 1353 | ); |
1354 | 1354 | //activate the templates for these message types |
1355 | - if ( ! empty( $default_message_type_names_to_activate ) ) { |
|
1355 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
1356 | 1356 | $templates_created = EEH_MSG_Template::generate_new_templates( |
1357 | 1357 | $active_messenger->name, |
1358 | 1358 | $default_message_type_names_for_messenger, |
@@ -1379,15 +1379,15 @@ discard block |
||
1379 | 1379 | EE_message_Resource_Manager $message_resource_manager |
1380 | 1380 | ) { |
1381 | 1381 | /** @type EE_Messenger[] $messengers_to_generate */ |
1382 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation( $message_resource_manager ); |
|
1382 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1383 | 1383 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1384 | 1384 | $templates_generated = false; |
1385 | - foreach ( $messengers_to_generate as $messenger_to_generate ) { |
|
1385 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1386 | 1386 | $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
1387 | 1387 | //verify the default message types match an installed message type. |
1388 | - foreach ( $default_message_type_names_for_messenger as $key => $name ) { |
|
1389 | - if ( ! isset( $installed_message_types[ $name ] ) ) { |
|
1390 | - unset( $default_message_type_names_for_messenger[ $key ] ); |
|
1388 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1389 | + if ( ! isset($installed_message_types[$name])) { |
|
1390 | + unset($default_message_type_names_for_messenger[$key]); |
|
1391 | 1391 | } |
1392 | 1392 | } |
1393 | 1393 | // in previous iterations, the active_messengers option in the db |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | false |
1402 | 1402 | ); |
1403 | 1403 | //create any templates needing created (or will reactivate templates already generated as necessary). |
1404 | - if ( ! empty( $default_message_type_names_for_messenger ) ) { |
|
1404 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
1405 | 1405 | $templates_generated = EEH_MSG_Template::generate_new_templates( |
1406 | 1406 | $messenger_to_generate->name, |
1407 | 1407 | $default_message_type_names_for_messenger, |
@@ -1432,18 +1432,18 @@ discard block |
||
1432 | 1432 | $installed_messengers = $message_resource_manager->installed_messengers(); |
1433 | 1433 | $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
1434 | 1434 | $messengers_to_generate = array(); |
1435 | - foreach ( $installed_messengers as $installed_messenger ) { |
|
1435 | + foreach ($installed_messengers as $installed_messenger) { |
|
1436 | 1436 | //if installed messenger is a messenger that should be activated on install |
1437 | 1437 | //and is not already active |
1438 | 1438 | //and has never been activated |
1439 | 1439 | if ( |
1440 | 1440 | ! $installed_messenger->activate_on_install |
1441 | - || isset( $active_messengers[ $installed_messenger->name ] ) |
|
1442 | - || isset( $has_activated[ $installed_messenger->name ] ) |
|
1441 | + || isset($active_messengers[$installed_messenger->name]) |
|
1442 | + || isset($has_activated[$installed_messenger->name]) |
|
1443 | 1443 | ) { |
1444 | 1444 | continue; |
1445 | 1445 | } |
1446 | - $messengers_to_generate[ $installed_messenger->name ] = $installed_messenger; |
|
1446 | + $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1447 | 1447 | } |
1448 | 1448 | return $messengers_to_generate; |
1449 | 1449 | } |
@@ -1467,11 +1467,11 @@ discard block |
||
1467 | 1467 | * @return void |
1468 | 1468 | */ |
1469 | 1469 | public static function validate_messages_system() { |
1470 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1470 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1471 | 1471 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1472 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1472 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1473 | 1473 | $message_resource_manager->validate_active_message_types_are_installed(); |
1474 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1474 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1475 | 1475 | return; |
1476 | 1476 | } |
1477 | 1477 | |
@@ -1485,12 +1485,12 @@ discard block |
||
1485 | 1485 | * @static |
1486 | 1486 | * @return void |
1487 | 1487 | */ |
1488 | - public static function create_no_ticket_prices_array(){ |
|
1488 | + public static function create_no_ticket_prices_array() { |
|
1489 | 1489 | // this creates an array for tracking events that have no active ticket prices created |
1490 | 1490 | // this allows us to warn admins of the situation so that it can be corrected |
1491 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1492 | - if ( ! $espresso_no_ticket_prices ) { |
|
1493 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1491 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1492 | + if ( ! $espresso_no_ticket_prices) { |
|
1493 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1494 | 1494 | } |
1495 | 1495 | } |
1496 | 1496 | |
@@ -1513,24 +1513,24 @@ discard block |
||
1513 | 1513 | * relations)/ |
1514 | 1514 | * @global wpdb $wpdb |
1515 | 1515 | */ |
1516 | - public static function delete_all_espresso_cpt_data(){ |
|
1516 | + public static function delete_all_espresso_cpt_data() { |
|
1517 | 1517 | global $wpdb; |
1518 | 1518 | //get all the CPT post_types |
1519 | 1519 | $ee_post_types = array(); |
1520 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1521 | - if ( method_exists( $model_name, 'instance' )) { |
|
1522 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1523 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1524 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1520 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1521 | + if (method_exists($model_name, 'instance')) { |
|
1522 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1523 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1524 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1525 | 1525 | } |
1526 | 1526 | } |
1527 | 1527 | } |
1528 | 1528 | //get all our CPTs |
1529 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1529 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1530 | 1530 | $cpt_ids = $wpdb->get_col($query); |
1531 | 1531 | //delete each post meta and term relations too |
1532 | - foreach($cpt_ids as $post_id){ |
|
1533 | - wp_delete_post($post_id,true); |
|
1532 | + foreach ($cpt_ids as $post_id) { |
|
1533 | + wp_delete_post($post_id, true); |
|
1534 | 1534 | } |
1535 | 1535 | } |
1536 | 1536 | |
@@ -1544,18 +1544,18 @@ discard block |
||
1544 | 1544 | * @param bool $remove_all |
1545 | 1545 | * @return void |
1546 | 1546 | */ |
1547 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1547 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1548 | 1548 | global $wpdb; |
1549 | 1549 | $undeleted_tables = array(); |
1550 | 1550 | |
1551 | 1551 | // load registry |
1552 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1553 | - if ( method_exists( $model_name, 'instance' )) { |
|
1554 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1555 | - if ( $model_obj instanceof EEM_Base ) { |
|
1556 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1557 | - if ( strpos( $table->get_table_name(), 'esp_' )) { |
|
1558 | - switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) { |
|
1552 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1553 | + if (method_exists($model_name, 'instance')) { |
|
1554 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1555 | + if ($model_obj instanceof EEM_Base) { |
|
1556 | + foreach ($model_obj->get_tables() as $table) { |
|
1557 | + if (strpos($table->get_table_name(), 'esp_')) { |
|
1558 | + switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) { |
|
1559 | 1559 | case false : |
1560 | 1560 | $undeleted_tables[] = $table->get_table_name(); |
1561 | 1561 | break; |
@@ -1580,8 +1580,8 @@ discard block |
||
1580 | 1580 | 'esp_promotion_rule', |
1581 | 1581 | 'esp_rule' |
1582 | 1582 | ); |
1583 | - foreach( $tables_without_models as $table ){ |
|
1584 | - EEH_Activation::delete_db_table_if_empty( $table ); |
|
1583 | + foreach ($tables_without_models as $table) { |
|
1584 | + EEH_Activation::delete_db_table_if_empty($table); |
|
1585 | 1585 | } |
1586 | 1586 | |
1587 | 1587 | |
@@ -1619,58 +1619,58 @@ discard block |
||
1619 | 1619 | 'ee_job_parameters_' => false, |
1620 | 1620 | 'ee_upload_directories_incomplete' => true, |
1621 | 1621 | ); |
1622 | - if( is_main_site() ) { |
|
1623 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1622 | + if (is_main_site()) { |
|
1623 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1624 | 1624 | } |
1625 | 1625 | |
1626 | 1626 | $undeleted_options = array(); |
1627 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1627 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1628 | 1628 | |
1629 | - if( $no_wildcard ){ |
|
1630 | - if( ! delete_option( $option_name ) ){ |
|
1629 | + if ($no_wildcard) { |
|
1630 | + if ( ! delete_option($option_name)) { |
|
1631 | 1631 | $undeleted_options[] = $option_name; |
1632 | 1632 | } |
1633 | - }else{ |
|
1634 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1635 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1636 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1633 | + } else { |
|
1634 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1635 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1636 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1637 | 1637 | $undeleted_options[] = $option_name_from_wildcard; |
1638 | 1638 | } |
1639 | 1639 | } |
1640 | 1640 | } |
1641 | 1641 | } |
1642 | 1642 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1643 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1643 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1644 | 1644 | |
1645 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1645 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1646 | 1646 | $db_update_sans_ee4 = array(); |
1647 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1648 | - if( $version[0] =='3'){//if its NON EE4 |
|
1647 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1648 | + if ($version[0] == '3') {//if its NON EE4 |
|
1649 | 1649 | $db_update_sans_ee4[$version] = $times_activated; |
1650 | 1650 | } |
1651 | 1651 | } |
1652 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1652 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1653 | 1653 | } |
1654 | 1654 | |
1655 | 1655 | $errors = ''; |
1656 | - if ( ! empty( $undeleted_tables )) { |
|
1656 | + if ( ! empty($undeleted_tables)) { |
|
1657 | 1657 | $errors .= sprintf( |
1658 | - __( 'The following tables could not be deleted: %s%s', 'event_espresso' ), |
|
1658 | + __('The following tables could not be deleted: %s%s', 'event_espresso'), |
|
1659 | 1659 | '<br/>', |
1660 | - implode( ',<br/>', $undeleted_tables ) |
|
1660 | + implode(',<br/>', $undeleted_tables) |
|
1661 | 1661 | ); |
1662 | 1662 | } |
1663 | - if ( ! empty( $undeleted_options )) { |
|
1664 | - $errors .= ! empty( $undeleted_tables ) ? '<br/>' : ''; |
|
1663 | + if ( ! empty($undeleted_options)) { |
|
1664 | + $errors .= ! empty($undeleted_tables) ? '<br/>' : ''; |
|
1665 | 1665 | $errors .= sprintf( |
1666 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1666 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1667 | 1667 | '<br/>', |
1668 | - implode( ',<br/>', $undeleted_options ) |
|
1668 | + implode(',<br/>', $undeleted_options) |
|
1669 | 1669 | ); |
1670 | 1670 | |
1671 | 1671 | } |
1672 | - if ( $errors != '' ) { |
|
1673 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1672 | + if ($errors != '') { |
|
1673 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1674 | 1674 | } |
1675 | 1675 | } |
1676 | 1676 | |
@@ -1680,23 +1680,23 @@ discard block |
||
1680 | 1680 | * @param string $table_name with or without $wpdb->prefix |
1681 | 1681 | * @return boolean |
1682 | 1682 | */ |
1683 | - public static function table_exists( $table_name ){ |
|
1683 | + public static function table_exists($table_name) { |
|
1684 | 1684 | global $wpdb, $EZSQL_ERROR; |
1685 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
1685 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
1686 | 1686 | //ignore if this causes an sql error |
1687 | 1687 | $old_error = $wpdb->last_error; |
1688 | 1688 | $old_suppress_errors = $wpdb->suppress_errors(); |
1689 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
1689 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
1690 | 1690 | $ezsql_error_cache = $EZSQL_ERROR; |
1691 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
1692 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1693 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
1691 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
1692 | + $wpdb->show_errors($old_show_errors_value); |
|
1693 | + $wpdb->suppress_errors($old_suppress_errors); |
|
1694 | 1694 | $new_error = $wpdb->last_error; |
1695 | 1695 | $wpdb->last_error = $old_error; |
1696 | 1696 | $EZSQL_ERROR = $ezsql_error_cache; |
1697 | - if( empty( $new_error ) ){ |
|
1697 | + if (empty($new_error)) { |
|
1698 | 1698 | return TRUE; |
1699 | - }else{ |
|
1699 | + } else { |
|
1700 | 1700 | return FALSE; |
1701 | 1701 | } |
1702 | 1702 | } |
@@ -1704,7 +1704,7 @@ discard block |
||
1704 | 1704 | /** |
1705 | 1705 | * Resets the cache on EEH_Activation |
1706 | 1706 | */ |
1707 | - public static function reset(){ |
|
1707 | + public static function reset() { |
|
1708 | 1708 | self::$_default_creator_id = NULL; |
1709 | 1709 | self::$_initialized_db_content_already_in_this_request = false; |
1710 | 1710 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $this->_message_type_collection_loader->load_message_types_from_folder(); |
125 | 125 | $this->_message_template_group_model = $Message_Template_Group_Model; |
126 | 126 | $this->_set_active_messengers_and_message_types(); |
127 | - $this->get_has_activated_messengers_option( true ); |
|
127 | + $this->get_has_activated_messengers_option(true); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * @param string $messenger_name |
152 | 152 | * @return \EE_Messenger |
153 | 153 | */ |
154 | - public function get_messenger( $messenger_name ) { |
|
155 | - return $this->messenger_collection()->get_by_info( $messenger_name ); |
|
154 | + public function get_messenger($messenger_name) { |
|
155 | + return $this->messenger_collection()->get_by_info($messenger_name); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | * @param string $messenger |
164 | 164 | * @return EE_Messenger | null |
165 | 165 | */ |
166 | - public function get_active_messenger( $messenger ) { |
|
167 | - return ! empty( $this->_active_messengers[ $messenger ] ) ? $this->_active_messengers[ $messenger ] : null; |
|
166 | + public function get_active_messenger($messenger) { |
|
167 | + return ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : null; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | * @return \EE_Messenger[] |
174 | 174 | */ |
175 | 175 | public function installed_messengers() { |
176 | - if ( empty( $this->_installed_messengers ) ) { |
|
176 | + if (empty($this->_installed_messengers)) { |
|
177 | 177 | $this->_installed_messengers = array(); |
178 | 178 | $this->messenger_collection()->rewind(); |
179 | - while ( $this->messenger_collection()->valid() ) { |
|
180 | - $this->_installed_messengers[ $this->messenger_collection()->current()->name ] = $this->messenger_collection()->current(); |
|
179 | + while ($this->messenger_collection()->valid()) { |
|
180 | + $this->_installed_messengers[$this->messenger_collection()->current()->name] = $this->messenger_collection()->current(); |
|
181 | 181 | $this->messenger_collection()->next(); |
182 | 182 | } |
183 | 183 | } |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | * @return \EE_Messenger |
192 | 192 | * @throws \EE_Error |
193 | 193 | */ |
194 | - public function valid_messenger( $messenger_name ) { |
|
195 | - $messenger = $this->get_messenger( $messenger_name ); |
|
196 | - if ( $messenger instanceof EE_Messenger ) { |
|
194 | + public function valid_messenger($messenger_name) { |
|
195 | + $messenger = $this->get_messenger($messenger_name); |
|
196 | + if ($messenger instanceof EE_Messenger) { |
|
197 | 197 | return $messenger; |
198 | 198 | } |
199 | 199 | throw new EE_Error( |
200 | 200 | sprintf( |
201 | - __( 'The "%1$s" messenger is either invalid or not installed', 'event_espresso' ), |
|
201 | + __('The "%1$s" messenger is either invalid or not installed', 'event_espresso'), |
|
202 | 202 | $messenger_name |
203 | 203 | ) |
204 | 204 | ); |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | * @param string $message_type_name |
229 | 229 | * @return \EE_Message_Type |
230 | 230 | */ |
231 | - public function get_message_type( $message_type_name ) { |
|
232 | - return $this->message_type_collection()->get_by_info( $message_type_name ); |
|
231 | + public function get_message_type($message_type_name) { |
|
232 | + return $this->message_type_collection()->get_by_info($message_type_name); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * @param string $message_type_name |
242 | 242 | * @return \EE_Message_Type|null |
243 | 243 | */ |
244 | - public function get_active_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
245 | - return $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) |
|
246 | - ? $this->get_message_type( $message_type_name ) |
|
244 | + public function get_active_message_type_for_messenger($messenger_name, $message_type_name) { |
|
245 | + return $this->is_message_type_active_for_messenger($messenger_name, $message_type_name) |
|
246 | + ? $this->get_message_type($message_type_name) |
|
247 | 247 | : null; |
248 | 248 | } |
249 | 249 | |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return bool |
258 | 258 | */ |
259 | - public function is_message_type_active_for_messenger( $messenger_name, $message_type_name ) { |
|
260 | - return ! empty( $this->_active_message_types[ $messenger_name ]['settings'][$messenger_name . '-message_types'][ $message_type_name ] ); |
|
259 | + public function is_message_type_active_for_messenger($messenger_name, $message_type_name) { |
|
260 | + return ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
@@ -270,15 +270,15 @@ discard block |
||
270 | 270 | * @param string $messenger_name The messenger being checked |
271 | 271 | * @return EE_message_type[] (or empty array if none present) |
272 | 272 | */ |
273 | - public function get_active_message_types_for_messenger( $messenger_name ) { |
|
273 | + public function get_active_message_types_for_messenger($messenger_name) { |
|
274 | 274 | $message_types = array(); |
275 | - if ( empty( $this->_active_message_types[ $messenger_name ] ) ) { |
|
275 | + if (empty($this->_active_message_types[$messenger_name])) { |
|
276 | 276 | return $message_types; |
277 | 277 | } |
278 | 278 | $installed_message_types = $this->installed_message_types(); |
279 | - foreach ( $installed_message_types as $message_type_name => $message_type ) { |
|
280 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
281 | - $message_types[ $message_type_name ] = $message_type; |
|
279 | + foreach ($installed_message_types as $message_type_name => $message_type) { |
|
280 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
281 | + $message_types[$message_type_name] = $message_type; |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | return $message_types; |
@@ -295,12 +295,12 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public function list_of_active_message_types() { |
297 | 297 | $active_message_type_names = array(); |
298 | - foreach ( $this->_active_message_types as $messenger => $messenger_settings ) { |
|
299 | - if ( ! isset( $messenger_settings[ $messenger . '-message_types' ] ) ) { |
|
298 | + foreach ($this->_active_message_types as $messenger => $messenger_settings) { |
|
299 | + if ( ! isset($messenger_settings[$messenger.'-message_types'])) { |
|
300 | 300 | continue; |
301 | 301 | } |
302 | - foreach ( $messenger_settings[ $messenger . '-message_types' ] as $message_type_name => $message_type_config ) { |
|
303 | - if ( ! in_array( $message_type_name, $active_message_type_names ) ) { |
|
302 | + foreach ($messenger_settings[$messenger.'-message_types'] as $message_type_name => $message_type_config) { |
|
303 | + if ( ! in_array($message_type_name, $active_message_type_names)) { |
|
304 | 304 | $active_message_type_names[] = $message_type_name; |
305 | 305 | } |
306 | 306 | } |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | $active_message_types = array(); |
321 | 321 | $installed_message_types = $this->installed_message_types(); |
322 | 322 | $active_message_type_names = $this->list_of_active_message_types(); |
323 | - foreach ( $active_message_type_names as $active_message_type_name ) { |
|
324 | - if ( isset( $installed_message_types[ $active_message_type_name ] ) ) { |
|
325 | - $active_message_types[ $active_message_type_name ] = $installed_message_types[ $active_message_type_name ]; |
|
323 | + foreach ($active_message_type_names as $active_message_type_name) { |
|
324 | + if (isset($installed_message_types[$active_message_type_name])) { |
|
325 | + $active_message_types[$active_message_type_name] = $installed_message_types[$active_message_type_name]; |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | return $active_message_types; |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | * @return \EE_Message_Type[] |
335 | 335 | */ |
336 | 336 | public function installed_message_types() { |
337 | - if ( empty( $this->_installed_message_types ) ) { |
|
337 | + if (empty($this->_installed_message_types)) { |
|
338 | 338 | $this->message_type_collection()->rewind(); |
339 | - while ( $this->message_type_collection()->valid() ) { |
|
340 | - $this->_installed_message_types[ $this->message_type_collection()->current()->name ] = $this->message_type_collection()->current(); |
|
339 | + while ($this->message_type_collection()->valid()) { |
|
340 | + $this->_installed_message_types[$this->message_type_collection()->current()->name] = $this->message_type_collection()->current(); |
|
341 | 341 | $this->message_type_collection()->next(); |
342 | 342 | } |
343 | 343 | } |
@@ -350,14 +350,14 @@ discard block |
||
350 | 350 | * @return \EE_message_type |
351 | 351 | * @throws \EE_Error |
352 | 352 | */ |
353 | - public function valid_message_type( $message_type_name ) { |
|
354 | - $message_type = $this->get_message_type( $message_type_name ); |
|
355 | - if ( $message_type instanceof EE_message_type ) { |
|
353 | + public function valid_message_type($message_type_name) { |
|
354 | + $message_type = $this->get_message_type($message_type_name); |
|
355 | + if ($message_type instanceof EE_message_type) { |
|
356 | 356 | return $message_type; |
357 | 357 | } |
358 | 358 | throw new EE_Error( |
359 | 359 | sprintf( |
360 | - __( 'The "%1$s" message type is either invalid or not installed', 'event_espresso' ), |
|
360 | + __('The "%1$s" message type is either invalid or not installed', 'event_espresso'), |
|
361 | 361 | $message_type_name |
362 | 362 | ) |
363 | 363 | ); |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | * @return array |
374 | 374 | * @throws \EE_Error |
375 | 375 | */ |
376 | - public function valid_message_type_for_messenger( EE_Messenger $messenger, $message_type_name ) { |
|
376 | + public function valid_message_type_for_messenger(EE_Messenger $messenger, $message_type_name) { |
|
377 | 377 | $valid_message_types = $messenger->get_valid_message_types(); |
378 | - if ( ! in_array( $message_type_name, $valid_message_types ) ) { |
|
378 | + if ( ! in_array($message_type_name, $valid_message_types)) { |
|
379 | 379 | throw new EE_Error( |
380 | 380 | sprintf( |
381 | 381 | __( |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @return array |
404 | 404 | */ |
405 | - public function get_active_messengers_option( $reset = false) { |
|
406 | - if ( $reset ) { |
|
407 | - $this->_active_message_types = get_option( 'ee_active_messengers', array() ); |
|
405 | + public function get_active_messengers_option($reset = false) { |
|
406 | + if ($reset) { |
|
407 | + $this->_active_message_types = get_option('ee_active_messengers', array()); |
|
408 | 408 | } |
409 | 409 | return $this->_active_message_types; |
410 | 410 | } |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | * representing this data is used. |
419 | 419 | * @return bool FALSE if not updated, TRUE if updated. |
420 | 420 | */ |
421 | - public function update_active_messengers_option( $active_messengers = array() ) { |
|
422 | - $active_messengers = empty( $active_messengers ) ? $this->_active_message_types : $active_messengers; |
|
423 | - return update_option( 'ee_active_messengers', $active_messengers ); |
|
421 | + public function update_active_messengers_option($active_messengers = array()) { |
|
422 | + $active_messengers = empty($active_messengers) ? $this->_active_message_types : $active_messengers; |
|
423 | + return update_option('ee_active_messengers', $active_messengers); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | |
@@ -435,9 +435,9 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return array |
437 | 437 | */ |
438 | - public function get_has_activated_messengers_option( $reset = false ) { |
|
439 | - if ( $reset ) { |
|
440 | - $this->_has_activated_messengers_and_message_types = get_option( 'ee_has_activated_messenger', array() ); |
|
438 | + public function get_has_activated_messengers_option($reset = false) { |
|
439 | + if ($reset) { |
|
440 | + $this->_has_activated_messengers_and_message_types = get_option('ee_has_activated_messenger', array()); |
|
441 | 441 | } |
442 | 442 | return $this->_has_activated_messengers_and_message_types; |
443 | 443 | } |
@@ -452,11 +452,11 @@ discard block |
||
452 | 452 | * |
453 | 453 | * @return bool FALSE if not updated, TRUE if updated. |
454 | 454 | */ |
455 | - public function update_has_activated_messengers_option( $has_activated_messengers = array() ) { |
|
456 | - $has_activated_messengers = empty( $has_activated_messengers ) |
|
455 | + public function update_has_activated_messengers_option($has_activated_messengers = array()) { |
|
456 | + $has_activated_messengers = empty($has_activated_messengers) |
|
457 | 457 | ? $this->_has_activated_messengers_and_message_types |
458 | 458 | : $has_activated_messengers; |
459 | - return update_option( 'ee_has_activated_messenger', $has_activated_messengers ); |
|
459 | + return update_option('ee_has_activated_messenger', $has_activated_messengers); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | //echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() \n"; |
479 | 479 | // list of activated messengers as set via the admin |
480 | 480 | // note calling `get_active_messengers_options` also initializes the _active_message_types property. |
481 | - $this->get_active_messengers_option( true ); |
|
482 | - $this->ensure_messengers_are_active( array(), false, true ); |
|
481 | + $this->get_active_messengers_option(true); |
|
482 | + $this->ensure_messengers_are_active(array(), false, true); |
|
483 | 483 | $this->update_active_messengers_option(); |
484 | 484 | $this->update_has_activated_messengers_option(); |
485 | 485 | } |
@@ -497,9 +497,9 @@ discard block |
||
497 | 497 | * @param bool $update_option Whether to update the option in the db or not. |
498 | 498 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
499 | 499 | */ |
500 | - public function ensure_messenger_is_active( $messenger_name, $update_option = true ) { |
|
501 | - if ( ! isset( $this->_active_messengers[ $messenger_name ] ) ) { |
|
502 | - $this->activate_messenger( $messenger_name, array(), $update_option ); |
|
500 | + public function ensure_messenger_is_active($messenger_name, $update_option = true) { |
|
501 | + if ( ! isset($this->_active_messengers[$messenger_name])) { |
|
502 | + $this->activate_messenger($messenger_name, array(), $update_option); |
|
503 | 503 | return false; |
504 | 504 | } |
505 | 505 | return true; |
@@ -517,25 +517,25 @@ discard block |
||
517 | 517 | * @param bool $update_option Whether to update the related active messengers option. |
518 | 518 | * @param bool $verify Whether to verify the messengers are installed before activating. Note if this is set to true |
519 | 519 | */ |
520 | - public function ensure_messengers_are_active( $messenger_names = array(), $update_option = true, $verify = false ) { |
|
521 | - $messenger_names = empty( $messenger_names ) ? array_keys( $this->_active_message_types ) : $messenger_names; |
|
520 | + public function ensure_messengers_are_active($messenger_names = array(), $update_option = true, $verify = false) { |
|
521 | + $messenger_names = empty($messenger_names) ? array_keys($this->_active_message_types) : $messenger_names; |
|
522 | 522 | |
523 | 523 | $not_installed = array(); |
524 | - foreach( $messenger_names as $messenger_name ) { |
|
525 | - if ( $verify && ! $this->messenger_collection()->has_by_name( $messenger_name ) ) { |
|
524 | + foreach ($messenger_names as $messenger_name) { |
|
525 | + if ($verify && ! $this->messenger_collection()->has_by_name($messenger_name)) { |
|
526 | 526 | $not_installed[] = $messenger_name; |
527 | - $this->deactivate_messenger( $messenger_name ); |
|
527 | + $this->deactivate_messenger($messenger_name); |
|
528 | 528 | continue; |
529 | 529 | } |
530 | - $this->ensure_messenger_is_active( $messenger_name, $update_option ); |
|
530 | + $this->ensure_messenger_is_active($messenger_name, $update_option); |
|
531 | 531 | } |
532 | 532 | |
533 | - if ( ! empty( $not_installed_messenger ) ) { |
|
533 | + if ( ! empty($not_installed_messenger)) { |
|
534 | 534 | EE_Error::add_error( |
535 | 535 | sprintf( |
536 | - __( 'The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso' ), |
|
536 | + __('The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso'), |
|
537 | 537 | '<br />', |
538 | - implode( ', ', $not_installed_messenger ) |
|
538 | + implode(', ', $not_installed_messenger) |
|
539 | 539 | ), |
540 | 540 | __FILE__, __FUNCTION__, __LINE__ |
541 | 541 | ); |
@@ -554,17 +554,17 @@ discard block |
||
554 | 554 | * @return array |
555 | 555 | * @throws \EE_Error |
556 | 556 | */ |
557 | - public function ensure_message_type_is_active( $message_type_name, $messenger_name, $update_option = true ) { |
|
557 | + public function ensure_message_type_is_active($message_type_name, $messenger_name, $update_option = true) { |
|
558 | 558 | // grab the messenger to work with. |
559 | - $messenger = $this->valid_messenger( $messenger_name ); |
|
560 | - if ( $this->valid_message_type_for_messenger( $messenger, $message_type_name ) ) { |
|
559 | + $messenger = $this->valid_messenger($messenger_name); |
|
560 | + if ($this->valid_message_type_for_messenger($messenger, $message_type_name)) { |
|
561 | 561 | //ensure messenger is active (that's an inherent coupling between active message types and the |
562 | 562 | //messenger they are being activated for. Note option is not being updated here because that gets handled later |
563 | 563 | //in this method. |
564 | - $this->ensure_messenger_is_active( $messenger_name, false ); |
|
564 | + $this->ensure_messenger_is_active($messenger_name, false); |
|
565 | 565 | //all is good so let's just get it active |
566 | - $this->_activate_message_types( $messenger, array( $message_type_name ) ); |
|
567 | - if ( $update_option ) { |
|
566 | + $this->_activate_message_types($messenger, array($message_type_name)); |
|
567 | + if ($update_option) { |
|
568 | 568 | $this->update_active_messengers_option(); |
569 | 569 | $this->update_has_activated_messengers_option(); |
570 | 570 | } |
@@ -584,14 +584,14 @@ discard block |
||
584 | 584 | * @param bool $update_option Whether to persist the activation to the database or not (default true). |
585 | 585 | * @return array |
586 | 586 | */ |
587 | - public function ensure_message_types_are_active( $message_type_names, $messenger_name, $update_option = true ) { |
|
587 | + public function ensure_message_types_are_active($message_type_names, $messenger_name, $update_option = true) { |
|
588 | 588 | $message_type_names = (array) $message_type_names; |
589 | - foreach ( $message_type_names as $message_type_name ) { |
|
589 | + foreach ($message_type_names as $message_type_name) { |
|
590 | 590 | // note, intentionally not updating option here because we're in a loop. |
591 | 591 | // We'll follow the instructions of the incoming $update_option argument after the loop. |
592 | - $this->ensure_message_type_is_active( $message_type_name, $messenger_name, false ); |
|
592 | + $this->ensure_message_type_is_active($message_type_name, $messenger_name, false); |
|
593 | 593 | } |
594 | - if ( $update_option ) { |
|
594 | + if ($update_option) { |
|
595 | 595 | $this->update_active_messengers_option(); |
596 | 596 | $this->update_has_activated_messengers_option(); |
597 | 597 | } |
@@ -619,22 +619,22 @@ discard block |
||
619 | 619 | //EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__ ); |
620 | 620 | $templates = array(); |
621 | 621 | // grab the messenger to work with. |
622 | - $messenger = $this->messenger_collection()->get_by_info( $messenger_name ); |
|
622 | + $messenger = $this->messenger_collection()->get_by_info($messenger_name); |
|
623 | 623 | // it's inactive. Activate it. |
624 | - if ( $messenger instanceof EE_Messenger ) { |
|
624 | + if ($messenger instanceof EE_Messenger) { |
|
625 | 625 | //EEH_Debug_Tools::printr( $messenger->name, 'activate_messenger', __FILE__, __LINE__ ); |
626 | - $this->_active_messengers[ $messenger->name ] = $messenger; |
|
626 | + $this->_active_messengers[$messenger->name] = $messenger; |
|
627 | 627 | //activate incoming message types set to be activated with messenger. |
628 | - $message_type_names = $this->_activate_message_types( $messenger, $message_type_names ); |
|
628 | + $message_type_names = $this->_activate_message_types($messenger, $message_type_names); |
|
629 | 629 | // setup any initial settings for the messenger if necessary. |
630 | - $this->_add_settings_for_messenger( $messenger ); |
|
631 | - if ( $update_active_messengers_option ) { |
|
630 | + $this->_add_settings_for_messenger($messenger); |
|
631 | + if ($update_active_messengers_option) { |
|
632 | 632 | $this->update_active_messengers_option(); |
633 | 633 | $this->update_has_activated_messengers_option(); |
634 | 634 | } |
635 | 635 | // might need to generate new templates |
636 | - if ( ! empty( $message_type_names ) ) { |
|
637 | - $templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $message_type_names, 0, true ); |
|
636 | + if ( ! empty($message_type_names)) { |
|
637 | + $templates = EEH_MSG_Template::generate_new_templates($messenger->name, $message_type_names, 0, true); |
|
638 | 638 | } |
639 | 639 | } |
640 | 640 | return $templates; |
@@ -653,31 +653,31 @@ discard block |
||
653 | 653 | * |
654 | 654 | * @return array |
655 | 655 | */ |
656 | - protected function _activate_message_types( EE_Messenger $messenger, $message_type_names = array() ) { |
|
656 | + protected function _activate_message_types(EE_Messenger $messenger, $message_type_names = array()) { |
|
657 | 657 | //EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__ ); |
658 | 658 | //If $message_type_names is empty, AND $this->_active_message_types is empty, then that means |
659 | 659 | //things have never been initialized (which should happen on EEH_Activation::generate_message_templates). |
660 | 660 | //So ONLY then do we need to actually grab defaults and cycle through them. Otherwise we |
661 | 661 | //only override _active_message_types when an explicit array of $message_type_names has been provided. |
662 | - $message_type_names = empty( $message_type_names ) && ! isset( $this->_active_message_types[ $messenger->name ] ) |
|
662 | + $message_type_names = empty($message_type_names) && ! isset($this->_active_message_types[$messenger->name]) |
|
663 | 663 | ? $messenger->get_default_message_types() |
664 | 664 | : $message_type_names; |
665 | 665 | |
666 | 666 | //now we ALWAYS need to make sure that the messenger is active for the message types we're activating! |
667 | - if ( ! isset( $this->_active_message_types[ $messenger->name ] ) ) { |
|
668 | - $this->_active_message_types[ $messenger->name ]['settings'] = array(); |
|
667 | + if ( ! isset($this->_active_message_types[$messenger->name])) { |
|
668 | + $this->_active_message_types[$messenger->name]['settings'] = array(); |
|
669 | 669 | } |
670 | 670 | |
671 | - if ( $message_type_names ) { |
|
671 | + if ($message_type_names) { |
|
672 | 672 | // cycle thru message types |
673 | - foreach ( $message_type_names as $message_type_name ) { |
|
673 | + foreach ($message_type_names as $message_type_name) { |
|
674 | 674 | //EEH_Debug_Tools::printr( $message_type_name, '$message_type_name', __FILE__, __LINE__ ); |
675 | 675 | //only register the message type as active IF it isn't already active! |
676 | 676 | //and if its actually installed. |
677 | 677 | if ( |
678 | - ! $this->is_message_type_active_for_messenger( $messenger->name, $message_type_name ) |
|
678 | + ! $this->is_message_type_active_for_messenger($messenger->name, $message_type_name) |
|
679 | 679 | ) { |
680 | - $this->_add_settings_for_message_type( $messenger, $message_type_name ); |
|
680 | + $this->_add_settings_for_message_type($messenger, $message_type_name); |
|
681 | 681 | $this->_set_messenger_has_activated_message_type( |
682 | 682 | $messenger, |
683 | 683 | $message_type_name |
@@ -697,18 +697,18 @@ discard block |
||
697 | 697 | * @param \EE_Messenger $messenger |
698 | 698 | * @param string $message_type_name |
699 | 699 | */ |
700 | - protected function _add_settings_for_message_type( EE_Messenger $messenger, $message_type_name ) { |
|
700 | + protected function _add_settings_for_message_type(EE_Messenger $messenger, $message_type_name) { |
|
701 | 701 | $settings = array(); |
702 | 702 | // get installed message type from collection |
703 | - $message_type = $this->message_type_collection()->get_by_info( $message_type_name ); |
|
703 | + $message_type = $this->message_type_collection()->get_by_info($message_type_name); |
|
704 | 704 | //we need to setup any initial settings for message types |
705 | - if ( $message_type instanceof EE_Message_Type ) { |
|
705 | + if ($message_type instanceof EE_Message_Type) { |
|
706 | 706 | $settings_fields = $message_type->get_admin_settings_fields(); |
707 | - foreach ( $settings_fields as $field => $values ) { |
|
708 | - $settings[ $field ] = $values[ 'default' ]; |
|
707 | + foreach ($settings_fields as $field => $values) { |
|
708 | + $settings[$field] = $values['default']; |
|
709 | 709 | } |
710 | 710 | } |
711 | - $this->_active_message_types[ $messenger->name ][ 'settings' ][ $messenger->name . '-message_types' ][ $message_type_name ][ 'settings' ] = $settings; |
|
711 | + $this->_active_message_types[$messenger->name]['settings'][$messenger->name.'-message_types'][$message_type_name]['settings'] = $settings; |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | |
@@ -721,14 +721,14 @@ discard block |
||
721 | 721 | * @param \EE_Messenger $messenger |
722 | 722 | * @param string $message_type_name |
723 | 723 | */ |
724 | - protected function _set_messenger_has_activated_message_type( EE_Messenger $messenger, $message_type_name ) { |
|
724 | + protected function _set_messenger_has_activated_message_type(EE_Messenger $messenger, $message_type_name) { |
|
725 | 725 | // make sure this messenger has a record in the has_activated array |
726 | - if ( ! isset( $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
727 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ] = array(); |
|
726 | + if ( ! isset($this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
727 | + $this->_has_activated_messengers_and_message_types[$messenger->name] = array(); |
|
728 | 728 | } |
729 | 729 | // check if message type has already been added |
730 | - if ( ! in_array( $message_type_name, $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
731 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ][] = $message_type_name; |
|
730 | + if ( ! in_array($message_type_name, $this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
731 | + $this->_has_activated_messengers_and_message_types[$messenger->name][] = $message_type_name; |
|
732 | 732 | } |
733 | 733 | } |
734 | 734 | |
@@ -740,13 +740,13 @@ discard block |
||
740 | 740 | * @access protected |
741 | 741 | * @param \EE_Messenger $messenger |
742 | 742 | */ |
743 | - protected function _add_settings_for_messenger( EE_Messenger $messenger ) { |
|
743 | + protected function _add_settings_for_messenger(EE_Messenger $messenger) { |
|
744 | 744 | $msgr_settings = $messenger->get_admin_settings_fields(); |
745 | - if ( ! empty( $msgr_settings ) ) { |
|
746 | - foreach ( $msgr_settings as $field => $value ) { |
|
745 | + if ( ! empty($msgr_settings)) { |
|
746 | + foreach ($msgr_settings as $field => $value) { |
|
747 | 747 | //only set the default if it isn't already set. |
748 | - if ( ! isset( $this->_active_message_types[ $messenger->name ]['settings'][ $field ] ) ) { |
|
749 | - $this->_active_message_types[ $messenger->name ]['settings'][ $field ] = $value; |
|
748 | + if ( ! isset($this->_active_message_types[$messenger->name]['settings'][$field])) { |
|
749 | + $this->_active_message_types[$messenger->name]['settings'][$field] = $value; |
|
750 | 750 | } |
751 | 751 | } |
752 | 752 | } |
@@ -760,13 +760,13 @@ discard block |
||
760 | 760 | * @param string|EE_Messenger $messenger_name name of messenger |
761 | 761 | * @return void |
762 | 762 | */ |
763 | - public function deactivate_messenger( $messenger_name ) { |
|
764 | - if ( $messenger_name instanceof EE_Messenger ) { |
|
763 | + public function deactivate_messenger($messenger_name) { |
|
764 | + if ($messenger_name instanceof EE_Messenger) { |
|
765 | 765 | $messenger_name = $messenger_name->name; |
766 | 766 | } |
767 | - unset( $this->_active_messengers[ $messenger_name ] ); |
|
768 | - unset( $this->_active_message_types[ $messenger_name ] ); |
|
769 | - $this->_message_template_group_model->deactivate_message_template_groups_for( $messenger_name ); |
|
767 | + unset($this->_active_messengers[$messenger_name]); |
|
768 | + unset($this->_active_message_types[$messenger_name]); |
|
769 | + $this->_message_template_group_model->deactivate_message_template_groups_for($messenger_name); |
|
770 | 770 | $this->update_active_messengers_option(); |
771 | 771 | } |
772 | 772 | |
@@ -776,16 +776,16 @@ discard block |
||
776 | 776 | * |
777 | 777 | * @param string $message_type_name name of message type being deactivated |
778 | 778 | */ |
779 | - public function deactivate_message_type( $message_type_name ) { |
|
780 | - if ( $message_type_name instanceof EE_Message_Type ) { |
|
779 | + public function deactivate_message_type($message_type_name) { |
|
780 | + if ($message_type_name instanceof EE_Message_Type) { |
|
781 | 781 | $message_type_name = $message_type_name->name; |
782 | 782 | } |
783 | - foreach ( $this->_active_message_types as $messenger => $settings ) { |
|
783 | + foreach ($this->_active_message_types as $messenger => $settings) { |
|
784 | 784 | unset( |
785 | - $this->_active_message_types[ $messenger ]['settings'][ $messenger . '-message_types' ][ $message_type_name ] |
|
785 | + $this->_active_message_types[$messenger]['settings'][$messenger.'-message_types'][$message_type_name] |
|
786 | 786 | ); |
787 | 787 | } |
788 | - $this->_message_template_group_model->deactivate_message_template_groups_for( '', $message_type_name ); |
|
788 | + $this->_message_template_group_model->deactivate_message_template_groups_for('', $message_type_name); |
|
789 | 789 | $this->update_active_messengers_option(); |
790 | 790 | } |
791 | 791 | |
@@ -802,12 +802,12 @@ discard block |
||
802 | 802 | * |
803 | 803 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
804 | 804 | */ |
805 | - public function is_generating_messenger_and_active( EE_Messenger $messenger, EE_message_type $message_type ) { |
|
805 | + public function is_generating_messenger_and_active(EE_Messenger $messenger, EE_message_type $message_type) { |
|
806 | 806 | //get the $messengers the message type says it can be used with. |
807 | - foreach ( $message_type->with_messengers() as $generating_messenger => $secondary_messengers ) { |
|
807 | + foreach ($message_type->with_messengers() as $generating_messenger => $secondary_messengers) { |
|
808 | 808 | if ( |
809 | 809 | $messenger->name === $generating_messenger |
810 | - && $this->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) |
|
810 | + && $this->is_message_type_active_for_messenger($messenger->name, $message_type->name) |
|
811 | 811 | ) { |
812 | 812 | return true; |
813 | 813 | } |
@@ -844,25 +844,25 @@ discard block |
||
844 | 844 | * or all contexts indexed by message type. |
845 | 845 | * @return array |
846 | 846 | */ |
847 | - public function get_all_contexts( $slugs_only = true ) { |
|
847 | + public function get_all_contexts($slugs_only = true) { |
|
848 | 848 | $key = $slugs_only ? 'slugs' : 'all'; |
849 | 849 | // check if contexts has been setup yet. |
850 | - if ( empty( $this->_contexts[ $key ] ) ) { |
|
850 | + if (empty($this->_contexts[$key])) { |
|
851 | 851 | // So let's get all active message type objects and loop through to get all unique contexts |
852 | - foreach ( $this->get_active_message_type_objects() as $message_type ) { |
|
853 | - if ( $message_type instanceof EE_message_type ) { |
|
852 | + foreach ($this->get_active_message_type_objects() as $message_type) { |
|
853 | + if ($message_type instanceof EE_message_type) { |
|
854 | 854 | $message_type_contexts = $message_type->get_contexts(); |
855 | - if ( $slugs_only ) { |
|
856 | - foreach ( $message_type_contexts as $context => $context_details ) { |
|
857 | - $this->_contexts[ $key ][ $context ] = $context_details[ 'label' ]; |
|
855 | + if ($slugs_only) { |
|
856 | + foreach ($message_type_contexts as $context => $context_details) { |
|
857 | + $this->_contexts[$key][$context] = $context_details['label']; |
|
858 | 858 | } |
859 | 859 | } else { |
860 | - $this->_contexts[ $key ][ $message_type->name ] = $message_type_contexts; |
|
860 | + $this->_contexts[$key][$message_type->name] = $message_type_contexts; |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | } |
864 | 864 | } |
865 | - return ! empty( $this->_contexts[ $key ] ) ? $this->_contexts[ $key ] : array(); |
|
865 | + return ! empty($this->_contexts[$key]) ? $this->_contexts[$key] : array(); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | |
@@ -881,9 +881,9 @@ discard block |
||
881 | 881 | $installed_message_types = $this->installed_message_types(); |
882 | 882 | $all_message_types_valid = true; |
883 | 883 | //loop through list of active message types and verify they are installed. |
884 | - foreach( $list_of_active_message_type_names as $message_type_name ) { |
|
885 | - if ( ! isset( $installed_message_types[$message_type_name] ) ) { |
|
886 | - $this->deactivate_message_type( $message_type_name ); |
|
884 | + foreach ($list_of_active_message_type_names as $message_type_name) { |
|
885 | + if ( ! isset($installed_message_types[$message_type_name])) { |
|
886 | + $this->deactivate_message_type($message_type_name); |
|
887 | 887 | $all_message_types_valid = false; |
888 | 888 | } |
889 | 889 | } |