@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * process_registration_from_admin |
281 | 281 | * |
282 | 282 | * @access public |
283 | - * @return int |
|
283 | + * @return EE_Transaction |
|
284 | 284 | */ |
285 | 285 | public static function process_registration_from_admin() { |
286 | 286 | EED_Single_Page_Checkout::load_reg_steps(); |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * _get_transaction_and_cart_for_previous_visit |
609 | 609 | * |
610 | 610 | * @access private |
611 | - * @return mixed EE_Transaction|NULL |
|
611 | + * @return EE_Transaction|null EE_Transaction|NULL |
|
612 | 612 | */ |
613 | 613 | private function _get_transaction_and_cart_for_previous_visit() { |
614 | 614 | /** @var $TXN_model EEM_Transaction */ |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | * generates a new EE_Transaction object and adds it to the $_transaction property. |
678 | 678 | * |
679 | 679 | * @access private |
680 | - * @return mixed EE_Transaction|NULL |
|
680 | + * @return EE_Transaction|null EE_Transaction|NULL |
|
681 | 681 | */ |
682 | 682 | private function _initialize_transaction() { |
683 | 683 | try { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\InvalidEntityException; |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
4 | 4 | /** |
5 | 5 | * Single Page Checkout (SPCO) |
6 | 6 | * |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * @return EED_Single_Page_Checkout |
50 | 50 | */ |
51 | 51 | public static function instance() { |
52 | - add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' ); |
|
53 | - return parent::get_instance( __CLASS__ ); |
|
52 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
53 | + return parent::get_instance(__CLASS__); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -95,22 +95,22 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public static function set_hooks_admin() { |
97 | 97 | EED_Single_Page_Checkout::set_definitions(); |
98 | - if ( defined( 'DOING_AJAX' )) { |
|
98 | + if (defined('DOING_AJAX')) { |
|
99 | 99 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
100 | 100 | ob_start(); |
101 | 101 | EED_Single_Page_Checkout::load_request_handler(); |
102 | 102 | EED_Single_Page_Checkout::load_reg_steps(); |
103 | 103 | } else { |
104 | 104 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
105 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
105 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
106 | 106 | } |
107 | 107 | // set ajax hooks |
108 | - add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
109 | - add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
110 | - add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
111 | - add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
112 | - add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
113 | - add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
108 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
109 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
110 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
111 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
112 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
113 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param string $ajax_action |
122 | 122 | * @throws \EE_Error |
123 | 123 | */ |
124 | - public static function process_ajax_request( $ajax_action ) { |
|
125 | - EE_Registry::instance()->REQ->set( 'action', $ajax_action ); |
|
124 | + public static function process_ajax_request($ajax_action) { |
|
125 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
126 | 126 | EED_Single_Page_Checkout::instance()->_initialize(); |
127 | 127 | } |
128 | 128 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @throws \EE_Error |
135 | 135 | */ |
136 | 136 | public static function display_reg_step() { |
137 | - EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' ); |
|
137 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @throws \EE_Error |
146 | 146 | */ |
147 | 147 | public static function process_reg_step() { |
148 | - EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' ); |
|
148 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @throws \EE_Error |
157 | 157 | */ |
158 | 158 | public static function update_reg_step() { |
159 | - EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' ); |
|
159 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @throws \EE_Error |
170 | 170 | */ |
171 | 171 | public static function update_checkout() { |
172 | - EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' ); |
|
172 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public static function load_request_handler() { |
184 | 184 | // load core Request_Handler class |
185 | - if ( ! isset( EE_Registry::instance()->REQ )) { |
|
186 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
185 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
186 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | * @throws \EE_Error |
198 | 198 | */ |
199 | 199 | public static function set_definitions() { |
200 | - define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
201 | - define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS ); |
|
202 | - define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS ); |
|
203 | - define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS ); |
|
204 | - define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS ); |
|
205 | - define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS ); |
|
206 | - define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS ); |
|
207 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE ); |
|
200 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
201 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
202 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
203 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
204 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
205 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
206 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
207 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public static function load_reg_steps() { |
221 | 221 | static $reg_steps_loaded = FALSE; |
222 | - if ( $reg_steps_loaded ) { |
|
222 | + if ($reg_steps_loaded) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | // filter list of reg_steps |
@@ -228,24 +228,24 @@ discard block |
||
228 | 228 | EED_Single_Page_Checkout::get_reg_steps() |
229 | 229 | ); |
230 | 230 | // sort by key (order) |
231 | - ksort( $reg_steps_to_load ); |
|
231 | + ksort($reg_steps_to_load); |
|
232 | 232 | // loop through folders |
233 | - foreach ( $reg_steps_to_load as $order => $reg_step ) { |
|
233 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
234 | 234 | // we need a |
235 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
235 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
236 | 236 | // copy over to the reg_steps_array |
237 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
237 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
238 | 238 | // register custom key route for each reg step |
239 | 239 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
240 | - EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
|
240 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
241 | 241 | // add AJAX or other hooks |
242 | - if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
|
242 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
243 | 243 | // setup autoloaders if necessary |
244 | - if ( ! class_exists( $reg_step['class_name'] )) { |
|
245 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
|
244 | + if ( ! class_exists($reg_step['class_name'])) { |
|
245 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE); |
|
246 | 246 | } |
247 | - if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
|
248 | - call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
|
247 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
248 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
@@ -264,28 +264,28 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public static function get_reg_steps() { |
266 | 266 | $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
267 | - if ( empty( $reg_steps )) { |
|
267 | + if (empty($reg_steps)) { |
|
268 | 268 | $reg_steps = array( |
269 | 269 | 10 => array( |
270 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
270 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
271 | 271 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
272 | 272 | 'slug' => 'attendee_information', |
273 | 273 | 'has_hooks' => FALSE |
274 | 274 | ), |
275 | 275 | 20 => array( |
276 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
276 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
277 | 277 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
278 | 278 | 'slug' => 'registration_confirmation', |
279 | 279 | 'has_hooks' => FALSE |
280 | 280 | ), |
281 | 281 | 30 => array( |
282 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
282 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
283 | 283 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
284 | 284 | 'slug' => 'payment_options', |
285 | 285 | 'has_hooks' => TRUE |
286 | 286 | ), |
287 | 287 | 999 => array( |
288 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
288 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
289 | 289 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
290 | 290 | 'slug' => 'finalize_registration', |
291 | 291 | 'has_hooks' => FALSE |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | */ |
307 | 307 | public static function registration_checkout_for_admin() { |
308 | 308 | EED_Single_Page_Checkout::load_reg_steps(); |
309 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
310 | - EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' ); |
|
311 | - EE_Registry::instance()->REQ->set( 'process_form_submission', false ); |
|
309 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
310 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
311 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
312 | 312 | EED_Single_Page_Checkout::instance()->_initialize(); |
313 | 313 | EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
314 | 314 | return EE_Registry::instance()->REQ->get_output(); |
@@ -325,15 +325,15 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public static function process_registration_from_admin() { |
327 | 327 | EED_Single_Page_Checkout::load_reg_steps(); |
328 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
329 | - EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' ); |
|
330 | - EE_Registry::instance()->REQ->set( 'process_form_submission', true ); |
|
328 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
329 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
330 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
331 | 331 | EED_Single_Page_Checkout::instance()->_initialize(); |
332 | - if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) { |
|
333 | - $final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps ); |
|
334 | - if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
335 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated( $final_reg_step ); |
|
336 | - if ( $final_reg_step->process_reg_step() ) { |
|
332 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
333 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
334 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
335 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
336 | + if ($final_reg_step->process_reg_step()) { |
|
337 | 337 | $final_reg_step->set_completed(); |
338 | 338 | EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
339 | 339 | return EED_Single_Page_Checkout::instance()->checkout->transaction; |
@@ -353,11 +353,11 @@ discard block |
||
353 | 353 | * @return void |
354 | 354 | * @throws \EE_Error |
355 | 355 | */ |
356 | - public function run( $WP_Query ) { |
|
356 | + public function run($WP_Query) { |
|
357 | 357 | if ( |
358 | 358 | $WP_Query instanceof WP_Query |
359 | 359 | && $WP_Query->is_main_query() |
360 | - && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true ) |
|
360 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
361 | 361 | ) { |
362 | 362 | $this->_initialize(); |
363 | 363 | } |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | * @return void |
374 | 374 | * @throws \EE_Error |
375 | 375 | */ |
376 | - public static function init( $WP_Query ) { |
|
377 | - EED_Single_Page_Checkout::instance()->run( $WP_Query ); |
|
376 | + public static function init($WP_Query) { |
|
377 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | |
@@ -388,34 +388,34 @@ discard block |
||
388 | 388 | */ |
389 | 389 | private function _initialize() { |
390 | 390 | // ensure SPCO doesn't run twice |
391 | - if ( EED_Single_Page_Checkout::$_initialized ) { |
|
391 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
392 | 392 | return; |
393 | 393 | } |
394 | 394 | try { |
395 | 395 | // setup the EE_Checkout object |
396 | 396 | $this->checkout = $this->_initialize_checkout(); |
397 | 397 | // filter checkout |
398 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
|
398 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
399 | 399 | // get the $_GET |
400 | 400 | $this->_get_request_vars(); |
401 | 401 | // filter continue_reg |
402 | - $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
|
402 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); |
|
403 | 403 | // load the reg steps array |
404 | - if ( ! $this->_load_and_instantiate_reg_steps() ) { |
|
404 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
405 | 405 | EED_Single_Page_Checkout::$_initialized = true; |
406 | 406 | return; |
407 | 407 | } |
408 | 408 | // set the current step |
409 | - $this->checkout->set_current_step( $this->checkout->step ); |
|
409 | + $this->checkout->set_current_step($this->checkout->step); |
|
410 | 410 | // and the next step |
411 | 411 | $this->checkout->set_next_step(); |
412 | 412 | // was there already a valid transaction in the checkout from the session ? |
413 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
413 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
414 | 414 | // get transaction from db or session |
415 | 415 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
416 | 416 | ? $this->_get_transaction_and_cart_for_previous_visit() |
417 | 417 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
418 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
418 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
419 | 419 | // add some style and make it dance |
420 | 420 | $this->checkout->transaction = EE_Transaction::new_instance(); |
421 | 421 | $this->add_styles_and_scripts(); |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | return; |
424 | 424 | } |
425 | 425 | // and the registrations for the transaction |
426 | - $this->_get_registrations( $this->checkout->transaction ); |
|
426 | + $this->_get_registrations($this->checkout->transaction); |
|
427 | 427 | } |
428 | 428 | // verify that everything has been setup correctly |
429 | - if ( ! $this->_final_verifications() ) { |
|
429 | + if ( ! $this->_final_verifications()) { |
|
430 | 430 | EED_Single_Page_Checkout::$_initialized = true; |
431 | 431 | return; |
432 | 432 | } |
@@ -451,9 +451,9 @@ discard block |
||
451 | 451 | // set no cache headers and constants |
452 | 452 | EE_System::do_not_cache(); |
453 | 453 | // add anchor |
454 | - add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
|
455 | - } catch ( Exception $e ) { |
|
456 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
454 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
455 | + } catch (Exception $e) { |
|
456 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
@@ -471,20 +471,20 @@ discard block |
||
471 | 471 | // look in session for existing checkout |
472 | 472 | $checkout = EE_Registry::instance()->SSN->checkout(); |
473 | 473 | // verify |
474 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
474 | + if ( ! $checkout instanceof EE_Checkout) { |
|
475 | 475 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
476 | - $checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE ); |
|
476 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE); |
|
477 | 477 | } else { |
478 | - if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true ) { |
|
478 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
479 | 479 | $this->unlock_transaction(); |
480 | - wp_safe_redirect( $checkout->redirect_url ); |
|
480 | + wp_safe_redirect($checkout->redirect_url); |
|
481 | 481 | exit(); |
482 | 482 | } |
483 | 483 | } |
484 | - $checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout ); |
|
484 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
485 | 485 | // verify again |
486 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
487 | - throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) ); |
|
486 | + if ( ! $checkout instanceof EE_Checkout) { |
|
487 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
488 | 488 | } |
489 | 489 | // reset anything that needs a clean slate for each request |
490 | 490 | $checkout->reset_for_current_request(); |
@@ -504,24 +504,24 @@ discard block |
||
504 | 504 | // load classes |
505 | 505 | EED_Single_Page_Checkout::load_request_handler(); |
506 | 506 | //make sure this request is marked as belonging to EE |
507 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
507 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
508 | 508 | // which step is being requested ? |
509 | - $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
|
509 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
510 | 510 | // which step is being edited ? |
511 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
|
511 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
512 | 512 | // and what we're doing on the current step |
513 | - $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
|
513 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
514 | 514 | // returning to edit ? |
515 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
|
515 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
516 | 516 | // or some other kind of revisit ? |
517 | - $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
|
517 | + $this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE); |
|
518 | 518 | // and whether or not to generate a reg form for this request |
519 | - $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
|
519 | + $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE FALSE |
|
520 | 520 | // and whether or not to process a reg form submission for this request |
521 | - $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
|
521 | + $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE FALSE |
|
522 | 522 | $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' |
523 | 523 | ? $this->checkout->process_form_submission |
524 | - : FALSE; // TRUE FALSE |
|
524 | + : FALSE; // TRUE FALSE |
|
525 | 525 | // $this->_display_request_vars(); |
526 | 526 | } |
527 | 527 | |
@@ -534,17 +534,17 @@ discard block |
||
534 | 534 | * @return void |
535 | 535 | */ |
536 | 536 | protected function _display_request_vars() { |
537 | - if ( ! WP_DEBUG ) { |
|
537 | + if ( ! WP_DEBUG) { |
|
538 | 538 | return; |
539 | 539 | } |
540 | - EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
541 | - EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ ); |
|
542 | - EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ ); |
|
543 | - EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ ); |
|
544 | - EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ ); |
|
545 | - EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ ); |
|
546 | - EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ ); |
|
547 | - EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ ); |
|
540 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
541 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
542 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
543 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
544 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
545 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
546 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
547 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | * @return array |
559 | 559 | */ |
560 | 560 | private function _get_first_step() { |
561 | - $first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array ); |
|
562 | - return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information'; |
|
561 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
562 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | |
@@ -575,27 +575,27 @@ discard block |
||
575 | 575 | private function _load_and_instantiate_reg_steps() { |
576 | 576 | // have reg_steps already been instantiated ? |
577 | 577 | if ( |
578 | - empty( $this->checkout->reg_steps ) || |
|
579 | - apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
|
578 | + empty($this->checkout->reg_steps) || |
|
579 | + apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
580 | 580 | ) { |
581 | 581 | // if not, then loop through raw reg steps array |
582 | - foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
|
583 | - if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
|
582 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
583 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
584 | 584 | return false; |
585 | 585 | } |
586 | 586 | } |
587 | 587 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
588 | 588 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
589 | 589 | // skip the registration_confirmation page ? |
590 | - if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
|
590 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
591 | 591 | // just remove it from the reg steps array |
592 | - $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
|
592 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
593 | 593 | } else if ( |
594 | - isset( $this->checkout->reg_steps['registration_confirmation'] ) |
|
594 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
595 | 595 | && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
596 | 596 | ) { |
597 | 597 | // set the order to something big like 100 |
598 | - $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
|
598 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
599 | 599 | } |
600 | 600 | // filter the array for good luck |
601 | 601 | $this->checkout->reg_steps = apply_filters( |
@@ -605,13 +605,13 @@ discard block |
||
605 | 605 | // finally re-sort based on the reg step class order properties |
606 | 606 | $this->checkout->sort_reg_steps(); |
607 | 607 | } else { |
608 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
608 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
609 | 609 | // set all current step stati to FALSE |
610 | - $reg_step->set_is_current_step( FALSE ); |
|
610 | + $reg_step->set_is_current_step(FALSE); |
|
611 | 611 | } |
612 | 612 | } |
613 | - if ( empty( $this->checkout->reg_steps )) { |
|
614 | - EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
613 | + if (empty($this->checkout->reg_steps)) { |
|
614 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
615 | 615 | return false; |
616 | 616 | } |
617 | 617 | // make reg step details available to JS |
@@ -629,10 +629,10 @@ discard block |
||
629 | 629 | * @param int $order |
630 | 630 | * @return bool |
631 | 631 | */ |
632 | - private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
|
632 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) { |
|
633 | 633 | |
634 | 634 | // we need a file_path, class_name, and slug to add a reg step |
635 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
635 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
636 | 636 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
637 | 637 | if ( |
638 | 638 | $this->checkout->reg_url_link |
@@ -650,26 +650,26 @@ discard block |
||
650 | 650 | FALSE |
651 | 651 | ); |
652 | 652 | // did we gets the goods ? |
653 | - if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
653 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
654 | 654 | // set reg step order based on config |
655 | - $reg_step_obj->set_order( $order ); |
|
655 | + $reg_step_obj->set_order($order); |
|
656 | 656 | // add instantiated reg step object to the master reg steps array |
657 | - $this->checkout->add_reg_step( $reg_step_obj ); |
|
657 | + $this->checkout->add_reg_step($reg_step_obj); |
|
658 | 658 | } else { |
659 | 659 | EE_Error::add_error( |
660 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
660 | + __('The current step could not be set.', 'event_espresso'), |
|
661 | 661 | __FILE__, __FUNCTION__, __LINE__ |
662 | 662 | ); |
663 | 663 | return false; |
664 | 664 | } |
665 | 665 | } else { |
666 | - if ( WP_DEBUG ) { |
|
666 | + if (WP_DEBUG) { |
|
667 | 667 | EE_Error::add_error( |
668 | 668 | sprintf( |
669 | - __( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ), |
|
670 | - isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
|
671 | - isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
|
672 | - isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
|
669 | + __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'), |
|
670 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
671 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
672 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
673 | 673 | '<ul>', |
674 | 674 | '<li>', |
675 | 675 | '</li>', |
@@ -693,16 +693,16 @@ discard block |
||
693 | 693 | */ |
694 | 694 | private function _get_transaction_and_cart_for_previous_visit() { |
695 | 695 | /** @var $TXN_model EEM_Transaction */ |
696 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
696 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
697 | 697 | // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
698 | - $transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link ); |
|
698 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
699 | 699 | // verify transaction |
700 | - if ( $transaction instanceof EE_Transaction ) { |
|
700 | + if ($transaction instanceof EE_Transaction) { |
|
701 | 701 | // and get the cart that was used for that transaction |
702 | - $this->checkout->cart = $this->_get_cart_for_transaction( $transaction ); |
|
702 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
703 | 703 | return $transaction; |
704 | 704 | } else { |
705 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
705 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
706 | 706 | return NULL; |
707 | 707 | } |
708 | 708 | } |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | * @param EE_Transaction $transaction |
717 | 717 | * @return EE_Cart |
718 | 718 | */ |
719 | - private function _get_cart_for_transaction( $transaction ) { |
|
720 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
719 | + private function _get_cart_for_transaction($transaction) { |
|
720 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | |
@@ -729,8 +729,8 @@ discard block |
||
729 | 729 | * @param EE_Transaction $transaction |
730 | 730 | * @return EE_Cart |
731 | 731 | */ |
732 | - public function get_cart_for_transaction( EE_Transaction $transaction ) { |
|
733 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
732 | + public function get_cart_for_transaction(EE_Transaction $transaction) { |
|
733 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | |
@@ -746,17 +746,17 @@ discard block |
||
746 | 746 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
747 | 747 | // if there's no transaction, then this is the FIRST visit to SPCO |
748 | 748 | // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
749 | - $this->checkout->cart = $this->_get_cart_for_transaction( NULL ); |
|
749 | + $this->checkout->cart = $this->_get_cart_for_transaction(NULL); |
|
750 | 750 | // and then create a new transaction |
751 | 751 | $transaction = $this->_initialize_transaction(); |
752 | 752 | // verify transaction |
753 | - if ( $transaction instanceof EE_Transaction ) { |
|
753 | + if ($transaction instanceof EE_Transaction) { |
|
754 | 754 | // save it so that we have an ID for other objects to use |
755 | 755 | $transaction->save(); |
756 | 756 | // and save TXN data to the cart |
757 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
757 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
758 | 758 | } else { |
759 | - EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
759 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
760 | 760 | } |
761 | 761 | return $transaction; |
762 | 762 | } |
@@ -776,15 +776,15 @@ discard block |
||
776 | 776 | // grab the cart grand total |
777 | 777 | $cart_total = $this->checkout->cart->get_cart_grand_total(); |
778 | 778 | // create new TXN |
779 | - return EE_Transaction::new_instance( array( |
|
779 | + return EE_Transaction::new_instance(array( |
|
780 | 780 | 'TXN_timestamp' => time(), |
781 | 781 | 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
782 | 782 | 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
783 | 783 | 'TXN_paid' => 0, |
784 | 784 | 'STS_ID' => EEM_Transaction::failed_status_code, |
785 | 785 | )); |
786 | - } catch( Exception $e ) { |
|
787 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
786 | + } catch (Exception $e) { |
|
787 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
788 | 788 | } |
789 | 789 | return NULL; |
790 | 790 | } |
@@ -799,38 +799,38 @@ discard block |
||
799 | 799 | * @return EE_Cart |
800 | 800 | * @throws \EE_Error |
801 | 801 | */ |
802 | - private function _get_registrations( EE_Transaction $transaction ) { |
|
802 | + private function _get_registrations(EE_Transaction $transaction) { |
|
803 | 803 | // first step: grab the registrants { : o |
804 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true ); |
|
804 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
805 | 805 | // verify registrations have been set |
806 | - if ( empty( $registrations )) { |
|
806 | + if (empty($registrations)) { |
|
807 | 807 | // if no cached registrations, then check the db |
808 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false ); |
|
808 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
809 | 809 | // still nothing ? well as long as this isn't a revisit |
810 | - if ( empty( $registrations ) && ! $this->checkout->revisit ) { |
|
810 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
811 | 811 | // generate new registrations from scratch |
812 | - $registrations = $this->_initialize_registrations( $transaction ); |
|
812 | + $registrations = $this->_initialize_registrations($transaction); |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | // sort by their original registration order |
816 | - usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' )); |
|
816 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
817 | 817 | // then loop thru the array |
818 | - foreach ( $registrations as $registration ) { |
|
818 | + foreach ($registrations as $registration) { |
|
819 | 819 | // verify each registration |
820 | - if ( $registration instanceof EE_Registration ) { |
|
820 | + if ($registration instanceof EE_Registration) { |
|
821 | 821 | // we display all attendee info for the primary registrant |
822 | - if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
|
822 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
823 | 823 | && $registration->is_primary_registrant() |
824 | 824 | ) { |
825 | 825 | $this->checkout->primary_revisit = true; |
826 | 826 | break; |
827 | - } else if ( $this->checkout->revisit |
|
827 | + } else if ($this->checkout->revisit |
|
828 | 828 | && $this->checkout->reg_url_link !== $registration->reg_url_link() |
829 | 829 | ) { |
830 | 830 | // but hide info if it doesn't belong to you |
831 | - $transaction->clear_cache( 'Registration', $registration->ID() ); |
|
831 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
832 | 832 | } |
833 | - $this->checkout->set_reg_status_updated( $registration->ID(), false ); |
|
833 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
834 | 834 | } |
835 | 835 | } |
836 | 836 | } |
@@ -845,17 +845,17 @@ discard block |
||
845 | 845 | * @return array |
846 | 846 | * @throws \EE_Error |
847 | 847 | */ |
848 | - private function _initialize_registrations( EE_Transaction $transaction ) { |
|
848 | + private function _initialize_registrations(EE_Transaction $transaction) { |
|
849 | 849 | $att_nmbr = 0; |
850 | 850 | $registrations = array(); |
851 | - if ( $transaction instanceof EE_Transaction ) { |
|
851 | + if ($transaction instanceof EE_Transaction) { |
|
852 | 852 | /** @type EE_Registration_Processor $registration_processor */ |
853 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
853 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
854 | 854 | $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
855 | 855 | // now let's add the cart items to the $transaction |
856 | - foreach ( $this->checkout->cart->get_tickets() as $line_item ) { |
|
856 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
857 | 857 | //do the following for each ticket of this type they selected |
858 | - for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
|
858 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
859 | 859 | $att_nmbr++; |
860 | 860 | $CreateRegistrationCommand = EE_Registry::instance() |
861 | 861 | ->create( |
@@ -867,17 +867,17 @@ discard block |
||
867 | 867 | $this->checkout->total_ticket_count |
868 | 868 | ) |
869 | 869 | ); |
870 | - $registration = EE_Registry::instance()->BUS->execute( $CreateRegistrationCommand ); |
|
871 | - if ( ! $registration instanceof EE_Registration ) { |
|
870 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
871 | + if ( ! $registration instanceof EE_Registration) { |
|
872 | 872 | throw new InvalidEntityException( |
873 | - is_object( $registration ) ? get_class( $registration ) : gettype( $registration ), |
|
873 | + is_object($registration) ? get_class($registration) : gettype($registration), |
|
874 | 874 | 'EE_Registration' |
875 | 875 | ); |
876 | 876 | } |
877 | - $registrations[ $registration->ID() ] = $registration; |
|
877 | + $registrations[$registration->ID()] = $registration; |
|
878 | 878 | } |
879 | 879 | } |
880 | - $registration_processor->fix_reg_final_price_rounding_issue( $transaction ); |
|
880 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
881 | 881 | } |
882 | 882 | return $registrations; |
883 | 883 | } |
@@ -892,12 +892,12 @@ discard block |
||
892 | 892 | * @param EE_Registration $reg_B |
893 | 893 | * @return array() |
894 | 894 | */ |
895 | - public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
|
895 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) { |
|
896 | 896 | // this shouldn't ever happen within the same TXN, but oh well |
897 | - if ( $reg_A->count() === $reg_B->count() ) { |
|
897 | + if ($reg_A->count() === $reg_B->count()) { |
|
898 | 898 | return 0; |
899 | 899 | } |
900 | - return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1; |
|
900 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | |
@@ -912,21 +912,21 @@ discard block |
||
912 | 912 | */ |
913 | 913 | private function _final_verifications() { |
914 | 914 | // filter checkout |
915 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout ); |
|
915 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
916 | 916 | //verify that current step is still set correctly |
917 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) { |
|
918 | - EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
917 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
918 | + EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
919 | 919 | return false; |
920 | 920 | } |
921 | 921 | // if returning to SPCO, then verify that primary registrant is set |
922 | - if ( ! empty( $this->checkout->reg_url_link )) { |
|
922 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
923 | 923 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
924 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
925 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
924 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
925 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
926 | 926 | return false; |
927 | 927 | } |
928 | 928 | $valid_registrant = null; |
929 | - foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) { |
|
929 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
930 | 930 | if ( |
931 | 931 | $registration instanceof EE_Registration |
932 | 932 | && $registration->reg_url_link() === $this->checkout->reg_url_link |
@@ -934,9 +934,9 @@ discard block |
||
934 | 934 | $valid_registrant = $registration; |
935 | 935 | } |
936 | 936 | } |
937 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
937 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
938 | 938 | // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
939 | - if ( EED_Single_Page_Checkout::$_checkout_verified ) { |
|
939 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
940 | 940 | // clear the session, mark the checkout as unverified, and try again |
941 | 941 | EE_Registry::instance()->SSN->clear_session(); |
942 | 942 | EED_Single_Page_Checkout::$_initialized = false; |
@@ -945,13 +945,13 @@ discard block |
||
945 | 945 | EE_Error::reset_notices(); |
946 | 946 | return false; |
947 | 947 | } |
948 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
948 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
949 | 949 | return false; |
950 | 950 | } |
951 | 951 | } |
952 | 952 | // now that things have been kinda sufficiently verified, |
953 | 953 | // let's add the checkout to the session so that's available other systems |
954 | - EE_Registry::instance()->SSN->set_checkout( $this->checkout ); |
|
954 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
955 | 955 | return true; |
956 | 956 | } |
957 | 957 | |
@@ -966,15 +966,15 @@ discard block |
||
966 | 966 | * @param bool $reinitializing |
967 | 967 | * @throws \EE_Error |
968 | 968 | */ |
969 | - private function _initialize_reg_steps( $reinitializing = false ) { |
|
970 | - $this->checkout->set_reg_step_initiated( $this->checkout->current_step ); |
|
969 | + private function _initialize_reg_steps($reinitializing = false) { |
|
970 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
971 | 971 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
972 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
973 | - if ( ! $reg_step->initialize_reg_step() ) { |
|
972 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
973 | + if ( ! $reg_step->initialize_reg_step()) { |
|
974 | 974 | // if not initialized then maybe this step is being removed... |
975 | - if ( ! $reinitializing && $reg_step->is_current_step() ) { |
|
975 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
976 | 976 | // if it was the current step, then we need to start over here |
977 | - $this->_initialize_reg_steps( true ); |
|
977 | + $this->_initialize_reg_steps(true); |
|
978 | 978 | return; |
979 | 979 | } |
980 | 980 | continue; |
@@ -983,13 +983,13 @@ discard block |
||
983 | 983 | $reg_step->enqueue_styles_and_scripts(); |
984 | 984 | // i18n |
985 | 985 | $reg_step->translate_js_strings(); |
986 | - if ( $reg_step->is_current_step() ) { |
|
986 | + if ($reg_step->is_current_step()) { |
|
987 | 987 | // the text that appears on the reg step form submit button |
988 | 988 | $reg_step->set_submit_button_text(); |
989 | 989 | } |
990 | 990 | } |
991 | 991 | // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
992 | - do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step ); |
|
992 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | |
@@ -1002,43 +1002,43 @@ discard block |
||
1002 | 1002 | */ |
1003 | 1003 | private function _check_form_submission() { |
1004 | 1004 | //does this request require the reg form to be generated ? |
1005 | - if ( $this->checkout->generate_reg_form ) { |
|
1005 | + if ($this->checkout->generate_reg_form) { |
|
1006 | 1006 | // ever heard that song by Blue Rodeo ? |
1007 | 1007 | try { |
1008 | 1008 | $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
1009 | 1009 | // if not displaying a form, then check for form submission |
1010 | - if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) { |
|
1010 | + if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) { |
|
1011 | 1011 | // clear out any old data in case this step is being run again |
1012 | - $this->checkout->current_step->set_valid_data( array() ); |
|
1012 | + $this->checkout->current_step->set_valid_data(array()); |
|
1013 | 1013 | // capture submitted form data |
1014 | 1014 | $this->checkout->current_step->reg_form->receive_form_submission( |
1015 | - apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout ) |
|
1015 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
1016 | 1016 | ); |
1017 | 1017 | // validate submitted form data |
1018 | - if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid() ) { |
|
1018 | + if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1019 | 1019 | // thou shall not pass !!! |
1020 | 1020 | $this->checkout->continue_reg = FALSE; |
1021 | 1021 | // any form validation errors? |
1022 | - if ( $this->checkout->current_step->reg_form->submission_error_message() !== '' ) { |
|
1022 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1023 | 1023 | $submission_error_messages = array(); |
1024 | 1024 | // bad, bad, bad registrant |
1025 | - foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){ |
|
1026 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1025 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
1026 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1027 | 1027 | $submission_error_messages[] = sprintf( |
1028 | - __( '%s : %s', 'event_espresso' ), |
|
1028 | + __('%s : %s', 'event_espresso'), |
|
1029 | 1029 | $validation_error->get_form_section()->html_label_text(), |
1030 | 1030 | $validation_error->getMessage() |
1031 | 1031 | ); |
1032 | 1032 | } |
1033 | 1033 | } |
1034 | - EE_Error::add_error( implode( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1034 | + EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1035 | 1035 | } |
1036 | 1036 | // well not really... what will happen is we'll just get redirected back to redo the current step |
1037 | 1037 | $this->go_to_next_step(); |
1038 | 1038 | return; |
1039 | 1039 | } |
1040 | 1040 | } |
1041 | - } catch( EE_Error $e ) { |
|
1041 | + } catch (EE_Error $e) { |
|
1042 | 1042 | $e->get_error(); |
1043 | 1043 | } |
1044 | 1044 | } |
@@ -1055,22 +1055,22 @@ discard block |
||
1055 | 1055 | */ |
1056 | 1056 | private function _process_form_action() { |
1057 | 1057 | // what cha wanna do? |
1058 | - switch( $this->checkout->action ) { |
|
1058 | + switch ($this->checkout->action) { |
|
1059 | 1059 | // AJAX next step reg form |
1060 | 1060 | case 'display_spco_reg_step' : |
1061 | 1061 | $this->checkout->redirect = FALSE; |
1062 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1063 | - $this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() ); |
|
1062 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1063 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1064 | 1064 | } |
1065 | 1065 | break; |
1066 | 1066 | |
1067 | 1067 | default : |
1068 | 1068 | // meh... do one of those other steps first |
1069 | - if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) { |
|
1069 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1070 | 1070 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
1071 | - do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1071 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1072 | 1072 | // call action on current step |
1073 | - if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) { |
|
1073 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1074 | 1074 | // good registrant, you get to proceed |
1075 | 1075 | if ( |
1076 | 1076 | $this->checkout->current_step->success_message() !== '' |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | ) { |
1082 | 1082 | EE_Error::add_success( |
1083 | 1083 | $this->checkout->current_step->success_message() |
1084 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1084 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
1085 | 1085 | ); |
1086 | 1086 | |
1087 | 1087 | } |
@@ -1089,12 +1089,12 @@ discard block |
||
1089 | 1089 | $this->_setup_redirect(); |
1090 | 1090 | } |
1091 | 1091 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
1092 | - do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1092 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1093 | 1093 | |
1094 | 1094 | } else { |
1095 | 1095 | EE_Error::add_error( |
1096 | 1096 | sprintf( |
1097 | - __( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ), |
|
1097 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1098 | 1098 | $this->checkout->action, |
1099 | 1099 | $this->checkout->current_step->name() |
1100 | 1100 | ), |
@@ -1120,10 +1120,10 @@ discard block |
||
1120 | 1120 | public function add_styles_and_scripts() { |
1121 | 1121 | // i18n |
1122 | 1122 | $this->translate_js_strings(); |
1123 | - if ( $this->checkout->admin_request ) { |
|
1124 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 ); |
|
1123 | + if ($this->checkout->admin_request) { |
|
1124 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1125 | 1125 | } else { |
1126 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 ); |
|
1126 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1127 | 1127 | } |
1128 | 1128 | } |
1129 | 1129 | |
@@ -1139,42 +1139,42 @@ discard block |
||
1139 | 1139 | EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
1140 | 1140 | EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
1141 | 1141 | EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
1142 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1143 | - EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
1144 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1142 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1143 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
1144 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1145 | 1145 | EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
1146 | 1146 | EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
1147 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( __( 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso' ), '<br/>', '<br/>' ); |
|
1148 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' ); |
|
1147 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf(__('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), '<br/>', '<br/>'); |
|
1148 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1149 | 1149 | EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
1150 | 1150 | EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
1151 | 1151 | EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
1152 | - EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' ); |
|
1153 | - EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' ); |
|
1154 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' ); |
|
1155 | - EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' ); |
|
1156 | - EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' ); |
|
1157 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' ); |
|
1158 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' ); |
|
1159 | - EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' ); |
|
1160 | - EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' ); |
|
1161 | - EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' ); |
|
1162 | - EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' ); |
|
1163 | - EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' ); |
|
1164 | - EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' ); |
|
1165 | - EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' ); |
|
1152 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1153 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1154 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1155 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1156 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1157 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1158 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1159 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1160 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1161 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1162 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1163 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1164 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1165 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1166 | 1166 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
1167 | - __( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
1167 | + __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
1168 | 1168 | '<h4 class="important-notice">', |
1169 | 1169 | '</h4>', |
1170 | 1170 | '<br />', |
1171 | 1171 | '<p>', |
1172 | - '<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1172 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1173 | 1173 | '">', |
1174 | 1174 | '</a>', |
1175 | 1175 | '</p>' |
1176 | 1176 | ); |
1177 | - EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true ); |
|
1177 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | |
@@ -1187,25 +1187,25 @@ discard block |
||
1187 | 1187 | */ |
1188 | 1188 | public function enqueue_styles_and_scripts() { |
1189 | 1189 | // load css |
1190 | - wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1191 | - wp_enqueue_style( 'single_page_checkout' ); |
|
1190 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1191 | + wp_enqueue_style('single_page_checkout'); |
|
1192 | 1192 | // load JS |
1193 | - wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array( 'jquery' ), '1.0.1', TRUE ); |
|
1194 | - wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE ); |
|
1195 | - wp_register_script( 'single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1196 | - wp_enqueue_script( 'single_page_checkout' ); |
|
1193 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', TRUE); |
|
1194 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE); |
|
1195 | + wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1196 | + wp_enqueue_script('single_page_checkout'); |
|
1197 | 1197 | |
1198 | 1198 | /** |
1199 | 1199 | * global action hook for enqueueing styles and scripts with |
1200 | 1200 | * spco calls. |
1201 | 1201 | */ |
1202 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this ); |
|
1202 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1203 | 1203 | |
1204 | 1204 | /** |
1205 | 1205 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
1206 | 1206 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1207 | 1207 | */ |
1208 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this ); |
|
1208 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
1209 | 1209 | |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1220,19 +1220,19 @@ discard block |
||
1220 | 1220 | */ |
1221 | 1221 | private function _display_spco_reg_form() { |
1222 | 1222 | // if registering via the admin, just display the reg form for the current step |
1223 | - if ( $this->checkout->admin_request ) { |
|
1224 | - EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() ); |
|
1223 | + if ($this->checkout->admin_request) { |
|
1224 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1225 | 1225 | } else { |
1226 | 1226 | // add powered by EE msg |
1227 | - add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' )); |
|
1227 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1228 | 1228 | |
1229 | - $empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false; |
|
1229 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false; |
|
1230 | 1230 | $cookies_not_set_msg = ''; |
1231 | - if ( $empty_cart && ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) { |
|
1231 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
1232 | 1232 | $cookies_not_set_msg = apply_filters( |
1233 | 1233 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
1234 | 1234 | sprintf( |
1235 | - __( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ), |
|
1235 | + __('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'), |
|
1236 | 1236 | '<div class="ee-attention">', |
1237 | 1237 | '</div>', |
1238 | 1238 | '<h6 class="important-notice">', |
@@ -1252,7 +1252,7 @@ discard block |
||
1252 | 1252 | 'layout_strategy' => |
1253 | 1253 | new EE_Template_Layout( |
1254 | 1254 | array( |
1255 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1255 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1256 | 1256 | 'template_args' => array( |
1257 | 1257 | 'empty_cart' => $empty_cart, |
1258 | 1258 | 'revisit' => $this->checkout->revisit, |
@@ -1261,8 +1261,8 @@ discard block |
||
1261 | 1261 | 'empty_msg' => apply_filters( |
1262 | 1262 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
1263 | 1263 | sprintf( |
1264 | - __( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ), |
|
1265 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1264 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'), |
|
1265 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1266 | 1266 | '">', |
1267 | 1267 | '</a>' |
1268 | 1268 | ) |
@@ -1270,14 +1270,14 @@ discard block |
||
1270 | 1270 | 'cookies_not_set_msg' => $cookies_not_set_msg, |
1271 | 1271 | 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
1272 | 1272 | 'session_expiration' => |
1273 | - gmdate( 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) |
|
1273 | + gmdate('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)) |
|
1274 | 1274 | ) |
1275 | 1275 | ) |
1276 | 1276 | ) |
1277 | 1277 | ) |
1278 | 1278 | ); |
1279 | 1279 | // load template and add to output sent that gets filtered into the_content() |
1280 | - EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() ); |
|
1280 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js()); |
|
1281 | 1281 | } |
1282 | 1282 | } |
1283 | 1283 | |
@@ -1291,8 +1291,8 @@ discard block |
||
1291 | 1291 | * @internal param string $label |
1292 | 1292 | * @return string |
1293 | 1293 | */ |
1294 | - public function add_extra_finalize_registration_inputs( $next_step ) { |
|
1295 | - if ( $next_step === 'finalize_registration' ) { |
|
1294 | + public function add_extra_finalize_registration_inputs($next_step) { |
|
1295 | + if ($next_step === 'finalize_registration') { |
|
1296 | 1296 | echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
1297 | 1297 | } |
1298 | 1298 | } |
@@ -1306,18 +1306,18 @@ discard block |
||
1306 | 1306 | * @return string |
1307 | 1307 | */ |
1308 | 1308 | public static function display_registration_footer() { |
1309 | - if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) { |
|
1310 | - EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1311 | - $url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'https://eventespresso.com/' ); |
|
1312 | - $url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url ); |
|
1309 | + if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) { |
|
1310 | + EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1311 | + $url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'https://eventespresso.com/'); |
|
1312 | + $url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1313 | 1313 | echo apply_filters( |
1314 | 1314 | 'FHEE__EE_Front_Controller__display_registration_footer', |
1315 | 1315 | sprintf( |
1316 | - __( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ), |
|
1317 | - '<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="', |
|
1316 | + __('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'), |
|
1317 | + '<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="', |
|
1318 | 1318 | '" target="_blank">', |
1319 | 1319 | '</a>', |
1320 | - '<a href="' . $url . '" title="', |
|
1320 | + '<a href="'.$url.'" title="', |
|
1321 | 1321 | '" target="_blank">', |
1322 | 1322 | '</a></div>' |
1323 | 1323 | ) |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | * @throws \EE_Error |
1336 | 1336 | */ |
1337 | 1337 | public function unlock_transaction() { |
1338 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
1338 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1339 | 1339 | $this->checkout->transaction->unlock(); |
1340 | 1340 | } |
1341 | 1341 | } |
@@ -1350,12 +1350,12 @@ discard block |
||
1350 | 1350 | * @return array |
1351 | 1351 | */ |
1352 | 1352 | private function _setup_redirect() { |
1353 | - if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
1353 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1354 | 1354 | $this->checkout->redirect = TRUE; |
1355 | - if ( empty( $this->checkout->redirect_url )) { |
|
1355 | + if (empty($this->checkout->redirect_url)) { |
|
1356 | 1356 | $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
1357 | 1357 | } |
1358 | - $this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout ); |
|
1358 | + $this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout); |
|
1359 | 1359 | } |
1360 | 1360 | } |
1361 | 1361 | |
@@ -1369,9 +1369,9 @@ discard block |
||
1369 | 1369 | * @throws \EE_Error |
1370 | 1370 | */ |
1371 | 1371 | public function go_to_next_step() { |
1372 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1372 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1373 | 1373 | // capture contents of output buffer we started earlier in the request, and insert into JSON response |
1374 | - $this->checkout->json_response->set_unexpected_errors( ob_get_clean() ); |
|
1374 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1375 | 1375 | } |
1376 | 1376 | $this->unlock_transaction(); |
1377 | 1377 | // just return for these conditions |
@@ -1400,7 +1400,7 @@ discard block |
||
1400 | 1400 | */ |
1401 | 1401 | protected function _handle_json_response() { |
1402 | 1402 | // if this is an ajax request |
1403 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1403 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1404 | 1404 | // DEBUG LOG |
1405 | 1405 | //$this->checkout->log( |
1406 | 1406 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1413,7 +1413,7 @@ discard block |
||
1413 | 1413 | $this->checkout->json_response->set_registration_time_limit( |
1414 | 1414 | $this->checkout->get_registration_time_limit() |
1415 | 1415 | ); |
1416 | - $this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing ); |
|
1416 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1417 | 1417 | // just send the ajax ( |
1418 | 1418 | $json_response = apply_filters( |
1419 | 1419 | 'FHEE__EE_Single_Page_Checkout__JSON_response', |
@@ -1434,9 +1434,9 @@ discard block |
||
1434 | 1434 | */ |
1435 | 1435 | protected function _handle_html_redirects() { |
1436 | 1436 | // going somewhere ? |
1437 | - if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) { |
|
1437 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1438 | 1438 | // store notices in a transient |
1439 | - EE_Error::get_notices( false, true, true ); |
|
1439 | + EE_Error::get_notices(false, true, true); |
|
1440 | 1440 | // DEBUG LOG |
1441 | 1441 | //$this->checkout->log( |
1442 | 1442 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1446,7 +1446,7 @@ discard block |
||
1446 | 1446 | // 'headers_list' => headers_list(), |
1447 | 1447 | // ) |
1448 | 1448 | //); |
1449 | - wp_safe_redirect( $this->checkout->redirect_url ); |
|
1449 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1450 | 1450 | exit(); |
1451 | 1451 | } |
1452 | 1452 | } |
@@ -820,12 +820,12 @@ discard block |
||
820 | 820 | if ( $registration instanceof EE_Registration ) { |
821 | 821 | // we display all attendee info for the primary registrant |
822 | 822 | if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
823 | - && $registration->is_primary_registrant() |
|
823 | + && $registration->is_primary_registrant() |
|
824 | 824 | ) { |
825 | 825 | $this->checkout->primary_revisit = true; |
826 | 826 | break; |
827 | 827 | } else if ( $this->checkout->revisit |
828 | - && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
828 | + && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
829 | 829 | ) { |
830 | 830 | // but hide info if it doesn't belong to you |
831 | 831 | $transaction->clear_cache( 'Registration', $registration->ID() ); |
@@ -857,24 +857,24 @@ discard block |
||
857 | 857 | //do the following for each ticket of this type they selected |
858 | 858 | for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
859 | 859 | $att_nmbr++; |
860 | - /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
861 | - $CreateRegistrationCommand = EE_Registry::instance() |
|
862 | - ->create( |
|
863 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
864 | - array( |
|
865 | - $transaction, |
|
866 | - $line_item, |
|
867 | - $att_nmbr, |
|
868 | - $this->checkout->total_ticket_count |
|
869 | - ) |
|
870 | - ); |
|
871 | - // override capabilities for frontend registrations |
|
872 | - if ( ! is_admin()) { |
|
873 | - $CreateRegistrationCommand->setCapCheck( |
|
874 | - new \EventEspresso\core\domain\services\capabilities\PublicCapabilities('', |
|
875 | - 'create_new_registration') |
|
876 | - ); |
|
877 | - } |
|
860 | + /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
861 | + $CreateRegistrationCommand = EE_Registry::instance() |
|
862 | + ->create( |
|
863 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
864 | + array( |
|
865 | + $transaction, |
|
866 | + $line_item, |
|
867 | + $att_nmbr, |
|
868 | + $this->checkout->total_ticket_count |
|
869 | + ) |
|
870 | + ); |
|
871 | + // override capabilities for frontend registrations |
|
872 | + if ( ! is_admin()) { |
|
873 | + $CreateRegistrationCommand->setCapCheck( |
|
874 | + new \EventEspresso\core\domain\services\capabilities\PublicCapabilities('', |
|
875 | + 'create_new_registration') |
|
876 | + ); |
|
877 | + } |
|
878 | 878 | $registration = EE_Registry::instance()->BUS->execute( $CreateRegistrationCommand ); |
879 | 879 | if ( ! $registration instanceof EE_Registration ) { |
880 | 880 | throw new InvalidEntityException( |
@@ -6,11 +6,11 @@ |
||
6 | 6 | <li class="ticket-registration"> |
7 | 7 | <table class="registration-details"> |
8 | 8 | <tr class="odd"> |
9 | - <th><?php _e('Attendee', 'event_espresso');?></th> |
|
9 | + <th><?php _e('Attendee', 'event_espresso'); ?></th> |
|
10 | 10 | <td>[FNAME] [LNAME] ([ATTENDEE_EMAIL])</td> |
11 | 11 | </tr> |
12 | 12 | <tr> |
13 | - <th><?php _e("Registration Code:", "event_espresso");?></th> |
|
13 | + <th><?php _e("Registration Code:", "event_espresso"); ?></th> |
|
14 | 14 | <td>[REGISTRATION_CODE] - <span class="[REGISTRATION_STATUS_ID]">[REGISTRATION_STATUS_LABEL]</span></td> |
15 | 15 | </tr> |
16 | 16 | </table> |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * @param EE_Line_Item $line_item |
18 | 18 | * @param array $options |
19 | - * @return mixed |
|
19 | + * @return string |
|
20 | 20 | */ |
21 | 21 | public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
22 | 22 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @param EE_Line_Item $line_item |
96 | 96 | * @param array $options |
97 | - * @return mixed |
|
97 | + * @return string |
|
98 | 98 | */ |
99 | 99 | private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
100 | 100 | // start of row |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @param EE_Line_Item $line_item |
125 | 125 | * @param array $options |
126 | - * @return mixed |
|
126 | + * @return string |
|
127 | 127 | */ |
128 | 128 | private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
129 | 129 | // start of row |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @param EE_Line_Item $line_item |
155 | 155 | * @param array $options |
156 | - * @return mixed |
|
156 | + * @return string |
|
157 | 157 | */ |
158 | 158 | private function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
159 | 159 | // start of row |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param EE_Line_Item $line_item |
180 | 180 | * @param string $text |
181 | 181 | * @param array $options |
182 | - * @return mixed |
|
182 | + * @return string |
|
183 | 183 | */ |
184 | 184 | private function _total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
185 | 185 | // colspan |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * _separator_row |
204 | 204 | * |
205 | 205 | * @param array $options |
206 | - * @return mixed |
|
206 | + * @return string |
|
207 | 207 | */ |
208 | 208 | private function _separator_row( $options = array() ) { |
209 | 209 | // colspan |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $options |
50 | 50 | * @return mixed |
51 | 51 | */ |
52 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
52 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
53 | 53 | |
54 | 54 | $html = ''; |
55 | 55 | // set some default options and merge with incoming |
@@ -60,40 +60,40 @@ discard block |
||
60 | 60 | 'taxes_tr_css_class' => 'admin-primary-mbox-taxes-tr', |
61 | 61 | 'total_tr_css_class' => 'admin-primary-mbox-total-tr' |
62 | 62 | ); |
63 | - $options = array_merge( $default_options, (array)$options ); |
|
63 | + $options = array_merge($default_options, (array) $options); |
|
64 | 64 | |
65 | - switch( $line_item->type() ) { |
|
65 | + switch ($line_item->type()) { |
|
66 | 66 | |
67 | 67 | case EEM_Line_Item::type_line_item: |
68 | 68 | // item row |
69 | - $html .= $this->_item_row( $line_item, $options ); |
|
69 | + $html .= $this->_item_row($line_item, $options); |
|
70 | 70 | break; |
71 | 71 | |
72 | 72 | case EEM_Line_Item::type_sub_line_item: |
73 | - $html .= $this->_sub_item_row( $line_item, $options ); |
|
73 | + $html .= $this->_sub_item_row($line_item, $options); |
|
74 | 74 | break; |
75 | 75 | |
76 | 76 | case EEM_Line_Item::type_sub_total: |
77 | 77 | //loop through children |
78 | 78 | $child_line_items = $line_item->children(); |
79 | 79 | //loop through children |
80 | - foreach ( $child_line_items as $child_line_item ) { |
|
80 | + foreach ($child_line_items as $child_line_item) { |
|
81 | 81 | //recursively feed children back into this method |
82 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
82 | + $html .= $this->display_line_item($child_line_item, $options); |
|
83 | 83 | } |
84 | - $html .= $this->_sub_total_row( $line_item, $options ); |
|
84 | + $html .= $this->_sub_total_row($line_item, $options); |
|
85 | 85 | break; |
86 | 86 | |
87 | 87 | case EEM_Line_Item::type_tax: |
88 | - if ( $this->_show_taxes ) { |
|
89 | - $this->_taxes_html .= $this->_tax_row( $line_item, $options ); |
|
88 | + if ($this->_show_taxes) { |
|
89 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
90 | 90 | } |
91 | 91 | break; |
92 | 92 | |
93 | 93 | case EEM_Line_Item::type_tax_sub_total: |
94 | - foreach( $line_item->children() as $child_line_item ) { |
|
95 | - if ( $child_line_item->type() == EEM_Line_Item::type_tax ) { |
|
96 | - $this->display_line_item( $child_line_item, $options ); |
|
94 | + foreach ($line_item->children() as $child_line_item) { |
|
95 | + if ($child_line_item->type() == EEM_Line_Item::type_tax) { |
|
96 | + $this->display_line_item($child_line_item, $options); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | break; |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | $children = $line_item->children(); |
106 | 106 | |
107 | 107 | // loop thru all non-tax child line items |
108 | - foreach( $children as $child_line_item ) { |
|
109 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
108 | + foreach ($children as $child_line_item) { |
|
109 | + $html .= $this->display_line_item($child_line_item, $options); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $html .= $this->_taxes_html; |
113 | - $html .= $this->_total_row( $line_item, $options ); |
|
114 | - if ( $options['use_table_wrapper'] ) { |
|
115 | - $html = $this->_table_header( $options ) . $html . $this->_table_footer( $options ); |
|
113 | + $html .= $this->_total_row($line_item, $options); |
|
114 | + if ($options['use_table_wrapper']) { |
|
115 | + $html = $this->_table_header($options).$html.$this->_table_footer($options); |
|
116 | 116 | } |
117 | 117 | break; |
118 | 118 | |
@@ -129,15 +129,15 @@ discard block |
||
129 | 129 | * @param array $options |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - protected function _table_header( $options ) { |
|
133 | - $html = EEH_HTML::table( '','', $options['table_css_class'] ); |
|
132 | + protected function _table_header($options) { |
|
133 | + $html = EEH_HTML::table('', '', $options['table_css_class']); |
|
134 | 134 | $html .= EEH_HTML::thead(); |
135 | 135 | $html .= EEH_HTML::tr(); |
136 | - $html .= EEH_HTML::th( __( 'Name', 'event_espresso' ), '', 'jst-left' ); |
|
137 | - $html .= EEH_HTML::th( __( 'Type', 'event_espresso'), '', 'jst-left' ); |
|
138 | - $html .= EEH_HTML::th( __( 'Amount', 'event_espresso' ), '', 'jst-cntr' ); |
|
139 | - $html .= EEH_HTML::th( __( 'Qty', 'event_espresso' ), '', 'jst-cntr' ); |
|
140 | - $html .= EEH_HTML::th( __( 'Line Total', 'event_espresso'), '', 'jst-cntr' ); |
|
136 | + $html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left'); |
|
137 | + $html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left'); |
|
138 | + $html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr'); |
|
139 | + $html .= EEH_HTML::th(__('Qty', 'event_espresso'), '', 'jst-cntr'); |
|
140 | + $html .= EEH_HTML::th(__('Line Total', 'event_espresso'), '', 'jst-cntr'); |
|
141 | 141 | $html .= EEH_HTML::tbody(); |
142 | 142 | return $html; |
143 | 143 | } |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param array $options array of options for the table. |
150 | 150 | * @return string |
151 | 151 | */ |
152 | - protected function _table_footer( $options ) { |
|
153 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex(); |
|
152 | + protected function _table_footer($options) { |
|
153 | + return EEH_HTML::tbodyx().EEH_HTML::tablex(); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | * @param array $options |
163 | 163 | * @return mixed |
164 | 164 | */ |
165 | - protected function _item_row( EE_Line_Item $line_item, $options = array() ) { |
|
165 | + protected function _item_row(EE_Line_Item $line_item, $options = array()) { |
|
166 | 166 | $line_item_related_object = $line_item->get_object(); |
167 | 167 | $parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->get_object() : null; |
168 | 168 | // start of row |
169 | 169 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
170 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
170 | + $html = EEH_HTML::tr('', '', $row_class); |
|
171 | 171 | |
172 | 172 | |
173 | 173 | //Name Column |
@@ -175,44 +175,44 @@ discard block |
||
175 | 175 | |
176 | 176 | //related object scope. |
177 | 177 | $parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object ? $parent_line_item_related_object->name() : ''; |
178 | - $parent_related_object_name = empty( $parent_related_object_name ) && $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->name() : $parent_related_object_name; |
|
178 | + $parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->name() : $parent_related_object_name; |
|
179 | 179 | $parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links ? $parent_line_item_related_object->get_admin_details_link() : ''; |
180 | 180 | |
181 | 181 | |
182 | 182 | $name_html = $line_item_related_object instanceof EEI_Line_Item_Object ? $line_item_related_object->name() : $line_item->name(); |
183 | - $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' : $name_html; |
|
183 | + $name_html = $name_link ? '<a href="'.$name_link.'">'.$name_html.'</a>' : $name_html; |
|
184 | 184 | $name_html .= $line_item->is_taxable() ? ' *' : ''; |
185 | 185 | //maybe preface with icon? |
186 | - $name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon() . $name_html : $name_html; |
|
187 | - $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>'; |
|
188 | - $name_html .= sprintf( |
|
189 | - _x( '%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
186 | + $name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon().$name_html : $name_html; |
|
187 | + $name_html = '<span class="ee-line-item-name linked">'.$name_html.'</span><br>'; |
|
188 | + $name_html .= sprintf( |
|
189 | + _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
190 | 190 | '<span class="ee-line-item-related-parent-object">', |
191 | - $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->OBJ_type_i18n() : __( 'Item:', 'event_espresso' ), |
|
192 | - $parent_related_object_link ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' : $parent_related_object_name, |
|
191 | + $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->OBJ_type_i18n() : __('Item:', 'event_espresso'), |
|
192 | + $parent_related_object_link ? '<a href="'.$parent_related_object_link.'">'.$parent_related_object_name.'</a>' : $parent_related_object_name, |
|
193 | 193 | '</span>' |
194 | 194 | ); |
195 | - $html .= EEH_HTML::td( $name_html, '', 'jst-left' ); |
|
195 | + $html .= EEH_HTML::td($name_html, '', 'jst-left'); |
|
196 | 196 | |
197 | 197 | //Type Column |
198 | - $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . '<br />' : ''; |
|
198 | + $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().'<br />' : ''; |
|
199 | 199 | $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : ''; |
200 | - $type_html .= ! empty( $code ) ? '<span class="ee-line-item-id">' . sprintf( __( 'Code: %s', 'event_espresso' ), $code ) . '</span>' : ''; |
|
201 | - $html .= EEH_HTML::td( $type_html, '', 'jst-left' ); |
|
200 | + $type_html .= ! empty($code) ? '<span class="ee-line-item-id">'.sprintf(__('Code: %s', 'event_espresso'), $code).'</span>' : ''; |
|
201 | + $html .= EEH_HTML::td($type_html, '', 'jst-left'); |
|
202 | 202 | |
203 | 203 | |
204 | 204 | //Amount Column |
205 | - if ( $line_item->is_percent() ) { |
|
206 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'jst-rght' ); |
|
205 | + if ($line_item->is_percent()) { |
|
206 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'jst-rght'); |
|
207 | 207 | } else { |
208 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'jst-rght' ); |
|
208 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght'); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | //QTY column |
212 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'jst-rght' ); |
|
212 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'jst-rght'); |
|
213 | 213 | |
214 | 214 | //total column |
215 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'jst-rght' ); |
|
215 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
216 | 216 | |
217 | 217 | //finish things off and return |
218 | 218 | $html .= EEH_HTML::trx(); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param array $options |
229 | 229 | * @return mixed |
230 | 230 | */ |
231 | - protected function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
|
231 | + protected function _sub_item_row(EE_Line_Item $line_item, $options = array()) { |
|
232 | 232 | //for now we're not showing sub-items |
233 | 233 | return ''; |
234 | 234 | } |
@@ -242,13 +242,13 @@ discard block |
||
242 | 242 | * @param array $options |
243 | 243 | * @return mixed |
244 | 244 | */ |
245 | - protected function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
|
245 | + protected function _tax_row(EE_Line_Item $line_item, $options = array()) { |
|
246 | 246 | // start of row |
247 | - $html = EEH_HTML::tr( '', 'admin-primary-mbox-taxes-tr' ); |
|
247 | + $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr'); |
|
248 | 248 | // name th |
249 | - $html .= EEH_HTML::th( $line_item->name() . '(' . $line_item->get_pretty( 'LIN_percent' ) . '%)', '', 'jst-rght', '', ' colspan="4"' ); |
|
249 | + $html .= EEH_HTML::th($line_item->name().'('.$line_item->get_pretty('LIN_percent').'%)', '', 'jst-rght', '', ' colspan="4"'); |
|
250 | 250 | // total th |
251 | - $html .= EEH_HTML::th( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'jst-rght' ); |
|
251 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
252 | 252 | // end of row |
253 | 253 | $html .= EEH_HTML::trx(); |
254 | 254 | return $html; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * @param array $options |
266 | 266 | * @return mixed |
267 | 267 | */ |
268 | - protected function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
|
268 | + protected function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) { |
|
269 | 269 | //currently not showing subtotal row |
270 | 270 | return ''; |
271 | 271 | } |
@@ -279,15 +279,15 @@ discard block |
||
279 | 279 | * @param array $options |
280 | 280 | * @return mixed |
281 | 281 | */ |
282 | - protected function _total_row( EE_Line_Item $line_item, $options = array() ) { |
|
282 | + protected function _total_row(EE_Line_Item $line_item, $options = array()) { |
|
283 | 283 | // start of row |
284 | - $html = EEH_HTML::tr( '', '', 'admin-primary-mbox-total-tr' ); |
|
284 | + $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr'); |
|
285 | 285 | // Total th label |
286 | - $total_label = sprintf( __( 'Transaction Total %s', 'event_espresso' ), '(' . EE_Registry::instance()->CFG->currency->code . ')' ); |
|
287 | - $html .= EEH_HTML::th( $total_label, '', 'jst-rght', '', ' colspan="4"' ); |
|
286 | + $total_label = sprintf(__('Transaction Total %s', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); |
|
287 | + $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="4"'); |
|
288 | 288 | // total th |
289 | 289 | |
290 | - $html .= EEH_HTML::th( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'jst-rght' ); |
|
290 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
291 | 291 | // end of row |
292 | 292 | $html .= EEH_HTML::trx(); |
293 | 293 | return $html; |
@@ -767,7 +767,7 @@ |
||
767 | 767 | * Takes care of setting up the addressee object(s) for the primary attendee. |
768 | 768 | * |
769 | 769 | * @access protected |
770 | - * @return array of EE_Addressee objects |
|
770 | + * @return EE_Messages_Addressee[] of EE_Addressee objects |
|
771 | 771 | */ |
772 | 772 | protected function _primary_attendee_addressees() { |
773 | 773 | $aee = $this->_default_addressee_data; |
@@ -326,11 +326,11 @@ |
||
326 | 326 | /** |
327 | 327 | * This sets up any action/filter hooks this message type puts in place for a specific messenger. Note that by |
328 | 328 | * default this does nothing. Child classes will need to override if they want to add specific hooks for a messenger. |
329 | - * |
|
330 | - * @since 1.0.0 |
|
331 | - * |
|
332 | - * @return void |
|
333 | - */ |
|
329 | + * |
|
330 | + * @since 1.0.0 |
|
331 | + * |
|
332 | + * @return void |
|
333 | + */ |
|
334 | 334 | protected function _do_messenger_hooks() { |
335 | 335 | return; |
336 | 336 | } |
@@ -1,6 +1,7 @@ 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 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -655,8 +656,9 @@ discard block |
||
655 | 656 | //process addressees for each context. Child classes will have to have methods for each context defined to handle the processing of the data object within them |
656 | 657 | foreach ( $this->_contexts as $context => $details ) { |
657 | 658 | $xpctd_method = '_' . $context . '_addressees'; |
658 | - if ( !method_exists( $this, $xpctd_method ) ) |
|
659 | - throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so. The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) ); |
|
659 | + if ( !method_exists( $this, $xpctd_method ) ) { |
|
660 | + throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so. The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) ); |
|
661 | + } |
|
660 | 662 | $this->_addressees[$context] = call_user_func( array( $this, $xpctd_method ) ); |
661 | 663 | } |
662 | 664 | return true; //data was processed successfully. |
@@ -823,7 +825,9 @@ discard block |
||
823 | 825 | //set the attendee array to blank on each loop; |
824 | 826 | $aee = array(); |
825 | 827 | |
826 | - if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) continue; |
|
828 | + if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) { |
|
829 | + continue; |
|
830 | + } |
|
827 | 831 | |
828 | 832 | //is $this->_regs_for_sending present? If so, let's make sure we ONLY generate addressee for registrations in that array. |
829 | 833 | if ( ! empty( $this->_regs_for_sending ) && is_array( $this->_regs_for_sending ) ) { |
@@ -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 | /** |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @param int $id Optional. Integer corresponding to the value for the primary key of a EE_Base_Class_Object |
286 | 286 | * @return mixed ( EE_Base_Class||EE_Base_Class[] ) |
287 | 287 | */ |
288 | - abstract protected function _get_data_for_context( $context, EE_Registration $registration, $id ); |
|
288 | + abstract protected function _get_data_for_context($context, EE_Registration $registration, $id); |
|
289 | 289 | |
290 | 290 | |
291 | 291 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @deprecated 4.9.0 |
316 | 316 | * @return int |
317 | 317 | */ |
318 | - protected function _get_id_for_msg_url( $context, EE_Registration $registration ) { |
|
318 | + protected function _get_id_for_msg_url($context, EE_Registration $registration) { |
|
319 | 319 | return 0; |
320 | 320 | } |
321 | 321 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * what messenger is being used to send the message at the time of sending. |
347 | 347 | * @since 4.9.0 |
348 | 348 | */ |
349 | - public function do_messenger_hooks( $messenger = null ) { |
|
349 | + public function do_messenger_hooks($messenger = null) { |
|
350 | 350 | $this->_active_messenger = $messenger; |
351 | 351 | $this->_do_messenger_hooks(); |
352 | 352 | } |
@@ -405,10 +405,10 @@ discard block |
||
405 | 405 | * @param mixed $data This sets the data property for the message type with the incoming data used for generating. |
406 | 406 | * @return string (the reference for the data handler) (will be an empty string if could not be determined). |
407 | 407 | */ |
408 | - public function get_data_handler( $data ) { |
|
408 | + public function get_data_handler($data) { |
|
409 | 409 | $this->_data = $data; |
410 | 410 | $this->_set_data_handler(); |
411 | - return apply_filters( 'FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this ); |
|
411 | + return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
@@ -447,28 +447,28 @@ discard block |
||
447 | 447 | * @deprecated 4.9.0 Likely 4.9.10 or 4.10.0 will remove this method completely |
448 | 448 | * @return string generated url |
449 | 449 | */ |
450 | - public function get_url_trigger( $context, $sending_messenger, EE_Registration $registration ) { |
|
450 | + public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) { |
|
451 | 451 | |
452 | 452 | //validate context |
453 | 453 | //valid context? |
454 | - if ( !isset( $this->_contexts[$context] ) ) { |
|
455 | - throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) ); |
|
454 | + if ( ! isset($this->_contexts[$context])) { |
|
455 | + throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this))); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | //valid sending_messenger? |
459 | 459 | $not_valid_msgr = FALSE; |
460 | - foreach ( $this->_with_messengers as $generating => $sendings ) { |
|
461 | - if ( empty( $sendings ) || array_search( $sending_messenger, $sendings ) === FALSE ) { |
|
460 | + foreach ($this->_with_messengers as $generating => $sendings) { |
|
461 | + if (empty($sendings) || array_search($sending_messenger, $sendings) === FALSE) { |
|
462 | 462 | $not_valid_msgr = TRUE; |
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
466 | - if ( $not_valid_msgr ) { |
|
467 | - throw new EE_Error( sprintf( __('The given sending messenger string (%s) does not match a valid sending messenger with the %s. If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class( $this ) ) ); |
|
466 | + if ($not_valid_msgr) { |
|
467 | + throw new EE_Error(sprintf(__('The given sending messenger string (%s) does not match a valid sending messenger with the %s. If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class($this))); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | EE_Registry::instance()->load_helper('MSG_Template'); |
471 | - return EEH_MSG_Template::generate_url_trigger( $sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url( $context, $registration ) ); |
|
471 | + return EEH_MSG_Template::generate_url_trigger($sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url($context, $registration)); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | |
@@ -489,19 +489,19 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return mixed (EE_Base_Class||EE_Base_Class[]) |
491 | 491 | */ |
492 | - public function get_data_for_context( $context, EE_Registration $registration, $id = 0 ) { |
|
492 | + public function get_data_for_context($context, EE_Registration $registration, $id = 0) { |
|
493 | 493 | //valid context? |
494 | - if ( !isset( $this->_contexts[$context] ) ) { |
|
495 | - throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) ); |
|
494 | + if ( ! isset($this->_contexts[$context])) { |
|
495 | + throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this))); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | //get data and apply global and class specific filters on it. |
499 | - $data = apply_filters( 'FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context( $context, $registration, $id ), $this ); |
|
500 | - $data = apply_filters( 'FHEE__' . get_class( $this ) . '__get_data_for_context__data', $data, $this ); |
|
499 | + $data = apply_filters('FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context($context, $registration, $id), $this); |
|
500 | + $data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this); |
|
501 | 501 | |
502 | 502 | //if empty then something went wrong! |
503 | - if ( empty( $data ) ) { |
|
504 | - throw new EE_Error( sprintf( __('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name ) ); |
|
503 | + if (empty($data)) { |
|
504 | + throw new EE_Error(sprintf(__('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name)); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | return $data; |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | */ |
553 | 553 | public function with_messengers() { |
554 | 554 | |
555 | - return apply_filters( 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class( $this ), $this->_with_messengers); |
|
555 | + return apply_filters('FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this), $this->_with_messengers); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | * @access public |
571 | 571 | * @return string |
572 | 572 | */ |
573 | - public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array() ) { |
|
573 | + public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array()) { |
|
574 | 574 | //we can also further refine the context by action (if present). |
575 | - return $this->_get_admin_page_content( $page, $action, $extra, $messengers ); |
|
575 | + return $this->_get_admin_page_content($page, $action, $extra, $messengers); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
@@ -602,8 +602,8 @@ discard block |
||
602 | 602 | */ |
603 | 603 | public function get_master_templates() { |
604 | 604 | //first class specific filter then filter that by the global filter. |
605 | - $master_templates = apply_filters( 'FHEE__' . get_class( $this ) . '__get_master_templates', $this->_master_templates ); |
|
606 | - return apply_filters( 'FHEE__EE_message_type__get_master_templates', $master_templates, $this ); |
|
605 | + $master_templates = apply_filters('FHEE__'.get_class($this).'__get_master_templates', $this->_master_templates); |
|
606 | + return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | |
@@ -617,23 +617,23 @@ discard block |
||
617 | 617 | * @return array An array indexed by context where each context is an array of EE_Messages_Addressee objects for |
618 | 618 | * that context |
619 | 619 | */ |
620 | - public function get_addressees( EE_Messages_incoming_data $data, $context = '' ) { |
|
620 | + public function get_addressees(EE_Messages_incoming_data $data, $context = '') { |
|
621 | 621 | //override _data |
622 | 622 | $this->_data = $data; |
623 | 623 | $addressees = array(); |
624 | 624 | |
625 | 625 | //if incoming context then limit to that context |
626 | - if ( ! empty( $context ) ) { |
|
627 | - $cntxt = ! empty( $this->_contexts[$context] ) ? $this->_contexts[$context] : ''; |
|
628 | - if ( ! empty( $cntxt ) ) { |
|
626 | + if ( ! empty($context)) { |
|
627 | + $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : ''; |
|
628 | + if ( ! empty($cntxt)) { |
|
629 | 629 | $this->_contexts = array(); |
630 | 630 | $this->_contexts[$context] = $cntxt; |
631 | 631 | } |
632 | 632 | } |
633 | 633 | |
634 | 634 | $this->_set_default_addressee_data(); |
635 | - if ( $this->_process_data() ) { |
|
636 | - $addressees = $this->_addressees; |
|
635 | + if ($this->_process_data()) { |
|
636 | + $addressees = $this->_addressees; |
|
637 | 637 | } |
638 | 638 | return $addressees; |
639 | 639 | } |
@@ -648,16 +648,16 @@ discard block |
||
648 | 648 | protected function _process_data() { |
649 | 649 | //at a minimum, we NEED EE_Attendee objects. |
650 | 650 | |
651 | - if ( empty( $this->_data->attendees ) ) { |
|
652 | - return false; //there's no data to process! |
|
651 | + if (empty($this->_data->attendees)) { |
|
652 | + return false; //there's no data to process! |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | //process addressees for each context. Child classes will have to have methods for each context defined to handle the processing of the data object within them |
656 | - foreach ( $this->_contexts as $context => $details ) { |
|
657 | - $xpctd_method = '_' . $context . '_addressees'; |
|
658 | - if ( !method_exists( $this, $xpctd_method ) ) |
|
659 | - throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so. The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) ); |
|
660 | - $this->_addressees[$context] = call_user_func( array( $this, $xpctd_method ) ); |
|
656 | + foreach ($this->_contexts as $context => $details) { |
|
657 | + $xpctd_method = '_'.$context.'_addressees'; |
|
658 | + if ( ! method_exists($this, $xpctd_method)) |
|
659 | + throw new EE_Error(sprintf(__('The data for %1$s message type cannot be prepared because there is no set method for doing so. The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method)); |
|
660 | + $this->_addressees[$context] = call_user_func(array($this, $xpctd_method)); |
|
661 | 661 | } |
662 | 662 | return true; //data was processed successfully. |
663 | 663 | } |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | 'total_ticket_count' => $this->_data->total_ticket_count |
693 | 693 | ); |
694 | 694 | |
695 | - if ( is_array( $this->_data->primary_attendee_data ) ) { |
|
696 | - $this->_default_addressee_data = array_merge( $this->_default_addressee_data, $this->_data->primary_attendee_data ); |
|
695 | + if (is_array($this->_data->primary_attendee_data)) { |
|
696 | + $this->_default_addressee_data = array_merge($this->_default_addressee_data, $this->_data->primary_attendee_data); |
|
697 | 697 | $this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj']; |
698 | 698 | $this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj']; |
699 | 699 | } |
@@ -711,26 +711,26 @@ discard block |
||
711 | 711 | * see abstract declaration in parent class for details, children message types can override these valid shortcodes if desired (we include all for all contexts by default). |
712 | 712 | */ |
713 | 713 | protected function _set_valid_shortcodes() { |
714 | - $all_shortcodes = array( 'attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger' ); |
|
714 | + $all_shortcodes = array('attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger'); |
|
715 | 715 | $contexts = $this->get_contexts(); |
716 | - foreach ( $contexts as $context => $details ) { |
|
716 | + foreach ($contexts as $context => $details) { |
|
717 | 717 | $this->_valid_shortcodes[$context] = $all_shortcodes; |
718 | 718 | |
719 | 719 | //make sure non admin context does not include the event_author shortcodes |
720 | - if ( $context != 'admin' ) { |
|
721 | - if( ($key = array_search('event_author', $this->_valid_shortcodes[$context] ) ) !== false) { |
|
720 | + if ($context != 'admin') { |
|
721 | + if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) { |
|
722 | 722 | unset($this->_valid_shortcodes[$context][$key]); |
723 | 723 | } |
724 | 724 | } |
725 | 725 | } |
726 | 726 | |
727 | 727 | //make sure admin context does not include the recipient_details shortcodes IF we have admin context hooked in message types might not have that context. |
728 | - if ( !empty( $this->_valid_shortcodes['admin'] ) ) { |
|
729 | - if( ($key = array_search('recipient_details', $this->_valid_shortcodes['admin'] ) ) !== false) { |
|
728 | + if ( ! empty($this->_valid_shortcodes['admin'])) { |
|
729 | + if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) { |
|
730 | 730 | unset($this->_valid_shortcodes['admin'][$key]); |
731 | 731 | } |
732 | 732 | //make sure admin context does not include the recipient_details shortcodes |
733 | - if( ($key = array_search('recipient_list', $this->_valid_shortcodes['admin'] ) ) !== false) { |
|
733 | + if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) { |
|
734 | 734 | unset($this->_valid_shortcodes['admin'][$key]); |
735 | 735 | } |
736 | 736 | } |
@@ -743,8 +743,8 @@ discard block |
||
743 | 743 | * @param array $new_config array of valid shortcodes (by context) |
744 | 744 | * @return void sets valid_shortcodes property |
745 | 745 | */ |
746 | - public function reset_valid_shortcodes_config( $new_config ) { |
|
747 | - foreach ( $new_config as $context => $shortcodes ) { |
|
746 | + public function reset_valid_shortcodes_config($new_config) { |
|
747 | + foreach ($new_config as $context => $shortcodes) { |
|
748 | 748 | $this->_valid_shortcodes[$context] = $shortcodes; |
749 | 749 | } |
750 | 750 | } |
@@ -763,13 +763,13 @@ discard block |
||
763 | 763 | $addressees = array(); |
764 | 764 | |
765 | 765 | //first we need to get the event admin user id for all the events and setup an addressee object for each unique admin user. |
766 | - foreach ( $this->_data->events as $line_ref => $event ) { |
|
767 | - $admin_id = $this->_get_event_admin_id( $event['ID'] ); |
|
766 | + foreach ($this->_data->events as $line_ref => $event) { |
|
767 | + $admin_id = $this->_get_event_admin_id($event['ID']); |
|
768 | 768 | //make sure we are just including the events that belong to this admin! |
769 | - $admin_events[ $admin_id ][$line_ref] = $event; |
|
769 | + $admin_events[$admin_id][$line_ref] = $event; |
|
770 | 770 | } |
771 | 771 | //k now we can loop through the event_admins and setup the addressee data. |
772 | - foreach ( $admin_events as $admin_id => $event_details ) { |
|
772 | + foreach ($admin_events as $admin_id => $event_details) { |
|
773 | 773 | $aee = array( |
774 | 774 | 'user_id' => $admin_id, |
775 | 775 | 'events' => $event_details, |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | 'recipient_id' => $admin_id, |
778 | 778 | 'recipient_type' => 'WP_User' |
779 | 779 | ); |
780 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
781 | - $addressees[] = new EE_Messages_Addressee( $aee ); |
|
780 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
781 | + $addressees[] = new EE_Messages_Addressee($aee); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | return $addressees; |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | $aee['recipient_type'] = 'Attendee'; |
801 | 801 | |
802 | 802 | //great now we can instantiate the $addressee object and return (as an array); |
803 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
803 | + $add[] = new EE_Messages_Addressee($aee); |
|
804 | 804 | return $add; |
805 | 805 | } |
806 | 806 | |
@@ -819,38 +819,38 @@ discard block |
||
819 | 819 | //use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we? |
820 | 820 | $already_processed = array(); |
821 | 821 | |
822 | - foreach ( $this->_data->attendees as $att_id => $details ) { |
|
822 | + foreach ($this->_data->attendees as $att_id => $details) { |
|
823 | 823 | //set the attendee array to blank on each loop; |
824 | 824 | $aee = array(); |
825 | 825 | |
826 | - if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) continue; |
|
826 | + if (isset($this->_data->reg_obj) && ($this->_data->reg_obj->attendee_ID() != $att_id) && $this->_single_message) continue; |
|
827 | 827 | |
828 | 828 | //is $this->_regs_for_sending present? If so, let's make sure we ONLY generate addressee for registrations in that array. |
829 | - if ( ! empty( $this->_regs_for_sending ) && is_array( $this->_regs_for_sending ) ) { |
|
830 | - $regs_allowed = array_intersect_key( array_flip( $this->_regs_for_sending ), $details['reg_objs'] ); |
|
831 | - if ( empty( $regs_allowed ) ) { |
|
829 | + if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) { |
|
830 | + $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']); |
|
831 | + if (empty($regs_allowed)) { |
|
832 | 832 | continue; |
833 | 833 | } |
834 | 834 | } |
835 | 835 | |
836 | 836 | if ( |
837 | - in_array( $details['attendee_email'], $already_processed ) |
|
838 | - && apply_filters( 'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', true, $this->_data, $this ) |
|
837 | + in_array($details['attendee_email'], $already_processed) |
|
838 | + && apply_filters('FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', true, $this->_data, $this) |
|
839 | 839 | ) { |
840 | 840 | continue; |
841 | 841 | } |
842 | 842 | |
843 | 843 | $already_processed[] = $details['attendee_email']; |
844 | 844 | |
845 | - foreach ( $details as $item => $value ) { |
|
845 | + foreach ($details as $item => $value) { |
|
846 | 846 | $aee[$item] = $value; |
847 | - if ( $item == 'line_ref' ) { |
|
848 | - foreach ( $value as $event_id ) { |
|
847 | + if ($item == 'line_ref') { |
|
848 | + foreach ($value as $event_id) { |
|
849 | 849 | $aee['events'][$event_id] = $this->_data->events[$event_id]; |
850 | 850 | } |
851 | 851 | } |
852 | 852 | |
853 | - if ( $item == 'attendee_email' ) { |
|
853 | + if ($item == 'attendee_email') { |
|
854 | 854 | $aee['attendee_email'] = $value; |
855 | 855 | } |
856 | 856 | |
@@ -868,8 +868,8 @@ discard block |
||
868 | 868 | $aee['recipient_type'] = 'Attendee'; |
869 | 869 | |
870 | 870 | //merge in the primary attendee data |
871 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
872 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
871 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
872 | + $add[] = new EE_Messages_Addressee($aee); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | return $add; |
@@ -881,8 +881,8 @@ discard block |
||
881 | 881 | * @param $event_id |
882 | 882 | * @return int |
883 | 883 | */ |
884 | - protected function _get_event_admin_id( $event_id ) { |
|
885 | - $event = EEM_Event::instance()->get_one_by_ID( $event_id ); |
|
884 | + protected function _get_event_admin_id($event_id) { |
|
885 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
886 | 886 | return $event instanceof EE_Event ? $event->wp_user() : 0; |
887 | 887 | } |
888 | 888 |
@@ -410,7 +410,7 @@ |
||
410 | 410 | /** |
411 | 411 | * This simply loops through all active messengers and takes care of setting up the |
412 | 412 | * EE_Message_To_Generate objects. |
413 | - * @param $message_type |
|
413 | + * @param string $message_type |
|
414 | 414 | * @param $data |
415 | 415 | * |
416 | 416 | * @return EE_Message_To_Generate[] |
@@ -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 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | 0 => array( |
34 | 34 | 'content_id' => 'attendee-column-tip', |
35 | 35 | 'target' => '.column-attendees .dashicons-groups', |
36 | - 'content' => sprintf( __('%s Registrations', 'event_espresso'), EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence') ), |
|
36 | + 'content' => sprintf(__('%s Registrations', 'event_espresso'), EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence')), |
|
37 | 37 | 'options' => array( |
38 | 38 | 'position' => array( |
39 | 39 | 'my' => 'bottom left', |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param EE_Datetime constant $status What status is set (by class) |
125 | 125 | * @return string The status legend with the related status highlighted |
126 | 126 | */ |
127 | - private function _event_status_legend( $status ) { |
|
127 | + private function _event_status_legend($status) { |
|
128 | 128 | |
129 | 129 | $status_array = array( |
130 | 130 | 'active_status' => EE_Datetime::active, |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | 'inactive_status' => EE_Datetime::inactive |
137 | 137 | ); |
138 | 138 | |
139 | - return EEH_Template::status_legend( $status_array, $status ); |
|
139 | + return EEH_Template::status_legend($status_array, $status); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | } |
143 | 143 | \ No newline at end of file |
@@ -1849,8 +1849,7 @@ discard block |
||
1849 | 1849 | $MTP = EEM_Message_Template_Group::instance(); |
1850 | 1850 | |
1851 | 1851 | if ( empty($GRP_ID) ) |
1852 | - {$this->_message_template_group = $MTP->create_default_object();} |
|
1853 | - else |
|
1852 | + {$this->_message_template_group = $MTP->create_default_object();} else |
|
1854 | 1853 | {$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );} |
1855 | 1854 | |
1856 | 1855 | $this->_template_pack = $this->_message_template_group->get_template_pack(); |
@@ -2977,9 +2976,7 @@ discard block |
||
2977 | 2976 | } |
2978 | 2977 | } |
2979 | 2978 | $this->_active_messengers[$messenger]['settings'] = $settings; |
2980 | - } |
|
2981 | - |
|
2982 | - else if ( $this->_req_data['type'] == 'message_type' ) { |
|
2979 | + } else if ( $this->_req_data['type'] == 'message_type' ) { |
|
2983 | 2980 | $settings = $this->_req_data['message_type_settings']; |
2984 | 2981 | $messenger = $settings['messenger']; |
2985 | 2982 | $message_type = $settings['message_type']; |
@@ -2430,7 +2430,7 @@ discard block |
||
2430 | 2430 | * @param int $GRP_ID The group being deleted |
2431 | 2431 | * @param bool $include_group whether to delete the Message Template Group as well. |
2432 | 2432 | * |
2433 | - * @return bool boolean to indicate the success of the deletes or not. |
|
2433 | + * @return integer boolean to indicate the success of the deletes or not. |
|
2434 | 2434 | */ |
2435 | 2435 | private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) { |
2436 | 2436 | $success = 1; |
@@ -2565,7 +2565,7 @@ discard block |
||
2565 | 2565 | * This just prepares the content for the message type settings |
2566 | 2566 | * |
2567 | 2567 | * @param object $message_type The message type object |
2568 | - * @param object $messenger The messenger object |
|
2568 | + * @param EE_messenger|null $messenger The messenger object |
|
2569 | 2569 | * @param boolean $active Whether the message type is active or not |
2570 | 2570 | * |
2571 | 2571 | * @return string html output for the content |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * |
103 | 103 | * @throws EE_Error |
104 | - */ |
|
104 | + */ |
|
105 | 105 | protected function _load_message_resource_manager() { |
106 | 106 | $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
107 | 107 | } |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | |
212 | 212 | /** |
213 | 213 | * an array for storing key => value pairs of request actions and their corresponding methods |
214 | - * @access protected |
|
215 | - * @return void |
|
216 | - */ |
|
214 | + * @access protected |
|
215 | + * @return void |
|
216 | + */ |
|
217 | 217 | protected function _set_page_routes() { |
218 | 218 | $grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] ) |
219 | 219 | ? $this->_req_data['GRP_ID'] |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | protected function _add_screen_options_global_mtps() { |
518 | 518 | /** |
519 | 519 | * Note: the reason for the value swap here on $this->_admin_page_title is because $this->_per_page_screen_options |
520 | - * uses the $_admin_page_title property and we want different outputs in the different spots. |
|
521 | - */ |
|
520 | + * uses the $_admin_page_title property and we want different outputs in the different spots. |
|
521 | + */ |
|
522 | 522 | $page_title = $this->_admin_page_title; |
523 | 523 | $this->_admin_page_title = __('Global Message Templates', 'event_espresso'); |
524 | 524 | $this->_per_page_screen_option(); |
@@ -721,9 +721,9 @@ discard block |
||
721 | 721 | $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' ) |
722 | 722 | ? array( |
723 | 723 | 'generate_now' => __( 'Generate Now', 'event_espresso' ), |
724 | - 'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ), |
|
725 | - 'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ), |
|
726 | - 'send_now' => __( 'Send Now', 'event_espresso' ) |
|
724 | + 'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ), |
|
725 | + 'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ), |
|
726 | + 'send_now' => __( 'Send Now', 'event_espresso' ) |
|
727 | 727 | ) |
728 | 728 | : array(); |
729 | 729 | |
@@ -734,10 +734,10 @@ discard block |
||
734 | 734 | |
735 | 735 | $this->_views = array( |
736 | 736 | 'all' => array( |
737 | - 'slug' => 'all', |
|
738 | - 'label' => __( 'All', 'event_espresso' ), |
|
739 | - 'count' => 0, |
|
740 | - 'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action ) |
|
737 | + 'slug' => 'all', |
|
738 | + 'label' => __( 'All', 'event_espresso' ), |
|
739 | + 'count' => 0, |
|
740 | + 'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action ) |
|
741 | 741 | ) |
742 | 742 | ); |
743 | 743 | |
@@ -1127,9 +1127,9 @@ discard block |
||
1127 | 1127 | && in_array($extra_field, $v_fields) |
1128 | 1128 | && |
1129 | 1129 | ( |
1130 | - is_array($validators[$extra_field] ) |
|
1130 | + is_array($validators[$extra_field] ) |
|
1131 | 1131 | && isset( $validators[$extra_field]['msg'] ) |
1132 | - ) |
|
1132 | + ) |
|
1133 | 1133 | ? 'validate-error ' . $css_class |
1134 | 1134 | : $css_class; |
1135 | 1135 | |
@@ -1414,8 +1414,8 @@ discard block |
||
1414 | 1414 | $GRP_ID, |
1415 | 1415 | false, |
1416 | 1416 | add_query_arg( |
1417 | - array( 'action' => 'global_mtps' ), |
|
1418 | - $this->_admin_base_url |
|
1417 | + array( 'action' => 'global_mtps' ), |
|
1418 | + $this->_admin_base_url |
|
1419 | 1419 | ) |
1420 | 1420 | ); |
1421 | 1421 | |
@@ -1890,14 +1890,14 @@ discard block |
||
1890 | 1890 | |
1891 | 1891 | |
1892 | 1892 | /** |
1893 | - * This returns the shortcode selector skeleton for a given context and field. |
|
1894 | - * |
|
1895 | - * @since 4.9.rc.000 |
|
1896 | - * |
|
1893 | + * This returns the shortcode selector skeleton for a given context and field. |
|
1894 | + * |
|
1895 | + * @since 4.9.rc.000 |
|
1896 | + * |
|
1897 | 1897 | * @param string $field The name of the field retrieving shortcodes for. |
1898 | - * @param string $linked_input_id The css id of the input that the shortcodes get added to. |
|
1899 | - * @return string |
|
1900 | - */ |
|
1898 | + * @param string $linked_input_id The css id of the input that the shortcodes get added to. |
|
1899 | + * @return string |
|
1900 | + */ |
|
1901 | 1901 | protected function _get_shortcode_selector( $field, $linked_input_id ) { |
1902 | 1902 | $template_args = array( |
1903 | 1903 | 'shortcodes' => $this->_get_shortcodes( array( $field ), true ), |
@@ -2495,9 +2495,9 @@ discard block |
||
2495 | 2495 | |
2496 | 2496 | /** |
2497 | 2497 | * _learn_more_about_message_templates_link |
2498 | - * @access protected |
|
2499 | - * @return string |
|
2500 | - */ |
|
2498 | + * @access protected |
|
2499 | + * @return string |
|
2500 | + */ |
|
2501 | 2501 | protected function _learn_more_about_message_templates_link() { |
2502 | 2502 | return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>'; |
2503 | 2503 | } |
@@ -3038,7 +3038,7 @@ discard block |
||
3038 | 3038 | /** @var EE_message_type $message_type */ |
3039 | 3039 | $message_type = $this->_message_resource_manager->get_message_type( $message_type_name ); |
3040 | 3040 | if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) |
3041 | - && $message_type instanceof EE_message_type |
|
3041 | + && $message_type instanceof EE_message_type |
|
3042 | 3042 | ) { |
3043 | 3043 | $this->_template_args['data']['active_mts'][] = $message_type_name; |
3044 | 3044 | if ( $message_type->get_admin_settings_fields() ) { |
@@ -3374,10 +3374,10 @@ discard block |
||
3374 | 3374 | |
3375 | 3375 | /** |
3376 | 3376 | * This immediately generates any EE_Message ID's that are selected that are EEM_Message::status_incomplete |
3377 | - * However, this does not send immediately, it just queues for sending. |
|
3378 | - * |
|
3379 | - * @since 4.9.0 |
|
3380 | - */ |
|
3377 | + * However, this does not send immediately, it just queues for sending. |
|
3378 | + * |
|
3379 | + * @since 4.9.0 |
|
3380 | + */ |
|
3381 | 3381 | protected function _generate_now() { |
3382 | 3382 | $msg_ids = $this->_get_msg_ids_from_request(); |
3383 | 3383 | EED_Messages::generate_now( $msg_ids ); |
@@ -3388,11 +3388,11 @@ discard block |
||
3388 | 3388 | |
3389 | 3389 | /** |
3390 | 3390 | * This immediately generates AND sends any EE_Message's selected that are EEM_Message::status_incomplete or that are |
3391 | - * EEM_Message::status_resend or EEM_Message::status_idle |
|
3392 | - * |
|
3393 | - * @since 4.9.0 |
|
3394 | - * |
|
3395 | - */ |
|
3391 | + * EEM_Message::status_resend or EEM_Message::status_idle |
|
3392 | + * |
|
3393 | + * @since 4.9.0 |
|
3394 | + * |
|
3395 | + */ |
|
3396 | 3396 | protected function _generate_and_send_now() { |
3397 | 3397 | $this->_generate_now(); |
3398 | 3398 | $this->_send_now(); |
@@ -3405,9 +3405,9 @@ discard block |
||
3405 | 3405 | |
3406 | 3406 | /** |
3407 | 3407 | * This queues any EEM_Message::status_sent EE_Message ids in the request for resending. |
3408 | - * |
|
3409 | - * @since 4.9.0 |
|
3410 | - */ |
|
3408 | + * |
|
3409 | + * @since 4.9.0 |
|
3410 | + */ |
|
3411 | 3411 | protected function _queue_for_resending() { |
3412 | 3412 | $msg_ids = $this->_get_msg_ids_from_request(); |
3413 | 3413 | EED_Messages::queue_for_resending( $msg_ids ); |
@@ -3419,9 +3419,9 @@ discard block |
||
3419 | 3419 | |
3420 | 3420 | /** |
3421 | 3421 | * This sends immediately any EEM_Message::status_idle or EEM_Message::status_resend messages in the queue |
3422 | - * |
|
3423 | - * @since 4.9.0 |
|
3424 | - */ |
|
3422 | + * |
|
3423 | + * @since 4.9.0 |
|
3424 | + */ |
|
3425 | 3425 | protected function _send_now() { |
3426 | 3426 | $msg_ids = $this->_get_msg_ids_from_request(); |
3427 | 3427 | EED_Messages::send_now( $msg_ids ); |
@@ -3433,9 +3433,9 @@ discard block |
||
3433 | 3433 | |
3434 | 3434 | /** |
3435 | 3435 | * Deletes EE_messages for IDs in the request. |
3436 | - * |
|
3437 | - * @since 4.9.0 |
|
3438 | - */ |
|
3436 | + * |
|
3437 | + * @since 4.9.0 |
|
3438 | + */ |
|
3439 | 3439 | protected function _delete_ee_messages() { |
3440 | 3440 | $msg_ids = $this->_get_msg_ids_from_request(); |
3441 | 3441 | $deleted_count = 0; |
@@ -3464,9 +3464,9 @@ discard block |
||
3464 | 3464 | |
3465 | 3465 | /** |
3466 | 3466 | * This looks for 'MSG_ID' key in the request and returns an array of MSG_ID's if present. |
3467 | - * @since 4.9.0 |
|
3468 | - * @return array |
|
3469 | - */ |
|
3467 | + * @since 4.9.0 |
|
3468 | + * @return array |
|
3469 | + */ |
|
3470 | 3470 | protected function _get_msg_ids_from_request() { |
3471 | 3471 | if ( ! isset( $this->_req_data['MSG_ID'] ) ) { |
3472 | 3472 | return array(); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | - {exit('NO direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
2 | + {exit('NO direct script access allowed'); } |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * @param bool $routing |
74 | 74 | */ |
75 | - public function __construct( $routing = true ) { |
|
75 | + public function __construct($routing = true) { |
|
76 | 76 | //make sure messages autoloader is running |
77 | 77 | EED_Messages::set_autoloaders(); |
78 | - parent::__construct( $routing ); |
|
78 | + parent::__construct($routing); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array(); |
91 | 91 | |
92 | - $this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : null; |
|
92 | + $this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null; |
|
93 | 93 | $this->_load_message_resource_manager(); |
94 | 94 | } |
95 | 95 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @throws EE_Error |
104 | 104 | */ |
105 | 105 | protected function _load_message_resource_manager() { |
106 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
106 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function get_messengers_for_list_table() { |
118 | 118 | $m_values = array(); |
119 | - $active_messengers = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_messenger' ) ); |
|
119 | + $active_messengers = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger')); |
|
120 | 120 | //setup messengers for selects |
121 | 121 | $i = 1; |
122 | - foreach ( $active_messengers as $active_messenger ) { |
|
123 | - if ( $active_messenger instanceof EE_Message ) { |
|
124 | - $m_values[ $i ]['id'] = $active_messenger->messenger(); |
|
125 | - $m_values[ $i ]['text'] = ucwords( $active_messenger->messenger_label() ); |
|
122 | + foreach ($active_messengers as $active_messenger) { |
|
123 | + if ($active_messenger instanceof EE_Message) { |
|
124 | + $m_values[$i]['id'] = $active_messenger->messenger(); |
|
125 | + $m_values[$i]['text'] = ucwords($active_messenger->messenger_label()); |
|
126 | 126 | $i++; |
127 | 127 | } |
128 | 128 | } |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function get_message_types_for_list_table() { |
141 | 141 | $mt_values = array(); |
142 | - $active_messages = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_message_type' ) ); |
|
142 | + $active_messages = EEM_Message::instance()->get_all(array('group_by' => 'MSG_message_type')); |
|
143 | 143 | $i = 1; |
144 | - foreach ( $active_messages as $active_message ) { |
|
145 | - if ( $active_message instanceof EE_Message ) { |
|
146 | - $mt_values[ $i ]['id'] = $active_message->message_type(); |
|
147 | - $mt_values[ $i ]['text'] = ucwords( $active_message->message_type_label() ); |
|
144 | + foreach ($active_messages as $active_message) { |
|
145 | + if ($active_message instanceof EE_Message) { |
|
146 | + $mt_values[$i]['id'] = $active_message->message_type(); |
|
147 | + $mt_values[$i]['text'] = ucwords($active_message->message_type_label()); |
|
148 | 148 | $i++; |
149 | 149 | } |
150 | 150 | } |
@@ -161,14 +161,14 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function get_contexts_for_message_types_for_list_table() { |
163 | 163 | $contexts = array(); |
164 | - $active_message_contexts = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_context' ) ); |
|
165 | - foreach ( $active_message_contexts as $active_message ) { |
|
166 | - if ( $active_message instanceof EE_Message ) { |
|
164 | + $active_message_contexts = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context')); |
|
165 | + foreach ($active_message_contexts as $active_message) { |
|
166 | + if ($active_message instanceof EE_Message) { |
|
167 | 167 | $message_type = $active_message->message_type_object(); |
168 | - if ( $message_type instanceof EE_message_type ) { |
|
168 | + if ($message_type instanceof EE_message_type) { |
|
169 | 169 | $message_type_contexts = $message_type->get_contexts(); |
170 | - foreach ( $message_type_contexts as $context => $context_details ) { |
|
171 | - $contexts[ $context ] = $context_details['label']; |
|
170 | + foreach ($message_type_contexts as $context => $context_details) { |
|
171 | + $contexts[$context] = $context_details['label']; |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | |
180 | 180 | |
181 | 181 | protected function _ajax_hooks() { |
182 | - add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) ); |
|
183 | - add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') ); |
|
184 | - add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') ); |
|
185 | - add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) ); |
|
186 | - add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) ); |
|
182 | + add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle')); |
|
183 | + add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle')); |
|
184 | + add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings')); |
|
185 | + add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form')); |
|
186 | + add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack')); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | * @return void |
216 | 216 | */ |
217 | 217 | protected function _set_page_routes() { |
218 | - $grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] ) |
|
218 | + $grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID']) |
|
219 | 219 | ? $this->_req_data['GRP_ID'] |
220 | 220 | : 0; |
221 | - $grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] ) |
|
221 | + $grp_id = empty($grp_id) && ! empty($this->_req_data['id']) |
|
222 | 222 | ? $this->_req_data['id'] |
223 | 223 | : $grp_id; |
224 | - $msg_id = ! empty( $this->_req_data['MSG_ID'] ) && ! is_array( $this->_req_data['MSG_ID'] ) |
|
224 | + $msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID']) |
|
225 | 225 | ? $this->_req_data['MSG_ID'] |
226 | 226 | : 0; |
227 | 227 | |
@@ -263,35 +263,35 @@ discard block |
||
263 | 263 | 'insert_message_template' => array( |
264 | 264 | 'func' => '_insert_or_update_message_template', |
265 | 265 | 'capability' => 'ee_edit_messages', |
266 | - 'args' => array( 'new_template' => true ), |
|
266 | + 'args' => array('new_template' => true), |
|
267 | 267 | 'noheader' => true |
268 | 268 | ), |
269 | 269 | 'update_message_template' => array( |
270 | 270 | 'func' => '_insert_or_update_message_template', |
271 | 271 | 'capability' => 'ee_edit_message', |
272 | 272 | 'obj_id' => $grp_id, |
273 | - 'args' => array( 'new_template' => false ), |
|
273 | + 'args' => array('new_template' => false), |
|
274 | 274 | 'noheader' => true |
275 | 275 | ), |
276 | 276 | 'trash_message_template' => array( |
277 | 277 | 'func' => '_trash_or_restore_message_template', |
278 | 278 | 'capability' => 'ee_delete_message', |
279 | 279 | 'obj_id' => $grp_id, |
280 | - 'args' => array( 'trash' => true, 'all' => true ), |
|
280 | + 'args' => array('trash' => true, 'all' => true), |
|
281 | 281 | 'noheader' => true |
282 | 282 | ), |
283 | 283 | 'trash_message_template_context' => array( |
284 | 284 | 'func' => '_trash_or_restore_message_template', |
285 | 285 | 'capability' => 'ee_delete_message', |
286 | 286 | 'obj_id' => $grp_id, |
287 | - 'args' => array( 'trash' => true ), |
|
287 | + 'args' => array('trash' => true), |
|
288 | 288 | 'noheader' => true |
289 | 289 | ), |
290 | 290 | 'restore_message_template' => array( |
291 | 291 | 'func' => '_trash_or_restore_message_template', |
292 | 292 | 'capability' => 'ee_delete_message', |
293 | 293 | 'obj_id' => $grp_id, |
294 | - 'args' => array( 'trash' => false, 'all' => true ), |
|
294 | + 'args' => array('trash' => false, 'all' => true), |
|
295 | 295 | 'noheader' => true |
296 | 296 | ), |
297 | 297 | 'restore_message_template_context' => array( |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | 'filename' => 'messages_overview_other', |
411 | 411 | ), |
412 | 412 | ), |
413 | - 'help_tour' => array( 'Messages_Overview_Help_Tour' ), |
|
413 | + 'help_tour' => array('Messages_Overview_Help_Tour'), |
|
414 | 414 | 'require_nonce' => false |
415 | 415 | ), |
416 | 416 | 'custom_mtps' => array( |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | ), |
446 | 446 | 'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'), |
447 | 447 | 'has_metaboxes' => true, |
448 | - 'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ), |
|
448 | + 'help_tour' => array('Message_Templates_Edit_Help_Tour'), |
|
449 | 449 | 'help_tabs' => array( |
450 | 450 | 'edit_message_template' => array( |
451 | 451 | 'title' => __('Message Template Editor', 'event_espresso'), |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | 'filename' => 'messages_settings_messengers' |
502 | 502 | ), |
503 | 503 | ), |
504 | - 'help_tour' => array( 'Messages_Settings_Help_Tour' ), |
|
504 | + 'help_tour' => array('Messages_Settings_Help_Tour'), |
|
505 | 505 | 'require_nonce' => false |
506 | 506 | ) |
507 | 507 | ); |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | |
535 | 535 | |
536 | 536 | protected function _add_screen_options_default() { |
537 | - $this->_admin_page_title = __( 'Message Activity', 'event_espresso' ); |
|
537 | + $this->_admin_page_title = __('Message Activity', 'event_espresso'); |
|
538 | 538 | $this->_per_page_screen_option(); |
539 | 539 | } |
540 | 540 | |
@@ -556,37 +556,37 @@ discard block |
||
556 | 556 | |
557 | 557 | |
558 | 558 | public function messages_help_tab() { |
559 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php' ); |
|
559 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php'); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | |
563 | 563 | public function messengers_help_tab() { |
564 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php' ); |
|
564 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php'); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | |
568 | 568 | public function message_types_help_tab() { |
569 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php' ); |
|
569 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php'); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | |
573 | 573 | public function messages_overview_help_tab() { |
574 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php' ); |
|
574 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php'); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | |
578 | 578 | public function message_templates_help_tab() { |
579 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php' ); |
|
579 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php'); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | |
583 | 583 | public function edit_message_template_help_tab() { |
584 | - $args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />'; |
|
585 | - $args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />'; |
|
586 | - $args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />'; |
|
587 | - $args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />'; |
|
588 | - $args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />'; |
|
589 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
584 | + $args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />'; |
|
585 | + $args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />'; |
|
586 | + $args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />'; |
|
587 | + $args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />'; |
|
588 | + $args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />'; |
|
589 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | |
@@ -594,22 +594,22 @@ discard block |
||
594 | 594 | public function message_template_shortcodes_help_tab() { |
595 | 595 | $this->_set_shortcodes(); |
596 | 596 | $args['shortcodes'] = $this->_shortcodes; |
597 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', $args ); |
|
597 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', $args); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | |
601 | 601 | |
602 | 602 | public function preview_message_help_tab() { |
603 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php' ); |
|
603 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php'); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | |
607 | 607 | public function settings_help_tab() { |
608 | - $args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'; |
|
609 | - $args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'; |
|
608 | + $args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />'; |
|
609 | + $args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />'; |
|
610 | 610 | $args['img3'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked"><label for="ee-on-off-toggle-on"></label>'; |
611 | 611 | $args['img4'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox"><label for="ee-on-off-toggle-on"></label>'; |
612 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args); |
|
612 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | |
@@ -617,31 +617,31 @@ discard block |
||
617 | 617 | |
618 | 618 | |
619 | 619 | public function load_scripts_styles() { |
620 | - wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION ); |
|
620 | + wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION); |
|
621 | 621 | wp_enqueue_style('espresso_ee_msg'); |
622 | 622 | |
623 | - wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true ); |
|
624 | - wp_register_script( 'ee-msg-list-table-js', EE_MSG_ASSETS_URL. 'ee_message_admin_list_table.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION ); |
|
623 | + wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL.'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true); |
|
624 | + wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | |
628 | 628 | |
629 | 629 | public function load_scripts_styles_default() { |
630 | - wp_enqueue_script( 'ee-msg-list-table-js' ); |
|
630 | + wp_enqueue_script('ee-msg-list-table-js'); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | |
634 | 634 | |
635 | 635 | |
636 | 636 | |
637 | - public function wp_editor_css( $mce_css ) { |
|
637 | + public function wp_editor_css($mce_css) { |
|
638 | 638 | //if we're on the edit_message_template route |
639 | - if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger ) { |
|
639 | + if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) { |
|
640 | 640 | $message_type_name = $this->_active_message_type_name; |
641 | 641 | |
642 | 642 | //we're going to REPLACE the existing mce css |
643 | 643 | //we need to get the css file location from the active messenger |
644 | - $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation ); |
|
644 | + $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | return $mce_css; |
@@ -659,15 +659,15 @@ discard block |
||
659 | 659 | $this->_message_template_group->messenger_obj()->label['singular'], |
660 | 660 | $this->_message_template_group->message_type_obj()->label['singular'] |
661 | 661 | ); |
662 | - EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded. Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso' ); |
|
662 | + EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded. Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso'); |
|
663 | 663 | |
664 | - wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION ); |
|
664 | + wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION); |
|
665 | 665 | |
666 | 666 | wp_enqueue_script('ee_admin_js'); |
667 | 667 | wp_enqueue_script('ee_msgs_edit_js'); |
668 | 668 | |
669 | 669 | //add in special css for tiny_mce |
670 | - add_filter( 'mce_css', array( $this, 'wp_editor_css' ) ); |
|
670 | + add_filter('mce_css', array($this, 'wp_editor_css')); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | |
@@ -676,22 +676,22 @@ discard block |
||
676 | 676 | |
677 | 677 | $this->_set_message_template_group(); |
678 | 678 | |
679 | - if ( isset( $this->_req_data['messenger'] ) ) { |
|
680 | - $this->_active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
679 | + if (isset($this->_req_data['messenger'])) { |
|
680 | + $this->_active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
681 | 681 | } |
682 | 682 | |
683 | - $message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : ''; |
|
683 | + $message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : ''; |
|
684 | 684 | |
685 | 685 | |
686 | - wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, true, 'preview', $this->_variation ) ); |
|
686 | + wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'preview', $this->_variation)); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | |
690 | 690 | |
691 | 691 | public function load_scripts_styles_settings() { |
692 | - wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION ); |
|
693 | - wp_enqueue_style( 'ee-text-links' ); |
|
694 | - wp_enqueue_style( 'ee-message-settings' ); |
|
692 | + wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION); |
|
693 | + wp_enqueue_style('ee-text-links'); |
|
694 | + wp_enqueue_style('ee-message-settings'); |
|
695 | 695 | |
696 | 696 | wp_enqueue_script('ee-messages-settings'); |
697 | 697 | } |
@@ -721,40 +721,40 @@ discard block |
||
721 | 721 | * set views array for message queue list table |
722 | 722 | */ |
723 | 723 | public function _set_list_table_views_default() { |
724 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
724 | + EE_Registry::instance()->load_helper('Template'); |
|
725 | 725 | |
726 | - $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' ) |
|
726 | + $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'message_list_table_bulk_actions') |
|
727 | 727 | ? array( |
728 | - 'generate_now' => __( 'Generate Now', 'event_espresso' ), |
|
729 | - 'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ), |
|
730 | - 'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ), |
|
731 | - 'send_now' => __( 'Send Now', 'event_espresso' ) |
|
728 | + 'generate_now' => __('Generate Now', 'event_espresso'), |
|
729 | + 'generate_and_send_now' => __('Generate and Send Now', 'event_espresso'), |
|
730 | + 'queue_for_resending' => __('Queue for Resending', 'event_espresso'), |
|
731 | + 'send_now' => __('Send Now', 'event_espresso') |
|
732 | 732 | ) |
733 | 733 | : array(); |
734 | 734 | |
735 | - $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'message_list_table_bulk_actions' ) |
|
736 | - ? array( 'delete_ee_messages' => __( 'Delete Messages', 'event_espresso' ) ) |
|
735 | + $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'message_list_table_bulk_actions') |
|
736 | + ? array('delete_ee_messages' => __('Delete Messages', 'event_espresso')) |
|
737 | 737 | : array(); |
738 | 738 | |
739 | 739 | |
740 | 740 | $this->_views = array( |
741 | 741 | 'all' => array( |
742 | 742 | 'slug' => 'all', |
743 | - 'label' => __( 'All', 'event_espresso' ), |
|
743 | + 'label' => __('All', 'event_espresso'), |
|
744 | 744 | 'count' => 0, |
745 | - 'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action ) |
|
745 | + 'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action) |
|
746 | 746 | ) |
747 | 747 | ); |
748 | 748 | |
749 | 749 | |
750 | - foreach ( EEM_Message::instance()->all_statuses() as $status ) { |
|
751 | - if ( $status === EEM_Message::status_debug_only && ! EEM_Message::debug() ) { |
|
750 | + foreach (EEM_Message::instance()->all_statuses() as $status) { |
|
751 | + if ($status === EEM_Message::status_debug_only && ! EEM_Message::debug()) { |
|
752 | 752 | continue; |
753 | 753 | } |
754 | 754 | $status_bulk_actions = $common_bulk_actions; |
755 | 755 | //unset bulk actions not applying to status |
756 | - if ( ! empty( $status_bulk_actions ) ) { |
|
757 | - switch ( $status ) { |
|
756 | + if ( ! empty($status_bulk_actions)) { |
|
757 | + switch ($status) { |
|
758 | 758 | case EEM_Message::status_idle : |
759 | 759 | case EEM_Message::status_resend : |
760 | 760 | $status_bulk_actions['send_now'] = $common_bulk_actions['send_now']; |
@@ -766,21 +766,21 @@ discard block |
||
766 | 766 | break; |
767 | 767 | |
768 | 768 | case EEM_Message::status_incomplete : |
769 | - unset( $status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now'] ); |
|
769 | + unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']); |
|
770 | 770 | break; |
771 | 771 | |
772 | 772 | case EEM_Message::status_retry : |
773 | 773 | case EEM_Message::status_sent : |
774 | - unset( $status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now'] ); |
|
774 | + unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']); |
|
775 | 775 | break; |
776 | 776 | } |
777 | 777 | } |
778 | 778 | |
779 | - $this->_views[ strtolower( $status ) ] = array( |
|
780 | - 'slug' => strtolower( $status ), |
|
781 | - 'label' => EEH_Template::pretty_status( $status, false, 'sentence' ), |
|
779 | + $this->_views[strtolower($status)] = array( |
|
780 | + 'slug' => strtolower($status), |
|
781 | + 'label' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
782 | 782 | 'count' => 0, |
783 | - 'bulk_action' => array_merge( $status_bulk_actions, $delete_bulk_action ) |
|
783 | + 'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action) |
|
784 | 784 | ); |
785 | 785 | } |
786 | 786 | } |
@@ -799,8 +799,8 @@ discard block |
||
799 | 799 | protected function _message_queue_list_table() { |
800 | 800 | $this->_search_btn_label = __('Message Activity', 'event_espresso'); |
801 | 801 | $this->_template_args['per_column'] = 6; |
802 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_message_legend_items() ); |
|
803 | - $this->_template_args['before_list_table'] = '<h3>' . EEM_Message::instance()->get_pretty_label_for_results() . '</h3>'; |
|
802 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items()); |
|
803 | + $this->_template_args['before_list_table'] = '<h3>'.EEM_Message::instance()->get_pretty_label_for_results().'</h3>'; |
|
804 | 804 | $this->display_admin_list_table_page_with_no_sidebar(); |
805 | 805 | } |
806 | 806 | |
@@ -813,8 +813,8 @@ discard block |
||
813 | 813 | $action_css_classes = EEH_MSG_Template::get_message_action_icons(); |
814 | 814 | $action_items = array(); |
815 | 815 | |
816 | - foreach( $action_css_classes as $action_item => $action_details ) { |
|
817 | - if ( $action_item === 'see_notifications_for' ) { |
|
816 | + foreach ($action_css_classes as $action_item => $action_details) { |
|
817 | + if ($action_item === 'see_notifications_for') { |
|
818 | 818 | continue; |
819 | 819 | } |
820 | 820 | $action_items[$action_item] = array( |
@@ -826,37 +826,37 @@ discard block |
||
826 | 826 | /** @type array $status_items status legend setup*/ |
827 | 827 | $status_items = array( |
828 | 828 | 'sent_status' => array( |
829 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent, |
|
830 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_sent, false, 'sentence' ) |
|
829 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent, |
|
830 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence') |
|
831 | 831 | ), |
832 | 832 | 'idle_status' => array( |
833 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle, |
|
834 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_idle, false, 'sentence' ) |
|
833 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle, |
|
834 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence') |
|
835 | 835 | ), |
836 | 836 | 'failed_status' => array( |
837 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed, |
|
838 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_failed, false, 'sentence' ) |
|
837 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed, |
|
838 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence') |
|
839 | 839 | ), |
840 | 840 | 'resend_status' => array( |
841 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend, |
|
842 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_resend, false, 'sentence' ) |
|
841 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend, |
|
842 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence') |
|
843 | 843 | ), |
844 | 844 | 'incomplete_status' => array( |
845 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete, |
|
846 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_incomplete, false, 'sentence' ) |
|
845 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete, |
|
846 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence') |
|
847 | 847 | ), |
848 | 848 | 'retry_status' => array( |
849 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry, |
|
850 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_retry, false, 'sentence' ) |
|
849 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry, |
|
850 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence') |
|
851 | 851 | ) |
852 | 852 | ); |
853 | - if ( EEM_Message::debug() ) { |
|
853 | + if (EEM_Message::debug()) { |
|
854 | 854 | $status_items['debug_only_status'] = array( |
855 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_debug_only, |
|
856 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_debug_only, false, 'sentence' ) |
|
855 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_debug_only, |
|
856 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence') |
|
857 | 857 | ); |
858 | 858 | } |
859 | - return array_merge( $action_items, $status_items ); |
|
859 | + return array_merge($action_items, $status_items); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | |
@@ -866,9 +866,9 @@ discard block |
||
866 | 866 | |
867 | 867 | protected function _custom_mtps_preview() { |
868 | 868 | $this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso'); |
869 | - $this->_template_args['preview_img'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png" alt="' . esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso' ) . '" />'; |
|
869 | + $this->_template_args['preview_img'] = '<img src="'.EE_MSG_ASSETS_URL.'images/custom_mtps_preview.png" alt="'.esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso').'" />'; |
|
870 | 870 | $this->_template_args['preview_text'] = '<strong>'.__('Custom Message Templates is a feature that is only available in the caffeinated version of Event Espresso. With the Custom Message Templates feature, you are able to create custom templates and set them per event.', 'event_espresso').'</strong>'; |
871 | - $this->display_admin_caf_preview_page( 'custom_message_types', false ); |
|
871 | + $this->display_admin_caf_preview_page('custom_message_types', false); |
|
872 | 872 | } |
873 | 873 | |
874 | 874 | |
@@ -892,31 +892,31 @@ discard block |
||
892 | 892 | * |
893 | 893 | * @return array |
894 | 894 | */ |
895 | - public function get_message_templates( $perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true ) { |
|
895 | + public function get_message_templates($perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true) { |
|
896 | 896 | |
897 | 897 | $MTP = EEM_Message_Template_Group::instance(); |
898 | 898 | |
899 | 899 | $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby']; |
900 | 900 | $orderby = $this->_req_data['orderby']; |
901 | 901 | |
902 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC'; |
|
902 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
903 | 903 | |
904 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
905 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage; |
|
904 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
905 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage; |
|
906 | 906 | |
907 | - $offset = ($current_page-1)*$per_page; |
|
908 | - $limit = $all ? null : array( $offset, $per_page ); |
|
907 | + $offset = ($current_page - 1) * $per_page; |
|
908 | + $limit = $all ? null : array($offset, $per_page); |
|
909 | 909 | |
910 | 910 | |
911 | 911 | //options will match what is in the _views array property |
912 | - switch( $type ) { |
|
912 | + switch ($type) { |
|
913 | 913 | |
914 | 914 | case 'in_use': |
915 | - $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true ); |
|
915 | + $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true); |
|
916 | 916 | break; |
917 | 917 | |
918 | 918 | default: |
919 | - $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global ); |
|
919 | + $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global); |
|
920 | 920 | |
921 | 921 | } |
922 | 922 | |
@@ -935,8 +935,8 @@ discard block |
||
935 | 935 | $installed_message_types = $this->_message_resource_manager->installed_message_types(); |
936 | 936 | $installed = array(); |
937 | 937 | |
938 | - foreach ( $installed_message_types as $message_type ) { |
|
939 | - $installed[ $message_type->name ] = $message_type; |
|
938 | + foreach ($installed_message_types as $message_type) { |
|
939 | + $installed[$message_type->name] = $message_type; |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | return $installed; |
@@ -955,24 +955,24 @@ discard block |
||
955 | 955 | * |
956 | 956 | * @throws EE_error |
957 | 957 | */ |
958 | - protected function _add_message_template( $message_type = '', $messenger='', $GRP_ID = '' ) { |
|
958 | + protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') { |
|
959 | 959 | //set values override any request data |
960 | - $message_type = !empty( $message_type ) ? $message_type : ''; |
|
961 | - $message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type; |
|
960 | + $message_type = ! empty($message_type) ? $message_type : ''; |
|
961 | + $message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type; |
|
962 | 962 | |
963 | - $messenger = !empty( $messenger ) ? $messenger : ''; |
|
964 | - $messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger; |
|
963 | + $messenger = ! empty($messenger) ? $messenger : ''; |
|
964 | + $messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger; |
|
965 | 965 | |
966 | - $GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : ''; |
|
967 | - $GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
966 | + $GRP_ID = ! empty($GRP_ID) ? $GRP_ID : ''; |
|
967 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
968 | 968 | |
969 | 969 | //we need messenger and message type. They should be coming from the event editor. If not here then return error |
970 | - if ( empty( $message_type ) || empty( $messenger ) ) |
|
971 | - {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));} |
|
970 | + if (empty($message_type) || empty($messenger)) |
|
971 | + {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso')); } |
|
972 | 972 | |
973 | 973 | //we need the GRP_ID for the template being used as the base for the new template |
974 | - if ( empty( $GRP_ID ) ) |
|
975 | - {throw new EE_Error( __('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso' ) );} |
|
974 | + if (empty($GRP_ID)) |
|
975 | + {throw new EE_Error(__('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso')); } |
|
976 | 976 | |
977 | 977 | //let's just make sure the template gets generated! |
978 | 978 | |
@@ -993,8 +993,8 @@ discard block |
||
993 | 993 | * @param int $GRP_ID GRP_ID for the related message template group this new template will be based |
994 | 994 | * off of. |
995 | 995 | */ |
996 | - public function add_message_template( $message_type, $messenger, $GRP_ID ) { |
|
997 | - $this->_add_message_template( $message_type, $messenger, $GRP_ID ); |
|
996 | + public function add_message_template($message_type, $messenger, $GRP_ID) { |
|
997 | + $this->_add_message_template($message_type, $messenger, $GRP_ID); |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | |
@@ -1005,14 +1005,14 @@ discard block |
||
1005 | 1005 | * @return void |
1006 | 1006 | */ |
1007 | 1007 | protected function _edit_message_template() { |
1008 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1008 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1009 | 1009 | $template_fields = ''; |
1010 | 1010 | $sidebar_fields = ''; |
1011 | 1011 | //we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates. |
1012 | - add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 ); |
|
1012 | + add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2); |
|
1013 | 1013 | |
1014 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) |
|
1015 | - ? absint( $this->_req_data['id'] ) |
|
1014 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) |
|
1015 | + ? absint($this->_req_data['id']) |
|
1016 | 1016 | : false; |
1017 | 1017 | |
1018 | 1018 | $this->_set_shortcodes(); //this also sets the _message_template property. |
@@ -1020,20 +1020,20 @@ discard block |
||
1020 | 1020 | $c_label = $message_template_group->context_label(); |
1021 | 1021 | $c_config = $message_template_group->contexts_config(); |
1022 | 1022 | |
1023 | - reset( $c_config ); |
|
1024 | - $context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] ) |
|
1023 | + reset($c_config); |
|
1024 | + $context = isset($this->_req_data['context']) && ! empty($this->_req_data['context']) |
|
1025 | 1025 | ? strtolower($this->_req_data['context']) |
1026 | 1026 | : key($c_config); |
1027 | 1027 | |
1028 | 1028 | |
1029 | - if ( empty($GRP_ID) ) { |
|
1029 | + if (empty($GRP_ID)) { |
|
1030 | 1030 | $action = 'insert_message_template'; |
1031 | 1031 | //$button_both = false; |
1032 | 1032 | //$button_text = array( __( 'Save','event_espresso') ); |
1033 | 1033 | //$button_actions = array('something_different'); |
1034 | 1034 | //$referrer = false; |
1035 | 1035 | $edit_message_template_form_url = add_query_arg( |
1036 | - array( 'action' => $action, 'noheader' => true ), |
|
1036 | + array('action' => $action, 'noheader' => true), |
|
1037 | 1037 | EE_MSG_ADMIN_URL |
1038 | 1038 | ); |
1039 | 1039 | } else { |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | //$button_actions = array(); |
1044 | 1044 | //$referrer = $this->_admin_base_url; |
1045 | 1045 | $edit_message_template_form_url = add_query_arg( |
1046 | - array( 'action' => $action, 'noheader' => true ), |
|
1046 | + array('action' => $action, 'noheader' => true), |
|
1047 | 1047 | EE_MSG_ADMIN_URL |
1048 | 1048 | ); |
1049 | 1049 | } |
@@ -1057,14 +1057,14 @@ discard block |
||
1057 | 1057 | |
1058 | 1058 | //Do we have any validation errors? |
1059 | 1059 | $validators = $this->_get_transient(); |
1060 | - $v_fields = !empty($validators) ? array_keys($validators) : array(); |
|
1060 | + $v_fields = ! empty($validators) ? array_keys($validators) : array(); |
|
1061 | 1061 | |
1062 | 1062 | |
1063 | 1063 | //we need to assemble the title from Various details |
1064 | 1064 | $context_label = sprintf( |
1065 | 1065 | __('(%s %s)', 'event_espresso'), |
1066 | 1066 | $c_config[$context]['label'], |
1067 | - ucwords($c_label['label'] ) |
|
1067 | + ucwords($c_label['label']) |
|
1068 | 1068 | ); |
1069 | 1069 | |
1070 | 1070 | $title = sprintf( |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | $message_template_group->message_type() |
1086 | 1086 | ); |
1087 | 1087 | |
1088 | - if ( !$template_field_structure ) { |
|
1088 | + if ( ! $template_field_structure) { |
|
1089 | 1089 | $template_field_structure = false; |
1090 | 1090 | $template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso'); |
1091 | 1091 | } |
@@ -1095,51 +1095,51 @@ discard block |
||
1095 | 1095 | |
1096 | 1096 | |
1097 | 1097 | //if we have the extra key.. then we need to remove the content index from the template_field_structure as it will get handled in the "extra" array. |
1098 | - if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) { |
|
1099 | - foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) { |
|
1100 | - unset( $template_field_structure[$context][$reference_field] ); |
|
1098 | + if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) { |
|
1099 | + foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) { |
|
1100 | + unset($template_field_structure[$context][$reference_field]); |
|
1101 | 1101 | } |
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | //let's loop through the template_field_structure and actually assemble the input fields! |
1105 | - if ( !empty($template_field_structure) ) { |
|
1106 | - foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) { |
|
1105 | + if ( ! empty($template_field_structure)) { |
|
1106 | + foreach ($template_field_structure[$context] as $template_field => $field_setup_array) { |
|
1107 | 1107 | //if this is an 'extra' template field then we need to remove any existing fields that are keyed up in the extra array and reset them. |
1108 | - if ( $template_field == 'extra' ) { |
|
1108 | + if ($template_field == 'extra') { |
|
1109 | 1109 | $this->_template_args['is_extra_fields'] = true; |
1110 | - foreach ( $field_setup_array as $reference_field => $new_fields_array ) { |
|
1111 | - $message_template = $message_templates[ $context ][ $reference_field ]; |
|
1110 | + foreach ($field_setup_array as $reference_field => $new_fields_array) { |
|
1111 | + $message_template = $message_templates[$context][$reference_field]; |
|
1112 | 1112 | $content = $message_template instanceof EE_Message_Template |
1113 | - ? $message_template->get( 'MTP_content' ) |
|
1113 | + ? $message_template->get('MTP_content') |
|
1114 | 1114 | : ''; |
1115 | - foreach ( $new_fields_array as $extra_field => $extra_array ) { |
|
1115 | + foreach ($new_fields_array as $extra_field => $extra_array) { |
|
1116 | 1116 | //let's verify if we need this extra field via the shortcodes parameter. |
1117 | 1117 | $continue = false; |
1118 | - if ( isset( $extra_array['shortcodes_required'] ) ) { |
|
1119 | - foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) { |
|
1120 | - if ( !array_key_exists( $shortcode, $this->_shortcodes ) ) |
|
1121 | - {$continue = true;} |
|
1118 | + if (isset($extra_array['shortcodes_required'])) { |
|
1119 | + foreach ((array) $extra_array['shortcodes_required'] as $shortcode) { |
|
1120 | + if ( ! array_key_exists($shortcode, $this->_shortcodes)) |
|
1121 | + {$continue = true; } |
|
1122 | 1122 | } |
1123 | - if ( $continue ) {continue;} |
|
1123 | + if ($continue) {continue; } |
|
1124 | 1124 | } |
1125 | 1125 | |
1126 | - $field_id = $reference_field . '-' . $extra_field . '-content'; |
|
1126 | + $field_id = $reference_field.'-'.$extra_field.'-content'; |
|
1127 | 1127 | $template_form_fields[$field_id] = $extra_array; |
1128 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']'; |
|
1129 | - $css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : ''; |
|
1128 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']'; |
|
1129 | + $css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : ''; |
|
1130 | 1130 | |
1131 | - $template_form_fields[$field_id]['css_class'] = ! empty( $v_fields ) |
|
1131 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
|
1132 | 1132 | && in_array($extra_field, $v_fields) |
1133 | 1133 | && |
1134 | 1134 | ( |
1135 | - is_array($validators[$extra_field] ) |
|
1136 | - && isset( $validators[$extra_field]['msg'] ) |
|
1135 | + is_array($validators[$extra_field]) |
|
1136 | + && isset($validators[$extra_field]['msg']) |
|
1137 | 1137 | ) |
1138 | - ? 'validate-error ' . $css_class |
|
1138 | + ? 'validate-error '.$css_class |
|
1139 | 1139 | : $css_class; |
1140 | 1140 | |
1141 | - $template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field]) |
|
1142 | - ? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") ) |
|
1141 | + $template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field]) |
|
1142 | + ? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8")) |
|
1143 | 1143 | : ''; |
1144 | 1144 | |
1145 | 1145 | //do we have a validation error? if we do then let's use that value instead |
@@ -1155,32 +1155,32 @@ discard block |
||
1155 | 1155 | $field_id |
1156 | 1156 | ); |
1157 | 1157 | |
1158 | - if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) { |
|
1158 | + if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') { |
|
1159 | 1159 | //we want to decode the entities |
1160 | 1160 | $template_form_fields[$field_id]['value'] = stripslashes( |
1161 | - html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") |
|
1161 | + html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") |
|
1162 | 1162 | ); |
1163 | 1163 | |
1164 | 1164 | }/**/ |
1165 | 1165 | } |
1166 | - $templatefield_MTP_id = $reference_field . '-MTP_ID'; |
|
1167 | - $templatefield_templatename_id = $reference_field . '-name'; |
|
1166 | + $templatefield_MTP_id = $reference_field.'-MTP_ID'; |
|
1167 | + $templatefield_templatename_id = $reference_field.'-name'; |
|
1168 | 1168 | |
1169 | 1169 | $template_form_fields[$templatefield_MTP_id] = array( |
1170 | - 'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]', |
|
1170 | + 'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]', |
|
1171 | 1171 | 'label' => null, |
1172 | 1172 | 'input' => 'hidden', |
1173 | 1173 | 'type' => 'int', |
1174 | 1174 | 'required' => false, |
1175 | 1175 | 'validation' => false, |
1176 | - 'value' => !empty($message_templates) ? $message_template->ID() : '', |
|
1176 | + 'value' => ! empty($message_templates) ? $message_template->ID() : '', |
|
1177 | 1177 | 'css_class' => '', |
1178 | 1178 | 'format' => '%d', |
1179 | 1179 | 'db-col' => 'MTP_ID' |
1180 | 1180 | ); |
1181 | 1181 | |
1182 | 1182 | $template_form_fields[$templatefield_templatename_id] = array( |
1183 | - 'name' => 'MTP_template_fields[' . $reference_field . '][name]', |
|
1183 | + 'name' => 'MTP_template_fields['.$reference_field.'][name]', |
|
1184 | 1184 | 'label' => null, |
1185 | 1185 | 'input' => 'hidden', |
1186 | 1186 | 'type' => 'string', |
@@ -1194,14 +1194,14 @@ discard block |
||
1194 | 1194 | } |
1195 | 1195 | continue; //skip the next stuff, we got the necessary fields here for this dataset. |
1196 | 1196 | } else { |
1197 | - $field_id = $template_field . '-content'; |
|
1197 | + $field_id = $template_field.'-content'; |
|
1198 | 1198 | $template_form_fields[$field_id] = $field_setup_array; |
1199 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]'; |
|
1200 | - $message_template = isset( $message_templates[ $context ][ $template_field ] ) |
|
1201 | - ? $message_templates[ $context ][ $template_field ] |
|
1199 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]'; |
|
1200 | + $message_template = isset($message_templates[$context][$template_field]) |
|
1201 | + ? $message_templates[$context][$template_field] |
|
1202 | 1202 | : null; |
1203 | - $template_form_fields[$field_id]['value'] = ! empty( $message_templates ) |
|
1204 | - && is_array( $message_templates[$context] ) |
|
1203 | + $template_form_fields[$field_id]['value'] = ! empty($message_templates) |
|
1204 | + && is_array($message_templates[$context]) |
|
1205 | 1205 | && $message_template instanceof EE_Message_Template |
1206 | 1206 | ? $message_template->get('MTP_content') |
1207 | 1207 | : ''; |
@@ -1214,10 +1214,10 @@ discard block |
||
1214 | 1214 | |
1215 | 1215 | $template_form_fields[$field_id]['db-col'] = 'MTP_content'; |
1216 | 1216 | $css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : ''; |
1217 | - $template_form_fields[$field_id]['css_class'] = ! empty( $v_fields ) |
|
1218 | - && in_array( $template_field, $v_fields ) |
|
1219 | - && isset( $validators[$template_field]['msg'] ) |
|
1220 | - ? 'validate-error ' . $css_class |
|
1217 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
|
1218 | + && in_array($template_field, $v_fields) |
|
1219 | + && isset($validators[$template_field]['msg']) |
|
1220 | + ? 'validate-error '.$css_class |
|
1221 | 1221 | : $css_class; |
1222 | 1222 | |
1223 | 1223 | //shortcode selector |
@@ -1228,12 +1228,12 @@ discard block |
||
1228 | 1228 | |
1229 | 1229 | //k took care of content field(s) now let's take care of others. |
1230 | 1230 | |
1231 | - $templatefield_MTP_id = $template_field . '-MTP_ID'; |
|
1232 | - $templatefield_field_templatename_id = $template_field . '-name'; |
|
1231 | + $templatefield_MTP_id = $template_field.'-MTP_ID'; |
|
1232 | + $templatefield_field_templatename_id = $template_field.'-name'; |
|
1233 | 1233 | |
1234 | 1234 | //foreach template field there are actually two form fields created |
1235 | 1235 | $template_form_fields[$templatefield_MTP_id] = array( |
1236 | - 'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]', |
|
1236 | + 'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]', |
|
1237 | 1237 | 'label' => null, |
1238 | 1238 | 'input' => 'hidden', |
1239 | 1239 | 'type' => 'int', |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | ); |
1247 | 1247 | |
1248 | 1248 | $template_form_fields[$templatefield_field_templatename_id] = array( |
1249 | - 'name' => 'MTP_template_fields[' . $template_field . '][name]', |
|
1249 | + 'name' => 'MTP_template_fields['.$template_field.'][name]', |
|
1250 | 1250 | 'label' => null, |
1251 | 1251 | 'input' => 'hidden', |
1252 | 1252 | 'type' => 'string', |
@@ -1390,13 +1390,13 @@ discard block |
||
1390 | 1390 | 'value' => $GRP_ID |
1391 | 1391 | ); |
1392 | 1392 | $sidebar_form_fields['ee-msg-evt-nonce'] = array( |
1393 | - 'name' => $action . '_nonce', |
|
1393 | + 'name' => $action.'_nonce', |
|
1394 | 1394 | 'input' => 'hidden', |
1395 | 1395 | 'type' => 'string', |
1396 | - 'value' => wp_create_nonce( $action . '_nonce') |
|
1396 | + 'value' => wp_create_nonce($action.'_nonce') |
|
1397 | 1397 | ); |
1398 | 1398 | |
1399 | - if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) { |
|
1399 | + if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) { |
|
1400 | 1400 | $sidebar_form_fields['ee-msg-template-switch'] = array( |
1401 | 1401 | 'name' => 'template_switch', |
1402 | 1402 | 'input' => 'hidden', |
@@ -1406,8 +1406,8 @@ discard block |
||
1406 | 1406 | } |
1407 | 1407 | |
1408 | 1408 | |
1409 | - $template_fields = $this->_generate_admin_form_fields( $template_form_fields ); |
|
1410 | - $sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields ); |
|
1409 | + $template_fields = $this->_generate_admin_form_fields($template_form_fields); |
|
1410 | + $sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields); |
|
1411 | 1411 | |
1412 | 1412 | |
1413 | 1413 | } //end if ( !empty($template_field_structure) ) |
@@ -1419,7 +1419,7 @@ discard block |
||
1419 | 1419 | $GRP_ID, |
1420 | 1420 | false, |
1421 | 1421 | add_query_arg( |
1422 | - array( 'action' => 'global_mtps' ), |
|
1422 | + array('action' => 'global_mtps'), |
|
1423 | 1423 | $this->_admin_base_url |
1424 | 1424 | ) |
1425 | 1425 | ); |
@@ -1435,7 +1435,7 @@ discard block |
||
1435 | 1435 | ), |
1436 | 1436 | $this->_admin_base_url |
1437 | 1437 | ); |
1438 | - $preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>'; |
|
1438 | + $preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>'; |
|
1439 | 1439 | |
1440 | 1440 | |
1441 | 1441 | //setup context switcher |
@@ -1463,17 +1463,17 @@ discard block |
||
1463 | 1463 | $this->_template_args['after_admin_page_content'] = $this->_add_form_element_after(); |
1464 | 1464 | |
1465 | 1465 | $this->_template_path = $this->_template_args['GRP_ID'] |
1466 | - ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php' |
|
1467 | - : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php'; |
|
1466 | + ? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php' |
|
1467 | + : EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php'; |
|
1468 | 1468 | |
1469 | 1469 | //send along EE_Message_Template_Group object for further template use. |
1470 | 1470 | $this->_template_args['MTP'] = $message_template_group; |
1471 | 1471 | |
1472 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, true ); |
|
1472 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, true); |
|
1473 | 1473 | |
1474 | 1474 | |
1475 | 1475 | //finally, let's set the admin_page title |
1476 | - $this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title ); |
|
1476 | + $this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title); |
|
1477 | 1477 | |
1478 | 1478 | |
1479 | 1479 | //we need to take care of setting the shortcodes property for use elsewhere. |
@@ -1486,7 +1486,7 @@ discard block |
||
1486 | 1486 | } |
1487 | 1487 | |
1488 | 1488 | |
1489 | - public function filter_tinymce_init( $mceInit, $editor_id ) { |
|
1489 | + public function filter_tinymce_init($mceInit, $editor_id) { |
|
1490 | 1490 | return $mceInit; |
1491 | 1491 | } |
1492 | 1492 | |
@@ -1497,7 +1497,7 @@ discard block |
||
1497 | 1497 | } |
1498 | 1498 | |
1499 | 1499 | public function _add_form_element_before() { |
1500 | - return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">'; |
|
1500 | + return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">'; |
|
1501 | 1501 | } |
1502 | 1502 | |
1503 | 1503 | public function _add_form_element_after() { |
@@ -1514,25 +1514,25 @@ discard block |
||
1514 | 1514 | * |
1515 | 1515 | */ |
1516 | 1516 | public function switch_template_pack() { |
1517 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1518 | - $template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : ''; |
|
1517 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1518 | + $template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : ''; |
|
1519 | 1519 | |
1520 | 1520 | //verify we have needed values. |
1521 | - if ( empty( $GRP_ID ) || empty( $template_pack ) ) { |
|
1521 | + if (empty($GRP_ID) || empty($template_pack)) { |
|
1522 | 1522 | $this->_template_args['error'] = true; |
1523 | - EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1523 | + EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1524 | 1524 | } else { |
1525 | 1525 | //get template, set the new template_pack and then reset to default |
1526 | 1526 | /** @type EE_Message_Template_Group $message_template_group */ |
1527 | - $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1527 | + $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1528 | 1528 | |
1529 | - $message_template_group->set_template_pack_name( $template_pack ); |
|
1529 | + $message_template_group->set_template_pack_name($template_pack); |
|
1530 | 1530 | $this->_req_data['msgr'] = $message_template_group->messenger(); |
1531 | 1531 | $this->_req_data['mt'] = $message_template_group->message_type(); |
1532 | 1532 | |
1533 | 1533 | $query_args = $this->_reset_to_default_template(); |
1534 | 1534 | |
1535 | - if ( empty( $query_args['id'] ) ) { |
|
1535 | + if (empty($query_args['id'])) { |
|
1536 | 1536 | EE_Error::add_error( |
1537 | 1537 | __( |
1538 | 1538 | 'Something went wrong with switching the template pack. Please try again or contact EE support', |
@@ -1542,7 +1542,7 @@ discard block |
||
1542 | 1542 | ); |
1543 | 1543 | $this->_template_args['error'] = true; |
1544 | 1544 | } else { |
1545 | - $template_label =$message_template_group->get_template_pack()->label; |
|
1545 | + $template_label = $message_template_group->get_template_pack()->label; |
|
1546 | 1546 | $template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels(); |
1547 | 1547 | EE_Error::add_success( |
1548 | 1548 | sprintf( |
@@ -1555,7 +1555,7 @@ discard block |
||
1555 | 1555 | ) |
1556 | 1556 | ); |
1557 | 1557 | //generate the redirect url for js. |
1558 | - $url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1558 | + $url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1559 | 1559 | $this->_template_args['data']['redirect_url'] = $url; |
1560 | 1560 | $this->_template_args['success'] = true; |
1561 | 1561 | } |
@@ -1577,9 +1577,9 @@ discard block |
||
1577 | 1577 | protected function _reset_to_default_template() { |
1578 | 1578 | |
1579 | 1579 | $templates = array(); |
1580 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1580 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1581 | 1581 | //we need to make sure we've got the info we need. |
1582 | - if ( ! isset( $this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'] ) ) { |
|
1582 | + if ( ! isset($this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'])) { |
|
1583 | 1583 | EE_Error::add_error( |
1584 | 1584 | __( |
1585 | 1585 | 'In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset. At least one of these is missing.', |
@@ -1591,9 +1591,9 @@ discard block |
||
1591 | 1591 | |
1592 | 1592 | // all templates will be reset to whatever the defaults are |
1593 | 1593 | // for the global template matching the messenger and message type. |
1594 | - $success = !empty( $GRP_ID ) ? true : false; |
|
1594 | + $success = ! empty($GRP_ID) ? true : false; |
|
1595 | 1595 | |
1596 | - if ( $success ) { |
|
1596 | + if ($success) { |
|
1597 | 1597 | |
1598 | 1598 | //let's first determine if the incoming template is a global template, |
1599 | 1599 | // if it isn't then we need to get the global template matching messenger and message type. |
@@ -1601,9 +1601,9 @@ discard block |
||
1601 | 1601 | |
1602 | 1602 | |
1603 | 1603 | //note this is ONLY deleting the template fields (Message Template rows) NOT the message template group. |
1604 | - $success = $this->_delete_mtp_permanently( $GRP_ID, false ); |
|
1604 | + $success = $this->_delete_mtp_permanently($GRP_ID, false); |
|
1605 | 1605 | |
1606 | - if ( $success ) { |
|
1606 | + if ($success) { |
|
1607 | 1607 | // if successfully deleted, lets generate the new ones. |
1608 | 1608 | // Note. We set GLOBAL to true, because resets on ANY template |
1609 | 1609 | // will use the related global template defaults for regeneration. |
@@ -1621,32 +1621,32 @@ discard block |
||
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | //any error messages? |
1624 | - if ( !$success ) { |
|
1624 | + if ( ! $success) { |
|
1625 | 1625 | EE_Error::add_error( |
1626 | - __( 'Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso' ), |
|
1626 | + __('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), |
|
1627 | 1627 | __FILE__, __FUNCTION__, __LINE__ |
1628 | 1628 | ); |
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | //all good, let's add a success message! |
1632 | - if ( $success && ! empty( $templates ) ) { |
|
1632 | + if ($success && ! empty($templates)) { |
|
1633 | 1633 | $templates = $templates[0]; //the info for the template we generated is the first element in the returned array. |
1634 | 1634 | EE_Error::overwrite_success(); |
1635 | - EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') ); |
|
1635 | + EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso')); |
|
1636 | 1636 | } |
1637 | 1637 | |
1638 | 1638 | |
1639 | 1639 | $query_args = array( |
1640 | - 'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : null, |
|
1641 | - 'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : null, |
|
1642 | - 'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'global_mtps' |
|
1640 | + 'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null, |
|
1641 | + 'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null, |
|
1642 | + 'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps' |
|
1643 | 1643 | ); |
1644 | 1644 | |
1645 | 1645 | //if called via ajax then we return query args otherwise redirect |
1646 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
1646 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
1647 | 1647 | return $query_args; |
1648 | 1648 | } else { |
1649 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
1649 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1650 | 1650 | return null; |
1651 | 1651 | } |
1652 | 1652 | } |
@@ -1659,7 +1659,7 @@ discard block |
||
1659 | 1659 | * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview. |
1660 | 1660 | * @return string |
1661 | 1661 | */ |
1662 | - public function _preview_message( $send = false ) { |
|
1662 | + public function _preview_message($send = false) { |
|
1663 | 1663 | //first make sure we've got the necessary parameters |
1664 | 1664 | if ( |
1665 | 1665 | ! isset( |
@@ -1675,13 +1675,13 @@ discard block |
||
1675 | 1675 | ); |
1676 | 1676 | } |
1677 | 1677 | |
1678 | - EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] ); |
|
1678 | + EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']); |
|
1679 | 1679 | |
1680 | 1680 | |
1681 | 1681 | //get the preview! |
1682 | - $preview = EED_Messages::preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send ); |
|
1682 | + $preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send); |
|
1683 | 1683 | |
1684 | - if ( $send ) { |
|
1684 | + if ($send) { |
|
1685 | 1685 | return $preview; |
1686 | 1686 | } |
1687 | 1687 | |
@@ -1691,22 +1691,22 @@ discard block |
||
1691 | 1691 | 'context' => $this->_req_data['context'], |
1692 | 1692 | 'action' => 'edit_message_template' |
1693 | 1693 | ); |
1694 | - $go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1695 | - $preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>'; |
|
1694 | + $go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1695 | + $preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>'; |
|
1696 | 1696 | $message_types = $this->get_installed_message_types(); |
1697 | - $active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
1697 | + $active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
1698 | 1698 | $active_messenger_label = $active_messenger instanceof EE_messenger |
1699 | - ? ucwords( $active_messenger->label['singular'] ) |
|
1700 | - : esc_html__( 'Unknown Messenger', 'event_espresso' ); |
|
1699 | + ? ucwords($active_messenger->label['singular']) |
|
1700 | + : esc_html__('Unknown Messenger', 'event_espresso'); |
|
1701 | 1701 | //let's provide a helpful title for context |
1702 | 1702 | $preview_title = sprintf( |
1703 | - __( 'Viewing Preview for %s %s Message Template', 'event_espresso' ), |
|
1703 | + __('Viewing Preview for %s %s Message Template', 'event_espresso'), |
|
1704 | 1704 | $active_messenger_label, |
1705 | - ucwords( $message_types[ $this->_req_data[ 'message_type' ] ]->label[ 'singular' ] ) |
|
1705 | + ucwords($message_types[$this->_req_data['message_type']]->label['singular']) |
|
1706 | 1706 | ); |
1707 | 1707 | //setup display of preview. |
1708 | 1708 | $this->_admin_page_title = $preview_title; |
1709 | - $this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview); |
|
1709 | + $this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview); |
|
1710 | 1710 | $this->_template_args['data']['force_json'] = true; |
1711 | 1711 | return ''; |
1712 | 1712 | } |
@@ -1736,9 +1736,9 @@ discard block |
||
1736 | 1736 | * @return void |
1737 | 1737 | */ |
1738 | 1738 | protected function _register_edit_meta_boxes() { |
1739 | - add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' ); |
|
1740 | - add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1741 | - add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1739 | + add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default'); |
|
1740 | + add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1741 | + add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1742 | 1742 | } |
1743 | 1743 | |
1744 | 1744 | |
@@ -1757,14 +1757,14 @@ discard block |
||
1757 | 1757 | |
1758 | 1758 | $tp_select_values = array(); |
1759 | 1759 | |
1760 | - foreach ( $tp_collection as $tp ) { |
|
1760 | + foreach ($tp_collection as $tp) { |
|
1761 | 1761 | //only include template packs that support this messenger and message type! |
1762 | 1762 | $supports = $tp->get_supports(); |
1763 | 1763 | if ( |
1764 | - ! isset( $supports[ $this->_message_template_group->messenger() ] ) |
|
1764 | + ! isset($supports[$this->_message_template_group->messenger()]) |
|
1765 | 1765 | || ! in_array( |
1766 | 1766 | $this->_message_template_group->message_type(), |
1767 | - $supports[ $this->_message_template_group->messenger() ] |
|
1767 | + $supports[$this->_message_template_group->messenger()] |
|
1768 | 1768 | ) |
1769 | 1769 | ) { |
1770 | 1770 | //not supported |
@@ -1778,7 +1778,7 @@ discard block |
||
1778 | 1778 | } |
1779 | 1779 | |
1780 | 1780 | //if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by the default template pack. This still allows for the odd template pack to override. |
1781 | - if ( empty( $tp_select_values ) ) { |
|
1781 | + if (empty($tp_select_values)) { |
|
1782 | 1782 | $tp_select_values[] = array( |
1783 | 1783 | 'text' => __('Default', 'event_espresso'), |
1784 | 1784 | 'id' => 'default' |
@@ -1791,14 +1791,14 @@ discard block |
||
1791 | 1791 | $this->_message_template_group->message_type() |
1792 | 1792 | ); |
1793 | 1793 | $variations_select_values = array(); |
1794 | - foreach ( $variations as $variation => $label ) { |
|
1794 | + foreach ($variations as $variation => $label) { |
|
1795 | 1795 | $variations_select_values[] = array( |
1796 | 1796 | 'text' => $label, |
1797 | 1797 | 'id' => $variation |
1798 | 1798 | ); |
1799 | 1799 | } |
1800 | 1800 | |
1801 | - $template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1801 | + $template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1802 | 1802 | |
1803 | 1803 | $template_args['template_packs_selector'] = EEH_Form_Fields::select_input( |
1804 | 1804 | 'MTP_template_pack', |
@@ -1815,9 +1815,9 @@ discard block |
||
1815 | 1815 | $template_args['template_pack_description'] = $template_pack_labels->template_pack_description; |
1816 | 1816 | $template_args['template_variation_description'] = $template_pack_labels->template_variation_description; |
1817 | 1817 | |
1818 | - $template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php'; |
|
1818 | + $template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php'; |
|
1819 | 1819 | |
1820 | - EEH_Template::display_template( $template, $template_args ); |
|
1820 | + EEH_Template::display_template($template, $template_args); |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | |
@@ -1848,47 +1848,47 @@ discard block |
||
1848 | 1848 | //first we need to see if there are any fields |
1849 | 1849 | $fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields(); |
1850 | 1850 | |
1851 | - if ( !empty( $fields ) ) { |
|
1851 | + if ( ! empty($fields)) { |
|
1852 | 1852 | //yup there be fields |
1853 | - foreach ( $fields as $field => $config ) { |
|
1854 | - $field_id = $this->_message_template_group->messenger() . '_' . $field; |
|
1853 | + foreach ($fields as $field => $config) { |
|
1854 | + $field_id = $this->_message_template_group->messenger().'_'.$field; |
|
1855 | 1855 | $existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings(); |
1856 | - $default = isset( $config['default'] ) ? $config['default'] : ''; |
|
1857 | - $default = isset( $config['value'] ) ? $config['value'] : $default; |
|
1856 | + $default = isset($config['default']) ? $config['default'] : ''; |
|
1857 | + $default = isset($config['value']) ? $config['value'] : $default; |
|
1858 | 1858 | |
1859 | 1859 | //if type is hidden and the value is empty something may have gone wrong so let's correct with the defaults |
1860 | 1860 | $fix = $config['input'] == 'hidden' && isset($existing[$field]) && empty($existing[$field]) ? $default : ''; |
1861 | - $existing[$field] = isset( $existing[$field] ) && empty( $fix ) ? $existing[$field] : $fix; |
|
1861 | + $existing[$field] = isset($existing[$field]) && empty($fix) ? $existing[$field] : $fix; |
|
1862 | 1862 | |
1863 | 1863 | $template_form_fields[$field_id] = array( |
1864 | - 'name' => 'test_settings_fld[' . $field . ']', |
|
1864 | + 'name' => 'test_settings_fld['.$field.']', |
|
1865 | 1865 | 'label' => $config['label'], |
1866 | 1866 | 'input' => $config['input'], |
1867 | 1867 | 'type' => $config['type'], |
1868 | 1868 | 'required' => $config['required'], |
1869 | 1869 | 'validation' => $config['validation'], |
1870 | - 'value' => isset( $existing[$field] ) ? $existing[$field] : $default, |
|
1870 | + 'value' => isset($existing[$field]) ? $existing[$field] : $default, |
|
1871 | 1871 | 'css_class' => $config['css_class'], |
1872 | - 'options' => isset( $config['options'] ) ? $config['options'] : array(), |
|
1872 | + 'options' => isset($config['options']) ? $config['options'] : array(), |
|
1873 | 1873 | 'default' => $default, |
1874 | 1874 | 'format' => $config['format'] |
1875 | 1875 | ); |
1876 | 1876 | } |
1877 | 1877 | } |
1878 | 1878 | |
1879 | - $test_settings_fields = !empty( $template_form_fields) |
|
1880 | - ? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' ) |
|
1879 | + $test_settings_fields = ! empty($template_form_fields) |
|
1880 | + ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds') |
|
1881 | 1881 | : ''; |
1882 | 1882 | |
1883 | 1883 | $test_settings_html = ''; |
1884 | 1884 | //print out $test_settings_fields |
1885 | - if ( !empty( $test_settings_fields ) ) { |
|
1885 | + if ( ! empty($test_settings_fields)) { |
|
1886 | 1886 | echo $test_settings_fields; |
1887 | - $test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="' . __('Test Send', 'event_espresso') . '" /><div style="clear:both"></div>'; |
|
1887 | + $test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="'.__('Test Send', 'event_espresso').'" /><div style="clear:both"></div>'; |
|
1888 | 1888 | } |
1889 | 1889 | |
1890 | 1890 | //and button |
1891 | - echo $test_settings_html . '<p>' . __('Need to reset this message type and start over?', 'event_espresso') . '</p>' . '<div class="publishing-action alignright resetbutton">' . $button . '</div><div style="clear:both"></div>'; |
|
1891 | + echo $test_settings_html.'<p>'.__('Need to reset this message type and start over?', 'event_espresso').'</p>'.'<div class="publishing-action alignright resetbutton">'.$button.'</div><div style="clear:both"></div>'; |
|
1892 | 1892 | } |
1893 | 1893 | |
1894 | 1894 | |
@@ -1903,13 +1903,13 @@ discard block |
||
1903 | 1903 | * @param string $linked_input_id The css id of the input that the shortcodes get added to. |
1904 | 1904 | * @return string |
1905 | 1905 | */ |
1906 | - protected function _get_shortcode_selector( $field, $linked_input_id ) { |
|
1906 | + protected function _get_shortcode_selector($field, $linked_input_id) { |
|
1907 | 1907 | $template_args = array( |
1908 | - 'shortcodes' => $this->_get_shortcodes( array( $field ), true ), |
|
1908 | + 'shortcodes' => $this->_get_shortcodes(array($field), true), |
|
1909 | 1909 | 'fieldname' => $field, |
1910 | 1910 | 'linked_input_id' => $linked_input_id |
1911 | 1911 | ); |
1912 | - return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true ); |
|
1912 | + return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true); |
|
1913 | 1913 | } |
1914 | 1914 | |
1915 | 1915 | |
@@ -1924,13 +1924,13 @@ discard block |
||
1924 | 1924 | $shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set |
1925 | 1925 | //$messenger = $this->_message_template_group->messenger_obj(); |
1926 | 1926 | //now let's set the content depending on the status of the shortcodes array |
1927 | - if ( empty( $shortcodes ) ) { |
|
1928 | - $content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>'; |
|
1927 | + if (empty($shortcodes)) { |
|
1928 | + $content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>'; |
|
1929 | 1929 | echo $content; |
1930 | 1930 | } else { |
1931 | 1931 | //$alt = 0; |
1932 | 1932 | ?> |
1933 | - <div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf( __('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso' ), '<span class="dashicons dashicons-menu"></span>' ); ?></p> |
|
1933 | + <div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf(__('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso'), '<span class="dashicons dashicons-menu"></span>'); ?></p> |
|
1934 | 1934 | <?php |
1935 | 1935 | } |
1936 | 1936 | |
@@ -1947,7 +1947,7 @@ discard block |
||
1947 | 1947 | protected function _set_shortcodes() { |
1948 | 1948 | |
1949 | 1949 | //no need to run this if the property is already set |
1950 | - if ( !empty($this->_shortcodes ) ) {return;} |
|
1950 | + if ( ! empty($this->_shortcodes)) {return; } |
|
1951 | 1951 | |
1952 | 1952 | $this->_shortcodes = $this->_get_shortcodes(); |
1953 | 1953 | } |
@@ -1969,14 +1969,14 @@ discard block |
||
1969 | 1969 | * @return array Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true |
1970 | 1970 | * just an array of shortcode/label pairs. |
1971 | 1971 | */ |
1972 | - protected function _get_shortcodes( $fields = array(), $merged = true ) { |
|
1972 | + protected function _get_shortcodes($fields = array(), $merged = true) { |
|
1973 | 1973 | $this->_set_message_template_group(); |
1974 | 1974 | |
1975 | 1975 | //we need the messenger and message template to retrieve the valid shortcodes array. |
1976 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false; |
|
1977 | - $context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() ); |
|
1976 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false; |
|
1977 | + $context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config()); |
|
1978 | 1978 | |
1979 | - return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array(); |
|
1979 | + return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array(); |
|
1980 | 1980 | } |
1981 | 1981 | |
1982 | 1982 | |
@@ -1989,19 +1989,19 @@ discard block |
||
1989 | 1989 | */ |
1990 | 1990 | protected function _set_message_template_group() { |
1991 | 1991 | |
1992 | - if ( !empty( $this->_message_template_group ) ) |
|
1993 | - {return;} //get out if this is already set. |
|
1992 | + if ( ! empty($this->_message_template_group)) |
|
1993 | + {return; } //get out if this is already set. |
|
1994 | 1994 | |
1995 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : false; |
|
1996 | - $GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID; |
|
1995 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false; |
|
1996 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID; |
|
1997 | 1997 | |
1998 | 1998 | //let's get the message templates |
1999 | 1999 | $MTP = EEM_Message_Template_Group::instance(); |
2000 | 2000 | |
2001 | - if ( empty($GRP_ID) ) |
|
2002 | - {$this->_message_template_group = $MTP->create_default_object();} |
|
2001 | + if (empty($GRP_ID)) |
|
2002 | + {$this->_message_template_group = $MTP->create_default_object(); } |
|
2003 | 2003 | else |
2004 | - {$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );} |
|
2004 | + {$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID); } |
|
2005 | 2005 | |
2006 | 2006 | $this->_template_pack = $this->_message_template_group->get_template_pack(); |
2007 | 2007 | $this->_variation = $this->_message_template_group->get_template_pack_variation(); |
@@ -2020,7 +2020,7 @@ discard block |
||
2020 | 2020 | * @param array $args various things the context switcher needs. |
2021 | 2021 | * |
2022 | 2022 | */ |
2023 | - protected function _set_context_switcher( EE_Message_Template_Group $template_group_object, $args) { |
|
2023 | + protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args) { |
|
2024 | 2024 | $context_details = $template_group_object->contexts_config(); |
2025 | 2025 | $context_label = $template_group_object->context_label(); |
2026 | 2026 | ob_start(); |
@@ -2028,20 +2028,20 @@ discard block |
||
2028 | 2028 | <div class="ee-msg-switcher-container"> |
2029 | 2029 | <form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm"> |
2030 | 2030 | <?php |
2031 | - foreach ( $args as $name => $value ) { |
|
2032 | - if ( $name == 'context' || empty($value) || $name == 'extra' ) {continue;} |
|
2031 | + foreach ($args as $name => $value) { |
|
2032 | + if ($name == 'context' || empty($value) || $name == 'extra') {continue; } |
|
2033 | 2033 | ?> |
2034 | 2034 | <input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" /> |
2035 | 2035 | <?php |
2036 | 2036 | } |
2037 | 2037 | //setup nonce_url |
2038 | - wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false); |
|
2038 | + wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false); |
|
2039 | 2039 | ?> |
2040 | 2040 | <select name="context"> |
2041 | 2041 | <?php |
2042 | 2042 | $context_templates = $template_group_object->context_templates(); |
2043 | - if ( is_array($context_templates) ) : |
|
2044 | - foreach ( $context_templates as $context => $template_fields ) : |
|
2043 | + if (is_array($context_templates)) : |
|
2044 | + foreach ($context_templates as $context => $template_fields) : |
|
2045 | 2045 | $checked = ($context == $args['context']) ? 'selected="selected"' : ''; |
2046 | 2046 | ?> |
2047 | 2047 | <option value="<?php echo $context; ?>" <?php echo $checked; ?>> |
@@ -2049,7 +2049,7 @@ discard block |
||
2049 | 2049 | </option> |
2050 | 2050 | <?php endforeach; endif; ?> |
2051 | 2051 | </select> |
2052 | - <?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?> |
|
2052 | + <?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?> |
|
2053 | 2053 | <input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>"> |
2054 | 2054 | </form> |
2055 | 2055 | <?php echo $args['extra']; ?> |
@@ -2076,8 +2076,8 @@ discard block |
||
2076 | 2076 | * @return array |
2077 | 2077 | */ |
2078 | 2078 | protected function _set_message_template_column_values($index) { |
2079 | - if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) { |
|
2080 | - foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) { |
|
2079 | + if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) { |
|
2080 | + foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) { |
|
2081 | 2081 | $this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value; |
2082 | 2082 | } |
2083 | 2083 | } /*else { |
@@ -2086,22 +2086,22 @@ discard block |
||
2086 | 2086 | |
2087 | 2087 | |
2088 | 2088 | $set_column_values = array( |
2089 | - 'MTP_ID' => absint( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'MTP_ID' ] ), |
|
2090 | - 'GRP_ID' => absint( $this->_req_data[ 'GRP_ID' ] ), |
|
2091 | - 'MTP_user_id' => absint( $this->_req_data[ 'MTP_user_id' ] ), |
|
2092 | - 'MTP_messenger' => strtolower( $this->_req_data[ 'MTP_messenger' ] ), |
|
2093 | - 'MTP_message_type' => strtolower( $this->_req_data[ 'MTP_message_type' ] ), |
|
2094 | - 'MTP_template_field' => strtolower( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'name' ] ), |
|
2095 | - 'MTP_context' => strtolower( $this->_req_data[ 'MTP_context' ] ), |
|
2096 | - 'MTP_content' => $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'content' ], |
|
2097 | - 'MTP_is_global' => isset( $this->_req_data[ 'MTP_is_global' ] ) |
|
2098 | - ? absint( $this->_req_data[ 'MTP_is_global' ] ) |
|
2089 | + 'MTP_ID' => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']), |
|
2090 | + 'GRP_ID' => absint($this->_req_data['GRP_ID']), |
|
2091 | + 'MTP_user_id' => absint($this->_req_data['MTP_user_id']), |
|
2092 | + 'MTP_messenger' => strtolower($this->_req_data['MTP_messenger']), |
|
2093 | + 'MTP_message_type' => strtolower($this->_req_data['MTP_message_type']), |
|
2094 | + 'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']), |
|
2095 | + 'MTP_context' => strtolower($this->_req_data['MTP_context']), |
|
2096 | + 'MTP_content' => $this->_req_data['MTP_template_fields'][$index]['content'], |
|
2097 | + 'MTP_is_global' => isset($this->_req_data['MTP_is_global']) |
|
2098 | + ? absint($this->_req_data['MTP_is_global']) |
|
2099 | 2099 | : 0, |
2100 | - 'MTP_is_override' => isset( $this->_req_data[ 'MTP_is_override' ] ) |
|
2101 | - ? absint( $this->_req_data[ 'MTP_is_override' ] ) |
|
2100 | + 'MTP_is_override' => isset($this->_req_data['MTP_is_override']) |
|
2101 | + ? absint($this->_req_data['MTP_is_override']) |
|
2102 | 2102 | : 0, |
2103 | - 'MTP_deleted' => absint( $this->_req_data[ 'MTP_deleted' ] ), |
|
2104 | - 'MTP_is_active' => absint( $this->_req_data[ 'MTP_is_active' ] ) |
|
2103 | + 'MTP_deleted' => absint($this->_req_data['MTP_deleted']), |
|
2104 | + 'MTP_is_active' => absint($this->_req_data['MTP_is_active']) |
|
2105 | 2105 | ); |
2106 | 2106 | |
2107 | 2107 | |
@@ -2113,36 +2113,36 @@ discard block |
||
2113 | 2113 | |
2114 | 2114 | |
2115 | 2115 | |
2116 | - protected function _insert_or_update_message_template($new = false ) { |
|
2116 | + protected function _insert_or_update_message_template($new = false) { |
|
2117 | 2117 | |
2118 | - do_action ( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2118 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2119 | 2119 | $success = 0; |
2120 | 2120 | $override = false; |
2121 | 2121 | |
2122 | 2122 | //setup notices description |
2123 | - $messenger = ! empty( $this->_req_data['MTP_messenger'] ) |
|
2124 | - ? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_messenger'] ) ) |
|
2123 | + $messenger = ! empty($this->_req_data['MTP_messenger']) |
|
2124 | + ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'])) |
|
2125 | 2125 | : false; |
2126 | 2126 | |
2127 | - $message_type = ! empty( $this->_req_data['MTP_message_type'] ) |
|
2128 | - ? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_message_type'] ) ) |
|
2127 | + $message_type = ! empty($this->_req_data['MTP_message_type']) |
|
2128 | + ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'])) |
|
2129 | 2129 | : false; |
2130 | 2130 | |
2131 | - $context = ! empty( $this->_req_data['MTP_context'] ) |
|
2132 | - ? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_context'] ) ) |
|
2131 | + $context = ! empty($this->_req_data['MTP_context']) |
|
2132 | + ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'])) |
|
2133 | 2133 | : false; |
2134 | 2134 | |
2135 | - $item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : ''; |
|
2135 | + $item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : ''; |
|
2136 | 2136 | $item_desc .= 'Message Template'; |
2137 | 2137 | $query_args = array(); |
2138 | 2138 | $edit_array = array(); |
2139 | 2139 | $action_desc = ''; |
2140 | 2140 | |
2141 | 2141 | //if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit. |
2142 | - if ( $new ) { |
|
2143 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
2144 | - if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) { |
|
2145 | - if ( empty($edit_array) ) { |
|
2142 | + if ($new) { |
|
2143 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
2144 | + if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) { |
|
2145 | + if (empty($edit_array)) { |
|
2146 | 2146 | $success = 0; |
2147 | 2147 | } else { |
2148 | 2148 | $success = 1; |
@@ -2161,7 +2161,7 @@ discard block |
||
2161 | 2161 | |
2162 | 2162 | |
2163 | 2163 | //run update for each template field in displayed context |
2164 | - if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) { |
|
2164 | + if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) { |
|
2165 | 2165 | EE_Error::add_error( |
2166 | 2166 | __('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), |
2167 | 2167 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2170,25 +2170,25 @@ discard block |
||
2170 | 2170 | |
2171 | 2171 | } else { |
2172 | 2172 | //first validate all fields! |
2173 | - $validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2173 | + $validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2174 | 2174 | |
2175 | 2175 | //if $validate returned error messages (i.e. is_array()) then we need to process them and setup an appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array. WE need to make sure there is no actual error messages in validates. |
2176 | - if ( is_array($validates) && !empty($validates) ) { |
|
2176 | + if (is_array($validates) && ! empty($validates)) { |
|
2177 | 2177 | //add the transient so when the form loads we know which fields to highlight |
2178 | - $this->_add_transient( 'edit_message_template', $validates ); |
|
2178 | + $this->_add_transient('edit_message_template', $validates); |
|
2179 | 2179 | |
2180 | 2180 | $success = 0; |
2181 | 2181 | |
2182 | 2182 | //setup notices |
2183 | - foreach ( $validates as $field => $error ) { |
|
2184 | - if ( isset($error['msg'] ) ) { |
|
2185 | - EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ ); |
|
2183 | + foreach ($validates as $field => $error) { |
|
2184 | + if (isset($error['msg'])) { |
|
2185 | + EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__); |
|
2186 | 2186 | } |
2187 | 2187 | } |
2188 | 2188 | |
2189 | 2189 | } else { |
2190 | 2190 | $set_column_values = array(); |
2191 | - foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) { |
|
2191 | + foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) { |
|
2192 | 2192 | $set_column_values = $this->_set_message_template_column_values($template_field); |
2193 | 2193 | |
2194 | 2194 | $where_cols_n_values = array( |
@@ -2201,11 +2201,11 @@ discard block |
||
2201 | 2201 | 'MTP_context' => $set_column_values['MTP_context'], |
2202 | 2202 | 'MTP_content' => $set_column_values['MTP_content'] |
2203 | 2203 | ); |
2204 | - if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) { |
|
2205 | - if ( $updated === false ) { |
|
2204 | + if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) { |
|
2205 | + if ($updated === false) { |
|
2206 | 2206 | EE_Error::add_error( |
2207 | 2207 | sprintf( |
2208 | - __( '%s field was NOT updated for some reason', 'event_espresso' ), |
|
2208 | + __('%s field was NOT updated for some reason', 'event_espresso'), |
|
2209 | 2209 | $template_field |
2210 | 2210 | ), |
2211 | 2211 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2219,46 +2219,46 @@ discard block |
||
2219 | 2219 | |
2220 | 2220 | //we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs) |
2221 | 2221 | $mtpg_fields = array( |
2222 | - 'MTP_user_id' => $set_column_values[ 'MTP_user_id' ], |
|
2223 | - 'MTP_messenger' => $set_column_values[ 'MTP_messenger' ], |
|
2224 | - 'MTP_message_type' => $set_column_values[ 'MTP_message_type' ], |
|
2225 | - 'MTP_is_global' => $set_column_values[ 'MTP_is_global' ], |
|
2226 | - 'MTP_is_override' => $set_column_values[ 'MTP_is_override' ], |
|
2227 | - 'MTP_deleted' => $set_column_values[ 'MTP_deleted' ], |
|
2228 | - 'MTP_is_active' => $set_column_values[ 'MTP_is_active' ], |
|
2229 | - 'MTP_name' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] ) |
|
2230 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] |
|
2222 | + 'MTP_user_id' => $set_column_values['MTP_user_id'], |
|
2223 | + 'MTP_messenger' => $set_column_values['MTP_messenger'], |
|
2224 | + 'MTP_message_type' => $set_column_values['MTP_message_type'], |
|
2225 | + 'MTP_is_global' => $set_column_values['MTP_is_global'], |
|
2226 | + 'MTP_is_override' => $set_column_values['MTP_is_override'], |
|
2227 | + 'MTP_deleted' => $set_column_values['MTP_deleted'], |
|
2228 | + 'MTP_is_active' => $set_column_values['MTP_is_active'], |
|
2229 | + 'MTP_name' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name']) |
|
2230 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] |
|
2231 | 2231 | : '', |
2232 | - 'MTP_description' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] ) |
|
2233 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] |
|
2232 | + 'MTP_description' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description']) |
|
2233 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] |
|
2234 | 2234 | : '' |
2235 | 2235 | ); |
2236 | 2236 | |
2237 | - $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] ); |
|
2238 | - $updated = $MTPG->update( $mtpg_fields, array($mtpg_where) ); |
|
2237 | + $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']); |
|
2238 | + $updated = $MTPG->update($mtpg_fields, array($mtpg_where)); |
|
2239 | 2239 | |
2240 | - if ( $updated === false ) { |
|
2240 | + if ($updated === false) { |
|
2241 | 2241 | EE_Error::add_error( |
2242 | 2242 | sprintf( |
2243 | - __( 'The Message Template Group (%d) was NOT updated for some reason', 'event_espresso' ), |
|
2244 | - $set_column_values[ 'GRP_ID' ] |
|
2243 | + __('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), |
|
2244 | + $set_column_values['GRP_ID'] |
|
2245 | 2245 | ), |
2246 | 2246 | __FILE__, __FUNCTION__, __LINE__ |
2247 | 2247 | ); |
2248 | 2248 | } else { |
2249 | 2249 | //k now we need to ensure the template_pack and template_variation fields are set. |
2250 | - $template_pack = ! empty( $this->_req_data['MTP_template_pack' ] ) |
|
2250 | + $template_pack = ! empty($this->_req_data['MTP_template_pack']) |
|
2251 | 2251 | ? $this->_req_data['MTP_template_pack'] |
2252 | 2252 | : 'default'; |
2253 | 2253 | |
2254 | - $template_variation = ! empty( $this->_req_data['MTP_template_variation'] ) |
|
2254 | + $template_variation = ! empty($this->_req_data['MTP_template_variation']) |
|
2255 | 2255 | ? $this->_req_data['MTP_template_variation'] |
2256 | 2256 | : 'default'; |
2257 | 2257 | |
2258 | - $mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] ); |
|
2259 | - if ( $mtpg_obj instanceof EE_Message_Template_Group ) { |
|
2260 | - $mtpg_obj->set_template_pack_name( $template_pack ); |
|
2261 | - $mtpg_obj->set_template_pack_variation( $template_variation ); |
|
2258 | + $mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']); |
|
2259 | + if ($mtpg_obj instanceof EE_Message_Template_Group) { |
|
2260 | + $mtpg_obj->set_template_pack_name($template_pack); |
|
2261 | + $mtpg_obj->set_template_pack_variation($template_variation); |
|
2262 | 2262 | } |
2263 | 2263 | $success = 1; |
2264 | 2264 | } |
@@ -2268,7 +2268,7 @@ discard block |
||
2268 | 2268 | } |
2269 | 2269 | |
2270 | 2270 | //we return things differently if doing ajax |
2271 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
2271 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2272 | 2272 | $this->_template_args['success'] = $success; |
2273 | 2273 | $this->_template_args['error'] = ! $success ? true : false; |
2274 | 2274 | $this->_template_args['content'] = ''; |
@@ -2276,9 +2276,9 @@ discard block |
||
2276 | 2276 | 'grpID' => $edit_array['GRP_ID'], |
2277 | 2277 | 'templateName' => $edit_array['template_name'] |
2278 | 2278 | ); |
2279 | - if ( $success ) { |
|
2279 | + if ($success) { |
|
2280 | 2280 | EE_Error::overwrite_success(); |
2281 | - EE_Error::add_success( __('The new template has been created and automatically selected for this event. You can edit the new template by clicking the edit button. Note before this template is assigned to this event, the event must be saved.', 'event_espresso') ); |
|
2281 | + EE_Error::add_success(__('The new template has been created and automatically selected for this event. You can edit the new template by clicking the edit button. Note before this template is assigned to this event, the event must be saved.', 'event_espresso')); |
|
2282 | 2282 | } |
2283 | 2283 | |
2284 | 2284 | $this->_return_json(); |
@@ -2286,13 +2286,13 @@ discard block |
||
2286 | 2286 | |
2287 | 2287 | |
2288 | 2288 | //was a test send triggered? |
2289 | - if ( isset( $this->_req_data['test_button'] ) ) { |
|
2289 | + if (isset($this->_req_data['test_button'])) { |
|
2290 | 2290 | EE_Error::overwrite_success(); |
2291 | - $this->_do_test_send( $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] ); |
|
2291 | + $this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']); |
|
2292 | 2292 | $override = true; |
2293 | 2293 | } |
2294 | 2294 | |
2295 | - if ( empty( $query_args ) ) { |
|
2295 | + if (empty($query_args)) { |
|
2296 | 2296 | $query_args = array( |
2297 | 2297 | 'id' => $this->_req_data['GRP_ID'], |
2298 | 2298 | 'context' => $this->_req_data['MTP_context'], |
@@ -2300,7 +2300,7 @@ discard block |
||
2300 | 2300 | ); |
2301 | 2301 | } |
2302 | 2302 | |
2303 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override ); |
|
2303 | + $this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override); |
|
2304 | 2304 | } |
2305 | 2305 | |
2306 | 2306 | |
@@ -2314,28 +2314,28 @@ discard block |
||
2314 | 2314 | * @param string $message_type message type being tested |
2315 | 2315 | * |
2316 | 2316 | */ |
2317 | - protected function _do_test_send( $context, $messenger, $message_type ) { |
|
2317 | + protected function _do_test_send($context, $messenger, $message_type) { |
|
2318 | 2318 | //set things up for preview |
2319 | 2319 | $this->_req_data['messenger'] = $messenger; |
2320 | 2320 | $this->_req_data['message_type'] = $message_type; |
2321 | 2321 | $this->_req_data['context'] = $context; |
2322 | - $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : ''; |
|
2323 | - $active_messenger = $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
2322 | + $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : ''; |
|
2323 | + $active_messenger = $this->_message_resource_manager->get_active_messenger($messenger); |
|
2324 | 2324 | |
2325 | 2325 | //let's save any existing fields that might be required by the messenger |
2326 | 2326 | if ( |
2327 | - isset( $this->_req_data['test_settings_fld'] ) |
|
2327 | + isset($this->_req_data['test_settings_fld']) |
|
2328 | 2328 | && $active_messenger instanceof EE_messenger |
2329 | 2329 | ) { |
2330 | - $active_messenger->set_existing_test_settings( $this->_req_data['test_settings_fld'] ); |
|
2330 | + $active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']); |
|
2331 | 2331 | } |
2332 | 2332 | |
2333 | 2333 | $success = $this->_preview_message(true); |
2334 | 2334 | |
2335 | - if ( $success ) { |
|
2336 | - EE_Error::add_success( __('Test message sent', 'event_espresso') ); |
|
2335 | + if ($success) { |
|
2336 | + EE_Error::add_success(__('Test message sent', 'event_espresso')); |
|
2337 | 2337 | } else { |
2338 | - EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2338 | + EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2339 | 2339 | } |
2340 | 2340 | } |
2341 | 2341 | |
@@ -2361,11 +2361,11 @@ discard block |
||
2361 | 2361 | protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
2362 | 2362 | |
2363 | 2363 | //if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we just don't generate any templates. |
2364 | - if ( empty( $message_types ) ) { |
|
2364 | + if (empty($message_types)) { |
|
2365 | 2365 | return true; |
2366 | 2366 | } |
2367 | 2367 | |
2368 | - return EEH_MSG_Template::generate_new_templates( $messenger, $message_types, $GRP_ID, $global ); |
|
2368 | + return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global); |
|
2369 | 2369 | } |
2370 | 2370 | |
2371 | 2371 | |
@@ -2381,33 +2381,33 @@ discard block |
||
2381 | 2381 | * |
2382 | 2382 | * @return void |
2383 | 2383 | */ |
2384 | - protected function _trash_or_restore_message_template($trash = true, $all = false ) { |
|
2385 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2384 | + protected function _trash_or_restore_message_template($trash = true, $all = false) { |
|
2385 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2386 | 2386 | $MTP = EEM_Message_Template_Group::instance(); |
2387 | 2387 | |
2388 | 2388 | $success = 1; |
2389 | 2389 | |
2390 | 2390 | //incoming GRP_IDs |
2391 | - if ( $all ) { |
|
2391 | + if ($all) { |
|
2392 | 2392 | //Checkboxes |
2393 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) { |
|
2393 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2394 | 2394 | //if array has more than one element then success message should be plural. |
2395 | 2395 | //todo: what about nonce? |
2396 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2396 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2397 | 2397 | |
2398 | 2398 | //cycle through checkboxes |
2399 | - while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) { |
|
2400 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2401 | - if ( ! $trashed_or_restored ) { |
|
2399 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2400 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2401 | + if ( ! $trashed_or_restored) { |
|
2402 | 2402 | $success = 0; |
2403 | 2403 | } |
2404 | 2404 | } |
2405 | 2405 | } else { |
2406 | 2406 | //grab single GRP_ID and handle |
2407 | - $GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0; |
|
2408 | - if ( ! empty( $GRP_ID ) ) { |
|
2409 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2410 | - if ( ! $trashed_or_restored ) { |
|
2407 | + $GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0; |
|
2408 | + if ( ! empty($GRP_ID)) { |
|
2409 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2410 | + if ( ! $trashed_or_restored) { |
|
2411 | 2411 | $success = 0; |
2412 | 2412 | } |
2413 | 2413 | } else { |
@@ -2419,13 +2419,13 @@ discard block |
||
2419 | 2419 | |
2420 | 2420 | $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
2421 | 2421 | |
2422 | - $action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc; |
|
2422 | + $action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc; |
|
2423 | 2423 | |
2424 | 2424 | $item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso'); |
2425 | 2425 | |
2426 | - $item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2426 | + $item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2427 | 2427 | |
2428 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, array() ); |
|
2428 | + $this->_redirect_after_action($success, $item_desc, $action_desc, array()); |
|
2429 | 2429 | |
2430 | 2430 | } |
2431 | 2431 | |
@@ -2441,24 +2441,24 @@ discard block |
||
2441 | 2441 | * @return void |
2442 | 2442 | */ |
2443 | 2443 | protected function _delete_message_template() { |
2444 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2444 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2445 | 2445 | |
2446 | 2446 | //checkboxes |
2447 | - if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) { |
|
2447 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2448 | 2448 | //if array has more than one element then success message should be plural |
2449 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2449 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2450 | 2450 | |
2451 | 2451 | //cycle through bulk action checkboxes |
2452 | - while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) { |
|
2453 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2452 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2453 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2454 | 2454 | } |
2455 | 2455 | } else { |
2456 | 2456 | //grab single grp_id and delete |
2457 | - $GRP_ID = absint($this->_req_data['id'] ); |
|
2458 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2457 | + $GRP_ID = absint($this->_req_data['id']); |
|
2458 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2459 | 2459 | } |
2460 | 2460 | |
2461 | - $this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() ); |
|
2461 | + $this->_redirect_after_action($success, 'Message Templates', 'deleted', array()); |
|
2462 | 2462 | |
2463 | 2463 | } |
2464 | 2464 | |
@@ -2473,20 +2473,20 @@ discard block |
||
2473 | 2473 | * |
2474 | 2474 | * @return bool boolean to indicate the success of the deletes or not. |
2475 | 2475 | */ |
2476 | - private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) { |
|
2476 | + private function _delete_mtp_permanently($GRP_ID, $include_group = true) { |
|
2477 | 2477 | $success = 1; |
2478 | 2478 | $MTPG = EEM_Message_Template_Group::instance(); |
2479 | 2479 | //first let's GET this group |
2480 | - $MTG = $MTPG->get_one_by_ID( $GRP_ID ); |
|
2480 | + $MTG = $MTPG->get_one_by_ID($GRP_ID); |
|
2481 | 2481 | //then delete permanently all the related Message Templates |
2482 | - $deleted = $MTG->delete_related_permanently( 'Message_Template' ); |
|
2482 | + $deleted = $MTG->delete_related_permanently('Message_Template'); |
|
2483 | 2483 | |
2484 | - if ( $deleted === 0 ) |
|
2485 | - {$success = 0;} |
|
2484 | + if ($deleted === 0) |
|
2485 | + {$success = 0; } |
|
2486 | 2486 | |
2487 | 2487 | //now delete permanently this particular group |
2488 | 2488 | |
2489 | - if ( $include_group && ! $MTG->delete_permanently() ) { |
|
2489 | + if ($include_group && ! $MTG->delete_permanently()) { |
|
2490 | 2490 | $success = 0; |
2491 | 2491 | } |
2492 | 2492 | return $success; |
@@ -2504,7 +2504,7 @@ discard block |
||
2504 | 2504 | * @return string |
2505 | 2505 | */ |
2506 | 2506 | protected function _learn_more_about_message_templates_link() { |
2507 | - return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>'; |
|
2507 | + return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>'; |
|
2508 | 2508 | } |
2509 | 2509 | |
2510 | 2510 | |
@@ -2522,10 +2522,10 @@ discard block |
||
2522 | 2522 | |
2523 | 2523 | $this->_set_m_mt_settings(); |
2524 | 2524 | |
2525 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2525 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2526 | 2526 | |
2527 | 2527 | //let's setup the messenger tabs |
2528 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger ); |
|
2528 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger); |
|
2529 | 2529 | $this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">'; |
2530 | 2530 | $this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->'; |
2531 | 2531 | |
@@ -2544,7 +2544,7 @@ discard block |
||
2544 | 2544 | */ |
2545 | 2545 | protected function _set_m_mt_settings() { |
2546 | 2546 | //first if this is already set then lets get out no need to regenerate data. |
2547 | - if ( !empty($this->_m_mt_settings) ) { |
|
2547 | + if ( ! empty($this->_m_mt_settings)) { |
|
2548 | 2548 | return; |
2549 | 2549 | } |
2550 | 2550 | |
@@ -2559,10 +2559,10 @@ discard block |
||
2559 | 2559 | |
2560 | 2560 | //assemble the array for the _tab_text_links helper |
2561 | 2561 | |
2562 | - foreach ( $messengers as $messenger ) { |
|
2562 | + foreach ($messengers as $messenger) { |
|
2563 | 2563 | $this->_m_mt_settings['messenger_tabs'][$messenger->name] = array( |
2564 | 2564 | 'label' => ucwords($messenger->label['singular']), |
2565 | - 'class' => $this->_message_resource_manager->is_messenger_active( $messenger->name ) ? 'messenger-active' : '', |
|
2565 | + 'class' => $this->_message_resource_manager->is_messenger_active($messenger->name) ? 'messenger-active' : '', |
|
2566 | 2566 | 'href' => $messenger->name, |
2567 | 2567 | 'title' => __('Modify this Messenger', 'event_espresso'), |
2568 | 2568 | 'slug' => $messenger->name, |
@@ -2572,26 +2572,26 @@ discard block |
||
2572 | 2572 | |
2573 | 2573 | $message_types_for_messenger = $messenger->get_valid_message_types(); |
2574 | 2574 | |
2575 | - foreach ( $message_types as $message_type ) { |
|
2575 | + foreach ($message_types as $message_type) { |
|
2576 | 2576 | //first we need to verify that this message type is valid with this messenger. Cause if it isn't then it shouldn't show in either the inactive OR active metabox. |
2577 | - if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) { |
|
2577 | + if ( ! in_array($message_type->name, $message_types_for_messenger)) { |
|
2578 | 2578 | continue; |
2579 | 2579 | } |
2580 | 2580 | |
2581 | - $a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) ? 'active' : 'inactive'; |
|
2581 | + $a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger($messenger->name, $message_type->name) ? 'active' : 'inactive'; |
|
2582 | 2582 | |
2583 | 2583 | $this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array( |
2584 | - 'label' => ucwords( $message_type->label[ 'singular' ] ), |
|
2585 | - 'class' => 'message-type-' . $a_or_i, |
|
2586 | - 'slug_id' => $message_type->name . '-messagetype-' . $messenger->name, |
|
2587 | - 'mt_nonce' => wp_create_nonce( $message_type->name . '_nonce' ), |
|
2588 | - 'href' => 'espresso_' . $message_type->name . '_message_type_settings', |
|
2584 | + 'label' => ucwords($message_type->label['singular']), |
|
2585 | + 'class' => 'message-type-'.$a_or_i, |
|
2586 | + 'slug_id' => $message_type->name.'-messagetype-'.$messenger->name, |
|
2587 | + 'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'), |
|
2588 | + 'href' => 'espresso_'.$message_type->name.'_message_type_settings', |
|
2589 | 2589 | 'title' => $a_or_i == 'active' |
2590 | - ? __( 'Drag this message type to the Inactive window to deactivate', 'event_espresso' ) |
|
2591 | - : __( 'Drag this message type to the messenger to activate', 'event_espresso' ), |
|
2590 | + ? __('Drag this message type to the Inactive window to deactivate', 'event_espresso') |
|
2591 | + : __('Drag this message type to the messenger to activate', 'event_espresso'), |
|
2592 | 2592 | 'content' => $a_or_i == 'active' |
2593 | - ? $this->_message_type_settings_content( $message_type, $messenger, true ) |
|
2594 | - : $this->_message_type_settings_content( $message_type, $messenger ), |
|
2593 | + ? $this->_message_type_settings_content($message_type, $messenger, true) |
|
2594 | + : $this->_message_type_settings_content($message_type, $messenger), |
|
2595 | 2595 | 'slug' => $message_type->name, |
2596 | 2596 | 'active' => $a_or_i == 'active' ? true : false, |
2597 | 2597 | 'obj' => $message_type |
@@ -2610,34 +2610,34 @@ discard block |
||
2610 | 2610 | * |
2611 | 2611 | * @return string html output for the content |
2612 | 2612 | */ |
2613 | - protected function _message_type_settings_content( $message_type, $messenger, $active = false ) { |
|
2613 | + protected function _message_type_settings_content($message_type, $messenger, $active = false) { |
|
2614 | 2614 | //get message type fields |
2615 | 2615 | $fields = $message_type->get_admin_settings_fields(); |
2616 | - $settings_template_args['template_form_fields']= ''; |
|
2616 | + $settings_template_args['template_form_fields'] = ''; |
|
2617 | 2617 | |
2618 | - if ( !empty( $fields ) && $active ) { |
|
2618 | + if ( ! empty($fields) && $active) { |
|
2619 | 2619 | |
2620 | - $existing_settings = $message_type->get_existing_admin_settings( $messenger->name ); |
|
2620 | + $existing_settings = $message_type->get_existing_admin_settings($messenger->name); |
|
2621 | 2621 | |
2622 | - foreach( $fields as $fldname => $fldprops ) { |
|
2623 | - $field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname; |
|
2622 | + foreach ($fields as $fldname => $fldprops) { |
|
2623 | + $field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname; |
|
2624 | 2624 | $template_form_field[$field_id] = array( |
2625 | - 'name' => 'message_type_settings[' . $fldname . ']', |
|
2625 | + 'name' => 'message_type_settings['.$fldname.']', |
|
2626 | 2626 | 'label' => $fldprops['label'], |
2627 | 2627 | 'input' => $fldprops['field_type'], |
2628 | 2628 | 'type' => $fldprops['value_type'], |
2629 | 2629 | 'required' => $fldprops['required'], |
2630 | 2630 | 'validation' => $fldprops['validation'], |
2631 | - 'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2632 | - 'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(), |
|
2633 | - 'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2631 | + 'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2632 | + 'options' => isset($fldprops['options']) ? $fldprops['options'] : array(), |
|
2633 | + 'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2634 | 2634 | 'css_class' => 'no-drag', |
2635 | 2635 | 'format' => $fldprops['format'] |
2636 | 2636 | ); |
2637 | 2637 | } |
2638 | 2638 | |
2639 | 2639 | |
2640 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : ''; |
|
2640 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : ''; |
|
2641 | 2641 | } |
2642 | 2642 | |
2643 | 2643 | $settings_template_args['description'] = $message_type->description; |
@@ -2657,13 +2657,13 @@ discard block |
||
2657 | 2657 | ) |
2658 | 2658 | ); |
2659 | 2659 | |
2660 | - $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' ); |
|
2661 | - $settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : ''; |
|
2660 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array'); |
|
2661 | + $settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : ''; |
|
2662 | 2662 | |
2663 | 2663 | |
2664 | 2664 | |
2665 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php'; |
|
2666 | - $content = EEH_Template::display_template( $template, $settings_template_args, true ); |
|
2665 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php'; |
|
2666 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2667 | 2667 | return $content; |
2668 | 2668 | } |
2669 | 2669 | |
@@ -2680,27 +2680,27 @@ discard block |
||
2680 | 2680 | $m_boxes = $mt_boxes = array(); |
2681 | 2681 | $m_template_args = $mt_template_args = array(); |
2682 | 2682 | |
2683 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2683 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2684 | 2684 | |
2685 | - if ( isset( $this->_m_mt_settings[ 'messenger_tabs' ] ) ) { |
|
2686 | - foreach ( $this->_m_mt_settings[ 'messenger_tabs' ] as $messenger => $tab_array ) { |
|
2687 | - $hide_on_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? '' : 'hidden'; |
|
2688 | - $hide_off_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? 'hidden' : ''; |
|
2685 | + if (isset($this->_m_mt_settings['messenger_tabs'])) { |
|
2686 | + foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) { |
|
2687 | + $hide_on_message = $this->_message_resource_manager->is_messenger_active($messenger) ? '' : 'hidden'; |
|
2688 | + $hide_off_message = $this->_message_resource_manager->is_messenger_active($messenger) ? 'hidden' : ''; |
|
2689 | 2689 | //messenger meta boxes |
2690 | 2690 | $active = $selected_messenger == $messenger ? true : false; |
2691 | - $active_mt_tabs = isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ] ) |
|
2692 | - ? $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ] |
|
2691 | + $active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active']) |
|
2692 | + ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] |
|
2693 | 2693 | : ''; |
2694 | - $m_boxes[ $messenger . '_a_box' ] = sprintf( |
|
2695 | - __( '%s Settings', 'event_espresso' ), |
|
2696 | - $tab_array[ 'label' ] |
|
2694 | + $m_boxes[$messenger.'_a_box'] = sprintf( |
|
2695 | + __('%s Settings', 'event_espresso'), |
|
2696 | + $tab_array['label'] |
|
2697 | 2697 | ); |
2698 | - $m_template_args[ $messenger . '_a_box' ] = array( |
|
2699 | - 'active_message_types' => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2700 | - 'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2701 | - ? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2698 | + $m_template_args[$messenger.'_a_box'] = array( |
|
2699 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2700 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2701 | + ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2702 | 2702 | : '', |
2703 | - 'content' => $this->_get_messenger_box_content( $tab_array[ 'obj' ] ), |
|
2703 | + 'content' => $this->_get_messenger_box_content($tab_array['obj']), |
|
2704 | 2704 | 'hidden' => $active ? '' : ' hidden', |
2705 | 2705 | 'hide_on_message' => $hide_on_message, |
2706 | 2706 | 'messenger' => $messenger, |
@@ -2709,11 +2709,11 @@ discard block |
||
2709 | 2709 | // message type meta boxes |
2710 | 2710 | // (which is really just the inactive container for each messenger |
2711 | 2711 | // showing inactive message types for that messenger) |
2712 | - $mt_boxes[ $messenger . '_i_box' ] = __( 'Inactive Message Types', 'event_espresso' ); |
|
2713 | - $mt_template_args[ $messenger . '_i_box' ] = array( |
|
2714 | - 'active_message_types' => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2715 | - 'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2716 | - ? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2712 | + $mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
2713 | + $mt_template_args[$messenger.'_i_box'] = array( |
|
2714 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2715 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2716 | + ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2717 | 2717 | : '', |
2718 | 2718 | 'hidden' => $active ? '' : ' hidden', |
2719 | 2719 | 'hide_on_message' => $hide_on_message, |
@@ -2726,15 +2726,15 @@ discard block |
||
2726 | 2726 | |
2727 | 2727 | |
2728 | 2728 | //register messenger metaboxes |
2729 | - $m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2730 | - foreach ( $m_boxes as $box => $label ) { |
|
2731 | - $callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] ); |
|
2732 | - $msgr = str_replace( '_a_box', '', $box ); |
|
2729 | + $m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2730 | + foreach ($m_boxes as $box => $label) { |
|
2731 | + $callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]); |
|
2732 | + $msgr = str_replace('_a_box', '', $box); |
|
2733 | 2733 | add_meta_box( |
2734 | - 'espresso_' . $msgr . '_settings', |
|
2734 | + 'espresso_'.$msgr.'_settings', |
|
2735 | 2735 | $label, |
2736 | - function( $post, $metabox ) { |
|
2737 | - echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE ); |
|
2736 | + function($post, $metabox) { |
|
2737 | + echo EEH_Template::display_template($metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE); |
|
2738 | 2738 | }, |
2739 | 2739 | $this->_current_screen->id, |
2740 | 2740 | 'normal', |
@@ -2744,17 +2744,17 @@ discard block |
||
2744 | 2744 | } |
2745 | 2745 | |
2746 | 2746 | //register message type metaboxes |
2747 | - $mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php'; |
|
2748 | - foreach ( $mt_boxes as $box => $label ) { |
|
2747 | + $mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php'; |
|
2748 | + foreach ($mt_boxes as $box => $label) { |
|
2749 | 2749 | $callback_args = array( |
2750 | - 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[ $box ] |
|
2750 | + 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box] |
|
2751 | 2751 | ); |
2752 | - $mt = str_replace( '_i_box', '', $box ); |
|
2752 | + $mt = str_replace('_i_box', '', $box); |
|
2753 | 2753 | add_meta_box( |
2754 | - 'espresso_' . $mt . '_inactive_mts', |
|
2754 | + 'espresso_'.$mt.'_inactive_mts', |
|
2755 | 2755 | $label, |
2756 | - function( $post, $metabox ) { |
|
2757 | - echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE ); |
|
2756 | + function($post, $metabox) { |
|
2757 | + echo EEH_Template::display_template($metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE); |
|
2758 | 2758 | }, |
2759 | 2759 | $this->_current_screen->id, |
2760 | 2760 | 'side', |
@@ -2765,11 +2765,11 @@ discard block |
||
2765 | 2765 | |
2766 | 2766 | //register metabox for global messages settings but only when on the main site. On single site installs this will |
2767 | 2767 | //always result in the metabox showing, on multisite installs the metabox will only show on the main site. |
2768 | - if ( is_main_site() ) { |
|
2768 | + if (is_main_site()) { |
|
2769 | 2769 | add_meta_box( |
2770 | 2770 | 'espresso_global_message_settings', |
2771 | - __( 'Global Message Settings', 'event_espresso' ), |
|
2772 | - array( $this, 'global_messages_settings_metabox_content' ), |
|
2771 | + __('Global Message Settings', 'event_espresso'), |
|
2772 | + array($this, 'global_messages_settings_metabox_content'), |
|
2773 | 2773 | $this->_current_screen->id, |
2774 | 2774 | 'normal', |
2775 | 2775 | 'low', |
@@ -2789,7 +2789,7 @@ discard block |
||
2789 | 2789 | public function global_messages_settings_metabox_content() { |
2790 | 2790 | $form = $this->_generate_global_settings_form(); |
2791 | 2791 | echo $form->form_open( |
2792 | - $this->add_query_args_and_nonce( array( 'action' => 'update_global_settings' ), EE_MSG_ADMIN_URL ), |
|
2792 | + $this->add_query_args_and_nonce(array('action' => 'update_global_settings'), EE_MSG_ADMIN_URL), |
|
2793 | 2793 | 'POST' |
2794 | 2794 | ) |
2795 | 2795 | . $form->get_html() |
@@ -2802,7 +2802,7 @@ discard block |
||
2802 | 2802 | * @return EE_Form_Section_Proper |
2803 | 2803 | */ |
2804 | 2804 | protected function _generate_global_settings_form() { |
2805 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
2805 | + EE_Registry::instance()->load_helper('HTML'); |
|
2806 | 2806 | /** @var EE_Network_Core_Config $network_config */ |
2807 | 2807 | $network_config = EE_Registry::instance()->NET_CFG->core; |
2808 | 2808 | return new EE_Form_Section_Proper( |
@@ -2821,13 +2821,13 @@ discard block |
||
2821 | 2821 | ), |
2822 | 2822 | array( |
2823 | 2823 | 'default' => $network_config->do_messages_on_same_request, |
2824 | - 'html_label_text' => __( 'Generate and send all messages:', 'event_espresso' ), |
|
2825 | - 'html_help_text' => __( 'By default the messages system uses a more efficient means of processing messages on separate requests and utilizes the wp-cron scheduling system. This makes things execute faster for people registering for your events. However, if the wp-cron system is disabled on your site and there is no alternative in place, then you can change this so messages are always executed on the same request.', 'event_espresso' ), |
|
2824 | + 'html_label_text' => __('Generate and send all messages:', 'event_espresso'), |
|
2825 | + 'html_help_text' => __('By default the messages system uses a more efficient means of processing messages on separate requests and utilizes the wp-cron scheduling system. This makes things execute faster for people registering for your events. However, if the wp-cron system is disabled on your site and there is no alternative in place, then you can change this so messages are always executed on the same request.', 'event_espresso'), |
|
2826 | 2826 | ) |
2827 | 2827 | ), |
2828 | 2828 | 'update_settings' => new EE_Submit_Input( |
2829 | 2829 | array( |
2830 | - 'default' => __( 'Update', 'event_espresso' ), |
|
2830 | + 'default' => __('Update', 'event_espresso'), |
|
2831 | 2831 | 'html_label_text' => ' ' |
2832 | 2832 | ) |
2833 | 2833 | ) |
@@ -2846,28 +2846,28 @@ discard block |
||
2846 | 2846 | /** @var EE_Network_Core_Config $network_config */ |
2847 | 2847 | $network_config = EE_Registry::instance()->NET_CFG->core; |
2848 | 2848 | $form = $this->_generate_global_settings_form(); |
2849 | - if ( $form->was_submitted() ) { |
|
2849 | + if ($form->was_submitted()) { |
|
2850 | 2850 | $form->receive_form_submission(); |
2851 | - if ( $form->is_valid() ) { |
|
2851 | + if ($form->is_valid()) { |
|
2852 | 2852 | $valid_data = $form->valid_data(); |
2853 | - foreach( $valid_data as $property => $value ) { |
|
2854 | - $setter = 'set_' . $property; |
|
2855 | - if ( method_exists( $network_config, $setter ) ) { |
|
2856 | - $network_config->{$setter}( $value ); |
|
2853 | + foreach ($valid_data as $property => $value) { |
|
2854 | + $setter = 'set_'.$property; |
|
2855 | + if (method_exists($network_config, $setter)) { |
|
2856 | + $network_config->{$setter}($value); |
|
2857 | 2857 | } else if ( |
2858 | - property_exists( $network_config, $property ) |
|
2858 | + property_exists($network_config, $property) |
|
2859 | 2859 | && $network_config->{$property} !== $value |
2860 | 2860 | ) { |
2861 | 2861 | $network_config->{$property} = $value; |
2862 | 2862 | } |
2863 | 2863 | } |
2864 | 2864 | //only update if the form submission was valid! |
2865 | - EE_Registry::instance()->NET_CFG->update_config( true, false ); |
|
2865 | + EE_Registry::instance()->NET_CFG->update_config(true, false); |
|
2866 | 2866 | EE_Error::overwrite_success(); |
2867 | - EE_Error::add_success( __( 'Global message settings were updated', 'event_espresso' ) ); |
|
2867 | + EE_Error::add_success(__('Global message settings were updated', 'event_espresso')); |
|
2868 | 2868 | } |
2869 | 2869 | } |
2870 | - $this->_redirect_after_action( 0, '', '', array( 'action' => 'settings' ), true ); |
|
2870 | + $this->_redirect_after_action(0, '', '', array('action' => 'settings'), true); |
|
2871 | 2871 | } |
2872 | 2872 | |
2873 | 2873 | |
@@ -2878,13 +2878,13 @@ discard block |
||
2878 | 2878 | * |
2879 | 2879 | * @return string html formatted tabs |
2880 | 2880 | */ |
2881 | - protected function _get_mt_tabs( $tab_array ) { |
|
2881 | + protected function _get_mt_tabs($tab_array) { |
|
2882 | 2882 | $tab_array = (array) $tab_array; |
2883 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2883 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php'; |
|
2884 | 2884 | $tabs = ''; |
2885 | 2885 | |
2886 | - foreach ( $tab_array as $tab ) { |
|
2887 | - $tabs .= EEH_Template::display_template( $template, $tab, true ); |
|
2886 | + foreach ($tab_array as $tab) { |
|
2887 | + $tabs .= EEH_Template::display_template($template, $tab, true); |
|
2888 | 2888 | } |
2889 | 2889 | |
2890 | 2890 | return $tabs; |
@@ -2900,29 +2900,29 @@ discard block |
||
2900 | 2900 | * |
2901 | 2901 | * @return string html formatted content |
2902 | 2902 | */ |
2903 | - protected function _get_messenger_box_content( EE_messenger $messenger ) { |
|
2903 | + protected function _get_messenger_box_content(EE_messenger $messenger) { |
|
2904 | 2904 | |
2905 | 2905 | $fields = $messenger->get_admin_settings_fields(); |
2906 | 2906 | $settings_template_args['template_form_fields'] = ''; |
2907 | 2907 | |
2908 | 2908 | //is $messenger active? |
2909 | - $settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active( $messenger->name ); |
|
2909 | + $settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active($messenger->name); |
|
2910 | 2910 | |
2911 | 2911 | |
2912 | - if ( ! empty( $fields ) ) { |
|
2912 | + if ( ! empty($fields)) { |
|
2913 | 2913 | |
2914 | 2914 | $existing_settings = $messenger->get_existing_admin_settings(); |
2915 | 2915 | |
2916 | - foreach( $fields as $fldname => $fldprops ) { |
|
2917 | - $field_id = $messenger->name . '-' . $fldname; |
|
2916 | + foreach ($fields as $fldname => $fldprops) { |
|
2917 | + $field_id = $messenger->name.'-'.$fldname; |
|
2918 | 2918 | $template_form_field[$field_id] = array( |
2919 | - 'name' => 'messenger_settings[' . $field_id . ']', |
|
2919 | + 'name' => 'messenger_settings['.$field_id.']', |
|
2920 | 2920 | 'label' => $fldprops['label'], |
2921 | 2921 | 'input' => $fldprops['field_type'], |
2922 | 2922 | 'type' => $fldprops['value_type'], |
2923 | 2923 | 'required' => $fldprops['required'], |
2924 | 2924 | 'validation' => $fldprops['validation'], |
2925 | - 'value' => isset( $existing_settings[$field_id]) |
|
2925 | + 'value' => isset($existing_settings[$field_id]) |
|
2926 | 2926 | ? $existing_settings[$field_id] |
2927 | 2927 | : $fldprops['default'], |
2928 | 2928 | 'css_class' => '', |
@@ -2931,8 +2931,8 @@ discard block |
||
2931 | 2931 | } |
2932 | 2932 | |
2933 | 2933 | |
2934 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) |
|
2935 | - ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' ) |
|
2934 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) |
|
2935 | + ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form') |
|
2936 | 2936 | : ''; |
2937 | 2937 | } |
2938 | 2938 | |
@@ -2949,39 +2949,39 @@ discard block |
||
2949 | 2949 | ); |
2950 | 2950 | |
2951 | 2951 | //make sure any active message types that are existing are included in the hidden fields |
2952 | - if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) { |
|
2953 | - foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) { |
|
2952 | + if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) { |
|
2953 | + foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) { |
|
2954 | 2954 | $settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array( |
2955 | 2955 | 'type' => 'hidden', |
2956 | 2956 | 'value' => $mt |
2957 | 2957 | ); |
2958 | 2958 | } |
2959 | 2959 | } |
2960 | - $settings_template_args[ 'hidden_fields' ] = $this->_generate_admin_form_fields( |
|
2961 | - $settings_template_args[ 'hidden_fields' ], |
|
2960 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( |
|
2961 | + $settings_template_args['hidden_fields'], |
|
2962 | 2962 | 'array' |
2963 | 2963 | ); |
2964 | - $active = $this->_message_resource_manager->is_messenger_active( $messenger->name ); |
|
2964 | + $active = $this->_message_resource_manager->is_messenger_active($messenger->name); |
|
2965 | 2965 | |
2966 | 2966 | $settings_template_args['messenger'] = $messenger->name; |
2967 | 2967 | $settings_template_args['description'] = $messenger->description; |
2968 | 2968 | $settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden'; |
2969 | 2969 | |
2970 | 2970 | |
2971 | - $settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active( $messenger->name ) |
|
2971 | + $settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active($messenger->name) |
|
2972 | 2972 | ? $settings_template_args['show_hide_edit_form'] |
2973 | 2973 | : ' hidden'; |
2974 | 2974 | |
2975 | - $settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] ) |
|
2975 | + $settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields']) |
|
2976 | 2976 | ? ' hidden' |
2977 | 2977 | : $settings_template_args['show_hide_edit_form']; |
2978 | 2978 | |
2979 | 2979 | |
2980 | 2980 | $settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on'; |
2981 | - $settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce'); |
|
2981 | + $settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce'); |
|
2982 | 2982 | $settings_template_args['on_off_status'] = $active ? true : false; |
2983 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php'; |
|
2984 | - $content = EEH_Template::display_template( $template, $settings_template_args, true); |
|
2983 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php'; |
|
2984 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2985 | 2985 | return $content; |
2986 | 2986 | } |
2987 | 2987 | |
@@ -2995,9 +2995,9 @@ discard block |
||
2995 | 2995 | $success = true; |
2996 | 2996 | $this->_prep_default_response_for_messenger_or_message_type_toggle(); |
2997 | 2997 | //let's check that we have required data |
2998 | - if ( !isset( $this->_req_data[ 'messenger' ] ) ) { |
|
2998 | + if ( ! isset($this->_req_data['messenger'])) { |
|
2999 | 2999 | EE_Error::add_error( |
3000 | - __( 'Messenger name needed to toggle activation. None given', 'event_espresso' ), |
|
3000 | + __('Messenger name needed to toggle activation. None given', 'event_espresso'), |
|
3001 | 3001 | __FILE__, |
3002 | 3002 | __FUNCTION__, |
3003 | 3003 | __LINE__ |
@@ -3006,14 +3006,14 @@ discard block |
||
3006 | 3006 | } |
3007 | 3007 | |
3008 | 3008 | //do a nonce check here since we're not arriving via a normal route |
3009 | - $nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : ''; |
|
3010 | - $nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce'; |
|
3009 | + $nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : ''; |
|
3010 | + $nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce'; |
|
3011 | 3011 | |
3012 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
3012 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
3013 | 3013 | |
3014 | 3014 | |
3015 | 3015 | |
3016 | - if ( !isset( $this->_req_data[ 'status' ])) { |
|
3016 | + if ( ! isset($this->_req_data['status'])) { |
|
3017 | 3017 | EE_Error::add_error( |
3018 | 3018 | __( |
3019 | 3019 | 'Messenger status needed to know whether activation or deactivation is happening. No status is given', |
@@ -3029,11 +3029,11 @@ discard block |
||
3029 | 3029 | //do check to verify we have a valid status. |
3030 | 3030 | $status = $this->_req_data['status']; |
3031 | 3031 | |
3032 | - if ( $status != 'off' && $status != 'on' ) { |
|
3032 | + if ($status != 'off' && $status != 'on') { |
|
3033 | 3033 | EE_Error::add_error( |
3034 | 3034 | sprintf( |
3035 | - __( 'The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso' ), |
|
3036 | - $this->_req_data[ 'status' ] |
|
3035 | + __('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), |
|
3036 | + $this->_req_data['status'] |
|
3037 | 3037 | ), |
3038 | 3038 | __FILE__, |
3039 | 3039 | __FUNCTION__, |
@@ -3042,11 +3042,11 @@ discard block |
||
3042 | 3042 | $success = false; |
3043 | 3043 | } |
3044 | 3044 | |
3045 | - if ( $success ) { |
|
3045 | + if ($success) { |
|
3046 | 3046 | //made it here? Stop dawdling then!! |
3047 | 3047 | $success = $status == 'off' |
3048 | - ? $this->_deactivate_messenger( $this->_req_data['messenger'] ) |
|
3049 | - : $this->_activate_messenger( $this->_req_data['messenger'] ); |
|
3048 | + ? $this->_deactivate_messenger($this->_req_data['messenger']) |
|
3049 | + : $this->_activate_messenger($this->_req_data['messenger']); |
|
3050 | 3050 | } |
3051 | 3051 | |
3052 | 3052 | $this->_template_args['success'] = $success; |
@@ -3069,7 +3069,7 @@ discard block |
||
3069 | 3069 | $this->_prep_default_response_for_messenger_or_message_type_toggle(); |
3070 | 3070 | |
3071 | 3071 | //let's make sure we have the necessary data |
3072 | - if ( ! isset( $this->_req_data[ 'message_type' ] ) ) { |
|
3072 | + if ( ! isset($this->_req_data['message_type'])) { |
|
3073 | 3073 | EE_Error::add_error( |
3074 | 3074 | __('Message Type name needed to toggle activation. None given', 'event_espresso'), |
3075 | 3075 | __FILE__, __FUNCTION__, __LINE__ |
@@ -3077,7 +3077,7 @@ discard block |
||
3077 | 3077 | $success = false; |
3078 | 3078 | } |
3079 | 3079 | |
3080 | - if ( ! isset( $this->_req_data[ 'messenger' ] ) ) { |
|
3080 | + if ( ! isset($this->_req_data['messenger'])) { |
|
3081 | 3081 | EE_Error::add_error( |
3082 | 3082 | __('Messenger name needed to toggle activation. None given', 'event_espresso'), |
3083 | 3083 | __FILE__, __FUNCTION__, __LINE__ |
@@ -3085,7 +3085,7 @@ discard block |
||
3085 | 3085 | $success = false; |
3086 | 3086 | } |
3087 | 3087 | |
3088 | - if ( ! isset( $this->_req_data[ 'status' ])) { |
|
3088 | + if ( ! isset($this->_req_data['status'])) { |
|
3089 | 3089 | EE_Error::add_error( |
3090 | 3090 | __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), |
3091 | 3091 | __FILE__, __FUNCTION__, __LINE__ |
@@ -3097,7 +3097,7 @@ discard block |
||
3097 | 3097 | //do check to verify we have a valid status. |
3098 | 3098 | $status = $this->_req_data['status']; |
3099 | 3099 | |
3100 | - if ( $status != 'activate' && $status != 'deactivate' ) { |
|
3100 | + if ($status != 'activate' && $status != 'deactivate') { |
|
3101 | 3101 | EE_Error::add_error( |
3102 | 3102 | sprintf( |
3103 | 3103 | __('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), |
@@ -3110,16 +3110,16 @@ discard block |
||
3110 | 3110 | |
3111 | 3111 | |
3112 | 3112 | //do a nonce check here since we're not arriving via a normal route |
3113 | - $nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : ''; |
|
3114 | - $nonce_ref = $this->_req_data['message_type'] . '_nonce'; |
|
3113 | + $nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : ''; |
|
3114 | + $nonce_ref = $this->_req_data['message_type'].'_nonce'; |
|
3115 | 3115 | |
3116 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
3116 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
3117 | 3117 | |
3118 | - if ( $success ) { |
|
3118 | + if ($success) { |
|
3119 | 3119 | //made it here? um, what are you waiting for then? |
3120 | 3120 | $success = $status == 'deactivate' |
3121 | - ? $this->_deactivate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] ) |
|
3122 | - : $this->_activate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] ); |
|
3121 | + ? $this->_deactivate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type']) |
|
3122 | + : $this->_activate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type']); |
|
3123 | 3123 | } |
3124 | 3124 | |
3125 | 3125 | $this->_template_args['success'] = $success; |
@@ -3133,30 +3133,30 @@ discard block |
||
3133 | 3133 | * @param string $messenger_name The name of the messenger being activated |
3134 | 3134 | * @return bool |
3135 | 3135 | */ |
3136 | - protected function _activate_messenger( $messenger_name ) { |
|
3136 | + protected function _activate_messenger($messenger_name) { |
|
3137 | 3137 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3138 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3138 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3139 | 3139 | $message_types_to_activate = $active_messenger instanceof EE_Messenger ? $active_messenger->get_default_message_types() : array(); |
3140 | 3140 | |
3141 | 3141 | //ensure is active |
3142 | - $this->_message_resource_manager->activate_messenger( $messenger_name, $message_types_to_activate ); |
|
3142 | + $this->_message_resource_manager->activate_messenger($messenger_name, $message_types_to_activate); |
|
3143 | 3143 | |
3144 | 3144 | //set response_data for reload |
3145 | - foreach( $message_types_to_activate as $message_type_name ) { |
|
3145 | + foreach ($message_types_to_activate as $message_type_name) { |
|
3146 | 3146 | /** @var EE_message_type $message_type */ |
3147 | - $message_type = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3148 | - if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) |
|
3147 | + $message_type = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3148 | + if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name) |
|
3149 | 3149 | && $message_type instanceof EE_message_type |
3150 | 3150 | ) { |
3151 | 3151 | $this->_template_args['data']['active_mts'][] = $message_type_name; |
3152 | - if ( $message_type->get_admin_settings_fields() ) { |
|
3152 | + if ($message_type->get_admin_settings_fields()) { |
|
3153 | 3153 | $this->_template_args['data']['mt_reload'][] = $message_type_name; |
3154 | 3154 | } |
3155 | 3155 | } |
3156 | 3156 | } |
3157 | 3157 | |
3158 | 3158 | //add success message for activating messenger |
3159 | - return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger ); |
|
3159 | + return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger); |
|
3160 | 3160 | |
3161 | 3161 | } |
3162 | 3162 | |
@@ -3167,11 +3167,11 @@ discard block |
||
3167 | 3167 | * @param string $messenger_name The name of the messenger being activated |
3168 | 3168 | * @return bool |
3169 | 3169 | */ |
3170 | - protected function _deactivate_messenger( $messenger_name ) { |
|
3170 | + protected function _deactivate_messenger($messenger_name) { |
|
3171 | 3171 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3172 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3173 | - $this->_message_resource_manager->deactivate_messenger( $messenger_name ); |
|
3174 | - return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger ); |
|
3172 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3173 | + $this->_message_resource_manager->deactivate_messenger($messenger_name); |
|
3174 | + return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger); |
|
3175 | 3175 | } |
3176 | 3176 | |
3177 | 3177 | |
@@ -3182,23 +3182,23 @@ discard block |
||
3182 | 3182 | * @param string $message_type_name The name of the message type being activated for the messenger |
3183 | 3183 | * @return bool |
3184 | 3184 | */ |
3185 | - protected function _activate_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
3185 | + protected function _activate_message_type_for_messenger($messenger_name, $message_type_name) { |
|
3186 | 3186 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3187 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3187 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3188 | 3188 | /** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/ |
3189 | - $message_type_to_activate = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3189 | + $message_type_to_activate = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3190 | 3190 | |
3191 | 3191 | //ensure is active |
3192 | - $this->_message_resource_manager->activate_messenger( $messenger_name, $message_type_name ); |
|
3192 | + $this->_message_resource_manager->activate_messenger($messenger_name, $message_type_name); |
|
3193 | 3193 | |
3194 | 3194 | //set response for load |
3195 | - if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
3195 | + if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
3196 | 3196 | $this->_template_args['data']['active_mts'][] = $message_type_name; |
3197 | - if ( $message_type_to_activate->get_admin_settings_fields() ) { |
|
3197 | + if ($message_type_to_activate->get_admin_settings_fields()) { |
|
3198 | 3198 | $this->_template_args['data']['mt_reload'][] = $message_type_name; |
3199 | 3199 | } |
3200 | 3200 | } |
3201 | - return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger, $message_type_to_activate ); |
|
3201 | + return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger, $message_type_to_activate); |
|
3202 | 3202 | } |
3203 | 3203 | |
3204 | 3204 | |
@@ -3210,13 +3210,13 @@ discard block |
||
3210 | 3210 | * @param string $message_type_name The name of the message type being deactivated for the messenger |
3211 | 3211 | * @return bool |
3212 | 3212 | */ |
3213 | - protected function _deactivate_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
3213 | + protected function _deactivate_message_type_for_messenger($messenger_name, $message_type_name) { |
|
3214 | 3214 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3215 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3215 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3216 | 3216 | /** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/ |
3217 | - $message_type_to_deactivate = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3218 | - $this->_message_resource_manager->deactivate_message_type_for_messenger( $message_type_name, $messenger_name ); |
|
3219 | - return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger, $message_type_to_deactivate ); |
|
3217 | + $message_type_to_deactivate = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3218 | + $this->_message_resource_manager->deactivate_message_type_for_messenger($message_type_name, $messenger_name); |
|
3219 | + return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger, $message_type_to_deactivate); |
|
3220 | 3220 | } |
3221 | 3221 | |
3222 | 3222 | |
@@ -3247,9 +3247,9 @@ discard block |
||
3247 | 3247 | EE_Message_Type $message_type = null |
3248 | 3248 | ) { |
3249 | 3249 | //if $messenger isn't a valid messenger object then get out. |
3250 | - if ( ! $messenger instanceof EE_Messenger ) { |
|
3250 | + if ( ! $messenger instanceof EE_Messenger) { |
|
3251 | 3251 | EE_Error::add_error( |
3252 | - __( 'The messenger being activated is not a valid messenger', 'event_espresso' ), |
|
3252 | + __('The messenger being activated is not a valid messenger', 'event_espresso'), |
|
3253 | 3253 | __FILE__, |
3254 | 3254 | __FUNCTION__, |
3255 | 3255 | __LINE__ |
@@ -3257,32 +3257,32 @@ discard block |
||
3257 | 3257 | return false; |
3258 | 3258 | } |
3259 | 3259 | //activated |
3260 | - if ( $this->_template_args['data']['active_mts'] ) { |
|
3260 | + if ($this->_template_args['data']['active_mts']) { |
|
3261 | 3261 | EE_Error::overwrite_success(); |
3262 | 3262 | //activated a message type with the messenger |
3263 | - if ( $message_type instanceof EE_message_type ) { |
|
3263 | + if ($message_type instanceof EE_message_type) { |
|
3264 | 3264 | EE_Error::add_success( |
3265 | 3265 | sprintf( |
3266 | 3266 | __('%s message type has been successfully activated with the %s messenger', 'event_espresso'), |
3267 | - ucwords( $message_type->label['singular'] ), |
|
3268 | - ucwords( $messenger->label['singular'] ) |
|
3267 | + ucwords($message_type->label['singular']), |
|
3268 | + ucwords($messenger->label['singular']) |
|
3269 | 3269 | ) |
3270 | 3270 | ); |
3271 | 3271 | |
3272 | 3272 | //if message type was invoice then let's make sure we activate the invoice payment method. |
3273 | - if ( $message_type->name == 'invoice' ) { |
|
3274 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
3275 | - $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
3276 | - if ( $pm instanceof EE_Payment_Method ) { |
|
3277 | - EE_Error::add_attention( __('Activating the invoice message type also automatically activates the invoice payment method. If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso' ) ); |
|
3273 | + if ($message_type->name == 'invoice') { |
|
3274 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
3275 | + $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
3276 | + if ($pm instanceof EE_Payment_Method) { |
|
3277 | + EE_Error::add_attention(__('Activating the invoice message type also automatically activates the invoice payment method. If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso')); |
|
3278 | 3278 | } |
3279 | 3279 | } |
3280 | 3280 | //just toggles the entire messenger |
3281 | 3281 | } else { |
3282 | 3282 | EE_Error::add_success( |
3283 | 3283 | sprintf( |
3284 | - __( '%s messenger has been successfully activated', 'event_espresso' ), |
|
3285 | - ucwords( $messenger->label[ 'singular' ] ) |
|
3284 | + __('%s messenger has been successfully activated', 'event_espresso'), |
|
3285 | + ucwords($messenger->label['singular']) |
|
3286 | 3286 | ) |
3287 | 3287 | ); |
3288 | 3288 | } |
@@ -3292,12 +3292,12 @@ discard block |
||
3292 | 3292 | //message types after the activation process. However its possible some messengers don't HAVE any default_message_types |
3293 | 3293 | //in which case we just give a success message for the messenger being successfully activated. |
3294 | 3294 | } else { |
3295 | - if ( ! $messenger->get_default_message_types() ) { |
|
3295 | + if ( ! $messenger->get_default_message_types()) { |
|
3296 | 3296 | //messenger doesn't have any default message types so still a success. |
3297 | 3297 | EE_Error::add_success( |
3298 | 3298 | sprintf( |
3299 | - __('%s messenger was successfully activated.', 'event_espresso' ), |
|
3300 | - ucwords( $messenger->label['singular'] ) |
|
3299 | + __('%s messenger was successfully activated.', 'event_espresso'), |
|
3300 | + ucwords($messenger->label['singular']) |
|
3301 | 3301 | ) |
3302 | 3302 | ); |
3303 | 3303 | return true; |
@@ -3305,13 +3305,13 @@ discard block |
||
3305 | 3305 | EE_Error::add_error( |
3306 | 3306 | $message_type instanceof EE_message_type |
3307 | 3307 | ? sprintf( |
3308 | - __( '%s message type was not successfully activated with the %s messenger', 'event_espresso' ), |
|
3309 | - ucwords( $message_type->label['singular'] ), |
|
3310 | - ucwords( $messenger->label['singular'] ) |
|
3308 | + __('%s message type was not successfully activated with the %s messenger', 'event_espresso'), |
|
3309 | + ucwords($message_type->label['singular']), |
|
3310 | + ucwords($messenger->label['singular']) |
|
3311 | 3311 | ) |
3312 | 3312 | : sprintf( |
3313 | - __( '%s messenger was not successfully activated', 'event_espresso' ), |
|
3314 | - ucwords( $messenger->label['singular'] ) |
|
3313 | + __('%s messenger was not successfully activated', 'event_espresso'), |
|
3314 | + ucwords($messenger->label['singular']) |
|
3315 | 3315 | ), |
3316 | 3316 | __FILE__, |
3317 | 3317 | __FUNCTION__, |
@@ -3339,9 +3339,9 @@ discard block |
||
3339 | 3339 | EE_Error::overwrite_success(); |
3340 | 3340 | |
3341 | 3341 | //if $messenger isn't a valid messenger object then get out. |
3342 | - if ( ! $messenger instanceof EE_Messenger ) { |
|
3342 | + if ( ! $messenger instanceof EE_Messenger) { |
|
3343 | 3343 | EE_Error::add_error( |
3344 | - __( 'The messenger being deactivated is not a valid messenger', 'event_espresso' ), |
|
3344 | + __('The messenger being deactivated is not a valid messenger', 'event_espresso'), |
|
3345 | 3345 | __FILE__, |
3346 | 3346 | __FUNCTION__, |
3347 | 3347 | __LINE__ |
@@ -3349,13 +3349,13 @@ discard block |
||
3349 | 3349 | return false; |
3350 | 3350 | } |
3351 | 3351 | |
3352 | - if ( $message_type instanceof EE_message_type ) { |
|
3352 | + if ($message_type instanceof EE_message_type) { |
|
3353 | 3353 | $message_type_name = $message_type->name; |
3354 | 3354 | EE_Error::add_success( |
3355 | 3355 | sprintf( |
3356 | 3356 | __('%s message type has been successfully deactivated for the %s messenger.', 'event_espresso'), |
3357 | - ucwords( $message_type->label['singular'] ), |
|
3358 | - ucwords ( $messenger->label['singular'] ) |
|
3357 | + ucwords($message_type->label['singular']), |
|
3358 | + ucwords($messenger->label['singular']) |
|
3359 | 3359 | ) |
3360 | 3360 | ); |
3361 | 3361 | } else { |
@@ -3363,20 +3363,20 @@ discard block |
||
3363 | 3363 | EE_Error::add_success( |
3364 | 3364 | sprintf( |
3365 | 3365 | __('%s messenger has been successfully deactivated.', 'event_espresso'), |
3366 | - ucwords( $messenger->label['singular'] ) |
|
3366 | + ucwords($messenger->label['singular']) |
|
3367 | 3367 | ) |
3368 | 3368 | ); |
3369 | 3369 | } |
3370 | 3370 | |
3371 | 3371 | //if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method. |
3372 | - if ( $messenger->name == 'html' || $message_type_name == 'invoice') { |
|
3373 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
3374 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' ); |
|
3375 | - if ( $count_updated > 0 ) { |
|
3372 | + if ($messenger->name == 'html' || $message_type_name == 'invoice') { |
|
3373 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
3374 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice'); |
|
3375 | + if ($count_updated > 0) { |
|
3376 | 3376 | $msg = $message_type_name == 'invoice' |
3377 | - ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' ) |
|
3378 | - : __('Deactivating the html messenger also automatically deactivates the invoice payment method. In order for invoices to be generated the html messenger must be be active. If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' ); |
|
3379 | - EE_Error::add_attention( $msg ); |
|
3377 | + ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso') |
|
3378 | + : __('Deactivating the html messenger also automatically deactivates the invoice payment method. In order for invoices to be generated the html messenger must be be active. If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso'); |
|
3379 | + EE_Error::add_attention($msg); |
|
3380 | 3380 | } |
3381 | 3381 | } |
3382 | 3382 | return true; |
@@ -3387,17 +3387,17 @@ discard block |
||
3387 | 3387 | * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax) |
3388 | 3388 | */ |
3389 | 3389 | public function update_mt_form() { |
3390 | - if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) { |
|
3391 | - EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3390 | + if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) { |
|
3391 | + EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__); |
|
3392 | 3392 | $this->_return_json(); |
3393 | 3393 | } |
3394 | 3394 | |
3395 | 3395 | $message_types = $this->get_installed_message_types(); |
3396 | 3396 | |
3397 | - $message_type = $message_types[ $this->_req_data['message_type'] ]; |
|
3398 | - $messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
3397 | + $message_type = $message_types[$this->_req_data['message_type']]; |
|
3398 | + $messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
3399 | 3399 | |
3400 | - $content = $this->_message_type_settings_content ( $message_type, $messenger, true ); |
|
3400 | + $content = $this->_message_type_settings_content($message_type, $messenger, true); |
|
3401 | 3401 | $this->_template_args['success'] = true; |
3402 | 3402 | $this->_template_args['content'] = $content; |
3403 | 3403 | $this->_return_json(); |
@@ -3411,45 +3411,45 @@ discard block |
||
3411 | 3411 | * |
3412 | 3412 | */ |
3413 | 3413 | public function save_settings() { |
3414 | - if ( !isset( $this->_req_data['type'] ) ) { |
|
3415 | - EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3414 | + if ( ! isset($this->_req_data['type'])) { |
|
3415 | + EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3416 | 3416 | $this->_template_args['error'] = true; |
3417 | 3417 | $this->_return_json(); |
3418 | 3418 | } |
3419 | 3419 | |
3420 | 3420 | |
3421 | - if ( $this->_req_data['type'] == 'messenger' ) { |
|
3421 | + if ($this->_req_data['type'] == 'messenger') { |
|
3422 | 3422 | $settings = $this->_req_data['messenger_settings']; //this should be an array. |
3423 | 3423 | $messenger = $settings['messenger']; |
3424 | 3424 | //let's setup the settings data |
3425 | - foreach ( $settings as $key => $value ) { |
|
3426 | - switch ( $key ) { |
|
3425 | + foreach ($settings as $key => $value) { |
|
3426 | + switch ($key) { |
|
3427 | 3427 | case 'messenger' : |
3428 | - unset( $settings['messenger'] ); |
|
3428 | + unset($settings['messenger']); |
|
3429 | 3429 | break; |
3430 | 3430 | case 'message_types' : |
3431 | - unset( $settings['message_types'] ); |
|
3431 | + unset($settings['message_types']); |
|
3432 | 3432 | break; |
3433 | 3433 | default : |
3434 | 3434 | $settings[$key] = $value; |
3435 | 3435 | break; |
3436 | 3436 | } |
3437 | 3437 | } |
3438 | - $this->_message_resource_manager->add_settings_for_messenger( $messenger, $settings ); |
|
3438 | + $this->_message_resource_manager->add_settings_for_messenger($messenger, $settings); |
|
3439 | 3439 | } |
3440 | 3440 | |
3441 | - else if ( $this->_req_data['type'] == 'message_type' ) { |
|
3441 | + else if ($this->_req_data['type'] == 'message_type') { |
|
3442 | 3442 | $settings = $this->_req_data['message_type_settings']; |
3443 | 3443 | $messenger = $settings['messenger']; |
3444 | 3444 | $message_type = $settings['message_type']; |
3445 | 3445 | |
3446 | - foreach ( $settings as $key => $value ) { |
|
3447 | - switch ( $key ) { |
|
3446 | + foreach ($settings as $key => $value) { |
|
3447 | + switch ($key) { |
|
3448 | 3448 | case 'messenger' : |
3449 | - unset( $settings['messenger'] ); |
|
3449 | + unset($settings['messenger']); |
|
3450 | 3450 | break; |
3451 | 3451 | case 'message_type' : |
3452 | - unset( $settings['message_type'] ); |
|
3452 | + unset($settings['message_type']); |
|
3453 | 3453 | break; |
3454 | 3454 | default : |
3455 | 3455 | $settings[$key] = $value; |
@@ -3457,16 +3457,16 @@ discard block |
||
3457 | 3457 | } |
3458 | 3458 | } |
3459 | 3459 | |
3460 | - $this->_message_resource_manager->add_settings_for_message_type( $messenger, $message_type, $settings ); |
|
3460 | + $this->_message_resource_manager->add_settings_for_message_type($messenger, $message_type, $settings); |
|
3461 | 3461 | } |
3462 | 3462 | |
3463 | 3463 | //okay we should have the data all setup. Now we just update! |
3464 | 3464 | $success = $this->_message_resource_manager->update_active_messengers_option(); |
3465 | 3465 | |
3466 | - if ( $success ) { |
|
3467 | - EE_Error::add_success( __('Settings updated', 'event_espresso') ); |
|
3466 | + if ($success) { |
|
3467 | + EE_Error::add_success(__('Settings updated', 'event_espresso')); |
|
3468 | 3468 | } else { |
3469 | - EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3469 | + EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3470 | 3470 | } |
3471 | 3471 | |
3472 | 3472 | $this->_template_args['success'] = $success; |
@@ -3488,8 +3488,8 @@ discard block |
||
3488 | 3488 | */ |
3489 | 3489 | protected function _generate_now() { |
3490 | 3490 | $msg_ids = $this->_get_msg_ids_from_request(); |
3491 | - EED_Messages::generate_now( $msg_ids ); |
|
3492 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3491 | + EED_Messages::generate_now($msg_ids); |
|
3492 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3493 | 3493 | } |
3494 | 3494 | |
3495 | 3495 | |
@@ -3504,7 +3504,7 @@ discard block |
||
3504 | 3504 | protected function _generate_and_send_now() { |
3505 | 3505 | $this->_generate_now(); |
3506 | 3506 | $this->_send_now(); |
3507 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3507 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3508 | 3508 | } |
3509 | 3509 | |
3510 | 3510 | |
@@ -3518,8 +3518,8 @@ discard block |
||
3518 | 3518 | */ |
3519 | 3519 | protected function _queue_for_resending() { |
3520 | 3520 | $msg_ids = $this->_get_msg_ids_from_request(); |
3521 | - EED_Messages::queue_for_resending( $msg_ids ); |
|
3522 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3521 | + EED_Messages::queue_for_resending($msg_ids); |
|
3522 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3523 | 3523 | } |
3524 | 3524 | |
3525 | 3525 | |
@@ -3532,8 +3532,8 @@ discard block |
||
3532 | 3532 | */ |
3533 | 3533 | protected function _send_now() { |
3534 | 3534 | $msg_ids = $this->_get_msg_ids_from_request(); |
3535 | - EED_Messages::send_now( $msg_ids ); |
|
3536 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3535 | + EED_Messages::send_now($msg_ids); |
|
3536 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3537 | 3537 | } |
3538 | 3538 | |
3539 | 3539 | |
@@ -3547,23 +3547,23 @@ discard block |
||
3547 | 3547 | protected function _delete_ee_messages() { |
3548 | 3548 | $msg_ids = $this->_get_msg_ids_from_request(); |
3549 | 3549 | $deleted_count = 0; |
3550 | - foreach ( $msg_ids as $msg_id ) { |
|
3551 | - if ( EEM_Message::instance()->delete_by_ID( $msg_id ) ) { |
|
3550 | + foreach ($msg_ids as $msg_id) { |
|
3551 | + if (EEM_Message::instance()->delete_by_ID($msg_id)) { |
|
3552 | 3552 | $deleted_count++; |
3553 | 3553 | } |
3554 | 3554 | } |
3555 | - if ( $deleted_count ) { |
|
3555 | + if ($deleted_count) { |
|
3556 | 3556 | $this->_redirect_after_action( |
3557 | 3557 | true, |
3558 | - _n( 'message', 'messages', $deleted_count, 'event_espresso' ), |
|
3558 | + _n('message', 'messages', $deleted_count, 'event_espresso'), |
|
3559 | 3559 | __('deleted', 'event_espresso') |
3560 | 3560 | ); |
3561 | 3561 | } else { |
3562 | 3562 | EE_Error::add_error( |
3563 | - _n( 'The message was not deleted.', 'The messages were not deleted', count( $msg_ids ), 'event_espresso' ), |
|
3563 | + _n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'), |
|
3564 | 3564 | __FILE__, __FUNCTION__, __LINE__ |
3565 | 3565 | ); |
3566 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3566 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3567 | 3567 | } |
3568 | 3568 | } |
3569 | 3569 | |
@@ -3576,10 +3576,10 @@ discard block |
||
3576 | 3576 | * @return array |
3577 | 3577 | */ |
3578 | 3578 | protected function _get_msg_ids_from_request() { |
3579 | - if ( ! isset( $this->_req_data['MSG_ID'] ) ) { |
|
3579 | + if ( ! isset($this->_req_data['MSG_ID'])) { |
|
3580 | 3580 | return array(); |
3581 | 3581 | } |
3582 | - return is_array( $this->_req_data['MSG_ID'] ) ? array_keys( $this->_req_data['MSG_ID'] ) : array( $this->_req_data['MSG_ID'] ); |
|
3582 | + return is_array($this->_req_data['MSG_ID']) ? array_keys($this->_req_data['MSG_ID']) : array($this->_req_data['MSG_ID']); |
|
3583 | 3583 | } |
3584 | 3584 | |
3585 | 3585 |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * |
@@ -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 | /** |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | |
42 | 42 | |
43 | 43 | protected function _setup_data() { |
44 | - $this->_data = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, FALSE); |
|
45 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, TRUE, TRUE ); |
|
44 | + $this->_data = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, FALSE); |
|
45 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, TRUE, TRUE); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -51,21 +51,21 @@ discard block |
||
51 | 51 | |
52 | 52 | protected function _set_properties() { |
53 | 53 | $this->_wp_list_args = array( |
54 | - 'singular' => __('Message Template Group', 'event_espresso' ), |
|
55 | - 'plural' => __('Message Template', 'event_espresso' ), |
|
54 | + 'singular' => __('Message Template Group', 'event_espresso'), |
|
55 | + 'plural' => __('Message Template', 'event_espresso'), |
|
56 | 56 | 'ajax' => TRUE, //for now, |
57 | 57 | 'screen' => $this->get_admin_page()->get_current_screen()->id |
58 | 58 | ); |
59 | 59 | $this->_columns = array( |
60 | 60 | //'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
61 | 61 | 'message_type' => __('Message Type', 'event_espresso'), |
62 | - 'messenger' => __( 'Messenger', 'event_espresso'), |
|
63 | - 'description' => __( 'Description', 'event_espresso' ), |
|
62 | + 'messenger' => __('Messenger', 'event_espresso'), |
|
63 | + 'description' => __('Description', 'event_espresso'), |
|
64 | 64 | //'messages_sent' => __( 'Total Sent', 'event_espresso' ) //todo this will come later when we've got message tracking in place. |
65 | 65 | ); |
66 | 66 | |
67 | 67 | $this->_sortable_columns = array( |
68 | - 'messenger' => array( 'MTP_messenger' => TRUE ), |
|
68 | + 'messenger' => array('MTP_messenger' => TRUE), |
|
69 | 69 | //'message_type' => array( 'MTP_message_type' => FALSE ) |
70 | 70 | ); |
71 | 71 | |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return string |
86 | 86 | */ |
87 | - public function single_row( $item ) { |
|
87 | + public function single_row($item) { |
|
88 | 88 | $message_type = $item->message_type_obj(); |
89 | 89 | $messenger = $item->messenger_obj(); |
90 | 90 | |
91 | - if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger ) { |
|
91 | + if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
92 | 92 | echo ''; |
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | - parent::single_row( $item ); |
|
96 | + parent::single_row($item); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -109,33 +109,33 @@ discard block |
||
109 | 109 | |
110 | 110 | $msgr_default[0] = array( |
111 | 111 | 'id' => 'none_selected', |
112 | - 'text' => __( 'Show All Messengers', 'event_espresso' ) |
|
112 | + 'text' => __('Show All Messengers', 'event_espresso') |
|
113 | 113 | ); |
114 | 114 | |
115 | 115 | $mt_default[0] = array( |
116 | 116 | 'id' => 'none_selected', |
117 | - 'text' => __( 'Show All Message Types', 'event_espresso' ) |
|
117 | + 'text' => __('Show All Message Types', 'event_espresso') |
|
118 | 118 | ); |
119 | 119 | |
120 | - $msgr_filters = ! empty( $m_values ) ? array_merge( $msgr_default, $m_values ) : array(); |
|
121 | - $mt_filters = ! empty( $mt_values ) ? array_merge( $mt_default, $mt_values ) : array(); |
|
120 | + $msgr_filters = ! empty($m_values) ? array_merge($msgr_default, $m_values) : array(); |
|
121 | + $mt_filters = ! empty($mt_values) ? array_merge($mt_default, $mt_values) : array(); |
|
122 | 122 | |
123 | - if ( empty( $m_values ) ) { |
|
123 | + if (empty($m_values)) { |
|
124 | 124 | $msgr_filters[0] = array( |
125 | 125 | 'id' => 'no_messenger_options', |
126 | - 'text' => __( 'No Messengers active', 'event_espresso' ) |
|
126 | + 'text' => __('No Messengers active', 'event_espresso') |
|
127 | 127 | ); |
128 | 128 | } |
129 | 129 | |
130 | - if ( empty( $mt_values ) ) { |
|
130 | + if (empty($mt_values)) { |
|
131 | 131 | $mt_filters[0] = array( |
132 | 132 | 'id' => 'no_message_type_options', |
133 | - 'text' => __( 'No Message Types active', 'event_espresso' ) |
|
133 | + 'text' => __('No Message Types active', 'event_espresso') |
|
134 | 134 | ); |
135 | 135 | } |
136 | 136 | |
137 | - $filters[] = EEH_Form_Fields::select_input( 'ee_messenger_filter_by', $msgr_filters, isset( $this->_req_data['ee_messenger_filter_by'] ) ? sanitize_key( $this->_req_data['ee_messenger_filter_by'] ) : '' ); |
|
138 | - $filters[] = EEH_Form_Fields::select_input( 'ee_message_type_filter_by', $mt_filters, isset( $this->_req_data['ee_message_type_filter_by'] ) ? sanitize_key( $this->_req_data['ee_message_type_filter_by'] ) : '' ); |
|
137 | + $filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_key($this->_req_data['ee_messenger_filter_by']) : ''); |
|
138 | + $filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_key($this->_req_data['ee_message_type_filter_by']) : ''); |
|
139 | 139 | return $filters; |
140 | 140 | } |
141 | 141 | |
@@ -143,20 +143,20 @@ discard block |
||
143 | 143 | * we're just removing the search box for message templates, not needed. |
144 | 144 | * @return string (empty); |
145 | 145 | */ |
146 | - function search_box( $text, $input_id ) { |
|
146 | + function search_box($text, $input_id) { |
|
147 | 147 | return ''; |
148 | 148 | } |
149 | 149 | |
150 | 150 | |
151 | 151 | protected function _add_view_counts() { |
152 | - foreach ( $this->_views as $view => $args ) { |
|
153 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( $this->_per_page, $view, TRUE, TRUE ); |
|
152 | + foreach ($this->_views as $view => $args) { |
|
153 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates($this->_per_page, $view, TRUE, TRUE); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | 157 | |
158 | 158 | |
159 | - public function column_cb( $item ) { |
|
159 | + public function column_cb($item) { |
|
160 | 160 | return ''; |
161 | 161 | } |
162 | 162 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | |
165 | 165 | |
166 | 166 | |
167 | - function column_description( $item ) { |
|
168 | - return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
167 | + function column_description($item) { |
|
168 | + return '<p>'.$item->message_type_obj()->description.'</p>'; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -180,27 +180,27 @@ discard block |
||
180 | 180 | $actions = array(); |
181 | 181 | |
182 | 182 | // edit link but only if item isn't trashed. |
183 | - if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ) { |
|
184 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_message_template', 'id'=>$item->GRP_ID() ), EE_MSG_ADMIN_URL ); |
|
185 | - $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template Group', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>'; |
|
183 | + if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID())) { |
|
184 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID()), EE_MSG_ADMIN_URL); |
|
185 | + $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>'; |
|
186 | 186 | } |
187 | 187 | |
188 | - $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template Group', 'event_espresso' ) . '">' . ucwords( $item->messenger_obj()->label['singular'] ) . '</a>' : ucwords( $item->messenger_obj()->label['singular'] ); |
|
188 | + $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'.ucwords($item->messenger_obj()->label['singular']).'</a>' : ucwords($item->messenger_obj()->label['singular']); |
|
189 | 189 | |
190 | 190 | //we want to display the contexts in here so we need to set them up |
191 | 191 | $c_label = $item->context_label(); |
192 | 192 | $c_configs = $item->contexts_config(); |
193 | 193 | $ctxt = array(); |
194 | 194 | $context_templates = $item->context_templates(); |
195 | - foreach ( $context_templates as $context => $template_fields ) { |
|
196 | - $mtp_to = !empty( $context_templates[$context]['to'] ) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
197 | - $inactive = empty( $mtp_to ) && !empty( $context_templates[$context]['to'] ) ? ' class="mtp-inactive"' : ''; |
|
195 | + foreach ($context_templates as $context => $template_fields) { |
|
196 | + $mtp_to = ! empty($context_templates[$context]['to']) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
197 | + $inactive = empty($mtp_to) && ! empty($context_templates[$context]['to']) ? ' class="mtp-inactive"' : ''; |
|
198 | 198 | $context_title = ucwords($c_configs[$context]['label']); |
199 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL ); |
|
200 | - $ctxt[] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a' . $inactive . ' href="'. $edit_link . '" title="' . esc_attr__('Edit Context', 'event_espresso') . '">' . $context_title . '</a>' : $context_title; |
|
199 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL); |
|
200 | + $ctxt[] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a'.$inactive.' href="'.$edit_link.'" title="'.esc_attr__('Edit Context', 'event_espresso').'">'.$context_title.'</a>' : $context_title; |
|
201 | 201 | } |
202 | 202 | |
203 | - $ctx_content = !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? sprintf( __('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural']) ) . implode(' | ', $ctxt) : ''; |
|
203 | + $ctx_content = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? sprintf(__('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural'])).implode(' | ', $ctxt) : ''; |
|
204 | 204 | |
205 | 205 | |
206 | 206 | //Return the name contents |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | /* $1%s */ $name_link, |
209 | 209 | /* $2%s */ $item->GRP_ID(), |
210 | 210 | /* %4$s */ $ctx_content, |
211 | - /* $3%s */ $this->row_actions( $actions ) |
|
211 | + /* $3%s */ $this->row_actions($actions) |
|
212 | 212 | ); |
213 | 213 | } |
214 | 214 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @return string message_type name |
219 | 219 | */ |
220 | 220 | function column_message_type($item) { |
221 | - return ucwords($item->message_type_obj()->label['singular'] ); |
|
221 | + return ucwords($item->message_type_obj()->label['singular']); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | |
94 | 94 | private function _registration_trash_message() { |
95 | - return '<p>' . __('This lock-icon means that this registration cannot be trashed. Registrations that belong to a transaction that has payments cannot be trashed. If you wish to trash this registration then you must delete all payments attached to the related transaction first.', 'event_espresso') . '</p>'; |
|
95 | + return '<p>'.__('This lock-icon means that this registration cannot be trashed. Registrations that belong to a transaction that has payments cannot be trashed. If you wish to trash this registration then you must delete all payments attached to the related transaction first.', 'event_espresso').'</p>'; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param EEM_Registration constant $status What status is set (by class) |
105 | 105 | * @return string The status legend with the related status highlighted |
106 | 106 | */ |
107 | - private function _registration_status_legend( $status ) { |
|
107 | + private function _registration_status_legend($status) { |
|
108 | 108 | |
109 | 109 | $status_array = array( |
110 | 110 | 'approved_status' => EEM_Registration::status_id_approved, |
@@ -114,6 +114,6 @@ discard block |
||
114 | 114 | 'cancelled_status' => EEM_Registration::status_id_cancelled |
115 | 115 | ); |
116 | 116 | |
117 | - return EEH_Template::status_legend( $status_array, $status ); |
|
117 | + return EEH_Template::status_legend($status_array, $status); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | \ No newline at end of file |