@@ -93,7 +93,7 @@ |
||
93 | 93 | * |
94 | 94 | * @abstract |
95 | 95 | * @access protected |
96 | - * @return array |
|
96 | + * @return string[] |
|
97 | 97 | */ |
98 | 98 | protected function _get_table_filters() { |
99 | 99 | $filters = array(); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -abstract class EE_Display_Strategy_Base extends EE_Form_Input_Strategy_Base{ |
|
11 | +abstract class EE_Display_Strategy_Base extends EE_Form_Input_Strategy_Base { |
|
12 | 12 | /** |
13 | 13 | * returns HTML and javascript related to the displaying of this input |
14 | 14 | * @return string |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @param string $chars - exact string of characters to remove |
25 | 25 | * @return string |
26 | 26 | */ |
27 | - protected function _remove_chars( $string = '', $chars = '-' ) { |
|
28 | - $char_length = strlen( $chars ) * -1; |
|
27 | + protected function _remove_chars($string = '', $chars = '-') { |
|
28 | + $char_length = strlen($chars) * -1; |
|
29 | 29 | // if last three characters of string is " - ", then remove it |
30 | - return substr( $string, $char_length ) == $chars ? substr( $string, 0, $char_length ) : $string; |
|
30 | + return substr($string, $char_length) == $chars ? substr($string, 0, $char_length) : $string; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -39,16 +39,16 @@ discard block |
||
39 | 39 | * @param string $chars - exact string of characters to be added to end of string |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - protected function _append_chars( $string = '', $chars = '-' ) { |
|
43 | - return $this->_remove_chars( $string, $chars ) . $chars; |
|
42 | + protected function _append_chars($string = '', $chars = '-') { |
|
43 | + return $this->_remove_chars($string, $chars).$chars; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Gets the HTML IDs of all the inputs |
48 | 48 | * @return array |
49 | 49 | */ |
50 | - public function get_html_input_ids( $add_pound_sign = false ) { |
|
51 | - return array( $this->get_input()->html_id( $add_pound_sign ) ); |
|
50 | + public function get_html_input_ids($add_pound_sign = false) { |
|
51 | + return array($this->get_input()->html_id($add_pound_sign)); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 |
@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | * base class for all strategies which operate on form inputs. Generally, they |
4 | 4 | * all need to know about the form input they are operating on. |
5 | 5 | */ |
6 | -abstract class EE_Form_Input_Strategy_Base{ |
|
6 | +abstract class EE_Form_Input_Strategy_Base { |
|
7 | 7 | /** |
8 | 8 | * Form Input to display |
9 | 9 | * @var EE_Form_Input_Base |
10 | 10 | */ |
11 | 11 | protected $_input; |
12 | 12 | |
13 | - function __construct(){ |
|
13 | + function __construct() { |
|
14 | 14 | |
15 | 15 | } |
16 | 16 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * The form input on which this strategy is to perform |
19 | 19 | * @param EE_Form_Input_Base $form_input |
20 | 20 | */ |
21 | - function _construct_finalize(EE_Form_Input_Base $form_input){ |
|
21 | + function _construct_finalize(EE_Form_Input_Base $form_input) { |
|
22 | 22 | $this->_input = $form_input; |
23 | 23 | } |
24 | 24 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | * @param bool $add_pound_sign |
28 | 28 | * @return string |
29 | 29 | */ |
30 | - public function get_sub_input_id( $option_value, $add_pound_sign = false ) { |
|
31 | - return $this->_append_chars( $this->_input->html_id( $add_pound_sign ), '-' ) . sanitize_key( $option_value ); |
|
30 | + public function get_sub_input_id($option_value, $add_pound_sign = false) { |
|
31 | + return $this->_append_chars($this->_input->html_id($add_pound_sign), '-').sanitize_key($option_value); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | * @return array |
41 | 41 | * @throws \EE_Error |
42 | 42 | */ |
43 | - public function get_html_input_ids( $add_pound_sign = false ) { |
|
43 | + public function get_html_input_ids($add_pound_sign = false) { |
|
44 | 44 | $html_input_ids = array(); |
45 | - foreach( $this->get_input()->options() as $value => $display ) { |
|
46 | - $html_input_ids[] = $this->get_sub_input_id( $value, $add_pound_sign ); |
|
45 | + foreach ($this->get_input()->options() as $value => $display) { |
|
46 | + $html_input_ids[] = $this->get_sub_input_id($value, $add_pound_sign); |
|
47 | 47 | } |
48 | 48 | return $html_input_ids; |
49 | 49 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @throws \EE_Error |
59 | 59 | */ |
60 | 60 | public function get_input() { |
61 | - if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base ){ |
|
61 | + if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
62 | 62 | throw new EE_Error( |
63 | 63 | sprintf( |
64 | 64 | __( |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Class EE_Radio_Button_Display_Strategy |
4 | 4 | * displays a set of radio buttons |
@@ -15,33 +15,33 @@ discard block |
||
15 | 15 | * @throws EE_Error |
16 | 16 | * @return string of html to display the field |
17 | 17 | */ |
18 | - public function display(){ |
|
18 | + public function display() { |
|
19 | 19 | $input = $this->get_input(); |
20 | 20 | $input->set_label_sizes(); |
21 | 21 | $label_size_class = $input->get_label_size_class(); |
22 | 22 | $html = ''; |
23 | - foreach( $input->options() as $value => $display_text ){ |
|
24 | - $value = $input->get_normalization_strategy()->unnormalize( $value ); |
|
23 | + foreach ($input->options() as $value => $display_text) { |
|
24 | + $value = $input->get_normalization_strategy()->unnormalize($value); |
|
25 | 25 | |
26 | - $html_id = $this->get_sub_input_id( $value ); |
|
27 | - $html .= EEH_HTML::nl( 0, 'radio' ); |
|
28 | - $html .= '<label for="' . $html_id . '"'; |
|
29 | - $html .= ' id="' . $html_id . '-lbl"'; |
|
30 | - $html .= ' class="ee-radio-label-after' . $label_size_class . '">'; |
|
31 | - $html .= EEH_HTML::nl( 1, 'radio' ); |
|
32 | - $html .= '<input id="' . $html_id . '"'; |
|
33 | - $html .= ' name="' . $input->html_name() . '"'; |
|
34 | - $html .= ' class="' . $input->html_class() . '"'; |
|
35 | - $html .= ' style="' . $input->html_style() . '"'; |
|
26 | + $html_id = $this->get_sub_input_id($value); |
|
27 | + $html .= EEH_HTML::nl(0, 'radio'); |
|
28 | + $html .= '<label for="'.$html_id.'"'; |
|
29 | + $html .= ' id="'.$html_id.'-lbl"'; |
|
30 | + $html .= ' class="ee-radio-label-after'.$label_size_class.'">'; |
|
31 | + $html .= EEH_HTML::nl(1, 'radio'); |
|
32 | + $html .= '<input id="'.$html_id.'"'; |
|
33 | + $html .= ' name="'.$input->html_name().'"'; |
|
34 | + $html .= ' class="'.$input->html_class().'"'; |
|
35 | + $html .= ' style="'.$input->html_style().'"'; |
|
36 | 36 | $html .= ' type="radio"'; |
37 | - $html .= ' value="' . esc_attr( $value ) . '"'; |
|
37 | + $html .= ' value="'.esc_attr($value).'"'; |
|
38 | 38 | $html .= $input->raw_value() === $value ? ' checked="checked"' : ''; |
39 | 39 | $html .= '> '; |
40 | 40 | $html .= $display_text; |
41 | - $html .= EEH_HTML::nl( -1, 'radio' ) . '</label>'; |
|
41 | + $html .= EEH_HTML::nl( -1, 'radio' ).'</label>'; |
|
42 | 42 | |
43 | 43 | } |
44 | - $html .= EEH_HTML::div( '', '', 'clear-float' ); |
|
44 | + $html .= EEH_HTML::div('', '', 'clear-float'); |
|
45 | 45 | $html .= EEH_HTML::divx(); |
46 | 46 | return $html; |
47 | 47 | } |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * |
561 | 561 | * @param string $payment_status The payment status being matched. |
562 | 562 | * |
563 | - * @return string|bool The payment message type slug matching the status or false if no match. |
|
563 | + * @return string|false The payment message type slug matching the status or false if no match. |
|
564 | 564 | */ |
565 | 565 | protected static function _get_payment_message_type( $payment_status ) { |
566 | 566 | EE_Registry::instance()->load_helper( 'MSG_Template' ); |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | * @param string $context This should correspond with a valid context for the message type |
805 | 805 | * @param string $messenger This should correspond with a valid messenger. |
806 | 806 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
807 | - * @return string|bool The body of the message or if send is requested, sends. |
|
807 | + * @return string The body of the message or if send is requested, sends. |
|
808 | 808 | */ |
809 | 809 | public static function preview_message( $type, $context, $messenger, $send = false ) { |
810 | 810 | self::_load_controller(); |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | * @since 4.9.0 |
901 | 901 | * @param $message_ids |
902 | 902 | * |
903 | - * @return bool | EE_Messages_Queue false if no messages sent. |
|
903 | + * @return EE_Messages_Queue | EE_Messages_Queue false if no messages sent. |
|
904 | 904 | */ |
905 | 905 | public static function send_now( $message_ids ) { |
906 | 906 | self::_load_controller(); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return EED_Module |
70 | 70 | */ |
71 | 71 | public static function instance() { |
72 | - return parent::get_instance( __CLASS__ ); |
|
72 | + return parent::get_instance(__CLASS__); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public static function set_hooks() { |
86 | 86 | //actions |
87 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
88 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 2 ); |
|
87 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
88 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 2); |
|
89 | 89 | //filters |
90 | - add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
91 | - add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
90 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
91 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
92 | 92 | //register routes |
93 | 93 | self::_register_routes(); |
94 | 94 | } |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public static function set_hooks_admin() { |
103 | 103 | //actions |
104 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
105 | - add_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array( 'EED_Messages', 'payment_reminder' ), 10 ); |
|
106 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 3 ); |
|
107 | - add_action( 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', array( 'EED_Messages', 'send_newsletter_message' ), 10, 2 ); |
|
108 | - add_action( 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array( 'EED_Messages', 'cancelled_registration' ), 10 ); |
|
109 | - add_action( 'AHEE__EE_Admin_Page___process_admin_payment_notification', array( 'EED_Messages', 'process_admin_payment' ), 10, 1 ); |
|
104 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
105 | + add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array('EED_Messages', 'payment_reminder'), 10); |
|
106 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 3); |
|
107 | + add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', array('EED_Messages', 'send_newsletter_message'), 10, 2); |
|
108 | + add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array('EED_Messages', 'cancelled_registration'), 10); |
|
109 | + add_action('AHEE__EE_Admin_Page___process_admin_payment_notification', array('EED_Messages', 'process_admin_payment'), 10, 1); |
|
110 | 110 | //filters |
111 | - add_filter( 'FHEE__EE_Admin_Page___process_resend_registration__success', array( 'EED_Messages', 'process_resend' ), 10, 2 ); |
|
112 | - add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
113 | - add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
111 | + add_filter('FHEE__EE_Admin_Page___process_resend_registration__success', array('EED_Messages', 'process_resend'), 10, 2); |
|
112 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
113 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | * @return void |
125 | 125 | */ |
126 | 126 | protected static function _register_routes() { |
127 | - EE_Config::register_route( 'msg_url_trigger', 'Messages', 'run' ); |
|
128 | - EE_Config::register_route( 'msg_cron_trigger', 'Messages', 'execute_batch_request' ); |
|
129 | - EE_Config::register_route( 'msg_browser_trigger', 'Messages', 'browser_trigger' ); |
|
130 | - EE_Config::register_route( 'msg_browser_error_trigger', 'Messages', 'browser_error_trigger' ); |
|
131 | - do_action( 'AHEE__EED_Messages___register_routes' ); |
|
127 | + EE_Config::register_route('msg_url_trigger', 'Messages', 'run'); |
|
128 | + EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request'); |
|
129 | + EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
130 | + EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
131 | + do_action('AHEE__EED_Messages___register_routes'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -139,18 +139,18 @@ discard block |
||
139 | 139 | * @since 4.9.0 |
140 | 140 | * @param WP $WP |
141 | 141 | */ |
142 | - public function browser_trigger( $WP ) { |
|
142 | + public function browser_trigger($WP) { |
|
143 | 143 | //ensure controller is loaded |
144 | 144 | self::_load_controller(); |
145 | - $token = EE_Registry::instance()->REQ->get( 'token' ); |
|
145 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
146 | 146 | try { |
147 | - $mtg = new EE_Message_Generated_From_Token( $token, 'html', self::$_message_resource_manager ); |
|
148 | - self::$_MSG_PROCESSOR->generate_and_send_now( $mtg ); |
|
149 | - } catch( EE_Error $e ) { |
|
150 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
147 | + $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
148 | + self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
149 | + } catch (EE_Error $e) { |
|
150 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
151 | 151 | // add specific message for developers if WP_DEBUG in on |
152 | - $error_msg .= '||' . $e->getMessage(); |
|
153 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
152 | + $error_msg .= '||'.$e->getMessage(); |
|
153 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -166,20 +166,20 @@ discard block |
||
166 | 166 | * @since 4.9.0 |
167 | 167 | * @param $WP |
168 | 168 | */ |
169 | - public function browser_error_trigger( $WP ) { |
|
170 | - $token = EE_Registry::instance()->REQ->get( 'token' ); |
|
171 | - if ( $token ) { |
|
172 | - $message = EEM_Message::instance()->get_one_by_token( $token ); |
|
173 | - if ( $message instanceof EE_Message ) { |
|
174 | - header( 'HTTP/1.1 200 OK' ); |
|
175 | - $error_msg = nl2br( $message->error_message() ); |
|
169 | + public function browser_error_trigger($WP) { |
|
170 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
171 | + if ($token) { |
|
172 | + $message = EEM_Message::instance()->get_one_by_token($token); |
|
173 | + if ($message instanceof EE_Message) { |
|
174 | + header('HTTP/1.1 200 OK'); |
|
175 | + $error_msg = nl2br($message->error_message()); |
|
176 | 176 | ?> |
177 | 177 | <!DOCTYPE html> |
178 | 178 | <html> |
179 | 179 | <head></head> |
180 | 180 | <body> |
181 | - <?php echo empty( $error_msg ) |
|
182 | - ? esc_html__( 'Unfortunately, we were unable to capture the error message for this message.', 'event_espresso' ) |
|
181 | + <?php echo empty($error_msg) |
|
182 | + ? esc_html__('Unfortunately, we were unable to capture the error message for this message.', 'event_espresso') |
|
183 | 183 | : wp_kses( |
184 | 184 | $error_msg, |
185 | 185 | array( |
@@ -214,19 +214,19 @@ discard block |
||
214 | 214 | * @throws EE_Error |
215 | 215 | * @return void |
216 | 216 | */ |
217 | - public function run( $WP ) { |
|
217 | + public function run($WP) { |
|
218 | 218 | //ensure controller is loaded |
219 | 219 | self::_load_controller(); |
220 | 220 | // attempt to process message |
221 | 221 | try { |
222 | 222 | /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
223 | - $message_to_generate = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
224 | - self::$_MSG_PROCESSOR->generate_and_send_now( $message_to_generate ); |
|
225 | - } catch ( EE_Error $e ) { |
|
226 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
223 | + $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
224 | + self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
225 | + } catch (EE_Error $e) { |
|
226 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
227 | 227 | // add specific message for developers if WP_DEBUG in on |
228 | - $error_msg .= '||' . $e->getMessage(); |
|
229 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
228 | + $error_msg .= '||'.$e->getMessage(); |
|
229 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | * This is triggered by the 'msg_cron_trigger' route. |
236 | 236 | * @param WP $WP |
237 | 237 | */ |
238 | - public function execute_batch_request( $WP ) { |
|
238 | + public function execute_batch_request($WP) { |
|
239 | 239 | $this->run_cron(); |
240 | - header( 'HTTP/1.1 200 OK' ); |
|
240 | + header('HTTP/1.1 200 OK'); |
|
241 | 241 | exit(); |
242 | 242 | } |
243 | 243 | |
@@ -251,35 +251,35 @@ discard block |
||
251 | 251 | public function run_cron() { |
252 | 252 | self::_load_controller(); |
253 | 253 | //get required vars |
254 | - $cron_type = EE_Registry::instance()->REQ->get( 'type' ); |
|
255 | - $transient_key = EE_Registry::instance()->REQ->get( 'key' ); |
|
254 | + $cron_type = EE_Registry::instance()->REQ->get('type'); |
|
255 | + $transient_key = EE_Registry::instance()->REQ->get('key'); |
|
256 | 256 | |
257 | 257 | //now let's verify transient, if not valid exit immediately |
258 | - if ( ! get_transient( $transient_key ) ) { |
|
258 | + if ( ! get_transient($transient_key)) { |
|
259 | 259 | /** |
260 | 260 | * trigger error so this gets in the error logs. This is important because it happens on a non-user request. |
261 | 261 | */ |
262 | - trigger_error( esc_attr__( 'Invalid Request (Transient does not exist)', 'event_espresso' ) ); |
|
262 | + trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso')); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | //if made it here, lets' delete the transient to keep the db clean |
266 | - delete_transient( $transient_key ); |
|
266 | + delete_transient($transient_key); |
|
267 | 267 | |
268 | - if ( apply_filters( 'FHEE__EED_Messages__run_cron__use_wp_cron', true ) ) { |
|
268 | + if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
|
269 | 269 | |
270 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
271 | - if ( method_exists( self::$_MSG_PROCESSOR, $method ) ) { |
|
270 | + $method = 'batch_'.$cron_type.'_from_queue'; |
|
271 | + if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
272 | 272 | self::$_MSG_PROCESSOR->$method(); |
273 | 273 | } else { |
274 | 274 | //no matching task |
275 | 275 | /** |
276 | 276 | * trigger error so this gets in the error logs. This is important because it happens on a non user request. |
277 | 277 | */ |
278 | - trigger_error( esc_attr( sprintf( __( 'There is no task corresponding to this route %s', 'event_espresso' ), $cron_type ) ) ); |
|
278 | + trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'), $cron_type))); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
282 | - do_action( 'FHEE__EED_Messages__run_cron__end' ); |
|
282 | + do_action('FHEE__EED_Messages__run_cron__end'); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @return EE_Messages_Template_Pack |
297 | 297 | */ |
298 | - public static function get_template_pack( $template_pack_name ) { |
|
299 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
300 | - return EEH_MSG_Template::get_template_pack( $template_pack_name ); |
|
298 | + public static function get_template_pack($template_pack_name) { |
|
299 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
300 | + return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | * @return EE_Messages_Template_Pack[] |
312 | 312 | */ |
313 | 313 | public static function get_template_packs() { |
314 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
314 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
315 | 315 | |
316 | 316 | //for backward compat, let's make sure this returns in the same format as originally. |
317 | 317 | $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
318 | 318 | $template_pack_collection->rewind(); |
319 | 319 | $template_packs = array(); |
320 | - while ( $template_pack_collection->valid() ) { |
|
321 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
320 | + while ($template_pack_collection->valid()) { |
|
321 | + $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current(); |
|
322 | 322 | $template_pack_collection->next(); |
323 | 323 | } |
324 | 324 | return $template_packs; |
@@ -334,14 +334,14 @@ discard block |
||
334 | 334 | * @return void |
335 | 335 | */ |
336 | 336 | public static function set_autoloaders() { |
337 | - if ( empty( self::$_MSG_PATHS ) ) { |
|
337 | + if (empty(self::$_MSG_PATHS)) { |
|
338 | 338 | self::_set_messages_paths(); |
339 | - foreach ( self::$_MSG_PATHS as $path ) { |
|
340 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $path ); |
|
339 | + foreach (self::$_MSG_PATHS as $path) { |
|
340 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
341 | 341 | } |
342 | 342 | // add aliases |
343 | - EEH_Autoloader::add_alias( 'EE_messages', 'EE_messages' ); |
|
344 | - EEH_Autoloader::add_alias( 'EE_messenger', 'EE_messenger' ); |
|
343 | + EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
344 | + EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
@@ -369,10 +369,10 @@ discard block |
||
369 | 369 | 'shortcodes', |
370 | 370 | ); |
371 | 371 | $paths = array(); |
372 | - foreach ( $dir_ref as $index => $dir ) { |
|
373 | - $paths[ $index ] = EE_LIBRARIES . $dir; |
|
372 | + foreach ($dir_ref as $index => $dir) { |
|
373 | + $paths[$index] = EE_LIBRARIES.$dir; |
|
374 | 374 | } |
375 | - self::$_MSG_PATHS = apply_filters( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths ); |
|
375 | + self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -383,12 +383,12 @@ discard block |
||
383 | 383 | * @return void |
384 | 384 | */ |
385 | 385 | protected static function _load_controller() { |
386 | - if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor ) { |
|
387 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
386 | + if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
387 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
388 | 388 | self::set_autoloaders(); |
389 | - self::$_EEMSG = EE_Registry::instance()->load_lib( 'messages' ); |
|
390 | - self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
391 | - self::$_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
389 | + self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
390 | + self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
391 | + self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
392 | 392 | } |
393 | 393 | } |
394 | 394 | |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | /** |
398 | 398 | * @param EE_Transaction $transaction |
399 | 399 | */ |
400 | - public static function payment_reminder( EE_Transaction $transaction ) { |
|
400 | + public static function payment_reminder(EE_Transaction $transaction) { |
|
401 | 401 | self::_load_controller(); |
402 | - $data = array( $transaction, null ); |
|
403 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'payment_reminder', $data ); |
|
402 | + $data = array($transaction, null); |
|
403 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -411,14 +411,14 @@ discard block |
||
411 | 411 | * @param EE_Payment object |
412 | 412 | * @return void |
413 | 413 | */ |
414 | - public static function payment( EE_Transaction $transaction, EE_Payment $payment ) { |
|
414 | + public static function payment(EE_Transaction $transaction, EE_Payment $payment) { |
|
415 | 415 | self::_load_controller(); |
416 | - $data = array( $transaction, $payment ); |
|
417 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
418 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
416 | + $data = array($transaction, $payment); |
|
417 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
418 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
419 | 419 | //if payment amount is less than 0 then switch to payment_refund message type. |
420 | 420 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
421 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
421 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | /** |
427 | 427 | * @param EE_Transaction $transaction |
428 | 428 | */ |
429 | - public static function cancelled_registration( EE_Transaction $transaction ) { |
|
429 | + public static function cancelled_registration(EE_Transaction $transaction) { |
|
430 | 430 | self::_load_controller(); |
431 | - $data = array( $transaction, null ); |
|
432 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'cancelled_registration', $data ); |
|
431 | + $data = array($transaction, null); |
|
432 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | * @param array $extra_details |
443 | 443 | * @return void |
444 | 444 | */ |
445 | - public static function maybe_registration( EE_Registration $registration, $extra_details = array() ) { |
|
445 | + public static function maybe_registration(EE_Registration $registration, $extra_details = array()) { |
|
446 | 446 | |
447 | - if ( ! self::_verify_registration_notification_send( $registration, $extra_details ) ) { |
|
447 | + if ( ! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
448 | 448 | //no messages please |
449 | 449 | return; |
450 | 450 | } |
@@ -459,22 +459,22 @@ discard block |
||
459 | 459 | $mtgs = array(); |
460 | 460 | |
461 | 461 | //loop through registrations and trigger messages once per status. |
462 | - foreach ( $all_registrations as $reg ) { |
|
462 | + foreach ($all_registrations as $reg) { |
|
463 | 463 | |
464 | 464 | //already triggered? |
465 | - if ( in_array( $reg->status_ID(), $statuses_sent ) ) { |
|
465 | + if (in_array($reg->status_ID(), $statuses_sent)) { |
|
466 | 466 | continue; |
467 | 467 | } |
468 | 468 | |
469 | - $message_type = EEH_MSG_Template::convert_reg_status_to_message_type( $reg->status_ID() ); |
|
470 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( $message_type, array( $registration->transaction(), null, $reg->status_ID() ) ); |
|
469 | + $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
470 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers($message_type, array($registration->transaction(), null, $reg->status_ID())); |
|
471 | 471 | $statuses_sent[] = $reg->status_ID(); |
472 | 472 | } |
473 | 473 | |
474 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( 'registration_summary', array( $registration->transaction(), null ) ); |
|
474 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers('registration_summary', array($registration->transaction(), null)); |
|
475 | 475 | |
476 | 476 | //batch queue and initiate request |
477 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $mtgs ); |
|
477 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
478 | 478 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
479 | 479 | } |
480 | 480 | |
@@ -489,39 +489,39 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return bool true = send away, false = nope halt the presses. |
491 | 491 | */ |
492 | - protected static function _verify_registration_notification_send( EE_Registration $registration, $extra_details = array() ) { |
|
492 | + protected static function _verify_registration_notification_send(EE_Registration $registration, $extra_details = array()) { |
|
493 | 493 | //self::log( |
494 | 494 | // __CLASS__, __FUNCTION__, __LINE__, |
495 | 495 | // $registration->transaction(), |
496 | 496 | // array( '$extra_details' => $extra_details ) |
497 | 497 | //); |
498 | 498 | // currently only using this to send messages for the primary registrant |
499 | - if ( ! $registration->is_primary_registrant() ) { |
|
499 | + if ( ! $registration->is_primary_registrant()) { |
|
500 | 500 | return false; |
501 | 501 | } |
502 | 502 | // first we check if we're in admin and not doing front ajax |
503 | - if ( is_admin() && ! EE_FRONT_AJAX ) { |
|
503 | + if (is_admin() && ! EE_FRONT_AJAX) { |
|
504 | 504 | //make sure appropriate admin params are set for sending messages |
505 | - if ( empty( $_REQUEST['txn_reg_status_change']['send_notifications'] ) || ! absint( $_REQUEST['txn_reg_status_change']['send_notifications'] ) ) { |
|
505 | + if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) { |
|
506 | 506 | //no messages sent please. |
507 | 507 | return false; |
508 | 508 | } |
509 | 509 | } else { |
510 | 510 | // frontend request (either regular or via AJAX) |
511 | 511 | // TXN is NOT finalized ? |
512 | - if ( ! isset( $extra_details['finalized'] ) || $extra_details['finalized'] === false ) { |
|
512 | + if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
513 | 513 | return false; |
514 | 514 | } |
515 | 515 | // return visit but nothing changed ??? |
516 | 516 | if ( |
517 | - isset( $extra_details['revisit'], $extra_details['status_updates'] ) && |
|
517 | + isset($extra_details['revisit'], $extra_details['status_updates']) && |
|
518 | 518 | $extra_details['revisit'] && ! $extra_details['status_updates'] |
519 | 519 | ) { |
520 | 520 | return false; |
521 | 521 | } |
522 | 522 | // NOT sending messages && reg status is something other than "Not-Approved" |
523 | 523 | if ( |
524 | - ! apply_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', false ) && |
|
524 | + ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
525 | 525 | $registration->status_ID() !== EEM_Registration::status_id_not_approved |
526 | 526 | ) { |
527 | 527 | return false; |
@@ -543,10 +543,10 @@ discard block |
||
543 | 543 | * |
544 | 544 | * @return array |
545 | 545 | */ |
546 | - protected static function _get_reg_status_array( $reg_status = '' ) { |
|
547 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
548 | - return EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
549 | - ? EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
546 | + protected static function _get_reg_status_array($reg_status = '') { |
|
547 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
548 | + return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
549 | + ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
550 | 550 | : EEH_MSG_Template::reg_status_to_message_type_array(); |
551 | 551 | } |
552 | 552 | |
@@ -562,10 +562,10 @@ discard block |
||
562 | 562 | * |
563 | 563 | * @return string|bool The payment message type slug matching the status or false if no match. |
564 | 564 | */ |
565 | - protected static function _get_payment_message_type( $payment_status ) { |
|
566 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
567 | - return EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
568 | - ? EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
565 | + protected static function _get_payment_message_type($payment_status) { |
|
566 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
567 | + return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
568 | + ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
569 | 569 | : false; |
570 | 570 | } |
571 | 571 | |
@@ -579,33 +579,33 @@ discard block |
||
579 | 579 | * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
580 | 580 | * @return bool success/fail |
581 | 581 | */ |
582 | - public static function process_resend( $req_data ) { |
|
582 | + public static function process_resend($req_data) { |
|
583 | 583 | self::_load_controller(); |
584 | 584 | |
585 | 585 | //if $msgID in this request then skip to the new resend_message |
586 | - if ( EE_Registry::instance()->REQ->get( 'MSG_ID' ) ) { |
|
586 | + if (EE_Registry::instance()->REQ->get('MSG_ID')) { |
|
587 | 587 | return self::resend_message(); |
588 | 588 | } |
589 | 589 | |
590 | 590 | //make sure any incoming request data is set on the REQ so that it gets picked up later. |
591 | 591 | $req_data = (array) $req_data; |
592 | - foreach( $req_data as $request_key => $request_value ) { |
|
593 | - EE_Registry::instance()->REQ->set( $request_key, $request_value ); |
|
592 | + foreach ($req_data as $request_key => $request_value) { |
|
593 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
594 | 594 | } |
595 | 595 | |
596 | - if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() ) { |
|
596 | + if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) { |
|
597 | 597 | return false; |
598 | 598 | } |
599 | 599 | |
600 | 600 | try { |
601 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $messages_to_send ); |
|
601 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
602 | 602 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
603 | - } catch( EE_Error $e ) { |
|
604 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
603 | + } catch (EE_Error $e) { |
|
604 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
605 | 605 | return false; |
606 | 606 | } |
607 | 607 | EE_Error::add_success( |
608 | - __( 'Messages have been successfully queued for generation and sending.', 'event_espresso' ) |
|
608 | + __('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
609 | 609 | ); |
610 | 610 | return true; //everything got queued. |
611 | 611 | } |
@@ -618,17 +618,17 @@ discard block |
||
618 | 618 | public static function resend_message() { |
619 | 619 | self::_load_controller(); |
620 | 620 | |
621 | - $msgID = EE_Registry::instance()->REQ->get( 'MSG_ID' ); |
|
622 | - if ( ! $msgID ) { |
|
623 | - EE_Error::add_error( __( 'Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
621 | + $msgID = EE_Registry::instance()->REQ->get('MSG_ID'); |
|
622 | + if ( ! $msgID) { |
|
623 | + EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
624 | 624 | return false; |
625 | 625 | } |
626 | 626 | |
627 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( (array) $msgID ); |
|
627 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
628 | 628 | |
629 | 629 | //setup success message. |
630 | - $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
631 | - EE_Error::add_success( sprintf( |
|
630 | + $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
631 | + EE_Error::add_success(sprintf( |
|
632 | 632 | _n( |
633 | 633 | 'There was %d message queued for resending.', |
634 | 634 | 'There were %d messages queued for resending.', |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | 'event_espresso' |
637 | 637 | ), |
638 | 638 | $count_ready_for_resend |
639 | - ) ); |
|
639 | + )); |
|
640 | 640 | return true; |
641 | 641 | } |
642 | 642 | |
@@ -649,13 +649,13 @@ discard block |
||
649 | 649 | * @param EE_Payment $payment EE_payment object |
650 | 650 | * @return bool success/fail |
651 | 651 | */ |
652 | - public static function process_admin_payment( EE_Payment $payment ) { |
|
653 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
652 | + public static function process_admin_payment(EE_Payment $payment) { |
|
653 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
654 | 654 | //we need to get the transaction object |
655 | 655 | $transaction = $payment->transaction(); |
656 | - if ( $transaction instanceof EE_Transaction ) { |
|
657 | - $data = array( $transaction, $payment ); |
|
658 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
656 | + if ($transaction instanceof EE_Transaction) { |
|
657 | + $data = array($transaction, $payment); |
|
658 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
659 | 659 | |
660 | 660 | //if payment amount is less than 0 then switch to payment_refund message type. |
661 | 661 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
@@ -665,22 +665,22 @@ discard block |
||
665 | 665 | |
666 | 666 | self::_load_controller(); |
667 | 667 | |
668 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
668 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
669 | 669 | |
670 | 670 | //get count of queued for generation |
671 | - $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( array( EEM_Message::status_incomplete, EEM_Message::status_idle ) ); |
|
671 | + $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(array(EEM_Message::status_incomplete, EEM_Message::status_idle)); |
|
672 | 672 | |
673 | - if ( $count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0 ) { |
|
674 | - add_filter( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true' ); |
|
673 | + if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) { |
|
674 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
675 | 675 | return true; |
676 | 676 | } else { |
677 | - $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::instance()->stati_indicating_failed_sending() ); |
|
677 | + $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending()); |
|
678 | 678 | /** |
679 | 679 | * Verify that there are actually errors. If not then we return a success message because the queue might have been emptied due to successful |
680 | 680 | * IMMEDIATE generation. |
681 | 681 | */ |
682 | - if ( $count_failed > 0 ) { |
|
683 | - EE_Error::add_error( sprintf( |
|
682 | + if ($count_failed > 0) { |
|
683 | + EE_Error::add_error(sprintf( |
|
684 | 684 | _n( |
685 | 685 | 'The payment notification generation failed.', |
686 | 686 | '%d payment notifications failed being sent.', |
@@ -688,11 +688,11 @@ discard block |
||
688 | 688 | 'event_espresso' |
689 | 689 | ), |
690 | 690 | $count_failed |
691 | - ), __FILE__, __FUNCTION__, __LINE__ ); |
|
691 | + ), __FILE__, __FUNCTION__, __LINE__); |
|
692 | 692 | |
693 | 693 | return false; |
694 | 694 | } else { |
695 | - add_filter( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true' ); |
|
695 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
696 | 696 | return true; |
697 | 697 | } |
698 | 698 | } |
@@ -716,11 +716,11 @@ discard block |
||
716 | 716 | * @param int $grp_id a specific message template group id. |
717 | 717 | * @return void |
718 | 718 | */ |
719 | - public static function send_newsletter_message( $registrations, $grp_id ) { |
|
719 | + public static function send_newsletter_message($registrations, $grp_id) { |
|
720 | 720 | //make sure mtp is id and set it in the EE_Request Handler later messages setup. |
721 | - EE_Registry::instance()->REQ->set( 'GRP_ID', (int) $grp_id ); |
|
721 | + EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id); |
|
722 | 722 | self::_load_controller(); |
723 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'newsletter', $registrations ); |
|
723 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | |
@@ -735,9 +735,9 @@ discard block |
||
735 | 735 | * @param string $message_type |
736 | 736 | * @return string |
737 | 737 | */ |
738 | - public static function registration_message_trigger_url( $registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice' ) { |
|
738 | + public static function registration_message_trigger_url($registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice') { |
|
739 | 739 | // whitelist $messenger |
740 | - switch ( $messenger ) { |
|
740 | + switch ($messenger) { |
|
741 | 741 | case 'pdf' : |
742 | 742 | $sending_messenger = 'pdf'; |
743 | 743 | $generating_messenger = 'html'; |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | break; |
750 | 750 | } |
751 | 751 | // whitelist $message_type |
752 | - switch ( $message_type ) { |
|
752 | + switch ($message_type) { |
|
753 | 753 | case 'receipt' : |
754 | 754 | $message_type = 'receipt'; |
755 | 755 | break; |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | break; |
760 | 760 | } |
761 | 761 | // verify that both the messenger AND the message type are active |
762 | - if ( EEH_MSG_Template::is_messenger_active( $sending_messenger ) && EEH_MSG_Template::is_mt_active( $message_type ) ) { |
|
762 | + if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) { |
|
763 | 763 | //need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?) |
764 | 764 | $template_query_params = array( |
765 | 765 | 'MTP_is_active' => true, |
@@ -768,16 +768,16 @@ discard block |
||
768 | 768 | 'Event.EVT_ID' => $registration->event_ID() |
769 | 769 | ); |
770 | 770 | //get the message template group. |
771 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
771 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
772 | 772 | //if we don't have an EE_Message_Template_Group then return |
773 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
773 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
774 | 774 | // remove EVT_ID from query params so that global templates get picked up |
775 | - unset( $template_query_params['Event.EVT_ID'] ); |
|
775 | + unset($template_query_params['Event.EVT_ID']); |
|
776 | 776 | //get global template as the fallback |
777 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
777 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
778 | 778 | } |
779 | 779 | //if we don't have an EE_Message_Template_Group then return |
780 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
780 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
781 | 781 | return ''; |
782 | 782 | } |
783 | 783 | // generate the URL |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
807 | 807 | * @return string|bool The body of the message or if send is requested, sends. |
808 | 808 | */ |
809 | - public static function preview_message( $type, $context, $messenger, $send = false ) { |
|
809 | + public static function preview_message($type, $context, $messenger, $send = false) { |
|
810 | 810 | self::_load_controller(); |
811 | 811 | $mtg = new EE_Message_To_Generate( |
812 | 812 | $messenger, |
@@ -815,8 +815,8 @@ discard block |
||
815 | 815 | $context, |
816 | 816 | true |
817 | 817 | ); |
818 | - $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview( $mtg, $send ); |
|
819 | - if ( $generated_preview_queue instanceof EE_Messages_Queue ) { |
|
818 | + $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send); |
|
819 | + if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
820 | 820 | return $generated_preview_queue->get_message_repository()->current()->content(); |
821 | 821 | } else { |
822 | 822 | return $generated_preview_queue; |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * |
844 | 844 | * @return bool success or fail. |
845 | 845 | */ |
846 | - public static function send_message_with_messenger_only( $messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '' ) { |
|
846 | + public static function send_message_with_messenger_only($messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '') { |
|
847 | 847 | self::_load_controller(); |
848 | 848 | /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
849 | 849 | $message_to_generate = EE_Registry::instance()->load_lib( |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | $custom_subject, |
856 | 856 | ) |
857 | 857 | ); |
858 | - return self::$_MSG_PROCESSOR->queue_for_sending( $message_to_generate ); |
|
858 | + return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | |
@@ -868,22 +868,22 @@ discard block |
||
868 | 868 | * @param array $message_ids An array of message ids |
869 | 869 | * @return bool | EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated messages. |
870 | 870 | */ |
871 | - public static function generate_now( $message_ids ) { |
|
871 | + public static function generate_now($message_ids) { |
|
872 | 872 | self::_load_controller(); |
873 | 873 | $messages = EEM_Message::instance()->get_all( |
874 | 874 | array( |
875 | 875 | 0 => array( |
876 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
876 | + 'MSG_ID' => array('IN', $message_ids), |
|
877 | 877 | 'STS_ID' => EEM_Message::status_incomplete, |
878 | 878 | ) |
879 | 879 | ) |
880 | 880 | ); |
881 | 881 | |
882 | - $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue( $messages ); |
|
882 | + $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
883 | 883 | |
884 | - if ( ! $generated_queue instanceof EE_Messages_Queue ) { |
|
884 | + if ( ! $generated_queue instanceof EE_Messages_Queue) { |
|
885 | 885 | EE_Error::add_error( |
886 | - __( 'The messages were not generated. This is usually because there is already a batch being generated on a separate request. You can wait a minute or two and try again.', 'event_espresso' ), |
|
886 | + __('The messages were not generated. This is usually because there is already a batch being generated on a separate request. You can wait a minute or two and try again.', 'event_espresso'), |
|
887 | 887 | __FILE__, __FUNCTION__, __LINE__ |
888 | 888 | ); |
889 | 889 | } |
@@ -902,28 +902,28 @@ discard block |
||
902 | 902 | * |
903 | 903 | * @return bool | EE_Messages_Queue false if no messages sent. |
904 | 904 | */ |
905 | - public static function send_now( $message_ids ) { |
|
905 | + public static function send_now($message_ids) { |
|
906 | 906 | self::_load_controller(); |
907 | 907 | $messages = EEM_Message::instance()->get_all( |
908 | 908 | array( |
909 | 909 | 0 => array( |
910 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
911 | - 'STS_ID' => array( 'IN', array( EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry ) ) |
|
910 | + 'MSG_ID' => array('IN', $message_ids), |
|
911 | + 'STS_ID' => array('IN', array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry)) |
|
912 | 912 | ) |
913 | 913 | ) |
914 | 914 | ); |
915 | 915 | |
916 | - $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue( $messages ); |
|
916 | + $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
917 | 917 | |
918 | - if ( ! $sent_queue instanceof EE_Messages_Queue ) { |
|
918 | + if ( ! $sent_queue instanceof EE_Messages_Queue) { |
|
919 | 919 | EE_Error::add_error( |
920 | - __( 'The messages were not sent. This is usually because there is already a batch being sent on a separate request. You can wait a minute or two and try again.', 'event_espresso' ), |
|
920 | + __('The messages were not sent. This is usually because there is already a batch being sent on a separate request. You can wait a minute or two and try again.', 'event_espresso'), |
|
921 | 921 | __FILE__, __FUNCTION__, __LINE__ |
922 | 922 | ); |
923 | 923 | } else { |
924 | 924 | //can count how many sent by using the messages in the queue |
925 | - $sent_count = $sent_queue->count_STS_in_queue( EEM_Message::instance()->stati_indicating_sent() ); |
|
926 | - if ( $sent_count > 0 ) { |
|
925 | + $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
926 | + if ($sent_count > 0) { |
|
927 | 927 | EE_Error::add_success( |
928 | 928 | sprintf( |
929 | 929 | _n( |
@@ -938,8 +938,8 @@ discard block |
||
938 | 938 | } else { |
939 | 939 | EE_Error::overwrite_errors(); |
940 | 940 | EE_Error::add_error( |
941 | - __( 'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
942 | - If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso' ), |
|
941 | + __('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
942 | + If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso'), |
|
943 | 943 | __FILE__, __FUNCTION__, __LINE__ |
944 | 944 | ); |
945 | 945 | } |
@@ -960,13 +960,13 @@ discard block |
||
960 | 960 | * |
961 | 961 | * @return bool true means messages were successfully queued for resending, false means none were queued for resending. |
962 | 962 | */ |
963 | - public static function queue_for_resending( $message_ids ) { |
|
963 | + public static function queue_for_resending($message_ids) { |
|
964 | 964 | self::_load_controller(); |
965 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( $message_ids ); |
|
965 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
966 | 966 | |
967 | 967 | //get queue and count |
968 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
969 | - if ( $queue_count > 0 ) { |
|
968 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
969 | + if ($queue_count > 0) { |
|
970 | 970 | EE_Error::add_success( |
971 | 971 | sprintf( |
972 | 972 | _n( |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | ); |
981 | 981 | } else { |
982 | 982 | EE_Error::add_error( |
983 | - __( 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso' ), |
|
983 | + __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso'), |
|
984 | 984 | __FILE__, __FUNCTION__, __LINE__ |
985 | 985 | ); |
986 | 986 | } |
@@ -1002,16 +1002,16 @@ discard block |
||
1002 | 1002 | * @param array $info |
1003 | 1003 | * @param bool $display_request |
1004 | 1004 | */ |
1005 | - protected static function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) { |
|
1006 | - if ( WP_DEBUG && false ) { |
|
1007 | - if ( $transaction instanceof EE_Transaction ) { |
|
1005 | + protected static function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) { |
|
1006 | + if (WP_DEBUG && false) { |
|
1007 | + if ($transaction instanceof EE_Transaction) { |
|
1008 | 1008 | // don't serialize objects |
1009 | - $info = EEH_Debug_Tools::strip_objects( $info ); |
|
1009 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
1010 | 1010 | $info['TXN_status'] = $transaction->status_ID(); |
1011 | 1011 | $info['TXN_reg_steps'] = $transaction->reg_steps(); |
1012 | - if ( $transaction->ID() ) { |
|
1013 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1014 | - EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index ); |
|
1012 | + if ($transaction->ID()) { |
|
1013 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
1014 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param EE_Message_Resource_Manager $message_resource_manager |
37 | 37 | */ |
38 | - public function __construct( EE_Message_Resource_Manager $message_resource_manager ) { |
|
38 | + public function __construct(EE_Message_Resource_Manager $message_resource_manager) { |
|
39 | 39 | $this->_message_resource_manager = $message_resource_manager; |
40 | 40 | $this->_init_queue_and_generator(); |
41 | 41 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * - $_generator = holds the messages generator |
51 | 51 | */ |
52 | 52 | protected function _init_queue_and_generator() { |
53 | - $this->_generator = EE_Registry::factory( 'EE_Messages_Generator' ); |
|
53 | + $this->_generator = EE_Registry::factory('EE_Messages_Generator'); |
|
54 | 54 | $this->_queue = $this->_generator->generation_queue(); |
55 | 55 | } |
56 | 56 | |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | * @return bool|EE_Messages_Queue return false if nothing generated. This returns a new EE_Message_Queue with |
76 | 76 | * generated messages. |
77 | 77 | */ |
78 | - public function batch_generate_from_queue( $messages = array(), $clear_queue = false ) { |
|
79 | - if ( $this->_build_queue_for_generation( $messages, $clear_queue ) ) { |
|
78 | + public function batch_generate_from_queue($messages = array(), $clear_queue = false) { |
|
79 | + if ($this->_build_queue_for_generation($messages, $clear_queue)) { |
|
80 | 80 | $new_queue = $this->_generator->generate(); |
81 | - if ( $new_queue instanceof EE_Messages_Queue ) { |
|
81 | + if ($new_queue instanceof EE_Messages_Queue) { |
|
82 | 82 | //unlock queue |
83 | 83 | $this->_queue->unlock_queue(); |
84 | - $this->_queue->initiate_request_by_priority( 'send' ); |
|
84 | + $this->_queue->initiate_request_by_priority('send'); |
|
85 | 85 | return $new_queue; |
86 | 86 | } |
87 | 87 | } |
@@ -102,24 +102,24 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return bool true means queue prepped, false means there was a lock so no generation please. |
104 | 104 | */ |
105 | - protected function _build_queue_for_generation( $messages = array(), $clear_queue = false ) { |
|
105 | + protected function _build_queue_for_generation($messages = array(), $clear_queue = false) { |
|
106 | 106 | |
107 | - if ( $clear_queue ) { |
|
107 | + if ($clear_queue) { |
|
108 | 108 | $this->_init_queue_and_generator(); |
109 | 109 | } |
110 | 110 | |
111 | - if ( $messages ) { |
|
111 | + if ($messages) { |
|
112 | 112 | //if generation is locked then get out now because that means processing is already happening. |
113 | - if ( $this->_queue->is_locked() ) { |
|
113 | + if ($this->_queue->is_locked()) { |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | |
117 | 117 | $this->_queue->lock_queue(); |
118 | - $messages = is_array( $messages ) ? $messages : array( $messages ); |
|
119 | - foreach ( $messages as $message ) { |
|
120 | - if ( $message instanceof EE_Message ) { |
|
118 | + $messages = is_array($messages) ? $messages : array($messages); |
|
119 | + foreach ($messages as $message) { |
|
120 | + if ($message instanceof EE_Message) { |
|
121 | 121 | $data = $message->all_extra_meta_array(); |
122 | - $this->_queue->add( $message, $data ); |
|
122 | + $this->_queue->add($message, $data); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | return true; |
@@ -137,22 +137,22 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return bool true means queue prepped, false means there was a lock so no queue prepped. |
139 | 139 | */ |
140 | - protected function _build_queue_for_sending( $messages, $clear_queue = false ) { |
|
140 | + protected function _build_queue_for_sending($messages, $clear_queue = false) { |
|
141 | 141 | //if sending is locked then get out now because that means processing is already happening. |
142 | - if ( $this->_queue->is_locked( EE_Messages_Queue::action_sending ) ) { |
|
142 | + if ($this->_queue->is_locked(EE_Messages_Queue::action_sending)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | - $this->_queue->lock_queue( EE_Messages_Queue::action_sending ); |
|
146 | + $this->_queue->lock_queue(EE_Messages_Queue::action_sending); |
|
147 | 147 | |
148 | - if ( $clear_queue ) { |
|
148 | + if ($clear_queue) { |
|
149 | 149 | $this->_init_queue_and_generator(); |
150 | 150 | } |
151 | 151 | |
152 | - $messages = is_array( $messages ) ? $messages : array( $messages ); |
|
152 | + $messages = is_array($messages) ? $messages : array($messages); |
|
153 | 153 | |
154 | - foreach ( $messages as $message ) { |
|
155 | - $this->_queue->add( $message ); |
|
154 | + foreach ($messages as $message) { |
|
155 | + $this->_queue->add($message); |
|
156 | 156 | } |
157 | 157 | return true; |
158 | 158 | } |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return EE_Messages_Queue |
170 | 170 | */ |
171 | - public function batch_send_from_queue( $messages = array(), $clear_queue = false ) { |
|
171 | + public function batch_send_from_queue($messages = array(), $clear_queue = false) { |
|
172 | 172 | |
173 | - if ( $messages && $this->_build_queue_for_sending( $messages, $clear_queue ) ) { |
|
173 | + if ($messages && $this->_build_queue_for_sending($messages, $clear_queue)) { |
|
174 | 174 | $this->_queue->execute(); |
175 | - $this->_queue->unlock_queue( EE_Messages_Queue::action_sending ); |
|
175 | + $this->_queue->unlock_queue(EE_Messages_Queue::action_sending); |
|
176 | 176 | } else { |
177 | 177 | //get messages to send and execute. |
178 | 178 | $this->_queue->get_to_send_batch_and_send(); |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | * @param EE_Message_To_Generate[] $messages_to_generate |
196 | 196 | * @return EE_Messages_Queue |
197 | 197 | */ |
198 | - public function generate_and_return( $messages_to_generate ) { |
|
198 | + public function generate_and_return($messages_to_generate) { |
|
199 | 199 | $this->_init_queue_and_generator(); |
200 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
201 | - return $this->_generator->generate( false ); |
|
200 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
201 | + return $this->_generator->generate(false); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | * @param bool $persist Indicate whether to instruct the generator to persist the generated queue (true) or not (false). |
210 | 210 | * @return EE_Messages_Queue |
211 | 211 | */ |
212 | - public function generate_queue( $persist = true ) { |
|
213 | - return $this->_generator->generate( $persist ); |
|
212 | + public function generate_queue($persist = true) { |
|
213 | + return $this->_generator->generate($persist); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | * @param bool $test_send Whether this item is for a test send or not. |
224 | 224 | * @return EE_Messages_Queue |
225 | 225 | */ |
226 | - public function queue_for_generation( EE_Message_To_Generate $message_to_generate, $test_send = false ) { |
|
227 | - if ( $message_to_generate->valid() ) { |
|
228 | - $this->_generator->create_and_add_message_to_queue( $message_to_generate, $test_send ); |
|
226 | + public function queue_for_generation(EE_Message_To_Generate $message_to_generate, $test_send = false) { |
|
227 | + if ($message_to_generate->valid()) { |
|
228 | + $this->_generator->create_and_add_message_to_queue($message_to_generate, $test_send); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @param EE_Message_To_Generate[] $messages_to_generate |
243 | 243 | */ |
244 | - public function batch_queue_for_generation_and_persist( $messages_to_generate ) { |
|
244 | + public function batch_queue_for_generation_and_persist($messages_to_generate) { |
|
245 | 245 | $this->_init_queue_and_generator(); |
246 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
246 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
247 | 247 | $this->_queue->save(); |
248 | 248 | } |
249 | 249 | |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @param EE_Message_To_Generate[] $messages_to_generate |
261 | 261 | */ |
262 | - public function batch_queue_for_generation_no_persist( $messages_to_generate ) { |
|
262 | + public function batch_queue_for_generation_no_persist($messages_to_generate) { |
|
263 | 263 | $this->_init_queue_and_generator(); |
264 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
264 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -273,15 +273,15 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @param EE_Message_To_Generate[] $messages_to_generate |
275 | 275 | */ |
276 | - protected function _queue_for_generation_loop( $messages_to_generate ) { |
|
276 | + protected function _queue_for_generation_loop($messages_to_generate) { |
|
277 | 277 | //make sure is in an array. |
278 | - if ( ! is_array( $messages_to_generate ) ) { |
|
279 | - $messages_to_generate = array( $messages_to_generate ); |
|
278 | + if ( ! is_array($messages_to_generate)) { |
|
279 | + $messages_to_generate = array($messages_to_generate); |
|
280 | 280 | } |
281 | 281 | |
282 | - foreach ( $messages_to_generate as $message_to_generate ) { |
|
283 | - if ( $message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid() ) { |
|
284 | - $this->queue_for_generation( $message_to_generate ); |
|
282 | + foreach ($messages_to_generate as $message_to_generate) { |
|
283 | + if ($message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid()) { |
|
284 | + $this->queue_for_generation($message_to_generate); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | } |
@@ -296,10 +296,10 @@ discard block |
||
296 | 296 | * @param EE_Message_To_Generate[] |
297 | 297 | * @return EE_Messages_Queue |
298 | 298 | */ |
299 | - public function generate_and_queue_for_sending( $messages_to_generate ) { |
|
299 | + public function generate_and_queue_for_sending($messages_to_generate) { |
|
300 | 300 | $this->_init_queue_and_generator(); |
301 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
302 | - return $this->_generator->generate( true ); |
|
301 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
302 | + return $this->_generator->generate(true); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | * @param bool $test_send Whether this is a test send or not. |
314 | 314 | * @return EE_Messages_Queue | bool false if unable to generate otherwise the generated queue. |
315 | 315 | */ |
316 | - public function generate_for_preview( EE_Message_To_Generate $message_to_generate, $test_send = false ) { |
|
317 | - if ( ! $message_to_generate->valid() ) { |
|
316 | + public function generate_for_preview(EE_Message_To_Generate $message_to_generate, $test_send = false) { |
|
317 | + if ( ! $message_to_generate->valid()) { |
|
318 | 318 | EE_Error::add_error( |
319 | - __( 'Unable to generate preview because of invalid data', 'event_espresso' ), |
|
319 | + __('Unable to generate preview because of invalid data', 'event_espresso'), |
|
320 | 320 | __FILE__, |
321 | 321 | __FUNCTION__, |
322 | 322 | __LINE__ |
@@ -324,14 +324,14 @@ discard block |
||
324 | 324 | return false; |
325 | 325 | } |
326 | 326 | //just make sure preview is set on the $message_to_generate (in case client forgot) |
327 | - $message_to_generate->set_preview( true ); |
|
327 | + $message_to_generate->set_preview(true); |
|
328 | 328 | $this->_init_queue_and_generator(); |
329 | - $this->queue_for_generation( $message_to_generate, $test_send ); |
|
330 | - $generated_queue = $this->_generator->generate( false ); |
|
331 | - if ( $generated_queue->execute( false ) ) { |
|
329 | + $this->queue_for_generation($message_to_generate, $test_send); |
|
330 | + $generated_queue = $this->_generator->generate(false); |
|
331 | + if ($generated_queue->execute(false)) { |
|
332 | 332 | //the first queue item should be the preview |
333 | 333 | $generated_queue->get_message_repository()->rewind(); |
334 | - if ( ! $generated_queue->get_message_repository()->valid() ) { |
|
334 | + if ( ! $generated_queue->get_message_repository()->valid()) { |
|
335 | 335 | return $generated_queue; |
336 | 336 | } |
337 | 337 | return $generated_queue->get_message_repository()->is_test_send() ? true : $generated_queue; |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | * @param EE_Message_To_Generate $message_to_generate |
349 | 349 | * @return bool true or false for success. |
350 | 350 | */ |
351 | - public function queue_for_sending( EE_Message_To_Generate $message_to_generate ) { |
|
352 | - if ( ! $message_to_generate->valid() ) { |
|
351 | + public function queue_for_sending(EE_Message_To_Generate $message_to_generate) { |
|
352 | + if ( ! $message_to_generate->valid()) { |
|
353 | 353 | return false; |
354 | 354 | } |
355 | 355 | $this->_init_queue_and_generator(); |
356 | 356 | $message = $message_to_generate->get_EE_Message(); |
357 | - $this->_queue->add( $message ); |
|
358 | - if ( $message->send_now() ) { |
|
359 | - $this->_queue->execute( false ); |
|
357 | + $this->_queue->add($message); |
|
358 | + if ($message->send_now()) { |
|
359 | + $this->_queue->execute(false); |
|
360 | 360 | } else { |
361 | 361 | $this->_queue->save(); |
362 | 362 | } |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | * @param EE_Message_To_Generate $message_to_generate |
370 | 370 | * @return EE_Messages_Queue | null |
371 | 371 | */ |
372 | - public function generate_and_send_now( EE_Message_To_Generate $message_to_generate ) { |
|
373 | - if ( ! $message_to_generate->valid() ) { |
|
372 | + public function generate_and_send_now(EE_Message_To_Generate $message_to_generate) { |
|
373 | + if ( ! $message_to_generate->valid()) { |
|
374 | 374 | return null; |
375 | 375 | } |
376 | 376 | // is there supposed to be a sending messenger for this message? |
377 | - if ( $message_to_generate instanceof EEI_Has_Sending_Messenger ) { |
|
377 | + if ($message_to_generate instanceof EEI_Has_Sending_Messenger) { |
|
378 | 378 | // make sure it's valid, but if it's not, |
379 | 379 | // then set the value of $sending_messenger to an EE_Error object |
380 | 380 | // so that downstream code can easily see that things went wrong. |
@@ -390,14 +390,14 @@ discard block |
||
390 | 390 | $sending_messenger = null; |
391 | 391 | } |
392 | 392 | |
393 | - if ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle ) { |
|
393 | + if ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle) { |
|
394 | 394 | $this->_init_queue_and_generator(); |
395 | - $this->_queue->add( $message_to_generate->get_EE_Message() ); |
|
396 | - $this->_queue->execute( false, $sending_messenger ); |
|
395 | + $this->_queue->add($message_to_generate->get_EE_Message()); |
|
396 | + $this->_queue->execute(false, $sending_messenger); |
|
397 | 397 | return $this->_queue; |
398 | - } elseif ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete ) { |
|
399 | - $generated_queue = $this->generate_and_return( array( $message_to_generate ) ); |
|
400 | - $generated_queue->execute( false, $sending_messenger ); |
|
398 | + } elseif ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete) { |
|
399 | + $generated_queue = $this->generate_and_return(array($message_to_generate)); |
|
400 | + $generated_queue->execute(false, $sending_messenger); |
|
401 | 401 | return $generated_queue; |
402 | 402 | } |
403 | 403 | return null; |
@@ -414,13 +414,13 @@ discard block |
||
414 | 414 | * @param mixed $data The data being used for generation. |
415 | 415 | * @param bool $persist Whether to persist the queued messages to the db or not. |
416 | 416 | */ |
417 | - public function generate_for_all_active_messengers( $message_type, $data, $persist = true ) { |
|
418 | - $messages_to_generate = $this->setup_mtgs_for_all_active_messengers( $message_type, $data ); |
|
419 | - if ( $persist ) { |
|
420 | - $this->batch_queue_for_generation_and_persist( $messages_to_generate ); |
|
417 | + public function generate_for_all_active_messengers($message_type, $data, $persist = true) { |
|
418 | + $messages_to_generate = $this->setup_mtgs_for_all_active_messengers($message_type, $data); |
|
419 | + if ($persist) { |
|
420 | + $this->batch_queue_for_generation_and_persist($messages_to_generate); |
|
421 | 421 | $this->_queue->initiate_request_by_priority(); |
422 | 422 | } else { |
423 | - $this->batch_queue_for_generation_no_persist( $messages_to_generate ); |
|
423 | + $this->batch_queue_for_generation_no_persist($messages_to_generate); |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 | |
@@ -435,11 +435,11 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return EE_Message_To_Generate[] |
437 | 437 | */ |
438 | - public function setup_mtgs_for_all_active_messengers( $message_type, $data ) { |
|
438 | + public function setup_mtgs_for_all_active_messengers($message_type, $data) { |
|
439 | 439 | $messages_to_generate = array(); |
440 | - foreach ( $this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object ) { |
|
441 | - $message_to_generate = new EE_Message_To_Generate( $messenger_slug, $message_type, $data ); |
|
442 | - if ( $message_to_generate->valid() ) { |
|
440 | + foreach ($this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object) { |
|
441 | + $message_to_generate = new EE_Message_To_Generate($messenger_slug, $message_type, $data); |
|
442 | + if ($message_to_generate->valid()) { |
|
443 | 443 | $messages_to_generate[] = $message_to_generate; |
444 | 444 | } |
445 | 445 | } |
@@ -454,23 +454,23 @@ discard block |
||
454 | 454 | * and send. |
455 | 455 | * @param array $message_ids |
456 | 456 | */ |
457 | - public function setup_messages_from_ids_and_send( $message_ids ) { |
|
457 | + public function setup_messages_from_ids_and_send($message_ids) { |
|
458 | 458 | $this->_init_queue_and_generator(); |
459 | - $messages = EEM_Message::instance()->get_all( array( |
|
459 | + $messages = EEM_Message::instance()->get_all(array( |
|
460 | 460 | array( |
461 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
462 | - 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_sent() ) |
|
461 | + 'MSG_ID' => array('IN', $message_ids), |
|
462 | + 'STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_sent()) |
|
463 | 463 | ) |
464 | 464 | )); |
465 | 465 | //set the Messages to resend. |
466 | - foreach ( $messages as $message ) { |
|
467 | - if ( $message instanceof EE_Message ) { |
|
468 | - $message->set_STS_ID( EEM_Message::status_resend ); |
|
469 | - $this->_queue->add( $message ); |
|
466 | + foreach ($messages as $message) { |
|
467 | + if ($message instanceof EE_Message) { |
|
468 | + $message->set_STS_ID(EEM_Message::status_resend); |
|
469 | + $this->_queue->add($message); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
473 | - $this->_queue->initiate_request_by_priority( 'send' ); |
|
473 | + $this->_queue->initiate_request_by_priority('send'); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -484,23 +484,23 @@ discard block |
||
484 | 484 | * |
485 | 485 | * @return EE_Message_To_Generate[] |
486 | 486 | */ |
487 | - public function setup_messages_to_generate_from_registration_ids_in_request( $registration_ids_key = '_REG_ID' ) { |
|
488 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
489 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
487 | + public function setup_messages_to_generate_from_registration_ids_in_request($registration_ids_key = '_REG_ID') { |
|
488 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
489 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
490 | 490 | $regs_to_send = array(); |
491 | - $regIDs = EE_Registry::instance()->REQ->get( $registration_ids_key ); |
|
492 | - if ( empty( $regIDs ) ) { |
|
493 | - EE_Error::add_error( __('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
491 | + $regIDs = EE_Registry::instance()->REQ->get($registration_ids_key); |
|
492 | + if (empty($regIDs)) { |
|
493 | + EE_Error::add_error(__('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | |
497 | 497 | //make sure is an array |
498 | - $regIDs = is_array( $regIDs ) ? $regIDs : array( $regIDs ); |
|
498 | + $regIDs = is_array($regIDs) ? $regIDs : array($regIDs); |
|
499 | 499 | |
500 | - foreach( $regIDs as $regID ) { |
|
501 | - $reg = EEM_Registration::instance()->get_one_by_ID( $regID ); |
|
502 | - if ( ! $reg instanceof EE_Registration ) { |
|
503 | - EE_Error::add_error( sprintf( __('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID ) ); |
|
500 | + foreach ($regIDs as $regID) { |
|
501 | + $reg = EEM_Registration::instance()->get_one_by_ID($regID); |
|
502 | + if ( ! $reg instanceof EE_Registration) { |
|
503 | + EE_Error::add_error(sprintf(__('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID)); |
|
504 | 504 | return false; |
505 | 505 | } |
506 | 506 | $regs_to_send[$reg->transaction_ID()][$reg->status_ID()][] = $reg; |
@@ -508,11 +508,11 @@ discard block |
||
508 | 508 | |
509 | 509 | $messages_to_generate = array(); |
510 | 510 | |
511 | - foreach ( $regs_to_send as $status_group ) { |
|
512 | - foreach ( $status_group as $status_id => $registrations ) { |
|
511 | + foreach ($regs_to_send as $status_group) { |
|
512 | + foreach ($status_group as $status_id => $registrations) { |
|
513 | 513 | $messages_to_generate = $messages_to_generate + $this->setup_mtgs_for_all_active_messengers( |
514 | - EEH_MSG_Template::convert_reg_status_to_message_type( $status_id ), |
|
515 | - array( $registrations, $status_id ) |
|
514 | + EEH_MSG_Template::convert_reg_status_to_message_type($status_id), |
|
515 | + array($registrations, $status_id) |
|
516 | 516 | ); |
517 | 517 | } |
518 | 518 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @return void |
290 | 290 | */ |
291 | 291 | public function enqueue_scripts_styles() { |
292 | - do_action( 'AHEE__EE_messenger__enqueue_scripts_styles'); |
|
292 | + do_action('AHEE__EE_messenger__enqueue_scripts_styles'); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | $this->_supports_labels->template_variation_description = __('These are different styles to choose from for the selected template structure. Usually these affect things like font style, color, borders etc. In some cases the styles will also make minor layout changes.'); |
361 | 361 | |
362 | - $this->_supports_labels = apply_filters( 'FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this ); |
|
362 | + $this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | * @return stdClass |
375 | 375 | */ |
376 | 376 | public function get_supports_labels() { |
377 | - if ( empty( $this->_supports_labels->template_pack ) || empty( $this->_supports_labels->template_variation) ) { |
|
377 | + if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) { |
|
378 | 378 | $this->_set_supports_labels_defaults(); |
379 | 379 | } |
380 | - return apply_filters( 'FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this ); |
|
380 | + return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | * |
398 | 398 | * @return string path or url for the requested variation. |
399 | 399 | */ |
400 | - public function get_variation( EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE ) { |
|
400 | + public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE) { |
|
401 | 401 | $this->_tmp_pack = $pack; |
402 | - $variation_path = apply_filters( 'EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters ); |
|
403 | - $variation_path = empty( $variation_path ) ? $this->_tmp_pack->get_variation( $this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters ) : $variation_path; |
|
402 | + $variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters); |
|
403 | + $variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path; |
|
404 | 404 | return $variation_path; |
405 | 405 | |
406 | 406 | } |
@@ -418,13 +418,13 @@ discard block |
||
418 | 418 | * @return array |
419 | 419 | */ |
420 | 420 | public function get_default_message_types() { |
421 | - $class = get_class( $this ); |
|
421 | + $class = get_class($this); |
|
422 | 422 | |
423 | 423 | //messenger specific filter |
424 | - $default_types = apply_filters( 'FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this ); |
|
424 | + $default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this); |
|
425 | 425 | |
426 | 426 | //all messengers filter |
427 | - $default_types = apply_filters( 'FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this ); |
|
427 | + $default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this); |
|
428 | 428 | return $default_types; |
429 | 429 | } |
430 | 430 | |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | * @return array |
440 | 440 | */ |
441 | 441 | public function get_valid_message_types() { |
442 | - $class = get_class( $this ); |
|
442 | + $class = get_class($this); |
|
443 | 443 | |
444 | 444 | //messenger specific filter |
445 | 445 | //messenger specific filter |
446 | - $valid_types = apply_filters( 'FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this ); |
|
446 | + $valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this); |
|
447 | 447 | |
448 | 448 | //all messengers filter |
449 | - $valid_types = apply_filters( 'FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this ); |
|
449 | + $valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this); |
|
450 | 450 | return $valid_types; |
451 | 451 | } |
452 | 452 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @access public |
461 | 461 | * @param array $new_config Whatever is put in here will reset the _validator_config property |
462 | 462 | */ |
463 | - public function set_validator_config( $new_config ) { |
|
463 | + public function set_validator_config($new_config) { |
|
464 | 464 | $this->_validator_config = $new_config; |
465 | 465 | } |
466 | 466 | |
@@ -476,8 +476,8 @@ discard block |
||
476 | 476 | public function get_validator_config() { |
477 | 477 | $class = get_class($this); |
478 | 478 | |
479 | - $config = apply_filters( 'FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this ); |
|
480 | - $config = apply_filters( 'FHEE__EE_messenger__get_validator_config', $config, $this ); |
|
479 | + $config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this); |
|
480 | + $config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this); |
|
481 | 481 | return $config; |
482 | 482 | } |
483 | 483 | |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | * @access public |
495 | 495 | * @return string content for page |
496 | 496 | */ |
497 | - public function get_messenger_admin_page_content( $page, $action = null, $extra = array(), $message_types = array() ) { |
|
498 | - return $this->_get_admin_page_content( $page, $action, $extra, $message_types ); |
|
497 | + public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array()) { |
|
498 | + return $this->_get_admin_page_content($page, $action, $extra, $message_types); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -505,20 +505,20 @@ discard block |
||
505 | 505 | * @param array $extra |
506 | 506 | * @return mixed|string |
507 | 507 | */ |
508 | - protected function _get_admin_content_events_edit( $message_types, $extra ) { |
|
508 | + protected function _get_admin_content_events_edit($message_types, $extra) { |
|
509 | 509 | //defaults |
510 | 510 | $template_args = array(); |
511 | 511 | $selector_rows = ''; |
512 | 512 | |
513 | 513 | //we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event. |
514 | - $event_id = isset( $extra['event'] ) ? $extra['event'] : NULL; |
|
514 | + $event_id = isset($extra['event']) ? $extra['event'] : NULL; |
|
515 | 515 | |
516 | - $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
517 | - $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
516 | + $template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
517 | + $template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
518 | 518 | |
519 | 519 | //array of template objects for global and custom (non-trashed) (but remember just for this messenger!) |
520 | 520 | $global_templates = EEM_Message_Template_Group::instance()->get_all( |
521 | - array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) ) |
|
521 | + array(array('MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true)) |
|
522 | 522 | ); |
523 | 523 | $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event( |
524 | 524 | $event_id, |
@@ -527,55 +527,55 @@ discard block |
||
527 | 527 | 'MTP_is_active' => true |
528 | 528 | ) |
529 | 529 | ); |
530 | - $templates_for_event = !empty( $templates_for_event ) ? $templates_for_event : array(); |
|
530 | + $templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array(); |
|
531 | 531 | |
532 | 532 | //so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups) |
533 | - foreach ( $global_templates as $mtpgID => $mtpg ) { |
|
534 | - if ( $mtpg instanceof EE_Message_Template_Group ) { |
|
533 | + foreach ($global_templates as $mtpgID => $mtpg) { |
|
534 | + if ($mtpg instanceof EE_Message_Template_Group) { |
|
535 | 535 | //verify this message type is supposed to show on this page |
536 | 536 | $mtp_obj = $mtpg->message_type_obj(); |
537 | - if ( ! $mtp_obj instanceof EE_message_type ) { |
|
537 | + if ( ! $mtp_obj instanceof EE_message_type) { |
|
538 | 538 | continue; |
539 | 539 | } |
540 | - $mtp_obj->admin_registered_pages = (array)$mtp_obj->admin_registered_pages; |
|
541 | - if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) { |
|
540 | + $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages; |
|
541 | + if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) { |
|
542 | 542 | continue; |
543 | 543 | } |
544 | 544 | $select_values = array(); |
545 | - $select_values[ $mtpgID ] = __( 'Global', 'event_espresso' ); |
|
546 | - $default_value = array_key_exists( $mtpgID, $templates_for_event ) && ! $mtpg->get( 'MTP_is_override' ) ? $mtpgID : null; |
|
545 | + $select_values[$mtpgID] = __('Global', 'event_espresso'); |
|
546 | + $default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null; |
|
547 | 547 | //if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override. |
548 | - if ( ! $mtpg->get( 'MTP_is_override' ) ) { |
|
548 | + if ( ! $mtpg->get('MTP_is_override')) { |
|
549 | 549 | //any custom templates for this message type? |
550 | - $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt( $this->name, $mtpg->message_type() ); |
|
551 | - foreach ( $custom_templates as $cmtpgID => $cmtpg ) { |
|
552 | - $select_values[ $cmtpgID ] = $cmtpg->name(); |
|
553 | - $default_value = array_key_exists( $cmtpgID, $templates_for_event ) ? $cmtpgID : $default_value; |
|
550 | + $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type()); |
|
551 | + foreach ($custom_templates as $cmtpgID => $cmtpg) { |
|
552 | + $select_values[$cmtpgID] = $cmtpg->name(); |
|
553 | + $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value; |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | //if there is no $default_value then we set it as the global |
557 | - $default_value = empty( $default_value ) ? $mtpgID : $default_value; |
|
558 | - $edit_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value ), admin_url( 'admin.php' ) ); |
|
559 | - $create_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value ), admin_url( 'admin.php' ) ); |
|
560 | - $st_args[ 'mt_name' ] = ucwords( $mtp_obj->label[ 'singular' ] ); |
|
561 | - $st_args[ 'mt_slug' ] = $mtpg->message_type(); |
|
562 | - $st_args[ 'messenger_slug' ] = $this->name; |
|
563 | - $st_args[ 'selector' ] = EEH_Form_Fields::select_input( 'event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector' ); |
|
557 | + $default_value = empty($default_value) ? $mtpgID : $default_value; |
|
558 | + $edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php')); |
|
559 | + $create_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value), admin_url('admin.php')); |
|
560 | + $st_args['mt_name'] = ucwords($mtp_obj->label['singular']); |
|
561 | + $st_args['mt_slug'] = $mtpg->message_type(); |
|
562 | + $st_args['messenger_slug'] = $this->name; |
|
563 | + $st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation['.$mtpgID.']', $select_values, $default_value, 'data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'"', 'message-template-selector'); |
|
564 | 564 | //note that message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates). |
565 | - $st_args[ 'create_button' ] = $mtpg->get( 'MTP_is_override' ) ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . __( 'Create New Custom', 'event_espresso' ) . '</a>'; |
|
566 | - $st_args[ 'create_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ? $st_args[ 'create_button' ] : ''; |
|
567 | - $st_args[ 'edit_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID ) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . __( 'Edit', 'event_espresso' ) . '</a>' : ''; |
|
568 | - $selector_rows .= EEH_Template::display_template( $template_row_path, $st_args, true ); |
|
565 | + $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$create_url.'" class="button button-small create-mtpg-button">'.__('Create New Custom', 'event_espresso').'</a>'; |
|
566 | + $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template') ? $st_args['create_button'] : ''; |
|
567 | + $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$edit_url.'" class="button button-small edit-mtpg-button">'.__('Edit', 'event_espresso').'</a>' : ''; |
|
568 | + $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true); |
|
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
572 | 572 | //if no selectors present then get out. |
573 | - if ( empty( $selector_rows ) ) { |
|
573 | + if (empty($selector_rows)) { |
|
574 | 574 | return ''; |
575 | 575 | } |
576 | 576 | |
577 | 577 | $template_args['selector_rows'] = $selector_rows; |
578 | - return EEH_Template::display_template( $template_wrapper_path, $template_args, TRUE ); |
|
578 | + return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | * @return array $this->_template_fields |
591 | 591 | */ |
592 | 592 | public function get_template_fields() { |
593 | - $template_fields = apply_filters( 'FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this ); |
|
594 | - $template_fields = apply_filters( 'FHEE__EE_messenger__get_template_fields', $template_fields, $this ); |
|
593 | + $template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this); |
|
594 | + $template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this); |
|
595 | 595 | return $template_fields; |
596 | 596 | } |
597 | 597 | |
@@ -605,9 +605,9 @@ discard block |
||
605 | 605 | * @param mixed $value |
606 | 606 | */ |
607 | 607 | protected function _set_template_value($item, $value) { |
608 | - if ( array_key_exists($item, $this->_template_fields) ) { |
|
609 | - $prop = '_' . $item; |
|
610 | - $this->{$prop}= $value; |
|
608 | + if (array_key_exists($item, $this->_template_fields)) { |
|
609 | + $prop = '_'.$item; |
|
610 | + $this->{$prop} = $value; |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | |
@@ -618,8 +618,8 @@ discard block |
||
618 | 618 | * @return bool Very important that all messengers return bool for successful send or not. Error messages can be |
619 | 619 | * added to EE_Error. |
620 | 620 | */ |
621 | - public function send_message( $message, EE_message_type $message_type ) { |
|
622 | - $this->_validate_and_setup( $message ); |
|
621 | + public function send_message($message, EE_message_type $message_type) { |
|
622 | + $this->_validate_and_setup($message); |
|
623 | 623 | $this->_incoming_message_type = $message_type; |
624 | 624 | return $this->_send_message(); |
625 | 625 | } |
@@ -633,28 +633,28 @@ discard block |
||
633 | 633 | * @param bool $send true we will actually use the _send method (for test sends). FALSE we just return preview |
634 | 634 | * @return string return the message html content |
635 | 635 | */ |
636 | - public function get_preview( EE_Message $message, EE_message_type $message_type, $send = false ) { |
|
637 | - $this->_validate_and_setup( $message ); |
|
636 | + public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false) { |
|
637 | + $this->_validate_and_setup($message); |
|
638 | 638 | |
639 | 639 | $this->_incoming_message_type = $message_type; |
640 | 640 | |
641 | - if ( $send ) { |
|
641 | + if ($send) { |
|
642 | 642 | //are we overriding any existing template fields? |
643 | 643 | $settings = $this->get_existing_test_settings(); |
644 | - if ( ! empty( $settings ) ) { |
|
645 | - foreach ( $settings as $field => $value ) { |
|
646 | - $this->_set_template_value( $field, $value ); |
|
644 | + if ( ! empty($settings)) { |
|
645 | + foreach ($settings as $field => $value) { |
|
646 | + $this->_set_template_value($field, $value); |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
651 | 651 | //enqueue preview js so that any links/buttons on the page are disabled. |
652 | - if ( ! $send ) { |
|
652 | + if ( ! $send) { |
|
653 | 653 | // the below may seem like duplication. However, typically if a messenger enqueues scripts/styles, |
654 | 654 | // it deregisters all existing wp scripts and styles first. So the second hook ensures our previewer still gets setup. |
655 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
656 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
657 | - add_action( 'AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10 ); |
|
655 | + add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
656 | + add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
657 | + add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | return $send ? $this->_send_message() : $this->_preview(); |
@@ -672,10 +672,10 @@ discard block |
||
672 | 672 | */ |
673 | 673 | public function add_preview_script() { |
674 | 674 | //error message |
675 | - EE_Registry::$i18n_js_strings[ 'links_disabled' ] = __( 'All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso' ); |
|
676 | - wp_register_script( 'ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true ); |
|
677 | - wp_localize_script( 'ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
678 | - wp_enqueue_script( 'ee-messages-preview-js' ); |
|
675 | + EE_Registry::$i18n_js_strings['links_disabled'] = __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso'); |
|
676 | + wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
677 | + wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings); |
|
678 | + wp_enqueue_script('ee-messages-preview-js'); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | |
@@ -686,13 +686,13 @@ discard block |
||
686 | 686 | * @param EE_Message $message |
687 | 687 | * @throws EE_Error |
688 | 688 | */ |
689 | - protected function _validate_and_setup( EE_Message $message ) { |
|
689 | + protected function _validate_and_setup(EE_Message $message) { |
|
690 | 690 | $template_pack = $message->get_template_pack(); |
691 | 691 | $variation = $message->get_template_pack_variation(); |
692 | 692 | |
693 | 693 | //verify we have the required template pack value on the $message object. |
694 | - if ( ! $template_pack instanceof EE_Messages_Template_Pack ) { |
|
695 | - throw new EE_Error( __('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso' ) ); |
|
694 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack) { |
|
695 | + throw new EE_Error(__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso')); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | $this->_tmp_pack = $template_pack; |
@@ -701,11 +701,11 @@ discard block |
||
701 | 701 | |
702 | 702 | $template_fields = $this->get_template_fields(); |
703 | 703 | |
704 | - foreach ( $template_fields as $template => $value ) { |
|
705 | - if ( $template !== 'extra' ) { |
|
706 | - $column_value = $message->get_field_or_extra_meta( 'MSG_' . $template ); |
|
704 | + foreach ($template_fields as $template => $value) { |
|
705 | + if ($template !== 'extra') { |
|
706 | + $column_value = $message->get_field_or_extra_meta('MSG_'.$template); |
|
707 | 707 | $message_template_value = $column_value ? $column_value : null; |
708 | - $this->_set_template_value( $template, $message_template_value ); |
|
708 | + $this->_set_template_value($template, $message_template_value); |
|
709 | 709 | } |
710 | 710 | } |
711 | 711 | } |
@@ -720,19 +720,19 @@ discard block |
||
720 | 720 | * @return string |
721 | 721 | * @throws \EE_Error |
722 | 722 | */ |
723 | - protected function _get_main_template( $preview = FALSE ) { |
|
723 | + protected function _get_main_template($preview = FALSE) { |
|
724 | 724 | $type = $preview ? 'preview' : 'main'; |
725 | 725 | |
726 | - $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type ); |
|
726 | + $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type); |
|
727 | 727 | |
728 | 728 | //check file exists and is readable |
729 | - if ( !is_readable( $wrapper_template ) ) |
|
730 | - throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
729 | + if ( ! is_readable($wrapper_template)) |
|
730 | + throw new EE_Error(sprintf(__('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template)); |
|
731 | 731 | |
732 | 732 | //add message type to template args |
733 | 733 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
734 | 734 | |
735 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE ); |
|
735 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | |
@@ -768,9 +768,9 @@ discard block |
||
768 | 768 | */ |
769 | 769 | public function get_existing_test_settings() { |
770 | 770 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
771 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
771 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
772 | 772 | $settings = $Message_Resource_Manager->get_active_messengers_option(); |
773 | - return isset( $settings[ $this->name ]['test_settings'] ) ? $settings[ $this->name ]['test_settings'] : array(); |
|
773 | + return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array(); |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | |
@@ -782,12 +782,12 @@ discard block |
||
782 | 782 | * @param $settings |
783 | 783 | * @return bool success/fail |
784 | 784 | */ |
785 | - public function set_existing_test_settings( $settings ) { |
|
785 | + public function set_existing_test_settings($settings) { |
|
786 | 786 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
787 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
787 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
788 | 788 | $existing = $Message_Resource_Manager->get_active_messengers_option(); |
789 | - $existing[ $this->name ]['test_settings'] = $settings; |
|
790 | - return $Message_Resource_Manager->update_active_messengers_option( $existing ); |
|
789 | + $existing[$this->name]['test_settings'] = $settings; |
|
790 | + return $Message_Resource_Manager->update_active_messengers_option($existing); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | |
@@ -800,21 +800,21 @@ discard block |
||
800 | 800 | * @param string $field The field to retrieve the label for |
801 | 801 | * @return string The label |
802 | 802 | */ |
803 | - public function get_field_label( $field ) { |
|
803 | + public function get_field_label($field) { |
|
804 | 804 | //first let's see if the field requests is in the top level array. |
805 | - if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) |
|
805 | + if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label'])) |
|
806 | 806 | return $this->_template[$field]['label']; |
807 | 807 | |
808 | 808 | //nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index. |
809 | - if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) |
|
809 | + if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label'])) |
|
810 | 810 | return $this->_template_fields['extra'][$field]['main']['label']; |
811 | 811 | |
812 | 812 | //now it's possible this field may just be existing in any of the extra array items. |
813 | - if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) { |
|
814 | - foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) { |
|
815 | - if ( !is_array( $subfields ) ) |
|
813 | + if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) { |
|
814 | + foreach ($this->_template_fields['extra'] as $main_field => $subfields) { |
|
815 | + if ( ! is_array($subfields)) |
|
816 | 816 | continue; |
817 | - if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) |
|
817 | + if (isset($subfields[$field]) && ! empty($subfields[$field]['label'])) |
|
818 | 818 | return $subfields[$field]['label']; |
819 | 819 | } |
820 | 820 | } |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * |
836 | 836 | * @return void |
837 | 837 | */ |
838 | - public function do_secondary_messenger_hooks( $sending_messenger_name ) { |
|
838 | + public function do_secondary_messenger_hooks($sending_messenger_name) { |
|
839 | 839 | return; |
840 | 840 | } |
841 | 841 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * @param $context |
120 | 120 | * @throws \EE_Error |
121 | 121 | */ |
122 | - public function __construct( $fields, $context ) { |
|
122 | + public function __construct($fields, $context) { |
|
123 | 123 | //check that _m_name and _mt_name have been set by child class otherwise we get out. |
124 | - if ( empty($this->_m_name ) || empty( $this->_mt_name) ) |
|
124 | + if (empty($this->_m_name) || empty($this->_mt_name)) |
|
125 | 125 | throw new EE_Error( |
126 | 126 | __( |
127 | 127 | 'EE_Messages_Validator child classes MUST set the $_m_name and $_mt_name property. Check that the child class is doing this', |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | */ |
168 | 168 | private function _load_objects() { |
169 | 169 | //load messenger |
170 | - $messenger = ucwords( str_replace( '_', ' ', $this->_m_name ) ); |
|
171 | - $messenger = str_replace( ' ', '_', $messenger ); |
|
172 | - $messenger = 'EE_' . $messenger . '_messenger'; |
|
170 | + $messenger = ucwords(str_replace('_', ' ', $this->_m_name)); |
|
171 | + $messenger = str_replace(' ', '_', $messenger); |
|
172 | + $messenger = 'EE_'.$messenger.'_messenger'; |
|
173 | 173 | |
174 | - if ( ! class_exists( $messenger ) ) { |
|
174 | + if ( ! class_exists($messenger)) { |
|
175 | 175 | throw new EE_Error( |
176 | 176 | sprintf( |
177 | - __( 'There is no messenger class for the given string (%s)', 'event_espresso' ), |
|
177 | + __('There is no messenger class for the given string (%s)', 'event_espresso'), |
|
178 | 178 | $this->_m_name |
179 | 179 | ) |
180 | 180 | ); |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | $this->_messenger = new $messenger(); |
184 | 184 | |
185 | 185 | //load message type |
186 | - $message_type = ucwords( str_replace( '_', ' ', $this->_mt_name ) ); |
|
187 | - $message_type = str_replace( ' ', '_', $message_type ); |
|
188 | - $message_type = 'EE_' . $message_type . '_message_type'; |
|
186 | + $message_type = ucwords(str_replace('_', ' ', $this->_mt_name)); |
|
187 | + $message_type = str_replace(' ', '_', $message_type); |
|
188 | + $message_type = 'EE_'.$message_type.'_message_type'; |
|
189 | 189 | |
190 | - if ( !class_exists( $message_type ) ) { |
|
190 | + if ( ! class_exists($message_type)) { |
|
191 | 191 | throw new EE_Error( |
192 | 192 | sprintf( |
193 | - __( 'There is no message type class for the given string (%s)', 'event_espresso' ), |
|
193 | + __('There is no message type class for the given string (%s)', 'event_espresso'), |
|
194 | 194 | $this->_mt_name |
195 | 195 | ) |
196 | 196 | ); |
@@ -227,25 +227,25 @@ discard block |
||
227 | 227 | $shortcode_groups = $mt_codes; |
228 | 228 | $groups_per_field = array(); |
229 | 229 | |
230 | - foreach ( $msgr_validator as $field => $config ) { |
|
231 | - if ( empty($config) || !isset($config['shortcodes']) ) |
|
232 | - continue; //Nothing to see here. |
|
233 | - $groups_per_field[$field] = array_intersect( $config['shortcodes'], $mt_codes ); |
|
234 | - $shortcode_groups = array_merge( $config[ 'shortcodes'], $shortcode_groups ); |
|
230 | + foreach ($msgr_validator as $field => $config) { |
|
231 | + if (empty($config) || ! isset($config['shortcodes'])) |
|
232 | + continue; //Nothing to see here. |
|
233 | + $groups_per_field[$field] = array_intersect($config['shortcodes'], $mt_codes); |
|
234 | + $shortcode_groups = array_merge($config['shortcodes'], $shortcode_groups); |
|
235 | 235 | } |
236 | 236 | |
237 | - $shortcode_groups = array_unique( $shortcode_groups); |
|
237 | + $shortcode_groups = array_unique($shortcode_groups); |
|
238 | 238 | |
239 | 239 | // okay now we've got our groups. |
240 | 240 | // Let's get the codes from the objects into an array indexed by group for easy retrieval later. |
241 | 241 | $codes_from_objs = array(); |
242 | 242 | |
243 | - foreach ( $shortcode_groups as $group ) { |
|
244 | - $ref = ucwords( str_replace('_', ' ', $group ) ); |
|
245 | - $ref = str_replace( ' ', '_', $ref ); |
|
246 | - $classname = 'EE_' . $ref . '_Shortcodes'; |
|
247 | - if ( class_exists( $classname ) ) { |
|
248 | - $a = new ReflectionClass( $classname ); |
|
243 | + foreach ($shortcode_groups as $group) { |
|
244 | + $ref = ucwords(str_replace('_', ' ', $group)); |
|
245 | + $ref = str_replace(' ', '_', $ref); |
|
246 | + $classname = 'EE_'.$ref.'_Shortcodes'; |
|
247 | + if (class_exists($classname)) { |
|
248 | + $a = new ReflectionClass($classname); |
|
249 | 249 | $obj = $a->newInstance(); |
250 | 250 | $codes_from_objs[$group] = $obj->get_shortcodes(); |
251 | 251 | } |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | |
255 | 255 | //let's just replace the $mt shortcode group indexes with the actual shortcodes (unique) |
256 | 256 | $final_mt_codes = array(); |
257 | - foreach ( $mt_codes as $group ) { |
|
258 | - $final_mt_codes = array_merge( $final_mt_codes, $codes_from_objs[$group] ); |
|
257 | + foreach ($mt_codes as $group) { |
|
258 | + $final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[$group]); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | $mt_codes = $final_mt_codes; |
@@ -263,60 +263,60 @@ discard block |
||
263 | 263 | |
264 | 264 | // k now in this next loop we're going to loop through $msgr_validator again |
265 | 265 | // and setup the _validators property from the data we've setup so far. |
266 | - foreach ( $msgr_validator as $field => $config ) { |
|
266 | + foreach ($msgr_validator as $field => $config) { |
|
267 | 267 | //if required shortcode is not in our list of codes for the given field, then we skip this field. |
268 | 268 | $required = isset($config['required']) |
269 | 269 | ? array_intersect($config['required'], array_keys($mt_codes)) |
270 | 270 | : true; |
271 | - if ( empty($required) ) |
|
271 | + if (empty($required)) |
|
272 | 272 | continue; |
273 | 273 | |
274 | 274 | //If we have an override then we use it to indicate the codes we want. |
275 | - if ( isset( $this->_valid_shortcodes_modifier[$context][$field] ) ) { |
|
276 | - $this->_validators[ $field ][ 'shortcodes' ] = $this->_reassemble_valid_shortcodes_from_group( |
|
277 | - $this->_valid_shortcodes_modifier[ $context ][ $field ], |
|
275 | + if (isset($this->_valid_shortcodes_modifier[$context][$field])) { |
|
276 | + $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group( |
|
277 | + $this->_valid_shortcodes_modifier[$context][$field], |
|
278 | 278 | $codes_from_objs |
279 | 279 | ); |
280 | 280 | } |
281 | 281 | |
282 | 282 | //if we have specific shortcodes for a field then we need to use them |
283 | - else if ( isset( $groups_per_field[$field] ) ) { |
|
284 | - $this->_validators[ $field ][ 'shortcodes' ] = $this->_reassemble_valid_shortcodes_from_group( |
|
285 | - $groups_per_field[ $field ], |
|
283 | + else if (isset($groups_per_field[$field])) { |
|
284 | + $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group( |
|
285 | + $groups_per_field[$field], |
|
286 | 286 | $codes_from_objs |
287 | 287 | ); |
288 | 288 | } |
289 | 289 | |
290 | 290 | //if empty config then we're assuming we're just going to use the shortcodes from the message type context |
291 | - else if ( empty( $config ) ) { |
|
291 | + else if (empty($config)) { |
|
292 | 292 | $this->_validators[$field]['shortcodes'] = $mt_codes; |
293 | 293 | } |
294 | 294 | |
295 | 295 | //if we have specific shortcodes then we need to use them |
296 | - else if ( isset($config['specific_shortcodes'] ) ) { |
|
296 | + else if (isset($config['specific_shortcodes'])) { |
|
297 | 297 | $this->_validators[$field]['shortcodes'] = $config['specific_shortcodes']; |
298 | 298 | } |
299 | 299 | |
300 | 300 | //otherwise the shortcodes are what is set by the messenger for that field |
301 | 301 | else { |
302 | - foreach ( $config['shortcodes'] as $group ) { |
|
302 | + foreach ($config['shortcodes'] as $group) { |
|
303 | 303 | $this->_validators[$field]['shortcodes'] = isset($this->_validators[$field]['shortcodes']) |
304 | - ? array_merge( $this->_validators[$field]['shortcodes'], $codes_from_objs[$group] ) |
|
304 | + ? array_merge($this->_validators[$field]['shortcodes'], $codes_from_objs[$group]) |
|
305 | 305 | : $codes_from_objs[$group]; |
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | 309 | //now let's just make sure that any excluded specific shortcodes are removed. |
310 | 310 | $specific_excludes = $this->get_specific_shortcode_excludes(); |
311 | - if ( isset( $specific_excludes[$field] ) ) { |
|
312 | - foreach( $specific_excludes[$field] as $sex ) { |
|
313 | - if ( isset( $this->_validators[$field]['shortcodes'][$sex] ) ) |
|
314 | - unset( $this->_validators[$field]['shortcodes'][$sex] ); |
|
311 | + if (isset($specific_excludes[$field])) { |
|
312 | + foreach ($specific_excludes[$field] as $sex) { |
|
313 | + if (isset($this->_validators[$field]['shortcodes'][$sex])) |
|
314 | + unset($this->_validators[$field]['shortcodes'][$sex]); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
318 | 318 | //hey! don't forget to include the type if present! |
319 | - $this->_validators[$field]['type'] = isset( $config['type'] ) ? $config['type'] : NULL; |
|
319 | + $this->_validators[$field]['type'] = isset($config['type']) ? $config['type'] : NULL; |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | public function get_specific_shortcode_excludes() { |
345 | 345 | //specific validator filter |
346 | 346 | $shortcode_excludes = apply_filters( |
347 | - 'FHEE__' . get_class( $this ) . '__get_specific_shortcode_excludes;', |
|
347 | + 'FHEE__'.get_class($this).'__get_specific_shortcode_excludes;', |
|
348 | 348 | $this->_specific_shortcode_excludes, |
349 | 349 | $this->_context |
350 | 350 | ); |
@@ -372,20 +372,20 @@ discard block |
||
372 | 372 | //some defaults |
373 | 373 | $template_fields = $this->_messenger->get_template_fields(); |
374 | 374 | //loop through the fields and check! |
375 | - foreach ( $this->_fields as $field => $value ) { |
|
375 | + foreach ($this->_fields as $field => $value) { |
|
376 | 376 | $this->_errors[$field] = array(); |
377 | 377 | $err_msg = ''; |
378 | 378 | $field_label = ''; |
379 | 379 | //if field is not present in the _validators array then we continue |
380 | - if ( !isset( $this->_validators[$field] ) ) { |
|
381 | - unset( $this->_errors[$field] ); |
|
380 | + if ( ! isset($this->_validators[$field])) { |
|
381 | + unset($this->_errors[$field]); |
|
382 | 382 | continue; |
383 | 383 | } |
384 | 384 | |
385 | 385 | //get the translated field label! |
386 | 386 | //first check if it's in the main fields list |
387 | - if ( isset( $template_fields[$field] ) ) { |
|
388 | - if ( empty( $template_fields[$field] ) ) |
|
387 | + if (isset($template_fields[$field])) { |
|
388 | + if (empty($template_fields[$field])) |
|
389 | 389 | $field_label = $field; //most likely the field is found in the 'extra' array. |
390 | 390 | else |
391 | 391 | $field_label = $template_fields[$field]['label']; |
@@ -393,16 +393,16 @@ discard block |
||
393 | 393 | |
394 | 394 | // if field label is empty OR is equal to the current field |
395 | 395 | // then we need to loop through the 'extra' fields in the template_fields config (if present) |
396 | - if ( isset( $template_fields['extra'] ) && ( empty($field_label) ) || $field_label == $field ) { |
|
397 | - foreach( $template_fields['extra'] as $main_field => $secondary_field ) { |
|
398 | - foreach ( $secondary_field as $name => $values ) { |
|
399 | - if ( $name == $field ) { |
|
396 | + if (isset($template_fields['extra']) && (empty($field_label)) || $field_label == $field) { |
|
397 | + foreach ($template_fields['extra'] as $main_field => $secondary_field) { |
|
398 | + foreach ($secondary_field as $name => $values) { |
|
399 | + if ($name == $field) { |
|
400 | 400 | $field_label = $values['label']; |
401 | 401 | } |
402 | 402 | |
403 | 403 | // if we've got a 'main' secondary field, let's see if that matches what field we're on |
404 | 404 | // which means it contains the label for this field. |
405 | - if ( $name == 'main' && $main_field == $field_label ) |
|
405 | + if ($name == 'main' && $main_field == $field_label) |
|
406 | 406 | $field_label = $values['label']; |
407 | 407 | } |
408 | 408 | } |
@@ -410,27 +410,27 @@ discard block |
||
410 | 410 | |
411 | 411 | //field is present. Let's validate shortcodes first (but only if shortcodes present). |
412 | 412 | if ( |
413 | - isset( $this->_validators[ $field ][ 'shortcodes' ] ) |
|
414 | - && ! empty( $this->_validators[ $field ][ 'shortcodes' ] ) |
|
413 | + isset($this->_validators[$field]['shortcodes']) |
|
414 | + && ! empty($this->_validators[$field]['shortcodes']) |
|
415 | 415 | ) { |
416 | - $invalid_shortcodes = $this->_invalid_shortcodes( $value, $this->_validators[$field]['shortcodes'] ); |
|
416 | + $invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[$field]['shortcodes']); |
|
417 | 417 | // if true then that means there is a returned error message |
418 | 418 | // that we'll need to add to the _errors array for this field. |
419 | - if ( $invalid_shortcodes ) { |
|
419 | + if ($invalid_shortcodes) { |
|
420 | 420 | $v_s = array_keys($this->_validators[$field]['shortcodes']); |
421 | 421 | $err_msg = sprintf( |
422 | 422 | __( |
423 | 423 | '%3$sThe following shortcodes were found in the "%1$s" field that ARE not valid: %2$s%4$s', |
424 | 424 | 'event_espresso' |
425 | 425 | ), |
426 | - '<strong>' . $field_label . '</strong>', |
|
426 | + '<strong>'.$field_label.'</strong>', |
|
427 | 427 | $invalid_shortcodes, |
428 | 428 | '<p>', |
429 | 429 | '</p >' |
430 | 430 | ); |
431 | 431 | $err_msg .= sprintf( |
432 | - __( '%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso' ), |
|
433 | - implode( ', ', $v_s ), |
|
432 | + __('%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso'), |
|
433 | + implode(', ', $v_s), |
|
434 | 434 | '<strong>', |
435 | 435 | '</strong>' |
436 | 436 | ); |
@@ -438,10 +438,10 @@ discard block |
||
438 | 438 | } |
439 | 439 | |
440 | 440 | //if there's a "type" to be validated then let's do that too. |
441 | - if ( isset( $this->_validators[$field]['type'] ) && !empty( $this->_validators[$field]['type'] ) ) { |
|
442 | - switch ( $this->_validators[$field]['type'] ) { |
|
441 | + if (isset($this->_validators[$field]['type']) && ! empty($this->_validators[$field]['type'])) { |
|
442 | + switch ($this->_validators[$field]['type']) { |
|
443 | 443 | case 'number' : |
444 | - if ( !is_numeric($value) ) |
|
444 | + if ( ! is_numeric($value)) |
|
445 | 445 | $err_msg .= sprintf( |
446 | 446 | __( |
447 | 447 | '%3$sThe %1$s field is supposed to be a number. The value given (%2$s) is not. Please double-check and make sure the field contains a number%4$s', |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | break; |
456 | 456 | case 'email' : |
457 | 457 | $valid_email = $this->_validate_email($value); |
458 | - if ( !$valid_email ) |
|
458 | + if ( ! $valid_email) |
|
459 | 459 | $err_msg .= htmlentities( |
460 | 460 | sprintf( |
461 | 461 | __( |
@@ -472,23 +472,23 @@ discard block |
||
472 | 472 | } |
473 | 473 | |
474 | 474 | //if $err_msg isn't empty let's setup the _errors array for this field. |
475 | - if ( !empty($err_msg ) ) { |
|
475 | + if ( ! empty($err_msg)) { |
|
476 | 476 | $this->_errors[$field]['msg'] = $err_msg; |
477 | 477 | } else { |
478 | - unset( $this->_errors[$field] ); |
|
478 | + unset($this->_errors[$field]); |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
482 | 482 | // if we have ANY errors, then we want to make sure we return the values |
483 | 483 | // for ALL the fields so the user doesn't have to retype them all. |
484 | - if ( !empty( $this->_errors ) ) { |
|
485 | - foreach ( $this->_fields as $field => $value ) { |
|
484 | + if ( ! empty($this->_errors)) { |
|
485 | + foreach ($this->_fields as $field => $value) { |
|
486 | 486 | $this->_errors[$field]['value'] = stripslashes($value); |
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
490 | 490 | //return any errors or just TRUE if everything validates |
491 | - return empty( $this->_errors ) ? TRUE : $this->_errors; |
|
491 | + return empty($this->_errors) ? TRUE : $this->_errors; |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | |
@@ -501,10 +501,10 @@ discard block |
||
501 | 501 | * @param array $codes_from_objs All the codes available. |
502 | 502 | * @return array an array of actual shortcodes (that will be used for validation). |
503 | 503 | */ |
504 | - private function _reassemble_valid_shortcodes_from_group( $groups, $codes_from_objs ) { |
|
504 | + private function _reassemble_valid_shortcodes_from_group($groups, $codes_from_objs) { |
|
505 | 505 | $shortcodes = array(); |
506 | - foreach ( $groups as $group ) { |
|
507 | - $shortcodes = array_merge( $shortcodes, $codes_from_objs[$group] ); |
|
506 | + foreach ($groups as $group) { |
|
507 | + $shortcodes = array_merge($shortcodes, $codes_from_objs[$group]); |
|
508 | 508 | } |
509 | 509 | return $shortcodes; |
510 | 510 | } |
@@ -523,29 +523,29 @@ discard block |
||
523 | 523 | */ |
524 | 524 | protected function _invalid_shortcodes($value, $valid_shortcodes) { |
525 | 525 | //first we need to go through the string and get the shortcodes in the string |
526 | - preg_match_all( '/(\[.+?\])/', $value, $matches ); |
|
526 | + preg_match_all('/(\[.+?\])/', $value, $matches); |
|
527 | 527 | $incoming_shortcodes = (array) $matches[0]; |
528 | 528 | |
529 | 529 | //get a diff of the shortcodes in the string vs the valid shortcodes |
530 | - $diff = array_diff( $incoming_shortcodes, array_keys($valid_shortcodes) ); |
|
530 | + $diff = array_diff($incoming_shortcodes, array_keys($valid_shortcodes)); |
|
531 | 531 | |
532 | 532 | //we need to account for custom codes so let's loop through the diff and remove any of those type of codes |
533 | - foreach ( $diff as $ind => $code ) { |
|
534 | - if ( preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code ) ) { |
|
533 | + foreach ($diff as $ind => $code) { |
|
534 | + if (preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code)) { |
|
535 | 535 | //strip the shortcode so we just have the BASE string (i.e. [ANSWER_*] ) |
536 | 536 | $dynamic_sc = preg_replace('/(_\*+.+)/', '_*]', $code); |
537 | 537 | //does this exist in the $valid_shortcodes? If so then unset. |
538 | - if ( isset( $valid_shortcodes[$dynamic_sc] ) ) { |
|
539 | - unset( $diff[$ind] ); |
|
538 | + if (isset($valid_shortcodes[$dynamic_sc])) { |
|
539 | + unset($diff[$ind]); |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
544 | - if ( empty( $diff ) ) return FALSE; //there is no diff, we have no invalid shortcodes, so return |
|
544 | + if (empty($diff)) return FALSE; //there is no diff, we have no invalid shortcodes, so return |
|
545 | 545 | |
546 | 546 | //made it here? then let's assemble the error message |
547 | - $invalid_shortcodes = implode( '</strong>,<strong>', $diff ); |
|
548 | - $invalid_shortcodes = '<strong>' . $invalid_shortcodes . '</strong>'; |
|
547 | + $invalid_shortcodes = implode('</strong>,<strong>', $diff); |
|
548 | + $invalid_shortcodes = '<strong>'.$invalid_shortcodes.'</strong>'; |
|
549 | 549 | return $invalid_shortcodes; |
550 | 550 | } |
551 | 551 | |
@@ -557,13 +557,13 @@ discard block |
||
557 | 557 | * @param string $value incoming value to validate |
558 | 558 | * @return bool true if the string validates, false if it doesn't |
559 | 559 | */ |
560 | - protected function _validate_email( $value ) { |
|
560 | + protected function _validate_email($value) { |
|
561 | 561 | $validate = TRUE; |
562 | 562 | $or_val = $value; |
563 | 563 | |
564 | 564 | // empty strings will validate because this is how a message template |
565 | 565 | // for a particular context can be "turned off" (if there is no email then no message) |
566 | - if ( empty( $value ) ) |
|
566 | + if (empty($value)) |
|
567 | 567 | return $validate; |
568 | 568 | |
569 | 569 | // first determine if there ARE any shortcodes. |
@@ -581,19 +581,19 @@ discard block |
||
581 | 581 | // its possible that this message is being "turned off" for a particular context |
582 | 582 | |
583 | 583 | |
584 | - if ( !empty($or_val) && empty($value) ) |
|
584 | + if ( ! empty($or_val) && empty($value)) |
|
585 | 585 | return $validate; |
586 | 586 | |
587 | 587 | //trim any commas from beginning and end of string ( after whitespace trimmed ); |
588 | - $value = trim( trim($value), ',' ); |
|
588 | + $value = trim(trim($value), ','); |
|
589 | 589 | |
590 | 590 | |
591 | 591 | //next we need to split up the string if its comma delimited. |
592 | 592 | $emails = explode(',', $value); |
593 | 593 | $empty = FALSE; //used to indicate that there is an empty comma. |
594 | 594 | //now let's loop through the emails and do our checks |
595 | - foreach ( $emails as $email ) { |
|
596 | - if ( empty($email) ) { |
|
595 | + foreach ($emails as $email) { |
|
596 | + if (empty($email)) { |
|
597 | 597 | $empty = TRUE; |
598 | 598 | continue; |
599 | 599 | } |
@@ -601,20 +601,20 @@ discard block |
||
601 | 601 | //trim whitespace |
602 | 602 | $email = trim($email); |
603 | 603 | //either its of type "[email protected]", or its of type "fname lname <[email protected]>" |
604 | - if(is_email($email)){ |
|
604 | + if (is_email($email)) { |
|
605 | 605 | continue; |
606 | - }else{ |
|
606 | + } else { |
|
607 | 607 | $matches = array(); |
608 | - $validate = preg_match( '/(.*)<(.+)>/', $email, $matches ) ? TRUE : FALSE; |
|
609 | - if( $validate && is_email($matches[2])){ |
|
608 | + $validate = preg_match('/(.*)<(.+)>/', $email, $matches) ? TRUE : FALSE; |
|
609 | + if ($validate && is_email($matches[2])) { |
|
610 | 610 | continue; |
611 | - }else{ |
|
611 | + } else { |
|
612 | 612 | return false; |
613 | 613 | } |
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | - $validate = $empty && !$has_shortcodes ? FALSE : $validate; |
|
617 | + $validate = $empty && ! $has_shortcodes ? FALSE : $validate; |
|
618 | 618 | |
619 | 619 | return $validate; |
620 | 620 | |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * @throws Exception |
631 | 631 | * @return mixed |
632 | 632 | */ |
633 | - public function __get( $property ) { |
|
633 | + public function __get($property) { |
|
634 | 634 | $expected_properties_map = array( |
635 | 635 | /** |
636 | 636 | * @deprecated 4.9.0 |
@@ -642,15 +642,15 @@ discard block |
||
642 | 642 | '_MSGTYP' => '_message_type' |
643 | 643 | ); |
644 | 644 | |
645 | - if ( isset( $expected_properties_map[ $property ] ) ) { |
|
646 | - return $this->{$expected_properties_map[ $property ]}; |
|
645 | + if (isset($expected_properties_map[$property])) { |
|
646 | + return $this->{$expected_properties_map[$property]}; |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | throw new Exception( |
650 | 650 | sprintf( |
651 | - __( 'The property %1$s being requested on %2$s does not exist', 'event_espresso' ), |
|
651 | + __('The property %1$s being requested on %2$s does not exist', 'event_espresso'), |
|
652 | 652 | $property, |
653 | - get_class( $this ) |
|
653 | + get_class($this) |
|
654 | 654 | ) |
655 | 655 | ); |
656 | 656 | } |
@@ -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 | * EE_Message_Template_Group class |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | * @param string $timezone |
19 | 19 | * @return EE_Message_Template_Group|mixed |
20 | 20 | */ |
21 | - public static function new_instance( $props_n_values = array(), $timezone = '' ) { |
|
22 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone ); |
|
23 | - return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone ); |
|
21 | + public static function new_instance($props_n_values = array(), $timezone = '') { |
|
22 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
23 | + return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | * @param string $timezone |
31 | 31 | * @return EE_Message_Template_Group |
32 | 32 | */ |
33 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = '' ) { |
|
34 | - return new self( $props_n_values, TRUE, $timezone ); |
|
33 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') { |
|
34 | + return new self($props_n_values, TRUE, $timezone); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * @param bool $message_type |
41 | 41 | * @throws EE_Error |
42 | 42 | */ |
43 | - public function set_message_type( $message_type = FALSE ) { |
|
44 | - if ( ! $message_type ) { |
|
45 | - throw new EE_Error( __( 'Missing required value for the message_type parameter', 'event_espresso' ) ); |
|
43 | + public function set_message_type($message_type = FALSE) { |
|
44 | + if ( ! $message_type) { |
|
45 | + throw new EE_Error(__('Missing required value for the message_type parameter', 'event_espresso')); |
|
46 | 46 | } |
47 | - $this->set( 'MTP_message_type', $message_type ); |
|
47 | + $this->set('MTP_message_type', $message_type); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | * @param bool $messenger |
54 | 54 | * @throws EE_Error |
55 | 55 | */ |
56 | - public function set_messenger( $messenger = FALSE ) { |
|
57 | - if ( ! $messenger ) { |
|
58 | - throw new EE_Error( __( 'Missing required value for the messenger parameter', 'event_espresso' ) ); |
|
56 | + public function set_messenger($messenger = FALSE) { |
|
57 | + if ( ! $messenger) { |
|
58 | + throw new EE_Error(__('Missing required value for the messenger parameter', 'event_espresso')); |
|
59 | 59 | } |
60 | - $this->set( 'MTP_messenger', $messenger ); |
|
60 | + $this->set('MTP_messenger', $messenger); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | * @param bool $GRP_ID |
67 | 67 | * @throws EE_Error |
68 | 68 | */ |
69 | - public function set_group_template_id( $GRP_ID = FALSE ) { |
|
70 | - if ( ! $GRP_ID ) { |
|
71 | - throw new EE_Error( __( 'Missing required value for the message template group id', 'event_espresso' ) ); |
|
69 | + public function set_group_template_id($GRP_ID = FALSE) { |
|
70 | + if ( ! $GRP_ID) { |
|
71 | + throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso')); |
|
72 | 72 | } |
73 | - $this->set( 'GRP_ID', $GRP_ID ); |
|
73 | + $this->set('GRP_ID', $GRP_ID); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @return int |
82 | 82 | */ |
83 | 83 | public function GRP_ID() { |
84 | - return $this->get( 'GRP_ID' ); |
|
84 | + return $this->get('GRP_ID'); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | * @return int |
93 | 93 | */ |
94 | 94 | public function user() { |
95 | - $user_id = $this->get( 'MTP_user_id' ); |
|
96 | - return empty( $user_id ) ? get_current_user_id() : $user_id; |
|
95 | + $user_id = $this->get('MTP_user_id'); |
|
96 | + return empty($user_id) ? get_current_user_id() : $user_id; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @return int |
117 | 117 | */ |
118 | 118 | public function count_events() { |
119 | - return $this->count_related( 'Event' ); |
|
119 | + return $this->count_related('Event'); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return string |
127 | 127 | */ |
128 | 128 | public function name() { |
129 | - return $this->get( 'MTP_name' ); |
|
129 | + return $this->get('MTP_name'); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @return string |
137 | 137 | */ |
138 | 138 | public function description() { |
139 | - return $this->get( 'MTP_description' ); |
|
139 | + return $this->get('MTP_description'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @param array $query_params like EEM_Base::get_all() |
147 | 147 | * @return EE_Message_Template[] |
148 | 148 | */ |
149 | - public function message_templates( $query_params = array() ) { |
|
150 | - return $this->get_many_related( 'Message_Template', $query_params ); |
|
149 | + public function message_templates($query_params = array()) { |
|
150 | + return $this->get_many_related('Message_Template', $query_params); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | public function messenger() { |
161 | - return $this->get( 'MTP_messenger' ); |
|
161 | + return $this->get('MTP_messenger'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | public function messenger_obj() { |
176 | 176 | $messenger = $this->messenger(); |
177 | 177 | try { |
178 | - $messenger = EEH_MSG_Template::messenger_obj( $messenger ); |
|
179 | - } catch( EE_Error $e ) { |
|
178 | + $messenger = EEH_MSG_Template::messenger_obj($messenger); |
|
179 | + } catch (EE_Error $e) { |
|
180 | 180 | //if an exception was thrown then let's deactivate this message template group because it means there is no class for this messenger in this group. |
181 | - $this->set( 'MTP_is_active', false ); |
|
181 | + $this->set('MTP_is_active', false); |
|
182 | 182 | $this->save(); |
183 | 183 | return null; |
184 | 184 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @return string |
195 | 195 | */ |
196 | 196 | public function message_type() { |
197 | - return $this->get( 'MTP_message_type' ); |
|
197 | + return $this->get('MTP_message_type'); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | public function message_type_obj() { |
213 | 213 | $message_type = $this->message_type(); |
214 | 214 | try { |
215 | - $message_type = EEH_MSG_Template::message_type_obj( $message_type ); |
|
216 | - } catch(EE_Error $e) { |
|
215 | + $message_type = EEH_MSG_Template::message_type_obj($message_type); |
|
216 | + } catch (EE_Error $e) { |
|
217 | 217 | //if an exception was thrown then let's deactivate this message template group because it means there is no class for the message type in this group. |
218 | - $this->set( 'MTP_is_active', false ); |
|
218 | + $this->set('MTP_is_active', false); |
|
219 | 219 | $this->save(); |
220 | 220 | return null; |
221 | 221 | } |
@@ -252,13 +252,13 @@ discard block |
||
252 | 252 | */ |
253 | 253 | public function context_templates() { |
254 | 254 | $mtps_arr = array(); |
255 | - $mtps = $this->get_many_related( 'Message_Template' ); |
|
256 | - if ( empty( $mtps ) ) { |
|
255 | + $mtps = $this->get_many_related('Message_Template'); |
|
256 | + if (empty($mtps)) { |
|
257 | 257 | return array(); |
258 | 258 | } |
259 | 259 | //note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field. |
260 | - foreach ( $mtps as $mtp ) { |
|
261 | - $mtps_arr[ $mtp->get( 'MTP_context' ) ][ $mtp->get( 'MTP_template_field' ) ] = $mtp; |
|
260 | + foreach ($mtps as $mtp) { |
|
261 | + $mtps_arr[$mtp->get('MTP_context')][$mtp->get('MTP_template_field')] = $mtp; |
|
262 | 262 | } |
263 | 263 | return $mtps_arr; |
264 | 264 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @return boolean true if it is, false if it isn't |
271 | 271 | */ |
272 | 272 | public function is_global() { |
273 | - return $this->get( 'MTP_is_global' ); |
|
273 | + return $this->get('MTP_is_global'); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @return boolean true if it is, false if it isn't |
281 | 281 | */ |
282 | 282 | public function is_active() { |
283 | - return $this->get( 'MTP_is_active' ); |
|
283 | + return $this->get('MTP_is_active'); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | |
@@ -296,10 +296,10 @@ discard block |
||
296 | 296 | * @param bool $merged If TRUE then we don't return shortcodes indexed by field but instead an array of the unique shortcodes for all the given (or all) fields. |
297 | 297 | * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no shortcodes found. |
298 | 298 | */ |
299 | - public function get_shortcodes( $context, $fields = array(), $merged = FALSE ) { |
|
299 | + public function get_shortcodes($context, $fields = array(), $merged = FALSE) { |
|
300 | 300 | $messenger = $this->messenger(); |
301 | 301 | $message_type = $this->message_type(); |
302 | - return EEH_MSG_Template::get_shortcodes( $message_type, $messenger, $fields, $context, $merged ); |
|
302 | + return EEH_MSG_Template::get_shortcodes($message_type, $messenger, $fields, $context, $merged); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * @return string |
341 | 341 | */ |
342 | 342 | public function get_template_pack_name() { |
343 | - return $this->get_extra_meta( 'MTP_template_pack', true, 'default' ); |
|
343 | + return $this->get_extra_meta('MTP_template_pack', true, 'default'); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public function get_template_pack() { |
357 | 357 | $pack_name = $this->get_template_pack_name(); |
358 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
359 | - return EEH_MSG_Template::get_template_pack( $pack_name ); |
|
358 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
359 | + return EEH_MSG_Template::get_template_pack($pack_name); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @return string |
370 | 370 | */ |
371 | 371 | public function get_template_pack_variation() { |
372 | - return $this->get_extra_meta( 'MTP_variation', TRUE, 'default' ); |
|
372 | + return $this->get_extra_meta('MTP_variation', TRUE, 'default'); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | * @param string $template_pack_name What message template pack is assigned. |
382 | 382 | * @return int |
383 | 383 | */ |
384 | - public function set_template_pack_name( $template_pack_name ) { |
|
385 | - return $this->update_extra_meta( 'MTP_template_pack', $template_pack_name ); |
|
384 | + public function set_template_pack_name($template_pack_name) { |
|
385 | + return $this->update_extra_meta('MTP_template_pack', $template_pack_name); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -394,8 +394,8 @@ discard block |
||
394 | 394 | * @param string $variation What variation is being set on the message template group. |
395 | 395 | * @return int |
396 | 396 | */ |
397 | - public function set_template_pack_variation( $variation ) { |
|
398 | - return $this->update_extra_meta( 'MTP_variation', $variation ); |
|
397 | + public function set_template_pack_variation($variation) { |
|
398 | + return $this->update_extra_meta('MTP_variation', $variation); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | //end EE_Message_Template_Group class |