@@ -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 10 minutes)', 'event_espresso' ) |
|
| 50 | + 'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 10 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,9 +70,9 @@ 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 ) { |
|
| 73 | + public static function initiate_scheduled_non_blocking_request($task) { |
|
| 74 | 74 | //create nonce (this ensures that only valid requests are accepted) |
| 75 | - $nonce = wp_create_nonce( 'EE_Messages_Scheduler_' . $task ); |
|
| 75 | + $nonce = wp_create_nonce('EE_Messages_Scheduler_'.$task); |
|
| 76 | 76 | $request_url = add_query_arg( |
| 77 | 77 | array( |
| 78 | 78 | 'ee' => 'msg_cron_trigger', |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | ); |
| 84 | 84 | $request_args = array( |
| 85 | 85 | 'timeout' => 300, |
| 86 | - 'blocking' => defined( 'DOING_CRON' ) && DOING_CRON ? true : false, |
|
| 86 | + 'blocking' => defined('DOING_CRON') && DOING_CRON ? true : false, |
|
| 87 | 87 | 'sslverify' => false, |
| 88 | 88 | 'http_request_redirection_count' => 10, |
| 89 | 89 | ); |
| 90 | - $response = wp_remote_get( $request_url, $request_args ); |
|
| 91 | - if ( is_wp_error( $response ) ) { |
|
| 92 | - trigger_error( $response->get_error_message() ); |
|
| 90 | + $response = wp_remote_get($request_url, $request_args); |
|
| 91 | + if (is_wp_error($response)) { |
|
| 92 | + trigger_error($response->get_error_message()); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event |
| 102 | 102 | */ |
| 103 | 103 | public static function batch_generation() { |
| 104 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( 'generate' ); |
|
| 104 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request('generate'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * Callback for scheduled AHEE__EE_Messages_Scheduler__sending |
| 112 | 112 | */ |
| 113 | 113 | public static function batch_sending() { |
| 114 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( 'send' ); |
|
| 114 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request('send'); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | } //end EE_Messages_Scheduler |
| 118 | 118 | \ No newline at end of file |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @param \EE_Message_Repository $message_repository |
| 73 | 73 | */ |
| 74 | - public function __construct( EE_Message_Repository $message_repository ) { |
|
| 75 | - $this->_batch_count = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 ); |
|
| 74 | + public function __construct(EE_Message_Repository $message_repository) { |
|
| 75 | + $this->_batch_count = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50); |
|
| 76 | 76 | $this->_rate_limit = $this->get_rate_limit(); |
| 77 | 77 | $this->_queue = $message_repository; |
| 78 | 78 | } |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | * use the messenger send method but typically is based on preview data. |
| 92 | 92 | * @return bool Whether the message was successfully added to the repository or not. |
| 93 | 93 | */ |
| 94 | - public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) { |
|
| 94 | + public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) { |
|
| 95 | 95 | $data['preview'] = $preview; |
| 96 | 96 | $data['test_send'] = $test_send; |
| 97 | - return $this->_queue->add( $message, $data ); |
|
| 97 | + return $this->_queue->add($message, $data); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | * @param bool $persist This flag indicates whether to attempt to delete the object from the db as well. |
| 107 | 107 | * @return bool |
| 108 | 108 | */ |
| 109 | - public function remove( EE_Message $message, $persist = false ) { |
|
| 110 | - if ( $persist && $this->_queue->current() !== $message ) { |
|
| 109 | + public function remove(EE_Message $message, $persist = false) { |
|
| 110 | + if ($persist && $this->_queue->current() !== $message) { |
|
| 111 | 111 | //get pointer on right message |
| 112 | - if ( $this->_queue->has( $message ) ) { |
|
| 112 | + if ($this->_queue->has($message)) { |
|
| 113 | 113 | $this->_queue->rewind(); |
| 114 | - while( $this->_queue->valid() ) { |
|
| 115 | - if ( $this->_queue->current() === $message ) { |
|
| 114 | + while ($this->_queue->valid()) { |
|
| 115 | + if ($this->_queue->current() === $message) { |
|
| 116 | 116 | break; |
| 117 | 117 | } |
| 118 | 118 | $this->_queue->next(); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | return false; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | - return $persist ? $this->_queue->delete() : $this->_queue->remove( $message ); |
|
| 124 | + return $persist ? $this->_queue->delete() : $this->_queue->remove($message); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
@@ -161,29 +161,29 @@ discard block |
||
| 161 | 161 | * @return bool true if successfully retrieved batch, false no batch ready. |
| 162 | 162 | */ |
| 163 | 163 | public function get_batch_to_generate() { |
| 164 | - if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) { |
|
| 164 | + if ($this->is_locked(EE_Messages_Queue::action_generating)) { |
|
| 165 | 165 | return false; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | //lock batch generation to prevent race conditions. |
| 169 | - $this->lock_queue( EE_Messages_Queue::action_generating ); |
|
| 169 | + $this->lock_queue(EE_Messages_Queue::action_generating); |
|
| 170 | 170 | |
| 171 | 171 | $query_args = array( |
| 172 | 172 | // key 0 = where conditions |
| 173 | - 0 => array( 'STS_ID' => EEM_Message::status_incomplete ), |
|
| 173 | + 0 => array('STS_ID' => EEM_Message::status_incomplete), |
|
| 174 | 174 | 'order_by' => $this->_get_priority_orderby(), |
| 175 | 175 | 'limit' => $this->_batch_count |
| 176 | 176 | ); |
| 177 | - $messages = EEM_Message::instance()->get_all( $query_args ); |
|
| 177 | + $messages = EEM_Message::instance()->get_all($query_args); |
|
| 178 | 178 | |
| 179 | - if ( ! $messages ) { |
|
| 179 | + if ( ! $messages) { |
|
| 180 | 180 | return false; //nothing to generate |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - foreach ( $messages as $message ) { |
|
| 184 | - if ( $message instanceof EE_Message ) { |
|
| 183 | + foreach ($messages as $message) { |
|
| 184 | + if ($message instanceof EE_Message) { |
|
| 185 | 185 | $data = $message->all_extra_meta_array(); |
| 186 | - $this->add( $message, $data ); |
|
| 186 | + $this->add($message, $data); |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | return true; |
@@ -206,34 +206,34 @@ discard block |
||
| 206 | 206 | * to assist with notifying user. |
| 207 | 207 | */ |
| 208 | 208 | public function get_to_send_batch_and_send() { |
| 209 | - if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) { |
|
| 209 | + if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) { |
|
| 210 | 210 | return false; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - $this->lock_queue( EE_Messages_Queue::action_sending ); |
|
| 213 | + $this->lock_queue(EE_Messages_Queue::action_sending); |
|
| 214 | 214 | |
| 215 | 215 | $batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit; |
| 216 | 216 | |
| 217 | 217 | $query_args = array( |
| 218 | 218 | // key 0 = where conditions |
| 219 | - 0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ), |
|
| 219 | + 0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())), |
|
| 220 | 220 | 'order_by' => $this->_get_priority_orderby(), |
| 221 | 221 | 'limit' => $batch |
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | - $messages_to_send = EEM_Message::instance()->get_all( $query_args ); |
|
| 224 | + $messages_to_send = EEM_Message::instance()->get_all($query_args); |
|
| 225 | 225 | |
| 226 | 226 | |
| 227 | 227 | //any to send? |
| 228 | - if ( ! $messages_to_send ) { |
|
| 229 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
| 228 | + if ( ! $messages_to_send) { |
|
| 229 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
| 230 | 230 | return false; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | //add to queue. |
| 234 | - foreach ( $messages_to_send as $message ) { |
|
| 235 | - if ( $message instanceof EE_Message ) { |
|
| 236 | - $this->add( $message ); |
|
| 234 | + foreach ($messages_to_send as $message) { |
|
| 235 | + if ($message instanceof EE_Message) { |
|
| 236 | + $this->add($message); |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $this->execute(); |
| 242 | 242 | |
| 243 | 243 | //release lock |
| 244 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
| 244 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
| 245 | 245 | return true; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @param string $type The type of queue being locked. |
| 255 | 255 | */ |
| 256 | - public function lock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
| 257 | - set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) ); |
|
| 256 | + public function lock_queue($type = EE_Messages_Queue::action_generating) { |
|
| 257 | + set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type)); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
@@ -265,8 +265,8 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @param string $type The type of queue being unlocked. |
| 267 | 267 | */ |
| 268 | - public function unlock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
| 269 | - delete_transient( $this->_get_lock_key( $type ) ); |
|
| 268 | + public function unlock_queue($type = EE_Messages_Queue::action_generating) { |
|
| 269 | + delete_transient($this->_get_lock_key($type)); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | |
@@ -277,8 +277,8 @@ discard block |
||
| 277 | 277 | * @param string $type The type of lock. |
| 278 | 278 | * @return string |
| 279 | 279 | */ |
| 280 | - protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) { |
|
| 281 | - return '_ee_lock_' . $type; |
|
| 280 | + protected function _get_lock_key($type = EE_Messages_Queue::action_generating) { |
|
| 281 | + return '_ee_lock_'.$type; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | * @param string $type The type of lock |
| 290 | 290 | * @return int time to expiry in seconds. |
| 291 | 291 | */ |
| 292 | - protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) { |
|
| 293 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type ); |
|
| 292 | + protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) { |
|
| 293 | + return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * @return int |
| 309 | 309 | */ |
| 310 | 310 | protected function _get_rate_limit_expiry() { |
| 311 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS ); |
|
| 311 | + return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * @return int |
| 320 | 320 | */ |
| 321 | 321 | protected function _default_rate_limit() { |
| 322 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 ); |
|
| 322 | + return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -345,8 +345,8 @@ discard block |
||
| 345 | 345 | * @param string $type The type of lock being checked for. |
| 346 | 346 | * @return bool |
| 347 | 347 | */ |
| 348 | - public function is_locked( $type = EE_Messages_Queue::action_generating ) { |
|
| 349 | - return (bool) get_transient( $this->_get_lock_key( $type ) ); |
|
| 348 | + public function is_locked($type = EE_Messages_Queue::action_generating) { |
|
| 349 | + return (bool) get_transient($this->_get_lock_key($type)); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | |
@@ -361,9 +361,9 @@ discard block |
||
| 361 | 361 | * @return int |
| 362 | 362 | */ |
| 363 | 363 | public function get_rate_limit() { |
| 364 | - if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) { |
|
| 364 | + if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) { |
|
| 365 | 365 | $rate_limit = $this->_default_rate_limit(); |
| 366 | - set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() ); |
|
| 366 | + set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key()); |
|
| 367 | 367 | } |
| 368 | 368 | return $rate_limit; |
| 369 | 369 | } |
@@ -375,12 +375,12 @@ discard block |
||
| 375 | 375 | * This updates existing rate limit with the new limit which is the old minus the batch. |
| 376 | 376 | * @param int $batch_completed This sets the new rate limit based on the given batch that was completed. |
| 377 | 377 | */ |
| 378 | - public function set_rate_limit( $batch_completed ) { |
|
| 378 | + public function set_rate_limit($batch_completed) { |
|
| 379 | 379 | //first get the most up to date rate limit (in case its expired and reset) |
| 380 | 380 | $rate_limit = $this->get_rate_limit(); |
| 381 | 381 | $new_limit = $rate_limit - $batch_completed; |
| 382 | 382 | //updating the transient option directly to avoid resetting the expiry. |
| 383 | - update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit ); |
|
| 383 | + update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | * @param string $task This indicates what type of request is going to be initiated. |
| 394 | 394 | * @param int $priority This indicates the priority that triggers initiating the request. |
| 395 | 395 | */ |
| 396 | - public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) { |
|
| 396 | + public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { |
|
| 397 | 397 | //determine what status is matched with the priority as part of the trigger conditions. |
| 398 | 398 | $status = $task == 'generate' |
| 399 | 399 | ? EEM_Message::status_incomplete |
@@ -401,8 +401,8 @@ discard block |
||
| 401 | 401 | // always make sure we save because either this will get executed immediately on a separate request |
| 402 | 402 | // or remains in the queue for the regularly scheduled queue batch. |
| 403 | 403 | $this->save(); |
| 404 | - if ( $this->_queue->count_by_priority_and_status( $priority, $status ) ) { |
|
| 405 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task ); |
|
| 404 | + if ($this->_queue->count_by_priority_and_status($priority, $status)) { |
|
| 405 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); |
|
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | |
@@ -427,50 +427,50 @@ discard block |
||
| 427 | 427 | * Also, if the messenger is an request type messenger (or a preview), |
| 428 | 428 | * its entirely possible that the messenger will exit before |
| 429 | 429 | */ |
| 430 | - public function execute( $save = true, $sending_messenger = null, $by_priority = false ) { |
|
| 430 | + public function execute($save = true, $sending_messenger = null, $by_priority = false) { |
|
| 431 | 431 | $messages_sent = 0; |
| 432 | 432 | $this->_did_hook = array(); |
| 433 | 433 | $this->_queue->rewind(); |
| 434 | - while ( $this->_queue->valid() ) { |
|
| 434 | + while ($this->_queue->valid()) { |
|
| 435 | 435 | $error_messages = array(); |
| 436 | 436 | /** @type EE_Message $message */ |
| 437 | 437 | $message = $this->_queue->current(); |
| 438 | 438 | //if the message in the queue has a sent status, then skip |
| 439 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_sent() ) ) { |
|
| 439 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_sent())) { |
|
| 440 | 440 | continue; |
| 441 | 441 | } |
| 442 | 442 | //if $by_priority is set and does not match then continue; |
| 443 | - if ( $by_priority && $by_priority != $message->priority() ) { |
|
| 443 | + if ($by_priority && $by_priority != $message->priority()) { |
|
| 444 | 444 | continue; |
| 445 | 445 | } |
| 446 | 446 | //error checking |
| 447 | - if ( ! $message->valid_messenger() ) { |
|
| 447 | + if ( ! $message->valid_messenger()) { |
|
| 448 | 448 | $error_messages[] = sprintf( |
| 449 | - __( 'The %s messenger is not active at time of sending.', 'event_espresso' ), |
|
| 449 | + __('The %s messenger is not active at time of sending.', 'event_espresso'), |
|
| 450 | 450 | $message->messenger() |
| 451 | 451 | ); |
| 452 | 452 | } |
| 453 | - if ( ! $message->valid_message_type() ) { |
|
| 453 | + if ( ! $message->valid_message_type()) { |
|
| 454 | 454 | $error_messages[] = sprintf( |
| 455 | - __( 'The %s message type is not active at the time of sending.', 'event_espresso' ), |
|
| 455 | + __('The %s message type is not active at the time of sending.', 'event_espresso'), |
|
| 456 | 456 | $message->message_type() |
| 457 | 457 | ); |
| 458 | 458 | } |
| 459 | 459 | // if there was supposed to be a sending messenger for this message, but it was invalid/inactive, |
| 460 | 460 | // then it will instead be an EE_Error object, so let's check for that |
| 461 | - if ( $sending_messenger instanceof EE_Error ) { |
|
| 461 | + if ($sending_messenger instanceof EE_Error) { |
|
| 462 | 462 | $error_messages[] = $sending_messenger->getMessage(); |
| 463 | 463 | } |
| 464 | 464 | // if there are no errors, then let's process the message |
| 465 | - if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) { |
|
| 465 | + if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) { |
|
| 466 | 466 | $messages_sent++; |
| 467 | 467 | } |
| 468 | - $this->_set_error_message( $message, $error_messages ); |
|
| 468 | + $this->_set_error_message($message, $error_messages); |
|
| 469 | 469 | //add modified time |
| 470 | - $message->set_modified( time() ); |
|
| 470 | + $message->set_modified(time()); |
|
| 471 | 471 | $this->_queue->next(); |
| 472 | 472 | } |
| 473 | - if ( $save ) { |
|
| 473 | + if ($save) { |
|
| 474 | 474 | $this->save(); |
| 475 | 475 | } |
| 476 | 476 | return $messages_sent; |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | * @param mixed $sending_messenger (optional) |
| 486 | 486 | * @return bool |
| 487 | 487 | */ |
| 488 | - protected function _process_message( EE_Message $message, $sending_messenger = null ) { |
|
| 488 | + protected function _process_message(EE_Message $message, $sending_messenger = null) { |
|
| 489 | 489 | // these *should* have been validated in the execute() method above |
| 490 | 490 | $messenger = $message->messenger_object(); |
| 491 | 491 | $message_type = $message->message_type_object(); |
@@ -495,20 +495,20 @@ discard block |
||
| 495 | 495 | && $messenger instanceof EE_messenger |
| 496 | 496 | && $sending_messenger->name != $messenger->name |
| 497 | 497 | ) { |
| 498 | - $messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
| 498 | + $messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
| 499 | 499 | $messenger = $sending_messenger; |
| 500 | 500 | } |
| 501 | 501 | // send using messenger, but double check objects |
| 502 | - if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) { |
|
| 502 | + if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) { |
|
| 503 | 503 | //set hook for message type (but only if not using another messenger to send). |
| 504 | - if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) { |
|
| 505 | - $message_type->do_messenger_hooks( $messenger ); |
|
| 506 | - $this->_did_hook[ $message_type->name ] = 1; |
|
| 504 | + if ( ! isset($this->_did_hook[$message_type->name])) { |
|
| 505 | + $message_type->do_messenger_hooks($messenger); |
|
| 506 | + $this->_did_hook[$message_type->name] = 1; |
|
| 507 | 507 | } |
| 508 | 508 | //if preview then use preview method |
| 509 | 509 | return $this->_queue->is_preview() |
| 510 | - ? $this->_do_preview( $message, $messenger, $message_type, $this->_queue->is_test_send() ) |
|
| 511 | - : $this->_do_send( $message, $messenger, $message_type ); |
|
| 510 | + ? $this->_do_preview($message, $messenger, $message_type, $this->_queue->is_test_send()) |
|
| 511 | + : $this->_do_send($message, $messenger, $message_type); |
|
| 512 | 512 | } |
| 513 | 513 | return false; |
| 514 | 514 | } |
@@ -526,12 +526,12 @@ discard block |
||
| 526 | 526 | * @param array $status Stati to check for in queue |
| 527 | 527 | * @return int Count of EE_Message's matching the given status. |
| 528 | 528 | */ |
| 529 | - public function count_STS_in_queue( $status ) { |
|
| 529 | + public function count_STS_in_queue($status) { |
|
| 530 | 530 | $count = 0; |
| 531 | - $status = is_array( $status ) ? $status : array( $status ); |
|
| 531 | + $status = is_array($status) ? $status : array($status); |
|
| 532 | 532 | $this->_queue->rewind(); |
| 533 | - foreach( $this->_queue as $message ) { |
|
| 534 | - if ( in_array( $message->STS_ID(), $status ) ) { |
|
| 533 | + foreach ($this->_queue as $message) { |
|
| 534 | + if (in_array($message->STS_ID(), $status)) { |
|
| 535 | 535 | $count++; |
| 536 | 536 | } |
| 537 | 537 | } |
@@ -548,15 +548,15 @@ discard block |
||
| 548 | 548 | * @param $test_send |
| 549 | 549 | * @return bool true means all went well, false means, not so much. |
| 550 | 550 | */ |
| 551 | - protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
|
| 552 | - if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) { |
|
| 553 | - if ( ! $test_send ) { |
|
| 554 | - $message->set_content( $preview ); |
|
| 551 | + protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) { |
|
| 552 | + if ($preview = $messenger->get_preview($message, $message_type, $test_send)) { |
|
| 553 | + if ( ! $test_send) { |
|
| 554 | + $message->set_content($preview); |
|
| 555 | 555 | } |
| 556 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
| 556 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
| 557 | 557 | return true; |
| 558 | 558 | } else { |
| 559 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
| 559 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
| 560 | 560 | return false; |
| 561 | 561 | } |
| 562 | 562 | } |
@@ -572,12 +572,12 @@ discard block |
||
| 572 | 572 | * @param EE_message_type $message_type |
| 573 | 573 | * @return bool true means all went well, false means, not so much. |
| 574 | 574 | */ |
| 575 | - protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) { |
|
| 576 | - if ( $messenger->send_message( $message, $message_type ) ) { |
|
| 577 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
| 575 | + protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) { |
|
| 576 | + if ($messenger->send_message($message, $message_type)) { |
|
| 577 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
| 578 | 578 | return true; |
| 579 | 579 | } else { |
| 580 | - $message->set_STS_ID( EEM_Message::status_retry ); |
|
| 580 | + $message->set_STS_ID(EEM_Message::status_retry); |
|
| 581 | 581 | return false; |
| 582 | 582 | } |
| 583 | 583 | } |
@@ -591,21 +591,21 @@ discard block |
||
| 591 | 591 | * @param EE_Message $message |
| 592 | 592 | * @param array $error_messages the response from the messenger. |
| 593 | 593 | */ |
| 594 | - protected function _set_error_message( EE_Message $message, $error_messages ) { |
|
| 594 | + protected function _set_error_message(EE_Message $message, $error_messages) { |
|
| 595 | 595 | $error_messages = (array) $error_messages; |
| 596 | - if ( $message->STS_ID() === EEM_Message::status_failed || $message->STS_ID() === EEM_Message::status_retry ) { |
|
| 596 | + if ($message->STS_ID() === EEM_Message::status_failed || $message->STS_ID() === EEM_Message::status_retry) { |
|
| 597 | 597 | $notices = EE_Error::has_notices(); |
| 598 | - $error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' ); |
|
| 599 | - if ( $notices === 1 ) { |
|
| 598 | + $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); |
|
| 599 | + if ($notices === 1) { |
|
| 600 | 600 | $notices = EE_Error::get_vanilla_notices(); |
| 601 | - $notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array(); |
|
| 602 | - $error_messages[] = implode( "\n", $notices['errors'] ); |
|
| 601 | + $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); |
|
| 602 | + $error_messages[] = implode("\n", $notices['errors']); |
|
| 603 | 603 | } |
| 604 | 604 | } |
| 605 | - if ( count( $error_messages ) > 0 ) { |
|
| 606 | - $msg = __( 'Message was not executed successfully.', 'event_espresso' ); |
|
| 607 | - $msg = $msg . "\n" . implode( "\n", $error_messages ); |
|
| 608 | - $message->set_error_message( $msg ); |
|
| 605 | + if (count($error_messages) > 0) { |
|
| 606 | + $msg = __('Message was not executed successfully.', 'event_espresso'); |
|
| 607 | + $msg = $msg."\n".implode("\n", $error_messages); |
|
| 608 | + $message->set_error_message($msg); |
|
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | 611 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @return EED_Module |
| 70 | 70 | */ |
| 71 | 71 | public static function instance() { |
| 72 | - return parent::get_instance( __CLASS__ ); |
|
| 72 | + return parent::get_instance(__CLASS__); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public static function set_hooks() { |
| 86 | 86 | //actions |
| 87 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
| 88 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 2 ); |
|
| 87 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
| 88 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 2); |
|
| 89 | 89 | //filters |
| 90 | - add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
| 91 | - add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
| 90 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 91 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 92 | 92 | //register routes |
| 93 | 93 | self::_register_routes(); |
| 94 | 94 | } |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public static function set_hooks_admin() { |
| 103 | 103 | //actions |
| 104 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
| 105 | - add_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array( 'EED_Messages', 'payment_reminder' ), 10 ); |
|
| 106 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 3 ); |
|
| 107 | - add_action( 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', 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', 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', 'run_cron' ); |
|
| 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', 'run_cron'); |
|
| 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,30 +235,30 @@ discard block |
||
| 235 | 235 | * This is triggered by the 'msg_cron_trigger' route. |
| 236 | 236 | * @param WP $WP |
| 237 | 237 | */ |
| 238 | - public function run_cron( $WP ) { |
|
| 238 | + public function run_cron($WP) { |
|
| 239 | 239 | self::_load_controller(); |
| 240 | 240 | //get required vars |
| 241 | - $cron_type = EE_Registry::instance()->REQ->get( 'type' ); |
|
| 242 | - $nonce = EE_Registry::instance()->REQ->get( '_nonce' ); |
|
| 243 | - header( 'HTTP/1.1 200 OK' ); |
|
| 241 | + $cron_type = EE_Registry::instance()->REQ->get('type'); |
|
| 242 | + $nonce = EE_Registry::instance()->REQ->get('_nonce'); |
|
| 243 | + header('HTTP/1.1 200 OK'); |
|
| 244 | 244 | |
| 245 | 245 | //now let's verify nonce, if not valid exit immediately |
| 246 | - if ( ! wp_verify_nonce( $nonce, 'EE_Messages_Scheduler_' . $cron_type ) ) { |
|
| 246 | + if ( ! wp_verify_nonce($nonce, 'EE_Messages_Scheduler_'.$cron_type)) { |
|
| 247 | 247 | /** |
| 248 | 248 | * trigger error so this gets in the error logs. This is important because it happens on a non-user request. |
| 249 | 249 | */ |
| 250 | - trigger_error( esc_attr__( 'Invalid Nonce', 'event_espresso' ) ); |
|
| 250 | + trigger_error(esc_attr__('Invalid Nonce', 'event_espresso')); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
| 254 | - if ( method_exists( self::$_MSG_PROCESSOR, $method ) ) { |
|
| 253 | + $method = 'batch_'.$cron_type.'_from_queue'; |
|
| 254 | + if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
| 255 | 255 | self::$_MSG_PROCESSOR->$method(); |
| 256 | 256 | } else { |
| 257 | 257 | //no matching task |
| 258 | 258 | /** |
| 259 | 259 | * trigger error so this gets in the error logs. This is important because it happens on a non user request. |
| 260 | 260 | */ |
| 261 | - trigger_error( esc_attr( sprintf( __( 'There is no task corresponding to this route %s', 'event_espresso' ), $cron_type ) ) ); |
|
| 261 | + trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'), $cron_type))); |
|
| 262 | 262 | } |
| 263 | 263 | exit(); |
| 264 | 264 | } |
@@ -276,9 +276,9 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return EE_Messages_Template_Pack |
| 278 | 278 | */ |
| 279 | - public static function get_template_pack( $template_pack_name ) { |
|
| 280 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 281 | - return EEH_MSG_Template::get_template_pack( $template_pack_name ); |
|
| 279 | + public static function get_template_pack($template_pack_name) { |
|
| 280 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 281 | + return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
@@ -292,14 +292,14 @@ discard block |
||
| 292 | 292 | * @return EE_Messages_Template_Pack[] |
| 293 | 293 | */ |
| 294 | 294 | public static function get_template_packs() { |
| 295 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 295 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 296 | 296 | |
| 297 | 297 | //for backward compat, let's make sure this returns in the same format as originally. |
| 298 | 298 | $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
| 299 | 299 | $template_pack_collection->rewind(); |
| 300 | 300 | $template_packs = array(); |
| 301 | - while ( $template_pack_collection->valid() ) { |
|
| 302 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
| 301 | + while ($template_pack_collection->valid()) { |
|
| 302 | + $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current(); |
|
| 303 | 303 | $template_pack_collection->next(); |
| 304 | 304 | } |
| 305 | 305 | return $template_packs; |
@@ -315,15 +315,15 @@ discard block |
||
| 315 | 315 | * @return void |
| 316 | 316 | */ |
| 317 | 317 | public static function set_autoloaders() { |
| 318 | - if ( empty( self::$_MSG_PATHS ) ) { |
|
| 318 | + if (empty(self::$_MSG_PATHS)) { |
|
| 319 | 319 | self::_set_messages_paths(); |
| 320 | - EE_Registry::instance()->load_helper( 'Autoloader' ); |
|
| 321 | - foreach ( self::$_MSG_PATHS as $path ) { |
|
| 322 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $path ); |
|
| 320 | + EE_Registry::instance()->load_helper('Autoloader'); |
|
| 321 | + foreach (self::$_MSG_PATHS as $path) { |
|
| 322 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
| 323 | 323 | } |
| 324 | 324 | // add aliases |
| 325 | - EEH_Autoloader::add_alias( 'EE_messages', 'EE_messages' ); |
|
| 326 | - EEH_Autoloader::add_alias( 'EE_messenger', 'EE_messenger' ); |
|
| 325 | + EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
| 326 | + EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | 'shortcodes', |
| 352 | 352 | ); |
| 353 | 353 | $paths = array(); |
| 354 | - foreach ( $dir_ref as $index => $dir ) { |
|
| 355 | - $paths[ $index ] = EE_LIBRARIES . $dir; |
|
| 354 | + foreach ($dir_ref as $index => $dir) { |
|
| 355 | + $paths[$index] = EE_LIBRARIES.$dir; |
|
| 356 | 356 | } |
| 357 | - self::$_MSG_PATHS = apply_filters( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths ); |
|
| 357 | + self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | |
@@ -365,12 +365,12 @@ discard block |
||
| 365 | 365 | * @return void |
| 366 | 366 | */ |
| 367 | 367 | protected static function _load_controller() { |
| 368 | - if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor ) { |
|
| 369 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
| 368 | + if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
| 369 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
| 370 | 370 | self::set_autoloaders(); |
| 371 | - self::$_EEMSG = EE_Registry::instance()->load_lib( 'messages' ); |
|
| 372 | - self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
| 373 | - self::$_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 371 | + self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
| 372 | + self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
| 373 | + self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | |
@@ -379,10 +379,10 @@ discard block |
||
| 379 | 379 | /** |
| 380 | 380 | * @param EE_Transaction $transaction |
| 381 | 381 | */ |
| 382 | - public static function payment_reminder( EE_Transaction $transaction ) { |
|
| 382 | + public static function payment_reminder(EE_Transaction $transaction) { |
|
| 383 | 383 | self::_load_controller(); |
| 384 | - $data = array( $transaction, null ); |
|
| 385 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'payment_reminder', $data ); |
|
| 384 | + $data = array($transaction, null); |
|
| 385 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | |
@@ -393,14 +393,14 @@ discard block |
||
| 393 | 393 | * @param EE_Payment object |
| 394 | 394 | * @return void |
| 395 | 395 | */ |
| 396 | - public static function payment( EE_Transaction $transaction, EE_Payment $payment ) { |
|
| 396 | + public static function payment(EE_Transaction $transaction, EE_Payment $payment) { |
|
| 397 | 397 | self::_load_controller(); |
| 398 | - $data = array( $transaction, $payment ); |
|
| 399 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 400 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
| 398 | + $data = array($transaction, $payment); |
|
| 399 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 400 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
| 401 | 401 | //if payment amount is less than 0 then switch to payment_refund message type. |
| 402 | 402 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
| 403 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
| 403 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | |
@@ -408,10 +408,10 @@ discard block |
||
| 408 | 408 | /** |
| 409 | 409 | * @param EE_Transaction $transaction |
| 410 | 410 | */ |
| 411 | - public static function cancelled_registration( EE_Transaction $transaction ) { |
|
| 411 | + public static function cancelled_registration(EE_Transaction $transaction) { |
|
| 412 | 412 | self::_load_controller(); |
| 413 | - $data = array( $transaction, null ); |
|
| 414 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'cancelled_registration', $data ); |
|
| 413 | + $data = array($transaction, null); |
|
| 414 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | |
@@ -424,14 +424,14 @@ discard block |
||
| 424 | 424 | * @param array $extra_details |
| 425 | 425 | * @return void |
| 426 | 426 | */ |
| 427 | - public static function maybe_registration( EE_Registration $registration, $extra_details = array() ) { |
|
| 427 | + public static function maybe_registration(EE_Registration $registration, $extra_details = array()) { |
|
| 428 | 428 | |
| 429 | - if ( ! self::_verify_registration_notification_send( $registration, $extra_details ) ) { |
|
| 429 | + if ( ! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
| 430 | 430 | //no messages please |
| 431 | 431 | return; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 434 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 435 | 435 | |
| 436 | 436 | //get all registrations so we make sure we send messages for the right status. |
| 437 | 437 | $all_registrations = $registration->transaction()->registrations(); |
@@ -442,22 +442,22 @@ discard block |
||
| 442 | 442 | $mtgs = array(); |
| 443 | 443 | |
| 444 | 444 | //loop through registrations and trigger messages once per status. |
| 445 | - foreach ( $all_registrations as $reg ) { |
|
| 445 | + foreach ($all_registrations as $reg) { |
|
| 446 | 446 | |
| 447 | 447 | //already triggered? |
| 448 | - if ( in_array( $reg->status_ID(), $statuses_sent ) ) { |
|
| 448 | + if (in_array($reg->status_ID(), $statuses_sent)) { |
|
| 449 | 449 | continue; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - $message_type = EEH_MSG_Template::convert_reg_status_to_message_type( $reg->status_ID() ); |
|
| 453 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( $message_type, array( $registration->transaction(), null, $reg->status_ID() ) ); |
|
| 452 | + $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
| 453 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers($message_type, array($registration->transaction(), null, $reg->status_ID())); |
|
| 454 | 454 | $statuses_sent[] = $reg->status_ID(); |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( 'registration_summary', array( $registration->transaction(), null ) ); |
|
| 457 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers('registration_summary', array($registration->transaction(), null)); |
|
| 458 | 458 | |
| 459 | 459 | //batch queue and initiate request |
| 460 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $mtgs ); |
|
| 460 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
| 461 | 461 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
| 462 | 462 | } |
| 463 | 463 | |
@@ -472,39 +472,39 @@ discard block |
||
| 472 | 472 | * |
| 473 | 473 | * @return bool true = send away, false = nope halt the presses. |
| 474 | 474 | */ |
| 475 | - protected static function _verify_registration_notification_send( EE_Registration $registration, $extra_details = array() ) { |
|
| 475 | + protected static function _verify_registration_notification_send(EE_Registration $registration, $extra_details = array()) { |
|
| 476 | 476 | //self::log( |
| 477 | 477 | // __CLASS__, __FUNCTION__, __LINE__, |
| 478 | 478 | // $registration->transaction(), |
| 479 | 479 | // array( '$extra_details' => $extra_details ) |
| 480 | 480 | //); |
| 481 | 481 | // currently only using this to send messages for the primary registrant |
| 482 | - if ( ! $registration->is_primary_registrant() ) { |
|
| 482 | + if ( ! $registration->is_primary_registrant()) { |
|
| 483 | 483 | return false; |
| 484 | 484 | } |
| 485 | 485 | // first we check if we're in admin and not doing front ajax |
| 486 | - if ( is_admin() && ! EE_FRONT_AJAX ) { |
|
| 486 | + if (is_admin() && ! EE_FRONT_AJAX) { |
|
| 487 | 487 | //make sure appropriate admin params are set for sending messages |
| 488 | - if ( empty( $_REQUEST['txn_reg_status_change']['send_notifications'] ) || ! absint( $_REQUEST['txn_reg_status_change']['send_notifications'] ) ) { |
|
| 488 | + if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) { |
|
| 489 | 489 | //no messages sent please. |
| 490 | 490 | return false; |
| 491 | 491 | } |
| 492 | 492 | } else { |
| 493 | 493 | // frontend request (either regular or via AJAX) |
| 494 | 494 | // TXN is NOT finalized ? |
| 495 | - if ( ! isset( $extra_details['finalized'] ) || $extra_details['finalized'] === false ) { |
|
| 495 | + if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
| 496 | 496 | return false; |
| 497 | 497 | } |
| 498 | 498 | // return visit but nothing changed ??? |
| 499 | 499 | if ( |
| 500 | - isset( $extra_details['revisit'], $extra_details['status_updates'] ) && |
|
| 500 | + isset($extra_details['revisit'], $extra_details['status_updates']) && |
|
| 501 | 501 | $extra_details['revisit'] && ! $extra_details['status_updates'] |
| 502 | 502 | ) { |
| 503 | 503 | return false; |
| 504 | 504 | } |
| 505 | 505 | // NOT sending messages && reg status is something other than "Not-Approved" |
| 506 | 506 | if ( |
| 507 | - ! apply_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', false ) && |
|
| 507 | + ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
| 508 | 508 | $registration->status_ID() !== EEM_Registration::status_id_not_approved |
| 509 | 509 | ) { |
| 510 | 510 | return false; |
@@ -526,10 +526,10 @@ discard block |
||
| 526 | 526 | * |
| 527 | 527 | * @return array |
| 528 | 528 | */ |
| 529 | - protected static function _get_reg_status_array( $reg_status = '' ) { |
|
| 530 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 531 | - return EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
| 532 | - ? EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
| 529 | + protected static function _get_reg_status_array($reg_status = '') { |
|
| 530 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 531 | + return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
| 532 | + ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
| 533 | 533 | : EEH_MSG_Template::reg_status_to_message_type_array(); |
| 534 | 534 | } |
| 535 | 535 | |
@@ -545,10 +545,10 @@ discard block |
||
| 545 | 545 | * |
| 546 | 546 | * @return string|bool The payment message type slug matching the status or false if no match. |
| 547 | 547 | */ |
| 548 | - protected static function _get_payment_message_type( $payment_status ) { |
|
| 549 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 550 | - return EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
| 551 | - ? EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
| 548 | + protected static function _get_payment_message_type($payment_status) { |
|
| 549 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 550 | + return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
| 551 | + ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
| 552 | 552 | : false; |
| 553 | 553 | } |
| 554 | 554 | |
@@ -562,27 +562,27 @@ discard block |
||
| 562 | 562 | * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
| 563 | 563 | * @return bool success/fail |
| 564 | 564 | */ |
| 565 | - public static function process_resend( $req_data ) { |
|
| 565 | + public static function process_resend($req_data) { |
|
| 566 | 566 | self::_load_controller(); |
| 567 | 567 | |
| 568 | 568 | //if $msgID in this request then skip to the new resend_message |
| 569 | - if ( EE_Registry::instance()->REQ->get( 'MSG_ID' ) ) { |
|
| 569 | + if (EE_Registry::instance()->REQ->get('MSG_ID')) { |
|
| 570 | 570 | return self::resend_message(); |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() ) { |
|
| 573 | + if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) { |
|
| 574 | 574 | return false; |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | try { |
| 578 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $messages_to_send ); |
|
| 578 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
| 579 | 579 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
| 580 | - } catch( EE_Error $e ) { |
|
| 581 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 580 | + } catch (EE_Error $e) { |
|
| 581 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 582 | 582 | return false; |
| 583 | 583 | } |
| 584 | 584 | EE_Error::add_success( |
| 585 | - __( 'Messages have been successfully queued for generation and sending.', 'event_espresso' ) |
|
| 585 | + __('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
| 586 | 586 | ); |
| 587 | 587 | return true; //everything got queued. |
| 588 | 588 | } |
@@ -595,17 +595,17 @@ discard block |
||
| 595 | 595 | public static function resend_message() { |
| 596 | 596 | self::_load_controller(); |
| 597 | 597 | |
| 598 | - $msgID = EE_Registry::instance()->REQ->get( 'MSG_ID' ); |
|
| 599 | - if ( ! $msgID ) { |
|
| 600 | - EE_Error::add_error( __( 'Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 598 | + $msgID = EE_Registry::instance()->REQ->get('MSG_ID'); |
|
| 599 | + if ( ! $msgID) { |
|
| 600 | + EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 601 | 601 | return false; |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( (array) $msgID ); |
|
| 604 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
| 605 | 605 | |
| 606 | 606 | //setup success message. |
| 607 | - $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
| 608 | - EE_Error::add_success( sprintf( |
|
| 607 | + $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
| 608 | + EE_Error::add_success(sprintf( |
|
| 609 | 609 | _n( |
| 610 | 610 | 'There was %d message queued for resending.', |
| 611 | 611 | 'There were %d messages queued for resending.', |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | 'event_espresso' |
| 614 | 614 | ), |
| 615 | 615 | $count_ready_for_resend |
| 616 | - ) ); |
|
| 616 | + )); |
|
| 617 | 617 | return true; |
| 618 | 618 | } |
| 619 | 619 | |
@@ -626,13 +626,13 @@ discard block |
||
| 626 | 626 | * @param EE_Payment $payment EE_payment object |
| 627 | 627 | * @return bool success/fail |
| 628 | 628 | */ |
| 629 | - public static function process_admin_payment( EE_Payment $payment ) { |
|
| 630 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 629 | + public static function process_admin_payment(EE_Payment $payment) { |
|
| 630 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 631 | 631 | //we need to get the transaction object |
| 632 | 632 | $transaction = $payment->transaction(); |
| 633 | - if ( $transaction instanceof EE_Transaction ) { |
|
| 634 | - $data = array( $transaction, $payment ); |
|
| 635 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
| 633 | + if ($transaction instanceof EE_Transaction) { |
|
| 634 | + $data = array($transaction, $payment); |
|
| 635 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
| 636 | 636 | |
| 637 | 637 | //if payment amount is less than 0 then switch to payment_refund message type. |
| 638 | 638 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
@@ -642,17 +642,17 @@ discard block |
||
| 642 | 642 | |
| 643 | 643 | self::_load_controller(); |
| 644 | 644 | |
| 645 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
| 645 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
| 646 | 646 | |
| 647 | 647 | //get count of queued for generation |
| 648 | - $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
| 648 | + $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
| 649 | 649 | |
| 650 | - if ( $count_to_generate > 0 ) { |
|
| 651 | - add_filter( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true' ); |
|
| 650 | + if ($count_to_generate > 0) { |
|
| 651 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
| 652 | 652 | return true; |
| 653 | 653 | } else { |
| 654 | - $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::instance()->stati_indicating_failed_sending() ); |
|
| 655 | - EE_Error::add_error( sprintf( |
|
| 654 | + $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending()); |
|
| 655 | + EE_Error::add_error(sprintf( |
|
| 656 | 656 | _n( |
| 657 | 657 | 'The payment notification generation failed.', |
| 658 | 658 | '%d payment notifications failed being sent.', |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | 'event_espresso' |
| 661 | 661 | ), |
| 662 | 662 | $count_failed |
| 663 | - ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 663 | + ), __FILE__, __FUNCTION__, __LINE__); |
|
| 664 | 664 | return false; |
| 665 | 665 | } |
| 666 | 666 | } else { |
@@ -683,11 +683,11 @@ discard block |
||
| 683 | 683 | * @param int $grp_id a specific message template group id. |
| 684 | 684 | * @return void |
| 685 | 685 | */ |
| 686 | - public static function send_newsletter_message( $contacts, $grp_id ) { |
|
| 686 | + public static function send_newsletter_message($contacts, $grp_id) { |
|
| 687 | 687 | //make sure mtp is id and set it in the EE_Request Handler later messages setup. |
| 688 | - EE_Registry::instance()->REQ->set( 'GRP_ID', (int) $grp_id ); |
|
| 688 | + EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id); |
|
| 689 | 689 | self::_load_controller(); |
| 690 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'newsletter', $contacts ); |
|
| 690 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $contacts); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | |
@@ -702,10 +702,10 @@ discard block |
||
| 702 | 702 | * @param string $message_type |
| 703 | 703 | * @return string |
| 704 | 704 | */ |
| 705 | - public static function registration_message_trigger_url( $registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice' ) { |
|
| 706 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 705 | + public static function registration_message_trigger_url($registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice') { |
|
| 706 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 707 | 707 | // whitelist $messenger |
| 708 | - switch ( $messenger ) { |
|
| 708 | + switch ($messenger) { |
|
| 709 | 709 | case 'pdf' : |
| 710 | 710 | $sending_messenger = 'pdf'; |
| 711 | 711 | $generating_messenger = 'html'; |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | break; |
| 718 | 718 | } |
| 719 | 719 | // whitelist $message_type |
| 720 | - switch ( $message_type ) { |
|
| 720 | + switch ($message_type) { |
|
| 721 | 721 | case 'receipt' : |
| 722 | 722 | $message_type = 'receipt'; |
| 723 | 723 | break; |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | break; |
| 728 | 728 | } |
| 729 | 729 | // verify that both the messenger AND the message type are active |
| 730 | - if ( EEH_MSG_Template::is_messenger_active( $sending_messenger ) && EEH_MSG_Template::is_mt_active( $message_type ) ) { |
|
| 730 | + if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) { |
|
| 731 | 731 | //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?) |
| 732 | 732 | $template_query_params = array( |
| 733 | 733 | 'MTP_is_active' => true, |
@@ -736,16 +736,16 @@ discard block |
||
| 736 | 736 | 'Event.EVT_ID' => $registration->event_ID() |
| 737 | 737 | ); |
| 738 | 738 | //get the message template group. |
| 739 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
| 739 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
| 740 | 740 | //if we don't have an EE_Message_Template_Group then return |
| 741 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
| 741 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
| 742 | 742 | // remove EVT_ID from query params so that global templates get picked up |
| 743 | - unset( $template_query_params['Event.EVT_ID'] ); |
|
| 743 | + unset($template_query_params['Event.EVT_ID']); |
|
| 744 | 744 | //get global template as the fallback |
| 745 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
| 745 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
| 746 | 746 | } |
| 747 | 747 | //if we don't have an EE_Message_Template_Group then return |
| 748 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
| 748 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
| 749 | 749 | return ''; |
| 750 | 750 | } |
| 751 | 751 | // generate the URL |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
| 775 | 775 | * @return string The body of the message. |
| 776 | 776 | */ |
| 777 | - public static function preview_message( $type, $context, $messenger, $send = false ) { |
|
| 777 | + public static function preview_message($type, $context, $messenger, $send = false) { |
|
| 778 | 778 | self::_load_controller(); |
| 779 | 779 | $mtg = new EE_Message_To_Generate( |
| 780 | 780 | $messenger, |
@@ -783,8 +783,8 @@ discard block |
||
| 783 | 783 | $context, |
| 784 | 784 | true |
| 785 | 785 | ); |
| 786 | - $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview( $mtg ); |
|
| 787 | - if ( $generated_preview_queue instanceof EE_Messages_Queue ) { |
|
| 786 | + $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg); |
|
| 787 | + if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
| 788 | 788 | return $generated_preview_queue->get_queue()->current()->content(); |
| 789 | 789 | } else { |
| 790 | 790 | return $generated_preview_queue; |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | * |
| 812 | 812 | * @return bool success or fail. |
| 813 | 813 | */ |
| 814 | - public static function send_message_with_messenger_only( $messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '' ) { |
|
| 814 | + public static function send_message_with_messenger_only($messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '') { |
|
| 815 | 815 | self::_load_controller(); |
| 816 | 816 | /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
| 817 | 817 | $message_to_generate = EE_Registry::instance()->load_lib( |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | $custom_subject, |
| 824 | 824 | ) |
| 825 | 825 | ); |
| 826 | - return self::$_MSG_PROCESSOR->queue_for_sending( $message_to_generate ); |
|
| 826 | + return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | |
@@ -836,22 +836,22 @@ discard block |
||
| 836 | 836 | * @param array $message_ids An array of message ids |
| 837 | 837 | * @return bool | EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated messages. |
| 838 | 838 | */ |
| 839 | - public static function generate_now( $message_ids ) { |
|
| 839 | + public static function generate_now($message_ids) { |
|
| 840 | 840 | self::_load_controller(); |
| 841 | 841 | $messages = EEM_Message::instance()->get_all( |
| 842 | 842 | array( |
| 843 | 843 | 0 => array( |
| 844 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
| 844 | + 'MSG_ID' => array('IN', $message_ids), |
|
| 845 | 845 | 'STS_ID' => EEM_Message::status_incomplete, |
| 846 | 846 | ) |
| 847 | 847 | ) |
| 848 | 848 | ); |
| 849 | 849 | |
| 850 | - $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue( $messages ); |
|
| 850 | + $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
| 851 | 851 | |
| 852 | - if ( ! $generated_queue instanceof EE_Messages_Queue ) { |
|
| 852 | + if ( ! $generated_queue instanceof EE_Messages_Queue) { |
|
| 853 | 853 | EE_Error::add_error( |
| 854 | - __( 'The messages were not generated. This is usually because there is already a batch being generated on a separate request. You can wait a minute or two and try again.', 'event_espresso' ), |
|
| 854 | + __('The messages were not generated. This is usually because there is already a batch being generated on a separate request. You can wait a minute or two and try again.', 'event_espresso'), |
|
| 855 | 855 | __FILE__, __FUNCTION__, __LINE__ |
| 856 | 856 | ); |
| 857 | 857 | } |
@@ -870,28 +870,28 @@ discard block |
||
| 870 | 870 | * |
| 871 | 871 | * @return bool | EE_Messages_Queue false if no messages sent. |
| 872 | 872 | */ |
| 873 | - public static function send_now( $message_ids ) { |
|
| 873 | + public static function send_now($message_ids) { |
|
| 874 | 874 | self::_load_controller(); |
| 875 | 875 | $messages = EEM_Message::instance()->get_all( |
| 876 | 876 | array( |
| 877 | 877 | 0 => array( |
| 878 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
| 879 | - 'STS_ID' => array( 'IN', array( EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry ) ) |
|
| 878 | + 'MSG_ID' => array('IN', $message_ids), |
|
| 879 | + 'STS_ID' => array('IN', array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry)) |
|
| 880 | 880 | ) |
| 881 | 881 | ) |
| 882 | 882 | ); |
| 883 | 883 | |
| 884 | - $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue( $messages ); |
|
| 884 | + $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
| 885 | 885 | |
| 886 | - if ( ! $sent_queue instanceof EE_Messages_Queue ) { |
|
| 886 | + if ( ! $sent_queue instanceof EE_Messages_Queue) { |
|
| 887 | 887 | EE_Error::add_error( |
| 888 | - __( 'The messages were not sent. This is usually because there is already a batch being sent on a separate request. You can wait a minute or two and try again.', 'event_espresso' ), |
|
| 888 | + __('The messages were not sent. This is usually because there is already a batch being sent on a separate request. You can wait a minute or two and try again.', 'event_espresso'), |
|
| 889 | 889 | __FILE__, __FUNCTION__, __LINE__ |
| 890 | 890 | ); |
| 891 | 891 | } else { |
| 892 | 892 | //can count how many sent by using the messages in the queue |
| 893 | - $sent_count = $sent_queue->count_STS_in_queue( EEM_Message::instance()->stati_indicating_sent() ); |
|
| 894 | - if ( $sent_count > 0 ) { |
|
| 893 | + $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
| 894 | + if ($sent_count > 0) { |
|
| 895 | 895 | EE_Error::add_success( |
| 896 | 896 | sprintf( |
| 897 | 897 | _n( |
@@ -906,8 +906,8 @@ discard block |
||
| 906 | 906 | } else { |
| 907 | 907 | EE_Error::overwrite_errors(); |
| 908 | 908 | EE_Error::add_error( |
| 909 | - __( '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. |
|
| 910 | - If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso' ), |
|
| 909 | + __('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. |
|
| 910 | + If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso'), |
|
| 911 | 911 | __FILE__, __FUNCTION__, __LINE__ |
| 912 | 912 | ); |
| 913 | 913 | } |
@@ -928,13 +928,13 @@ discard block |
||
| 928 | 928 | * |
| 929 | 929 | * @return bool true means messages were successfully queued for resending, false means none were queued for resending. |
| 930 | 930 | */ |
| 931 | - public static function queue_for_resending( $message_ids ) { |
|
| 931 | + public static function queue_for_resending($message_ids) { |
|
| 932 | 932 | self::_load_controller(); |
| 933 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( $message_ids ); |
|
| 933 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
| 934 | 934 | |
| 935 | 935 | //get queue and count |
| 936 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
| 937 | - if ( $queue_count > 0 ) { |
|
| 936 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
| 937 | + if ($queue_count > 0) { |
|
| 938 | 938 | EE_Error::add_success( |
| 939 | 939 | sprintf( |
| 940 | 940 | _n( |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | ); |
| 949 | 949 | } else { |
| 950 | 950 | EE_Error::add_error( |
| 951 | - __( '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' ), |
|
| 951 | + __('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'), |
|
| 952 | 952 | __FILE__, __FUNCTION__, __LINE__ |
| 953 | 953 | ); |
| 954 | 954 | } |
@@ -970,17 +970,17 @@ discard block |
||
| 970 | 970 | * @param array $info |
| 971 | 971 | * @param bool $display_request |
| 972 | 972 | */ |
| 973 | - protected static function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) { |
|
| 974 | - EE_Registry::instance()->load_helper( 'Debug_Tools' ); |
|
| 975 | - if ( WP_DEBUG && false ) { |
|
| 976 | - if ( $transaction instanceof EE_Transaction ) { |
|
| 973 | + protected static function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) { |
|
| 974 | + EE_Registry::instance()->load_helper('Debug_Tools'); |
|
| 975 | + if (WP_DEBUG && false) { |
|
| 976 | + if ($transaction instanceof EE_Transaction) { |
|
| 977 | 977 | // don't serialize objects |
| 978 | - $info = EEH_Debug_Tools::strip_objects( $info ); |
|
| 978 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
| 979 | 979 | $info['TXN_status'] = $transaction->status_ID(); |
| 980 | 980 | $info['TXN_reg_steps'] = $transaction->reg_steps(); |
| 981 | - if ( $transaction->ID() ) { |
|
| 982 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
| 983 | - EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index ); |
|
| 981 | + if ($transaction->ID()) { |
|
| 982 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
| 983 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
| 984 | 984 | } |
| 985 | 985 | } |
| 986 | 986 | } |