@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @param \EE_Message_Resource_Manager $Message_Resource_Manager |
54 | 54 | * @return \EE_Message_Factory instance |
55 | 55 | */ |
56 | - public static function instance( EE_Message_Resource_Manager $Message_Resource_Manager = null ) { |
|
56 | + public static function instance(EE_Message_Resource_Manager $Message_Resource_Manager = null) { |
|
57 | 57 | // check if class object is instantiated, and instantiated properly |
58 | - if ( ! self::$_instance instanceof EE_Message_Factory ) { |
|
59 | - self::$_instance = new EE_Message_Factory( $Message_Resource_Manager ); |
|
58 | + if ( ! self::$_instance instanceof EE_Message_Factory) { |
|
59 | + self::$_instance = new EE_Message_Factory($Message_Resource_Manager); |
|
60 | 60 | } |
61 | 61 | return self::$_instance; |
62 | 62 | } |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | * @param array $props_n_values |
69 | 69 | * @return mixed |
70 | 70 | */ |
71 | - public static function create( $props_n_values = array() ) { |
|
72 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
73 | - return $Message_Factory->_create( $props_n_values ); |
|
71 | + public static function create($props_n_values = array()) { |
|
72 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
73 | + return $Message_Factory->_create($props_n_values); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * @return \EE_Message |
82 | 82 | * @throws \EE_Error |
83 | 83 | */ |
84 | - public static function set_messenger_and_message_type( EE_Message $message ) { |
|
85 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
86 | - return $Message_Factory->_set_messenger_and_message_type( $message ); |
|
84 | + public static function set_messenger_and_message_type(EE_Message $message) { |
|
85 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
86 | + return $Message_Factory->_set_messenger_and_message_type($message); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @return \EE_Message |
95 | 95 | * @throws \EE_Error |
96 | 96 | */ |
97 | - public static function set_messenger( EE_Message $message ) { |
|
98 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
99 | - return $Message_Factory->_set_messenger( $message ); |
|
97 | + public static function set_messenger(EE_Message $message) { |
|
98 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
99 | + return $Message_Factory->_set_messenger($message); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | * @return \EE_Message |
108 | 108 | * @throws \EE_Error |
109 | 109 | */ |
110 | - public static function set_message_type( EE_Message $message ) { |
|
111 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
112 | - return $Message_Factory->_set_message_type( $message ); |
|
110 | + public static function set_message_type(EE_Message $message) { |
|
111 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
112 | + return $Message_Factory->_set_message_type($message); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | * @return \EE_Message |
121 | 121 | * @throws \EE_Error |
122 | 122 | */ |
123 | - protected function _create( $props_n_values = array() ) { |
|
124 | - if ( ! empty( $props_n_values['MSG_ID'] ) ) { |
|
125 | - $message = EE_Message::new_instance_from_db( $props_n_values ); |
|
123 | + protected function _create($props_n_values = array()) { |
|
124 | + if ( ! empty($props_n_values['MSG_ID'])) { |
|
125 | + $message = EE_Message::new_instance_from_db($props_n_values); |
|
126 | 126 | } else { |
127 | - $message = EE_Message::new_instance( $props_n_values ); |
|
127 | + $message = EE_Message::new_instance($props_n_values); |
|
128 | 128 | } |
129 | - return $this->_set_messenger_and_message_type( $message ); |
|
129 | + return $this->_set_messenger_and_message_type($message); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * @return \EE_Message |
138 | 138 | * @throws \EE_Error |
139 | 139 | */ |
140 | - protected function _set_messenger_and_message_type( EE_Message $message ) { |
|
141 | - $message = $this->_set_messenger( $message ); |
|
142 | - $message = $this->_set_message_type( $message ); |
|
140 | + protected function _set_messenger_and_message_type(EE_Message $message) { |
|
141 | + $message = $this->_set_messenger($message); |
|
142 | + $message = $this->_set_message_type($message); |
|
143 | 143 | return $message; |
144 | 144 | } |
145 | 145 | |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * @return \EE_Message |
152 | 152 | * @throws \EE_Error |
153 | 153 | */ |
154 | - protected function _set_messenger( EE_Message $message ) { |
|
155 | - $messenger = $this->_message_resource_manager->get_messenger( $message->messenger() ); |
|
156 | - if ( $messenger instanceof EE_Messenger ) { |
|
157 | - $message->set_messenger_object( $messenger ); |
|
154 | + protected function _set_messenger(EE_Message $message) { |
|
155 | + $messenger = $this->_message_resource_manager->get_messenger($message->messenger()); |
|
156 | + if ($messenger instanceof EE_Messenger) { |
|
157 | + $message->set_messenger_object($messenger); |
|
158 | 158 | } |
159 | 159 | return $message; |
160 | 160 | } |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | * @return \EE_Message |
168 | 168 | * @throws \EE_Error |
169 | 169 | */ |
170 | - protected function _set_message_type( EE_Message $message ) { |
|
171 | - $message_type = $this->_message_resource_manager->get_message_type( $message->message_type() ); |
|
172 | - if ( $message_type instanceof EE_Message_Type ) { |
|
173 | - $message->set_message_type_object( $message_type ); |
|
170 | + protected function _set_message_type(EE_Message $message) { |
|
171 | + $message_type = $this->_message_resource_manager->get_message_type($message->message_type()); |
|
172 | + if ($message_type instanceof EE_Message_Type) { |
|
173 | + $message->set_message_type_object($message_type); |
|
174 | 174 | } |
175 | 175 | return $message; |
176 | 176 | } |
@@ -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 | |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | * @param mixed $info |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function add( $object, $info = null ) { |
|
43 | - $info = empty( $info ) && $object instanceof $this->interface ? $object->name : $info; |
|
44 | - return parent::add( $object, $info ); |
|
42 | + public function add($object, $info = null) { |
|
43 | + $info = empty($info) && $object instanceof $this->interface ? $object->name : $info; |
|
44 | + return parent::add($object, $info); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param mixed $info |
58 | 58 | * @return bool |
59 | 59 | */ |
60 | - public function set_info( $object, $info = null ) { |
|
61 | - $info = empty( $info ) && $object instanceof $this->interface ? $object->name : $info; |
|
62 | - return parent::set_info( $object, $info ); |
|
60 | + public function set_info($object, $info = null) { |
|
61 | + $info = empty($info) && $object instanceof $this->interface ? $object->name : $info; |
|
62 | + return parent::set_info($object, $info); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * @param mixed |
75 | 75 | * @return null | object |
76 | 76 | */ |
77 | - public function get_by_info( $info ) { |
|
78 | - return parent::get_by_info( $info ); |
|
77 | + public function get_by_info($info) { |
|
78 | + return parent::get_by_info($info); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @param object $object |
90 | 90 | * @return bool |
91 | 91 | */ |
92 | - public function has( $object ) { |
|
93 | - return parent::has( $object ); |
|
92 | + public function has($object) { |
|
93 | + return parent::has($object); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @param string $messenger_name |
105 | 105 | * @return bool |
106 | 106 | */ |
107 | - public function has_by_name( $messenger_name ) { |
|
108 | - return $this->get_by_info( $messenger_name ) instanceof $this->interface ? true : false; |
|
107 | + public function has_by_name($messenger_name) { |
|
108 | + return $this->get_by_info($messenger_name) instanceof $this->interface ? true : false; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @param $object |
120 | 120 | * @return bool |
121 | 121 | */ |
122 | - public function remove( $object ) { |
|
123 | - return parent::remove( $object ); |
|
122 | + public function remove($object) { |
|
123 | + return parent::remove($object); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | * @param $object |
149 | 149 | * @return void |
150 | 150 | */ |
151 | - public function set_current( $object ) { |
|
152 | - parent::set_current( $object ); |
|
151 | + public function set_current($object) { |
|
152 | + parent::set_current($object); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | * @param $info |
164 | 164 | * @return void |
165 | 165 | */ |
166 | - public function set_current_by_info( $info ) { |
|
167 | - parent::set_current_by_info( $info ); |
|
166 | + public function set_current_by_info($info) { |
|
167 | + parent::set_current_by_info($info); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | * @return void |
179 | 179 | */ |
180 | 180 | public function show_collection_classes() { |
181 | - if ( WP_DEBUG ) { |
|
181 | + if (WP_DEBUG) { |
|
182 | 182 | $this->rewind(); |
183 | - while ( $this->valid() ) { |
|
184 | - echo '<h5 style="color:#2EA2CC;">collection class : <span style="color:#E76700">' . $this->getInfo() |
|
183 | + while ($this->valid()) { |
|
184 | + echo '<h5 style="color:#2EA2CC;">collection class : <span style="color:#E76700">'.$this->getInfo() |
|
185 | 185 | . '</span></h5>'; |
186 | 186 | $this->next(); |
187 | 187 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @return EED_Module |
67 | 67 | */ |
68 | 68 | public static function instance() { |
69 | - return parent::get_instance( __CLASS__ ); |
|
69 | + return parent::get_instance(__CLASS__); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public static function set_hooks() { |
83 | 83 | //actions |
84 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
85 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 2 ); |
|
84 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
85 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 2); |
|
86 | 86 | //filters |
87 | - add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
88 | - add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
87 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
88 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
89 | 89 | //register routes |
90 | 90 | self::_register_routes(); |
91 | 91 | } |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public static function set_hooks_admin() { |
100 | 100 | //actions |
101 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
102 | - add_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array( 'EED_Messages', 'payment_reminder' ), 10 ); |
|
103 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 3 ); |
|
104 | - add_action( 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', array( 'EED_Messages', 'send_newsletter_message' ), 10, 2 ); |
|
105 | - add_action( 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array( 'EED_Messages', 'cancelled_registration' ), 10 ); |
|
106 | - add_action( 'AHEE__EE_Admin_Page___process_admin_payment_notification', array( 'EED_Messages', 'process_admin_payment' ), 10, 1 ); |
|
101 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
102 | + add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array('EED_Messages', 'payment_reminder'), 10); |
|
103 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 3); |
|
104 | + add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', array('EED_Messages', 'send_newsletter_message'), 10, 2); |
|
105 | + add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array('EED_Messages', 'cancelled_registration'), 10); |
|
106 | + add_action('AHEE__EE_Admin_Page___process_admin_payment_notification', array('EED_Messages', 'process_admin_payment'), 10, 1); |
|
107 | 107 | //filters |
108 | - add_filter( 'FHEE__EE_Admin_Page___process_resend_registration__success', array( 'EED_Messages', 'process_resend' ), 10, 2 ); |
|
109 | - add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
110 | - add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
108 | + add_filter('FHEE__EE_Admin_Page___process_resend_registration__success', array('EED_Messages', 'process_resend'), 10, 2); |
|
109 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
110 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | * @return void |
122 | 122 | */ |
123 | 123 | protected static function _register_routes() { |
124 | - EE_Config::register_route( 'msg_url_trigger', 'Messages', 'run' ); |
|
125 | - EE_Config::register_route( 'msg_cron_trigger', 'Messages', 'run_cron' ); |
|
126 | - EE_Config::register_route( 'msg_browser_trigger', 'Messages', 'browser_trigger' ); |
|
127 | - EE_Config::register_route( 'msg_browser_error_trigger', 'Messages', 'browser_error_trigger' ); |
|
128 | - do_action( 'AHEE__EED_Messages___register_routes' ); |
|
124 | + EE_Config::register_route('msg_url_trigger', 'Messages', 'run'); |
|
125 | + EE_Config::register_route('msg_cron_trigger', 'Messages', 'run_cron'); |
|
126 | + EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
127 | + EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
128 | + do_action('AHEE__EED_Messages___register_routes'); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -136,18 +136,18 @@ discard block |
||
136 | 136 | * @since 4.9.0 |
137 | 137 | * @param WP $WP |
138 | 138 | */ |
139 | - public function browser_trigger( $WP ) { |
|
139 | + public function browser_trigger($WP) { |
|
140 | 140 | //ensure controller is loaded |
141 | 141 | self::_load_controller(); |
142 | - $token = EE_Registry::instance()->REQ->get( 'token' ); |
|
142 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
143 | 143 | try { |
144 | - $mtg = new EE_Message_Generated_From_Token( $token, 'html', self::$_EEMSG ); |
|
145 | - self::$_MSG_PROCESSOR->generate_and_send_now( $mtg ); |
|
146 | - } catch( EE_Error $e ) { |
|
147 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
144 | + $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_EEMSG); |
|
145 | + self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
146 | + } catch (EE_Error $e) { |
|
147 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
148 | 148 | // add specific message for developers if WP_DEBUG in on |
149 | - $error_msg .= '||' . $e->getMessage(); |
|
150 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
149 | + $error_msg .= '||'.$e->getMessage(); |
|
150 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -163,21 +163,21 @@ discard block |
||
163 | 163 | * @since 4.9.0 |
164 | 164 | * @param $WP |
165 | 165 | */ |
166 | - public function browser_error_trigger( $WP ) { |
|
167 | - $token = EE_Registry::instance()->REQ->get( 'token' ); |
|
168 | - if ( $token ) { |
|
169 | - $message = EEM_Message::instance()->get_one_by_token( $token ); |
|
170 | - if ( $message instanceof EE_Message ) { |
|
171 | - header( 'HTTP/1.1 200 OK' ); |
|
166 | + public function browser_error_trigger($WP) { |
|
167 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
168 | + if ($token) { |
|
169 | + $message = EEM_Message::instance()->get_one_by_token($token); |
|
170 | + if ($message instanceof EE_Message) { |
|
171 | + header('HTTP/1.1 200 OK'); |
|
172 | 172 | $error_msg = $message->error_message(); |
173 | 173 | ?> |
174 | 174 | <!DOCTYPE html> |
175 | 175 | <html> |
176 | 176 | <head></head> |
177 | 177 | <body> |
178 | - <?php echo empty( $error_msg ) |
|
179 | - ? esc_html__( 'Unfortunately, we were unable to capture the error message for this message.', 'event_espresso' ) |
|
180 | - : wp_kses( $error_msg, array( 'a', 'span', 'div', 'p', 'strong', 'em', 'br' ) ); ?> |
|
178 | + <?php echo empty($error_msg) |
|
179 | + ? esc_html__('Unfortunately, we were unable to capture the error message for this message.', 'event_espresso') |
|
180 | + : wp_kses($error_msg, array('a', 'span', 'div', 'p', 'strong', 'em', 'br')); ?> |
|
181 | 181 | </body> |
182 | 182 | </html> |
183 | 183 | <?php |
@@ -197,18 +197,18 @@ discard block |
||
197 | 197 | * @throws EE_Error |
198 | 198 | * @return void |
199 | 199 | */ |
200 | - public function run( $WP ) { |
|
200 | + public function run($WP) { |
|
201 | 201 | //ensure controller is loaded |
202 | 202 | self::_load_controller(); |
203 | 203 | // attempt to process message |
204 | 204 | try { |
205 | - $mtg = new EE_Message_To_Generate_From_Request( self::$_EEMSG, EE_Registry::instance()->REQ ); |
|
206 | - self::$_MSG_PROCESSOR->generate_and_send_now( $mtg ); |
|
207 | - } catch ( EE_Error $e ) { |
|
208 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
205 | + $mtg = new EE_Message_To_Generate_From_Request(self::$_EEMSG, EE_Registry::instance()->REQ); |
|
206 | + self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
207 | + } catch (EE_Error $e) { |
|
208 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
209 | 209 | // add specific message for developers if WP_DEBUG in on |
210 | - $error_msg .= '||' . $e->getMessage(); |
|
211 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
210 | + $error_msg .= '||'.$e->getMessage(); |
|
211 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
@@ -217,30 +217,30 @@ discard block |
||
217 | 217 | * This is triggered by the 'msg_cron_trigger' route. |
218 | 218 | * @param WP $WP |
219 | 219 | */ |
220 | - public function run_cron( $WP ) { |
|
220 | + public function run_cron($WP) { |
|
221 | 221 | self::_load_controller(); |
222 | 222 | //get required vars |
223 | - $cron_type = EE_Registry::instance()->REQ->get( 'type' ); |
|
224 | - $nonce = EE_Registry::instance()->REQ->get( '_nonce' ); |
|
225 | - header( 'HTTP/1.1 200 OK' ); |
|
223 | + $cron_type = EE_Registry::instance()->REQ->get('type'); |
|
224 | + $nonce = EE_Registry::instance()->REQ->get('_nonce'); |
|
225 | + header('HTTP/1.1 200 OK'); |
|
226 | 226 | |
227 | 227 | //now let's verify nonce, if not valid exit immediately |
228 | - if ( ! wp_verify_nonce( $nonce, 'EE_Messages_Scheduler_' . $cron_type ) ) { |
|
228 | + if ( ! wp_verify_nonce($nonce, 'EE_Messages_Scheduler_'.$cron_type)) { |
|
229 | 229 | /** |
230 | 230 | * trigger error so this gets in the error logs. This is important because it happens on a non-user request. |
231 | 231 | */ |
232 | - trigger_error( esc_attr__( 'Invalid Nonce', 'event_espresso' ) ); |
|
232 | + trigger_error(esc_attr__('Invalid Nonce', 'event_espresso')); |
|
233 | 233 | } |
234 | 234 | |
235 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
236 | - if ( method_exists( self::$_MSG_PROCESSOR, $method ) ) { |
|
235 | + $method = 'batch_'.$cron_type.'_from_queue'; |
|
236 | + if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
237 | 237 | self::$_MSG_PROCESSOR->$method(); |
238 | 238 | } else { |
239 | 239 | //no matching task |
240 | 240 | /** |
241 | 241 | * trigger error so this gets in the error logs. This is important because it happens on a non user request. |
242 | 242 | */ |
243 | - trigger_error( esc_attr( sprintf( __( 'There is no task corresponding to this route %s', 'event_espresso' ), $cron_type ) ) ); |
|
243 | + trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'), $cron_type))); |
|
244 | 244 | } |
245 | 245 | exit(); |
246 | 246 | } |
@@ -258,9 +258,9 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return EE_Messages_Template_Pack |
260 | 260 | */ |
261 | - public static function get_template_pack( $template_pack_name ) { |
|
262 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
263 | - return EEH_MSG_Template::get_template_pack( $template_pack_name ); |
|
261 | + public static function get_template_pack($template_pack_name) { |
|
262 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
263 | + return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -274,14 +274,14 @@ discard block |
||
274 | 274 | * @return EE_Messages_Template_Pack[] |
275 | 275 | */ |
276 | 276 | public static function get_template_packs() { |
277 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
277 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
278 | 278 | |
279 | 279 | //for backward compat, let's make sure this returns in the same format as originally. |
280 | 280 | $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
281 | 281 | $template_pack_collection->rewind(); |
282 | 282 | $template_packs = array(); |
283 | - while ( $template_pack_collection->valid() ) { |
|
284 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
283 | + while ($template_pack_collection->valid()) { |
|
284 | + $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current(); |
|
285 | 285 | $template_pack_collection->next(); |
286 | 286 | } |
287 | 287 | return $template_packs; |
@@ -297,15 +297,15 @@ discard block |
||
297 | 297 | * @return void |
298 | 298 | */ |
299 | 299 | public static function set_autoloaders() { |
300 | - if ( empty( self::$_MSG_PATHS ) ) { |
|
300 | + if (empty(self::$_MSG_PATHS)) { |
|
301 | 301 | self::_set_messages_paths(); |
302 | - EE_Registry::instance()->load_helper( 'Autoloader' ); |
|
303 | - foreach ( self::$_MSG_PATHS as $path ) { |
|
304 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $path ); |
|
302 | + EE_Registry::instance()->load_helper('Autoloader'); |
|
303 | + foreach (self::$_MSG_PATHS as $path) { |
|
304 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
305 | 305 | } |
306 | 306 | // add aliases |
307 | - EEH_Autoloader::add_alias( 'EE_messages', 'EE_Messages' ); |
|
308 | - EEH_Autoloader::add_alias( 'EE_messenger', 'EE_Messenger' ); |
|
307 | + EEH_Autoloader::add_alias('EE_messages', 'EE_Messages'); |
|
308 | + EEH_Autoloader::add_alias('EE_messenger', 'EE_Messenger'); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | 'shortcodes', |
335 | 335 | ); |
336 | 336 | $paths = array(); |
337 | - foreach ( $dir_ref as $index => $dir ) { |
|
338 | - $paths[ $index ] = EE_LIBRARIES . $dir; |
|
337 | + foreach ($dir_ref as $index => $dir) { |
|
338 | + $paths[$index] = EE_LIBRARIES.$dir; |
|
339 | 339 | } |
340 | - self::$_MSG_PATHS = apply_filters( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths ); |
|
340 | + self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | * @return void |
350 | 350 | */ |
351 | 351 | protected static function _load_controller() { |
352 | - if ( ! self::$_EEMSG instanceof EE_Messages ) { |
|
353 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
352 | + if ( ! self::$_EEMSG instanceof EE_Messages) { |
|
353 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
354 | 354 | self::set_autoloaders(); |
355 | - self::$_EEMSG = EE_Registry::instance()->load_lib( 'messages' ); |
|
356 | - self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib( 'Messages_Processor', self::$_EEMSG ); |
|
355 | + self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
356 | + self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor', self::$_EEMSG); |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | |
@@ -362,10 +362,10 @@ discard block |
||
362 | 362 | /** |
363 | 363 | * @param EE_Transaction $transaction |
364 | 364 | */ |
365 | - public static function payment_reminder( EE_Transaction $transaction ) { |
|
365 | + public static function payment_reminder(EE_Transaction $transaction) { |
|
366 | 366 | self::_load_controller(); |
367 | - $data = array( $transaction, null ); |
|
368 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'payment_reminder', $data ); |
|
367 | + $data = array($transaction, null); |
|
368 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | |
@@ -376,14 +376,14 @@ discard block |
||
376 | 376 | * @param EE_Payment object |
377 | 377 | * @return void |
378 | 378 | */ |
379 | - public static function payment( EE_Transaction $transaction, EE_Payment $payment ) { |
|
379 | + public static function payment(EE_Transaction $transaction, EE_Payment $payment) { |
|
380 | 380 | self::_load_controller(); |
381 | - $data = array( $transaction, $payment ); |
|
382 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
383 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
381 | + $data = array($transaction, $payment); |
|
382 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
383 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
384 | 384 | //if payment amount is less than 0 then switch to payment_refund message type. |
385 | 385 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
386 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
386 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | /** |
392 | 392 | * @param EE_Transaction $transaction |
393 | 393 | */ |
394 | - public static function cancelled_registration( EE_Transaction $transaction ) { |
|
394 | + public static function cancelled_registration(EE_Transaction $transaction) { |
|
395 | 395 | self::_load_controller(); |
396 | - $data = array( $transaction, null ); |
|
397 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'cancelled_registration', $data ); |
|
396 | + $data = array($transaction, null); |
|
397 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
@@ -407,14 +407,14 @@ discard block |
||
407 | 407 | * @param array $extra_details |
408 | 408 | * @return void |
409 | 409 | */ |
410 | - public static function maybe_registration( EE_Registration $registration, $extra_details = array() ) { |
|
410 | + public static function maybe_registration(EE_Registration $registration, $extra_details = array()) { |
|
411 | 411 | |
412 | - if ( ! self::_verify_registration_notification_send( $registration, $extra_details ) ) { |
|
412 | + if ( ! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
413 | 413 | //no messages please |
414 | 414 | return; |
415 | 415 | } |
416 | 416 | |
417 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
417 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
418 | 418 | |
419 | 419 | //get all registrations so we make sure we send messages for the right status. |
420 | 420 | $all_registrations = $registration->transaction()->registrations(); |
@@ -425,22 +425,22 @@ discard block |
||
425 | 425 | $mtgs = array(); |
426 | 426 | |
427 | 427 | //loop through registrations and trigger messages once per status. |
428 | - foreach ( $all_registrations as $reg ) { |
|
428 | + foreach ($all_registrations as $reg) { |
|
429 | 429 | |
430 | 430 | //already triggered? |
431 | - if ( in_array( $reg->status_ID(), $statuses_sent ) ) { |
|
431 | + if (in_array($reg->status_ID(), $statuses_sent)) { |
|
432 | 432 | continue; |
433 | 433 | } |
434 | 434 | |
435 | - $message_type = EEH_MSG_Template::convert_reg_status_to_message_type( $reg->status_ID() ); |
|
436 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( $message_type, array( $registration->transaction(), null, $reg->status_ID() ) ); |
|
435 | + $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
436 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers($message_type, array($registration->transaction(), null, $reg->status_ID())); |
|
437 | 437 | $statuses_sent[] = $reg->status_ID(); |
438 | 438 | } |
439 | 439 | |
440 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( 'registration_summary', array( $registration->transaction(), null ) ); |
|
440 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers('registration_summary', array($registration->transaction(), null)); |
|
441 | 441 | |
442 | 442 | //batch queue and initiate request |
443 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $mtgs ); |
|
443 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
444 | 444 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
445 | 445 | } |
446 | 446 | |
@@ -455,39 +455,39 @@ discard block |
||
455 | 455 | * |
456 | 456 | * @return bool true = send away, false = nope halt the presses. |
457 | 457 | */ |
458 | - protected static function _verify_registration_notification_send( EE_Registration $registration, $extra_details = array() ) { |
|
458 | + protected static function _verify_registration_notification_send(EE_Registration $registration, $extra_details = array()) { |
|
459 | 459 | //self::log( |
460 | 460 | // __CLASS__, __FUNCTION__, __LINE__, |
461 | 461 | // $registration->transaction(), |
462 | 462 | // array( '$extra_details' => $extra_details ) |
463 | 463 | //); |
464 | 464 | // currently only using this to send messages for the primary registrant |
465 | - if ( ! $registration->is_primary_registrant() ) { |
|
465 | + if ( ! $registration->is_primary_registrant()) { |
|
466 | 466 | return false; |
467 | 467 | } |
468 | 468 | // first we check if we're in admin and not doing front ajax |
469 | - if ( is_admin() && ! EE_FRONT_AJAX ) { |
|
469 | + if (is_admin() && ! EE_FRONT_AJAX) { |
|
470 | 470 | //make sure appropriate admin params are set for sending messages |
471 | - if ( empty( $_REQUEST['txn_reg_status_change']['send_notifications'] ) || ! absint( $_REQUEST['txn_reg_status_change']['send_notifications'] ) ) { |
|
471 | + if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) { |
|
472 | 472 | //no messages sent please. |
473 | 473 | return false; |
474 | 474 | } |
475 | 475 | } else { |
476 | 476 | // frontend request (either regular or via AJAX) |
477 | 477 | // TXN is NOT finalized ? |
478 | - if ( ! isset( $extra_details['finalized'] ) || $extra_details['finalized'] === false ) { |
|
478 | + if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
479 | 479 | return false; |
480 | 480 | } |
481 | 481 | // return visit but nothing changed ??? |
482 | 482 | if ( |
483 | - isset( $extra_details['revisit'], $extra_details['status_updates'] ) && |
|
483 | + isset($extra_details['revisit'], $extra_details['status_updates']) && |
|
484 | 484 | $extra_details['revisit'] && ! $extra_details['status_updates'] |
485 | 485 | ) { |
486 | 486 | return false; |
487 | 487 | } |
488 | 488 | // NOT sending messages && reg status is something other than "Not-Approved" |
489 | 489 | if ( |
490 | - ! apply_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', false ) && |
|
490 | + ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
491 | 491 | $registration->status_ID() !== EEM_Registration::status_id_not_approved |
492 | 492 | ) { |
493 | 493 | return false; |
@@ -509,10 +509,10 @@ discard block |
||
509 | 509 | * |
510 | 510 | * @return array |
511 | 511 | */ |
512 | - protected static function _get_reg_status_array( $reg_status = '' ) { |
|
513 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
514 | - return EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
515 | - ? EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
512 | + protected static function _get_reg_status_array($reg_status = '') { |
|
513 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
514 | + return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
515 | + ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
516 | 516 | : EEH_MSG_Template::reg_status_to_message_type_array(); |
517 | 517 | } |
518 | 518 | |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | * |
529 | 529 | * @return string|bool The payment message type slug matching the status or false if no match. |
530 | 530 | */ |
531 | - protected static function _get_payment_message_type( $payment_status ) { |
|
532 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
533 | - return EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
534 | - ? EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
531 | + protected static function _get_payment_message_type($payment_status) { |
|
532 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
533 | + return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
534 | + ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
535 | 535 | : false; |
536 | 536 | } |
537 | 537 | |
@@ -545,23 +545,23 @@ discard block |
||
545 | 545 | * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
546 | 546 | * @return bool success/fail |
547 | 547 | */ |
548 | - public static function process_resend( $req_data ) { |
|
548 | + public static function process_resend($req_data) { |
|
549 | 549 | self::_load_controller(); |
550 | 550 | |
551 | 551 | //if $msgID in this request then skip to the new resend_message |
552 | - if ( EE_Registry::instance()->REQ->get( 'MSG_ID' ) ) { |
|
552 | + if (EE_Registry::instance()->REQ->get('MSG_ID')) { |
|
553 | 553 | return self::resend_message(); |
554 | 554 | } |
555 | 555 | |
556 | - if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() ) { |
|
556 | + if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) { |
|
557 | 557 | return false; |
558 | 558 | } |
559 | 559 | |
560 | 560 | try { |
561 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $messages_to_send ); |
|
561 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
562 | 562 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
563 | - } catch( EE_Error $e ) { |
|
564 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
563 | + } catch (EE_Error $e) { |
|
564 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
565 | 565 | return false; |
566 | 566 | } |
567 | 567 | return true; //everything got queued. |
@@ -575,17 +575,17 @@ discard block |
||
575 | 575 | public static function resend_message() { |
576 | 576 | self::_load_controller(); |
577 | 577 | |
578 | - $msgID = EE_Registry::instance()->REQ->get( 'MSG_ID' ); |
|
579 | - if ( ! $msgID ) { |
|
580 | - EE_Error::add_error( __( 'Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
578 | + $msgID = EE_Registry::instance()->REQ->get('MSG_ID'); |
|
579 | + if ( ! $msgID) { |
|
580 | + EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | |
584 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( (array) $msgID ); |
|
584 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
585 | 585 | |
586 | 586 | //setup success message. |
587 | - $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
588 | - EE_Error::add_success( sprintf( |
|
587 | + $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
588 | + EE_Error::add_success(sprintf( |
|
589 | 589 | _n( |
590 | 590 | 'There was %d message queued for resending.', |
591 | 591 | 'There were %d messages queued for resending.', |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | 'event_espresso' |
594 | 594 | ), |
595 | 595 | $count_ready_for_resend |
596 | - ) ); |
|
596 | + )); |
|
597 | 597 | return true; |
598 | 598 | } |
599 | 599 | |
@@ -606,13 +606,13 @@ discard block |
||
606 | 606 | * @param EE_Payment $payment EE_payment object |
607 | 607 | * @return bool success/fail |
608 | 608 | */ |
609 | - public static function process_admin_payment( EE_Payment $payment ) { |
|
610 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
609 | + public static function process_admin_payment(EE_Payment $payment) { |
|
610 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
611 | 611 | //we need to get the transaction object |
612 | 612 | $transaction = $payment->transaction(); |
613 | - if ( $transaction instanceof EE_Transaction ) { |
|
614 | - $data = array( $transaction, $payment ); |
|
615 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
613 | + if ($transaction instanceof EE_Transaction) { |
|
614 | + $data = array($transaction, $payment); |
|
615 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
616 | 616 | |
617 | 617 | //if payment amount is less than 0 then switch to payment_refund message type. |
618 | 618 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
@@ -622,17 +622,17 @@ discard block |
||
622 | 622 | |
623 | 623 | self::_load_controller(); |
624 | 624 | |
625 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
625 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
626 | 626 | |
627 | 627 | //get count of queued for generation |
628 | - $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
628 | + $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
629 | 629 | |
630 | - if ( $count_to_generate > 0 ) { |
|
631 | - add_filter( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true' ); |
|
630 | + if ($count_to_generate > 0) { |
|
631 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
632 | 632 | return true; |
633 | 633 | } else { |
634 | - $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::instance()->stati_indicating_failed_sending() ); |
|
635 | - EE_Error::add_error( sprintf( |
|
634 | + $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending()); |
|
635 | + EE_Error::add_error(sprintf( |
|
636 | 636 | _n( |
637 | 637 | 'The payment notification generation failed.', |
638 | 638 | '%d payment notifications failed being sent.', |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | 'event_espresso' |
641 | 641 | ), |
642 | 642 | $count_failed |
643 | - ), __FILE__, __FUNCTION__, __LINE__ ); |
|
643 | + ), __FILE__, __FUNCTION__, __LINE__); |
|
644 | 644 | return false; |
645 | 645 | } |
646 | 646 | } else { |
@@ -663,11 +663,11 @@ discard block |
||
663 | 663 | * @param int $grp_id a specific message template group id. |
664 | 664 | * @return void |
665 | 665 | */ |
666 | - public static function send_newsletter_message( $contacts, $grp_id ) { |
|
666 | + public static function send_newsletter_message($contacts, $grp_id) { |
|
667 | 667 | //make sure mtp is id and set it in the EE_Request Handler later messages setup. |
668 | - EE_Registry::instance()->REQ->set( 'GRP_ID', (int) $grp_id ); |
|
668 | + EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id); |
|
669 | 669 | self::_load_controller(); |
670 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'newsletter', $contacts ); |
|
670 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $contacts); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | |
@@ -682,10 +682,10 @@ discard block |
||
682 | 682 | * @param string $message_type |
683 | 683 | * @return string |
684 | 684 | */ |
685 | - public static function registration_message_trigger_url( $registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice' ) { |
|
686 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
685 | + public static function registration_message_trigger_url($registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice') { |
|
686 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
687 | 687 | // whitelist $messenger |
688 | - switch ( $messenger ) { |
|
688 | + switch ($messenger) { |
|
689 | 689 | case 'pdf' : |
690 | 690 | $sending_messenger = 'pdf'; |
691 | 691 | $generating_messenger = 'html'; |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | break; |
698 | 698 | } |
699 | 699 | // whitelist $message_type |
700 | - switch ( $message_type ) { |
|
700 | + switch ($message_type) { |
|
701 | 701 | case 'receipt' : |
702 | 702 | $message_type = 'receipt'; |
703 | 703 | break; |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | break; |
708 | 708 | } |
709 | 709 | // verify that both the messenger AND the message type are active |
710 | - if ( EEH_MSG_Template::is_messenger_active( $sending_messenger ) && EEH_MSG_Template::is_mt_active( $message_type ) ) { |
|
710 | + if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) { |
|
711 | 711 | //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?) |
712 | 712 | $template_query_params = array( |
713 | 713 | 'MTP_is_active' => true, |
@@ -716,16 +716,16 @@ discard block |
||
716 | 716 | 'Event.EVT_ID' => $registration->event_ID() |
717 | 717 | ); |
718 | 718 | //get the message template group. |
719 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
719 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
720 | 720 | //if we don't have an EE_Message_Template_Group then return |
721 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
721 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
722 | 722 | // remove EVT_ID from query params so that global templates get picked up |
723 | - unset( $template_query_params['Event.EVT_ID'] ); |
|
723 | + unset($template_query_params['Event.EVT_ID']); |
|
724 | 724 | //get global template as the fallback |
725 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
725 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
726 | 726 | } |
727 | 727 | //if we don't have an EE_Message_Template_Group then return |
728 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
728 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
729 | 729 | return ''; |
730 | 730 | } |
731 | 731 | // generate the URL |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
755 | 755 | * @return string The body of the message. |
756 | 756 | */ |
757 | - public static function preview_message( $type, $context, $messenger, $send = false ) { |
|
757 | + public static function preview_message($type, $context, $messenger, $send = false) { |
|
758 | 758 | self::_load_controller(); |
759 | 759 | $mtg = new EE_Message_To_Generate( |
760 | 760 | $messenger, |
@@ -764,8 +764,8 @@ discard block |
||
764 | 764 | $context, |
765 | 765 | true |
766 | 766 | ); |
767 | - $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview( $mtg ); |
|
768 | - if ( $generated_preview_queue instanceof EE_Messages_Queue ) { |
|
767 | + $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg); |
|
768 | + if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
769 | 769 | return $generated_preview_queue->get_queue()->current()->content(); |
770 | 770 | } else { |
771 | 771 | return $generated_preview_queue; |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | * |
790 | 790 | * @return bool success or fail. |
791 | 791 | */ |
792 | - public static function send_message_with_messenger_only( $messenger, $message_type, EE_Messages_Queue $queue ) { |
|
792 | + public static function send_message_with_messenger_only($messenger, $message_type, EE_Messages_Queue $queue) { |
|
793 | 793 | self::_load_controller(); |
794 | 794 | //set mtg |
795 | 795 | $mtg = new EE_Message_To_Generate_From_Queue( |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | $queue |
800 | 800 | ); |
801 | 801 | |
802 | - return self::$_MSG_PROCESSOR->queue_for_sending( $mtg ); |
|
802 | + return self::$_MSG_PROCESSOR->queue_for_sending($mtg); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | |
@@ -812,22 +812,22 @@ discard block |
||
812 | 812 | * @param array $message_ids An array of message ids |
813 | 813 | * @return bool | EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated messages. |
814 | 814 | */ |
815 | - public static function generate_now( $message_ids ) { |
|
815 | + public static function generate_now($message_ids) { |
|
816 | 816 | self::_load_controller(); |
817 | 817 | $messages = EEM_Message::instance()->get_all( |
818 | 818 | array( |
819 | 819 | 0 => array( |
820 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
820 | + 'MSG_ID' => array('IN', $message_ids), |
|
821 | 821 | 'STS_ID' => EEM_Message::status_incomplete, |
822 | 822 | ) |
823 | 823 | ) |
824 | 824 | ); |
825 | 825 | |
826 | - $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue( $messages ); |
|
826 | + $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
827 | 827 | |
828 | - if ( ! $generated_queue instanceof EE_Messages_Queue ) { |
|
828 | + if ( ! $generated_queue instanceof EE_Messages_Queue) { |
|
829 | 829 | EE_Error::add_error( |
830 | - __( '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' ), |
|
830 | + __('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'), |
|
831 | 831 | __FILE__, __FUNCTION__, __LINE__ |
832 | 832 | ); |
833 | 833 | } |
@@ -846,28 +846,28 @@ discard block |
||
846 | 846 | * |
847 | 847 | * @return bool | EE_Messages_Queue false if no messages sent. |
848 | 848 | */ |
849 | - public static function send_now( $message_ids ) { |
|
849 | + public static function send_now($message_ids) { |
|
850 | 850 | self::_load_controller(); |
851 | 851 | $messages = EEM_Message::instance()->get_all( |
852 | 852 | array( |
853 | 853 | 0 => array( |
854 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
855 | - 'STS_ID' => array( 'IN', array( EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry ) ) |
|
854 | + 'MSG_ID' => array('IN', $message_ids), |
|
855 | + 'STS_ID' => array('IN', array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry)) |
|
856 | 856 | ) |
857 | 857 | ) |
858 | 858 | ); |
859 | 859 | |
860 | - $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue( $messages ); |
|
860 | + $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
861 | 861 | |
862 | - if ( ! $sent_queue instanceof EE_Messages_Queue ) { |
|
862 | + if ( ! $sent_queue instanceof EE_Messages_Queue) { |
|
863 | 863 | EE_Error::add_error( |
864 | - __( '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' ), |
|
864 | + __('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'), |
|
865 | 865 | __FILE__, __FUNCTION__, __LINE__ |
866 | 866 | ); |
867 | 867 | } else { |
868 | 868 | //can count how many sent by using the messages in the queue |
869 | - $sent_count = $sent_queue->count_STS_in_queue( array( EEM_Message::instance()->stati_indicating_sent() ) ); |
|
870 | - if ( $sent_count > 0 ) { |
|
869 | + $sent_count = $sent_queue->count_STS_in_queue(array(EEM_Message::instance()->stati_indicating_sent())); |
|
870 | + if ($sent_count > 0) { |
|
871 | 871 | EE_Error::add_success( |
872 | 872 | sprintf( |
873 | 873 | _n( |
@@ -882,8 +882,8 @@ discard block |
||
882 | 882 | } else { |
883 | 883 | EE_Error::overwrite_errors(); |
884 | 884 | EE_Error::add_error( |
885 | - __( 'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, or there was an error. |
|
886 | - If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso' ), |
|
885 | + __('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, or there was an error. |
|
886 | + If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso'), |
|
887 | 887 | __FILE__, __FUNCTION__, __LINE__ |
888 | 888 | ); |
889 | 889 | } |
@@ -904,13 +904,13 @@ discard block |
||
904 | 904 | * |
905 | 905 | * @return bool true means messages were successfully queued for resending, false means none were queued for resending. |
906 | 906 | */ |
907 | - public static function queue_for_resending( $message_ids ) { |
|
907 | + public static function queue_for_resending($message_ids) { |
|
908 | 908 | self::_load_controller(); |
909 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( $message_ids ); |
|
909 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
910 | 910 | |
911 | 911 | //get queue and count |
912 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
913 | - if ( $queue_count > 0 ) { |
|
912 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
913 | + if ($queue_count > 0) { |
|
914 | 914 | EE_Error::add_success( |
915 | 915 | sprintf( |
916 | 916 | _n( |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | ); |
925 | 925 | } else { |
926 | 926 | EE_Error::add_error( |
927 | - __( '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' ), |
|
927 | + __('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'), |
|
928 | 928 | __FILE__, __FUNCTION__, __LINE__ |
929 | 929 | ); |
930 | 930 | } |
@@ -946,17 +946,17 @@ discard block |
||
946 | 946 | * @param array $info |
947 | 947 | * @param bool $display_request |
948 | 948 | */ |
949 | - protected static function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) { |
|
950 | - EE_Registry::instance()->load_helper( 'Debug_Tools' ); |
|
951 | - if ( WP_DEBUG && false ) { |
|
952 | - if ( $transaction instanceof EE_Transaction ) { |
|
949 | + protected static function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) { |
|
950 | + EE_Registry::instance()->load_helper('Debug_Tools'); |
|
951 | + if (WP_DEBUG && false) { |
|
952 | + if ($transaction instanceof EE_Transaction) { |
|
953 | 953 | // don't serialize objects |
954 | - $info = EEH_Debug_Tools::strip_objects( $info ); |
|
954 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
955 | 955 | $info['TXN_status'] = $transaction->status_ID(); |
956 | 956 | $info['TXN_reg_steps'] = $transaction->reg_steps(); |
957 | - if ( $transaction->ID() ) { |
|
958 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
959 | - EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index ); |
|
957 | + if ($transaction->ID()) { |
|
958 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
959 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
960 | 960 | } |
961 | 961 | } |
962 | 962 | } |