@@ -105,42 +105,42 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return EEM_Message |
107 | 107 | */ |
108 | - protected function __construct( $timezone = null ) { |
|
109 | - $this->singular_item = __('Message','event_espresso'); |
|
110 | - $this->plural_item = __('Messages','event_espresso'); |
|
108 | + protected function __construct($timezone = null) { |
|
109 | + $this->singular_item = __('Message', 'event_espresso'); |
|
110 | + $this->plural_item = __('Messages', 'event_espresso'); |
|
111 | 111 | |
112 | 112 | //used for token generator |
113 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
113 | + EE_Registry::instance()->load_helper('URL'); |
|
114 | 114 | |
115 | 115 | $this->_tables = array( |
116 | - 'Message'=>new EE_Primary_Table('esp_message','MSG_ID') |
|
116 | + 'Message'=>new EE_Primary_Table('esp_message', 'MSG_ID') |
|
117 | 117 | ); |
118 | 118 | |
119 | 119 | $allowed_priority = array( |
120 | - self::priority_high => __( 'high', 'event_espresso' ), |
|
121 | - self::priority_medium => __( 'medium', 'event_espresso' ), |
|
122 | - self::priority_low => __( 'low', 'event_espresso' ) |
|
120 | + self::priority_high => __('high', 'event_espresso'), |
|
121 | + self::priority_medium => __('medium', 'event_espresso'), |
|
122 | + self::priority_low => __('low', 'event_espresso') |
|
123 | 123 | ); |
124 | 124 | |
125 | 125 | $this->_fields = array( |
126 | 126 | 'Message'=>array( |
127 | - 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID','event_espresso')), |
|
128 | - 'MSG_token' => new EE_Plain_Text_Field( 'MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso' ), false, EEH_URL::generate_unique_token() ), |
|
129 | - 'GRP_ID'=>new EE_Foreign_Key_Int_Field( 'GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso' ), true, 0, 'Message_Template_Group' ), |
|
130 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( 'Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso' ), true, 0, 'Transaction' ), |
|
131 | - 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __( 'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso' ), false, 'email' ), |
|
132 | - 'MSG_message_type' => new EE_Plain_Text_Field( 'MSG_message_type', __( 'Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso' ), false, 'receipt' ), |
|
133 | - 'MSG_context' => new EE_Plain_Text_Field( 'MSG_context', __( 'Context', 'event_espresso' ), false ), |
|
134 | - 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field( 'MSG_recipient_ID', __( 'Recipient ID', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
135 | - 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field( 'MSG_recipient_type', __( 'Recipient Type', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
136 | - 'MSG_content' => new EE_Maybe_Serialized_Text_Field( 'MSG_content', __( 'Content', 'event_espresso' ), true, '' ), |
|
137 | - 'MSG_to' => new EE_Maybe_Serialized_Text_Field( 'MSG_to', __( 'Address To', 'event_espresso' ), true ), |
|
138 | - 'MSG_from' => new EE_Maybe_Serialized_Text_Field( 'MSG_from', __( 'Address From', 'event_espresso' ), true ), |
|
139 | - 'MSG_subject' => new EE_Maybe_Serialized_Text_Field( 'MSG_subject', __( 'Subject', 'event_espresso' ), true, '' ), |
|
140 | - 'MSG_priority' => new EE_Enum_Integer_Field( 'MSG_priority', __( 'Priority', 'event_espresso' ), false, self::priority_low, $allowed_priority ), |
|
141 | - 'STS_ID' => new EE_Foreign_Key_String_Field( 'STS_ID', __( 'Status', 'event_espresso' ), false, self::status_incomplete, 'Status' ), |
|
142 | - 'MSG_created' => new EE_Datetime_Field( 'MSG_created', __( 'Created', 'event_espresso' ), false, time() ), |
|
143 | - 'MSG_modified' => new EE_Datetime_Field( 'MSG_modified', __( 'Modified', 'event_espresso' ), true, time() ) |
|
127 | + 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')), |
|
128 | + 'MSG_token' => new EE_Plain_Text_Field('MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso'), false, EEH_URL::generate_unique_token()), |
|
129 | + 'GRP_ID'=>new EE_Foreign_Key_Int_Field('GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, 'Message_Template_Group'), |
|
130 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso'), true, 0, 'Transaction'), |
|
131 | + 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso'), false, 'email'), |
|
132 | + 'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), false, 'receipt'), |
|
133 | + 'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false), |
|
134 | + 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
135 | + 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
136 | + 'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', __('Content', 'event_espresso'), true, ''), |
|
137 | + 'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), true), |
|
138 | + 'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', __('Address From', 'event_espresso'), true), |
|
139 | + 'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', __('Subject', 'event_espresso'), true, ''), |
|
140 | + 'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), false, self::priority_low, $allowed_priority), |
|
141 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, self::status_incomplete, 'Status'), |
|
142 | + 'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, time()), |
|
143 | + 'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, time()) |
|
144 | 144 | ) |
145 | 145 | ); |
146 | 146 | $this->_model_relations = array( |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
151 | 151 | 'Transaction' => new EE_Belongs_To_Relation() |
152 | 152 | ); |
153 | - parent::__construct( $timezone ); |
|
153 | + parent::__construct($timezone); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | public function create_default_object() { |
162 | 162 | /** @type EE_Message $message */ |
163 | 163 | $message = parent::create_default_object(); |
164 | - if ( $message instanceof EE_Message ) { |
|
165 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
164 | + if ($message instanceof EE_Message) { |
|
165 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
166 | 166 | } |
167 | 167 | return null; |
168 | 168 | } |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | * @param mixed $cols_n_values |
174 | 174 | * @return \EE_Message |
175 | 175 | */ |
176 | - public function instantiate_class_from_array_or_object( $cols_n_values ) { |
|
176 | + public function instantiate_class_from_array_or_object($cols_n_values) { |
|
177 | 177 | /** @type EE_Message $message */ |
178 | - $message = parent::instantiate_class_from_array_or_object( $cols_n_values ); |
|
179 | - if ( $message instanceof EE_Message ) { |
|
180 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
178 | + $message = parent::instantiate_class_from_array_or_object($cols_n_values); |
|
179 | + if ($message instanceof EE_Message) { |
|
180 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
181 | 181 | } |
182 | 182 | return null; |
183 | 183 | } |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | * @param string $message_type the message type slug |
191 | 191 | * @return boolean |
192 | 192 | */ |
193 | - public function message_sent_for_attendee( $attendee, $message_type ) { |
|
194 | - $attendee_ID = EEM_Attendee::instance()->ensure_is_ID( $attendee ); |
|
195 | - return $this->exists( array( array( |
|
193 | + public function message_sent_for_attendee($attendee, $message_type) { |
|
194 | + $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee); |
|
195 | + return $this->exists(array(array( |
|
196 | 196 | 'Attendee.ATT_ID' => $attendee_ID, |
197 | 197 | 'MSG_message_type' => $message_type, |
198 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
199 | - ) ) ); |
|
198 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
199 | + ))); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | * @param string $message_type the message type slug |
209 | 209 | * @return boolean |
210 | 210 | */ |
211 | - public function message_sent_for_registration( $registration, $message_type ) { |
|
212 | - $registrationID = EEM_Registration::instance()->ensure_is_ID( $registration ); |
|
213 | - return $this->exists( array( array( |
|
211 | + public function message_sent_for_registration($registration, $message_type) { |
|
212 | + $registrationID = EEM_Registration::instance()->ensure_is_ID($registration); |
|
213 | + return $this->exists(array(array( |
|
214 | 214 | 'Registration.REG_ID' => $registrationID, |
215 | 215 | 'MSG_message_type' => $message_type, |
216 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
217 | - ) ) ); |
|
216 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
217 | + ))); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | * @param string $token |
226 | 226 | * @return EE_Message |
227 | 227 | */ |
228 | - public function get_one_by_token( $token ) { |
|
229 | - return $this->get_one( array( array( |
|
228 | + public function get_one_by_token($token) { |
|
229 | + return $this->get_one(array(array( |
|
230 | 230 | 'MSG_token' => $token |
231 | - ) ) ); |
|
231 | + ))); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | * Returns stati that indicate the message HAS been sent |
237 | 237 | * @return array of strings for possible stati |
238 | 238 | */ |
239 | - public function stati_indicating_sent(){ |
|
240 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_sent', array( self::status_sent ) ); |
|
239 | + public function stati_indicating_sent() { |
|
240 | + return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent)); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @return array of strings for possible stati. |
249 | 249 | */ |
250 | 250 | public function stati_indicating_to_send() { |
251 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_to_send', array( self::status_idle, self::status_resend ) ); |
|
251 | + return apply_filters('FHEE__EEM_Message__stati_indicating_to_send', array(self::status_idle, self::status_resend)); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | self::status_retry, |
263 | 263 | ); |
264 | 264 | //if WP_DEBUG is set, then let's include debug_only fails |
265 | - if ( WP_DEBUG ) { |
|
265 | + if (WP_DEBUG) { |
|
266 | 266 | $failed_stati[] = self::status_debug_only; |
267 | 267 | } |
268 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati ); |
|
268 | + return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | // the value, matches the corresponding EEM_Base child reference. |
301 | 301 | $expected_vars = $this->_expected_vars_for_query_inject(); |
302 | 302 | $query_params[0] = array(); |
303 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
304 | - $request_value = EE_Registry::instance()->REQ->get( $request_key ); |
|
305 | - if ( $request_value ) { |
|
303 | + foreach ($expected_vars as $request_key => $model_name) { |
|
304 | + $request_value = EE_Registry::instance()->REQ->get($request_key); |
|
305 | + if ($request_value) { |
|
306 | 306 | //special case |
307 | - switch ( $request_key ) { |
|
307 | + switch ($request_key) { |
|
308 | 308 | case '_REG_ID' : |
309 | 309 | $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array( |
310 | 310 | 'Transaction.Registration.REG_ID' => $request_value, |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | ); |
317 | 317 | break; |
318 | 318 | default : |
319 | - $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value; |
|
319 | + $query_params[0]['AND**filter_by']['OR**filter_by_'.$request_key][$model_name.'.'.$request_key] = $request_value; |
|
320 | 320 | break; |
321 | 321 | } |
322 | 322 | } |
@@ -333,53 +333,53 @@ discard block |
||
333 | 333 | $expected_vars = $this->_expected_vars_for_query_inject(); |
334 | 334 | $pretty_label = ''; |
335 | 335 | $label_parts = array(); |
336 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
337 | - $model = EE_Registry::instance()->load_model( $model_name ); |
|
338 | - if ( $model_field_value = EE_Registry::instance()->REQ->get( $request_key ) ) { |
|
339 | - switch ( $request_key ) { |
|
336 | + foreach ($expected_vars as $request_key => $model_name) { |
|
337 | + $model = EE_Registry::instance()->load_model($model_name); |
|
338 | + if ($model_field_value = EE_Registry::instance()->REQ->get($request_key)) { |
|
339 | + switch ($request_key) { |
|
340 | 340 | case '_REG_ID' : |
341 | 341 | $label_parts[] = sprintf( |
342 | - esc_html__( 'Registration with the ID: %s', 'event_espresso' ), |
|
342 | + esc_html__('Registration with the ID: %s', 'event_espresso'), |
|
343 | 343 | $model_field_value |
344 | 344 | ); |
345 | 345 | break; |
346 | 346 | case 'ATT_ID' : |
347 | 347 | /** @var EE_Attendee $attendee */ |
348 | - $attendee = $model->get_one_by_ID( $model_field_value ); |
|
348 | + $attendee = $model->get_one_by_ID($model_field_value); |
|
349 | 349 | $label_parts[] = $attendee instanceof EE_Attendee |
350 | - ? sprintf( esc_html__( 'Attendee %s', 'event_espresso' ), $attendee->full_name() ) |
|
351 | - : sprintf( esc_html__( 'Attendee ID: %s', 'event_espresso' ), $model_field_value ); |
|
350 | + ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name()) |
|
351 | + : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value); |
|
352 | 352 | break; |
353 | 353 | case 'ID' : |
354 | 354 | /** @var EE_WP_User $wpUser */ |
355 | - $wpUser = $model->get_one_by_ID( $model_field_value ); |
|
355 | + $wpUser = $model->get_one_by_ID($model_field_value); |
|
356 | 356 | $label_parts[] = $wpUser instanceof EE_WP_User |
357 | - ? sprintf( esc_html__( 'WP User: %s', 'event_espresso' ), $wpUser->name() ) |
|
358 | - : sprintf( esc_html__( 'WP User ID: %s', 'event_espresso' ), $model_field_value ); |
|
357 | + ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name()) |
|
358 | + : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value); |
|
359 | 359 | break; |
360 | 360 | case 'TXN_ID' : |
361 | 361 | $label_parts[] = sprintf( |
362 | - esc_html__( 'Transaction with the ID: %s', 'event_espresso' ), |
|
362 | + esc_html__('Transaction with the ID: %s', 'event_espresso'), |
|
363 | 363 | $model_field_value |
364 | 364 | ); |
365 | 365 | break; |
366 | 366 | case 'EVT_ID' : |
367 | 367 | /** @var EE_Event $Event */ |
368 | - $Event = $model->get_one_by_ID( $model_field_value ); |
|
368 | + $Event = $model->get_one_by_ID($model_field_value); |
|
369 | 369 | $label_parts[] = $Event instanceof EE_Event |
370 | - ? sprintf( esc_html__( 'for the Event: %s', 'event_espresso' ), $Event->name() ) |
|
371 | - : sprintf( esc_html__( 'for the Event with ID: %s', 'event_espresso' ), $model_field_value ); |
|
370 | + ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name()) |
|
371 | + : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value); |
|
372 | 372 | break; |
373 | 373 | } |
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | - if ( $label_parts ) { |
|
377 | + if ($label_parts) { |
|
378 | 378 | |
379 | 379 | //prepend to the last element of $label_parts an "and". |
380 | - if ( count( $label_parts ) > 1 ) { |
|
381 | - $label_parts_index_to_prepend = count( $label_parts ) - 1; |
|
382 | - $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ]; |
|
380 | + if (count($label_parts) > 1) { |
|
381 | + $label_parts_index_to_prepend = count($label_parts) - 1; |
|
382 | + $label_parts[$label_parts_index_to_prepend] = 'and'.$label_parts[$label_parts_index_to_prepend]; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | $pretty_label .= sprintf( |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | 'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.', |
389 | 389 | 'event_espresso' |
390 | 390 | ), |
391 | - implode( ', ', $label_parts ) |
|
391 | + implode(', ', $label_parts) |
|
392 | 392 | ); |
393 | 393 | } |
394 | 394 | return $pretty_label; |
@@ -438,20 +438,20 @@ discard block |
||
438 | 438 | * |
439 | 439 | * @return bool true means Messages is in debug mode. false means messages system is not in debug mode. |
440 | 440 | */ |
441 | - public static function debug( $set_debug = null ) { |
|
441 | + public static function debug($set_debug = null) { |
|
442 | 442 | static $is_debugging = null; |
443 | 443 | |
444 | 444 | //initialize (use constant if set). |
445 | - if ( is_null( $set_debug ) && is_null( $is_debugging ) ) { |
|
446 | - $is_debugging = defined( 'EE_DEBUG_MESSAGES' ) && EE_DEBUG_MESSAGES; |
|
445 | + if (is_null($set_debug) && is_null($is_debugging)) { |
|
446 | + $is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES; |
|
447 | 447 | } |
448 | 448 | |
449 | - if ( ! is_null( $set_debug ) ) { |
|
450 | - $is_debugging = filter_var( $set_debug, FILTER_VALIDATE_BOOLEAN ); |
|
449 | + if ( ! is_null($set_debug)) { |
|
450 | + $is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | //return filtered value |
454 | - return apply_filters( 'FHEE__EEM_Message__debug', $is_debugging ); |
|
454 | + return apply_filters('FHEE__EEM_Message__debug', $is_debugging); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Message Model |
4 | 6 | * |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return EED_Messages |
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,24 +868,24 @@ 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 | $generated_queue = false; |
882 | - if ( $messages ) { |
|
883 | - $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue( $messages ); |
|
882 | + if ($messages) { |
|
883 | + $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
884 | 884 | } |
885 | 885 | |
886 | - if ( ! $generated_queue instanceof EE_Messages_Queue ) { |
|
886 | + if ( ! $generated_queue instanceof EE_Messages_Queue) { |
|
887 | 887 | EE_Error::add_error( |
888 | - __( 'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.', 'event_espresso' ), |
|
888 | + __('The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.', 'event_espresso'), |
|
889 | 889 | __FILE__, __FUNCTION__, __LINE__ |
890 | 890 | ); |
891 | 891 | } |
@@ -904,30 +904,30 @@ discard block |
||
904 | 904 | * |
905 | 905 | * @return bool | EE_Messages_Queue false if no messages sent. |
906 | 906 | */ |
907 | - public static function send_now( $message_ids ) { |
|
907 | + public static function send_now($message_ids) { |
|
908 | 908 | self::_load_controller(); |
909 | 909 | $messages = EEM_Message::instance()->get_all( |
910 | 910 | array( |
911 | 911 | 0 => array( |
912 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
913 | - 'STS_ID' => array( 'IN', array( EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry ) ) |
|
912 | + 'MSG_ID' => array('IN', $message_ids), |
|
913 | + 'STS_ID' => array('IN', array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry)) |
|
914 | 914 | ) |
915 | 915 | ) |
916 | 916 | ); |
917 | 917 | $sent_queue = false; |
918 | - if ( $messages ) { |
|
919 | - $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue( $messages ); |
|
918 | + if ($messages) { |
|
919 | + $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
920 | 920 | } |
921 | 921 | |
922 | - if ( ! $sent_queue instanceof EE_Messages_Queue ) { |
|
922 | + if ( ! $sent_queue instanceof EE_Messages_Queue) { |
|
923 | 923 | EE_Error::add_error( |
924 | - __( 'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.', 'event_espresso' ), |
|
924 | + __('The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.', 'event_espresso'), |
|
925 | 925 | __FILE__, __FUNCTION__, __LINE__ |
926 | 926 | ); |
927 | 927 | } else { |
928 | 928 | //can count how many sent by using the messages in the queue |
929 | - $sent_count = $sent_queue->count_STS_in_queue( EEM_Message::instance()->stati_indicating_sent() ); |
|
930 | - if ( $sent_count > 0 ) { |
|
929 | + $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
930 | + if ($sent_count > 0) { |
|
931 | 931 | EE_Error::add_success( |
932 | 932 | sprintf( |
933 | 933 | _n( |
@@ -942,8 +942,8 @@ discard block |
||
942 | 942 | } else { |
943 | 943 | EE_Error::overwrite_errors(); |
944 | 944 | EE_Error::add_error( |
945 | - __( '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. |
|
946 | - If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso' ), |
|
945 | + __('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. |
|
946 | + If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso'), |
|
947 | 947 | __FILE__, __FUNCTION__, __LINE__ |
948 | 948 | ); |
949 | 949 | } |
@@ -964,12 +964,12 @@ discard block |
||
964 | 964 | * |
965 | 965 | * @return bool true means messages were successfully queued for resending, false means none were queued for resending. |
966 | 966 | */ |
967 | - public static function queue_for_resending( $message_ids ) { |
|
967 | + public static function queue_for_resending($message_ids) { |
|
968 | 968 | self::_load_controller(); |
969 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( $message_ids ); |
|
969 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
970 | 970 | |
971 | 971 | //get queue and count |
972 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
972 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
973 | 973 | |
974 | 974 | if ( |
975 | 975 | $queue_count > 0 |
@@ -989,11 +989,11 @@ discard block |
||
989 | 989 | * @see filter usage in EE_Messages_Queue::initiate_request_by_priority |
990 | 990 | */ |
991 | 991 | } elseif ( |
992 | - apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true ) |
|
992 | + apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true) |
|
993 | 993 | || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
994 | 994 | ) { |
995 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_sent ); |
|
996 | - if ( $queue_count > 0 ) { |
|
995 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent); |
|
996 | + if ($queue_count > 0) { |
|
997 | 997 | EE_Error::add_success( |
998 | 998 | sprintf( |
999 | 999 | _n( |
@@ -1007,13 +1007,13 @@ discard block |
||
1007 | 1007 | ); |
1008 | 1008 | } else { |
1009 | 1009 | EE_Error::add_error( |
1010 | - __( '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' ), |
|
1010 | + __('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'), |
|
1011 | 1011 | __FILE__, __FUNCTION__, __LINE__ |
1012 | 1012 | ); |
1013 | 1013 | } |
1014 | 1014 | } else { |
1015 | 1015 | EE_Error::add_error( |
1016 | - __( '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' ), |
|
1016 | + __('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'), |
|
1017 | 1017 | __FILE__, __FUNCTION__, __LINE__ |
1018 | 1018 | ); |
1019 | 1019 | } |
@@ -1035,16 +1035,16 @@ discard block |
||
1035 | 1035 | * @param array $info |
1036 | 1036 | * @param bool $display_request |
1037 | 1037 | */ |
1038 | - protected static function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) { |
|
1039 | - if ( WP_DEBUG && false ) { |
|
1040 | - if ( $transaction instanceof EE_Transaction ) { |
|
1038 | + protected static function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) { |
|
1039 | + if (WP_DEBUG && false) { |
|
1040 | + if ($transaction instanceof EE_Transaction) { |
|
1041 | 1041 | // don't serialize objects |
1042 | - $info = EEH_Debug_Tools::strip_objects( $info ); |
|
1042 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
1043 | 1043 | $info['TXN_status'] = $transaction->status_ID(); |
1044 | 1044 | $info['TXN_reg_steps'] = $transaction->reg_steps(); |
1045 | - if ( $transaction->ID() ) { |
|
1046 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1047 | - EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index ); |
|
1045 | + if ($transaction->ID()) { |
|
1046 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
1047 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | } |
@@ -560,7 +560,7 @@ |
||
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' ); |
@@ -6,7 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage modules, messages |
8 | 8 | */ |
9 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | +} |
|
10 | 12 | /** |
11 | 13 | * |
12 | 14 | * Messages module. Takes care of registering all the triggers for messages. |
@@ -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 | /** |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | class Support_Admin_Page extends EE_Admin_Page { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $routing = TRUE ) { |
|
34 | - parent::__construct( $routing ); |
|
33 | + public function __construct($routing = TRUE) { |
|
34 | + parent::__construct($routing); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | 'nav' => array( |
85 | 85 | 'label' => __('Shortcodes', 'event_espresso'), |
86 | 86 | 'order' => 30), |
87 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_shortcodes_boxes' ) ), |
|
87 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')), |
|
88 | 88 | 'require_nonce' => FALSE |
89 | 89 | ), |
90 | 90 | 'contact_support' => array( |
91 | 91 | 'nav' => array( |
92 | 92 | 'label' => __('Support', 'event_espresso'), |
93 | 93 | 'order' => 40), |
94 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_support_boxes' ) ), |
|
94 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')), |
|
95 | 95 | 'require_nonce' => FALSE |
96 | 96 | ), |
97 | 97 | 'developers' => array( |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | |
120 | 120 | |
121 | 121 | protected function _installation() { |
122 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php'; |
|
123 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, '', TRUE); |
|
122 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_installation.template.php'; |
|
123 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', TRUE); |
|
124 | 124 | $this->display_admin_page_with_sidebar(); |
125 | 125 | } |
126 | 126 | |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | 'other_resources' => __('Other Resources', 'event_espresso') |
146 | 146 | ); |
147 | 147 | |
148 | - foreach ( $boxes as $box => $label ) { |
|
149 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php'; |
|
148 | + foreach ($boxes as $box => $label) { |
|
149 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php'; |
|
150 | 150 | $callback_args = array('template_path' => $template_path); |
151 | - add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
151 | + add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | 'shortcodes_event_listings' => __('Event Listings', 'event_espresso'), |
170 | 170 | 'shortcodes_ticket_selector' => __('Event Ticket Selector', 'event_espresso'), |
171 | 171 | 'shortcodes_category' => __('Event Categories', 'event_espresso'), |
172 | - 'shortcodes_attendee' => __( 'Event Attendees', 'event_espresso' ) |
|
172 | + 'shortcodes_attendee' => __('Event Attendees', 'event_espresso') |
|
173 | 173 | /*'shortcodes_single_events' => __('Single Events', 'event_espresso'),*/ |
174 | 174 | /*'shortcodes_attendee_listings' => __('Attendee Listings', 'event_espresso'),*/ |
175 | 175 | ); |
176 | 176 | |
177 | - foreach ( $boxes as $box => $label ) { |
|
178 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php'; |
|
177 | + foreach ($boxes as $box => $label) { |
|
178 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php'; |
|
179 | 179 | $callback_args = array('template_path' => $template_path); |
180 | - add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
180 | + add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -196,17 +196,17 @@ discard block |
||
196 | 196 | 'important_information' => __('Important Information', 'event_espresso') |
197 | 197 | ); |
198 | 198 | |
199 | - foreach ( $boxes as $box => $label ) { |
|
200 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php'; |
|
199 | + foreach ($boxes as $box => $label) { |
|
200 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php'; |
|
201 | 201 | $callback_args = array('template_path' => $template_path, 'template_args' => $this->_template_args); |
202 | - add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
202 | + add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | 206 | |
207 | 207 | protected function _developers() { |
208 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php'; |
|
209 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true ); |
|
208 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'developers_admin_details.template.php'; |
|
209 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true); |
|
210 | 210 | $this->display_admin_page_with_sidebar(); |
211 | 211 | } |
212 | 212 | } //end Support_Admin_Page class |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -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 | /** |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class Extend_Support_Admin_Page extends Support_Admin_Page { |
31 | 31 | |
32 | - public function __construct( $routing = TRUE ) { |
|
33 | - parent::__construct( $routing ); |
|
34 | - define( 'EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'support/templates/' ); |
|
32 | + public function __construct($routing = TRUE) { |
|
33 | + parent::__construct($routing); |
|
34 | + define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'support/templates/'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | 39 | |
40 | 40 | protected function _extend_page_config() { |
41 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'support'; |
|
41 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'support'; |
|
42 | 42 | //new routes and new configs (or overrides ) |
43 | 43 | $new_page_routes = array( |
44 | 44 | 'faq' => array( |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | 'capability' => 'ee_read_ee' |
47 | 47 | ) |
48 | 48 | ); |
49 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
49 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
50 | 50 | |
51 | 51 | $new_page_config = array( |
52 | 52 | 'faq' => array( |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'require_nonce' => FALSE |
58 | 58 | ) |
59 | 59 | ); |
60 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
60 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
61 | 61 | |
62 | 62 | $this->_page_config['default']['metaboxes'][] = '_installation_boxes'; |
63 | 63 | } |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | |
67 | 67 | |
68 | 68 | protected function _faq() { |
69 | - $template_path = EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH . 'support_admin_details_faq.template.php'; |
|
70 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, '', TRUE); |
|
69 | + $template_path = EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH.'support_admin_details_faq.template.php'; |
|
70 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', TRUE); |
|
71 | 71 | $this->display_admin_page_with_sidebar(); |
72 | 72 | |
73 | 73 | } |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | |
76 | 76 | |
77 | 77 | protected function _installation_boxes() { |
78 | - $callback_args = array('template_path' => EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH . 'support_admin_details_additional_information.template.php'); |
|
79 | - add_meta_box( 'espresso_additional_information_support', __('Additional Information', 'event_espresso'), create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE);' ), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
78 | + $callback_args = array('template_path' => EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH.'support_admin_details_additional_information.template.php'); |
|
79 | + add_meta_box('espresso_additional_information_support', __('Additional Information', 'event_espresso'), create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE);'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -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,31 +75,31 @@ discard block |
||
75 | 75 | * @param EE_Messages_Queue $queue_to_process |
76 | 76 | * @return bool true for success false for error. |
77 | 77 | */ |
78 | - public function process_immediately_from_queue( EE_Messages_Queue $queue_to_process ) { |
|
78 | + public function process_immediately_from_queue(EE_Messages_Queue $queue_to_process) { |
|
79 | 79 | $success = false; |
80 | 80 | $messages_to_send = array(); |
81 | 81 | $messages_to_generate = array(); |
82 | 82 | //loop through and setup the various messages from the queue so we know what is being processed |
83 | 83 | $queue_to_process->get_message_repository()->rewind(); |
84 | - foreach ( $queue_to_process->get_message_repository() as $message ) { |
|
85 | - if ( $message->STS_ID() === EEM_Message::status_incomplete ) { |
|
84 | + foreach ($queue_to_process->get_message_repository() as $message) { |
|
85 | + if ($message->STS_ID() === EEM_Message::status_incomplete) { |
|
86 | 86 | $messages_to_generate[] = $message; |
87 | 87 | continue; |
88 | 88 | } |
89 | 89 | |
90 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send() ) ) { |
|
90 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send())) { |
|
91 | 91 | $messages_to_send[] = $message; |
92 | 92 | continue; |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | 96 | //do generation/sends |
97 | - if ( $messages_to_generate ) { |
|
98 | - $success = $this->batch_generate_from_queue( $messages_to_generate, true ); |
|
97 | + if ($messages_to_generate) { |
|
98 | + $success = $this->batch_generate_from_queue($messages_to_generate, true); |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( $messages_to_send ) { |
|
102 | - $sent = $this->batch_send_from_queue( $messages_to_send, true ); |
|
101 | + if ($messages_to_send) { |
|
102 | + $sent = $this->batch_send_from_queue($messages_to_send, true); |
|
103 | 103 | //if there was messages to generate and it failed, then we override any success value for the sending process |
104 | 104 | //otherwise we just use the return from batch send. The intent is that there is a simple response for success/fail. |
105 | 105 | //Either everything was successful or we consider it a fail. To be clear, this is a limitation of doing |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | * @return bool|EE_Messages_Queue return false if nothing generated. This returns a new EE_Message_Queue with |
120 | 120 | * generated messages. |
121 | 121 | */ |
122 | - public function batch_generate_from_queue( $messages = array(), $clear_queue = false ) { |
|
123 | - if ( $this->_build_queue_for_generation( $messages, $clear_queue ) ) { |
|
122 | + public function batch_generate_from_queue($messages = array(), $clear_queue = false) { |
|
123 | + if ($this->_build_queue_for_generation($messages, $clear_queue)) { |
|
124 | 124 | $new_queue = $this->_generator->generate(); |
125 | - if ( $new_queue instanceof EE_Messages_Queue ) { |
|
125 | + if ($new_queue instanceof EE_Messages_Queue) { |
|
126 | 126 | //unlock queue |
127 | 127 | $this->_queue->unlock_queue(); |
128 | - $new_queue->initiate_request_by_priority( 'send' ); |
|
128 | + $new_queue->initiate_request_by_priority('send'); |
|
129 | 129 | return $new_queue; |
130 | 130 | } |
131 | 131 | } |
@@ -146,24 +146,24 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool true means queue prepped, false means there was a lock so no generation please. |
148 | 148 | */ |
149 | - protected function _build_queue_for_generation( $messages = array(), $clear_queue = false ) { |
|
149 | + protected function _build_queue_for_generation($messages = array(), $clear_queue = false) { |
|
150 | 150 | |
151 | - if ( $clear_queue ) { |
|
151 | + if ($clear_queue) { |
|
152 | 152 | $this->_init_queue_and_generator(); |
153 | 153 | } |
154 | 154 | |
155 | - if ( $messages ) { |
|
155 | + if ($messages) { |
|
156 | 156 | //if generation is locked then get out now because that means processing is already happening. |
157 | - if ( $this->_queue->is_locked() ) { |
|
157 | + if ($this->_queue->is_locked()) { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | |
161 | 161 | $this->_queue->lock_queue(); |
162 | - $messages = is_array( $messages ) ? $messages : array( $messages ); |
|
163 | - foreach ( $messages as $message ) { |
|
164 | - if ( $message instanceof EE_Message ) { |
|
162 | + $messages = is_array($messages) ? $messages : array($messages); |
|
163 | + foreach ($messages as $message) { |
|
164 | + if ($message instanceof EE_Message) { |
|
165 | 165 | $data = $message->all_extra_meta_array(); |
166 | - $this->_queue->add( $message, $data ); |
|
166 | + $this->_queue->add($message, $data); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | return true; |
@@ -181,22 +181,22 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return bool true means queue prepped, false means there was a lock so no queue prepped. |
183 | 183 | */ |
184 | - protected function _build_queue_for_sending( $messages, $clear_queue = false ) { |
|
184 | + protected function _build_queue_for_sending($messages, $clear_queue = false) { |
|
185 | 185 | //if sending is locked then get out now because that means processing is already happening. |
186 | - if ( $this->_queue->is_locked( EE_Messages_Queue::action_sending ) ) { |
|
186 | + if ($this->_queue->is_locked(EE_Messages_Queue::action_sending)) { |
|
187 | 187 | return false; |
188 | 188 | } |
189 | 189 | |
190 | - $this->_queue->lock_queue( EE_Messages_Queue::action_sending ); |
|
190 | + $this->_queue->lock_queue(EE_Messages_Queue::action_sending); |
|
191 | 191 | |
192 | - if ( $clear_queue ) { |
|
192 | + if ($clear_queue) { |
|
193 | 193 | $this->_init_queue_and_generator(); |
194 | 194 | } |
195 | 195 | |
196 | - $messages = is_array( $messages ) ? $messages : array( $messages ); |
|
196 | + $messages = is_array($messages) ? $messages : array($messages); |
|
197 | 197 | |
198 | - foreach ( $messages as $message ) { |
|
199 | - $this->_queue->add( $message ); |
|
198 | + foreach ($messages as $message) { |
|
199 | + $this->_queue->add($message); |
|
200 | 200 | } |
201 | 201 | return true; |
202 | 202 | } |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return EE_Messages_Queue |
214 | 214 | */ |
215 | - public function batch_send_from_queue( $messages = array(), $clear_queue = false ) { |
|
215 | + public function batch_send_from_queue($messages = array(), $clear_queue = false) { |
|
216 | 216 | |
217 | - if ( $messages && $this->_build_queue_for_sending( $messages, $clear_queue ) ) { |
|
217 | + if ($messages && $this->_build_queue_for_sending($messages, $clear_queue)) { |
|
218 | 218 | $this->_queue->execute(); |
219 | - $this->_queue->unlock_queue( EE_Messages_Queue::action_sending ); |
|
219 | + $this->_queue->unlock_queue(EE_Messages_Queue::action_sending); |
|
220 | 220 | } else { |
221 | 221 | //get messages to send and execute. |
222 | 222 | $this->_queue->get_to_send_batch_and_send(); |
@@ -239,10 +239,10 @@ discard block |
||
239 | 239 | * @param EE_Message_To_Generate[] $messages_to_generate |
240 | 240 | * @return EE_Messages_Queue |
241 | 241 | */ |
242 | - public function generate_and_return( $messages_to_generate ) { |
|
242 | + public function generate_and_return($messages_to_generate) { |
|
243 | 243 | $this->_init_queue_and_generator(); |
244 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
245 | - return $this->_generator->generate( false ); |
|
244 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
245 | + return $this->_generator->generate(false); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * @param bool $persist Indicate whether to instruct the generator to persist the generated queue (true) or not (false). |
254 | 254 | * @return EE_Messages_Queue |
255 | 255 | */ |
256 | - public function generate_queue( $persist = true ) { |
|
257 | - return $this->_generator->generate( $persist ); |
|
256 | + public function generate_queue($persist = true) { |
|
257 | + return $this->_generator->generate($persist); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | * @param bool $test_send Whether this item is for a test send or not. |
268 | 268 | * @return EE_Messages_Queue |
269 | 269 | */ |
270 | - public function queue_for_generation( EE_Message_To_Generate $message_to_generate, $test_send = false ) { |
|
271 | - if ( $message_to_generate->valid() ) { |
|
272 | - $this->_generator->create_and_add_message_to_queue( $message_to_generate, $test_send ); |
|
270 | + public function queue_for_generation(EE_Message_To_Generate $message_to_generate, $test_send = false) { |
|
271 | + if ($message_to_generate->valid()) { |
|
272 | + $this->_generator->create_and_add_message_to_queue($message_to_generate, $test_send); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @param EE_Message_To_Generate[] $messages_to_generate |
287 | 287 | */ |
288 | - public function batch_queue_for_generation_and_persist( $messages_to_generate ) { |
|
288 | + public function batch_queue_for_generation_and_persist($messages_to_generate) { |
|
289 | 289 | $this->_init_queue_and_generator(); |
290 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
290 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
291 | 291 | $this->_queue->save(); |
292 | 292 | } |
293 | 293 | |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @param EE_Message_To_Generate[] $messages_to_generate |
305 | 305 | */ |
306 | - public function batch_queue_for_generation_no_persist( $messages_to_generate ) { |
|
306 | + public function batch_queue_for_generation_no_persist($messages_to_generate) { |
|
307 | 307 | $this->_init_queue_and_generator(); |
308 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
308 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -317,15 +317,15 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @param EE_Message_To_Generate[] $messages_to_generate |
319 | 319 | */ |
320 | - protected function _queue_for_generation_loop( $messages_to_generate ) { |
|
320 | + protected function _queue_for_generation_loop($messages_to_generate) { |
|
321 | 321 | //make sure is in an array. |
322 | - if ( ! is_array( $messages_to_generate ) ) { |
|
323 | - $messages_to_generate = array( $messages_to_generate ); |
|
322 | + if ( ! is_array($messages_to_generate)) { |
|
323 | + $messages_to_generate = array($messages_to_generate); |
|
324 | 324 | } |
325 | 325 | |
326 | - foreach ( $messages_to_generate as $message_to_generate ) { |
|
327 | - if ( $message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid() ) { |
|
328 | - $this->queue_for_generation( $message_to_generate ); |
|
326 | + foreach ($messages_to_generate as $message_to_generate) { |
|
327 | + if ($message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid()) { |
|
328 | + $this->queue_for_generation($message_to_generate); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | } |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | * @param EE_Message_To_Generate[] |
341 | 341 | * @return EE_Messages_Queue |
342 | 342 | */ |
343 | - public function generate_and_queue_for_sending( $messages_to_generate ) { |
|
343 | + public function generate_and_queue_for_sending($messages_to_generate) { |
|
344 | 344 | $this->_init_queue_and_generator(); |
345 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
346 | - return $this->_generator->generate( true ); |
|
345 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
346 | + return $this->_generator->generate(true); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * @param bool $test_send Whether this is a test send or not. |
358 | 358 | * @return EE_Messages_Queue | bool false if unable to generate otherwise the generated queue. |
359 | 359 | */ |
360 | - public function generate_for_preview( EE_Message_To_Generate $message_to_generate, $test_send = false ) { |
|
361 | - if ( ! $message_to_generate->valid() ) { |
|
360 | + public function generate_for_preview(EE_Message_To_Generate $message_to_generate, $test_send = false) { |
|
361 | + if ( ! $message_to_generate->valid()) { |
|
362 | 362 | EE_Error::add_error( |
363 | - __( 'Unable to generate preview because of invalid data', 'event_espresso' ), |
|
363 | + __('Unable to generate preview because of invalid data', 'event_espresso'), |
|
364 | 364 | __FILE__, |
365 | 365 | __FUNCTION__, |
366 | 366 | __LINE__ |
@@ -368,14 +368,14 @@ discard block |
||
368 | 368 | return false; |
369 | 369 | } |
370 | 370 | //just make sure preview is set on the $message_to_generate (in case client forgot) |
371 | - $message_to_generate->set_preview( true ); |
|
371 | + $message_to_generate->set_preview(true); |
|
372 | 372 | $this->_init_queue_and_generator(); |
373 | - $this->queue_for_generation( $message_to_generate, $test_send ); |
|
374 | - $generated_queue = $this->_generator->generate( false ); |
|
375 | - if ( $generated_queue->execute( false ) ) { |
|
373 | + $this->queue_for_generation($message_to_generate, $test_send); |
|
374 | + $generated_queue = $this->_generator->generate(false); |
|
375 | + if ($generated_queue->execute(false)) { |
|
376 | 376 | //the first queue item should be the preview |
377 | 377 | $generated_queue->get_message_repository()->rewind(); |
378 | - if ( ! $generated_queue->get_message_repository()->valid() ) { |
|
378 | + if ( ! $generated_queue->get_message_repository()->valid()) { |
|
379 | 379 | return $generated_queue; |
380 | 380 | } |
381 | 381 | return $generated_queue->get_message_repository()->is_test_send() ? true : $generated_queue; |
@@ -392,15 +392,15 @@ discard block |
||
392 | 392 | * @param EE_Message_To_Generate $message_to_generate |
393 | 393 | * @return bool true or false for success. |
394 | 394 | */ |
395 | - public function queue_for_sending( EE_Message_To_Generate $message_to_generate ) { |
|
396 | - if ( ! $message_to_generate->valid() ) { |
|
395 | + public function queue_for_sending(EE_Message_To_Generate $message_to_generate) { |
|
396 | + if ( ! $message_to_generate->valid()) { |
|
397 | 397 | return false; |
398 | 398 | } |
399 | 399 | $this->_init_queue_and_generator(); |
400 | 400 | $message = $message_to_generate->get_EE_Message(); |
401 | - $this->_queue->add( $message ); |
|
402 | - if ( $message->send_now() ) { |
|
403 | - $this->_queue->execute( false ); |
|
401 | + $this->_queue->add($message); |
|
402 | + if ($message->send_now()) { |
|
403 | + $this->_queue->execute(false); |
|
404 | 404 | } else { |
405 | 405 | $this->_queue->save(); |
406 | 406 | } |
@@ -413,12 +413,12 @@ discard block |
||
413 | 413 | * @param EE_Message_To_Generate $message_to_generate |
414 | 414 | * @return EE_Messages_Queue | null |
415 | 415 | */ |
416 | - public function generate_and_send_now( EE_Message_To_Generate $message_to_generate ) { |
|
417 | - if ( ! $message_to_generate->valid() ) { |
|
416 | + public function generate_and_send_now(EE_Message_To_Generate $message_to_generate) { |
|
417 | + if ( ! $message_to_generate->valid()) { |
|
418 | 418 | return null; |
419 | 419 | } |
420 | 420 | // is there supposed to be a sending messenger for this message? |
421 | - if ( $message_to_generate instanceof EEI_Has_Sending_Messenger ) { |
|
421 | + if ($message_to_generate instanceof EEI_Has_Sending_Messenger) { |
|
422 | 422 | // make sure it's valid, but if it's not, |
423 | 423 | // then set the value of $sending_messenger to an EE_Error object |
424 | 424 | // so that downstream code can easily see that things went wrong. |
@@ -434,14 +434,14 @@ discard block |
||
434 | 434 | $sending_messenger = null; |
435 | 435 | } |
436 | 436 | |
437 | - if ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle ) { |
|
437 | + if ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle) { |
|
438 | 438 | $this->_init_queue_and_generator(); |
439 | - $this->_queue->add( $message_to_generate->get_EE_Message() ); |
|
440 | - $this->_queue->execute( false, $sending_messenger ); |
|
439 | + $this->_queue->add($message_to_generate->get_EE_Message()); |
|
440 | + $this->_queue->execute(false, $sending_messenger); |
|
441 | 441 | return $this->_queue; |
442 | - } elseif ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete ) { |
|
443 | - $generated_queue = $this->generate_and_return( array( $message_to_generate ) ); |
|
444 | - $generated_queue->execute( false, $sending_messenger ); |
|
442 | + } elseif ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete) { |
|
443 | + $generated_queue = $this->generate_and_return(array($message_to_generate)); |
|
444 | + $generated_queue->execute(false, $sending_messenger); |
|
445 | 445 | return $generated_queue; |
446 | 446 | } |
447 | 447 | return null; |
@@ -458,13 +458,13 @@ discard block |
||
458 | 458 | * @param mixed $data The data being used for generation. |
459 | 459 | * @param bool $persist Whether to persist the queued messages to the db or not. |
460 | 460 | */ |
461 | - public function generate_for_all_active_messengers( $message_type, $data, $persist = true ) { |
|
462 | - $messages_to_generate = $this->setup_mtgs_for_all_active_messengers( $message_type, $data ); |
|
463 | - if ( $persist ) { |
|
464 | - $this->batch_queue_for_generation_and_persist( $messages_to_generate ); |
|
461 | + public function generate_for_all_active_messengers($message_type, $data, $persist = true) { |
|
462 | + $messages_to_generate = $this->setup_mtgs_for_all_active_messengers($message_type, $data); |
|
463 | + if ($persist) { |
|
464 | + $this->batch_queue_for_generation_and_persist($messages_to_generate); |
|
465 | 465 | $this->_queue->initiate_request_by_priority(); |
466 | 466 | } else { |
467 | - $this->batch_queue_for_generation_no_persist( $messages_to_generate ); |
|
467 | + $this->batch_queue_for_generation_no_persist($messages_to_generate); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
@@ -479,11 +479,11 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return EE_Message_To_Generate[] |
481 | 481 | */ |
482 | - public function setup_mtgs_for_all_active_messengers( $message_type, $data ) { |
|
482 | + public function setup_mtgs_for_all_active_messengers($message_type, $data) { |
|
483 | 483 | $messages_to_generate = array(); |
484 | - foreach ( $this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object ) { |
|
485 | - $message_to_generate = new EE_Message_To_Generate( $messenger_slug, $message_type, $data ); |
|
486 | - if ( $message_to_generate->valid() ) { |
|
484 | + foreach ($this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object) { |
|
485 | + $message_to_generate = new EE_Message_To_Generate($messenger_slug, $message_type, $data); |
|
486 | + if ($message_to_generate->valid()) { |
|
487 | 487 | $messages_to_generate[] = $message_to_generate; |
488 | 488 | } |
489 | 489 | } |
@@ -498,29 +498,29 @@ discard block |
||
498 | 498 | * and send. |
499 | 499 | * @param array $message_ids |
500 | 500 | */ |
501 | - public function setup_messages_from_ids_and_send( $message_ids ) { |
|
501 | + public function setup_messages_from_ids_and_send($message_ids) { |
|
502 | 502 | $this->_init_queue_and_generator(); |
503 | - $messages = EEM_Message::instance()->get_all( array( |
|
503 | + $messages = EEM_Message::instance()->get_all(array( |
|
504 | 504 | array( |
505 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
505 | + 'MSG_ID' => array('IN', $message_ids), |
|
506 | 506 | 'STS_ID' => array( |
507 | 507 | 'IN', |
508 | 508 | array_merge( |
509 | 509 | EEM_Message::instance()->stati_indicating_sent(), |
510 | - array( EEM_Message::status_retry ) |
|
510 | + array(EEM_Message::status_retry) |
|
511 | 511 | ), |
512 | 512 | ), |
513 | 513 | ), |
514 | 514 | )); |
515 | 515 | //set the Messages to resend. |
516 | - foreach ( $messages as $message ) { |
|
517 | - if ( $message instanceof EE_Message ) { |
|
518 | - $message->set_STS_ID( EEM_Message::status_resend ); |
|
519 | - $this->_queue->add( $message ); |
|
516 | + foreach ($messages as $message) { |
|
517 | + if ($message instanceof EE_Message) { |
|
518 | + $message->set_STS_ID(EEM_Message::status_resend); |
|
519 | + $this->_queue->add($message); |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | - $this->_queue->initiate_request_by_priority( 'send' ); |
|
523 | + $this->_queue->initiate_request_by_priority('send'); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | |
@@ -534,23 +534,23 @@ discard block |
||
534 | 534 | * |
535 | 535 | * @return EE_Message_To_Generate[] |
536 | 536 | */ |
537 | - public function setup_messages_to_generate_from_registration_ids_in_request( $registration_ids_key = '_REG_ID' ) { |
|
538 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
539 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
537 | + public function setup_messages_to_generate_from_registration_ids_in_request($registration_ids_key = '_REG_ID') { |
|
538 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
539 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
540 | 540 | $regs_to_send = array(); |
541 | - $regIDs = EE_Registry::instance()->REQ->get( $registration_ids_key ); |
|
542 | - if ( empty( $regIDs ) ) { |
|
543 | - EE_Error::add_error( __('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
541 | + $regIDs = EE_Registry::instance()->REQ->get($registration_ids_key); |
|
542 | + if (empty($regIDs)) { |
|
543 | + EE_Error::add_error(__('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
544 | 544 | return false; |
545 | 545 | } |
546 | 546 | |
547 | 547 | //make sure is an array |
548 | - $regIDs = is_array( $regIDs ) ? $regIDs : array( $regIDs ); |
|
548 | + $regIDs = is_array($regIDs) ? $regIDs : array($regIDs); |
|
549 | 549 | |
550 | - foreach( $regIDs as $regID ) { |
|
551 | - $reg = EEM_Registration::instance()->get_one_by_ID( $regID ); |
|
552 | - if ( ! $reg instanceof EE_Registration ) { |
|
553 | - EE_Error::add_error( sprintf( __('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID ) ); |
|
550 | + foreach ($regIDs as $regID) { |
|
551 | + $reg = EEM_Registration::instance()->get_one_by_ID($regID); |
|
552 | + if ( ! $reg instanceof EE_Registration) { |
|
553 | + EE_Error::add_error(sprintf(__('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID)); |
|
554 | 554 | return false; |
555 | 555 | } |
556 | 556 | $regs_to_send[$reg->transaction_ID()][$reg->status_ID()][] = $reg; |
@@ -558,13 +558,13 @@ discard block |
||
558 | 558 | |
559 | 559 | $messages_to_generate = array(); |
560 | 560 | |
561 | - foreach ( $regs_to_send as $status_group ) { |
|
562 | - foreach ( $status_group as $status_id => $registrations ) { |
|
561 | + foreach ($regs_to_send as $status_group) { |
|
562 | + foreach ($status_group as $status_id => $registrations) { |
|
563 | 563 | $messages_to_generate = array_merge( |
564 | 564 | $messages_to_generate, |
565 | 565 | $this->setup_mtgs_for_all_active_messengers( |
566 | - EEH_MSG_Template::convert_reg_status_to_message_type( $status_id ), |
|
567 | - array( $registrations, $status_id ) |
|
566 | + EEH_MSG_Template::convert_reg_status_to_message_type($status_id), |
|
567 | + array($registrations, $status_id) |
|
568 | 568 | ) |
569 | 569 | ); |
570 | 570 | } |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param \EE_Message_Repository $message_repository |
73 | 73 | */ |
74 | - public function __construct( EE_Message_Repository $message_repository ) { |
|
75 | - $this->_batch_count = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 ); |
|
74 | + public function __construct(EE_Message_Repository $message_repository) { |
|
75 | + $this->_batch_count = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50); |
|
76 | 76 | $this->_rate_limit = $this->get_rate_limit(); |
77 | 77 | $this->_message_repository = $message_repository; |
78 | 78 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * use the messenger send method but typically is based on preview data. |
92 | 92 | * @return bool Whether the message was successfully added to the repository or not. |
93 | 93 | */ |
94 | - public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) { |
|
94 | + public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) { |
|
95 | 95 | $data['preview'] = $preview; |
96 | 96 | $data['test_send'] = $test_send; |
97 | - return $this->_message_repository->add( $message, $data ); |
|
97 | + return $this->_message_repository->add($message, $data); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param bool $persist This flag indicates whether to attempt to delete the object from the db as well. |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function remove( EE_Message $message, $persist = false ) { |
|
110 | - if ( $persist && $this->_message_repository->current() !== $message ) { |
|
109 | + public function remove(EE_Message $message, $persist = false) { |
|
110 | + if ($persist && $this->_message_repository->current() !== $message) { |
|
111 | 111 | //get pointer on right message |
112 | - if ( $this->_message_repository->has( $message ) ) { |
|
112 | + if ($this->_message_repository->has($message)) { |
|
113 | 113 | $this->_message_repository->rewind(); |
114 | - while( $this->_message_repository->valid() ) { |
|
115 | - if ( $this->_message_repository->current() === $message ) { |
|
114 | + while ($this->_message_repository->valid()) { |
|
115 | + if ($this->_message_repository->current() === $message) { |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | $this->_message_repository->next(); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | } |
124 | - return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove( $message ); |
|
124 | + return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove($message); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | * @return bool true if successfully retrieved batch, false no batch ready. |
162 | 162 | */ |
163 | 163 | public function get_batch_to_generate() { |
164 | - if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) { |
|
164 | + if ($this->is_locked(EE_Messages_Queue::action_generating)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | //lock batch generation to prevent race conditions. |
169 | - $this->lock_queue( EE_Messages_Queue::action_generating ); |
|
169 | + $this->lock_queue(EE_Messages_Queue::action_generating); |
|
170 | 170 | |
171 | 171 | $query_args = array( |
172 | 172 | // key 0 = where conditions |
173 | - 0 => array( 'STS_ID' => EEM_Message::status_incomplete ), |
|
173 | + 0 => array('STS_ID' => EEM_Message::status_incomplete), |
|
174 | 174 | 'order_by' => $this->_get_priority_orderby(), |
175 | 175 | 'limit' => $this->_batch_count |
176 | 176 | ); |
177 | - $messages = EEM_Message::instance()->get_all( $query_args ); |
|
177 | + $messages = EEM_Message::instance()->get_all($query_args); |
|
178 | 178 | |
179 | - if ( ! $messages ) { |
|
179 | + if ( ! $messages) { |
|
180 | 180 | return false; //nothing to generate |
181 | 181 | } |
182 | 182 | |
183 | - foreach ( $messages as $message ) { |
|
184 | - if ( $message instanceof EE_Message ) { |
|
183 | + foreach ($messages as $message) { |
|
184 | + if ($message instanceof EE_Message) { |
|
185 | 185 | $data = $message->all_extra_meta_array(); |
186 | - $this->add( $message, $data ); |
|
186 | + $this->add($message, $data); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | return true; |
@@ -206,34 +206,34 @@ discard block |
||
206 | 206 | * to assist with notifying user. |
207 | 207 | */ |
208 | 208 | public function get_to_send_batch_and_send() { |
209 | - if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) { |
|
209 | + if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | |
213 | - $this->lock_queue( EE_Messages_Queue::action_sending ); |
|
213 | + $this->lock_queue(EE_Messages_Queue::action_sending); |
|
214 | 214 | |
215 | 215 | $batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit; |
216 | 216 | |
217 | 217 | $query_args = array( |
218 | 218 | // key 0 = where conditions |
219 | - 0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ), |
|
219 | + 0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())), |
|
220 | 220 | 'order_by' => $this->_get_priority_orderby(), |
221 | 221 | 'limit' => $batch |
222 | 222 | ); |
223 | 223 | |
224 | - $messages_to_send = EEM_Message::instance()->get_all( $query_args ); |
|
224 | + $messages_to_send = EEM_Message::instance()->get_all($query_args); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | //any to send? |
228 | - if ( ! $messages_to_send ) { |
|
229 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
228 | + if ( ! $messages_to_send) { |
|
229 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
230 | 230 | return false; |
231 | 231 | } |
232 | 232 | |
233 | 233 | //add to queue. |
234 | - foreach ( $messages_to_send as $message ) { |
|
235 | - if ( $message instanceof EE_Message ) { |
|
236 | - $this->add( $message ); |
|
234 | + foreach ($messages_to_send as $message) { |
|
235 | + if ($message instanceof EE_Message) { |
|
236 | + $this->add($message); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $this->execute(); |
242 | 242 | |
243 | 243 | //release lock |
244 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
244 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param string $type The type of queue being locked. |
255 | 255 | */ |
256 | - public function lock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
257 | - set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) ); |
|
256 | + public function lock_queue($type = EE_Messages_Queue::action_generating) { |
|
257 | + set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param string $type The type of queue being unlocked. |
267 | 267 | */ |
268 | - public function unlock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
269 | - delete_transient( $this->_get_lock_key( $type ) ); |
|
268 | + public function unlock_queue($type = EE_Messages_Queue::action_generating) { |
|
269 | + delete_transient($this->_get_lock_key($type)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $type The type of lock. |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) { |
|
281 | - return '_ee_lock_' . $type; |
|
280 | + protected function _get_lock_key($type = EE_Messages_Queue::action_generating) { |
|
281 | + return '_ee_lock_'.$type; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param string $type The type of lock |
290 | 290 | * @return int time to expiry in seconds. |
291 | 291 | */ |
292 | - protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) { |
|
293 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type ); |
|
292 | + protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) { |
|
293 | + return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return int |
309 | 309 | */ |
310 | 310 | protected function _get_rate_limit_expiry() { |
311 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS ); |
|
311 | + return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return int |
320 | 320 | */ |
321 | 321 | protected function _default_rate_limit() { |
322 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 ); |
|
322 | + return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -345,14 +345,14 @@ discard block |
||
345 | 345 | * @param string $type The type of lock being checked for. |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | - public function is_locked( $type = EE_Messages_Queue::action_generating ) { |
|
348 | + public function is_locked($type = EE_Messages_Queue::action_generating) { |
|
349 | 349 | /** |
350 | 350 | * This filters the default is_locked behaviour. |
351 | 351 | */ |
352 | 352 | $is_locked = filter_var( |
353 | 353 | apply_filters( |
354 | 354 | 'FHEE__EE_Messages_Queue__is_locked', |
355 | - get_transient( $this->_get_lock_key( $type ) ), |
|
355 | + get_transient($this->_get_lock_key($type)), |
|
356 | 356 | $this |
357 | 357 | ), |
358 | 358 | FILTER_VALIDATE_BOOLEAN |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * Also implemented here because messages processed on the same request should not have any locks applied. |
364 | 364 | */ |
365 | 365 | if ( |
366 | - apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false ) |
|
366 | + apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
367 | 367 | || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
368 | 368 | ) { |
369 | 369 | $is_locked = false; |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | * @return int |
386 | 386 | */ |
387 | 387 | public function get_rate_limit() { |
388 | - if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) { |
|
388 | + if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) { |
|
389 | 389 | $rate_limit = $this->_default_rate_limit(); |
390 | - set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() ); |
|
390 | + set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key()); |
|
391 | 391 | } |
392 | 392 | return $rate_limit; |
393 | 393 | } |
@@ -399,12 +399,12 @@ discard block |
||
399 | 399 | * This updates existing rate limit with the new limit which is the old minus the batch. |
400 | 400 | * @param int $batch_completed This sets the new rate limit based on the given batch that was completed. |
401 | 401 | */ |
402 | - public function set_rate_limit( $batch_completed ) { |
|
402 | + public function set_rate_limit($batch_completed) { |
|
403 | 403 | //first get the most up to date rate limit (in case its expired and reset) |
404 | 404 | $rate_limit = $this->get_rate_limit(); |
405 | 405 | $new_limit = $rate_limit - $batch_completed; |
406 | 406 | //updating the transient option directly to avoid resetting the expiry. |
407 | - update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit ); |
|
407 | + update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param string $task This indicates what type of request is going to be initiated. |
418 | 418 | * @param int $priority This indicates the priority that triggers initiating the request. |
419 | 419 | */ |
420 | - public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) { |
|
420 | + public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { |
|
421 | 421 | //determine what status is matched with the priority as part of the trigger conditions. |
422 | 422 | $status = $task == 'generate' |
423 | 423 | ? EEM_Message::status_incomplete |
@@ -437,19 +437,19 @@ discard block |
||
437 | 437 | * the same request. |
438 | 438 | */ |
439 | 439 | if ( |
440 | - apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false ) |
|
440 | + apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
441 | 441 | || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
442 | 442 | ) { |
443 | - $messages_processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
444 | - if ( $messages_processor instanceof EE_Messages_Processor ) { |
|
445 | - return $messages_processor->process_immediately_from_queue( $this ); |
|
443 | + $messages_processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
444 | + if ($messages_processor instanceof EE_Messages_Processor) { |
|
445 | + return $messages_processor->process_immediately_from_queue($this); |
|
446 | 446 | } |
447 | 447 | //if we get here then that means the messages processor couldn't be loaded so messages will just remain |
448 | 448 | //queued for manual triggering by end user. |
449 | 449 | } |
450 | 450 | |
451 | - if ( $this->_message_repository->count_by_priority_and_status( $priority, $status ) ) { |
|
452 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task ); |
|
451 | + if ($this->_message_repository->count_by_priority_and_status($priority, $status)) { |
|
452 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); |
|
453 | 453 | } |
454 | 454 | } |
455 | 455 | |
@@ -474,53 +474,53 @@ discard block |
||
474 | 474 | * Also, if the messenger is an request type messenger (or a preview), |
475 | 475 | * its entirely possible that the messenger will exit before |
476 | 476 | */ |
477 | - public function execute( $save = true, $sending_messenger = null, $by_priority = false ) { |
|
477 | + public function execute($save = true, $sending_messenger = null, $by_priority = false) { |
|
478 | 478 | $messages_sent = 0; |
479 | 479 | $this->_did_hook = array(); |
480 | 480 | $this->_message_repository->rewind(); |
481 | 481 | |
482 | - while ( $this->_message_repository->valid() ) { |
|
482 | + while ($this->_message_repository->valid()) { |
|
483 | 483 | $error_messages = array(); |
484 | 484 | /** @type EE_Message $message */ |
485 | 485 | $message = $this->_message_repository->current(); |
486 | 486 | //only process things that are queued for sending |
487 | - if ( ! in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send() ) ) { |
|
487 | + if ( ! in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send())) { |
|
488 | 488 | $this->_message_repository->next(); |
489 | 489 | continue; |
490 | 490 | } |
491 | 491 | //if $by_priority is set and does not match then continue; |
492 | - if ( $by_priority && $by_priority != $message->priority() ) { |
|
492 | + if ($by_priority && $by_priority != $message->priority()) { |
|
493 | 493 | $this->_message_repository->next(); |
494 | 494 | continue; |
495 | 495 | } |
496 | 496 | //error checking |
497 | - if ( ! $message->valid_messenger() ) { |
|
497 | + if ( ! $message->valid_messenger()) { |
|
498 | 498 | $error_messages[] = sprintf( |
499 | - __( 'The %s messenger is not active at time of sending.', 'event_espresso' ), |
|
499 | + __('The %s messenger is not active at time of sending.', 'event_espresso'), |
|
500 | 500 | $message->messenger() |
501 | 501 | ); |
502 | 502 | } |
503 | - if ( ! $message->valid_message_type() ) { |
|
503 | + if ( ! $message->valid_message_type()) { |
|
504 | 504 | $error_messages[] = sprintf( |
505 | - __( 'The %s message type is not active at the time of sending.', 'event_espresso' ), |
|
505 | + __('The %s message type is not active at the time of sending.', 'event_espresso'), |
|
506 | 506 | $message->message_type() |
507 | 507 | ); |
508 | 508 | } |
509 | 509 | // if there was supposed to be a sending messenger for this message, but it was invalid/inactive, |
510 | 510 | // then it will instead be an EE_Error object, so let's check for that |
511 | - if ( $sending_messenger instanceof EE_Error ) { |
|
511 | + if ($sending_messenger instanceof EE_Error) { |
|
512 | 512 | $error_messages[] = $sending_messenger->getMessage(); |
513 | 513 | } |
514 | 514 | // if there are no errors, then let's process the message |
515 | - if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) { |
|
515 | + if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) { |
|
516 | 516 | $messages_sent++; |
517 | 517 | } |
518 | - $this->_set_error_message( $message, $error_messages ); |
|
518 | + $this->_set_error_message($message, $error_messages); |
|
519 | 519 | //add modified time |
520 | - $message->set_modified( time() ); |
|
520 | + $message->set_modified(time()); |
|
521 | 521 | $this->_message_repository->next(); |
522 | 522 | } |
523 | - if ( $save ) { |
|
523 | + if ($save) { |
|
524 | 524 | $this->save(); |
525 | 525 | } |
526 | 526 | return $messages_sent; |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | * @param mixed $sending_messenger (optional) |
536 | 536 | * @return bool |
537 | 537 | */ |
538 | - protected function _process_message( EE_Message $message, $sending_messenger = null ) { |
|
538 | + protected function _process_message(EE_Message $message, $sending_messenger = null) { |
|
539 | 539 | // these *should* have been validated in the execute() method above |
540 | 540 | $messenger = $message->messenger_object(); |
541 | 541 | $message_type = $message->message_type_object(); |
@@ -545,20 +545,20 @@ discard block |
||
545 | 545 | && $messenger instanceof EE_messenger |
546 | 546 | && $sending_messenger->name != $messenger->name |
547 | 547 | ) { |
548 | - $messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
548 | + $messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
549 | 549 | $messenger = $sending_messenger; |
550 | 550 | } |
551 | 551 | // send using messenger, but double check objects |
552 | - if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) { |
|
552 | + if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) { |
|
553 | 553 | //set hook for message type (but only if not using another messenger to send). |
554 | - if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) { |
|
555 | - $message_type->do_messenger_hooks( $messenger ); |
|
556 | - $this->_did_hook[ $message_type->name ] = 1; |
|
554 | + if ( ! isset($this->_did_hook[$message_type->name])) { |
|
555 | + $message_type->do_messenger_hooks($messenger); |
|
556 | + $this->_did_hook[$message_type->name] = 1; |
|
557 | 557 | } |
558 | 558 | //if preview then use preview method |
559 | 559 | return $this->_message_repository->is_preview() |
560 | - ? $this->_do_preview( $message, $messenger, $message_type, $this->_message_repository->is_test_send() ) |
|
561 | - : $this->_do_send( $message, $messenger, $message_type ); |
|
560 | + ? $this->_do_preview($message, $messenger, $message_type, $this->_message_repository->is_test_send()) |
|
561 | + : $this->_do_send($message, $messenger, $message_type); |
|
562 | 562 | } |
563 | 563 | return false; |
564 | 564 | } |
@@ -576,12 +576,12 @@ discard block |
||
576 | 576 | * @param array $status Stati to check for in queue |
577 | 577 | * @return int Count of EE_Message's matching the given status. |
578 | 578 | */ |
579 | - public function count_STS_in_queue( $status ) { |
|
579 | + public function count_STS_in_queue($status) { |
|
580 | 580 | $count = 0; |
581 | - $status = is_array( $status ) ? $status : array( $status ); |
|
581 | + $status = is_array($status) ? $status : array($status); |
|
582 | 582 | $this->_message_repository->rewind(); |
583 | - foreach( $this->_message_repository as $message ) { |
|
584 | - if ( in_array( $message->STS_ID(), $status ) ) { |
|
583 | + foreach ($this->_message_repository as $message) { |
|
584 | + if (in_array($message->STS_ID(), $status)) { |
|
585 | 585 | $count++; |
586 | 586 | } |
587 | 587 | } |
@@ -598,15 +598,15 @@ discard block |
||
598 | 598 | * @param $test_send |
599 | 599 | * @return bool true means all went well, false means, not so much. |
600 | 600 | */ |
601 | - protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
|
602 | - if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) { |
|
603 | - if ( ! $test_send ) { |
|
604 | - $message->set_content( $preview ); |
|
601 | + protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) { |
|
602 | + if ($preview = $messenger->get_preview($message, $message_type, $test_send)) { |
|
603 | + if ( ! $test_send) { |
|
604 | + $message->set_content($preview); |
|
605 | 605 | } |
606 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
606 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
607 | 607 | return true; |
608 | 608 | } else { |
609 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
609 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
610 | 610 | return false; |
611 | 611 | } |
612 | 612 | } |
@@ -622,12 +622,12 @@ discard block |
||
622 | 622 | * @param EE_message_type $message_type |
623 | 623 | * @return bool true means all went well, false means, not so much. |
624 | 624 | */ |
625 | - protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) { |
|
626 | - if ( $messenger->send_message( $message, $message_type ) ) { |
|
627 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
625 | + protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) { |
|
626 | + if ($messenger->send_message($message, $message_type)) { |
|
627 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
628 | 628 | return true; |
629 | 629 | } else { |
630 | - $message->set_STS_ID( EEM_Message::status_retry ); |
|
630 | + $message->set_STS_ID(EEM_Message::status_retry); |
|
631 | 631 | return false; |
632 | 632 | } |
633 | 633 | } |
@@ -641,21 +641,21 @@ discard block |
||
641 | 641 | * @param EE_Message $message |
642 | 642 | * @param array $error_messages the response from the messenger. |
643 | 643 | */ |
644 | - protected function _set_error_message( EE_Message $message, $error_messages ) { |
|
644 | + protected function _set_error_message(EE_Message $message, $error_messages) { |
|
645 | 645 | $error_messages = (array) $error_messages; |
646 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending() ) ) { |
|
646 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) { |
|
647 | 647 | $notices = EE_Error::has_notices(); |
648 | - $error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' ); |
|
649 | - if ( $notices === 1 ) { |
|
648 | + $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); |
|
649 | + if ($notices === 1) { |
|
650 | 650 | $notices = EE_Error::get_vanilla_notices(); |
651 | - $notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array(); |
|
652 | - $error_messages[] = implode( "\n", $notices['errors'] ); |
|
651 | + $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); |
|
652 | + $error_messages[] = implode("\n", $notices['errors']); |
|
653 | 653 | } |
654 | 654 | } |
655 | - if ( count( $error_messages ) > 0 ) { |
|
656 | - $msg = __( 'Message was not executed successfully.', 'event_espresso' ); |
|
657 | - $msg = $msg . "\n" . implode( "\n", $error_messages ); |
|
658 | - $message->set_error_message( $msg ); |
|
655 | + if (count($error_messages) > 0) { |
|
656 | + $msg = __('Message was not executed successfully.', 'event_espresso'); |
|
657 | + $msg = $msg."\n".implode("\n", $error_messages); |
|
658 | + $message->set_error_message($msg); |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 |
@@ -595,7 +595,7 @@ |
||
595 | 595 | *@param EE_Message $message |
596 | 596 | * @param EE_messenger $messenger |
597 | 597 | * @param EE_message_type $message_type |
598 | - * @param $test_send |
|
598 | + * @param boolean $test_send |
|
599 | 599 | * @return bool true means all went well, false means, not so much. |
600 | 600 | */ |
601 | 601 | protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | 60 | // check if class object is instantiated, and instantiated properly |
61 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Network_Config )) { |
|
61 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Network_Config)) { |
|
62 | 62 | self::$_instance = new self(); |
63 | 63 | } |
64 | 64 | return self::$_instance; |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | * @access private |
74 | 74 | */ |
75 | 75 | private function __construct() { |
76 | - do_action( 'AHEE__EE_Network_Config__construct__begin',$this ); |
|
76 | + do_action('AHEE__EE_Network_Config__construct__begin', $this); |
|
77 | 77 | //set defaults |
78 | - $this->core = apply_filters( 'FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config() ); |
|
78 | + $this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config()); |
|
79 | 79 | $this->addons = array(); |
80 | 80 | |
81 | 81 | $this->_load_config(); |
82 | 82 | |
83 | 83 | // construct__end hook |
84 | - do_action( 'AHEE__EE_Network_Config__construct__end',$this ); |
|
84 | + do_action('AHEE__EE_Network_Config__construct__end', $this); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -94,25 +94,25 @@ discard block |
||
94 | 94 | */ |
95 | 95 | private function _load_config() { |
96 | 96 | //load network config start hook |
97 | - do_action( 'AHEE__EE_Network_Config___load_config__start', $this ); |
|
97 | + do_action('AHEE__EE_Network_Config___load_config__start', $this); |
|
98 | 98 | $config = $this->get_config(); |
99 | - foreach ( $config as $config_prop => $settings ) { |
|
100 | - if ( is_object( $settings ) && property_exists( $this, $config_prop ) ) { |
|
101 | - $this->{$config_prop} = apply_filters( 'FHEE__EE_Network_Config___load_config__config_settings', $settings, $config_prop, $this ); |
|
102 | - if ( method_exists( $settings, 'populate' ) ) { |
|
99 | + foreach ($config as $config_prop => $settings) { |
|
100 | + if (is_object($settings) && property_exists($this, $config_prop)) { |
|
101 | + $this->{$config_prop} = apply_filters('FHEE__EE_Network_Config___load_config__config_settings', $settings, $config_prop, $this); |
|
102 | + if (method_exists($settings, 'populate')) { |
|
103 | 103 | $this->{$config_prop}->populate(); |
104 | 104 | } |
105 | - if ( method_exists( $settings, 'do_hooks' ) ) { |
|
105 | + if (method_exists($settings, 'do_hooks')) { |
|
106 | 106 | $this->{$config_prop}->do_hooks(); |
107 | 107 | } |
108 | 108 | } |
109 | 109 | } |
110 | - if ( apply_filters( 'FHEE__EE_Network_Config___load_config__update_network_config', false ) ) { |
|
110 | + if (apply_filters('FHEE__EE_Network_Config___load_config__update_network_config', false)) { |
|
111 | 111 | $this->update_config(); |
112 | 112 | } |
113 | 113 | |
114 | 114 | //load network config end hook |
115 | - do_action( 'AHEE__EE_Network_Config___load_config__end', $this ); |
|
115 | + do_action('AHEE__EE_Network_Config___load_config__end', $this); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function get_config() { |
128 | 128 | // grab network configuration |
129 | - $CFG = get_site_option( 'ee_network_config', array() ); |
|
130 | - $CFG = apply_filters( 'FHEE__EE_Network_Config__get_config__CFG', $CFG ); |
|
129 | + $CFG = get_site_option('ee_network_config', array()); |
|
130 | + $CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG); |
|
131 | 131 | return $CFG; |
132 | 132 | } |
133 | 133 | |
@@ -141,32 +141,32 @@ discard block |
||
141 | 141 | * @param bool $add_error |
142 | 142 | * @return bool success |
143 | 143 | */ |
144 | - public function update_config( $add_success = FALSE, $add_error = TRUE ) { |
|
145 | - do_action( 'AHEE__EE_Network_Config__update_config__begin',$this ); |
|
144 | + public function update_config($add_success = FALSE, $add_error = TRUE) { |
|
145 | + do_action('AHEE__EE_Network_Config__update_config__begin', $this); |
|
146 | 146 | |
147 | 147 | //we have to compare existing saved config with config in memory because if there is no difference that means |
148 | 148 | //that the method executed fine but there just was no update. WordPress doesn't distinguish between false because |
149 | 149 | //there were 0 records updated because of no change vs false because some error produced problems with the update. |
150 | - $original = get_site_option( 'ee_network_config' ); |
|
150 | + $original = get_site_option('ee_network_config'); |
|
151 | 151 | |
152 | - if ( $original == $this ) { |
|
152 | + if ($original == $this) { |
|
153 | 153 | return true; |
154 | 154 | } |
155 | 155 | // update |
156 | - $saved = update_site_option( 'ee_network_config', $this ); |
|
156 | + $saved = update_site_option('ee_network_config', $this); |
|
157 | 157 | |
158 | - do_action( 'AHEE__EE_Network_Config__update_config__end', $this, $saved ); |
|
158 | + do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved); |
|
159 | 159 | // if config remains the same or was updated successfully |
160 | - if ( $saved ) { |
|
161 | - if ( $add_success ) { |
|
162 | - $msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso' ) : __( 'Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso' ); |
|
163 | - EE_Error::add_success( $msg ); |
|
160 | + if ($saved) { |
|
161 | + if ($add_success) { |
|
162 | + $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso') : __('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso'); |
|
163 | + EE_Error::add_success($msg); |
|
164 | 164 | } |
165 | 165 | return TRUE; |
166 | 166 | } else { |
167 | - if ( $add_error ) { |
|
168 | - $msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings were not updated.', 'event_espresso' ) : __( 'Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso' ); |
|
169 | - EE_Error::add_error( $msg , __FILE__, __FUNCTION__, __LINE__ ); |
|
167 | + if ($add_error) { |
|
168 | + $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings were not updated.', 'event_espresso') : __('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso'); |
|
169 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
170 | 170 | } |
171 | 171 | return FALSE; |
172 | 172 | } |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * @return array |
181 | 181 | */ |
182 | 182 | public function __sleep() { |
183 | - return apply_filters( 'FHEE__EE_Network_Config__sleep',array( |
|
183 | + return apply_filters('FHEE__EE_Network_Config__sleep', array( |
|
184 | 184 | 'core', |
185 | - ) ); |
|
185 | + )); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } //end EE_Network_Config. |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -23,18 +23,18 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct() { |
25 | 25 | //register tasks (and make sure only registered once). |
26 | - if ( ! has_action( 'FHEE__EEH_Activation__get_cron_tasks', array( $this, 'register_scheduled_tasks' ) ) ) { |
|
27 | - add_action( 'FHEE__EEH_Activation__get_cron_tasks', array( $this, 'register_scheduled_tasks' ), 10 ); |
|
26 | + if ( ! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
27 | + add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | //register callbacks for scheduled events (but make sure they are set only once). |
31 | - if ( ! has_action( 'AHEE__EE_Messages_Scheduler__generation', array( 'EE_Messages_Scheduler', 'batch_generation' ) ) ) { |
|
32 | - add_action( 'AHEE__EE_Messages_Scheduler__generation', array( 'EE_Messages_Scheduler', 'batch_generation') ); |
|
33 | - add_action( 'AHEE__EE_Messages_Scheduler__sending', array( 'EE_Messages_Scheduler', 'batch_sending' ) ); |
|
31 | + if ( ! has_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation'))) { |
|
32 | + add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
33 | + add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | //add custom schedules |
37 | - add_filter( 'cron_schedules', array( $this, 'custom_schedules' ) ); |
|
37 | + add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | * Add custom schedules for wp_cron |
45 | 45 | * @param $schedules |
46 | 46 | */ |
47 | - public function custom_schedules( $schedules ) { |
|
47 | + public function custom_schedules($schedules) { |
|
48 | 48 | $schedules['ee_message_cron'] = array( |
49 | 49 | 'interval' => self::message_cron_schedule, |
50 | - 'display' => __( 'This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', 'event_espresso' ) |
|
50 | + 'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', 'event_espresso') |
|
51 | 51 | ); |
52 | 52 | return $schedules; |
53 | 53 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param array $tasks already existing scheduled tasks |
59 | 59 | * @return array |
60 | 60 | */ |
61 | - public function register_scheduled_tasks( $tasks ) { |
|
61 | + public function register_scheduled_tasks($tasks) { |
|
62 | 62 | $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
63 | 63 | $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
64 | 64 | return $tasks; |
@@ -70,27 +70,27 @@ discard block |
||
70 | 70 | * Note: The EED_Messages module has the handlers for these requests. |
71 | 71 | * @param string $task The task the request is being generated for. |
72 | 72 | */ |
73 | - public static function initiate_scheduled_non_blocking_request( $task ) { |
|
74 | - if ( apply_filters( 'EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', true ) ) { |
|
75 | - $request_url = add_query_arg( |
|
73 | + public static function initiate_scheduled_non_blocking_request($task) { |
|
74 | + if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', true)) { |
|
75 | + $request_url = add_query_arg( |
|
76 | 76 | array_merge( |
77 | - array( 'ee' => 'msg_cron_trigger' ), |
|
78 | - EE_Messages_Scheduler::get_request_params( $task ) |
|
77 | + array('ee' => 'msg_cron_trigger'), |
|
78 | + EE_Messages_Scheduler::get_request_params($task) |
|
79 | 79 | ), |
80 | 80 | site_url() |
81 | 81 | ); |
82 | 82 | $request_args = array( |
83 | 83 | 'timeout' => 300, |
84 | - 'blocking' => ( defined( 'DOING_CRON' ) && DOING_CRON ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? true : false, |
|
84 | + 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
85 | 85 | 'sslverify' => false, |
86 | 86 | 'redirection' => 10, |
87 | 87 | ); |
88 | - $response = wp_remote_get( $request_url, $request_args ); |
|
89 | - if ( is_wp_error( $response ) ) { |
|
90 | - trigger_error( $response->get_error_message() ); |
|
88 | + $response = wp_remote_get($request_url, $request_args); |
|
89 | + if (is_wp_error($response)) { |
|
90 | + trigger_error($response->get_error_message()); |
|
91 | 91 | } |
92 | 92 | } else { |
93 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron( $task ); |
|
93 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron($task); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | * @param string $task The task the request is for. |
104 | 104 | * @return array |
105 | 105 | */ |
106 | - public static function get_request_params( $task ) { |
|
106 | + public static function get_request_params($task) { |
|
107 | 107 | //transient is used for flood control on msg_cron_trigger requests |
108 | - $transient_key = 'ee_trans_' . uniqid( $task ); |
|
109 | - set_transient( $transient_key, 1, 5 * MINUTE_IN_SECONDS ); |
|
108 | + $transient_key = 'ee_trans_'.uniqid($task); |
|
109 | + set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
|
110 | 110 | return array( |
111 | 111 | 'type' => $task, |
112 | 112 | 'key' => $transient_key, |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | * This is used to execute an immediate call to the run_cron task performed by EED_Messages |
121 | 121 | * @param string $task The task the request is being generated for. |
122 | 122 | */ |
123 | - public static function initiate_immediate_request_on_cron( $task ) { |
|
124 | - $request_args = EE_Messages_Scheduler::get_request_params( $task ); |
|
123 | + public static function initiate_immediate_request_on_cron($task) { |
|
124 | + $request_args = EE_Messages_Scheduler::get_request_params($task); |
|
125 | 125 | //set those request args in the request so it gets picked up |
126 | - foreach ( $request_args as $request_key => $request_value ) { |
|
127 | - EE_Registry::instance()->REQ->set( $request_key, $request_value ); |
|
126 | + foreach ($request_args as $request_key => $request_value) { |
|
127 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
128 | 128 | } |
129 | 129 | EED_Messages::instance()->run_cron(); |
130 | 130 | } |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
142 | 142 | */ |
143 | 143 | if ( |
144 | - ! apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false ) |
|
144 | + ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
145 | 145 | || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
146 | 146 | ) { |
147 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron( 'generate' ); |
|
147 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate'); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
160 | 160 | */ |
161 | 161 | if ( |
162 | - ! apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false ) |
|
162 | + ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
163 | 163 | || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
164 | 164 | ) { |
165 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron( 'send' ); |
|
165 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | protected static $_event = NULL; |
36 | 36 | |
37 | 37 | /** |
38 | - * array of datetimes and the spaces available for them |
|
39 | - * |
|
40 | - * @access private |
|
41 | - * @var array |
|
42 | - */ |
|
38 | + * array of datetimes and the spaces available for them |
|
39 | + * |
|
40 | + * @access private |
|
41 | + * @var array |
|
42 | + */ |
|
43 | 43 | private static $_available_spaces = array(); |
44 | 44 | |
45 | 45 | |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | return $permalink_string; |
209 | 209 | } |
210 | 210 | $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' |
211 | - . __( 'Embed', 'event_espresso' ) |
|
212 | - . '</a> '; |
|
211 | + . __( 'Embed', 'event_espresso' ) |
|
212 | + . '</a> '; |
|
213 | 213 | $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
214 | 214 | $iframe_string = esc_html( |
215 | 215 | '<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>' |
@@ -884,11 +884,11 @@ discard block |
||
884 | 884 | |
885 | 885 | |
886 | 886 | /** |
887 | - * load js |
|
888 | - * |
|
889 | - * @access public |
|
890 | - * @return void |
|
891 | - */ |
|
887 | + * load js |
|
888 | + * |
|
889 | + * @access public |
|
890 | + * @return void |
|
891 | + */ |
|
892 | 892 | public static function load_tckt_slctr_assets() { |
893 | 893 | // add some style |
894 | 894 | if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | * @return EED_Ticket_Selector |
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | - return parent::get_instance( __CLASS__ ); |
|
60 | + return parent::get_instance(__CLASS__); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | - protected function set_config(){ |
|
66 | - $this->set_config_section( 'template_settings' ); |
|
67 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
68 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
65 | + protected function set_config() { |
|
66 | + $this->set_config_section('template_settings'); |
|
67 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
68 | + $this->set_config_name('EED_Ticket_Selector'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function set_hooks() { |
82 | 82 | // routing |
83 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
84 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
85 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
83 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
84 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
85 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
86 | 86 | //add_action( 'AHEE_event_details_before_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_open' ), 10, 1 ); |
87 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
87 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
88 | 88 | //add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', array( 'EED_Ticket_Selector', 'display_ticket_selector_submit' ), 10, 1 ); |
89 | 89 | //add_action( 'AHEE_event_details_after_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_close' ), 10 ); |
90 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
90 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * @return void |
100 | 100 | */ |
101 | 101 | public static function set_hooks_admin() { |
102 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
102 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
103 | 103 | //add button for iframe code to event editor. |
104 | - add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 ); |
|
105 | - add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 ); |
|
104 | + add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4); |
|
105 | + add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @return void |
115 | 115 | */ |
116 | 116 | public static function set_definitions() { |
117 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
118 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
117 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
118 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
119 | 119 | |
120 | 120 | //if config is not set, initialize |
121 | 121 | //If config is not set, set it. |
122 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) { |
|
122 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) { |
|
123 | 123 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
124 | 124 | } |
125 | - EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' ); |
|
125 | + EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso'); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param object $WP |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function run( $WP ) {} |
|
136 | + public function run($WP) {} |
|
137 | 137 | |
138 | 138 | |
139 | 139 | /** |
@@ -145,23 +145,23 @@ discard block |
||
145 | 145 | public function ticket_selector_iframe() { |
146 | 146 | self::$_in_iframe = true; |
147 | 147 | /** @type EEM_Event $EEM_Event */ |
148 | - $EEM_Event = EE_Registry::instance()->load_model( 'Event' ); |
|
148 | + $EEM_Event = EE_Registry::instance()->load_model('Event'); |
|
149 | 149 | $event = $EEM_Event->get_one_by_ID( |
150 | - EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
150 | + EE_Registry::instance()->REQ->get('event', 0) |
|
151 | 151 | ); |
152 | - EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
153 | - $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event ); |
|
152 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
153 | + $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event); |
|
154 | 154 | $template_args['css'] = apply_filters( |
155 | 155 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
156 | 156 | array( |
157 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
158 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
159 | - includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ), |
|
160 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
|
157 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION, |
|
158 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION, |
|
159 | + includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']), |
|
160 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION |
|
161 | 161 | ) |
162 | 162 | ); |
163 | - EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true; |
|
164 | - EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = __( 'Please choose at least one ticket before continuing.', 'event_espresso' ); |
|
163 | + EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true; |
|
164 | + EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = __('Please choose at least one ticket before continuing.', 'event_espresso'); |
|
165 | 165 | $template_args['eei18n'] = apply_filters( |
166 | 166 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings', |
167 | 167 | EE_Registry::localize_i18n_js_strings() |
@@ -169,18 +169,18 @@ discard block |
||
169 | 169 | $template_args['js'] = apply_filters( |
170 | 170 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
171 | 171 | array( |
172 | - includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ), |
|
173 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
174 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION |
|
172 | + includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']), |
|
173 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION, |
|
174 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION |
|
175 | 175 | ) |
176 | 176 | ); |
177 | - $template_args[ 'notices' ] = EEH_Template::display_template( |
|
178 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
177 | + $template_args['notices'] = EEH_Template::display_template( |
|
178 | + EE_TEMPLATES.'espresso-ajax-notices.template.php', |
|
179 | 179 | array(), |
180 | 180 | true |
181 | 181 | ); |
182 | 182 | EEH_Template::display_template( |
183 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php', |
|
183 | + TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php', |
|
184 | 184 | $template_args |
185 | 185 | ); |
186 | 186 | exit; |
@@ -199,25 +199,25 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return string The new html string for the permalink area. |
201 | 201 | */ |
202 | - public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) { |
|
202 | + public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) { |
|
203 | 203 | //make sure this is ONLY when editing and the event id has been set. |
204 | - if ( ! empty( $id ) ) { |
|
205 | - $post = get_post( $id ); |
|
204 | + if ( ! empty($id)) { |
|
205 | + $post = get_post($id); |
|
206 | 206 | //if NOT event then let's get out. |
207 | - if ( $post->post_type !== 'espresso_events' ) { |
|
207 | + if ($post->post_type !== 'espresso_events') { |
|
208 | 208 | return $permalink_string; |
209 | 209 | } |
210 | 210 | $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' |
211 | - . __( 'Embed', 'event_espresso' ) |
|
211 | + . __('Embed', 'event_espresso') |
|
212 | 212 | . '</a> '; |
213 | - $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
|
213 | + $ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url()); |
|
214 | 214 | $iframe_string = esc_html( |
215 | - '<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>' |
|
215 | + '<iframe src="'.$ticket_selector_url.'" width="100%" height="100%"></iframe>' |
|
216 | 216 | ); |
217 | 217 | $permalink_string .= ' |
218 | 218 | <div id="js-ts-iframe" style="display:none"> |
219 | 219 | <div style="width:100%; height: 500px;"> |
220 | - ' . $iframe_string . ' |
|
220 | + ' . $iframe_string.' |
|
221 | 221 | </div> |
222 | 222 | </div>'; |
223 | 223 | } |
@@ -236,22 +236,22 @@ discard block |
||
236 | 236 | * @param mixed $event |
237 | 237 | * @return bool |
238 | 238 | */ |
239 | - protected static function set_event( $event = null ) { |
|
240 | - if( $event === null ) { |
|
239 | + protected static function set_event($event = null) { |
|
240 | + if ($event === null) { |
|
241 | 241 | global $post; |
242 | 242 | $event = $post; |
243 | 243 | } |
244 | - if ( $event instanceof EE_Event ) { |
|
244 | + if ($event instanceof EE_Event) { |
|
245 | 245 | self::$_event = $event; |
246 | - } else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) { |
|
246 | + } else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) { |
|
247 | 247 | self::$_event = $event->EE_Event; |
248 | - } else if ( $event instanceof WP_Post && $event->post_type == 'espresso_events' ) { |
|
249 | - $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
248 | + } else if ($event instanceof WP_Post && $event->post_type == 'espresso_events') { |
|
249 | + $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
250 | 250 | self::$_event = $event->EE_Event; |
251 | 251 | } else { |
252 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
253 | - $dev_msg = $user_msg . __( 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso' ); |
|
254 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
252 | + $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
253 | + $dev_msg = $user_msg.__('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso'); |
|
254 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
255 | 255 | return false; |
256 | 256 | } |
257 | 257 | return true; |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | * @param bool $view_details |
271 | 271 | * @return string |
272 | 272 | */ |
273 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
273 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
274 | 274 | // reset filter for displaying submit button |
275 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
275 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
276 | 276 | // poke and prod incoming event till it tells us what it is |
277 | - if ( ! EED_Ticket_Selector::set_event( $event )) { |
|
277 | + if ( ! EED_Ticket_Selector::set_event($event)) { |
|
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | && ( |
286 | 286 | ! self::$_event->display_ticket_selector() |
287 | 287 | || $view_details |
288 | - || post_password_required( $event_post ) |
|
288 | + || post_password_required($event_post) |
|
289 | 289 | || ( |
290 | 290 | $_event_active_status != EE_Datetime::active |
291 | 291 | && $_event_active_status != EE_Datetime::upcoming |
@@ -303,68 +303,68 @@ discard block |
||
303 | 303 | $template_args = array(); |
304 | 304 | $template_args['event_status'] = $_event_active_status; |
305 | 305 | |
306 | - $template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) ); |
|
307 | - $template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) ); |
|
306 | + $template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format')); |
|
307 | + $template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format')); |
|
308 | 308 | |
309 | 309 | $template_args['EVT_ID'] = self::$_event->ID(); |
310 | 310 | $template_args['event'] = self::$_event; |
311 | 311 | |
312 | 312 | // is the event expired ? |
313 | 313 | $template_args['event_is_expired'] = self::$_event->is_expired(); |
314 | - if ( $template_args['event_is_expired'] ) { |
|
315 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>'; |
|
314 | + if ($template_args['event_is_expired']) { |
|
315 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso').'</span></div>'; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | $ticket_query_args = array( |
319 | - array( 'Datetime.EVT_ID' => self::$_event->ID() ), |
|
320 | - 'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' ) |
|
319 | + array('Datetime.EVT_ID' => self::$_event->ID()), |
|
320 | + 'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC') |
|
321 | 321 | ); |
322 | 322 | |
323 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) { |
|
323 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
324 | 324 | //use the correct applicable time query depending on what version of core is being run. |
325 | - $current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp'); |
|
326 | - $ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time ); |
|
325 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp'); |
|
326 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | // get all tickets for this event ordered by the datetime |
330 | - $template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args ); |
|
330 | + $template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args); |
|
331 | 331 | |
332 | - if ( count( $template_args['tickets'] ) < 1 ) { |
|
333 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>'; |
|
332 | + if (count($template_args['tickets']) < 1) { |
|
333 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>'; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
337 | - $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit() ); |
|
338 | - if ( $template_args['max_atndz'] < 1 ) { |
|
339 | - $sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' ); |
|
340 | - if ( current_user_can( 'edit_post', self::$_event->ID() )) { |
|
341 | - $sales_closed_msg .= sprintf( |
|
342 | - __( '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso' ), |
|
337 | + $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit()); |
|
338 | + if ($template_args['max_atndz'] < 1) { |
|
339 | + $sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso'); |
|
340 | + if (current_user_can('edit_post', self::$_event->ID())) { |
|
341 | + $sales_closed_msg .= sprintf( |
|
342 | + __('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'), |
|
343 | 343 | '<div class="ee-attention" style="text-align: left;"><b>', |
344 | 344 | '</b><br />', |
345 | - $link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">', |
|
345 | + $link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">', |
|
346 | 346 | '</a></span></div>' |
347 | 347 | ); |
348 | 348 | } |
349 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
349 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
350 | 350 | } |
351 | 351 | |
352 | - $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php'; |
|
353 | - $templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event ); |
|
352 | + $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php'; |
|
353 | + $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event); |
|
354 | 354 | |
355 | 355 | // redirecting to another site for registration ?? |
356 | 356 | $external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE; |
357 | 357 | // set up the form (but not for the admin) |
358 | - $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open( self::$_event->ID(), $external_url ) : ''; |
|
358 | + $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : ''; |
|
359 | 359 | // if not redirecting to another site for registration |
360 | - if ( ! $external_url ) { |
|
360 | + if ( ! $external_url) { |
|
361 | 361 | // then display the ticket selector |
362 | - $ticket_selector .= EEH_Template::locate_template( $templates['ticket_selector'], $template_args ); |
|
362 | + $ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args); |
|
363 | 363 | } else { |
364 | 364 | // if not we still need to trigger the display of the submit button |
365 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
365 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
366 | 366 | //display notice to admin that registration is external |
367 | - $ticket_selector .= ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' ); |
|
367 | + $ticket_selector .= ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso'); |
|
368 | 368 | } |
369 | 369 | // submit button and form close tag |
370 | 370 | $ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : ''; |
@@ -384,25 +384,25 @@ discard block |
||
384 | 384 | * @param string $external_url |
385 | 385 | * @return string |
386 | 386 | */ |
387 | - public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) { |
|
387 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') { |
|
388 | 388 | // if redirecting, we don't need any anything else |
389 | - if ( $external_url ) { |
|
390 | - $html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">'; |
|
391 | - $query_args = EEH_URL::get_query_string( $external_url ); |
|
392 | - foreach ( $query_args as $query_arg => $value ) { |
|
393 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
389 | + if ($external_url) { |
|
390 | + $html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">'; |
|
391 | + $query_args = EEH_URL::get_query_string($external_url); |
|
392 | + foreach ($query_args as $query_arg => $value) { |
|
393 | + $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">'; |
|
394 | 394 | } |
395 | 395 | return $html; |
396 | 396 | } |
397 | - $checkout_url = EEH_Event_View::event_link_url( $ID ); |
|
398 | - if ( ! $checkout_url ) { |
|
399 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
397 | + $checkout_url = EEH_Event_View::event_link_url($ID); |
|
398 | + if ( ! $checkout_url) { |
|
399 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
400 | 400 | } |
401 | 401 | $extra_params = self::$_in_iframe ? ' target="_blank"' : ''; |
402 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
403 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE ); |
|
402 | + $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>'; |
|
403 | + $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE); |
|
404 | 404 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
405 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event ); |
|
405 | + $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event); |
|
406 | 406 | return $html; |
407 | 407 | } |
408 | 408 | |
@@ -417,23 +417,23 @@ discard block |
||
417 | 417 | * @return string |
418 | 418 | */ |
419 | 419 | public static function display_ticket_selector_submit() { |
420 | - if ( ! is_admin() ) { |
|
421 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE ) ) { |
|
420 | + if ( ! is_admin()) { |
|
421 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE)) { |
|
422 | 422 | $btn_text = apply_filters( |
423 | 423 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
424 | - __('Register Now', 'event_espresso' ), |
|
424 | + __('Register Now', 'event_espresso'), |
|
425 | 425 | self::$_event |
426 | 426 | ); |
427 | 427 | $external_url = self::$_event->external_url(); |
428 | - $html = '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn"'; |
|
428 | + $html = '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn"'; |
|
429 | 429 | $html .= ' class="ticket-selector-submit-btn '; |
430 | - $html .= empty( $external_url ) ? 'ticket-selector-submit-ajax"' : '"'; |
|
431 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
432 | - $html .= apply_filters( 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event ); |
|
430 | + $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
431 | + $html .= ' type="submit" value="'.$btn_text.'" />'; |
|
432 | + $html .= apply_filters('FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event); |
|
433 | 433 | $html .= '<div class="clear"><br/></div></form>'; |
434 | 434 | return $html; |
435 | - } else if ( is_archive() ) { |
|
436 | - return EED_Ticket_Selector::ticket_selector_form_close() . EED_Ticket_Selector::display_view_details_btn(); |
|
435 | + } else if (is_archive()) { |
|
436 | + return EED_Ticket_Selector::ticket_selector_form_close().EED_Ticket_Selector::display_view_details_btn(); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | return ''; |
@@ -465,13 +465,13 @@ discard block |
||
465 | 465 | * @return string |
466 | 466 | */ |
467 | 467 | public static function display_view_details_btn() { |
468 | - if ( ! self::$_event->get_permalink() ) { |
|
469 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
468 | + if ( ! self::$_event->get_permalink()) { |
|
469 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
470 | 470 | } |
471 | - $view_details_btn = '<form method="POST" action="' . self::$_event->get_permalink() . '">'; |
|
472 | - $btn_text = apply_filters( 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __( 'View Details', 'event_espresso' ), self::$_event ); |
|
473 | - $view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />'; |
|
474 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event ); |
|
471 | + $view_details_btn = '<form method="POST" action="'.self::$_event->get_permalink().'">'; |
|
472 | + $btn_text = apply_filters('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __('View Details', 'event_espresso'), self::$_event); |
|
473 | + $view_details_btn .= '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'.$btn_text.'" />'; |
|
474 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event); |
|
475 | 475 | $view_details_btn .= '<div class="clear"><br/></div>'; |
476 | 476 | $view_details_btn .= '</form>'; |
477 | 477 | return $view_details_btn; |
@@ -490,11 +490,11 @@ discard block |
||
490 | 490 | * @return array or FALSE |
491 | 491 | */ |
492 | 492 | public function process_ticket_selections() { |
493 | - do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
493 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
494 | 494 | // check nonce |
495 | - if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce' ) || ! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce' ), 'process_ticket_selections' ))) { |
|
495 | + if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce') || ! wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce'), 'process_ticket_selections'))) { |
|
496 | 496 | EE_Error::add_error( |
497 | - sprintf( __( 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
497 | + sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
498 | 498 | __FILE__, __FUNCTION__, __LINE__ |
499 | 499 | ); |
500 | 500 | return FALSE; |
@@ -508,16 +508,16 @@ discard block |
||
508 | 508 | |
509 | 509 | //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart. |
510 | 510 | // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc. |
511 | - EE_Registry::instance()->load_core( 'Session' ); |
|
511 | + EE_Registry::instance()->load_core('Session'); |
|
512 | 512 | // unless otherwise requested, clear the session |
513 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) { |
|
514 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
513 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) { |
|
514 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
515 | 515 | } |
516 | 516 | //d( EE_Registry::instance()->SSN ); |
517 | 517 | |
518 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
518 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
519 | 519 | // do we have an event id? |
520 | - if ( EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) { |
|
520 | + if (EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) { |
|
521 | 521 | // validate/sanitize data |
522 | 522 | $valid = self::_validate_post_data(); |
523 | 523 | |
@@ -527,41 +527,41 @@ discard block |
||
527 | 527 | //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ ); |
528 | 528 | |
529 | 529 | //check total tickets ordered vs max number of attendees that can register |
530 | - if ( $valid['total_tickets'] > $valid['max_atndz'] ) { |
|
530 | + if ($valid['total_tickets'] > $valid['max_atndz']) { |
|
531 | 531 | |
532 | 532 | // ordering too many tickets !!! |
533 | 533 | $total_tickets_string = _n('You have attempted to purchase %s ticket.', 'You have attempted to purchase %s tickets.', $valid['total_tickets'], 'event_espresso'); |
534 | - $limit_error_1 = sprintf( $total_tickets_string, $valid['total_tickets'] ); |
|
534 | + $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
535 | 535 | // dev only message |
536 | 536 | $max_atndz_string = _n('The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', $valid['max_atndz'], 'event_espresso'); |
537 | - $limit_error_2 = sprintf( $max_atndz_string, $valid['max_atndz'], $valid['max_atndz'] ); |
|
538 | - EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ ); |
|
537 | + $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']); |
|
538 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
539 | 539 | } else { |
540 | 540 | |
541 | 541 | // all data appears to be valid |
542 | 542 | $tckts_slctd = FALSE; |
543 | 543 | $success = TRUE; |
544 | 544 | // load cart |
545 | - EE_Registry::instance()->load_core( 'Cart' ); |
|
545 | + EE_Registry::instance()->load_core('Cart'); |
|
546 | 546 | |
547 | 547 | // cycle thru the number of data rows sent from the event listing |
548 | - for ( $x = 0; $x < $valid['rows']; $x++ ) { |
|
548 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
549 | 549 | // does this row actually contain a ticket quantity? |
550 | - if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) { |
|
550 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
551 | 551 | // YES we have a ticket quantity |
552 | 552 | $tckts_slctd = TRUE; |
553 | 553 | // d( $valid['ticket_obj'][$x] ); |
554 | - if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) { |
|
554 | + if ($valid['ticket_obj'][$x] instanceof EE_Ticket) { |
|
555 | 555 | // then add ticket to cart |
556 | - $ticket_added = self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] ); |
|
556 | + $ticket_added = self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]); |
|
557 | 557 | $success = ! $ticket_added ? FALSE : $success; |
558 | - if ( EE_Error::has_error() ) { |
|
558 | + if (EE_Error::has_error()) { |
|
559 | 559 | break; |
560 | 560 | } |
561 | 561 | } else { |
562 | 562 | // nothing added to cart retrieved |
563 | 563 | EE_Error::add_error( |
564 | - sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
564 | + sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
565 | 565 | __FILE__, __FUNCTION__, __LINE__ |
566 | 566 | ); |
567 | 567 | } |
@@ -570,45 +570,45 @@ discard block |
||
570 | 570 | //d( EE_Registry::instance()->CART ); |
571 | 571 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
572 | 572 | |
573 | - if ( $tckts_slctd ) { |
|
574 | - if ( $success ) { |
|
575 | - do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this ); |
|
573 | + if ($tckts_slctd) { |
|
574 | + if ($success) { |
|
575 | + do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this); |
|
576 | 576 | EE_Registry::instance()->CART->recalculate_all_cart_totals(); |
577 | - EE_Registry::instance()->CART->save_cart( FALSE ); |
|
577 | + EE_Registry::instance()->CART->save_cart(FALSE); |
|
578 | 578 | EE_Registry::instance()->SSN->update(); |
579 | 579 | //d( EE_Registry::instance()->CART ); |
580 | 580 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
581 | 581 | // just return TRUE for registrations being made from admin |
582 | - if ( is_admin() ) { |
|
582 | + if (is_admin()) { |
|
583 | 583 | return TRUE; |
584 | 584 | } |
585 | - wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() )); |
|
585 | + wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url())); |
|
586 | 586 | exit(); |
587 | 587 | |
588 | 588 | } else { |
589 | - if ( ! EE_Error::has_error() ) { |
|
589 | + if ( ! EE_Error::has_error()) { |
|
590 | 590 | // nothing added to cart |
591 | - EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
591 | + EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | 595 | } else { |
596 | 596 | // no ticket quantities were selected |
597 | - EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
597 | + EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
598 | 598 | } |
599 | 599 | } |
600 | 600 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
601 | 601 | // at this point, just return if registration is being made from admin |
602 | - if ( is_admin() ) { |
|
602 | + if (is_admin()) { |
|
603 | 603 | return FALSE; |
604 | 604 | } |
605 | - if ( $valid['return_url'] ) { |
|
606 | - EE_Error::get_notices( FALSE, TRUE ); |
|
607 | - wp_safe_redirect( $valid['return_url'] ); |
|
605 | + if ($valid['return_url']) { |
|
606 | + EE_Error::get_notices(FALSE, TRUE); |
|
607 | + wp_safe_redirect($valid['return_url']); |
|
608 | 608 | exit(); |
609 | - } elseif ( isset( $event_to_add['id'] )) { |
|
610 | - EE_Error::get_notices( FALSE, TRUE ); |
|
611 | - wp_safe_redirect( get_permalink( $event_to_add['id'] )); |
|
609 | + } elseif (isset($event_to_add['id'])) { |
|
610 | + EE_Error::get_notices(FALSE, TRUE); |
|
611 | + wp_safe_redirect(get_permalink($event_to_add['id'])); |
|
612 | 612 | exit(); |
613 | 613 | } else { |
614 | 614 | echo EE_Error::get_notices(); |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | } else { |
618 | 618 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
619 | 619 | EE_Error::add_error( |
620 | - sprintf( __( 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
620 | + sprintf(__('An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
621 | 621 | __FILE__, __FUNCTION__, __LINE__ |
622 | 622 | ); |
623 | 623 | } |
@@ -635,18 +635,18 @@ discard block |
||
635 | 635 | * @return array or FALSE |
636 | 636 | */ |
637 | 637 | private static function _validate_post_data() { |
638 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
638 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
639 | 639 | |
640 | 640 | // start with an empty array() |
641 | 641 | $valid_data = array(); |
642 | 642 | // d( $_POST ); |
643 | 643 | //if event id is valid |
644 | - $id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' )); |
|
645 | - if ( $id ) { |
|
644 | + $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id')); |
|
645 | + if ($id) { |
|
646 | 646 | // grab valid id |
647 | 647 | $valid_data['id'] = $id; |
648 | 648 | // grab and sanitize return-url |
649 | - $valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id )); |
|
649 | + $valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id)); |
|
650 | 650 | // array of other form names |
651 | 651 | $inputs_to_clean = array( |
652 | 652 | 'event_id' => 'tkt-slctr-event-id', |
@@ -659,22 +659,22 @@ discard block |
||
659 | 659 | // let's track the total number of tickets ordered.' |
660 | 660 | $valid_data['total_tickets'] = 0; |
661 | 661 | // cycle through $inputs_to_clean array |
662 | - foreach ( $inputs_to_clean as $what => $input_to_clean ) { |
|
662 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
663 | 663 | // check for POST data |
664 | - if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) { |
|
664 | + if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) { |
|
665 | 665 | // grab value |
666 | - $input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id ); |
|
666 | + $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id); |
|
667 | 667 | switch ($what) { |
668 | 668 | |
669 | 669 | // integers |
670 | 670 | case 'event_id': |
671 | - $valid_data[$what] = absint( $input_value ); |
|
671 | + $valid_data[$what] = absint($input_value); |
|
672 | 672 | // get event via the event id we put in the form |
673 | - $valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] ); |
|
673 | + $valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']); |
|
674 | 674 | break; |
675 | 675 | case 'rows': |
676 | 676 | case 'max_atndz': |
677 | - $valid_data[$what] = absint( $input_value ); |
|
677 | + $valid_data[$what] = absint($input_value); |
|
678 | 678 | break; |
679 | 679 | |
680 | 680 | // arrays of integers |
@@ -682,27 +682,27 @@ discard block |
||
682 | 682 | // d( $input_value ); |
683 | 683 | $row_qty = $input_value; |
684 | 684 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
685 | - if( ! is_array( $row_qty )) { |
|
685 | + if ( ! is_array($row_qty)) { |
|
686 | 686 | // get number of rows |
687 | - $rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1; |
|
687 | + $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1; |
|
688 | 688 | // d( $rows ); |
689 | 689 | // explode ints by the dash |
690 | - $row_qty = explode( '-', $row_qty ); |
|
691 | - $row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1; |
|
692 | - $qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0; |
|
693 | - $row_qty = array( $row => $qty ); |
|
690 | + $row_qty = explode('-', $row_qty); |
|
691 | + $row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1; |
|
692 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
693 | + $row_qty = array($row => $qty); |
|
694 | 694 | // d( $row_qty ); |
695 | - for( $x = 1; $x <= $rows; $x++ ) { |
|
696 | - if ( ! isset( $row_qty[$x] )) { |
|
695 | + for ($x = 1; $x <= $rows; $x++) { |
|
696 | + if ( ! isset($row_qty[$x])) { |
|
697 | 697 | $row_qty[$x] = 0; |
698 | 698 | } |
699 | 699 | } |
700 | 700 | } |
701 | - ksort( $row_qty ); |
|
701 | + ksort($row_qty); |
|
702 | 702 | // d( $row_qty ); |
703 | 703 | // cycle thru values |
704 | - foreach ( $row_qty as $qty ) { |
|
705 | - $qty = absint( $qty ); |
|
704 | + foreach ($row_qty as $qty) { |
|
705 | + $qty = absint($qty); |
|
706 | 706 | // sanitize as integers |
707 | 707 | $valid_data[$what][] = $qty; |
708 | 708 | $valid_data['total_tickets'] += $qty; |
@@ -713,19 +713,19 @@ discard block |
||
713 | 713 | case 'ticket_id': |
714 | 714 | $value_array = array(); |
715 | 715 | // cycle thru values |
716 | - foreach ( $input_value as $key=>$value ) { |
|
716 | + foreach ($input_value as $key=>$value) { |
|
717 | 717 | // allow only numbers, letters, spaces, commas and dashes |
718 | - $value_array[ $key ] = wp_strip_all_tags( $value ); |
|
718 | + $value_array[$key] = wp_strip_all_tags($value); |
|
719 | 719 | // get ticket via the ticket id we put in the form |
720 | - $ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value ); |
|
721 | - $valid_data['ticket_obj'][ $key ] = $ticket_obj; |
|
720 | + $ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value); |
|
721 | + $valid_data['ticket_obj'][$key] = $ticket_obj; |
|
722 | 722 | } |
723 | - $valid_data[ $what ] = $value_array; |
|
723 | + $valid_data[$what] = $value_array; |
|
724 | 724 | break; |
725 | 725 | |
726 | 726 | case 'return_url' : |
727 | 727 | // grab and sanitize return-url |
728 | - $valid_data[$what] = esc_url_raw( $input_value ); |
|
728 | + $valid_data[$what] = esc_url_raw($input_value); |
|
729 | 729 | break; |
730 | 730 | |
731 | 731 | } // end switch $what |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | } // end foreach $inputs_to_clean |
734 | 734 | |
735 | 735 | } else { |
736 | - EE_Error::add_error( __('The event id provided was not valid.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
736 | + EE_Error::add_error(__('The event id provided was not valid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
737 | 737 | return FALSE; |
738 | 738 | } |
739 | 739 | |
@@ -751,28 +751,28 @@ discard block |
||
751 | 751 | * @param int $qty |
752 | 752 | * @return TRUE on success, FALSE on fail |
753 | 753 | */ |
754 | - private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) { |
|
755 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
754 | + private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) { |
|
755 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
756 | 756 | // get the number of spaces left for this datetime ticket |
757 | - $available_spaces = self::_ticket_datetime_availability( $ticket ); |
|
757 | + $available_spaces = self::_ticket_datetime_availability($ticket); |
|
758 | 758 | // compare available spaces against the number of tickets being purchased |
759 | - if ( $available_spaces >= $qty ) { |
|
759 | + if ($available_spaces >= $qty) { |
|
760 | 760 | // allow addons to prevent a ticket from being added to cart |
761 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces ) ) { |
|
761 | + if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces)) { |
|
762 | 762 | return false; |
763 | 763 | } |
764 | 764 | // add event to cart |
765 | - if( EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) { |
|
766 | - self::_recalculate_ticket_datetime_availability( $ticket, $qty ); |
|
765 | + if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) { |
|
766 | + self::_recalculate_ticket_datetime_availability($ticket, $qty); |
|
767 | 767 | return true; |
768 | 768 | } else { |
769 | 769 | return false; |
770 | 770 | } |
771 | 771 | } else { |
772 | 772 | // tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets |
773 | - $available_spaces = self::_ticket_datetime_availability( $ticket, true ); |
|
773 | + $available_spaces = self::_ticket_datetime_availability($ticket, true); |
|
774 | 774 | // greedy greedy greedy eh? |
775 | - if ( $available_spaces > 0 ) { |
|
775 | + if ($available_spaces > 0) { |
|
776 | 776 | // add error messaging - we're using the _n function that will generate the appropriate singular or plural message based on the number of $available_spaces |
777 | 777 | EE_Error::add_error( |
778 | 778 | sprintf( |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | __FILE__, __FUNCTION__, __LINE__ |
789 | 789 | ); |
790 | 790 | } else { |
791 | - EE_Error::add_error( __('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
791 | + EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
792 | 792 | } |
793 | 793 | return false; |
794 | 794 | } |
@@ -806,22 +806,22 @@ discard block |
||
806 | 806 | * @param bool $get_original_ticket_spaces |
807 | 807 | * @return int |
808 | 808 | */ |
809 | - private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) { |
|
809 | + private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) { |
|
810 | 810 | // if the $_available_spaces array has not been set up yet... |
811 | - if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
812 | - self::_set_initial_ticket_datetime_availability( $ticket ); |
|
811 | + if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
812 | + self::_set_initial_ticket_datetime_availability($ticket); |
|
813 | 813 | } |
814 | 814 | $available_spaces = $ticket->qty() - $ticket->sold(); |
815 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
815 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
816 | 816 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
817 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
817 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
818 | 818 | // if we want the original datetime availability BEFORE we started subtracting tickets ? |
819 | - if ( $get_original_ticket_spaces ) { |
|
819 | + if ($get_original_ticket_spaces) { |
|
820 | 820 | // then grab the available spaces from the "tickets" array and compare with the above to get the lowest number |
821 | - $available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] ); |
|
821 | + $available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]); |
|
822 | 822 | } else { |
823 | 823 | // we want the updated ticket availability as stored in the "datetimes" array |
824 | - $available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] ); |
|
824 | + $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]); |
|
825 | 825 | } |
826 | 826 | } |
827 | 827 | } |
@@ -837,23 +837,23 @@ discard block |
||
837 | 837 | * @param EE_Ticket $ticket |
838 | 838 | * @return int |
839 | 839 | */ |
840 | - private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) { |
|
840 | + private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) { |
|
841 | 841 | // first, get all of the datetimes that are available to this ticket |
842 | 842 | $datetimes = $ticket->get_many_related( |
843 | 843 | 'Datetime', |
844 | - array( array( 'DTT_EVT_end' => array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' )) |
|
844 | + array(array('DTT_EVT_end' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))), 'order_by' => array('DTT_EVT_start' => 'ASC')) |
|
845 | 845 | ); |
846 | - if ( ! empty( $datetimes )) { |
|
846 | + if ( ! empty($datetimes)) { |
|
847 | 847 | // now loop thru all of the datetimes |
848 | - foreach ( $datetimes as $datetime ) { |
|
849 | - if ( $datetime instanceof EE_Datetime ) { |
|
848 | + foreach ($datetimes as $datetime) { |
|
849 | + if ($datetime instanceof EE_Datetime) { |
|
850 | 850 | // the number of spaces available for the datetime without considering individual ticket quantities |
851 | 851 | $spaces_remaining = $datetime->spaces_remaining(); |
852 | 852 | // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key |
853 | - self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining ); |
|
853 | + self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining); |
|
854 | 854 | // if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number, |
855 | 855 | // else just take the datetime spaces remaining, and assign to the datetimes array |
856 | - self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining; |
|
856 | + self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining; |
|
857 | 857 | } |
858 | 858 | } |
859 | 859 | } |
@@ -869,12 +869,12 @@ discard block |
||
869 | 869 | * @param int $qty |
870 | 870 | * @return int |
871 | 871 | */ |
872 | - private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) { |
|
873 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
872 | + private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) { |
|
873 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
874 | 874 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
875 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
875 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
876 | 876 | // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to, |
877 | - self::$_available_spaces['datetimes'][ $DTD_ID ] = self::$_available_spaces['datetimes'][ $DTD_ID ] - $qty; |
|
877 | + self::$_available_spaces['datetimes'][$DTD_ID] = self::$_available_spaces['datetimes'][$DTD_ID] - $qty; |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | } |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | */ |
892 | 892 | public static function load_tckt_slctr_assets() { |
893 | 893 | // add some style |
894 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
895 | - wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'); |
|
894 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
895 | + wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'); |
|
896 | 896 | wp_enqueue_style('ticket_selector'); |
897 | 897 | // make it dance |
898 | 898 | // wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
@@ -906,9 +906,9 @@ discard block |
||
906 | 906 | |
907 | 907 | public static function load_tckt_slctr_assets_admin() { |
908 | 908 | //iframe button js on admin event editor page |
909 | - if ( EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit' ) { |
|
910 | - wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true ); |
|
911 | - wp_enqueue_script( 'ticket_selector_embed' ); |
|
909 | + if (EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit') { |
|
910 | + wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
911 | + wp_enqueue_script('ticket_selector_embed'); |
|
912 | 912 | } |
913 | 913 | } |
914 | 914 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |