@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public static function instance() { |
178 | 178 | // check if class object is instantiated |
179 | - if ( ! self::$_instance instanceof EE_Registry ) { |
|
179 | + if ( ! self::$_instance instanceof EE_Registry) { |
|
180 | 180 | self::$_instance = new self(); |
181 | 181 | } |
182 | 182 | return self::$_instance; |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | $this->modules = new StdClass(); |
214 | 214 | $this->shortcodes = new StdClass(); |
215 | 215 | $this->widgets = new StdClass(); |
216 | - $this->load_core( 'Base', array(), true ); |
|
217 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
216 | + $this->load_core('Base', array(), true); |
|
217 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function init() { |
238 | 238 | // Get current page protocol |
239 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
239 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
240 | 240 | // Output admin-ajax.php URL with same protocol as current page |
241 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
242 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
241 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
242 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | * @return string |
251 | 251 | */ |
252 | 252 | public static function localize_i18n_js_strings() { |
253 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
254 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
255 | - if ( is_scalar( $value ) ) { |
|
256 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
253 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
254 | + foreach ($i18n_js_strings as $key => $value) { |
|
255 | + if (is_scalar($value)) { |
|
256 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
260 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
@@ -265,15 +265,15 @@ discard block |
||
265 | 265 | /** |
266 | 266 | * @param mixed string | EED_Module $module |
267 | 267 | */ |
268 | - public function add_module( $module ) { |
|
269 | - if ( $module instanceof EED_Module ) { |
|
270 | - $module_class = get_class( $module ); |
|
268 | + public function add_module($module) { |
|
269 | + if ($module instanceof EED_Module) { |
|
270 | + $module_class = get_class($module); |
|
271 | 271 | $this->modules->{$module_class} = $module; |
272 | 272 | } else { |
273 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
274 | - $this->load_core( 'Module_Request_Router' ); |
|
273 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
274 | + $this->load_core('Module_Request_Router'); |
|
275 | 275 | } |
276 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
276 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | * @param string $module_name |
284 | 284 | * @return mixed EED_Module | NULL |
285 | 285 | */ |
286 | - public function get_module( $module_name = '' ) { |
|
287 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
286 | + public function get_module($module_name = '') { |
|
287 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -299,20 +299,20 @@ discard block |
||
299 | 299 | * @param bool $resolve_dependencies |
300 | 300 | * @return mixed |
301 | 301 | */ |
302 | - public function load_core( $class_name, $arguments = array(), $load_only = false, $resolve_dependencies = false ) { |
|
302 | + public function load_core($class_name, $arguments = array(), $load_only = false, $resolve_dependencies = false) { |
|
303 | 303 | $core_paths = apply_filters( |
304 | 304 | 'FHEE__EE_Registry__load_core__core_paths', |
305 | 305 | array( |
306 | 306 | EE_CORE, |
307 | 307 | EE_ADMIN, |
308 | 308 | EE_CPTS, |
309 | - EE_CORE . 'data_migration_scripts' . DS, |
|
310 | - EE_CORE . 'request_stack' . DS, |
|
311 | - EE_CORE . 'middleware' . DS, |
|
309 | + EE_CORE.'data_migration_scripts'.DS, |
|
310 | + EE_CORE.'request_stack'.DS, |
|
311 | + EE_CORE.'middleware'.DS, |
|
312 | 312 | ) |
313 | 313 | ); |
314 | 314 | // retrieve instantiated class |
315 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only, $resolve_dependencies ); |
|
315 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only, $resolve_dependencies); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | * @param bool $load_only |
327 | 327 | * @return mixed |
328 | 328 | */ |
329 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
329 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
330 | 330 | $service_paths = apply_filters( |
331 | 331 | 'FHEE__EE_Registry__load_service__service_paths', |
332 | 332 | array( |
333 | - EE_CORE . 'services' . DS, |
|
333 | + EE_CORE.'services'.DS, |
|
334 | 334 | ) |
335 | 335 | ); |
336 | 336 | // retrieve instantiated class |
337 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only, true ); |
|
337 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only, true); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | * @param mixed $arguments |
348 | 348 | * @return EE_Data_Migration_Script_Base |
349 | 349 | */ |
350 | - public function load_dms( $class_name, $arguments = array() ) { |
|
350 | + public function load_dms($class_name, $arguments = array()) { |
|
351 | 351 | // retrieve instantiated class |
352 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
352 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -364,14 +364,14 @@ discard block |
||
364 | 364 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
365 | 365 | * @return EE_Base_Class |
366 | 366 | */ |
367 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
368 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
367 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
368 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
369 | 369 | EE_CORE, |
370 | 370 | EE_CLASSES, |
371 | 371 | EE_BUSINESS |
372 | - ) ); |
|
372 | + )); |
|
373 | 373 | // retrieve instantiated class |
374 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
374 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | * @param bool $load_only |
385 | 385 | * @return EEH_Base |
386 | 386 | */ |
387 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
388 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
387 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
388 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
389 | 389 | // retrieve instantiated class |
390 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
390 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | |
@@ -401,16 +401,16 @@ discard block |
||
401 | 401 | * @param bool $load_only |
402 | 402 | * @return mixed |
403 | 403 | */ |
404 | - public function load_lib( $class_name, $arguments = array(), $load_only = false ) { |
|
404 | + public function load_lib($class_name, $arguments = array(), $load_only = false) { |
|
405 | 405 | $paths = array( |
406 | 406 | EE_LIBRARIES, |
407 | - EE_LIBRARIES . 'messages' . DS, |
|
408 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
409 | - EE_LIBRARIES . 'qtips' . DS, |
|
410 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
407 | + EE_LIBRARIES.'messages'.DS, |
|
408 | + EE_LIBRARIES.'shortcodes'.DS, |
|
409 | + EE_LIBRARIES.'qtips'.DS, |
|
410 | + EE_LIBRARIES.'payment_methods'.DS, |
|
411 | 411 | ); |
412 | 412 | // retrieve instantiated class |
413 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, true, $load_only ); |
|
413 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, true, $load_only); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
@@ -423,13 +423,13 @@ discard block |
||
423 | 423 | * @param bool $load_only |
424 | 424 | * @return EEM_Base |
425 | 425 | */ |
426 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
427 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
426 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
427 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
428 | 428 | EE_MODELS, |
429 | 429 | EE_CORE |
430 | - ) ); |
|
430 | + )); |
|
431 | 431 | // retrieve instantiated class |
432 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
432 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -442,15 +442,15 @@ discard block |
||
442 | 442 | * @param bool $load_only |
443 | 443 | * @return mixed |
444 | 444 | */ |
445 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
445 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
446 | 446 | $paths = array( |
447 | - EE_MODELS . 'fields' . DS, |
|
448 | - EE_MODELS . 'helpers' . DS, |
|
449 | - EE_MODELS . 'relations' . DS, |
|
450 | - EE_MODELS . 'strategies' . DS |
|
447 | + EE_MODELS.'fields'.DS, |
|
448 | + EE_MODELS.'helpers'.DS, |
|
449 | + EE_MODELS.'relations'.DS, |
|
450 | + EE_MODELS.'strategies'.DS |
|
451 | 451 | ); |
452 | 452 | // retrieve instantiated class |
453 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
453 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
461 | 461 | * @return boolean |
462 | 462 | */ |
463 | - public function is_model_name( $model_name ) { |
|
464 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
463 | + public function is_model_name($model_name) { |
|
464 | + return isset($this->models[$model_name]) ? true : false; |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -476,9 +476,9 @@ discard block |
||
476 | 476 | * @param bool $load_only |
477 | 477 | * @return mixed |
478 | 478 | */ |
479 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
479 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
480 | 480 | // retrieve instantiated class |
481 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
481 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | |
@@ -493,9 +493,9 @@ discard block |
||
493 | 493 | * @param bool $load_only |
494 | 494 | * @return EE_Addon |
495 | 495 | */ |
496 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
496 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
497 | 497 | // retrieve instantiated class |
498 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
498 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -527,29 +527,29 @@ discard block |
||
527 | 527 | $resolve_dependencies = false |
528 | 528 | ) { |
529 | 529 | // strip php file extension |
530 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
530 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
531 | 531 | // does the class have a prefix ? |
532 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
532 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
533 | 533 | // make sure $class_prefix is uppercase |
534 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
534 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
535 | 535 | // add class prefix ONCE!!! |
536 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
536 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
537 | 537 | } |
538 | - if ( ! $this->_skip_cache ) { |
|
538 | + if ( ! $this->_skip_cache) { |
|
539 | 539 | // return object if it's already cached |
540 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
541 | - if ( $cached_class !== null ) { |
|
540 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
541 | + if ($cached_class !== null) { |
|
542 | 542 | return $cached_class; |
543 | 543 | } |
544 | 544 | } |
545 | 545 | // get full path to file |
546 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
546 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
547 | 547 | // load the file |
548 | - $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
548 | + $this->_require_file($path, $class_name, $type, $file_paths); |
|
549 | 549 | // instantiate the requested object |
550 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db, $load_only, $resolve_dependencies ); |
|
550 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db, $load_only, $resolve_dependencies); |
|
551 | 551 | // save it for later... kinda like gum { : $ |
552 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db, $cache ); |
|
552 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db, $cache); |
|
553 | 553 | $this->_skip_cache = false; |
554 | 554 | return $class_obj; |
555 | 555 | } |
@@ -571,21 +571,21 @@ discard block |
||
571 | 571 | * @param string $class_prefix |
572 | 572 | * @return null|object |
573 | 573 | */ |
574 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
575 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
576 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
574 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
575 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
576 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
577 | 577 | } else { |
578 | 578 | // have to specify something, but not anything that will conflict |
579 | 579 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
580 | 580 | } |
581 | 581 | // check if class has already been loaded, and return it if it has been |
582 | - if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) { |
|
582 | + if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) { |
|
583 | 583 | return $this->{$class_abbreviation}; |
584 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
584 | + } else if (isset ($this->{$class_name} )) { |
|
585 | 585 | return $this->{$class_name}; |
586 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
586 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
587 | 587 | return $this->LIB->{$class_name}; |
588 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
588 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
589 | 589 | return $this->addons->{$class_name}; |
590 | 590 | } |
591 | 591 | return null; |
@@ -606,20 +606,20 @@ discard block |
||
606 | 606 | * @param array $file_paths |
607 | 607 | * @return string | bool |
608 | 608 | */ |
609 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
609 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
610 | 610 | // make sure $file_paths is an array |
611 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
611 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
612 | 612 | // cycle thru paths |
613 | - foreach ( $file_paths as $key => $file_path ) { |
|
613 | + foreach ($file_paths as $key => $file_path) { |
|
614 | 614 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
615 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
615 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
616 | 616 | // prep file type |
617 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
617 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
618 | 618 | // build full file path |
619 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
619 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
620 | 620 | //does the file exist and can be read ? |
621 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
622 | - return $file_paths[ $key ]; |
|
621 | + if (is_readable($file_paths[$key])) { |
|
622 | + return $file_paths[$key]; |
|
623 | 623 | } |
624 | 624 | } |
625 | 625 | return false; |
@@ -641,31 +641,31 @@ discard block |
||
641 | 641 | * @return void |
642 | 642 | * @throws \EE_Error |
643 | 643 | */ |
644 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
644 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
645 | 645 | // don't give up! you gotta... |
646 | 646 | try { |
647 | 647 | //does the file exist and can it be read ? |
648 | - if ( ! $path ) { |
|
648 | + if ( ! $path) { |
|
649 | 649 | $this->_skip_cache = false; |
650 | 650 | // so sorry, can't find the file |
651 | - throw new EE_Error ( |
|
651 | + throw new EE_Error( |
|
652 | 652 | sprintf( |
653 | - __( 'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso' ), |
|
654 | - trim( $type, '.' ), |
|
653 | + __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'), |
|
654 | + trim($type, '.'), |
|
655 | 655 | $class_name, |
656 | - '<br />' . implode( ',<br />', $file_paths ) |
|
656 | + '<br />'.implode(',<br />', $file_paths) |
|
657 | 657 | ) |
658 | 658 | ); |
659 | 659 | } |
660 | 660 | // get the file |
661 | - require_once( $path ); |
|
661 | + require_once($path); |
|
662 | 662 | // if the class isn't already declared somewhere |
663 | - if ( class_exists( $class_name, false ) === false ) { |
|
663 | + if (class_exists($class_name, false) === false) { |
|
664 | 664 | $this->_skip_cache = false; |
665 | 665 | // so sorry, not a class |
666 | 666 | throw new EE_Error( |
667 | 667 | sprintf( |
668 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
668 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
669 | 669 | $type, |
670 | 670 | $path, |
671 | 671 | $class_name |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | ); |
674 | 674 | } |
675 | 675 | |
676 | - } catch ( EE_Error $e ) { |
|
676 | + } catch (EE_Error $e) { |
|
677 | 677 | $e->get_error(); |
678 | 678 | } |
679 | 679 | } |
@@ -705,53 +705,53 @@ discard block |
||
705 | 705 | * @return null | object |
706 | 706 | * @throws \EE_Error |
707 | 707 | */ |
708 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false, $load_only = false, $resolve_dependencies = true ) { |
|
708 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false, $load_only = false, $resolve_dependencies = true) { |
|
709 | 709 | $class_obj = null; |
710 | - $resolve_dependencies = isset( $this->_auto_resolve_dependencies[ $class_name ] ) /*&& empty( $arguments )*/ ? true : $resolve_dependencies; |
|
710 | + $resolve_dependencies = isset($this->_auto_resolve_dependencies[$class_name]) /*&& empty( $arguments )*/ ? true : $resolve_dependencies; |
|
711 | 711 | // don't give up! you gotta... |
712 | 712 | try { |
713 | 713 | // create reflection |
714 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
714 | + $reflector = $this->get_ReflectionClass($class_name); |
|
715 | 715 | // make sure arguments are an array |
716 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
716 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
717 | 717 | // and if arguments array is NOT numerically indexed, then we want it to stay as an array, |
718 | 718 | // so wrap it in an additional array so that it doesn't get split into multiple parameters |
719 | - $arguments = isset( $arguments[ 0 ] ) ? $arguments : array( $arguments ); |
|
719 | + $arguments = isset($arguments[0]) ? $arguments : array($arguments); |
|
720 | 720 | // attempt to inject dependencies ? |
721 | - if ( $resolve_dependencies && ! $from_db && ! $load_only && ! $reflector->isSubclassOf( 'EE_Base_Class' ) ) { |
|
722 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
721 | + if ($resolve_dependencies && ! $from_db && ! $load_only && ! $reflector->isSubclassOf('EE_Base_Class')) { |
|
722 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
723 | 723 | } |
724 | 724 | // instantiate the class and add to the LIB array for tracking |
725 | 725 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
726 | - if ( $reflector->getConstructor() === null || $reflector->isAbstract() || $load_only ) { |
|
726 | + if ($reflector->getConstructor() === null || $reflector->isAbstract() || $load_only) { |
|
727 | 727 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
728 | 728 | //$instantiation_mode = "no constructor"; |
729 | 729 | return true; |
730 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
730 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
731 | 731 | //$instantiation_mode = "new_instance_from_db"; |
732 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
733 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
732 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
733 | + } else if (method_exists($class_name, 'new_instance')) { |
|
734 | 734 | //$instantiation_mode = "new_instance"; |
735 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
736 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
735 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
736 | + } else if (method_exists($class_name, 'instance')) { |
|
737 | 737 | //$instantiation_mode = "instance"; |
738 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
739 | - } else if ( $reflector->isInstantiable() ) { |
|
738 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
739 | + } else if ($reflector->isInstantiable()) { |
|
740 | 740 | //$instantiation_mode = "isInstantiable"; |
741 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
742 | - } else if ( ! $load_only ) { |
|
741 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
742 | + } else if ( ! $load_only) { |
|
743 | 743 | $this->_skip_cache = false; |
744 | 744 | // heh ? something's not right ! |
745 | 745 | //$instantiation_mode = 'none'; |
746 | 746 | throw new EE_Error( |
747 | 747 | sprintf( |
748 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
748 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
749 | 749 | $type, |
750 | 750 | $class_name |
751 | 751 | ) |
752 | 752 | ); |
753 | 753 | } |
754 | - } catch ( EE_Error $e ) { |
|
754 | + } catch (EE_Error $e) { |
|
755 | 755 | $e->get_error(); |
756 | 756 | } |
757 | 757 | return $class_obj; |
@@ -769,14 +769,14 @@ discard block |
||
769 | 769 | * @param string $class_name |
770 | 770 | * @return ReflectionClass |
771 | 771 | */ |
772 | - public function get_ReflectionClass( $class_name ) { |
|
772 | + public function get_ReflectionClass($class_name) { |
|
773 | 773 | if ( |
774 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
775 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
774 | + ! isset($this->_reflectors[$class_name]) |
|
775 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
776 | 776 | ) { |
777 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
777 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
778 | 778 | } |
779 | - return $this->_reflectors[ $class_name ]; |
|
779 | + return $this->_reflectors[$class_name]; |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | |
@@ -801,19 +801,19 @@ discard block |
||
801 | 801 | * @param array $arguments |
802 | 802 | * @return array |
803 | 803 | */ |
804 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
804 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
805 | 805 | // let's examine the constructor |
806 | 806 | $constructor = $reflector->getConstructor(); |
807 | 807 | // whu? huh? nothing? |
808 | - if ( ! $constructor ) { |
|
808 | + if ( ! $constructor) { |
|
809 | 809 | return $arguments; |
810 | 810 | } |
811 | 811 | // get constructor parameters |
812 | 812 | $params = $constructor->getParameters(); |
813 | 813 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
814 | - $argument_keys = array_keys( $arguments ); |
|
814 | + $argument_keys = array_keys($arguments); |
|
815 | 815 | // now loop thru all of the constructors expected parameters |
816 | - foreach ( $params as $index => $param ) { |
|
816 | + foreach ($params as $index => $param) { |
|
817 | 817 | // is this a dependency for a specific class ? |
818 | 818 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
819 | 819 | if ( |
@@ -821,44 +821,44 @@ discard block |
||
821 | 821 | $param_class === null || |
822 | 822 | ( |
823 | 823 | // something already exists in the incoming arguments for this param |
824 | - isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
824 | + isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
825 | 825 | // AND it's the correct class |
826 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
826 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
827 | 827 | ) |
828 | 828 | |
829 | 829 | ) { |
830 | 830 | // so let's skip this argument and move on to the next |
831 | 831 | continue; |
832 | 832 | } else if ( |
833 | - isset( $this->_auto_resolve_dependencies[ $class_name ] ) |
|
834 | - && in_array( $param_class, $this->_auto_resolve_dependencies[ $class_name ] ) |
|
833 | + isset($this->_auto_resolve_dependencies[$class_name]) |
|
834 | + && in_array($param_class, $this->_auto_resolve_dependencies[$class_name]) |
|
835 | 835 | ) { |
836 | 836 | // we might have a dependency... let's MAYBE try and find it in our cache |
837 | - $cached_class = ! $this->_skip_cache ? $this->_get_cached_class( $param_class ) : null; |
|
837 | + $cached_class = ! $this->_skip_cache ? $this->_get_cached_class($param_class) : null; |
|
838 | 838 | $dependency = null; |
839 | 839 | // and grab it if it exists |
840 | - if ( $cached_class instanceof $param_class ) { |
|
840 | + if ($cached_class instanceof $param_class) { |
|
841 | 841 | $dependency = $cached_class; |
842 | - } else if ( $param_class != $class_name ) { |
|
843 | - $loader = EE_Dependency_Map::class_loader( $param_class ); |
|
842 | + } else if ($param_class != $class_name) { |
|
843 | + $loader = EE_Dependency_Map::class_loader($param_class); |
|
844 | 844 | // grab current state for skip cache property |
845 | 845 | $skip_cache = $this->_skip_cache; |
846 | 846 | // or if not cached, then let's try and load it directly |
847 | - $core_class = $this->$loader( $param_class ); |
|
847 | + $core_class = $this->$loader($param_class); |
|
848 | 848 | // reset skip cache so that it will work again for the next dependency |
849 | 849 | $this->_skip_cache = $skip_cache; |
850 | 850 | // as long as we aren't creating some recursive loading loop |
851 | - if ( $core_class instanceof $param_class ) { |
|
851 | + if ($core_class instanceof $param_class) { |
|
852 | 852 | $dependency = $core_class; |
853 | 853 | } |
854 | 854 | } |
855 | 855 | // did we successfully find the correct dependency ? |
856 | - if ( $dependency instanceof $param_class ) { |
|
856 | + if ($dependency instanceof $param_class) { |
|
857 | 857 | // then let's inject it into the incoming array of arguments at the correct location |
858 | - array_splice( $arguments, $index, 1, array( $dependency ) ); |
|
858 | + array_splice($arguments, $index, 1, array($dependency)); |
|
859 | 859 | } |
860 | 860 | } else { |
861 | - $arguments[ $index ] = null; |
|
861 | + $arguments[$index] = null; |
|
862 | 862 | } |
863 | 863 | |
864 | 864 | } |
@@ -887,16 +887,16 @@ discard block |
||
887 | 887 | * @param bool $cache |
888 | 888 | * @return void |
889 | 889 | */ |
890 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false, $cache = true ) { |
|
890 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false, $cache = true) { |
|
891 | 891 | // return newly instantiated class |
892 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
893 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
892 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
893 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
894 | 894 | $this->{$class_abbreviation} = $class_obj; |
895 | - } else if ( property_exists( $this, $class_name ) ) { |
|
895 | + } else if (property_exists($this, $class_name)) { |
|
896 | 896 | $this->{$class_name} = $class_obj; |
897 | - } else if ( $class_prefix == 'addon' && $cache ) { |
|
897 | + } else if ($class_prefix == 'addon' && $cache) { |
|
898 | 898 | $this->addons->{$class_name} = $class_obj; |
899 | - } else if ( ! $from_db && $cache ) { |
|
899 | + } else if ( ! $from_db && $cache) { |
|
900 | 900 | $this->LIB->{$class_name} = $class_obj; |
901 | 901 | } |
902 | 902 | } |
@@ -909,9 +909,9 @@ discard block |
||
909 | 909 | * @param string $name |
910 | 910 | * @return EE_Addon |
911 | 911 | */ |
912 | - public function get_addon_by_name( $name ) { |
|
913 | - foreach ( $this->addons as $addon ) { |
|
914 | - if ( $addon->name() == $name ) { |
|
912 | + public function get_addon_by_name($name) { |
|
913 | + foreach ($this->addons as $addon) { |
|
914 | + if ($addon->name() == $name) { |
|
915 | 915 | return $addon; |
916 | 916 | } |
917 | 917 | } |
@@ -927,8 +927,8 @@ discard block |
||
927 | 927 | */ |
928 | 928 | public function get_addons_by_name() { |
929 | 929 | $addons = array(); |
930 | - foreach ( $this->addons as $addon ) { |
|
931 | - $addons[ $addon->name() ] = $addon; |
|
930 | + foreach ($this->addons as $addon) { |
|
931 | + $addons[$addon->name()] = $addon; |
|
932 | 932 | } |
933 | 933 | return $addons; |
934 | 934 | } |
@@ -943,14 +943,14 @@ discard block |
||
943 | 943 | * @return \EEM_Base |
944 | 944 | * @throws \EE_Error |
945 | 945 | */ |
946 | - public function reset_model( $model_name ) { |
|
947 | - $model = $this->load_model( $model_name ); |
|
948 | - $model_class_name = get_class( $model ); |
|
946 | + public function reset_model($model_name) { |
|
947 | + $model = $this->load_model($model_name); |
|
948 | + $model_class_name = get_class($model); |
|
949 | 949 | //get that model reset it and make sure we nuke the old reference to it |
950 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
950 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
951 | 951 | $this->LIB->$model_class_name = $model::reset(); |
952 | 952 | } else { |
953 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
953 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
954 | 954 | } |
955 | 955 | return $this->LIB->$model_class_name; |
956 | 956 | } |
@@ -968,16 +968,16 @@ discard block |
||
968 | 968 | * currently reinstantiate the singletons at the moment) |
969 | 969 | * @return EE_Registry |
970 | 970 | */ |
971 | - public static function reset( $hard = false, $reinstantiate = true ) { |
|
971 | + public static function reset($hard = false, $reinstantiate = true) { |
|
972 | 972 | $instance = self::instance(); |
973 | - $instance->load_helper( 'Activation' ); |
|
973 | + $instance->load_helper('Activation'); |
|
974 | 974 | EEH_Activation::reset(); |
975 | 975 | $instance->_skip_cache = false; |
976 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
976 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
977 | 977 | $instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset(); |
978 | 978 | $instance->LIB = new stdClass(); |
979 | - foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) { |
|
980 | - $instance->reset_model( $model_name ); |
|
979 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
980 | + $instance->reset_model($model_name); |
|
981 | 981 | } |
982 | 982 | return $instance; |
983 | 983 | } |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | * @param $a |
998 | 998 | * @param $b |
999 | 999 | */ |
1000 | - final function __call( $a, $b ) { |
|
1000 | + final function __call($a, $b) { |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | /** |
1006 | 1006 | * @param $a |
1007 | 1007 | */ |
1008 | - final function __get( $a ) { |
|
1008 | + final function __get($a) { |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | * @param $a |
1015 | 1015 | * @param $b |
1016 | 1016 | */ |
1017 | - final function __set( $a, $b ) { |
|
1017 | + final function __set($a, $b) { |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | /** |
1023 | 1023 | * @param $a |
1024 | 1024 | */ |
1025 | - final function __isset( $a ) { |
|
1025 | + final function __isset($a) { |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | /** |
1031 | 1031 | * @param $a |
1032 | 1032 | */ |
1033 | - final function __unset( $a ) { |
|
1033 | + final function __unset($a) { |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | * @param $a |
1078 | 1078 | * @param $b |
1079 | 1079 | */ |
1080 | - final static function __callStatic( $a, $b ) { |
|
1080 | + final static function __callStatic($a, $b) { |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | /** |
@@ -1086,9 +1086,9 @@ discard block |
||
1086 | 1086 | */ |
1087 | 1087 | public function cpt_models() { |
1088 | 1088 | $cpt_models = array(); |
1089 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
1090 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
1091 | - $cpt_models[ $short_name ] = $classname; |
|
1089 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
1090 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
1091 | + $cpt_models[$short_name] = $classname; |
|
1092 | 1092 | } |
1093 | 1093 | } |
1094 | 1094 | return $cpt_models; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -97,67 +97,67 @@ discard block |
||
97 | 97 | 'message_type' => $message_type, |
98 | 98 | 'message' => $message |
99 | 99 | ); |
100 | - $this->_init_data( $template, $data, $valid_shortcodes, $extra_data ); |
|
100 | + $this->_init_data($template, $data, $valid_shortcodes, $extra_data); |
|
101 | 101 | $this->_template = is_array($template) ? $template['main'] : $template; |
102 | 102 | return $this->_parse_message_template(); |
103 | 103 | } |
104 | 104 | |
105 | 105 | |
106 | - public function parse_attendee_list_template( $template, EE_Registration $registration, $valid_shortcodes, $extra_data = array() ) { |
|
107 | - $this->_init_data( $template, $registration, $valid_shortcodes, $extra_data ); |
|
106 | + public function parse_attendee_list_template($template, EE_Registration $registration, $valid_shortcodes, $extra_data = array()) { |
|
107 | + $this->_init_data($template, $registration, $valid_shortcodes, $extra_data); |
|
108 | 108 | $this->_template = is_array($template) ? $template['attendee_list'] : $template; |
109 | 109 | return $this->_parse_message_template(); |
110 | 110 | } |
111 | 111 | |
112 | - public function parse_event_list_template( $template, EE_Event $event, $valid_shortcodes, $extra_data = array() ) { |
|
113 | - $this->_init_data( $template, $event, $valid_shortcodes, $extra_data ); |
|
112 | + public function parse_event_list_template($template, EE_Event $event, $valid_shortcodes, $extra_data = array()) { |
|
113 | + $this->_init_data($template, $event, $valid_shortcodes, $extra_data); |
|
114 | 114 | $this->_template = is_array($template) ? $template['event_list'] : $template; |
115 | 115 | return $this->_parse_message_template(); |
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | - public function parse_ticket_list_template( $template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array() ) { |
|
120 | - $this->_init_data( $template, $ticket, $valid_shortcodes, $extra_data ); |
|
119 | + public function parse_ticket_list_template($template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array()) { |
|
120 | + $this->_init_data($template, $ticket, $valid_shortcodes, $extra_data); |
|
121 | 121 | $this->_template = is_array($template) ? $template['ticket_list'] : $template; |
122 | 122 | return $this->_parse_message_template(); |
123 | 123 | } |
124 | 124 | |
125 | 125 | |
126 | 126 | |
127 | - public function parse_line_item_list_template( $template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array() ) { |
|
128 | - $this->_init_data( $template, $line_item, $valid_shortcodes, $extra_data ); |
|
129 | - $this->_template = is_array( $template ) ? $template['ticket_line_item_no_pms'] : $template; |
|
127 | + public function parse_line_item_list_template($template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array()) { |
|
128 | + $this->_init_data($template, $line_item, $valid_shortcodes, $extra_data); |
|
129 | + $this->_template = is_array($template) ? $template['ticket_line_item_no_pms'] : $template; |
|
130 | 130 | return $this->_parse_message_template(); |
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | - public function parse_payment_list_template( $template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array() ) { |
|
135 | - $this->_init_data( $template, $payment_item, $valid_shortcodes, $extra_data ); |
|
136 | - $this->_template = is_array( $template ) ? $template['payment_list'] : $template; |
|
134 | + public function parse_payment_list_template($template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array()) { |
|
135 | + $this->_init_data($template, $payment_item, $valid_shortcodes, $extra_data); |
|
136 | + $this->_template = is_array($template) ? $template['payment_list'] : $template; |
|
137 | 137 | return $this->_parse_message_template(); |
138 | 138 | } |
139 | 139 | |
140 | 140 | |
141 | - public function parse_datetime_list_template( $template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array() ) { |
|
142 | - $this->_init_data( $template, $datetime, $valid_shortcodes, $extra_data ); |
|
141 | + public function parse_datetime_list_template($template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array()) { |
|
142 | + $this->_init_data($template, $datetime, $valid_shortcodes, $extra_data); |
|
143 | 143 | $this->_template = is_array($template) ? $template['datetime_list'] : $template; |
144 | 144 | return $this->_parse_message_template(); |
145 | 145 | } |
146 | 146 | |
147 | 147 | |
148 | - public function parse_question_list_template( $template, EE_Answer $answer, $valid_shortcodes, $extra_data = array() ) { |
|
149 | - $this->_init_data( $template, $answer, $valid_shortcodes, $extra_data ); |
|
148 | + public function parse_question_list_template($template, EE_Answer $answer, $valid_shortcodes, $extra_data = array()) { |
|
149 | + $this->_init_data($template, $answer, $valid_shortcodes, $extra_data); |
|
150 | 150 | $this->_template = is_array($template) ? $template['question_list'] : $template; |
151 | 151 | return $this->_parse_message_template(); |
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | - private function _init_data( $template, $data, $valid_shortcodes, $extra_data = array() ) { |
|
155 | + private function _init_data($template, $data, $valid_shortcodes, $extra_data = array()) { |
|
156 | 156 | $this->_reset_props(); |
157 | 157 | $this->_data['template'] = $template; |
158 | 158 | $this->_data['data'] = $data; |
159 | 159 | $this->_data['extra_data'] = $extra_data; |
160 | - $this->_set_shortcodes( $valid_shortcodes ); |
|
160 | + $this->_set_shortcodes($valid_shortcodes); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | private function _parse_message_template() { |
177 | 177 | //now let's get a list of shortcodes that are found in the given template |
178 | - preg_match_all( '/(\[.+?\])/', $this->_template, $matches ); |
|
178 | + preg_match_all('/(\[.+?\])/', $this->_template, $matches); |
|
179 | 179 | $shortcodes = (array) $matches[0]; //this should be an array of shortcodes in the template string. |
180 | 180 | |
181 | 181 | $matched_code = array(); |
@@ -200,30 +200,30 @@ discard block |
||
200 | 200 | '[PAYMENT_LIST_*]' |
201 | 201 | ); |
202 | 202 | |
203 | - $list_type_shortcodes = apply_filters( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes ); |
|
203 | + $list_type_shortcodes = apply_filters('FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes); |
|
204 | 204 | |
205 | 205 | //now lets go ahead and loop through our parsers for each shortcode and setup the values |
206 | - foreach ( $shortcodes as $shortcode ) { |
|
206 | + foreach ($shortcodes as $shortcode) { |
|
207 | 207 | |
208 | - foreach ( $this->_shortcode_objs as $sc_obj ) { |
|
209 | - if ( $sc_obj instanceof EE_Shortcodes ){ |
|
208 | + foreach ($this->_shortcode_objs as $sc_obj) { |
|
209 | + if ($sc_obj instanceof EE_Shortcodes) { |
|
210 | 210 | //we need to setup any dynamic shortcodes so that they work with the array_key_exists |
211 | - preg_match_all( '/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches ); |
|
212 | - $sc_to_verify = !empty($matches[0] ) ? $matches[0][0] . ']' : $shortcode; |
|
211 | + preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches); |
|
212 | + $sc_to_verify = ! empty($matches[0]) ? $matches[0][0].']' : $shortcode; |
|
213 | 213 | |
214 | - if ( !array_key_exists( $sc_to_verify, $sc_obj->get_shortcodes() ) ) { |
|
214 | + if ( ! array_key_exists($sc_to_verify, $sc_obj->get_shortcodes())) { |
|
215 | 215 | continue; //the given shortcode isn't in this object |
216 | 216 | } |
217 | 217 | |
218 | 218 | //if this isn't a "list" type shortcode then we'll send along the data vanilla instead of in an array. |
219 | - if ( ! in_array( $sc_to_verify, $list_type_shortcodes ) ) { |
|
220 | - $data_send = !is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data; |
|
219 | + if ( ! in_array($sc_to_verify, $list_type_shortcodes)) { |
|
220 | + $data_send = ! is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data; |
|
221 | 221 | } else { |
222 | 222 | $data_send = $this->_data; |
223 | 223 | } |
224 | 224 | |
225 | 225 | |
226 | - $parsed = $sc_obj->parser( $shortcode, $data_send, $this->_data['extra_data'] ); |
|
226 | + $parsed = $sc_obj->parser($shortcode, $data_send, $this->_data['extra_data']); |
|
227 | 227 | |
228 | 228 | $matched_code[] = $shortcode; |
229 | 229 | $sc_values[] = $parsed; |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | * @param array $valid_shortcodes an array of strings corresponding to EE_Shortcode Library objects |
247 | 247 | * @return void |
248 | 248 | */ |
249 | - private function _set_shortcodes( $valid_shortcodes ) { |
|
250 | - foreach ( $valid_shortcodes as $shortcode_ref ) { |
|
251 | - $ref = ucwords( str_replace('_', ' ', $shortcode_ref ) ); |
|
252 | - $ref = str_replace( ' ', '_', $ref ); |
|
253 | - $classname = 'EE_' . $ref . '_Shortcodes'; |
|
254 | - if ( class_exists( $classname ) ) { |
|
249 | + private function _set_shortcodes($valid_shortcodes) { |
|
250 | + foreach ($valid_shortcodes as $shortcode_ref) { |
|
251 | + $ref = ucwords(str_replace('_', ' ', $shortcode_ref)); |
|
252 | + $ref = str_replace(' ', '_', $ref); |
|
253 | + $classname = 'EE_'.$ref.'_Shortcodes'; |
|
254 | + if (class_exists($classname)) { |
|
255 | 255 | $this->_shortcode_objs[] = new $classname; |
256 | 256 | } |
257 | 257 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | // check if class object is instantiated, and instantiated properly |
38 | - if ( ! self::$_instance instanceof EE_Payment_Method_Manager ) { |
|
38 | + if ( ! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
39 | 39 | self::$_instance = new self(); |
40 | 40 | } |
41 | 41 | EE_Registry::instance()->load_lib('PMT_Base'); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * Resets the instance and returns a new one |
47 | 47 | * @return EE_Payment_Method_Manager |
48 | 48 | */ |
49 | - public static function reset(){ |
|
49 | + public static function reset() { |
|
50 | 50 | self::$_instance = NULL; |
51 | 51 | return self::instance(); |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * or just re-use the PMTs we found last time we checked during this request (if |
58 | 58 | * we have not yet checked during this request, then we need to check anyways) |
59 | 59 | */ |
60 | - public function maybe_register_payment_methods( $force_recheck = FALSE ){ |
|
61 | - if( ! $this->_payment_method_types || $force_recheck ){ |
|
60 | + public function maybe_register_payment_methods($force_recheck = FALSE) { |
|
61 | + if ( ! $this->_payment_method_types || $force_recheck) { |
|
62 | 62 | $this->_register_payment_methods(); |
63 | 63 | //if in admin lets ensure caps are set. |
64 | - if ( is_admin() ) { |
|
65 | - add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( $this, 'add_payment_method_caps' ) ); |
|
64 | + if (is_admin()) { |
|
65 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps')); |
|
66 | 66 | EE_Registry::instance()->CAP->init_caps(); |
67 | 67 | } |
68 | 68 | } |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function _register_payment_methods() { |
77 | 77 | // grab list of installed modules |
78 | - $pm_to_register = glob( EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR ); |
|
78 | + $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR); |
|
79 | 79 | // filter list of modules to register |
80 | - $pm_to_register = apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register ); |
|
80 | + $pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register); |
|
81 | 81 | |
82 | 82 | // loop through folders |
83 | - foreach ( $pm_to_register as $pm_path ) { |
|
84 | - $this->register_payment_method( $pm_path ); |
|
83 | + foreach ($pm_to_register as $pm_path) { |
|
84 | + $this->register_payment_method($pm_path); |
|
85 | 85 | } |
86 | - do_action( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods' ); |
|
86 | + do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
87 | 87 | // filter list of installed modules |
88 | 88 | //keep them organized alphabetically by the payment method type's name |
89 | - ksort( $this->_payment_method_types ); |
|
90 | - return apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types ); |
|
89 | + ksort($this->_payment_method_types); |
|
90 | + return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,35 +99,35 @@ discard block |
||
99 | 99 | * @param string $payment_method_path - full path up to and including payment method folder |
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | - public function register_payment_method( $payment_method_path = '' ) { |
|
103 | - do_action( 'AHEE__EE_Payment_Method_Manager__register_payment_method__begin',$payment_method_path ); |
|
102 | + public function register_payment_method($payment_method_path = '') { |
|
103 | + do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
104 | 104 | $module_ext = '.pm.php'; |
105 | 105 | // make all separators match |
106 | - $payment_method_path = rtrim( str_replace( '/\\', DS, $payment_method_path ), DS ); |
|
106 | + $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
107 | 107 | // grab and sanitize module name |
108 | - $module_dir = basename( $payment_method_path ); |
|
108 | + $module_dir = basename($payment_method_path); |
|
109 | 109 | // create classname from module directory name |
110 | - $module = str_replace( ' ', '_', str_replace( '_', ' ', $module_dir )); |
|
110 | + $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir)); |
|
111 | 111 | // add class prefix |
112 | - $module_class = 'EE_PMT_' . $module; |
|
112 | + $module_class = 'EE_PMT_'.$module; |
|
113 | 113 | // does the module exist ? |
114 | - if ( ! is_readable( $payment_method_path . DS . $module_class . $module_ext )) { |
|
115 | - $msg = sprintf( __( 'The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
116 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
114 | + if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) { |
|
115 | + $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso'), $module); |
|
116 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
117 | 117 | return FALSE; |
118 | 118 | } |
119 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->start_timer(); } |
|
119 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->start_timer(); } |
|
120 | 120 | // load the module class file |
121 | - require_once( $payment_method_path . DS . $module_class . $module_ext ); |
|
122 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
121 | + require_once($payment_method_path.DS.$module_class.$module_ext); |
|
122 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
123 | 123 | // verify that class exists |
124 | - if ( ! class_exists( $module_class )) { |
|
125 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
126 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
124 | + if ( ! class_exists($module_class)) { |
|
125 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
126 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
127 | 127 | return FALSE; |
128 | 128 | } |
129 | 129 | // add to array of registered modules |
130 | - $this->_payment_method_types[ $module ] = $payment_method_path . DS . $module_class . $module_ext; |
|
130 | + $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext; |
|
131 | 131 | return TRUE; |
132 | 132 | } |
133 | 133 | /** |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
137 | 137 | * @return boolean |
138 | 138 | */ |
139 | - public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE){ |
|
140 | - if ( ! is_array( $this->_payment_method_types ) || ! isset( $this->_payment_method_types[$payment_method_name] ) |
|
141 | - || $force_recheck ) { |
|
139 | + public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE) { |
|
140 | + if ( ! is_array($this->_payment_method_types) || ! isset($this->_payment_method_types[$payment_method_name]) |
|
141 | + || $force_recheck) { |
|
142 | 142 | $this->maybe_register_payment_methods($force_recheck); |
143 | 143 | } |
144 | - if(isset($this->_payment_method_types[$payment_method_name])){ |
|
144 | + if (isset($this->_payment_method_types[$payment_method_name])) { |
|
145 | 145 | require_once($this->_payment_method_types[$payment_method_name]); |
146 | 146 | return true; |
147 | - }else{ |
|
147 | + } else { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | } |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
156 | 156 | * @return array |
157 | 157 | */ |
158 | - public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE ){ |
|
158 | + public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE) { |
|
159 | 159 | $this->maybe_register_payment_methods($force_recheck); |
160 | - if($with_prefixes){ |
|
160 | + if ($with_prefixes) { |
|
161 | 161 | $classnames = array_keys($this->_payment_method_types); |
162 | 162 | $payment_methods = array(); |
163 | - foreach($classnames as $classname){ |
|
163 | + foreach ($classnames as $classname) { |
|
164 | 164 | $payment_methods[] = $this->payment_method_class_from_type($classname); |
165 | 165 | } |
166 | 166 | return $payment_methods; |
167 | - }else{ |
|
167 | + } else { |
|
168 | 168 | return array_keys($this->_payment_method_types); |
169 | 169 | } |
170 | 170 | } |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
175 | 175 | * @return EE_PMT_Base[] |
176 | 176 | */ |
177 | - public function payment_method_types( $force_recheck = FALSE ){ |
|
177 | + public function payment_method_types($force_recheck = FALSE) { |
|
178 | 178 | $this->maybe_register_payment_methods($force_recheck); |
179 | 179 | $pmt_objs = array(); |
180 | - foreach($this->payment_method_type_names(true) as $classname){ |
|
180 | + foreach ($this->payment_method_type_names(true) as $classname) { |
|
181 | 181 | $pmt_objs[] = new $classname; |
182 | 182 | } |
183 | 183 | return $pmt_objs; |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * @param string $classname |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - public function payment_method_type_sans_class_prefix($classname){ |
|
193 | - $pmt_name = str_replace("EE_PMT_","",$classname); |
|
192 | + public function payment_method_type_sans_class_prefix($classname) { |
|
193 | + $pmt_name = str_replace("EE_PMT_", "", $classname); |
|
194 | 194 | return $pmt_name; |
195 | 195 | } |
196 | 196 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param string $type |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function payment_method_class_from_type($type){ |
|
202 | + public function payment_method_class_from_type($type) { |
|
203 | 203 | $this->maybe_register_payment_methods(); |
204 | 204 | return "EE_PMT_".$type; |
205 | 205 | } |
@@ -213,39 +213,39 @@ discard block |
||
213 | 213 | * @return \EE_Payment_Method |
214 | 214 | * @throws \EE_Error |
215 | 215 | */ |
216 | - public function activate_a_payment_method_of_type( $payment_method_type ){ |
|
216 | + public function activate_a_payment_method_of_type($payment_method_type) { |
|
217 | 217 | $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
218 | - if( ! $payment_method instanceof EE_Payment_Method ){ |
|
218 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
219 | 219 | $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
220 | - if(class_exists($pm_type_class)){ |
|
220 | + if (class_exists($pm_type_class)) { |
|
221 | 221 | /** @var $pm_type_obj EE_PMT_Base */ |
222 | 222 | $pm_type_obj = new $pm_type_class; |
223 | 223 | $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
224 | - if( ! $payment_method){ |
|
225 | - $payment_method = $this->create_payment_method_of_type( $pm_type_obj ); |
|
224 | + if ( ! $payment_method) { |
|
225 | + $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
226 | 226 | } |
227 | - $payment_method->set_type( $payment_method_type ); |
|
228 | - $this->initialize_payment_method( $payment_method ); |
|
227 | + $payment_method->set_type($payment_method_type); |
|
228 | + $this->initialize_payment_method($payment_method); |
|
229 | 229 | } else { |
230 | 230 | throw new EE_Error( |
231 | 231 | sprintf( |
232 | - __( 'There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
232 | + __('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
233 | 233 | $pm_type_class ) |
234 | 234 | ); |
235 | 235 | } |
236 | 236 | } |
237 | 237 | $payment_method->set_active(); |
238 | 238 | $payment_method->save(); |
239 | - $this->set_usable_currencies_on_payment_method( $payment_method ); |
|
240 | - if( $payment_method->type() == 'Invoice' ){ |
|
239 | + $this->set_usable_currencies_on_payment_method($payment_method); |
|
240 | + if ($payment_method->type() == 'Invoice') { |
|
241 | 241 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
242 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
243 | - $message_resource_manager->ensure_message_type_is_active( 'invoice', 'html' ); |
|
244 | - $message_resource_manager->ensure_messenger_is_active( 'pdf' ); |
|
242 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
243 | + $message_resource_manager->ensure_message_type_is_active('invoice', 'html'); |
|
244 | + $message_resource_manager->ensure_messenger_is_active('pdf'); |
|
245 | 245 | EE_Error::add_attention( |
246 | 246 | sprintf( |
247 | - __( 'Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso' ), |
|
248 | - '<a href="' . admin_url( 'admin.php?page=espresso_messages') . '">', |
|
247 | + __('Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso'), |
|
248 | + '<a href="'.admin_url('admin.php?page=espresso_messages').'">', |
|
249 | 249 | '</a>' |
250 | 250 | ) |
251 | 251 | ); |
@@ -259,17 +259,17 @@ discard block |
||
259 | 259 | * @param EE_PMT_Base $pm_type_obj |
260 | 260 | * @return EE_Payment_Method |
261 | 261 | */ |
262 | - public function create_payment_method_of_type( $pm_type_obj ) { |
|
262 | + public function create_payment_method_of_type($pm_type_obj) { |
|
263 | 263 | global $current_user; |
264 | 264 | $payment_method = EE_Payment_Method::new_instance( |
265 | 265 | array( |
266 | 266 | 'PMD_type' => $pm_type_obj->system_name(), |
267 | 267 | 'PMD_name' => $pm_type_obj->pretty_name(), |
268 | 268 | 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
269 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
269 | + 'PMD_slug' => $pm_type_obj->system_name(), //automatically converted to slug |
|
270 | 270 | 'PMD_wp_user' => $current_user->ID, |
271 | 271 | 'PMD_order' => EEM_Payment_Method::instance()->count( |
272 | - array( array( 'PMD_type' => array( '!=', 'Admin_Only' ))) |
|
272 | + array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
273 | 273 | ) * 10, |
274 | 274 | ) |
275 | 275 | ); |
@@ -281,16 +281,16 @@ discard block |
||
281 | 281 | * @param EE_Payment_Method $payment_method |
282 | 282 | * @return EE_Payment_Method |
283 | 283 | */ |
284 | - public function initialize_payment_method( $payment_method ) { |
|
284 | + public function initialize_payment_method($payment_method) { |
|
285 | 285 | $pm_type_obj = $payment_method->type_obj(); |
286 | - $payment_method->set_description( $pm_type_obj->default_description() ); |
|
287 | - if( ! $payment_method->button_url() ){ |
|
288 | - $payment_method->set_button_url( $pm_type_obj->default_button_url() ); |
|
286 | + $payment_method->set_description($pm_type_obj->default_description()); |
|
287 | + if ( ! $payment_method->button_url()) { |
|
288 | + $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
289 | 289 | } |
290 | 290 | //now add setup its default extra meta properties |
291 | 291 | $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
292 | - foreach( $extra_metas as $meta_name => $input ){ |
|
293 | - $payment_method->update_extra_meta($meta_name, $input->raw_value() ); |
|
292 | + foreach ($extra_metas as $meta_name => $input) { |
|
293 | + $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
294 | 294 | } |
295 | 295 | return $payment_method; |
296 | 296 | } |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * @param EE_Payment_Method $payment_method |
301 | 301 | * @return EE_Payment_Method |
302 | 302 | */ |
303 | - public function set_usable_currencies_on_payment_method( $payment_method ) { |
|
304 | - foreach($payment_method->get_all_usable_currencies() as $currency_obj){ |
|
303 | + public function set_usable_currencies_on_payment_method($payment_method) { |
|
304 | + foreach ($payment_method->get_all_usable_currencies() as $currency_obj) { |
|
305 | 305 | $payment_method->_add_relation_to($currency_obj, 'Currency'); |
306 | 306 | } |
307 | 307 | return $payment_method; |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @return int count of rows updated. |
321 | 321 | */ |
322 | - public function deactivate_payment_method( $payment_method_slug ) { |
|
323 | - $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()),array(array('PMD_slug'=>$payment_method_slug))); |
|
322 | + public function deactivate_payment_method($payment_method_slug) { |
|
323 | + $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()), array(array('PMD_slug'=>$payment_method_slug))); |
|
324 | 324 | return $count_updated; |
325 | 325 | } |
326 | 326 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @param array $caps capabilities being filtered |
334 | 334 | * @return array |
335 | 335 | */ |
336 | - public function add_payment_method_caps( $caps ) { |
|
336 | + public function add_payment_method_caps($caps) { |
|
337 | 337 | /* add dynamic caps from payment methods |
338 | 338 | * at the time of writing, october 20 2014, these are the caps added: |
339 | 339 | * ee_payment_method_admin_only |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * their related capability automatically added too, so long as they are |
349 | 349 | * registered properly using EE_Register_Payment_Method::register() |
350 | 350 | */ |
351 | - foreach( $this->payment_method_types() as $payment_method_type_obj ){ |
|
351 | + foreach ($this->payment_method_types() as $payment_method_type_obj) { |
|
352 | 352 | $caps['administrator'][] = $payment_method_type_obj->cap_name(); |
353 | 353 | } |
354 | 354 | return $caps; |
@@ -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 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | protected function _init_queue_and_generator() { |
53 | 53 | // ensure new instances of dependencies are created |
54 | 54 | EE_Registry::instance()->skip_cache(); |
55 | - $this->_generator = EE_Registry::instance()->load_lib( 'Messages_Generator' ); |
|
55 | + $this->_generator = EE_Registry::instance()->load_lib('Messages_Generator'); |
|
56 | 56 | $this->_queue = $this->_generator->generation_queue(); |
57 | 57 | } |
58 | 58 | |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | * @return bool|EE_Messages_Queue return false if nothing generated. This returns a new EE_Message_Queue with |
78 | 78 | * generated messages. |
79 | 79 | */ |
80 | - public function batch_generate_from_queue( $messages = array(), $clear_queue = false ) { |
|
81 | - if ( $this->_build_queue_for_generation( $messages, $clear_queue ) ) { |
|
80 | + public function batch_generate_from_queue($messages = array(), $clear_queue = false) { |
|
81 | + if ($this->_build_queue_for_generation($messages, $clear_queue)) { |
|
82 | 82 | $new_queue = $this->_generator->generate(); |
83 | - if ( $new_queue instanceof EE_Messages_Queue ) { |
|
83 | + if ($new_queue instanceof EE_Messages_Queue) { |
|
84 | 84 | //unlock queue |
85 | 85 | $this->_queue->unlock_queue(); |
86 | - $this->_queue->initiate_request_by_priority( 'send' ); |
|
86 | + $this->_queue->initiate_request_by_priority('send'); |
|
87 | 87 | return $new_queue; |
88 | 88 | } |
89 | 89 | } |
@@ -104,24 +104,24 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return bool true means queue prepped, false means there was a lock so no generation please. |
106 | 106 | */ |
107 | - protected function _build_queue_for_generation( $messages = array(), $clear_queue = false ) { |
|
107 | + protected function _build_queue_for_generation($messages = array(), $clear_queue = false) { |
|
108 | 108 | |
109 | - if ( $clear_queue ) { |
|
109 | + if ($clear_queue) { |
|
110 | 110 | $this->_init_queue_and_generator(); |
111 | 111 | } |
112 | 112 | |
113 | - if ( $messages ) { |
|
113 | + if ($messages) { |
|
114 | 114 | //if generation is locked then get out now because that means processing is already happening. |
115 | - if ( $this->_queue->is_locked() ) { |
|
115 | + if ($this->_queue->is_locked()) { |
|
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $this->_queue->lock_queue(); |
120 | - $messages = is_array( $messages ) ? $messages : array( $messages ); |
|
121 | - foreach ( $messages as $message ) { |
|
122 | - if ( $message instanceof EE_Message ) { |
|
120 | + $messages = is_array($messages) ? $messages : array($messages); |
|
121 | + foreach ($messages as $message) { |
|
122 | + if ($message instanceof EE_Message) { |
|
123 | 123 | $data = $message->all_extra_meta_array(); |
124 | - $this->_queue->add( $message, $data ); |
|
124 | + $this->_queue->add($message, $data); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | return true; |
@@ -139,22 +139,22 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return bool true means queue prepped, false means there was a lock so no queue prepped. |
141 | 141 | */ |
142 | - protected function _build_queue_for_sending( $messages, $clear_queue = false ) { |
|
142 | + protected function _build_queue_for_sending($messages, $clear_queue = false) { |
|
143 | 143 | //if sending is locked then get out now because that means processing is already happening. |
144 | - if ( $this->_queue->is_locked( EE_Messages_Queue::action_sending ) ) { |
|
144 | + if ($this->_queue->is_locked(EE_Messages_Queue::action_sending)) { |
|
145 | 145 | return false; |
146 | 146 | } |
147 | 147 | |
148 | - $this->_queue->lock_queue( EE_Messages_Queue::action_sending ); |
|
148 | + $this->_queue->lock_queue(EE_Messages_Queue::action_sending); |
|
149 | 149 | |
150 | - if ( $clear_queue ) { |
|
150 | + if ($clear_queue) { |
|
151 | 151 | $this->_init_queue_and_generator(); |
152 | 152 | } |
153 | 153 | |
154 | - $messages = is_array( $messages ) ? $messages : array( $messages ); |
|
154 | + $messages = is_array($messages) ? $messages : array($messages); |
|
155 | 155 | |
156 | - foreach ( $messages as $message ) { |
|
157 | - $this->_queue->add( $message ); |
|
156 | + foreach ($messages as $message) { |
|
157 | + $this->_queue->add($message); |
|
158 | 158 | } |
159 | 159 | return true; |
160 | 160 | } |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return EE_Messages_Queue |
172 | 172 | */ |
173 | - public function batch_send_from_queue( $messages = array(), $clear_queue = false ) { |
|
173 | + public function batch_send_from_queue($messages = array(), $clear_queue = false) { |
|
174 | 174 | |
175 | - if ( $messages && $this->_build_queue_for_sending( $messages, $clear_queue ) ) { |
|
175 | + if ($messages && $this->_build_queue_for_sending($messages, $clear_queue)) { |
|
176 | 176 | $this->_queue->execute(); |
177 | - $this->_queue->unlock_queue( EE_Messages_Queue::action_sending ); |
|
177 | + $this->_queue->unlock_queue(EE_Messages_Queue::action_sending); |
|
178 | 178 | } else { |
179 | 179 | //get messages to send and execute. |
180 | 180 | $this->_queue->get_to_send_batch_and_send(); |
@@ -197,9 +197,9 @@ discard block |
||
197 | 197 | * @param EE_Message_To_Generate[] $messages_to_generate |
198 | 198 | * @return EE_Messages_Queue |
199 | 199 | */ |
200 | - public function generate_and_return( $messages_to_generate ) { |
|
201 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
202 | - return $this->_generator->generate( false ); |
|
200 | + public function generate_and_return($messages_to_generate) { |
|
201 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
202 | + return $this->_generator->generate(false); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * @param bool $persist Indicate whether to instruct the generator to persist the generated queue (true) or not (false). |
211 | 211 | * @return EE_Messages_Queue |
212 | 212 | */ |
213 | - public function generate_queue( $persist = true ) { |
|
214 | - return $this->_generator->generate( $persist ); |
|
213 | + public function generate_queue($persist = true) { |
|
214 | + return $this->_generator->generate($persist); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | * @param EE_Message_To_Generate $message_to_generate |
224 | 224 | * @return EE_Messages_Queue |
225 | 225 | */ |
226 | - public function queue_for_generation( EE_Message_To_Generate $message_to_generate ) { |
|
227 | - if ( $message_to_generate->valid() ) { |
|
228 | - $this->_generator->create_and_add_message_to_queue( $message_to_generate ); |
|
226 | + public function queue_for_generation(EE_Message_To_Generate $message_to_generate) { |
|
227 | + if ($message_to_generate->valid()) { |
|
228 | + $this->_generator->create_and_add_message_to_queue($message_to_generate); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @param EE_Message_To_Generate[] $messages_to_generate |
243 | 243 | */ |
244 | - public function batch_queue_for_generation_and_persist( $messages_to_generate ) { |
|
245 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
244 | + public function batch_queue_for_generation_and_persist($messages_to_generate) { |
|
245 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
246 | 246 | $this->_queue->save(); |
247 | 247 | } |
248 | 248 | |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @param EE_Message_To_Generate[] $messages_to_generate |
260 | 260 | */ |
261 | - public function batch_queue_for_generation_no_persist( $messages_to_generate ) { |
|
262 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
261 | + public function batch_queue_for_generation_no_persist($messages_to_generate) { |
|
262 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
@@ -271,15 +271,15 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @param EE_Message_To_Generate[] $messages_to_generate |
273 | 273 | */ |
274 | - protected function _queue_for_generation_loop( $messages_to_generate ) { |
|
274 | + protected function _queue_for_generation_loop($messages_to_generate) { |
|
275 | 275 | //make sure is in an array. |
276 | - if ( ! is_array( $messages_to_generate ) ) { |
|
277 | - $messages_to_generate = array( $messages_to_generate ); |
|
276 | + if ( ! is_array($messages_to_generate)) { |
|
277 | + $messages_to_generate = array($messages_to_generate); |
|
278 | 278 | } |
279 | 279 | |
280 | - foreach ( $messages_to_generate as $message_to_generate ) { |
|
281 | - if ( $message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid() ) { |
|
282 | - $this->queue_for_generation( $message_to_generate ); |
|
280 | + foreach ($messages_to_generate as $message_to_generate) { |
|
281 | + if ($message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid()) { |
|
282 | + $this->queue_for_generation($message_to_generate); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | * @param EE_Message_To_Generate[] |
295 | 295 | * @return EE_Messages_Queue |
296 | 296 | */ |
297 | - public function generate_and_queue_for_sending( $messages_to_generate ) { |
|
298 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
299 | - return $this->_generator->generate( true ); |
|
297 | + public function generate_and_queue_for_sending($messages_to_generate) { |
|
298 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
299 | + return $this->_generator->generate(true); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | *@param EE_Message_To_Generate $message_to_generate |
310 | 310 | * @return EE_Messages_Queue | bool false if unable to generate otherwise the generated queue. |
311 | 311 | */ |
312 | - public function generate_for_preview( EE_Message_To_Generate $message_to_generate ) { |
|
313 | - if ( ! $message_to_generate->valid() ) { |
|
312 | + public function generate_for_preview(EE_Message_To_Generate $message_to_generate) { |
|
313 | + if ( ! $message_to_generate->valid()) { |
|
314 | 314 | EE_Error::add_error( |
315 | - __( 'Unable to generate preview because of invalid data', 'event_espresso' ), |
|
315 | + __('Unable to generate preview because of invalid data', 'event_espresso'), |
|
316 | 316 | __FILE__, |
317 | 317 | __FUNCTION__, |
318 | 318 | __LINE__ |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | //just make sure preview is set on the $message_to_generate (in case client forgot) |
323 | - $message_to_generate->set_preview( true ); |
|
324 | - $generated_queue = $this->generate_and_return( array( $message_to_generate ) ); |
|
325 | - if ( $generated_queue->execute( false ) ) { |
|
323 | + $message_to_generate->set_preview(true); |
|
324 | + $generated_queue = $this->generate_and_return(array($message_to_generate)); |
|
325 | + if ($generated_queue->execute(false)) { |
|
326 | 326 | //the first queue item should be the preview |
327 | 327 | $generated_queue->get_queue()->rewind(); |
328 | - if ( ! $generated_queue->get_queue()->valid() ) { |
|
328 | + if ( ! $generated_queue->get_queue()->valid()) { |
|
329 | 329 | return $generated_queue; |
330 | 330 | } |
331 | 331 | return $generated_queue->get_queue()->is_test_send() ? true : $generated_queue; |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | * @param EE_Message_To_Generate $message_to_generate |
343 | 343 | * @return bool true or false for success. |
344 | 344 | */ |
345 | - public function queue_for_sending( EE_Message_To_Generate $message_to_generate ) { |
|
346 | - if ( ! $message_to_generate->valid() ) { |
|
345 | + public function queue_for_sending(EE_Message_To_Generate $message_to_generate) { |
|
346 | + if ( ! $message_to_generate->valid()) { |
|
347 | 347 | return false; |
348 | 348 | } |
349 | 349 | $message = $message_to_generate->get_EE_Message(); |
350 | - $this->_queue->add( $message ); |
|
351 | - if ( $message->send_now() ) { |
|
352 | - $this->_queue->execute( false ); |
|
350 | + $this->_queue->add($message); |
|
351 | + if ($message->send_now()) { |
|
352 | + $this->_queue->execute(false); |
|
353 | 353 | } else { |
354 | 354 | $this->_queue->save(); |
355 | 355 | } |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | * @param EE_Message_To_Generate $message_to_generate |
363 | 363 | * @return EE_Messages_Queue | null |
364 | 364 | */ |
365 | - public function generate_and_send_now( EE_Message_To_Generate $message_to_generate ) { |
|
366 | - if ( ! $message_to_generate->valid() ) { |
|
365 | + public function generate_and_send_now(EE_Message_To_Generate $message_to_generate) { |
|
366 | + if ( ! $message_to_generate->valid()) { |
|
367 | 367 | return null; |
368 | 368 | } |
369 | 369 | // is there supposed to be a sending messenger for this message? |
370 | - if ( $message_to_generate instanceof EEI_Has_Sending_Messenger ) { |
|
370 | + if ($message_to_generate instanceof EEI_Has_Sending_Messenger) { |
|
371 | 371 | // make sure it's valid, but if it's not, |
372 | 372 | // then set the value of $sending_messenger to an EE_Error object |
373 | 373 | // so that downstream code can easily see that things went wrong. |
@@ -383,13 +383,13 @@ discard block |
||
383 | 383 | $sending_messenger = null; |
384 | 384 | } |
385 | 385 | |
386 | - if ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle ) { |
|
387 | - $this->_queue->add( $message_to_generate->get_EE_Message() ); |
|
388 | - $this->_queue->execute( false, $sending_messenger ); |
|
386 | + if ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle) { |
|
387 | + $this->_queue->add($message_to_generate->get_EE_Message()); |
|
388 | + $this->_queue->execute(false, $sending_messenger); |
|
389 | 389 | return $this->_queue; |
390 | - } elseif ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete ) { |
|
391 | - $generated_queue = $this->generate_and_return( array( $message_to_generate ) ); |
|
392 | - $generated_queue->execute( false, $sending_messenger ); |
|
390 | + } elseif ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete) { |
|
391 | + $generated_queue = $this->generate_and_return(array($message_to_generate)); |
|
392 | + $generated_queue->execute(false, $sending_messenger); |
|
393 | 393 | return $generated_queue; |
394 | 394 | } |
395 | 395 | return null; |
@@ -406,13 +406,13 @@ discard block |
||
406 | 406 | * @param mixed $data The data being used for generation. |
407 | 407 | * @param bool $persist Whether to persist the queued messages to the db or not. |
408 | 408 | */ |
409 | - public function generate_for_all_active_messengers( $message_type, $data, $persist = true ) { |
|
410 | - $messages_to_generate = $this->setup_mtgs_for_all_active_messengers( $message_type, $data ); |
|
411 | - if ( $persist ) { |
|
412 | - $this->batch_queue_for_generation_and_persist( $messages_to_generate ); |
|
409 | + public function generate_for_all_active_messengers($message_type, $data, $persist = true) { |
|
410 | + $messages_to_generate = $this->setup_mtgs_for_all_active_messengers($message_type, $data); |
|
411 | + if ($persist) { |
|
412 | + $this->batch_queue_for_generation_and_persist($messages_to_generate); |
|
413 | 413 | $this->_queue->initiate_request_by_priority(); |
414 | 414 | } else { |
415 | - $this->batch_queue_for_generation_no_persist( $messages_to_generate ); |
|
415 | + $this->batch_queue_for_generation_no_persist($messages_to_generate); |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
@@ -427,11 +427,11 @@ discard block |
||
427 | 427 | * |
428 | 428 | * @return EE_Message_To_Generate[] |
429 | 429 | */ |
430 | - public function setup_mtgs_for_all_active_messengers( $message_type, $data ) { |
|
430 | + public function setup_mtgs_for_all_active_messengers($message_type, $data) { |
|
431 | 431 | $messages_to_generate = array(); |
432 | - foreach ( $this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object ) { |
|
433 | - $message_to_generate = new EE_Message_To_Generate( $messenger_slug, $message_type, $data ); |
|
434 | - if ( $message_to_generate->valid() ) { |
|
432 | + foreach ($this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object) { |
|
433 | + $message_to_generate = new EE_Message_To_Generate($messenger_slug, $message_type, $data); |
|
434 | + if ($message_to_generate->valid()) { |
|
435 | 435 | $messages_to_generate[] = $message_to_generate; |
436 | 436 | } |
437 | 437 | } |
@@ -446,22 +446,22 @@ discard block |
||
446 | 446 | * and send. |
447 | 447 | * @param array $message_ids |
448 | 448 | */ |
449 | - public function setup_messages_from_ids_and_send( $message_ids ) { |
|
450 | - $messages = EEM_Message::instance()->get_all( array( |
|
449 | + public function setup_messages_from_ids_and_send($message_ids) { |
|
450 | + $messages = EEM_Message::instance()->get_all(array( |
|
451 | 451 | array( |
452 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
453 | - 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_sent() ) |
|
452 | + 'MSG_ID' => array('IN', $message_ids), |
|
453 | + 'STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_sent()) |
|
454 | 454 | ) |
455 | 455 | )); |
456 | 456 | //set the Messages to resend. |
457 | - foreach ( $messages as $message ) { |
|
458 | - if ( $message instanceof EE_Message ) { |
|
459 | - $message->set_STS_ID( EEM_Message::status_resend ); |
|
460 | - $this->_queue->add( $message ); |
|
457 | + foreach ($messages as $message) { |
|
458 | + if ($message instanceof EE_Message) { |
|
459 | + $message->set_STS_ID(EEM_Message::status_resend); |
|
460 | + $this->_queue->add($message); |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | |
464 | - $this->_queue->initiate_request_by_priority( 'send' ); |
|
464 | + $this->_queue->initiate_request_by_priority('send'); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -474,22 +474,22 @@ discard block |
||
474 | 474 | * @return EE_Message_To_Generate[] |
475 | 475 | */ |
476 | 476 | public function setup_messages_to_generate_from_registration_ids_in_request() { |
477 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
478 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
477 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
478 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
479 | 479 | $regs_to_send = array(); |
480 | - $regIDs = EE_Registry::instance()->REQ->get( '_REG_ID' ); |
|
481 | - if ( empty( $regIDs ) ) { |
|
482 | - EE_Error::add_error( __('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
480 | + $regIDs = EE_Registry::instance()->REQ->get('_REG_ID'); |
|
481 | + if (empty($regIDs)) { |
|
482 | + EE_Error::add_error(__('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
483 | 483 | return false; |
484 | 484 | } |
485 | 485 | |
486 | 486 | //make sure is an array |
487 | - $regIDs = is_array( $regIDs ) ? $regIDs : array( $regIDs ); |
|
487 | + $regIDs = is_array($regIDs) ? $regIDs : array($regIDs); |
|
488 | 488 | |
489 | - foreach( $regIDs as $regID ) { |
|
490 | - $reg = EEM_Registration::instance()->get_one_by_ID( $regID ); |
|
491 | - if ( ! $reg instanceof EE_Registration ) { |
|
492 | - EE_Error::add_error( sprintf( __('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID ) ); |
|
489 | + foreach ($regIDs as $regID) { |
|
490 | + $reg = EEM_Registration::instance()->get_one_by_ID($regID); |
|
491 | + if ( ! $reg instanceof EE_Registration) { |
|
492 | + EE_Error::add_error(sprintf(__('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID)); |
|
493 | 493 | return false; |
494 | 494 | } |
495 | 495 | $regs_to_send[$reg->transaction_ID()][$reg->status_ID()][] = $reg; |
@@ -497,11 +497,11 @@ discard block |
||
497 | 497 | |
498 | 498 | $messages_to_generate = array(); |
499 | 499 | |
500 | - foreach ( $regs_to_send as $status_group ) { |
|
501 | - foreach ( $status_group as $status_id => $registrations ) { |
|
500 | + foreach ($regs_to_send as $status_group) { |
|
501 | + foreach ($status_group as $status_id => $registrations) { |
|
502 | 502 | $messages_to_generate = $messages_to_generate + $this->setup_mtgs_for_all_active_messengers( |
503 | - EEH_MSG_Template::convert_reg_status_to_message_type( $status_id ), |
|
504 | - array( $registrations, $status_id ) |
|
503 | + EEH_MSG_Template::convert_reg_status_to_message_type($status_id), |
|
504 | + array($registrations, $status_id) |
|
505 | 505 | ); |
506 | 506 | } |
507 | 507 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | EE_Messenger $messenger = null, |
94 | 94 | EE_message_type $message_type = null |
95 | 95 | ) { |
96 | - if ( $deprecated !== null ) { |
|
96 | + if ($deprecated !== null) { |
|
97 | 97 | EE_Error::doing_it_wrong( |
98 | 98 | __FUNCTION__, |
99 | 99 | sprintf( |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | 'The first parameter for the "%1$s" method is deprecated and no longer required. Please update any addons or custom code accordingly.', |
102 | 102 | 'event_espresso' |
103 | 103 | ), |
104 | - __METHOD__ . '()' |
|
104 | + __METHOD__.'()' |
|
105 | 105 | ), |
106 | 106 | '4.9.0' |
107 | 107 | ); |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | * @throws \EE_Error |
128 | 128 | */ |
129 | 129 | protected function _validate_messenger_and_message_type() { |
130 | - if ( ! $this->_messenger instanceof EE_Messenger ) { |
|
131 | - if ( empty( $this->_m_name ) ) { |
|
130 | + if ( ! $this->_messenger instanceof EE_Messenger) { |
|
131 | + if (empty($this->_m_name)) { |
|
132 | 132 | $msg[] = __( |
133 | 133 | 'Message Templates cannot be generated because a messenger was not supplied.', |
134 | 134 | 'event_espresso' |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | ), |
141 | 141 | $this->_m_name, |
142 | 142 | 'EEH_MSG_Template::create_new_templates()', |
143 | - print_r( $this->_messenger, true ), |
|
143 | + print_r($this->_messenger, true), |
|
144 | 144 | '<br />' |
145 | 145 | ); |
146 | - throw new EE_Error( implode( '||', $msg ) ); |
|
146 | + throw new EE_Error(implode('||', $msg)); |
|
147 | 147 | } |
148 | 148 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
149 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
150 | - $this->_messenger = $Message_Resource_Manager->valid_messenger( $this->_m_name ); |
|
149 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
150 | + $this->_messenger = $Message_Resource_Manager->valid_messenger($this->_m_name); |
|
151 | 151 | } |
152 | - if ( ! $this->_message_type instanceof EE_message_type ) { |
|
153 | - if ( empty( $this->_mt_name ) ) { |
|
152 | + if ( ! $this->_message_type instanceof EE_message_type) { |
|
153 | + if (empty($this->_mt_name)) { |
|
154 | 154 | $msg[] = __( |
155 | 155 | 'Message Templates cannot be generated because a message type was not supplied.', |
156 | 156 | 'event_espresso' |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | ), |
163 | 163 | $this->_mt_name, |
164 | 164 | 'EEH_MSG_Template::create_new_templates()', |
165 | - print_r( $this->_message_type, true ), |
|
165 | + print_r($this->_message_type, true), |
|
166 | 166 | '<br />' |
167 | 167 | ); |
168 | - throw new EE_Error( implode( '||', $msg ) ); |
|
168 | + throw new EE_Error(implode('||', $msg)); |
|
169 | 169 | } |
170 | 170 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
171 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
172 | - $this->_message_type = $Message_Resource_Manager->valid_message_type( $this->_mt_name ); |
|
171 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
172 | + $this->_message_type = $Message_Resource_Manager->valid_message_type($this->_mt_name); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -183,12 +183,12 @@ discard block |
||
183 | 183 | * @param string $template_pack This corresponds to a template pack class reference which will contain information about where to obtain the templates. |
184 | 184 | * @return void |
185 | 185 | */ |
186 | - final private function _set_templates( $template_pack ) { |
|
186 | + final private function _set_templates($template_pack) { |
|
187 | 187 | |
188 | 188 | //get the corresponding template pack object (if present. If not then we just load the default and add a notice). The class name should be something like 'EE_Messages_Template_Pack_Default' where "default' would be the incoming template pack reference. |
189 | - $class_name = 'EE_Messages_Template_Pack_' . str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $template_pack ) ) ); |
|
189 | + $class_name = 'EE_Messages_Template_Pack_'.str_replace(' ', '_', ucwords(str_replace('_', ' ', $template_pack))); |
|
190 | 190 | |
191 | - if ( ! class_exists( $class_name ) ) { |
|
191 | + if ( ! class_exists($class_name)) { |
|
192 | 192 | EE_Error::add_error( |
193 | 193 | sprintf( |
194 | 194 | __( |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $template_pack = new $class_name; |
208 | 208 | |
209 | 209 | //get all the templates from the template pack. |
210 | - $this->_templates = $template_pack->get_templates( $this->_messenger, $this->_message_type ); |
|
210 | + $this->_templates = $template_pack->get_templates($this->_messenger, $this->_message_type); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | public function create_new_templates() { |
233 | 233 | $template_pack = 'default'; |
234 | 234 | //if we have the GRP_ID then let's use that to see if there is a set template pack and use that for the new templates. |
235 | - if ( !empty( $this->_GRP_ID ) ) { |
|
236 | - $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $this->_GRP_ID ); |
|
235 | + if ( ! empty($this->_GRP_ID)) { |
|
236 | + $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_GRP_ID); |
|
237 | 237 | $template_pack = $message_template_group instanceof EE_Message_Template_Group ? $message_template_group->get_template_pack_name() : 'default'; |
238 | 238 | //we also need to reset the template variation to default |
239 | - $message_template_group->set_template_pack_variation( 'default' ); |
|
239 | + $message_template_group->set_template_pack_variation('default'); |
|
240 | 240 | } |
241 | - return $this->_create_new_templates( $template_pack ); |
|
241 | + return $this->_create_new_templates($template_pack); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | * which will contain information about where to obtain the templates. |
253 | 253 | * @return mixed (array|bool) success array or false. |
254 | 254 | */ |
255 | - private function _create_new_templates( $template_pack ) { |
|
255 | + private function _create_new_templates($template_pack) { |
|
256 | 256 | |
257 | - $this->_set_templates( $template_pack ); |
|
257 | + $this->_set_templates($template_pack); |
|
258 | 258 | |
259 | 259 | //necessary properties are set, let's save the default templates |
260 | - if ( empty( $this->_GRP_ID ) ) { |
|
260 | + if (empty($this->_GRP_ID)) { |
|
261 | 261 | $main_template_data = array( |
262 | 262 | 'MTP_messenger' => $this->_messenger->name, |
263 | 263 | 'MTP_message_type' => $this->_message_type->name, |
@@ -268,24 +268,24 @@ discard block |
||
268 | 268 | 'MTP_is_active' => 1, |
269 | 269 | ); |
270 | 270 | //let's insert the above and get our GRP_ID, then reset the template data array to just include the GRP_ID |
271 | - $grp_id = $this->_message_template_group_model->insert( $main_template_data ); |
|
272 | - if ( empty( $grp_id ) ) { |
|
271 | + $grp_id = $this->_message_template_group_model->insert($main_template_data); |
|
272 | + if (empty($grp_id)) { |
|
273 | 273 | return $grp_id; |
274 | 274 | } |
275 | 275 | $this->_GRP_ID = $grp_id; |
276 | 276 | } |
277 | 277 | |
278 | - $template_data = array( 'GRP_ID' => $this->_GRP_ID ); |
|
278 | + $template_data = array('GRP_ID' => $this->_GRP_ID); |
|
279 | 279 | |
280 | - foreach ( $this->_contexts as $context => $details ) { |
|
281 | - foreach ( $this->_fields as $field => $field_type ) { |
|
282 | - if ( $field != 'extra' ) { |
|
280 | + foreach ($this->_contexts as $context => $details) { |
|
281 | + foreach ($this->_fields as $field => $field_type) { |
|
282 | + if ($field != 'extra') { |
|
283 | 283 | $template_data['MTP_context'] = $context; |
284 | 284 | $template_data['MTP_template_field'] = $field; |
285 | 285 | $template_data['MTP_content'] = $this->_templates[$context][$field]; |
286 | 286 | |
287 | 287 | $MTP = EEM_Message_Template::instance()->insert($template_data); |
288 | - if ( !$MTP ) { |
|
288 | + if ( ! $MTP) { |
|
289 | 289 | EE_Error::add_error( |
290 | 290 | sprintf( |
291 | 291 | __( |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | return array( |
311 | 311 | 'GRP_ID' => $this->_GRP_ID, |
312 | - 'MTP_context' => key( $this->_contexts ) |
|
312 | + 'MTP_context' => key($this->_contexts) |
|
313 | 313 | ); |
314 | 314 | } |
315 | 315 |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param \EE_Message_Repository $message_repository |
73 | 73 | */ |
74 | - public function __construct( EE_Message_Repository $message_repository ) { |
|
75 | - $this->_batch_count = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 ); |
|
74 | + public function __construct(EE_Message_Repository $message_repository) { |
|
75 | + $this->_batch_count = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50); |
|
76 | 76 | $this->_rate_limit = $this->get_rate_limit(); |
77 | 77 | $this->_queue = $message_repository; |
78 | 78 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * use the messenger send method but typically is based on preview data. |
92 | 92 | * @return bool Whether the message was successfully added to the repository or not. |
93 | 93 | */ |
94 | - public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) { |
|
94 | + public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) { |
|
95 | 95 | $data['preview'] = $preview; |
96 | 96 | $data['test_send'] = $test_send; |
97 | - return $this->_queue->add( $message, $data ); |
|
97 | + return $this->_queue->add($message, $data); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param bool $persist This flag indicates whether to attempt to delete the object from the db as well. |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function remove( EE_Message $message, $persist = false ) { |
|
110 | - if ( $persist && $this->_queue->current() !== $message ) { |
|
109 | + public function remove(EE_Message $message, $persist = false) { |
|
110 | + if ($persist && $this->_queue->current() !== $message) { |
|
111 | 111 | //get pointer on right message |
112 | - if ( $this->_queue->has( $message ) ) { |
|
112 | + if ($this->_queue->has($message)) { |
|
113 | 113 | $this->_queue->rewind(); |
114 | - while( $this->_queue->valid() ) { |
|
115 | - if ( $this->_queue->current() === $message ) { |
|
114 | + while ($this->_queue->valid()) { |
|
115 | + if ($this->_queue->current() === $message) { |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | $this->_queue->next(); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | } |
124 | - return $persist ? $this->_queue->delete() : $this->_queue->remove( $message ); |
|
124 | + return $persist ? $this->_queue->delete() : $this->_queue->remove($message); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | * @return bool true if successfully retrieved batch, false no batch ready. |
162 | 162 | */ |
163 | 163 | public function get_batch_to_generate() { |
164 | - if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) { |
|
164 | + if ($this->is_locked(EE_Messages_Queue::action_generating)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | //lock batch generation to prevent race conditions. |
169 | - $this->lock_queue( EE_Messages_Queue::action_generating ); |
|
169 | + $this->lock_queue(EE_Messages_Queue::action_generating); |
|
170 | 170 | |
171 | 171 | $query_args = array( |
172 | 172 | // key 0 = where conditions |
173 | - 0 => array( 'STS_ID' => EEM_Message::status_incomplete ), |
|
173 | + 0 => array('STS_ID' => EEM_Message::status_incomplete), |
|
174 | 174 | 'order_by' => $this->_get_priority_orderby(), |
175 | 175 | 'limit' => $this->_batch_count |
176 | 176 | ); |
177 | - $messages = EEM_Message::instance()->get_all( $query_args ); |
|
177 | + $messages = EEM_Message::instance()->get_all($query_args); |
|
178 | 178 | |
179 | - if ( ! $messages ) { |
|
179 | + if ( ! $messages) { |
|
180 | 180 | return false; //nothing to generate |
181 | 181 | } |
182 | 182 | |
183 | - foreach ( $messages as $message ) { |
|
184 | - if ( $message instanceof EE_Message ) { |
|
183 | + foreach ($messages as $message) { |
|
184 | + if ($message instanceof EE_Message) { |
|
185 | 185 | $data = $message->all_extra_meta_array(); |
186 | - $this->add( $message, $data ); |
|
186 | + $this->add($message, $data); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | return true; |
@@ -206,34 +206,34 @@ discard block |
||
206 | 206 | * to assist with notifying user. |
207 | 207 | */ |
208 | 208 | public function get_to_send_batch_and_send() { |
209 | - if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) { |
|
209 | + if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | |
213 | - $this->lock_queue( EE_Messages_Queue::action_sending ); |
|
213 | + $this->lock_queue(EE_Messages_Queue::action_sending); |
|
214 | 214 | |
215 | 215 | $batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit; |
216 | 216 | |
217 | 217 | $query_args = array( |
218 | 218 | // key 0 = where conditions |
219 | - 0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ), |
|
219 | + 0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())), |
|
220 | 220 | 'order_by' => $this->_get_priority_orderby(), |
221 | 221 | 'limit' => $batch |
222 | 222 | ); |
223 | 223 | |
224 | - $messages_to_send = EEM_Message::instance()->get_all( $query_args ); |
|
224 | + $messages_to_send = EEM_Message::instance()->get_all($query_args); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | //any to send? |
228 | - if ( ! $messages_to_send ) { |
|
229 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
228 | + if ( ! $messages_to_send) { |
|
229 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
230 | 230 | return false; |
231 | 231 | } |
232 | 232 | |
233 | 233 | //add to queue. |
234 | - foreach ( $messages_to_send as $message ) { |
|
235 | - if ( $message instanceof EE_Message ) { |
|
236 | - $this->add( $message ); |
|
234 | + foreach ($messages_to_send as $message) { |
|
235 | + if ($message instanceof EE_Message) { |
|
236 | + $this->add($message); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $this->execute(); |
242 | 242 | |
243 | 243 | //release lock |
244 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
244 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param string $type The type of queue being locked. |
255 | 255 | */ |
256 | - public function lock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
257 | - set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) ); |
|
256 | + public function lock_queue($type = EE_Messages_Queue::action_generating) { |
|
257 | + set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param string $type The type of queue being unlocked. |
267 | 267 | */ |
268 | - public function unlock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
269 | - delete_transient( $this->_get_lock_key( $type ) ); |
|
268 | + public function unlock_queue($type = EE_Messages_Queue::action_generating) { |
|
269 | + delete_transient($this->_get_lock_key($type)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $type The type of lock. |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) { |
|
281 | - return '_ee_lock_' . $type; |
|
280 | + protected function _get_lock_key($type = EE_Messages_Queue::action_generating) { |
|
281 | + return '_ee_lock_'.$type; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param string $type The type of lock |
290 | 290 | * @return int time to expiry in seconds. |
291 | 291 | */ |
292 | - protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) { |
|
293 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type ); |
|
292 | + protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) { |
|
293 | + return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return int |
309 | 309 | */ |
310 | 310 | protected function _get_rate_limit_expiry() { |
311 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS ); |
|
311 | + return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return int |
320 | 320 | */ |
321 | 321 | protected function _default_rate_limit() { |
322 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 ); |
|
322 | + return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param string $type The type of lock being checked for. |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | - public function is_locked( $type = EE_Messages_Queue::action_generating ) { |
|
349 | - return (bool) get_transient( $this->_get_lock_key( $type ) ); |
|
348 | + public function is_locked($type = EE_Messages_Queue::action_generating) { |
|
349 | + return (bool) get_transient($this->_get_lock_key($type)); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | |
@@ -361,9 +361,9 @@ discard block |
||
361 | 361 | * @return int |
362 | 362 | */ |
363 | 363 | public function get_rate_limit() { |
364 | - if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) { |
|
364 | + if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) { |
|
365 | 365 | $rate_limit = $this->_default_rate_limit(); |
366 | - set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() ); |
|
366 | + set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key()); |
|
367 | 367 | } |
368 | 368 | return $rate_limit; |
369 | 369 | } |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | * This updates existing rate limit with the new limit which is the old minus the batch. |
376 | 376 | * @param int $batch_completed This sets the new rate limit based on the given batch that was completed. |
377 | 377 | */ |
378 | - public function set_rate_limit( $batch_completed ) { |
|
378 | + public function set_rate_limit($batch_completed) { |
|
379 | 379 | //first get the most up to date rate limit (in case its expired and reset) |
380 | 380 | $rate_limit = $this->get_rate_limit(); |
381 | 381 | $new_limit = $rate_limit - $batch_completed; |
382 | 382 | //updating the transient option directly to avoid resetting the expiry. |
383 | - update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit ); |
|
383 | + update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param string $task This indicates what type of request is going to be initiated. |
394 | 394 | * @param int $priority This indicates the priority that triggers initiating the request. |
395 | 395 | */ |
396 | - public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) { |
|
396 | + public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { |
|
397 | 397 | //determine what status is matched with the priority as part of the trigger conditions. |
398 | 398 | $status = $task == 'generate' |
399 | 399 | ? EEM_Message::status_incomplete |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | // always make sure we save because either this will get executed immediately on a separate request |
402 | 402 | // or remains in the queue for the regularly scheduled queue batch. |
403 | 403 | $this->save(); |
404 | - if ( $this->_queue->count_by_priority_and_status( $priority, $status ) ) { |
|
405 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task ); |
|
404 | + if ($this->_queue->count_by_priority_and_status($priority, $status)) { |
|
405 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -425,50 +425,50 @@ discard block |
||
425 | 425 | * Also, if the messenger is an request type messenger (or a preview), |
426 | 426 | * its entirely possible that the messenger will exit before |
427 | 427 | */ |
428 | - public function execute( $save = true, $sending_messenger = null, $by_priority = false ) { |
|
428 | + public function execute($save = true, $sending_messenger = null, $by_priority = false) { |
|
429 | 429 | $messages_sent = 0; |
430 | 430 | $this->_did_hook = array(); |
431 | 431 | $this->_queue->rewind(); |
432 | - while ( $this->_queue->valid() ) { |
|
432 | + while ($this->_queue->valid()) { |
|
433 | 433 | $error_messages = array(); |
434 | 434 | /** @type EE_Message $message */ |
435 | 435 | $message = $this->_queue->current(); |
436 | 436 | //if the message in the queue has a sent status, then skip |
437 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_sent() ) ) { |
|
437 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_sent())) { |
|
438 | 438 | continue; |
439 | 439 | } |
440 | 440 | //if $by_priority is set and does not match then continue; |
441 | - if ( $by_priority && $by_priority != $message->priority() ) { |
|
441 | + if ($by_priority && $by_priority != $message->priority()) { |
|
442 | 442 | continue; |
443 | 443 | } |
444 | 444 | //error checking |
445 | - if ( ! $message->valid_messenger() ) { |
|
445 | + if ( ! $message->valid_messenger()) { |
|
446 | 446 | $error_messages[] = sprintf( |
447 | - __( 'The %s messenger is not active at time of sending.', 'event_espresso' ), |
|
447 | + __('The %s messenger is not active at time of sending.', 'event_espresso'), |
|
448 | 448 | $message->messenger() |
449 | 449 | ); |
450 | 450 | } |
451 | - if ( ! $message->valid_message_type() ) { |
|
451 | + if ( ! $message->valid_message_type()) { |
|
452 | 452 | $error_messages[] = sprintf( |
453 | - __( 'The %s message type is not active at the time of sending.', 'event_espresso' ), |
|
453 | + __('The %s message type is not active at the time of sending.', 'event_espresso'), |
|
454 | 454 | $message->message_type() |
455 | 455 | ); |
456 | 456 | } |
457 | 457 | // if there was supposed to be a sending messenger for this message, but it was invalid/inactive, |
458 | 458 | // then it will instead be an EE_Error object, so let's check for that |
459 | - if ( $sending_messenger instanceof EE_Error ) { |
|
459 | + if ($sending_messenger instanceof EE_Error) { |
|
460 | 460 | $error_messages[] = $sending_messenger->getMessage(); |
461 | 461 | } |
462 | 462 | // if there are no errors, then let's process the message |
463 | - if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) { |
|
463 | + if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) { |
|
464 | 464 | $messages_sent++; |
465 | 465 | } |
466 | - $this->_set_error_message( $message, $error_messages ); |
|
466 | + $this->_set_error_message($message, $error_messages); |
|
467 | 467 | //add modified time |
468 | - $message->set_modified( time() ); |
|
468 | + $message->set_modified(time()); |
|
469 | 469 | $this->_queue->next(); |
470 | 470 | } |
471 | - if ( $save ) { |
|
471 | + if ($save) { |
|
472 | 472 | $this->save(); |
473 | 473 | } |
474 | 474 | return $messages_sent; |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | * @param mixed $sending_messenger (optional) |
484 | 484 | * @return bool |
485 | 485 | */ |
486 | - protected function _process_message( EE_Message $message, $sending_messenger = null ) { |
|
486 | + protected function _process_message(EE_Message $message, $sending_messenger = null) { |
|
487 | 487 | // these *should* have been validated in the execute() method above |
488 | 488 | $messenger = $message->messenger_object(); |
489 | 489 | $message_type = $message->message_type_object(); |
@@ -493,20 +493,20 @@ discard block |
||
493 | 493 | && $messenger instanceof EE_Messenger |
494 | 494 | && $sending_messenger->name != $messenger->name |
495 | 495 | ) { |
496 | - $messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
496 | + $messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
497 | 497 | $messenger = $sending_messenger; |
498 | 498 | } |
499 | 499 | // send using messenger, but double check objects |
500 | - if ( $messenger instanceof EE_Messenger && $message_type instanceof EE_Message_Type ) { |
|
500 | + if ($messenger instanceof EE_Messenger && $message_type instanceof EE_Message_Type) { |
|
501 | 501 | //set hook for message type (but only if not using another messenger to send). |
502 | - if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) { |
|
503 | - $message_type->do_messenger_hooks( $messenger ); |
|
504 | - $this->_did_hook[ $message_type->name ] = 1; |
|
502 | + if ( ! isset($this->_did_hook[$message_type->name])) { |
|
503 | + $message_type->do_messenger_hooks($messenger); |
|
504 | + $this->_did_hook[$message_type->name] = 1; |
|
505 | 505 | } |
506 | 506 | //if preview then use preview method |
507 | 507 | return $this->_queue->is_preview() |
508 | - ? $this->_do_preview( $message, $messenger, $message_type, $this->_queue->is_test_send() ) |
|
509 | - : $this->_do_send( $message, $messenger, $message_type ); |
|
508 | + ? $this->_do_preview($message, $messenger, $message_type, $this->_queue->is_test_send()) |
|
509 | + : $this->_do_send($message, $messenger, $message_type); |
|
510 | 510 | } |
511 | 511 | return false; |
512 | 512 | } |
@@ -524,11 +524,11 @@ discard block |
||
524 | 524 | * @param array $status Stati to check for in queue |
525 | 525 | * @return int Count of EE_Message's matching the given status. |
526 | 526 | */ |
527 | - public function count_STS_in_queue( $status ) { |
|
527 | + public function count_STS_in_queue($status) { |
|
528 | 528 | $count = 0; |
529 | - $status = is_array( $status ) ? $status : array( $status ); |
|
530 | - foreach( $this->_queue as $message ) { |
|
531 | - if ( in_array( $message->STS_ID(), $status ) ) { |
|
529 | + $status = is_array($status) ? $status : array($status); |
|
530 | + foreach ($this->_queue as $message) { |
|
531 | + if (in_array($message->STS_ID(), $status)) { |
|
532 | 532 | $count++; |
533 | 533 | } |
534 | 534 | } |
@@ -545,15 +545,15 @@ discard block |
||
545 | 545 | * @param $test_send |
546 | 546 | * @return bool true means all went well, false means, not so much. |
547 | 547 | */ |
548 | - protected function _do_preview( EE_Message $message, EE_Messenger $messenger, EE_message_type $message_type, $test_send ) { |
|
549 | - if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) { |
|
550 | - if ( ! $test_send ) { |
|
551 | - $message->set_content( $preview ); |
|
548 | + protected function _do_preview(EE_Message $message, EE_Messenger $messenger, EE_message_type $message_type, $test_send) { |
|
549 | + if ($preview = $messenger->get_preview($message, $message_type, $test_send)) { |
|
550 | + if ( ! $test_send) { |
|
551 | + $message->set_content($preview); |
|
552 | 552 | } |
553 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
553 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
554 | 554 | return true; |
555 | 555 | } else { |
556 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
556 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
557 | 557 | return false; |
558 | 558 | } |
559 | 559 | } |
@@ -569,12 +569,12 @@ discard block |
||
569 | 569 | * @param EE_message_type $message_type |
570 | 570 | * @return bool true means all went well, false means, not so much. |
571 | 571 | */ |
572 | - protected function _do_send( EE_Message $message, EE_Messenger $messenger, EE_message_type $message_type ) { |
|
573 | - if ( $messenger->send_message( $message, $message_type ) ) { |
|
574 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
572 | + protected function _do_send(EE_Message $message, EE_Messenger $messenger, EE_message_type $message_type) { |
|
573 | + if ($messenger->send_message($message, $message_type)) { |
|
574 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
575 | 575 | return true; |
576 | 576 | } else { |
577 | - $message->set_STS_ID( EEM_Message::status_retry ); |
|
577 | + $message->set_STS_ID(EEM_Message::status_retry); |
|
578 | 578 | return false; |
579 | 579 | } |
580 | 580 | } |
@@ -588,21 +588,21 @@ discard block |
||
588 | 588 | * @param EE_Message $message |
589 | 589 | * @param array $error_messages the response from the messenger. |
590 | 590 | */ |
591 | - protected function _set_error_message( EE_Message $message, $error_messages ) { |
|
591 | + protected function _set_error_message(EE_Message $message, $error_messages) { |
|
592 | 592 | $error_messages = (array) $error_messages; |
593 | - if ( $message->STS_ID() === EEM_Message::status_failed || $message->STS_ID() === EEM_Message::status_retry ) { |
|
593 | + if ($message->STS_ID() === EEM_Message::status_failed || $message->STS_ID() === EEM_Message::status_retry) { |
|
594 | 594 | $notices = EE_Error::has_notices(); |
595 | - $error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' ); |
|
596 | - if ( $notices === 1 ) { |
|
595 | + $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); |
|
596 | + if ($notices === 1) { |
|
597 | 597 | $notices = EE_Error::get_vanilla_notices(); |
598 | - $notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array(); |
|
599 | - $error_messages[] = implode( "\n", $notices['errors'] ); |
|
598 | + $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); |
|
599 | + $error_messages[] = implode("\n", $notices['errors']); |
|
600 | 600 | } |
601 | 601 | } |
602 | - if ( count( $error_messages ) > 0 ) { |
|
603 | - $msg = __( 'Message was not executed successfully.', 'event_espresso' ); |
|
604 | - $msg = $msg . "\n" . implode( "\n", $error_messages ); |
|
605 | - $message->set_error_message( $msg ); |
|
602 | + if (count($error_messages) > 0) { |
|
603 | + $msg = __('Message was not executed successfully.', 'event_espresso'); |
|
604 | + $msg = $msg."\n".implode("\n", $error_messages); |
|
605 | + $message->set_error_message($msg); |
|
606 | 606 | } |
607 | 607 | } |
608 | 608 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * Identifier properties for the recipient |
23 | 23 | */ |
24 | - public $user_id; //if available we'll use this to set the fname and lname (admin) |
|
24 | + public $user_id; //if available we'll use this to set the fname and lname (admin) |
|
25 | 25 | public $fname; //this will always be the admin fname (set later via incoming user_id) |
26 | 26 | public $lname; //this will always be the admin lname (set later via incoming user_id) |
27 | 27 | public $primary_registration_id; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @access public |
151 | 151 | * @param array $addressee_data We're expecting an incoming array of data that will be used to fill the properties for the object. |
152 | 152 | */ |
153 | - public function __construct( $addressee_data ) { |
|
153 | + public function __construct($addressee_data) { |
|
154 | 154 | $this->_data = $addressee_data; |
155 | 155 | $this->_set_properties(); |
156 | 156 | } |
@@ -166,15 +166,15 @@ discard block |
||
166 | 166 | */ |
167 | 167 | protected function _set_properties() { |
168 | 168 | |
169 | - foreach ( $this->_data as $prop => $value ) { |
|
170 | - if( property_exists( $this, $prop ) ) |
|
169 | + foreach ($this->_data as $prop => $value) { |
|
170 | + if (property_exists($this, $prop)) |
|
171 | 171 | $this->$prop = $value; |
172 | 172 | } |
173 | 173 | |
174 | 174 | //if user_id present we'll use this to set the fname and lname and admin_email. |
175 | - if ( !empty( $this->user_id ) ) { |
|
175 | + if ( ! empty($this->user_id)) { |
|
176 | 176 | $this->user_id = (int) $this->user_id; |
177 | - $user = get_userdata( $this->user_id ); |
|
177 | + $user = get_userdata($this->user_id); |
|
178 | 178 | $this->fname = $user->user_firstname; |
179 | 179 | $this->lname = $user->user_lastname; |
180 | 180 | $this->admin_email = $user->user_email; |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * EE_Messages_Addressee |
@@ -167,8 +168,9 @@ discard block |
||
167 | 168 | protected function _set_properties() { |
168 | 169 | |
169 | 170 | foreach ( $this->_data as $prop => $value ) { |
170 | - if( property_exists( $this, $prop ) ) |
|
171 | - $this->$prop = $value; |
|
171 | + if( property_exists( $this, $prop ) ) { |
|
172 | + $this->$prop = $value; |
|
173 | + } |
|
172 | 174 | } |
173 | 175 | |
174 | 176 | //if user_id present we'll use this to set the fname and lname and admin_email. |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * For the constructor of this special preview class. We're either looking for an event id or empty data. If we have an event id (or ids) then we'll use that as the source for the "dummy" data. If the data is empty then we'll get the first three published events from the users database and use that as a source. |
30 | 30 | * @param array $data |
31 | 31 | */ |
32 | - public function __construct( $data = array() ) { |
|
33 | - $this->_data = isset( $data['event_ids'] ) ? $data['event_ids'] : array(); |
|
32 | + public function __construct($data = array()) { |
|
33 | + $this->_data = isset($data['event_ids']) ? $data['event_ids'] : array(); |
|
34 | 34 | $this->_setup_attendees_events(); |
35 | 35 | parent::__construct($data); |
36 | 36 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return array The prepped data for db |
48 | 48 | */ |
49 | - static public function convert_data_for_persistent_storage( $data ) { |
|
49 | + static public function convert_data_for_persistent_storage($data) { |
|
50 | 50 | return $data; |
51 | 51 | } |
52 | 52 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return array |
63 | 63 | */ |
64 | - static public function convert_data_from_persistent_storage( $data ) { |
|
64 | + static public function convert_data_from_persistent_storage($data) { |
|
65 | 65 | return $data; |
66 | 66 | } |
67 | 67 | |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $attendees = $this->_get_some_attendees(); |
79 | 79 | |
80 | 80 | //if empty $data we'll do a query to get some events from the server. otherwise we'll retrieve the event data for the given ids. |
81 | - $events = $this->_get_some_events( $this->_data ); |
|
81 | + $events = $this->_get_some_events($this->_data); |
|
82 | 82 | |
83 | 83 | $answers_n_questions = $this->_get_some_q_and_as(); |
84 | 84 | |
85 | - if ( count( $events ) < 1 ) { |
|
86 | - throw new EE_Error( __('We can\'t generate a preview for you because there are no active events in your database', 'event_espresso' ) ); |
|
85 | + if (count($events) < 1) { |
|
86 | + throw new EE_Error(__('We can\'t generate a preview for you because there are no active events in your database', 'event_espresso')); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | |
94 | 94 | //we'll actually use the generated line_item identifiers for our loop |
95 | 95 | $dtts = $tkts = array(); |
96 | - foreach( $events as $id => $event ) { |
|
97 | - if ( ! $event instanceof EE_Event ) { |
|
96 | + foreach ($events as $id => $event) { |
|
97 | + if ( ! $event instanceof EE_Event) { |
|
98 | 98 | continue; |
99 | 99 | } |
100 | 100 | $this->_events[$id]['ID'] = $id; |
101 | 101 | $this->_events[$id]['name'] = $event->get('EVT_name'); |
102 | 102 | $datetime = $event->get_first_related('Datetime'); |
103 | - $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related('Ticket', array('default_where_conditions' => 'none') ) : array(); |
|
103 | + $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related('Ticket', array('default_where_conditions' => 'none')) : array(); |
|
104 | 104 | $this->_events[$id]['event'] = $event; |
105 | 105 | $this->_events[$id]['reg_objs'] = array(); |
106 | 106 | $this->_events[$id]['tkt_objs'] = $tickets; |
@@ -108,51 +108,51 @@ discard block |
||
108 | 108 | |
109 | 109 | $dttcache = array(); |
110 | 110 | $tkts = array(); |
111 | - foreach ( $tickets as $ticket ) { |
|
112 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
111 | + foreach ($tickets as $ticket) { |
|
112 | + if ( ! $ticket instanceof EE_Ticket) { |
|
113 | 113 | continue; |
114 | 114 | } |
115 | 115 | $reldatetime = $ticket->datetimes(); |
116 | - $tkts[ $ticket->ID() ] = array(); |
|
117 | - $tkts[ $ticket->ID() ][ 'ticket' ] = $ticket; |
|
118 | - $tkts[ $ticket->ID() ][ 'dtt_objs' ] = $reldatetime; |
|
119 | - $tkts[ $ticket->ID() ][ 'att_objs' ] = $attendees; |
|
120 | - $tkts[ $ticket->ID() ][ 'count' ] = count( $attendees ); |
|
121 | - $tkts[ $ticket->ID() ][ 'EE_Event' ] = $event; |
|
122 | - foreach ( $reldatetime as $datetime ) { |
|
123 | - if ( $datetime instanceof EE_Datetime && ! isset( $dtts[ $datetime->ID() ] ) ) { |
|
124 | - $this->_events[ $id ][ 'dtt_objs' ][ $datetime->ID() ] = $datetime; |
|
125 | - $dtts[ $datetime->ID() ][ 'datetime' ] = $datetime; |
|
126 | - $dtts[ $datetime->ID() ][ 'tkt_objs' ][] = $ticket; |
|
127 | - $dtts[ $datetime->ID() ][ 'evt_objs' ][] = $event; |
|
128 | - $dttcache[ $datetime->ID() ] = $datetime; |
|
116 | + $tkts[$ticket->ID()] = array(); |
|
117 | + $tkts[$ticket->ID()]['ticket'] = $ticket; |
|
118 | + $tkts[$ticket->ID()]['dtt_objs'] = $reldatetime; |
|
119 | + $tkts[$ticket->ID()]['att_objs'] = $attendees; |
|
120 | + $tkts[$ticket->ID()]['count'] = count($attendees); |
|
121 | + $tkts[$ticket->ID()]['EE_Event'] = $event; |
|
122 | + foreach ($reldatetime as $datetime) { |
|
123 | + if ($datetime instanceof EE_Datetime && ! isset($dtts[$datetime->ID()])) { |
|
124 | + $this->_events[$id]['dtt_objs'][$datetime->ID()] = $datetime; |
|
125 | + $dtts[$datetime->ID()]['datetime'] = $datetime; |
|
126 | + $dtts[$datetime->ID()]['tkt_objs'][] = $ticket; |
|
127 | + $dtts[$datetime->ID()]['evt_objs'][] = $event; |
|
128 | + $dttcache[$datetime->ID()] = $datetime; |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | - $this->_events[$id]['total_attendees'] = count( $attendees ); |
|
133 | + $this->_events[$id]['total_attendees'] = count($attendees); |
|
134 | 134 | $this->_events[$id]['att_objs'] = $attendees; |
135 | 135 | |
136 | 136 | //let's also setup the dummy attendees property! |
137 | - foreach ( $attendees as $att_key => $attendee ) { |
|
138 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
137 | + foreach ($attendees as $att_key => $attendee) { |
|
138 | + if ( ! $attendee instanceof EE_Attendee) { |
|
139 | 139 | continue; |
140 | 140 | } |
141 | - $this->_attendees[$att_key]['line_ref'][] = $id; //so later it can be determined what events this attendee registered for! |
|
141 | + $this->_attendees[$att_key]['line_ref'][] = $id; //so later it can be determined what events this attendee registered for! |
|
142 | 142 | $this->_attendees[$att_key]['evt_objs'][] = $event; |
143 | 143 | $this->_attendees[$att_key]['att_obj'] = $attendee; |
144 | 144 | //$this->_attendees[$att_key]['registration_id'] = 0; |
145 | 145 | $this->_attendees[$att_key]['attendee_email'] = $attendee->email(); |
146 | 146 | $this->_attendees[$att_key]['tkt_objs'] = $tickets; |
147 | - if ( $att_key == 999999991 ) { |
|
147 | + if ($att_key == 999999991) { |
|
148 | 148 | $this->_attendees[$att_key]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
149 | 149 | $this->_attendees[$att_key]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
150 | 150 | $this->_attendees[$att_key]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
151 | - } elseif ( $att_key == 999999992 ) { |
|
151 | + } elseif ($att_key == 999999992) { |
|
152 | 152 | $this->_attendees[$att_key]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
153 | 153 | $this->_attendees[$att_key]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
154 | 154 | $this->_attendees[$att_key]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
155 | - } elseif ( $att_key == 999999993 ) { |
|
155 | + } elseif ($att_key == 999999993) { |
|
156 | 156 | $this->_attendees[$att_key]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
157 | 157 | $this->_attendees[$att_key]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
158 | 158 | $this->_attendees[$att_key]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | |
226 | 226 | //let's generate the attendee objects |
227 | 227 | $attendees = array(); |
228 | - $var_array = array('fname','lname','email','address','address2','city','staid','cntry','zip','phone','deleted','attid'); |
|
228 | + $var_array = array('fname', 'lname', 'email', 'address', 'address2', 'city', 'staid', 'cntry', 'zip', 'phone', 'deleted', 'attid'); |
|
229 | 229 | |
230 | - EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, TRUE, TRUE ); |
|
231 | - foreach ( $dummy_attendees as $dummy ) { |
|
232 | - $att = array_combine( $var_array, $dummy ); |
|
230 | + EE_Registry::instance()->load_class('Attendee', array(), FALSE, TRUE, TRUE); |
|
231 | + foreach ($dummy_attendees as $dummy) { |
|
232 | + $att = array_combine($var_array, $dummy); |
|
233 | 233 | extract($att); |
234 | 234 | /** @var $fname string */ |
235 | 235 | /** @var $lname string */ |
@@ -341,20 +341,20 @@ discard block |
||
341 | 341 | $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system'); |
342 | 342 | $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value'); |
343 | 343 | |
344 | - EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE ); |
|
345 | - EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE ); |
|
344 | + EE_Registry::instance()->load_class('Question', array(), FALSE, TRUE, TRUE); |
|
345 | + EE_Registry::instance()->load_class('Answer', array(), FALSE, TRUE, TRUE); |
|
346 | 346 | |
347 | 347 | $qsts = array(); |
348 | 348 | //first the questions |
349 | - foreach ( $quests_array as $qst ) { |
|
350 | - $qstobj = array_combine( $qst_columns, $qst ); |
|
349 | + foreach ($quests_array as $qst) { |
|
350 | + $qstobj = array_combine($qst_columns, $qst); |
|
351 | 351 | $qsts[$qstobj['QST_ID']] = EE_Question::new_instance($qstobj); |
352 | 352 | } |
353 | 353 | |
354 | 354 | //now the answers (and we'll setup our arrays) |
355 | 355 | $q_n_as = array(); |
356 | - foreach ( $ans_array as $ans ) { |
|
357 | - $ansobj = array_combine( $ans_columns, $ans ); |
|
356 | + foreach ($ans_array as $ans) { |
|
357 | + $ansobj = array_combine($ans_columns, $ans); |
|
358 | 358 | $ansobj = EE_Answer::new_instance($ansobj); |
359 | 359 | $q_n_as['answers'][$ansobj->ID()] = $ansobj; |
360 | 360 | $q_n_as['questions'][$ansobj->ID()] = $qsts[$ansobj->get('QST_ID')]; |
@@ -376,25 +376,25 @@ discard block |
||
376 | 376 | * @param array $event_ids if set, this will be an array of event ids to obtain events for. |
377 | 377 | * @return array An array of event objects from the db. |
378 | 378 | */ |
379 | - private function _get_some_events( $event_ids = array() ) { |
|
379 | + private function _get_some_events($event_ids = array()) { |
|
380 | 380 | |
381 | 381 | //HEY, if we have an evt_id then we want to make sure we use that for the preview (because a specific event template is being viewed); |
382 | - $event_ids = isset( $_REQUEST['evt_id'] ) && !empty( $_REQUEST['evt_id'] ) |
|
383 | - ? array( $_REQUEST['evt_id'] ) |
|
382 | + $event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id']) |
|
383 | + ? array($_REQUEST['evt_id']) |
|
384 | 384 | : $event_ids; |
385 | 385 | |
386 | - $limit = !empty( $event_ids ) |
|
386 | + $limit = ! empty($event_ids) |
|
387 | 387 | ? NULL |
388 | - : apply_filters( 'FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1' ); |
|
388 | + : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1'); |
|
389 | 389 | |
390 | - $where = ! empty( $event_ids ) |
|
390 | + $where = ! empty($event_ids) |
|
391 | 391 | ? array( |
392 | - 'EVT_ID' => array( 'IN', $event_ids ), |
|
393 | - 'Datetime.Ticket.TKT_ID' => array( '>', 1 ) |
|
392 | + 'EVT_ID' => array('IN', $event_ids), |
|
393 | + 'Datetime.Ticket.TKT_ID' => array('>', 1) |
|
394 | 394 | ) |
395 | - : array( 'Datetime.Ticket.TKT_ID' => array( '>', 1 ) ); |
|
395 | + : array('Datetime.Ticket.TKT_ID' => array('>', 1)); |
|
396 | 396 | |
397 | - $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit ) ); |
|
397 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit)); |
|
398 | 398 | |
399 | 399 | return $events; |
400 | 400 | } |
@@ -407,17 +407,17 @@ discard block |
||
407 | 407 | protected function _setup_data() { |
408 | 408 | |
409 | 409 | //need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it! |
410 | - if ( EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
411 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
410 | + if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
411 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
412 | 412 | $session = EE_Registry::instance()->SSN; |
413 | 413 | } else { |
414 | - $session = EE_Registry::instance()->load_core( 'Session' ); |
|
414 | + $session = EE_Registry::instance()->load_core('Session'); |
|
415 | 415 | } |
416 | - $cart = EE_Cart::instance( null, $session ); |
|
416 | + $cart = EE_Cart::instance(null, $session); |
|
417 | 417 | |
418 | 418 | |
419 | 419 | //add tickets to cart |
420 | - foreach ( $this->tickets as $ticket ) { |
|
420 | + foreach ($this->tickets as $ticket) { |
|
421 | 421 | $cart->add_ticket_to_cart($ticket['ticket']); |
422 | 422 | } |
423 | 423 | |
@@ -441,14 +441,14 @@ discard block |
||
441 | 441 | //note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array. |
442 | 442 | $this->reg_objs = array(); |
443 | 443 | $regid = 9999990; |
444 | - foreach ( $this->_attendees as $key => $attendee ) { |
|
444 | + foreach ($this->_attendees as $key => $attendee) { |
|
445 | 445 | //note we need to setup reg_objects for each event this attendee belongs to |
446 | 446 | $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null; |
447 | 447 | $regtxn = $this->txn->ID(); |
448 | 448 | $regcnt = 1; |
449 | - foreach ( $attendee['line_ref'] as $evtid ) { |
|
450 | - foreach ( $this->_events[$evtid]['tkt_objs'] as $ticket ) { |
|
451 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
449 | + foreach ($attendee['line_ref'] as $evtid) { |
|
450 | + foreach ($this->_events[$evtid]['tkt_objs'] as $ticket) { |
|
451 | + if ( ! $ticket instanceof EE_Ticket) { |
|
452 | 452 | continue; |
453 | 453 | } |
454 | 454 | $reg_array = array( |
@@ -460,14 +460,14 @@ discard block |
||
460 | 460 | 'REG_date' => time(), |
461 | 461 | 'REG_final_price' => $ticket->get('TKT_price'), |
462 | 462 | 'REG_session' => 'dummy_session_id', |
463 | - 'REG_code' => $regid . '-dummy-generated-code', |
|
464 | - 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
463 | + 'REG_code' => $regid.'-dummy-generated-code', |
|
464 | + 'REG_url_link' => $regcnt.'-daafpapasdlfakasdfpqasdfasdf', |
|
465 | 465 | 'REG_count' => $regcnt, |
466 | 466 | 'REG_group_size' => $this->_events[$evtid]['total_attendees'], |
467 | 467 | 'REG_att_is_going' => TRUE, |
468 | 468 | 'REG_ID' => $regid |
469 | 469 | ); |
470 | - $REG_OBJ = EE_Registration::new_instance( $reg_array ); |
|
470 | + $REG_OBJ = EE_Registration::new_instance($reg_array); |
|
471 | 471 | $this->_attendees[$key]['reg_objs'][$regid] = $REG_OBJ; |
472 | 472 | $this->_events[$evtid]['reg_objs'][] = $REG_OBJ; |
473 | 473 | $this->reg_objs[] = $REG_OBJ; |
@@ -483,40 +483,40 @@ discard block |
||
483 | 483 | |
484 | 484 | //setup line items! |
485 | 485 | EE_Registry::instance()->load_helper('Line_Item'); |
486 | - $line_item_total = EEH_Line_Item::create_total_line_item( $this->txn ); |
|
486 | + $line_item_total = EEH_Line_Item::create_total_line_item($this->txn); |
|
487 | 487 | |
488 | 488 | //add tickets |
489 | - foreach ( $this->tickets as $tktid => $item ) { |
|
489 | + foreach ($this->tickets as $tktid => $item) { |
|
490 | 490 | $qty = $item['count']; |
491 | 491 | $ticket = $item['ticket']; |
492 | - EEH_Line_Item::add_ticket_purchase( $line_item_total, $ticket, $qty ); |
|
492 | + EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty); |
|
493 | 493 | } |
494 | 494 | |
495 | - $shipping_line_item = EE_Line_Item::new_instance( array( |
|
496 | - 'LIN_name' => __( 'Shipping Surcharge', 'event_espresso' ), |
|
497 | - 'LIN_desc' => __( 'Sent via Millenium Falcon', 'event_espresso' ), |
|
495 | + $shipping_line_item = EE_Line_Item::new_instance(array( |
|
496 | + 'LIN_name' => __('Shipping Surcharge', 'event_espresso'), |
|
497 | + 'LIN_desc' => __('Sent via Millenium Falcon', 'event_espresso'), |
|
498 | 498 | 'LIN_unit_price' => 20, |
499 | 499 | 'LIN_quantity' => 1, |
500 | 500 | 'LIN_is_taxable' => TRUE, |
501 | 501 | 'LIN_total' => 20, |
502 | 502 | 'LIN_type' => EEM_Line_Item::type_line_item |
503 | 503 | )); |
504 | - EEH_Line_Item::add_item($line_item_total, $shipping_line_item ); |
|
505 | - $this->additional_line_items = array( $shipping_line_item ); |
|
504 | + EEH_Line_Item::add_item($line_item_total, $shipping_line_item); |
|
505 | + $this->additional_line_items = array($shipping_line_item); |
|
506 | 506 | |
507 | 507 | //now let's add taxes |
508 | - EEH_Line_Item::apply_taxes( $line_item_total ); |
|
508 | + EEH_Line_Item::apply_taxes($line_item_total); |
|
509 | 509 | |
510 | 510 | //now we should be able to get the items we need from this object |
511 | - $event_line_items = EEH_Line_Item::get_pre_tax_subtotal( $line_item_total )->children(); |
|
511 | + $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
|
512 | 512 | $line_items = array(); |
513 | - foreach ( $event_line_items as $line_id => $line_item ) { |
|
514 | - if ( ! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event' ) { |
|
513 | + foreach ($event_line_items as $line_id => $line_item) { |
|
514 | + if ( ! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
515 | 515 | continue; |
516 | 516 | } |
517 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items( $line_item ); |
|
518 | - foreach ( $ticket_line_items as $ticket_line_id => $ticket_line_item ) { |
|
519 | - if ( ! $ticket_line_item instanceof EE_Line_Item ) { |
|
517 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
|
518 | + foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) { |
|
519 | + if ( ! $ticket_line_item instanceof EE_Line_Item) { |
|
520 | 520 | continue; |
521 | 521 | } |
522 | 522 | $this->tickets[$ticket_line_item->OBJ_ID()]['line_item'] = $ticket_line_item; |
@@ -532,12 +532,12 @@ discard block |
||
532 | 532 | //add proper total to transaction object. |
533 | 533 | $grand_total = $line_item_total->recalculate_total_including_taxes(); |
534 | 534 | $this->grand_total_line_item = $line_item_total; |
535 | - $this->txn->set_total( $grand_total ); |
|
535 | + $this->txn->set_total($grand_total); |
|
536 | 536 | |
537 | 537 | |
538 | 538 | //add additional details for each registration |
539 | - foreach ( $this->reg_objs as $reg ) { |
|
540 | - if ( ! $reg instanceof EE_Registration ) { |
|
539 | + foreach ($this->reg_objs as $reg) { |
|
540 | + if ( ! $reg instanceof EE_Registration) { |
|
541 | 541 | continue; |
542 | 542 | } |
543 | 543 | $this->_registrations[$reg->ID()]['tkt_obj'] = $this->tickets[$reg->get('TKT_ID')]['ticket']; |
@@ -562,17 +562,17 @@ discard block |
||
562 | 562 | ? $this->_attendees[999999991]['att_obj']->fname() |
563 | 563 | : '', |
564 | 564 | |
565 | - 'lname' => $this->_attendees[ 999999991 ][ 'att_obj' ] instanceof EE_Attendee |
|
565 | + 'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
566 | 566 | ? $this->_attendees[999999991]['att_obj']->lname() |
567 | 567 | : '', |
568 | 568 | |
569 | - 'email' => $this->_attendees[ 999999991 ][ 'att_obj' ] instanceof EE_Attendee |
|
569 | + 'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
570 | 570 | ? $this->_attendees[999999991]['att_obj']->email() |
571 | 571 | : '', |
572 | 572 | |
573 | 573 | 'att_obj' => $this->_attendees[999999991]['att_obj'], |
574 | 574 | |
575 | - 'reg_obj' => array_shift( $attendees_to_shift[999999991]['reg_objs'] ) |
|
575 | + 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']) |
|
576 | 576 | ); |
577 | 577 | |
578 | 578 | //reg_info property |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | $this->reg_info = array(); |
581 | 581 | |
582 | 582 | //let's set a reg_obj for messengers expecting one. |
583 | - $this->reg_obj = array_pop( $this->_attendees[999999991]['reg_objs'] ); |
|
583 | + $this->reg_obj = array_pop($this->_attendees[999999991]['reg_objs']); |
|
584 | 584 | |
585 | 585 | |
586 | 586 | //the below are just dummy items. |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | * @param EE_Registration|array $data |
30 | 30 | * @throws \EE_Error |
31 | 31 | */ |
32 | - public function __construct( $data ) { |
|
32 | + public function __construct($data) { |
|
33 | 33 | $filtered_reg_status = null; |
34 | 34 | |
35 | - if ( ! is_array( $data ) && $data instanceof EE_Registration ) { |
|
35 | + if ( ! is_array($data) && $data instanceof EE_Registration) { |
|
36 | 36 | $this->reg_obj = $data; |
37 | 37 | } else { |
38 | - $this->reg_obj = is_array( $data ) && isset( $data[0] ) && $data[0] instanceof EE_Registration ? $data[0] : null; |
|
39 | - $filtered_reg_status = is_array( $data ) && ! empty( $data[1] ) ? $data[1] : null; |
|
38 | + $this->reg_obj = is_array($data) && isset($data[0]) && $data[0] instanceof EE_Registration ? $data[0] : null; |
|
39 | + $filtered_reg_status = is_array($data) && ! empty($data[1]) ? $data[1] : null; |
|
40 | 40 | } |
41 | 41 | |
42 | - if ( ! $this->reg_obj instanceof EE_Registration ) { |
|
42 | + if ( ! $this->reg_obj instanceof EE_Registration) { |
|
43 | 43 | throw new EE_Error( |
44 | 44 | sprintf( |
45 | - __( '%1$s requires the incoming data argument to be an instance of %2$s or an array where the first value is an instance of %2$s', 'event_espresso'), |
|
45 | + __('%1$s requires the incoming data argument to be an instance of %2$s or an array where the first value is an instance of %2$s', 'event_espresso'), |
|
46 | 46 | 'EE_Messages_REG_incoming_data', |
47 | 47 | 'EE_Registration' |
48 | 48 | ) |
@@ -64,18 +64,18 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return array The prepped data for db |
66 | 66 | */ |
67 | - static public function convert_data_for_persistent_storage( $data ) { |
|
67 | + static public function convert_data_for_persistent_storage($data) { |
|
68 | 68 | $prepped_data = array(); |
69 | - if ( ! is_array( $data ) && $data instanceof EE_Registration ) { |
|
69 | + if ( ! is_array($data) && $data instanceof EE_Registration) { |
|
70 | 70 | $prepped_data['Registration'] = $data->ID(); |
71 | 71 | return $prepped_data; |
72 | - } elseif ( ! is_array( $data ) ) { |
|
72 | + } elseif ( ! is_array($data)) { |
|
73 | 73 | return array(); |
74 | 74 | } else { |
75 | - if ( $data[0] instanceof EE_Registration ) { |
|
75 | + if ($data[0] instanceof EE_Registration) { |
|
76 | 76 | $prepped_data['Registration'] = $data[0]; |
77 | 77 | } |
78 | - if ( ! empty( $data[1] ) ) { |
|
78 | + if ( ! empty($data[1])) { |
|
79 | 79 | $prepped_data['filter'] = $data[1]; |
80 | 80 | } |
81 | 81 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return mixed |
93 | 93 | */ |
94 | - static public function convert_data_from_persistent_storage( $data ) { |
|
94 | + static public function convert_data_from_persistent_storage($data) { |
|
95 | 95 | $prepped_data = array( |
96 | - 0 => isset( $data['Registration'] ) ? EEM_Registration::instance()->get_one_by_ID( $data['Registration'] ) : null, |
|
97 | - 1 => isset( $data['filter'] ) ? $data['filter'] : null |
|
96 | + 0 => isset($data['Registration']) ? EEM_Registration::instance()->get_one_by_ID($data['Registration']) : null, |
|
97 | + 1 => isset($data['filter']) ? $data['filter'] : null |
|
98 | 98 | ); |
99 | 99 | return $prepped_data; |
100 | 100 | } |
@@ -112,18 +112,18 @@ discard block |
||
112 | 112 | $this->txn = $this->reg_obj->transaction(); |
113 | 113 | //possible session stuff? |
114 | 114 | $session = $this->txn->session_data(); |
115 | - $session_data = $session instanceof EE_Session ? $session->get_session_data() : array(); |
|
115 | + $session_data = $session instanceof EE_Session ? $session->get_session_data() : array(); |
|
116 | 116 | |
117 | 117 | //other data from the session (if possible) |
118 | - $this->user_id = isset( $session_data['user_id'] ) ? $session_data['user_id'] : ''; |
|
119 | - $this->ip_address = isset( $session_data['ip_address'] ) ? $session_data['ip_address'] : ''; |
|
120 | - $this->user_agent = isset( $session_data['user_agent'] ) ? $session_data['user_agent'] : ''; |
|
118 | + $this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : ''; |
|
119 | + $this->ip_address = isset($session_data['ip_address']) ? $session_data['ip_address'] : ''; |
|
120 | + $this->user_agent = isset($session_data['user_agent']) ? $session_data['user_agent'] : ''; |
|
121 | 121 | $this->init_access = $this->last_access = ''; |
122 | 122 | |
123 | 123 | $this->payment = $this->txn->get_first_related('Payment'); |
124 | 124 | // if there is no payments associated with the transaction |
125 | 125 | // then we just create a default payment object for potential parsing. |
126 | - $this->payment = empty( $this->payment ) |
|
126 | + $this->payment = empty($this->payment) |
|
127 | 127 | ? EE_Payment::new_instance( |
128 | 128 | array( |
129 | 129 | 'STS_ID' => EEM_Payment::status_id_pending, |