@@ -278,6 +278,7 @@ |
||
278 | 278 | |
279 | 279 | /** |
280 | 280 | * @param mixed string | EED_Module $module |
281 | + * @param string $module |
|
281 | 282 | */ |
282 | 283 | public function add_module( $module ) { |
283 | 284 | if ( $module instanceof EED_Module ) { |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | * @param \EE_Dependency_Map $dependency_map |
179 | 179 | * @return \EE_Registry instance |
180 | 180 | */ |
181 | - public static function instance( \EE_Dependency_Map $dependency_map = null ) { |
|
181 | + public static function instance(\EE_Dependency_Map $dependency_map = null) { |
|
182 | 182 | // check if class object is instantiated |
183 | - if ( ! self::$_instance instanceof EE_Registry ) { |
|
184 | - self::$_instance = new EE_Registry( $dependency_map ); |
|
183 | + if ( ! self::$_instance instanceof EE_Registry) { |
|
184 | + self::$_instance = new EE_Registry($dependency_map); |
|
185 | 185 | } |
186 | 186 | return self::$_instance; |
187 | 187 | } |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | * @param \EE_Dependency_Map $dependency_map |
197 | 197 | * @return \EE_Registry |
198 | 198 | */ |
199 | - protected function __construct( \EE_Dependency_Map $dependency_map ) { |
|
199 | + protected function __construct(\EE_Dependency_Map $dependency_map) { |
|
200 | 200 | $this->_dependency_map = $dependency_map; |
201 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
201 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -225,19 +225,19 @@ discard block |
||
225 | 225 | $this->modules = new StdClass(); |
226 | 226 | $this->shortcodes = new StdClass(); |
227 | 227 | $this->widgets = new StdClass(); |
228 | - $this->load_core( 'Base', array(), true ); |
|
228 | + $this->load_core('Base', array(), true); |
|
229 | 229 | // add our request and response objects to the cache |
230 | - $request_loader = $this->_dependency_map->class_loader( 'EE_Request' ); |
|
230 | + $request_loader = $this->_dependency_map->class_loader('EE_Request'); |
|
231 | 231 | $this->_set_cached_class( |
232 | 232 | $request_loader(), |
233 | 233 | 'EE_Request' |
234 | 234 | ); |
235 | - $response_loader = $this->_dependency_map->class_loader( 'EE_Response' ); |
|
235 | + $response_loader = $this->_dependency_map->class_loader('EE_Response'); |
|
236 | 236 | $this->_set_cached_class( |
237 | 237 | $response_loader(), |
238 | 238 | 'EE_Response' |
239 | 239 | ); |
240 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
240 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function init() { |
252 | 252 | // Get current page protocol |
253 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
253 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
254 | 254 | // Output admin-ajax.php URL with same protocol as current page |
255 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
256 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
255 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
256 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | * @return string |
265 | 265 | */ |
266 | 266 | public static function localize_i18n_js_strings() { |
267 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
268 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
269 | - if ( is_scalar( $value ) ) { |
|
270 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
267 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
268 | + foreach ($i18n_js_strings as $key => $value) { |
|
269 | + if (is_scalar($value)) { |
|
270 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
274 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -279,15 +279,15 @@ discard block |
||
279 | 279 | /** |
280 | 280 | * @param mixed string | EED_Module $module |
281 | 281 | */ |
282 | - public function add_module( $module ) { |
|
283 | - if ( $module instanceof EED_Module ) { |
|
284 | - $module_class = get_class( $module ); |
|
282 | + public function add_module($module) { |
|
283 | + if ($module instanceof EED_Module) { |
|
284 | + $module_class = get_class($module); |
|
285 | 285 | $this->modules->{$module_class} = $module; |
286 | 286 | } else { |
287 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
288 | - $this->load_core( 'Module_Request_Router' ); |
|
287 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
288 | + $this->load_core('Module_Request_Router'); |
|
289 | 289 | } |
290 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
290 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | * @param string $module_name |
298 | 298 | * @return mixed EED_Module | NULL |
299 | 299 | */ |
300 | - public function get_module( $module_name = '' ) { |
|
301 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
300 | + public function get_module($module_name = '') { |
|
301 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -312,20 +312,20 @@ discard block |
||
312 | 312 | * @param bool $load_only |
313 | 313 | * @return mixed |
314 | 314 | */ |
315 | - public function load_core( $class_name, $arguments = array(), $load_only = false ) { |
|
315 | + public function load_core($class_name, $arguments = array(), $load_only = false) { |
|
316 | 316 | $core_paths = apply_filters( |
317 | 317 | 'FHEE__EE_Registry__load_core__core_paths', |
318 | 318 | array( |
319 | 319 | EE_CORE, |
320 | 320 | EE_ADMIN, |
321 | 321 | EE_CPTS, |
322 | - EE_CORE . 'data_migration_scripts' . DS, |
|
323 | - EE_CORE . 'request_stack' . DS, |
|
324 | - EE_CORE . 'middleware' . DS, |
|
322 | + EE_CORE.'data_migration_scripts'.DS, |
|
323 | + EE_CORE.'request_stack'.DS, |
|
324 | + EE_CORE.'middleware'.DS, |
|
325 | 325 | ) |
326 | 326 | ); |
327 | 327 | // retrieve instantiated class |
328 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only ); |
|
328 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -339,15 +339,15 @@ discard block |
||
339 | 339 | * @param bool $load_only |
340 | 340 | * @return mixed |
341 | 341 | */ |
342 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
342 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
343 | 343 | $service_paths = apply_filters( |
344 | 344 | 'FHEE__EE_Registry__load_service__service_paths', |
345 | 345 | array( |
346 | - EE_CORE . 'services' . DS, |
|
346 | + EE_CORE.'services'.DS, |
|
347 | 347 | ) |
348 | 348 | ); |
349 | 349 | // retrieve instantiated class |
350 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only ); |
|
350 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | * @param mixed $arguments |
361 | 361 | * @return EE_Data_Migration_Script_Base |
362 | 362 | */ |
363 | - public function load_dms( $class_name, $arguments = array() ) { |
|
363 | + public function load_dms($class_name, $arguments = array()) { |
|
364 | 364 | // retrieve instantiated class |
365 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
365 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | |
@@ -377,14 +377,14 @@ discard block |
||
377 | 377 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
378 | 378 | * @return EE_Base_Class | bool |
379 | 379 | */ |
380 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
381 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
380 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
381 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
382 | 382 | EE_CORE, |
383 | 383 | EE_CLASSES, |
384 | 384 | EE_BUSINESS |
385 | - ) ); |
|
385 | + )); |
|
386 | 386 | // retrieve instantiated class |
387 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
387 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | * @param bool $load_only |
398 | 398 | * @return EEH_Base | bool |
399 | 399 | */ |
400 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
400 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
401 | 401 | // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed |
402 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
402 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
403 | 403 | // retrieve instantiated class |
404 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
404 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -416,16 +416,16 @@ discard block |
||
416 | 416 | * @param bool $cache whether to cache the object or not. |
417 | 417 | * @return mixed |
418 | 418 | */ |
419 | - public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) { |
|
419 | + public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) { |
|
420 | 420 | $paths = array( |
421 | 421 | EE_LIBRARIES, |
422 | - EE_LIBRARIES . 'messages' . DS, |
|
423 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
424 | - EE_LIBRARIES . 'qtips' . DS, |
|
425 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
422 | + EE_LIBRARIES.'messages'.DS, |
|
423 | + EE_LIBRARIES.'shortcodes'.DS, |
|
424 | + EE_LIBRARIES.'qtips'.DS, |
|
425 | + EE_LIBRARIES.'payment_methods'.DS, |
|
426 | 426 | ); |
427 | 427 | // retrieve instantiated class |
428 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only ); |
|
428 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | |
@@ -438,13 +438,13 @@ discard block |
||
438 | 438 | * @param bool $load_only |
439 | 439 | * @return EEM_Base | bool |
440 | 440 | */ |
441 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
442 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
441 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
442 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
443 | 443 | EE_MODELS, |
444 | 444 | EE_CORE |
445 | - ) ); |
|
445 | + )); |
|
446 | 446 | // retrieve instantiated class |
447 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
447 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -457,15 +457,15 @@ discard block |
||
457 | 457 | * @param bool $load_only |
458 | 458 | * @return mixed | bool |
459 | 459 | */ |
460 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
460 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
461 | 461 | $paths = array( |
462 | - EE_MODELS . 'fields' . DS, |
|
463 | - EE_MODELS . 'helpers' . DS, |
|
464 | - EE_MODELS . 'relations' . DS, |
|
465 | - EE_MODELS . 'strategies' . DS |
|
462 | + EE_MODELS.'fields'.DS, |
|
463 | + EE_MODELS.'helpers'.DS, |
|
464 | + EE_MODELS.'relations'.DS, |
|
465 | + EE_MODELS.'strategies'.DS |
|
466 | 466 | ); |
467 | 467 | // retrieve instantiated class |
468 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
468 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
@@ -475,8 +475,8 @@ discard block |
||
475 | 475 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
476 | 476 | * @return boolean |
477 | 477 | */ |
478 | - public function is_model_name( $model_name ) { |
|
479 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
478 | + public function is_model_name($model_name) { |
|
479 | + return isset($this->models[$model_name]) ? true : false; |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | |
@@ -491,9 +491,9 @@ discard block |
||
491 | 491 | * @param bool $load_only |
492 | 492 | * @return mixed |
493 | 493 | */ |
494 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
494 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
495 | 495 | // retrieve instantiated class |
496 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
496 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | |
@@ -508,9 +508,9 @@ discard block |
||
508 | 508 | * @param bool $load_only |
509 | 509 | * @return EE_Addon |
510 | 510 | */ |
511 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
511 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
512 | 512 | // retrieve instantiated class |
513 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
513 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | |
@@ -541,46 +541,46 @@ discard block |
||
541 | 541 | $load_only = false |
542 | 542 | ) { |
543 | 543 | // strip php file extension |
544 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
544 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
545 | 545 | // does the class have a prefix ? |
546 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
546 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
547 | 547 | // make sure $class_prefix is uppercase |
548 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
548 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
549 | 549 | // add class prefix ONCE!!! |
550 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
550 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
551 | 551 | } |
552 | - $class_exists = class_exists( $class_name ); |
|
552 | + $class_exists = class_exists($class_name); |
|
553 | 553 | // if we're only loading the class and it already exists, then let's just return true immediately |
554 | - if ( $load_only && $class_exists ) { |
|
554 | + if ($load_only && $class_exists) { |
|
555 | 555 | return true; |
556 | 556 | } |
557 | 557 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
558 | 558 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
559 | 559 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
560 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
560 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
561 | 561 | // return object if it's already cached |
562 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
563 | - if ( $cached_class !== null ) { |
|
562 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
563 | + if ($cached_class !== null) { |
|
564 | 564 | return $cached_class; |
565 | 565 | } |
566 | 566 | } |
567 | 567 | // if the class doesn't already exist.. then we need to try and find the file and load it |
568 | - if ( ! $class_exists ) { |
|
568 | + if ( ! $class_exists) { |
|
569 | 569 | // get full path to file |
570 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
570 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
571 | 571 | // load the file |
572 | - $loaded = $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
572 | + $loaded = $this->_require_file($path, $class_name, $type, $file_paths); |
|
573 | 573 | // if loading failed, or we are only loading a file but NOT instantiating an object |
574 | - if ( ! $loaded || $load_only ) { |
|
574 | + if ( ! $loaded || $load_only) { |
|
575 | 575 | // return boolean if only loading, or null if an object was expected |
576 | 576 | return $load_only ? $loaded : null; |
577 | 577 | } |
578 | 578 | } |
579 | 579 | // instantiate the requested object |
580 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db ); |
|
581 | - if ( $this->_cache_on && $cache ) { |
|
580 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db); |
|
581 | + if ($this->_cache_on && $cache) { |
|
582 | 582 | // save it for later... kinda like gum { : $ |
583 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db ); |
|
583 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db); |
|
584 | 584 | } |
585 | 585 | $this->_cache_on = true; |
586 | 586 | return $class_obj; |
@@ -603,21 +603,21 @@ discard block |
||
603 | 603 | * @param string $class_prefix |
604 | 604 | * @return null|object |
605 | 605 | */ |
606 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
607 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
608 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
606 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
607 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
608 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
609 | 609 | } else { |
610 | 610 | // have to specify something, but not anything that will conflict |
611 | 611 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
612 | 612 | } |
613 | 613 | // check if class has already been loaded, and return it if it has been |
614 | - if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) { |
|
614 | + if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) { |
|
615 | 615 | return $this->{$class_abbreviation}; |
616 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
616 | + } else if (isset ($this->{$class_name} )) { |
|
617 | 617 | return $this->{$class_name}; |
618 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
618 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
619 | 619 | return $this->LIB->{$class_name}; |
620 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
620 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
621 | 621 | return $this->addons->{$class_name}; |
622 | 622 | } |
623 | 623 | return null; |
@@ -638,20 +638,20 @@ discard block |
||
638 | 638 | * @param array $file_paths |
639 | 639 | * @return string | bool |
640 | 640 | */ |
641 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
641 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
642 | 642 | // make sure $file_paths is an array |
643 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
643 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
644 | 644 | // cycle thru paths |
645 | - foreach ( $file_paths as $key => $file_path ) { |
|
645 | + foreach ($file_paths as $key => $file_path) { |
|
646 | 646 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
647 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
647 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
648 | 648 | // prep file type |
649 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
649 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
650 | 650 | // build full file path |
651 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
651 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
652 | 652 | //does the file exist and can be read ? |
653 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
654 | - return $file_paths[ $key ]; |
|
653 | + if (is_readable($file_paths[$key])) { |
|
654 | + return $file_paths[$key]; |
|
655 | 655 | } |
656 | 656 | } |
657 | 657 | return false; |
@@ -673,29 +673,29 @@ discard block |
||
673 | 673 | * @return boolean |
674 | 674 | * @throws \EE_Error |
675 | 675 | */ |
676 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
676 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
677 | 677 | // don't give up! you gotta... |
678 | 678 | try { |
679 | 679 | //does the file exist and can it be read ? |
680 | - if ( ! $path ) { |
|
680 | + if ( ! $path) { |
|
681 | 681 | // so sorry, can't find the file |
682 | - throw new EE_Error ( |
|
682 | + throw new EE_Error( |
|
683 | 683 | sprintf( |
684 | - __( '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' ), |
|
685 | - trim( $type, '.' ), |
|
684 | + __('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'), |
|
685 | + trim($type, '.'), |
|
686 | 686 | $class_name, |
687 | - '<br />' . implode( ',<br />', $file_paths ) |
|
687 | + '<br />'.implode(',<br />', $file_paths) |
|
688 | 688 | ) |
689 | 689 | ); |
690 | 690 | } |
691 | 691 | // get the file |
692 | - require_once( $path ); |
|
692 | + require_once($path); |
|
693 | 693 | // if the class isn't already declared somewhere |
694 | - if ( class_exists( $class_name, false ) === false ) { |
|
694 | + if (class_exists($class_name, false) === false) { |
|
695 | 695 | // so sorry, not a class |
696 | 696 | throw new EE_Error( |
697 | 697 | sprintf( |
698 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
698 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
699 | 699 | $type, |
700 | 700 | $path, |
701 | 701 | $class_name |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | ); |
704 | 704 | } |
705 | 705 | |
706 | - } catch ( EE_Error $e ) { |
|
706 | + } catch (EE_Error $e) { |
|
707 | 707 | $e->get_error(); |
708 | 708 | return false; |
709 | 709 | } |
@@ -735,55 +735,55 @@ discard block |
||
735 | 735 | * @return null | object |
736 | 736 | * @throws \EE_Error |
737 | 737 | */ |
738 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) { |
|
738 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) { |
|
739 | 739 | $class_obj = null; |
740 | 740 | // don't give up! you gotta... |
741 | 741 | try { |
742 | 742 | // create reflection |
743 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
743 | + $reflector = $this->get_ReflectionClass($class_name); |
|
744 | 744 | // make sure arguments are an array |
745 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
745 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
746 | 746 | // and if arguments array is numerically and sequentially indexed, then we want it to remain as is, |
747 | 747 | // else wrap it in an additional array so that it doesn't get split into multiple parameters |
748 | - $arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments ) |
|
748 | + $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments) |
|
749 | 749 | ? $arguments |
750 | - : array( $arguments ); |
|
750 | + : array($arguments); |
|
751 | 751 | // attempt to inject dependencies ? |
752 | - if ( $this->_dependency_map->has( $class_name ) ) { |
|
753 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
752 | + if ($this->_dependency_map->has($class_name)) { |
|
753 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
754 | 754 | } |
755 | 755 | // instantiate the class and add to the LIB array for tracking |
756 | 756 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
757 | - if ( $reflector->getConstructor() === null || $reflector->isAbstract() ) { |
|
757 | + if ($reflector->getConstructor() === null || $reflector->isAbstract()) { |
|
758 | 758 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
759 | 759 | //$instantiation_mode = "no constructor"; |
760 | 760 | $class_obj = true; |
761 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
761 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
762 | 762 | //$instantiation_mode = "new_instance_from_db"; |
763 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
764 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
763 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
764 | + } else if (method_exists($class_name, 'new_instance')) { |
|
765 | 765 | //$instantiation_mode = "new_instance"; |
766 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
767 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
766 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
767 | + } else if (method_exists($class_name, 'instance')) { |
|
768 | 768 | //$instantiation_mode = "instance"; |
769 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
770 | - } else if ( $reflector->isInstantiable() ) { |
|
769 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
770 | + } else if ($reflector->isInstantiable()) { |
|
771 | 771 | //$instantiation_mode = "isInstantiable"; |
772 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
772 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
773 | 773 | } else { |
774 | 774 | // heh ? something's not right ! |
775 | 775 | //$instantiation_mode = 'none'; |
776 | 776 | throw new EE_Error( |
777 | 777 | sprintf( |
778 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
778 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
779 | 779 | $type, |
780 | 780 | $class_name |
781 | 781 | ) |
782 | 782 | ); |
783 | 783 | } |
784 | - } catch ( Exception $e ) { |
|
785 | - if ( ! $e instanceof EE_Error ) { |
|
786 | - $e = new EE_Error( $e->getMessage() ); |
|
784 | + } catch (Exception $e) { |
|
785 | + if ( ! $e instanceof EE_Error) { |
|
786 | + $e = new EE_Error($e->getMessage()); |
|
787 | 787 | } |
788 | 788 | $e->get_error(); |
789 | 789 | } |
@@ -797,8 +797,8 @@ discard block |
||
797 | 797 | * @param array $array |
798 | 798 | * @return bool |
799 | 799 | */ |
800 | - protected function _array_is_numerically_and_sequentially_indexed( array $array ) { |
|
801 | - return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true; |
|
800 | + protected function _array_is_numerically_and_sequentially_indexed(array $array) { |
|
801 | + return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | |
@@ -813,14 +813,14 @@ discard block |
||
813 | 813 | * @param string $class_name |
814 | 814 | * @return ReflectionClass |
815 | 815 | */ |
816 | - public function get_ReflectionClass( $class_name ) { |
|
816 | + public function get_ReflectionClass($class_name) { |
|
817 | 817 | if ( |
818 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
819 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
818 | + ! isset($this->_reflectors[$class_name]) |
|
819 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
820 | 820 | ) { |
821 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
821 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
822 | 822 | } |
823 | - return $this->_reflectors[ $class_name ]; |
|
823 | + return $this->_reflectors[$class_name]; |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | |
@@ -845,45 +845,45 @@ discard block |
||
845 | 845 | * @param array $arguments |
846 | 846 | * @return array |
847 | 847 | */ |
848 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
848 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
849 | 849 | // let's examine the constructor |
850 | 850 | $constructor = $reflector->getConstructor(); |
851 | 851 | // whu? huh? nothing? |
852 | - if ( ! $constructor ) { |
|
852 | + if ( ! $constructor) { |
|
853 | 853 | return $arguments; |
854 | 854 | } |
855 | 855 | // get constructor parameters |
856 | 856 | $params = $constructor->getParameters(); |
857 | 857 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
858 | - $argument_keys = array_keys( $arguments ); |
|
858 | + $argument_keys = array_keys($arguments); |
|
859 | 859 | // now loop thru all of the constructors expected parameters |
860 | - foreach ( $params as $index => $param ) { |
|
860 | + foreach ($params as $index => $param) { |
|
861 | 861 | // is this a dependency for a specific class ? |
862 | 862 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
863 | 863 | if ( |
864 | 864 | // param is not even a class |
865 | - empty( $param_class ) |
|
865 | + empty($param_class) |
|
866 | 866 | // and something already exists in the incoming arguments for this param |
867 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
867 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
868 | 868 | ) { |
869 | 869 | // so let's skip this argument and move on to the next |
870 | 870 | continue; |
871 | 871 | } else if ( |
872 | 872 | // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class |
873 | - ! empty( $param_class ) |
|
874 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
875 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
873 | + ! empty($param_class) |
|
874 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
875 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
876 | 876 | ) { |
877 | 877 | // skip this argument and move on to the next |
878 | 878 | continue; |
879 | 879 | } else if ( |
880 | 880 | // parameter is type hinted as a class, and should be injected |
881 | - ! empty( $param_class ) |
|
882 | - && $this->_dependency_map->has_dependency_for_class( $class_name, $param_class ) |
|
881 | + ! empty($param_class) |
|
882 | + && $this->_dependency_map->has_dependency_for_class($class_name, $param_class) |
|
883 | 883 | ) { |
884 | - $arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index ); |
|
884 | + $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index); |
|
885 | 885 | } else { |
886 | - $arguments[ $index ] = $param->getDefaultValue(); |
|
886 | + $arguments[$index] = $param->getDefaultValue(); |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | } |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | * @param mixed $index |
901 | 901 | * @return array |
902 | 902 | */ |
903 | - protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) { |
|
903 | + protected function _resolve_dependency($class_name, $param_class, $arguments, $index) { |
|
904 | 904 | $dependency = null; |
905 | 905 | // should dependency be loaded from cache ? |
906 | 906 | $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency( |
@@ -910,30 +910,30 @@ discard block |
||
910 | 910 | : false; |
911 | 911 | // we might have a dependency... |
912 | 912 | // let's MAYBE try and find it in our cache if that's what's been requested |
913 | - $cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null; |
|
913 | + $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null; |
|
914 | 914 | // and grab it if it exists |
915 | - if ( $cached_class instanceof $param_class ) { |
|
915 | + if ($cached_class instanceof $param_class) { |
|
916 | 916 | $dependency = $cached_class; |
917 | - } else if ( $param_class != $class_name ) { |
|
917 | + } else if ($param_class != $class_name) { |
|
918 | 918 | // obtain the loader method from the dependency map |
919 | - $loader = $this->_dependency_map->class_loader( $param_class ); |
|
919 | + $loader = $this->_dependency_map->class_loader($param_class); |
|
920 | 920 | // is loader a custom closure ? |
921 | - if ( $loader instanceof Closure ) { |
|
921 | + if ($loader instanceof Closure) { |
|
922 | 922 | $dependency = $loader(); |
923 | 923 | } else { |
924 | 924 | // set the cache on property for the recursive loading call |
925 | 925 | $this->_cache_on = $cache_on; |
926 | 926 | // if not, then let's try and load it via the registry |
927 | - $dependency = $this->{$loader}( $param_class ); |
|
927 | + $dependency = $this->{$loader}($param_class); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | // did we successfully find the correct dependency ? |
931 | - if ( $dependency instanceof $param_class ) { |
|
931 | + if ($dependency instanceof $param_class) { |
|
932 | 932 | // then let's inject it into the incoming array of arguments at the correct location |
933 | - if ( isset( $argument_keys[ $index ] ) ) { |
|
934 | - $arguments[ $argument_keys[ $index ] ] = $dependency; |
|
933 | + if (isset($argument_keys[$index])) { |
|
934 | + $arguments[$argument_keys[$index]] = $dependency; |
|
935 | 935 | } else { |
936 | - $arguments[ $index ] = $dependency; |
|
936 | + $arguments[$index] = $dependency; |
|
937 | 937 | } |
938 | 938 | } |
939 | 939 | return $arguments; |
@@ -958,16 +958,16 @@ discard block |
||
958 | 958 | * @param bool $from_db |
959 | 959 | * @return void |
960 | 960 | */ |
961 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) { |
|
961 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) { |
|
962 | 962 | // return newly instantiated class |
963 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
964 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
963 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
964 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
965 | 965 | $this->{$class_abbreviation} = $class_obj; |
966 | - } else if ( property_exists( $this, $class_name ) ) { |
|
966 | + } else if (property_exists($this, $class_name)) { |
|
967 | 967 | $this->{$class_name} = $class_obj; |
968 | - } else if ( $class_prefix == 'addon' ) { |
|
968 | + } else if ($class_prefix == 'addon') { |
|
969 | 969 | $this->addons->{$class_name} = $class_obj; |
970 | - } else if ( ! $from_db ) { |
|
970 | + } else if ( ! $from_db) { |
|
971 | 971 | $this->LIB->{$class_name} = $class_obj; |
972 | 972 | } |
973 | 973 | } |
@@ -984,12 +984,12 @@ discard block |
||
984 | 984 | * @param array $arguments |
985 | 985 | * @return object |
986 | 986 | */ |
987 | - public static function factory( $classname, $arguments = array() ) { |
|
988 | - $loader = self::instance()->_dependency_map->class_loader( $classname ); |
|
989 | - if ( $loader instanceof Closure ) { |
|
990 | - return $loader( $arguments ); |
|
991 | - } else if ( method_exists( EE_Registry::instance(), $loader ) ) { |
|
992 | - return EE_Registry::instance()->{$loader}( $classname, $arguments ); |
|
987 | + public static function factory($classname, $arguments = array()) { |
|
988 | + $loader = self::instance()->_dependency_map->class_loader($classname); |
|
989 | + if ($loader instanceof Closure) { |
|
990 | + return $loader($arguments); |
|
991 | + } else if (method_exists(EE_Registry::instance(), $loader)) { |
|
992 | + return EE_Registry::instance()->{$loader}($classname, $arguments); |
|
993 | 993 | } |
994 | 994 | return null; |
995 | 995 | } |
@@ -1002,9 +1002,9 @@ discard block |
||
1002 | 1002 | * @param string $name |
1003 | 1003 | * @return EE_Addon |
1004 | 1004 | */ |
1005 | - public function get_addon_by_name( $name ) { |
|
1006 | - foreach ( $this->addons as $addon ) { |
|
1007 | - if ( $addon->name() == $name ) { |
|
1005 | + public function get_addon_by_name($name) { |
|
1006 | + foreach ($this->addons as $addon) { |
|
1007 | + if ($addon->name() == $name) { |
|
1008 | 1008 | return $addon; |
1009 | 1009 | } |
1010 | 1010 | } |
@@ -1020,8 +1020,8 @@ discard block |
||
1020 | 1020 | */ |
1021 | 1021 | public function get_addons_by_name() { |
1022 | 1022 | $addons = array(); |
1023 | - foreach ( $this->addons as $addon ) { |
|
1024 | - $addons[ $addon->name() ] = $addon; |
|
1023 | + foreach ($this->addons as $addon) { |
|
1024 | + $addons[$addon->name()] = $addon; |
|
1025 | 1025 | } |
1026 | 1026 | return $addons; |
1027 | 1027 | } |
@@ -1036,14 +1036,14 @@ discard block |
||
1036 | 1036 | * @return \EEM_Base |
1037 | 1037 | * @throws \EE_Error |
1038 | 1038 | */ |
1039 | - public function reset_model( $model_name ) { |
|
1040 | - $model = $this->load_model( $model_name ); |
|
1041 | - $model_class_name = get_class( $model ); |
|
1039 | + public function reset_model($model_name) { |
|
1040 | + $model = $this->load_model($model_name); |
|
1041 | + $model_class_name = get_class($model); |
|
1042 | 1042 | //get that model reset it and make sure we nuke the old reference to it |
1043 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
1043 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
1044 | 1044 | $this->LIB->{$model_class_name} = $model::reset(); |
1045 | 1045 | } else { |
1046 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
1046 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
1047 | 1047 | } |
1048 | 1048 | return $this->LIB->{$model_class_name}; |
1049 | 1049 | } |
@@ -1064,16 +1064,16 @@ discard block |
||
1064 | 1064 | * code instead can just change the model context to a different blog id if necessary |
1065 | 1065 | * @return EE_Registry |
1066 | 1066 | */ |
1067 | - public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) { |
|
1067 | + public static function reset($hard = false, $reinstantiate = true, $reset_models = true) { |
|
1068 | 1068 | $instance = self::instance(); |
1069 | 1069 | EEH_Activation::reset(); |
1070 | 1070 | $instance->_cache_on = true; |
1071 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
1071 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
1072 | 1072 | $instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset(); |
1073 | 1073 | $instance->LIB = new stdClass(); |
1074 | - if ( $reset_models ) { |
|
1075 | - foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) { |
|
1076 | - $instance->reset_model( $model_name ); |
|
1074 | + if ($reset_models) { |
|
1075 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
1076 | + $instance->reset_model($model_name); |
|
1077 | 1077 | } |
1078 | 1078 | } |
1079 | 1079 | return $instance; |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | * @param $a |
1095 | 1095 | * @param $b |
1096 | 1096 | */ |
1097 | - final function __call( $a, $b ) { |
|
1097 | + final function __call($a, $b) { |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | 1100 | |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | /** |
1103 | 1103 | * @param $a |
1104 | 1104 | */ |
1105 | - final function __get( $a ) { |
|
1105 | + final function __get($a) { |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | * @param $a |
1112 | 1112 | * @param $b |
1113 | 1113 | */ |
1114 | - final function __set( $a, $b ) { |
|
1114 | + final function __set($a, $b) { |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | /** |
1120 | 1120 | * @param $a |
1121 | 1121 | */ |
1122 | - final function __isset( $a ) { |
|
1122 | + final function __isset($a) { |
|
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | /** |
1128 | 1128 | * @param $a |
1129 | 1129 | */ |
1130 | - final function __unset( $a ) { |
|
1130 | + final function __unset($a) { |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | * @param $a |
1175 | 1175 | * @param $b |
1176 | 1176 | */ |
1177 | - final static function __callStatic( $a, $b ) { |
|
1177 | + final static function __callStatic($a, $b) { |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | /** |
@@ -1183,9 +1183,9 @@ discard block |
||
1183 | 1183 | */ |
1184 | 1184 | public function cpt_models() { |
1185 | 1185 | $cpt_models = array(); |
1186 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
1187 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
1188 | - $cpt_models[ $short_name ] = $classname; |
|
1186 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
1187 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
1188 | + $cpt_models[$short_name] = $classname; |
|
1189 | 1189 | } |
1190 | 1190 | } |
1191 | 1191 | return $cpt_models; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * remove param |
352 | 352 | * |
353 | 353 | * @access public |
354 | - * @param $key |
|
354 | + * @param string $key |
|
355 | 355 | * @return void |
356 | 356 | */ |
357 | 357 | public function un_set( $key ) { |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * add_output |
392 | 392 | * |
393 | 393 | * @access public |
394 | - * @param $string |
|
394 | + * @param string $string |
|
395 | 395 | * @return void |
396 | 396 | */ |
397 | 397 | public function add_output( $string ) { |
@@ -456,14 +456,14 @@ discard block |
||
456 | 456 | |
457 | 457 | |
458 | 458 | /** |
459 | - * @return bool |
|
459 | + * @return boolean|null |
|
460 | 460 | */ |
461 | 461 | public function __clone() {} |
462 | 462 | |
463 | 463 | |
464 | 464 | |
465 | 465 | /** |
466 | - * @return bool |
|
466 | + * @return boolean|null |
|
467 | 467 | */ |
468 | 468 | public function __wakeup() {} |
469 | 469 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * class EE_Request_Handler |
4 | 4 | * |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | * @param EE_Request $request |
51 | 51 | * @return \EE_Request_Handler |
52 | 52 | */ |
53 | - public function __construct( EE_Request $request ) { |
|
53 | + public function __construct(EE_Request $request) { |
|
54 | 54 | // grab request vars |
55 | 55 | $this->_params = $request->params(); |
56 | 56 | // AJAX ??? |
57 | - $this->ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false; |
|
58 | - $this->front_ajax = defined( 'EE_FRONT_AJAX' ) && EE_FRONT_AJAX ? true : false; |
|
59 | - do_action( 'AHEE__EE_Request_Handler__construct__complete' ); |
|
57 | + $this->ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false; |
|
58 | + $this->front_ajax = defined('EE_FRONT_AJAX') && EE_FRONT_AJAX ? true : false; |
|
59 | + do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * @param WP $wp |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - public function parse_request( $wp = null ) { |
|
71 | + public function parse_request($wp = null) { |
|
72 | 72 | //if somebody forgot to provide us with WP, that's ok because its global |
73 | - if ( ! $wp instanceof WP ) { |
|
73 | + if ( ! $wp instanceof WP) { |
|
74 | 74 | global $wp; |
75 | 75 | } |
76 | - $this->set_request_vars( $wp ); |
|
76 | + $this->set_request_vars($wp); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -85,14 +85,14 @@ discard block |
||
85 | 85 | * @param WP $wp |
86 | 86 | * @return void |
87 | 87 | */ |
88 | - public function set_request_vars( $wp = null ) { |
|
89 | - if ( ! is_admin() ) { |
|
88 | + public function set_request_vars($wp = null) { |
|
89 | + if ( ! is_admin()) { |
|
90 | 90 | // set request post_id |
91 | - $this->set( 'post_id', $this->get_post_id_from_request( $wp )); |
|
91 | + $this->set('post_id', $this->get_post_id_from_request($wp)); |
|
92 | 92 | // set request post name |
93 | - $this->set( 'post_name', $this->get_post_name_from_request( $wp )); |
|
93 | + $this->set('post_name', $this->get_post_name_from_request($wp)); |
|
94 | 94 | // set request post_type |
95 | - $this->set( 'post_type', $this->get_post_type_from_request( $wp )); |
|
95 | + $this->set('post_type', $this->get_post_type_from_request($wp)); |
|
96 | 96 | // true or false ? is this page being used by EE ? |
97 | 97 | $this->set_espresso_page(); |
98 | 98 | } |
@@ -107,19 +107,19 @@ discard block |
||
107 | 107 | * @param WP $wp |
108 | 108 | * @return int |
109 | 109 | */ |
110 | - public function get_post_id_from_request( $wp = null ) { |
|
111 | - if ( ! $wp instanceof WP ){ |
|
110 | + public function get_post_id_from_request($wp = null) { |
|
111 | + if ( ! $wp instanceof WP) { |
|
112 | 112 | global $wp; |
113 | 113 | } |
114 | 114 | $post_id = null; |
115 | - if ( isset( $wp->query_vars['p'] )) { |
|
115 | + if (isset($wp->query_vars['p'])) { |
|
116 | 116 | $post_id = $wp->query_vars['p']; |
117 | 117 | } |
118 | - if ( ! $post_id && isset( $wp->query_vars['page_id'] )) { |
|
118 | + if ( ! $post_id && isset($wp->query_vars['page_id'])) { |
|
119 | 119 | $post_id = $wp->query_vars['page_id']; |
120 | 120 | } |
121 | - if ( ! $post_id && isset( $wp->request ) && is_numeric( basename( $wp->request ))) { |
|
122 | - $post_id = basename( $wp->request ); |
|
121 | + if ( ! $post_id && isset($wp->request) && is_numeric(basename($wp->request))) { |
|
122 | + $post_id = basename($wp->request); |
|
123 | 123 | } |
124 | 124 | return $post_id; |
125 | 125 | } |
@@ -133,35 +133,35 @@ discard block |
||
133 | 133 | * @param WP $wp |
134 | 134 | * @return string |
135 | 135 | */ |
136 | - public function get_post_name_from_request( $wp = null ) { |
|
137 | - if ( ! $wp instanceof WP ){ |
|
136 | + public function get_post_name_from_request($wp = null) { |
|
137 | + if ( ! $wp instanceof WP) { |
|
138 | 138 | global $wp; |
139 | 139 | } |
140 | 140 | $post_name = null; |
141 | - if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) { |
|
141 | + if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
142 | 142 | $post_name = $wp->query_vars['name']; |
143 | 143 | } |
144 | - if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) { |
|
144 | + if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
145 | 145 | $post_name = $wp->query_vars['pagename']; |
146 | 146 | } |
147 | - if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) { |
|
148 | - $possible_post_name = basename( $wp->request ); |
|
149 | - if ( ! is_numeric( $possible_post_name )) { |
|
147 | + if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) { |
|
148 | + $possible_post_name = basename($wp->request); |
|
149 | + if ( ! is_numeric($possible_post_name)) { |
|
150 | 150 | /** @type WPDB $wpdb */ |
151 | 151 | global $wpdb; |
152 | 152 | $SQL = "SELECT ID from $wpdb->posts WHERE post_status='publish' AND post_name=%s"; |
153 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name )); |
|
154 | - if ( $possible_post_name ) { |
|
153 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
154 | + if ($possible_post_name) { |
|
155 | 155 | $post_name = $possible_post_name; |
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
159 | - if ( ! $post_name && $this->get( 'post_id' )) { |
|
159 | + if ( ! $post_name && $this->get('post_id')) { |
|
160 | 160 | /** @type WPDB $wpdb */ |
161 | 161 | global $wpdb; |
162 | 162 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_status='publish' AND ID=%d"; |
163 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' ))); |
|
164 | - if( $possible_post_name ) { |
|
163 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
164 | + if ($possible_post_name) { |
|
165 | 165 | $post_name = $possible_post_name; |
166 | 166 | } |
167 | 167 | } |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | * @param WP $wp |
178 | 178 | * @return mixed |
179 | 179 | */ |
180 | - public function get_post_type_from_request( $wp = null ) { |
|
181 | - if ( ! $wp instanceof WP ){ |
|
180 | + public function get_post_type_from_request($wp = null) { |
|
181 | + if ( ! $wp instanceof WP) { |
|
182 | 182 | global $wp; |
183 | 183 | } |
184 | - return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null; |
|
184 | + return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -191,18 +191,18 @@ discard block |
||
191 | 191 | * @param WP $wp |
192 | 192 | * @return bool|string|void |
193 | 193 | */ |
194 | - public function get_current_page_permalink( $wp = null ) { |
|
195 | - $post_id = $this->get_post_id_from_request( $wp ); |
|
196 | - if ( $post_id ) { |
|
197 | - $current_page_permalink = get_permalink( $post_id ); |
|
194 | + public function get_current_page_permalink($wp = null) { |
|
195 | + $post_id = $this->get_post_id_from_request($wp); |
|
196 | + if ($post_id) { |
|
197 | + $current_page_permalink = get_permalink($post_id); |
|
198 | 198 | } else { |
199 | - if ( ! $wp instanceof WP ) { |
|
199 | + if ( ! $wp instanceof WP) { |
|
200 | 200 | global $wp; |
201 | 201 | } |
202 | - if ( $wp->request ) { |
|
203 | - $current_page_permalink = site_url( $wp->request ); |
|
202 | + if ($wp->request) { |
|
203 | + $current_page_permalink = site_url($wp->request); |
|
204 | 204 | } else { |
205 | - $current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) ); |
|
205 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | return $current_page_permalink; |
@@ -219,41 +219,41 @@ discard block |
||
219 | 219 | public function test_for_espresso_page() { |
220 | 220 | global $wp; |
221 | 221 | /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
222 | - $EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
222 | + $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
223 | 223 | $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
224 | - if ( is_array( $espresso_CPT_taxonomies ) ) { |
|
225 | - foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) { |
|
226 | - if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) { |
|
224 | + if (is_array($espresso_CPT_taxonomies)) { |
|
225 | + foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) { |
|
226 | + if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { |
|
227 | 227 | return true; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | } |
231 | 231 | // load espresso CPT endpoints |
232 | 232 | $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
233 | - $post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints ); |
|
234 | - $post_types = (array)$this->get( 'post_type' ); |
|
235 | - foreach ( $post_types as $post_type ) { |
|
233 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
234 | + $post_types = (array) $this->get('post_type'); |
|
235 | + foreach ($post_types as $post_type) { |
|
236 | 236 | // was a post name passed ? |
237 | - if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) { |
|
237 | + if (isset($post_type_CPT_endpoints[$post_type])) { |
|
238 | 238 | // kk we know this is an espresso page, but is it a specific post ? |
239 | - if ( ! $this->get( 'post_name' ) ) { |
|
239 | + if ( ! $this->get('post_name')) { |
|
240 | 240 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
241 | - $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] : null; |
|
241 | + $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) ? $post_type_CPT_endpoints[$this->get('post_type')] : null; |
|
242 | 242 | // if the post type matches on of our then set the endpoint |
243 | - if ( $post_name ) { |
|
244 | - $this->set( 'post_name', $post_name ); |
|
243 | + if ($post_name) { |
|
244 | + $this->set('post_name', $post_name); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | return true; |
248 | 248 | } |
249 | 249 | } |
250 | - if ( $this->get( 'post_name' )) { |
|
250 | + if ($this->get('post_name')) { |
|
251 | 251 | // load all pages using espresso shortcodes |
252 | - $post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
252 | + $post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
253 | 253 | // make sure core pages are included |
254 | - $espresso_pages = array_merge( $espresso_CPT_endpoints, $post_shortcodes ); |
|
254 | + $espresso_pages = array_merge($espresso_CPT_endpoints, $post_shortcodes); |
|
255 | 255 | // was a post name passed ? |
256 | - if ( isset( $espresso_pages[ $this->get( 'post_name' ) ] )) { |
|
256 | + if (isset($espresso_pages[$this->get('post_name')])) { |
|
257 | 257 | return true; |
258 | 258 | } |
259 | 259 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param null|bool $value |
270 | 270 | * @return mixed |
271 | 271 | */ |
272 | - public function set_espresso_page( $value = null ) { |
|
272 | + public function set_espresso_page($value = null) { |
|
273 | 273 | $value = $value ? $value : $this->test_for_espresso_page(); |
274 | 274 | $this->_params['is_espresso_page'] = $value; |
275 | 275 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @return mixed |
284 | 284 | */ |
285 | 285 | public function is_espresso_page() { |
286 | - return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false; |
|
286 | + return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
@@ -307,14 +307,14 @@ discard block |
||
307 | 307 | * @param bool $override_ee |
308 | 308 | * @return void |
309 | 309 | */ |
310 | - public function set( $key, $value, $override_ee = false ) { |
|
310 | + public function set($key, $value, $override_ee = false) { |
|
311 | 311 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
312 | 312 | if ( |
313 | 313 | $key !== 'ee' || |
314 | - ( $key === 'ee' && empty( $this->_params['ee'] )) |
|
315 | - || ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee ) |
|
314 | + ($key === 'ee' && empty($this->_params['ee'])) |
|
315 | + || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee) |
|
316 | 316 | ) { |
317 | - $this->_params[ $key ] = $value; |
|
317 | + $this->_params[$key] = $value; |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
@@ -328,8 +328,8 @@ discard block |
||
328 | 328 | * @param null $default |
329 | 329 | * @return mixed |
330 | 330 | */ |
331 | - public function get( $key, $default = null ) { |
|
332 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
331 | + public function get($key, $default = null) { |
|
332 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | * @param $key |
342 | 342 | * @return boolean |
343 | 343 | */ |
344 | - public function is_set( $key ) { |
|
345 | - return isset( $this->_params[ $key ] ) ? true : false; |
|
344 | + public function is_set($key) { |
|
345 | + return isset($this->_params[$key]) ? true : false; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @param $key |
355 | 355 | * @return void |
356 | 356 | */ |
357 | - public function un_set( $key ) { |
|
358 | - unset( $this->_params[ $key ] ); |
|
357 | + public function un_set($key) { |
|
358 | + unset($this->_params[$key]); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | * @param $value |
369 | 369 | * @return void |
370 | 370 | */ |
371 | - public function set_notice( $key, $value ) { |
|
372 | - $this->_notice[ $key ] = $value; |
|
371 | + public function set_notice($key, $value) { |
|
372 | + $this->_notice[$key] = $value; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | * @param $key |
382 | 382 | * @return mixed |
383 | 383 | */ |
384 | - public function get_notice( $key ) { |
|
385 | - return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null; |
|
384 | + public function get_notice($key) { |
|
385 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | * @param $string |
395 | 395 | * @return void |
396 | 396 | */ |
397 | - public function add_output( $string ) { |
|
397 | + public function add_output($string) { |
|
398 | 398 | $this->_output .= $string; |
399 | 399 | } |
400 | 400 | |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * @param $item |
417 | 417 | * @param $key |
418 | 418 | */ |
419 | - public function sanitize_text_field_for_array_walk( &$item, &$key ) { |
|
420 | - $item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item ); |
|
419 | + public function sanitize_text_field_for_array_walk(&$item, &$key) { |
|
420 | + $item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * @param $b |
428 | 428 | * @return bool |
429 | 429 | */ |
430 | - public function __set($a,$b) { return false; } |
|
430 | + public function __set($a, $b) { return false; } |
|
431 | 431 | |
432 | 432 | |
433 | 433 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | class Custom_Messages_Template_List_Table extends EE_Admin_List_Table { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $admin_page ) { |
|
33 | + public function __construct($admin_page) { |
|
34 | 34 | //Set parent defaults |
35 | 35 | parent::__construct($admin_page); |
36 | 36 | } |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | protected function _setup_data() { |
52 | - $this->_data = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, FALSE, FALSE, FALSE ); |
|
53 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, TRUE, TRUE, FALSE ); |
|
52 | + $this->_data = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, FALSE, FALSE, FALSE); |
|
53 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, TRUE, TRUE, FALSE); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | |
60 | 60 | protected function _set_properties() { |
61 | 61 | $this->_wp_list_args = array( |
62 | - 'singular' => __('Message Template Group', 'event_espresso' ), |
|
63 | - 'plural' => __('Message Template', 'event_espresso' ), |
|
62 | + 'singular' => __('Message Template Group', 'event_espresso'), |
|
63 | + 'plural' => __('Message Template', 'event_espresso'), |
|
64 | 64 | 'ajax' => TRUE, //for now, |
65 | 65 | 'screen' => $this->get_admin_page()->get_current_screen()->id |
66 | 66 | ); |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | 'cb' => '<input type="checkbox" />', |
70 | 70 | 'name' => __('Template Name', 'event_espresso'), |
71 | 71 | 'message_type' => __('Message Type', 'event_espresso'), |
72 | - 'messenger' => __( 'Messenger', 'event_espresso'), |
|
73 | - 'description' => __( 'Description', 'event_espresso' ), |
|
74 | - 'events' => __( 'Events', 'event_espresso'), //count of events using this template. |
|
72 | + 'messenger' => __('Messenger', 'event_espresso'), |
|
73 | + 'description' => __('Description', 'event_espresso'), |
|
74 | + 'events' => __('Events', 'event_espresso'), //count of events using this template. |
|
75 | 75 | 'actions' => '' |
76 | 76 | //'messages_sent' => __( 'Total Sent', 'event_espresso' ) //todo this will come later when we've got message tracking in place. |
77 | 77 | ); |
78 | 78 | |
79 | 79 | $this->_sortable_columns = array( |
80 | - 'messenger' => array( 'MTP_messenger' => TRUE ), |
|
80 | + 'messenger' => array('MTP_messenger' => TRUE), |
|
81 | 81 | //'message_type' => array( 'MTP_message_type' => FALSE ) |
82 | 82 | ); |
83 | 83 | |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return string |
98 | 98 | */ |
99 | - public function single_row( $item ) { |
|
99 | + public function single_row($item) { |
|
100 | 100 | $message_type = $item->message_type_obj(); |
101 | 101 | $messenger = $item->messenger_obj(); |
102 | 102 | |
103 | - if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger ) { |
|
103 | + if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
104 | 104 | echo ''; |
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | - parent::single_row( $item ); |
|
108 | + parent::single_row($item); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $mt_values = $this->get_admin_page()->get_message_types_for_list_table(); |
122 | 122 | //setup messengers for selects |
123 | 123 | $m_values[0]['id'] = 'all'; |
124 | - $m_values[0]['text'] = __('All Messengers', 'event_espresso' ); |
|
124 | + $m_values[0]['text'] = __('All Messengers', 'event_espresso'); |
|
125 | 125 | |
126 | 126 | $msgr_default[0] = array( |
127 | 127 | 'id' => 'none_selected', |
@@ -133,28 +133,28 @@ discard block |
||
133 | 133 | 'text' => __('Show All', 'event_espresso') |
134 | 134 | ); |
135 | 135 | |
136 | - $msgr_filters = !empty($m_values) ? array_merge( $msgr_default, $m_values ) : array(); |
|
137 | - $mt_filters = !empty($mt_values) ? array_merge( $mt_default, $mt_values ) : array(); |
|
136 | + $msgr_filters = ! empty($m_values) ? array_merge($msgr_default, $m_values) : array(); |
|
137 | + $mt_filters = ! empty($mt_values) ? array_merge($mt_default, $mt_values) : array(); |
|
138 | 138 | |
139 | - if ( empty( $m_values ) ) |
|
139 | + if (empty($m_values)) |
|
140 | 140 | $msgr_filters[0] = array( |
141 | 141 | 'id' => 'no_messenger_options', |
142 | 142 | 'text' => __('No Messengers active', 'event_espresso') |
143 | 143 | ); |
144 | 144 | |
145 | - if ( empty($mt_values) ) |
|
145 | + if (empty($mt_values)) |
|
146 | 146 | $mt_filters[0] = array( |
147 | 147 | 'id' => 'no_message_type_options', |
148 | 148 | 'text' => __('No Message Types active', 'event_espresso') |
149 | 149 | ); |
150 | 150 | |
151 | - if ( count( $m_values ) >= 1 && !empty( $m_values ) ) { |
|
152 | - unset( $msgr_filters[0] ); |
|
153 | - $msgr_filters = array_values( $msgr_filters ); //reindex keys |
|
151 | + if (count($m_values) >= 1 && ! empty($m_values)) { |
|
152 | + unset($msgr_filters[0]); |
|
153 | + $msgr_filters = array_values($msgr_filters); //reindex keys |
|
154 | 154 | } |
155 | 155 | |
156 | - $filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_key( $this->_req_data['ee_messenger_filter_by']) : '' ); |
|
157 | - $filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_key( $this->_req_data['ee_message_type_filter_by']) : ''); |
|
156 | + $filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_key($this->_req_data['ee_messenger_filter_by']) : ''); |
|
157 | + $filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_key($this->_req_data['ee_message_type_filter_by']) : ''); |
|
158 | 158 | return $filters; |
159 | 159 | } |
160 | 160 | |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | * we're just removing the search box for message templates, not needed. |
163 | 163 | * @return string (empty); |
164 | 164 | */ |
165 | - function search_box( $text, $input_id ) { |
|
165 | + function search_box($text, $input_id) { |
|
166 | 166 | return ''; |
167 | 167 | } |
168 | 168 | |
169 | 169 | |
170 | 170 | protected function _add_view_counts() { |
171 | - foreach ( $this->_views as $view => $args ) { |
|
172 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( $this->_per_page, $view, TRUE, TRUE, FALSE ); |
|
171 | + foreach ($this->_views as $view => $args) { |
|
172 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates($this->_per_page, $view, TRUE, TRUE, FALSE); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | * @return string |
184 | 184 | */ |
185 | 185 | public function no_items() { |
186 | - if ( $this->_view !== 'trashed' ) |
|
187 | - printf( __('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>' ); |
|
186 | + if ($this->_view !== 'trashed') |
|
187 | + printf(__('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>'); |
|
188 | 188 | else |
189 | 189 | parent::no_items(); |
190 | 190 | } |
191 | 191 | |
192 | 192 | |
193 | 193 | |
194 | - public function column_cb( $item ) { |
|
195 | - return sprintf( '<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID() ); |
|
194 | + public function column_cb($item) { |
|
195 | + return sprintf('<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID()); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -200,29 +200,29 @@ discard block |
||
200 | 200 | |
201 | 201 | |
202 | 202 | |
203 | - function column_name( $item ) { |
|
204 | - return '<p>' . $item->name() . '</p>'; |
|
203 | + function column_name($item) { |
|
204 | + return '<p>'.$item->name().'</p>'; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
208 | 208 | |
209 | 209 | |
210 | - function column_description( $item ) { |
|
211 | - return '<p>' . $item->description() . '</p>'; |
|
210 | + function column_description($item) { |
|
211 | + return '<p>'.$item->description().'</p>'; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
215 | 215 | |
216 | - function column_actions( $item ) { |
|
217 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ) { |
|
216 | + function column_actions($item) { |
|
217 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template')) { |
|
218 | 218 | $create_args = array( |
219 | 219 | 'GRP_ID' => $item->ID(), |
220 | 220 | 'messenger' => $item->messenger(), |
221 | 221 | 'message_type' => $item->message_type(), |
222 | 222 | 'action' => 'add_new_message_template' |
223 | 223 | ); |
224 | - $create_link = EE_Admin_Page::add_query_args_and_nonce( $create_args, EE_MSG_ADMIN_URL ); |
|
225 | - return sprintf( '<p><a href="%s" class="button button-small">%s</a></p>', $create_link, __('Create Custom', 'event_espresso') ); |
|
224 | + $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
225 | + return sprintf('<p><a href="%s" class="button button-small">%s</a></p>', $create_link, __('Create Custom', 'event_espresso')); |
|
226 | 226 | } |
227 | 227 | return ''; |
228 | 228 | } |
@@ -239,27 +239,27 @@ discard block |
||
239 | 239 | $actions = array(); |
240 | 240 | |
241 | 241 | // edit link but only if item isn't trashed. |
242 | - if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ) { |
|
243 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_message_template', 'id'=>$item->GRP_ID() ), EE_MSG_ADMIN_URL ); |
|
244 | - $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>'; |
|
242 | + if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID())) { |
|
243 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID()), EE_MSG_ADMIN_URL); |
|
244 | + $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>'; |
|
245 | 245 | } |
246 | 246 | |
247 | - $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() )? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template', 'event_espresso' ) . '">' . ucwords( $item->messenger_obj()->label['singular'] ) . '</a>' : ucwords( $item->messenger_obj()->label['singular'] ); |
|
248 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'trash_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL ); |
|
247 | + $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template', 'event_espresso').'">'.ucwords($item->messenger_obj()->label['singular']).'</a>' : ucwords($item->messenger_obj()->label['singular']); |
|
248 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'trash_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL); |
|
249 | 249 | // restore link |
250 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'restore_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL ); |
|
250 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'restore_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL); |
|
251 | 251 | // delete price link |
252 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'delete_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL ); |
|
252 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'delete_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL); |
|
253 | 253 | |
254 | - if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_trash_message_template', $item->ID() ) ) { |
|
255 | - $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' . esc_attr__( 'Move Template Group to Trash', 'event_espresso' ) . '">' . __( 'Move to Trash', 'event_espresso' ) . '</a>'; |
|
254 | + if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_trash_message_template', $item->ID())) { |
|
255 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Move Template Group to Trash', 'event_espresso').'">'.__('Move to Trash', 'event_espresso').'</a>'; |
|
256 | 256 | } else { |
257 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_restore_message_template', $item->ID() ) ) { |
|
258 | - $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' . esc_attr__( 'Restore Message Template', 'event_espresso' ) . '">' . __( 'Restore', 'event_espresso' ) . '</a>'; |
|
257 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_restore_message_template', $item->ID())) { |
|
258 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Message Template', 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>'; |
|
259 | 259 | } |
260 | 260 | |
261 | - if ( $this->_view == 'trashed' && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_delete_message_template', $item->ID() ) ) { |
|
262 | - $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="' . esc_attr__( 'Delete Template Group Permanently', 'event_espresso' ) . '">' . __( 'Delete Permanently', 'event_espresso' ) . '</a>'; |
|
261 | + if ($this->_view == 'trashed' && EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_delete_message_template', $item->ID())) { |
|
262 | + $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'.esc_attr__('Delete Template Group Permanently', 'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>'; |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
@@ -268,15 +268,15 @@ discard block |
||
268 | 268 | $c_configs = $item->contexts_config(); |
269 | 269 | $ctxt = array(); |
270 | 270 | $context_templates = $item->context_templates(); |
271 | - foreach ( $context_templates as $context => $template_fields ) { |
|
272 | - $mtp_to = !empty( $context_templates[$context]['to'] ) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
273 | - $inactive = empty( $mtp_to ) && !empty( $context_templates[$context]['to'] ) ? ' class="mtp-inactive"' : ''; |
|
271 | + foreach ($context_templates as $context => $template_fields) { |
|
272 | + $mtp_to = ! empty($context_templates[$context]['to']) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
273 | + $inactive = empty($mtp_to) && ! empty($context_templates[$context]['to']) ? ' class="mtp-inactive"' : ''; |
|
274 | 274 | $context_title = ucwords($c_configs[$context]['label']); |
275 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL ); |
|
276 | - $ctxt[] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a' . $inactive . ' href="'. $edit_link . '" title="' . esc_attr__('Edit Context', 'event_espresso') . '">' . $context_title . '</a>' : $context_title; |
|
275 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL); |
|
276 | + $ctxt[] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a'.$inactive.' href="'.$edit_link.'" title="'.esc_attr__('Edit Context', 'event_espresso').'">'.$context_title.'</a>' : $context_title; |
|
277 | 277 | } |
278 | 278 | |
279 | - $ctx_content = !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? sprintf( __('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural']) ) . implode(' | ', $ctxt) : ''; |
|
279 | + $ctx_content = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? sprintf(__('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural'])).implode(' | ', $ctxt) : ''; |
|
280 | 280 | |
281 | 281 | |
282 | 282 | //Return the name contents |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | /* $1%s */ $name_link, |
285 | 285 | /* $2%s */ $item->GRP_ID(), |
286 | 286 | /* %4$s */ $ctx_content, |
287 | - /* $3%s */ $this->row_actions( $actions ) |
|
287 | + /* $3%s */ $this->row_actions($actions) |
|
288 | 288 | ); |
289 | 289 | } |
290 | 290 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @return string message_type name |
306 | 306 | */ |
307 | 307 | function column_message_type($item) { |
308 | - return ucwords($item->message_type_obj()->label['singular'] ); |
|
308 | + return ucwords($item->message_type_obj()->label['singular']); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -22,21 +22,21 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param \EE_Admin_Page $admin_page |
24 | 24 | */ |
25 | - public function __construct( EE_Admin_Page $admin_page ) { |
|
25 | + public function __construct(EE_Admin_Page $admin_page) { |
|
26 | 26 | /** |
27 | 27 | * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages |
28 | 28 | */ |
29 | 29 | if ( |
30 | - ! EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'messages_events_editor_metabox' ) |
|
30 | + ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'messages_events_editor_metabox') |
|
31 | 31 | ) { |
32 | 32 | return; |
33 | 33 | } |
34 | 34 | add_filter( |
35 | 35 | 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
36 | - array( $this, 'caf_updates' ), |
|
36 | + array($this, 'caf_updates'), |
|
37 | 37 | 10 |
38 | 38 | ); |
39 | - parent::__construct( $admin_page ); |
|
39 | + parent::__construct($admin_page); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | */ |
50 | 50 | protected function _extend_properties() { |
51 | 51 | |
52 | - define( 'EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/' ); |
|
52 | + define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'messages/assets/'); |
|
53 | 53 | $this->_ajax_func = array( |
54 | 54 | 'ee_msgs_create_new_custom' => 'create_new_custom' |
55 | 55 | ); |
56 | 56 | $this->_metaboxes = array( |
57 | 57 | 0 => array( |
58 | - 'page_route' => array('edit','create_new'), |
|
58 | + 'page_route' => array('edit', 'create_new'), |
|
59 | 59 | 'func' => 'messages_metabox', |
60 | 60 | 'label' => __('Notifications', 'event_espresso'), |
61 | 61 | 'priority' => 'high' |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | $this->_scripts_styles = array( |
67 | 67 | 'registers' => array( |
68 | 68 | 'events_msg_admin' => array( |
69 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js', |
|
69 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL.'events_messages_admin.js', |
|
70 | 70 | 'depends' => array('ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array') |
71 | 71 | ), |
72 | 72 | 'events_msg_admin_css' => array( |
73 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css', |
|
73 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL.'ee_msg_events_admin.css', |
|
74 | 74 | 'type' => 'css' |
75 | 75 | ) |
76 | 76 | ), |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | - public function caf_updates( $update_callbacks ) { |
|
86 | - $update_callbacks[] = array( $this, 'attach_evt_message_templates' ); |
|
85 | + public function caf_updates($update_callbacks) { |
|
86 | + $update_callbacks[] = array($this, 'attach_evt_message_templates'); |
|
87 | 87 | return $update_callbacks; |
88 | 88 | } |
89 | 89 | |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | * @param array $data The request data from the form |
98 | 98 | * @return bool success or fail |
99 | 99 | */ |
100 | - public function attach_evt_message_templates( $event, $data ) { |
|
100 | + public function attach_evt_message_templates($event, $data) { |
|
101 | 101 | //first we remove all existing relations on the Event for message types. |
102 | 102 | $event->_remove_relations('Message_Template_Group'); |
103 | 103 | //now let's just loop through the selected templates and add relations! |
104 | - if ( isset( $data[ 'event_message_templates_relation' ] ) ) { |
|
105 | - foreach ( $data[ 'event_message_templates_relation' ] as $grp_ID ) { |
|
106 | - $event->_add_relation_to( $grp_ID, 'Message_Template_Group' ); |
|
104 | + if (isset($data['event_message_templates_relation'])) { |
|
105 | + foreach ($data['event_message_templates_relation'] as $grp_ID) { |
|
106 | + $event->_add_relation_to($grp_ID, 'Message_Template_Group'); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | //now save |
@@ -118,25 +118,25 @@ discard block |
||
118 | 118 | * @return string |
119 | 119 | * @throws \EE_Error |
120 | 120 | */ |
121 | - public function messages_metabox( $event, $callback_args ) { |
|
121 | + public function messages_metabox($event, $callback_args) { |
|
122 | 122 | //let's get the active messengers (b/c messenger objects have the active message templates) |
123 | 123 | //convert 'evt_id' to 'EVT_ID' |
124 | - $this->_req_data['EVT_ID'] = isset( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : NULL; |
|
125 | - $this->_req_data['EVT_ID'] = isset( $this->_req_data['post'] ) && empty( $this->_req_data['EVT_ID'] ) |
|
124 | + $this->_req_data['EVT_ID'] = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL; |
|
125 | + $this->_req_data['EVT_ID'] = isset($this->_req_data['post']) && empty($this->_req_data['EVT_ID']) |
|
126 | 126 | ? $this->_req_data['post'] |
127 | 127 | : $this->_req_data['EVT_ID']; |
128 | 128 | |
129 | - $this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID'] ) && isset($this->_req_data['evt_id'] ) |
|
129 | + $this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID']) && isset($this->_req_data['evt_id']) |
|
130 | 130 | ? $this->_req_data['evt_id'] |
131 | 131 | : $this->_req_data['EVT_ID']; |
132 | 132 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
133 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
133 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
134 | 134 | $active_messengers = $message_resource_manager->active_messengers(); |
135 | 135 | $tabs = array(); |
136 | 136 | |
137 | 137 | //empty messengers? |
138 | 138 | //Note message types will always have at least one available because every messenger has a default message type associated with it (payment) if no other message types are selected. |
139 | - if ( empty( $active_messengers ) ) { |
|
139 | + if (empty($active_messengers)) { |
|
140 | 140 | $msg_activate_url = EE_Admin_Page::add_query_args_and_nonce( |
141 | 141 | array('action' => 'settings'), |
142 | 142 | EE_MSG_ADMIN_URL |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | __('There are no active messengers. So no notifications will go out for %1$sany%2$s events. You will want to %3$sActivate a Messenger%4$s.', 'event_espresso'), |
146 | 146 | '<strong>', |
147 | 147 | '</strong>', |
148 | - '<a href="' . $msg_activate_url . '">', |
|
148 | + '<a href="'.$msg_activate_url.'">', |
|
149 | 149 | '</a>' |
150 | 150 | ); |
151 | - $error_content = '<div class="error"><p>' . $error_msg . '</p></div>'; |
|
152 | - $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>'; |
|
151 | + $error_content = '<div class="error"><p>'.$error_msg.'</p></div>'; |
|
152 | + $internal_content = '<div id="messages-error"><p>'.$error_msg.'</p></div>'; |
|
153 | 153 | |
154 | 154 | echo $error_content; |
155 | 155 | echo $internal_content; |
@@ -158,20 +158,20 @@ discard block |
||
158 | 158 | |
159 | 159 | $event_id = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL; |
160 | 160 | //get content for active messengers |
161 | - foreach ( $active_messengers as $name => $messenger ) { |
|
161 | + foreach ($active_messengers as $name => $messenger) { |
|
162 | 162 | //first check if there are any active message types for this messenger. |
163 | - $active_mts = $message_resource_manager->get_active_message_types_for_messenger( $name ); |
|
164 | - if ( empty( $active_mts ) ) { |
|
163 | + $active_mts = $message_resource_manager->get_active_message_types_for_messenger($name); |
|
164 | + if (empty($active_mts)) { |
|
165 | 165 | continue; |
166 | 166 | } |
167 | 167 | |
168 | 168 | $tab_content = $messenger->get_messenger_admin_page_content( |
169 | 169 | 'events', |
170 | 170 | 'edit', |
171 | - array( 'event' => $event_id ) |
|
171 | + array('event' => $event_id) |
|
172 | 172 | ); |
173 | 173 | |
174 | - if ( ! empty( $tab_content ) ) { |
|
174 | + if ( ! empty($tab_content)) { |
|
175 | 175 | $tabs[$name] = $tab_content; |
176 | 176 | } |
177 | 177 | } |
@@ -179,23 +179,23 @@ discard block |
||
179 | 179 | |
180 | 180 | //we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper. |
181 | 181 | $tabbed_content = EEH_Tabbed_Content::display($tabs); |
182 | - if ( $tabbed_content instanceof WP_Error ) { |
|
182 | + if ($tabbed_content instanceof WP_Error) { |
|
183 | 183 | $tabbed_content = $tabbed_content->get_error_message(); |
184 | 184 | } |
185 | 185 | |
186 | 186 | $notices = ' |
187 | 187 | <div id="espresso-ajax-loading" class="ajax-loader-grey"> |
188 | - <span class="ee-spinner ee-spin"></span><span class="hidden">' . __('loading...', 'event_espresso') . '</span> |
|
188 | + <span class="ee-spinner ee-spin"></span><span class="hidden">' . __('loading...', 'event_espresso').'</span> |
|
189 | 189 | </div> |
190 | 190 | <div class="ee-notices"></div>'; |
191 | 191 | |
192 | - if ( defined('DOING_AJAX' ) ) { |
|
192 | + if (defined('DOING_AJAX')) { |
|
193 | 193 | return $tabbed_content; |
194 | 194 | } |
195 | 195 | |
196 | - do_action( 'AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content' ); |
|
197 | - echo $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>'; |
|
198 | - do_action( 'AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content' ); |
|
196 | + do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content'); |
|
197 | + echo $notices.'<div class="messages-tabs-content">'.$tabbed_content.'</div>'; |
|
198 | + do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content'); |
|
199 | 199 | |
200 | 200 | } |
201 | 201 | |
@@ -210,15 +210,15 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function create_new_custom() { |
212 | 212 | |
213 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'create_new_custom_ajax' ) ) { |
|
214 | - wp_die( __('You don\'t have privileges to do this action', 'event_espresso' ) ); |
|
213 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) { |
|
214 | + wp_die(__('You don\'t have privileges to do this action', 'event_espresso')); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | //let's clean up the _POST global a bit for downstream usage of name and description. |
218 | - $_POST['templateName'] = !empty( $this->_req_data['custom_template_args']['MTP_name'] ) |
|
218 | + $_POST['templateName'] = ! empty($this->_req_data['custom_template_args']['MTP_name']) |
|
219 | 219 | ? $this->_req_data['custom_template_args']['MTP_name'] |
220 | 220 | : ''; |
221 | - $_POST['templateDescription'] = !empty( $this->_req_data['custom_template_args']['MTP_description'] ) |
|
221 | + $_POST['templateDescription'] = ! empty($this->_req_data['custom_template_args']['MTP_description']) |
|
222 | 222 | ? $this->_req_data['custom_template_args']['MTP_description'] |
223 | 223 | : ''; |
224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $this->_set_page_object(); |
228 | 228 | |
229 | 229 | // is this a template switch if so EE_Admin_Page child needs this object |
230 | - $this->_page_object->set_hook_object( $this ); |
|
230 | + $this->_page_object->set_hook_object($this); |
|
231 | 231 | |
232 | 232 | $this->_page_object->add_message_template( |
233 | 233 | $this->_req_data['messageType'], |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function edit_admin_footer() { |
253 | 253 | EEH_Template::display_template( |
254 | - EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php' |
|
254 | + EE_CORE_CAF_ADMIN_EXTEND.'messages/templates/create_custom_template_form.template.php' |
|
255 | 255 | ); |
256 | 256 | } |
257 | 257 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $this->_name = 'pricing'; |
55 | 55 | |
56 | 56 | //capability check |
57 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) { |
|
57 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | //if we were going to add our own metaboxes we'd use the below. |
63 | 63 | $this->_metaboxes = array( |
64 | 64 | 0 => array( |
65 | - 'page_route' => array('edit','create_new'), |
|
65 | + 'page_route' => array('edit', 'create_new'), |
|
66 | 66 | 'func' => 'pricing_metabox', |
67 | 67 | 'label' => __('Event Tickets & Datetimes', 'event_espresso'), |
68 | 68 | 'priority' => 'high', |
69 | 69 | 'context' => 'normal' |
70 | 70 | ), |
71 | 71 | |
72 | - );/**/ |
|
72 | + ); /**/ |
|
73 | 73 | |
74 | 74 | $this->_remove_metaboxes = array( |
75 | 75 | 0 => array( |
@@ -88,24 +88,24 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @var array Expected an array returned with 'date' and 'time' keys. |
90 | 90 | */ |
91 | - $this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
91 | + $this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
92 | 92 | 'date' => 'Y-m-d', |
93 | 93 | 'time' => 'h:i a' |
94 | 94 | )); |
95 | 95 | |
96 | 96 | //validate |
97 | - $this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null; |
|
98 | - $this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null; |
|
97 | + $this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null; |
|
98 | + $this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null; |
|
99 | 99 | |
100 | 100 | //validate format strings |
101 | - $format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
102 | - if ( is_array( $format_validation ) ) { |
|
103 | - $msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>'; |
|
104 | - foreach ( $format_validation as $error ) { |
|
105 | - $msg .= '<li>' . $error . '</li>'; |
|
101 | + $format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
102 | + if (is_array($format_validation)) { |
|
103 | + $msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>'; |
|
104 | + foreach ($format_validation as $error) { |
|
105 | + $msg .= '<li>'.$error.'</li>'; |
|
106 | 106 | } |
107 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
108 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
107 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
108 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
109 | 109 | $this->_date_format_strings = array( |
110 | 110 | 'date' => 'Y-m-d', |
111 | 111 | 'time' => 'h:i a' |
@@ -116,60 +116,60 @@ discard block |
||
116 | 116 | $this->_scripts_styles = array( |
117 | 117 | 'registers' => array( |
118 | 118 | 'ee-tickets-datetimes-css' => array( |
119 | - 'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css', |
|
119 | + 'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css', |
|
120 | 120 | 'type' => 'css' |
121 | 121 | ), |
122 | 122 | 'ee-dtt-ticket-metabox' => array( |
123 | - 'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js', |
|
123 | + 'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js', |
|
124 | 124 | 'depends' => array('ee-datepicker', 'ee-dialog', 'underscore') |
125 | 125 | ) |
126 | 126 | ), |
127 | 127 | 'deregisters' => array( |
128 | - 'event-editor-css' => array('type' => 'css' ), |
|
128 | + 'event-editor-css' => array('type' => 'css'), |
|
129 | 129 | 'event-datetime-metabox' => array('type' => 'js') |
130 | 130 | ), |
131 | 131 | 'enqueues' => array( |
132 | - 'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ), |
|
133 | - 'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' ) |
|
132 | + 'ee-tickets-datetimes-css' => array('edit', 'create_new'), |
|
133 | + 'ee-dtt-ticket-metabox' => array('edit', 'create_new') |
|
134 | 134 | ), |
135 | 135 | 'localize' => array( |
136 | 136 | 'ee-dtt-ticket-metabox' => array( |
137 | 137 | 'DTT_TRASH_BLOCK' => array( |
138 | 138 | 'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'), |
139 | 139 | 'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'), |
140 | - 'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>', |
|
140 | + 'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>', |
|
141 | 141 | 'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
142 | 142 | 'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
143 | - 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>' |
|
143 | + 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>' |
|
144 | 144 | ), |
145 | 145 | 'DTT_ERROR_MSG' => array( |
146 | 146 | 'no_ticket_name' => __('General Admission', 'event_espresso'), |
147 | - 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>' |
|
147 | + 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>' |
|
148 | 148 | ), |
149 | 149 | 'DTT_OVERSELL_WARNING' => array( |
150 | 150 | 'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'), |
151 | 151 | 'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso') |
152 | 152 | ), |
153 | - 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ), |
|
154 | - 'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) ) |
|
153 | + 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']), |
|
154 | + 'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week')) |
|
155 | 155 | ) |
156 | 156 | ) |
157 | 157 | ); |
158 | 158 | |
159 | 159 | |
160 | - add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 ); |
|
161 | - add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 ); |
|
160 | + add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10); |
|
161 | + add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
165 | 165 | |
166 | - public function caf_updates( $update_callbacks ) { |
|
167 | - foreach ( $update_callbacks as $key => $callback ) { |
|
168 | - if ( $callback[1] == '_default_tickets_update' ) |
|
169 | - unset( $update_callbacks[$key] ); |
|
166 | + public function caf_updates($update_callbacks) { |
|
167 | + foreach ($update_callbacks as $key => $callback) { |
|
168 | + if ($callback[1] == '_default_tickets_update') |
|
169 | + unset($update_callbacks[$key]); |
|
170 | 170 | } |
171 | 171 | |
172 | - $update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' ); |
|
172 | + $update_callbacks[] = array($this, 'dtt_and_tickets_caf_update'); |
|
173 | 173 | return $update_callbacks; |
174 | 174 | } |
175 | 175 | |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | * @param array $data The request data from the form |
183 | 183 | * @return bool success or fail |
184 | 184 | */ |
185 | - public function dtt_and_tickets_caf_update( $evtobj, $data ) { |
|
185 | + public function dtt_and_tickets_caf_update($evtobj, $data) { |
|
186 | 186 | //first we need to start with datetimes cause they are the "root" items attached to events. |
187 | - $saved_dtts = $this->_update_dtts( $evtobj, $data ); |
|
187 | + $saved_dtts = $this->_update_dtts($evtobj, $data); |
|
188 | 188 | //next tackle the tickets (and prices?) |
189 | - $this->_update_tkts( $evtobj, $saved_dtts, $data ); |
|
189 | + $this->_update_tkts($evtobj, $saved_dtts, $data); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
@@ -197,41 +197,41 @@ discard block |
||
197 | 197 | * @param array $data the request data from the form |
198 | 198 | * @return EE_Datetime[] |
199 | 199 | */ |
200 | - protected function _update_dtts( $evt_obj, $data ) { |
|
201 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
200 | + protected function _update_dtts($evt_obj, $data) { |
|
201 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
202 | 202 | $saved_dtt_ids = array(); |
203 | 203 | $saved_dtt_objs = array(); |
204 | 204 | |
205 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
205 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
206 | 206 | //trim all values to ensure any excess whitespace is removed. |
207 | 207 | $dtt = array_map( |
208 | - function( $datetime_data ) { |
|
209 | - return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data ); |
|
208 | + function($datetime_data) { |
|
209 | + return is_array($datetime_data) ? $datetime_data : trim($datetime_data); |
|
210 | 210 | }, |
211 | 211 | $dtt |
212 | 212 | ); |
213 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
213 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
214 | 214 | $datetime_values = array( |
215 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
216 | - 'DTT_name' => ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '', |
|
217 | - 'DTT_description' => ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '', |
|
215 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
216 | + 'DTT_name' => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '', |
|
217 | + 'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '', |
|
218 | 218 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
219 | 219 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
220 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ], |
|
221 | - 'DTT_order' => ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'], |
|
220 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
221 | + 'DTT_order' => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'], |
|
222 | 222 | ); |
223 | 223 | |
224 | 224 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
225 | 225 | |
226 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
227 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
226 | + if ( ! empty($dtt['DTT_ID'])) { |
|
227 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']); |
|
228 | 228 | |
229 | 229 | //set date and time format according to what is set in this class. |
230 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
231 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
230 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
231 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
232 | 232 | |
233 | - foreach ( $datetime_values as $field => $value ) { |
|
234 | - $DTM->set( $field, $value ); |
|
233 | + foreach ($datetime_values as $field => $value) { |
|
234 | + $DTM->set($field, $value); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. |
@@ -239,24 +239,24 @@ discard block |
||
239 | 239 | $saved_dtt_ids[$DTM->ID()] = $DTM->ID(); |
240 | 240 | |
241 | 241 | } else { |
242 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE ); |
|
242 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE); |
|
243 | 243 | |
244 | 244 | //reset date and times to match the format |
245 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
246 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
247 | - foreach( $datetime_values as $field => $value ) { |
|
248 | - $DTM->set( $field, $value ); |
|
245 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
246 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
247 | + foreach ($datetime_values as $field => $value) { |
|
248 | + $DTM->set($field, $value); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | 252 | |
253 | 253 | $DTM->save(); |
254 | - $DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' ); |
|
254 | + $DTM = $evt_obj->_add_relation_to($DTM, 'Datetime'); |
|
255 | 255 | $evt_obj->save(); |
256 | 256 | |
257 | 257 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
258 | - if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) { |
|
259 | - $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') ); |
|
258 | + if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) { |
|
259 | + $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start')); |
|
260 | 260 | $DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days'); |
261 | 261 | $DTM->save(); |
262 | 262 | } |
@@ -271,25 +271,25 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | //now we need to REMOVE any dtts that got deleted. Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point. |
274 | - $old_datetimes = explode(',', $data['datetime_IDs'] ); |
|
274 | + $old_datetimes = explode(',', $data['datetime_IDs']); |
|
275 | 275 | $old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes; |
276 | 276 | |
277 | - if ( is_array( $old_datetimes ) ) { |
|
278 | - $dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids ); |
|
279 | - foreach ( $dtts_to_delete as $id ) { |
|
280 | - $id = absint( $id ); |
|
281 | - if ( empty( $id ) ) |
|
277 | + if (is_array($old_datetimes)) { |
|
278 | + $dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids); |
|
279 | + foreach ($dtts_to_delete as $id) { |
|
280 | + $id = absint($id); |
|
281 | + if (empty($id)) |
|
282 | 282 | continue; |
283 | 283 | |
284 | 284 | $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id); |
285 | 285 | |
286 | 286 | //remove tkt relationships. |
287 | 287 | $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
288 | - foreach ( $related_tickets as $tkt ) { |
|
288 | + foreach ($related_tickets as $tkt) { |
|
289 | 289 | $dtt_to_remove->_remove_relation_to($tkt, 'Ticket'); |
290 | 290 | } |
291 | 291 | |
292 | - $evt_obj->_remove_relation_to( $id, 'Datetime' ); |
|
292 | + $evt_obj->_remove_relation_to($id, 'Datetime'); |
|
293 | 293 | $dtt_to_remove->refresh_cache_of_related_objects(); |
294 | 294 | |
295 | 295 | } |
@@ -310,85 +310,85 @@ discard block |
||
310 | 310 | * @param array $data incoming request data |
311 | 311 | * @return EE_Ticket[] |
312 | 312 | */ |
313 | - protected function _update_tkts( $evtobj, $saved_dtts, $data ) { |
|
313 | + protected function _update_tkts($evtobj, $saved_dtts, $data) { |
|
314 | 314 | |
315 | 315 | $new_tkt = null; |
316 | 316 | $new_default = null; |
317 | 317 | //stripslashes because WP filtered the $_POST ($data) array to add slashes |
318 | 318 | $data = stripslashes_deep($data); |
319 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
319 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
320 | 320 | $saved_tickets = $dtts_on_existing = array(); |
321 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
321 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
322 | 322 | |
323 | 323 | //load money helper |
324 | 324 | |
325 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
325 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
326 | 326 | |
327 | 327 | $update_prices = $create_new_TKT = FALSE; |
328 | 328 | |
329 | 329 | //figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session. |
330 | 330 | |
331 | - $starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]); |
|
332 | - $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] ); |
|
331 | + $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]); |
|
332 | + $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]); |
|
333 | 333 | $dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows); |
334 | 334 | $dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows); |
335 | 335 | |
336 | 336 | // trim inputs to ensure any excess whitespace is removed. |
337 | 337 | $tkt = array_map( |
338 | - function( $ticket_data ) { |
|
339 | - return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data ); |
|
338 | + function($ticket_data) { |
|
339 | + return is_array($ticket_data) ? $ticket_data : trim($ticket_data); |
|
340 | 340 | }, |
341 | 341 | $tkt |
342 | 342 | ); |
343 | 343 | |
344 | 344 | //note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models. |
345 | 345 | //note incoming ['TKT_price'] value is already in standard notation (via js). |
346 | - $ticket_price = isset( $tkt['TKT_price'] ) ? round ( (float) $tkt['TKT_price'], 3 ) : 0; |
|
346 | + $ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0; |
|
347 | 347 | |
348 | 348 | //note incoming base price needs converted from localized value. |
349 | - $base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0; |
|
349 | + $base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0; |
|
350 | 350 | //if ticket price == 0 and $base_price != 0 then ticket price == base_price |
351 | 351 | $ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price; |
352 | - $base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0; |
|
352 | + $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0; |
|
353 | 353 | |
354 | 354 | $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array(); |
355 | 355 | |
356 | 356 | $now = null; |
357 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
357 | + if (empty($tkt['TKT_start_date'])) { |
|
358 | 358 | //lets' use now in the set timezone. |
359 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
360 | - $tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
359 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
360 | + $tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
361 | 361 | } |
362 | 362 | |
363 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
363 | + if (empty($tkt['TKT_end_date'])) { |
|
364 | 364 | /** |
365 | 365 | * set the TKT_end_date to the first datetime attached to the ticket. |
366 | 366 | */ |
367 | - $first_dtt = $saved_dtts[reset( $tkt_dtt_rows )]; |
|
368 | - $tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] ); |
|
367 | + $first_dtt = $saved_dtts[reset($tkt_dtt_rows)]; |
|
368 | + $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $TKT_values = array( |
372 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
373 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
374 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
375 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
372 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
373 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
374 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
375 | + 'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
376 | 376 | 'TKT_start_date' => $tkt['TKT_start_date'], |
377 | 377 | 'TKT_end_date' => $tkt['TKT_end_date'], |
378 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ], |
|
379 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'], |
|
380 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
381 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
378 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
379 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
380 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
381 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
382 | 382 | 'TKT_row' => $row, |
383 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0, |
|
384 | - 'TKT_taxable' => ! empty( $tkt['TKT_taxable'] ) ? 1 : 0, |
|
385 | - 'TKT_required' => ! empty( $tkt['TKT_required'] ) ? 1 : 0, |
|
383 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0, |
|
384 | + 'TKT_taxable' => ! empty($tkt['TKT_taxable']) ? 1 : 0, |
|
385 | + 'TKT_required' => ! empty($tkt['TKT_required']) ? 1 : 0, |
|
386 | 386 | 'TKT_price' => $ticket_price |
387 | 387 | ); |
388 | 388 | |
389 | 389 | |
390 | 390 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
391 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
391 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
392 | 392 | $TKT_values['TKT_ID'] = 0; |
393 | 393 | $TKT_values['TKT_is_default'] = 0; |
394 | 394 | $update_prices = TRUE; |
@@ -400,21 +400,21 @@ discard block |
||
400 | 400 | // but DID have it's items modified. |
401 | 401 | // keep in mind that if the TKT has been sold (and we have changed pricing information), |
402 | 402 | // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
403 | - if ( absint( $TKT_values['TKT_ID'] ) ) { |
|
404 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
405 | - if ( $TKT instanceof EE_Ticket ) { |
|
403 | + if (absint($TKT_values['TKT_ID'])) { |
|
404 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']); |
|
405 | + if ($TKT instanceof EE_Ticket) { |
|
406 | 406 | |
407 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
407 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
408 | 408 | // are there any registrations using this ticket ? |
409 | 409 | $tickets_sold = $TKT->count_related( |
410 | 410 | 'Registration', |
411 | - array( array( |
|
412 | - 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) |
|
413 | - ) ) |
|
411 | + array(array( |
|
412 | + 'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)) |
|
413 | + )) |
|
414 | 414 | ); |
415 | 415 | //set ticket formats |
416 | - $TKT->set_date_format( $this->_date_format_strings['date'] ); |
|
417 | - $TKT->set_time_format( $this->_date_format_strings['time'] ); |
|
416 | + $TKT->set_date_format($this->_date_format_strings['date']); |
|
417 | + $TKT->set_time_format($this->_date_format_strings['time']); |
|
418 | 418 | |
419 | 419 | // let's just check the total price for the existing ticket |
420 | 420 | // and determine if it matches the new total price. |
@@ -424,17 +424,17 @@ discard block |
||
424 | 424 | ? TRUE : FALSE; |
425 | 425 | |
426 | 426 | //set new values |
427 | - foreach ( $TKT_values as $field => $value ) { |
|
428 | - if ( $field === 'TKT_qty' ) { |
|
429 | - $TKT->set_qty( $value ); |
|
427 | + foreach ($TKT_values as $field => $value) { |
|
428 | + if ($field === 'TKT_qty') { |
|
429 | + $TKT->set_qty($value); |
|
430 | 430 | } else { |
431 | - $TKT->set( $field, $value ); |
|
431 | + $TKT->set($field, $value); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | 435 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
436 | - if ( $create_new_TKT ) { |
|
437 | - $new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id ); |
|
436 | + if ($create_new_TKT) { |
|
437 | + $new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id); |
|
438 | 438 | } |
439 | 439 | } |
440 | 440 | |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | $TKT = EE_Ticket::new_instance( |
444 | 444 | $TKT_values, |
445 | 445 | $timezone, |
446 | - array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ] ) |
|
446 | + array($this->_date_format_strings['date'], $this->_date_format_strings['time']) |
|
447 | 447 | ); |
448 | - if ( $TKT instanceof EE_Ticket ) { |
|
448 | + if ($TKT instanceof EE_Ticket) { |
|
449 | 449 | // make sure ticket has an ID of setting relations won't work |
450 | 450 | $TKT->save(); |
451 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
451 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
452 | 452 | $update_prices = TRUE; |
453 | 453 | } |
454 | 454 | } |
@@ -456,37 +456,37 @@ discard block |
||
456 | 456 | //$TKT->save(); |
457 | 457 | |
458 | 458 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
459 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
460 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
459 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
460 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
461 | 461 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
462 | 462 | } |
463 | 463 | |
464 | 464 | //let's make sure the base price is handled |
465 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT; |
|
465 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT; |
|
466 | 466 | |
467 | 467 | //add/update price_modifiers |
468 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT; |
|
468 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT; |
|
469 | 469 | |
470 | 470 | //need to make sue that the TKT_price is accurate after saving the prices. |
471 | 471 | $TKT->ensure_TKT_Price_correct(); |
472 | 472 | |
473 | 473 | //handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave. |
474 | - if ( ! defined('DOING_AUTOSAVE' ) ) { |
|
475 | - if ( !empty($tkt['TKT_is_default_selector'] ) ) { |
|
474 | + if ( ! defined('DOING_AUTOSAVE')) { |
|
475 | + if ( ! empty($tkt['TKT_is_default_selector'])) { |
|
476 | 476 | $update_prices = TRUE; |
477 | 477 | $new_default = clone $TKT; |
478 | - $new_default->set( 'TKT_ID', 0 ); |
|
479 | - $new_default->set( 'TKT_is_default', 1 ); |
|
480 | - $new_default->set( 'TKT_row', 1 ); |
|
481 | - $new_default->set( 'TKT_price', $ticket_price ); |
|
478 | + $new_default->set('TKT_ID', 0); |
|
479 | + $new_default->set('TKT_is_default', 1); |
|
480 | + $new_default->set('TKT_row', 1); |
|
481 | + $new_default->set('TKT_price', $ticket_price); |
|
482 | 482 | //remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object) |
483 | 483 | $new_default->_remove_relations('Datetime'); |
484 | 484 | //todo we need to add the current attached prices as new prices to the new default ticket. |
485 | - $new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices ); |
|
485 | + $new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices); |
|
486 | 486 | //don't forget the base price! |
487 | - $new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id ); |
|
487 | + $new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id); |
|
488 | 488 | $new_default->save(); |
489 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data ); |
|
489 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
@@ -497,19 +497,19 @@ discard block |
||
497 | 497 | //let's assign any tickets that have been setup to the saved_tickets tracker |
498 | 498 | //save existing TKT |
499 | 499 | $TKT->save(); |
500 | - if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) { |
|
500 | + if ($create_new_TKT && $new_tkt instanceof EE_Ticket) { |
|
501 | 501 | //save new TKT |
502 | 502 | $new_tkt->save(); |
503 | 503 | //add new ticket to array |
504 | - $saved_tickets[ $new_tkt->ID() ] = $new_tkt; |
|
504 | + $saved_tickets[$new_tkt->ID()] = $new_tkt; |
|
505 | 505 | |
506 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data ); |
|
506 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data); |
|
507 | 507 | |
508 | 508 | } else { |
509 | 509 | //add tkt to saved tkts |
510 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
510 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
511 | 511 | |
512 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data ); |
|
512 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | } |
@@ -519,22 +519,22 @@ discard block |
||
519 | 519 | // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket). |
520 | 520 | // Or a draft event was saved and in the process of editing a ticket is trashed. |
521 | 521 | // No sense in keeping all the related data in the db! |
522 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
523 | - $tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) ); |
|
522 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
523 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
524 | 524 | |
525 | - foreach ( $tickets_removed as $id ) { |
|
526 | - $id = absint( $id ); |
|
525 | + foreach ($tickets_removed as $id) { |
|
526 | + $id = absint($id); |
|
527 | 527 | |
528 | 528 | //get the ticket for this id |
529 | 529 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
530 | 530 | |
531 | 531 | //if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime |
532 | - if ( $tkt_to_remove->get('TKT_is_default') ) |
|
532 | + if ($tkt_to_remove->get('TKT_is_default')) |
|
533 | 533 | continue; |
534 | 534 | |
535 | 535 | // if this tkt has any registrations attached so then we just ARCHIVE |
536 | 536 | // because we don't actually permanently delete these tickets. |
537 | - if ( $tkt_to_remove->count_related('Registration') > 0 ) { |
|
537 | + if ($tkt_to_remove->count_related('Registration') > 0) { |
|
538 | 538 | $tkt_to_remove->delete(); |
539 | 539 | continue; |
540 | 540 | } |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | // (remember this process can ONLY kick off if there are NO tkts_sold) |
544 | 544 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
545 | 545 | |
546 | - foreach( $dtts as $dtt ) { |
|
546 | + foreach ($dtts as $dtt) { |
|
547 | 547 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
548 | 548 | } |
549 | 549 | |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
552 | 552 | $tkt_to_remove->delete_related_permanently('Price'); |
553 | 553 | |
554 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove ); |
|
554 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove); |
|
555 | 555 | |
556 | 556 | // finally let's delete this ticket |
557 | 557 | // (which should not be blocked at this point b/c we've removed all our relationships) |
@@ -583,39 +583,39 @@ discard block |
||
583 | 583 | // and removing the ticket from datetimes it got removed from. |
584 | 584 | |
585 | 585 | // first let's add datetimes |
586 | - if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) { |
|
587 | - foreach ( $added_datetimes as $row_id ) { |
|
586 | + if ( ! empty($added_datetimes) && is_array($added_datetimes)) { |
|
587 | + foreach ($added_datetimes as $row_id) { |
|
588 | 588 | $row_id = (int) $row_id; |
589 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
590 | - $ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
589 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
590 | + $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
591 | 591 | // Is this an existing ticket (has an ID) and does it have any sold? |
592 | 592 | // If so, then we need to add that to the DTT sold because this DTT is getting added. |
593 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
594 | - $saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() ); |
|
595 | - $saved_datetimes[ $row_id ]->save(); |
|
593 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
594 | + $saved_datetimes[$row_id]->increase_sold($ticket->sold()); |
|
595 | + $saved_datetimes[$row_id]->save(); |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | } |
599 | 599 | } |
600 | 600 | // then remove datetimes |
601 | - if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) { |
|
602 | - foreach ( $removed_datetimes as $row_id ) { |
|
603 | - $row_id = (int)$row_id; |
|
601 | + if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
602 | + foreach ($removed_datetimes as $row_id) { |
|
603 | + $row_id = (int) $row_id; |
|
604 | 604 | // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
605 | 605 | // So make sure we skip over this if the dtt isn't in the $saved_datetimes array) |
606 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
607 | - $ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
606 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
607 | + $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
608 | 608 | // Is this an existing ticket (has an ID) and does it have any sold? |
609 | 609 | // If so, then we need to remove it's sold from the DTT_sold. |
610 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
611 | - $saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() ); |
|
612 | - $saved_datetimes[ $row_id ]->save(); |
|
610 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
611 | + $saved_datetimes[$row_id]->decrease_sold($ticket->sold()); |
|
612 | + $saved_datetimes[$row_id]->save(); |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | } |
616 | 616 | } |
617 | 617 | // cap ticket qty by datetime reg limits |
618 | - $ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) ); |
|
618 | + $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
619 | 619 | return $ticket; |
620 | 620 | } |
621 | 621 | |
@@ -636,39 +636,39 @@ discard block |
||
636 | 636 | EE_Ticket $ticket, |
637 | 637 | $price_rows = array(), |
638 | 638 | $ticket_price = 0, |
639 | - $base_price = 0 , |
|
639 | + $base_price = 0, |
|
640 | 640 | $base_price_id = 0 |
641 | 641 | ) { |
642 | 642 | |
643 | 643 | // create new ticket that's a copy of the existing |
644 | 644 | // except a new id of course (and not archived) |
645 | 645 | // AND has the new TKT_price associated with it. |
646 | - $new_ticket = clone( $ticket ); |
|
647 | - $new_ticket->set( 'TKT_ID', 0 ); |
|
648 | - $new_ticket->set( 'TKT_deleted', 0 ); |
|
649 | - $new_ticket->set( 'TKT_price', $ticket_price ); |
|
650 | - $new_ticket->set( 'TKT_sold', 0 ); |
|
646 | + $new_ticket = clone($ticket); |
|
647 | + $new_ticket->set('TKT_ID', 0); |
|
648 | + $new_ticket->set('TKT_deleted', 0); |
|
649 | + $new_ticket->set('TKT_price', $ticket_price); |
|
650 | + $new_ticket->set('TKT_sold', 0); |
|
651 | 651 | // let's get a new ID for this ticket |
652 | 652 | $new_ticket->save(); |
653 | 653 | // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket |
654 | - $datetimes_on_existing = $ticket->get_many_related( 'Datetime' ); |
|
654 | + $datetimes_on_existing = $ticket->get_many_related('Datetime'); |
|
655 | 655 | $new_ticket = $this->_update_ticket_datetimes( |
656 | 656 | $new_ticket, |
657 | 657 | $datetimes_on_existing, |
658 | - array_keys( $datetimes_on_existing ) |
|
658 | + array_keys($datetimes_on_existing) |
|
659 | 659 | ); |
660 | 660 | |
661 | 661 | // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array. |
662 | 662 | // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining |
663 | 663 | // available. |
664 | - if ( $ticket->sold() > 0 ) { |
|
664 | + if ($ticket->sold() > 0) { |
|
665 | 665 | $new_qty = $ticket->qty() - $ticket->sold(); |
666 | - $new_ticket->set_qty( $new_qty ); |
|
666 | + $new_ticket->set_qty($new_qty); |
|
667 | 667 | } |
668 | 668 | //now we update the prices just for this ticket |
669 | - $new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true ); |
|
669 | + $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true); |
|
670 | 670 | //and we update the base price |
671 | - $new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id ); |
|
671 | + $new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id); |
|
672 | 672 | return $new_ticket; |
673 | 673 | } |
674 | 674 | |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * @param int|bool $base_price_id if present then this is the base_price_id being updated. |
689 | 689 | * @return EE_Ticket |
690 | 690 | */ |
691 | - protected function _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) { |
|
691 | + protected function _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) { |
|
692 | 692 | |
693 | 693 | //let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session. |
694 | 694 | $current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers(); |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | $updated_prices = array(); |
697 | 697 | |
698 | 698 | // if $base_price ! FALSE then updating a base price. |
699 | - if ( $base_price !== FALSE ) { |
|
699 | + if ($base_price !== FALSE) { |
|
700 | 700 | $prices[1] = array( |
701 | 701 | 'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id, |
702 | 702 | 'PRT_ID' => 1, |
@@ -707,47 +707,47 @@ discard block |
||
707 | 707 | } |
708 | 708 | |
709 | 709 | //possibly need to save tkt |
710 | - if ( ! $ticket->ID() ) |
|
710 | + if ( ! $ticket->ID()) |
|
711 | 711 | $ticket->save(); |
712 | 712 | |
713 | - foreach ( $prices as $row => $prc ) { |
|
714 | - $prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL; |
|
715 | - if ( empty($prt_id) ) |
|
713 | + foreach ($prices as $row => $prc) { |
|
714 | + $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL; |
|
715 | + if (empty($prt_id)) |
|
716 | 716 | continue; //prices MUST have a price type id. |
717 | 717 | $PRC_values = array( |
718 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
718 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
719 | 719 | 'PRT_ID' => $prt_id, |
720 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
721 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
722 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
720 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
721 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
722 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
723 | 723 | 'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor |
724 | 724 | 'PRC_order' => $row |
725 | 725 | ); |
726 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
726 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
727 | 727 | $PRC_values['PRC_ID'] = 0; |
728 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
728 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
729 | 729 | } else { |
730 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
730 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
731 | 731 | //update this price with new values |
732 | - foreach ( $PRC_values as $field => $newprc ) { |
|
733 | - $PRC->set( $field, $newprc ); |
|
732 | + foreach ($PRC_values as $field => $newprc) { |
|
733 | + $PRC->set($field, $newprc); |
|
734 | 734 | } |
735 | 735 | } |
736 | 736 | $PRC->save(); |
737 | 737 | $prcid = $PRC->ID(); |
738 | 738 | $updated_prices[$prcid] = $PRC; |
739 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
739 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | //now let's remove any prices that got removed from the ticket |
743 | - if ( !empty ( $current_prices_on_ticket ) ) { |
|
743 | + if ( ! empty ($current_prices_on_ticket)) { |
|
744 | 744 | $current = array_keys($current_prices_on_ticket); |
745 | 745 | $updated = array_keys($updated_prices); |
746 | 746 | $prices_to_remove = array_diff($current, $updated); |
747 | - if ( !empty( $prices_to_remove ) ) { |
|
748 | - foreach ( $prices_to_remove as $prc_id ) { |
|
747 | + if ( ! empty($prices_to_remove)) { |
|
748 | + foreach ($prices_to_remove as $prc_id) { |
|
749 | 749 | $p = $current_prices_on_ticket[$prc_id]; |
750 | - $ticket->_remove_relation_to( $p, 'Price' ); |
|
750 | + $ticket->_remove_relation_to($p, 'Price'); |
|
751 | 751 | |
752 | 752 | //delete permanently the price |
753 | 753 | $p->delete_permanently(); |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | |
761 | 761 | |
762 | 762 | |
763 | - public function autosave_handling( $event_admin_obj ) { |
|
763 | + public function autosave_handling($event_admin_obj) { |
|
764 | 764 | return $event_admin_obj; //doing nothing for the moment. |
765 | 765 | //todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method) |
766 | 766 | |
@@ -794,12 +794,12 @@ discard block |
||
794 | 794 | |
795 | 795 | //default main template args |
796 | 796 | $main_template_args = array( |
797 | - 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
797 | + 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
798 | 798 | 'existing_datetime_ids' => '', |
799 | 799 | 'total_dtt_rows' => 1, |
800 | - 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
800 | + 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
801 | 801 | 'datetime_rows' => '', |
802 | - 'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
802 | + 'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
803 | 803 | 'ticket_rows' => '', |
804 | 804 | 'existing_ticket_ids' => '', |
805 | 805 | 'total_ticket_rows' => 1, |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | |
810 | 810 | $timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL; |
811 | 811 | |
812 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
812 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
813 | 813 | |
814 | 814 | /** |
815 | 815 | * 1. Start with retrieving Datetimes |
@@ -817,8 +817,8 @@ discard block |
||
817 | 817 | * 3. For each ticket get related prices |
818 | 818 | */ |
819 | 819 | |
820 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) ); |
|
821 | - $times = $DTM->get_all_event_dates( $evtID ); |
|
820 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone)); |
|
821 | + $times = $DTM->get_all_event_dates($evtID); |
|
822 | 822 | |
823 | 823 | |
824 | 824 | |
@@ -826,31 +826,31 @@ discard block |
||
826 | 826 | |
827 | 827 | /** @see https://events.codebasehq.com/projects/event-espresso/tickets/9486 for why we are counting $dttrow and then setting that on the Datetime object */ |
828 | 828 | $dttrow = 1; |
829 | - foreach ( $times as $time ) { |
|
829 | + foreach ($times as $time) { |
|
830 | 830 | $dttid = $time->get('DTT_ID'); |
831 | - $time->set( 'DTT_order', $dttrow ); |
|
831 | + $time->set('DTT_order', $dttrow); |
|
832 | 832 | $existing_datetime_ids[] = $dttid; |
833 | 833 | |
834 | 834 | //tickets attached |
835 | - $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array(); |
|
835 | + $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array(); |
|
836 | 836 | |
837 | 837 | //if there are no related tickets this is likely a new event OR autodraft |
838 | 838 | // event so we need to generate the default tickets because dtts |
839 | 839 | // ALWAYS have at least one related ticket!!. EXCEPT, we dont' do this if there is already more than one |
840 | 840 | // datetime on the event. |
841 | - if ( empty ( $related_tickets ) && count( $times ) < 2 ) { |
|
841 | + if (empty ($related_tickets) && count($times) < 2) { |
|
842 | 842 | $related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
843 | 843 | |
844 | 844 | //this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save). |
845 | 845 | $default_prices = EEM_Price::instance()->get_all_default_prices(); |
846 | 846 | |
847 | - $main_default_ticket = reset( $related_tickets ); |
|
848 | - if ( $main_default_ticket instanceof EE_Ticket ) { |
|
849 | - foreach ( $default_prices as $default_price ) { |
|
850 | - if ( $default_price->is_base_price() ) { |
|
847 | + $main_default_ticket = reset($related_tickets); |
|
848 | + if ($main_default_ticket instanceof EE_Ticket) { |
|
849 | + foreach ($default_prices as $default_price) { |
|
850 | + if ($default_price->is_base_price()) { |
|
851 | 851 | continue; |
852 | 852 | } |
853 | - $main_default_ticket->cache( 'Price', $default_price ); |
|
853 | + $main_default_ticket->cache('Price', $default_price); |
|
854 | 854 | } |
855 | 855 | } |
856 | 856 | } |
@@ -859,11 +859,11 @@ discard block |
||
859 | 859 | //we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information. |
860 | 860 | |
861 | 861 | //loop through and setup the ticket rows and make sure the order is set. |
862 | - foreach ( $related_tickets as $ticket ) { |
|
862 | + foreach ($related_tickets as $ticket) { |
|
863 | 863 | $tktid = $ticket->get('TKT_ID'); |
864 | 864 | $tktrow = $ticket->get('TKT_row'); |
865 | 865 | //we only want unique tickets in our final display!! |
866 | - if ( !in_array( $tktid, $existing_ticket_ids ) ) { |
|
866 | + if ( ! in_array($tktid, $existing_ticket_ids)) { |
|
867 | 867 | $existing_ticket_ids[] = $tktid; |
868 | 868 | $all_tickets[] = $ticket; |
869 | 869 | } |
@@ -872,57 +872,57 @@ discard block |
||
872 | 872 | $datetime_tickets[$dttid][] = $tktrow; |
873 | 873 | |
874 | 874 | //temporary cache of this datetime info for this ticket for later processing of ticket rows. |
875 | - if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) ) |
|
875 | + if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) |
|
876 | 876 | $ticket_datetimes[$tktid][] = $dttrow; |
877 | 877 | } |
878 | 878 | $dttrow++; |
879 | 879 | } |
880 | 880 | |
881 | - $main_template_args['total_ticket_rows'] = count( $existing_ticket_ids ); |
|
882 | - $main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
883 | - $main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
881 | + $main_template_args['total_ticket_rows'] = count($existing_ticket_ids); |
|
882 | + $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
883 | + $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
884 | 884 | |
885 | 885 | //sort $all_tickets by order |
886 | - usort( $all_tickets, function( $a, $b ) { |
|
886 | + usort($all_tickets, function($a, $b) { |
|
887 | 887 | $a_order = (int) $a->get('TKT_order'); |
888 | 888 | $b_order = (int) $b->get('TKT_order'); |
889 | - if ( $a_order == $b_order ) { |
|
889 | + if ($a_order == $b_order) { |
|
890 | 890 | return 0; |
891 | 891 | } |
892 | - return ( $a_order < $b_order ) ? -1 : 1; |
|
892 | + return ($a_order < $b_order) ? -1 : 1; |
|
893 | 893 | }); |
894 | 894 | |
895 | 895 | //k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again. |
896 | 896 | $dttrow = 1; |
897 | - foreach ( $times as $time ) { |
|
898 | - $main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times ); |
|
897 | + foreach ($times as $time) { |
|
898 | + $main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times); |
|
899 | 899 | $dttrow++; |
900 | 900 | } |
901 | 901 | |
902 | 902 | //then loop through all tickets for the ticket rows. |
903 | 903 | $tktrow = 1; |
904 | - foreach ( $all_tickets as $ticket ) { |
|
905 | - $main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets ); |
|
904 | + foreach ($all_tickets as $ticket) { |
|
905 | + $main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets); |
|
906 | 906 | $tktrow++; |
907 | 907 | } |
908 | 908 | |
909 | 909 | $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets); |
910 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'; |
|
911 | - EEH_Template::display_template( $template, $main_template_args ); |
|
910 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'; |
|
911 | + EEH_Template::display_template($template, $main_template_args); |
|
912 | 912 | return; |
913 | 913 | } |
914 | 914 | |
915 | 915 | |
916 | 916 | |
917 | - protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) { |
|
917 | + protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) { |
|
918 | 918 | |
919 | 919 | $dtt_display_template_args = array( |
920 | - 'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ), |
|
921 | - 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ), |
|
920 | + 'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts), |
|
921 | + 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default), |
|
922 | 922 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow |
923 | 923 | ); |
924 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php'; |
|
925 | - return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE); |
|
924 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php'; |
|
925 | + return EEH_Template::display_template($template, $dtt_display_template_args, TRUE); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return string Generated edit row. |
942 | 942 | */ |
943 | - protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) { |
|
943 | + protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) { |
|
944 | 944 | |
945 | 945 | // if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true. |
946 | 946 | $default = ! $dtt instanceof EE_Datetime ? true : false; |
@@ -948,30 +948,30 @@ discard block |
||
948 | 948 | $template_args = array( |
949 | 949 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
950 | 950 | 'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes', |
951 | - 'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
951 | + 'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
952 | 952 | 'DTT_ID' => $default ? '' : $dtt->ID(), |
953 | 953 | 'DTT_name' => $default ? '' : $dtt->name(), |
954 | 954 | 'DTT_description' => $default ? '' : $dtt->description(), |
955 | - 'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
956 | - 'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
957 | - 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'), |
|
955 | + 'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
956 | + 'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
957 | + 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'), |
|
958 | 958 | 'DTT_order' => $default ? 'DTTNUM' : $dttrow, |
959 | 959 | 'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'), |
960 | - 'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
961 | - 'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
960 | + 'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
961 | + 'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
962 | 962 | ); |
963 | 963 | |
964 | - $template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
964 | + $template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
965 | 965 | |
966 | 966 | //allow filtering of template args at this point. |
967 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event ); |
|
967 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event); |
|
968 | 968 | |
969 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php'; |
|
970 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
969 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php'; |
|
970 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | |
974 | - protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) { |
|
974 | + protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) { |
|
975 | 975 | |
976 | 976 | $template_args = array( |
977 | 977 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
@@ -979,47 +979,47 @@ discard block |
||
979 | 979 | 'DTT_description' => $default ? '' : $dtt->description(), |
980 | 980 | 'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '', |
981 | 981 | 'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '', |
982 | - 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
982 | + 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
983 | 983 | 'DTT_ID' => $default ? '' : $dtt->ID() |
984 | 984 | ); |
985 | 985 | |
986 | 986 | //need to setup the list items (but only if this isnt' a default skeleton setup) |
987 | - if ( !$default ) { |
|
987 | + if ( ! $default) { |
|
988 | 988 | $tktrow = 1; |
989 | - foreach ( $all_tickets as $ticket ) { |
|
990 | - $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ); |
|
989 | + foreach ($all_tickets as $ticket) { |
|
990 | + $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default); |
|
991 | 991 | $tktrow++; |
992 | 992 | } |
993 | 993 | } |
994 | 994 | |
995 | 995 | //filter template args at this point |
996 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event ); |
|
996 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event); |
|
997 | 997 | |
998 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php'; |
|
999 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
998 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php'; |
|
999 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | |
1003 | 1003 | |
1004 | - protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) { |
|
1005 | - $tktid = !empty( $ticket ) ? $ticket->ID() : 0; |
|
1006 | - $dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1004 | + protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) { |
|
1005 | + $tktid = ! empty($ticket) ? $ticket->ID() : 0; |
|
1006 | + $dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1007 | 1007 | |
1008 | - $displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0; |
|
1008 | + $displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0; |
|
1009 | 1009 | $template_args = array( |
1010 | 1010 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
1011 | - 'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow, |
|
1011 | + 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
|
1012 | 1012 | 'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '', |
1013 | 1013 | 'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '', |
1014 | - 'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1015 | - 'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(), |
|
1014 | + 'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1015 | + 'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(), |
|
1016 | 1016 | ); |
1017 | 1017 | |
1018 | 1018 | //filter template args |
1019 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event ); |
|
1019 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event); |
|
1020 | 1020 | |
1021 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1022 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1021 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1022 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | |
@@ -1041,37 +1041,37 @@ discard block |
||
1041 | 1041 | * |
1042 | 1042 | * @return [type] [description] |
1043 | 1043 | */ |
1044 | - protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) { |
|
1044 | + protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) { |
|
1045 | 1045 | |
1046 | 1046 | //if $ticket is not an instance of EE_Ticket then force default to true. |
1047 | - $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1047 | + $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1048 | 1048 | |
1049 | - $prices = ! empty( $ticket ) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array(); |
|
1049 | + $prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array(); |
|
1050 | 1050 | |
1051 | 1051 | //if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on |
1052 | 1052 | //the object. This is done by not including any query_params. |
1053 | - if ( $ticket instanceof EE_Ticket && $ticket->is_default() && ( count( $prices ) === 1 || empty( $prices ) ) ) { |
|
1054 | - $prices = $ticket->get_many_related( 'Price' ); |
|
1053 | + if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) { |
|
1054 | + $prices = $ticket->get_many_related('Price'); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | // check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket). This will future proof in case there is ever any behaviour change between what the primary_key defaults to. |
1058 | - $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE; |
|
1058 | + $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE; |
|
1059 | 1059 | |
1060 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1060 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1061 | 1061 | |
1062 | 1062 | $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal(); |
1063 | - $base_price = $default ? NULL : $ticket->base_price(); |
|
1063 | + $base_price = $default ? NULL : $ticket->base_price(); |
|
1064 | 1064 | $count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE); |
1065 | 1065 | |
1066 | 1066 | //breaking out complicated condition for ticket_status |
1067 | - if ( $default ) { |
|
1068 | - $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
1067 | + if ($default) { |
|
1068 | + $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale; |
|
1069 | 1069 | } else { |
1070 | - $ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(); |
|
1070 | + $ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | //breaking out complicated condition for TKT_taxable |
1074 | - if ( $default ) { |
|
1074 | + if ($default) { |
|
1075 | 1075 | $TKT_taxable = ''; |
1076 | 1076 | } else { |
1077 | 1077 | $TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : ''; |
@@ -1086,19 +1086,19 @@ discard block |
||
1086 | 1086 | 'edit_tkt_expanded' => '', |
1087 | 1087 | 'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets', |
1088 | 1088 | 'TKT_name' => $default ? '' : $ticket->get('TKT_name'), |
1089 | - 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1090 | - 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1091 | - 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1089 | + 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1090 | + 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1091 | + 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1092 | 1092 | 'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE), |
1093 | 1093 | 'TKT_price_code' => EE_Registry::instance()->CFG->currency->code, |
1094 | 1094 | 'TKT_price_amount' => $default ? 0 : $ticket_subtotal, |
1095 | - 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'), |
|
1096 | - 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'), |
|
1097 | - 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'), |
|
1098 | - 'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ), |
|
1099 | - 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max','input'), |
|
1095 | + 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'), |
|
1096 | + 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'), |
|
1097 | + 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'), |
|
1098 | + 'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')), |
|
1099 | + 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'), |
|
1100 | 1100 | 'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'), |
1101 | - 'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ), |
|
1101 | + 'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))), |
|
1102 | 1102 | 'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'), |
1103 | 1103 | 'TKT_description' => $default ? '' : $ticket->get('TKT_description'), |
1104 | 1104 | 'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'), |
@@ -1107,99 +1107,99 @@ discard block |
||
1107 | 1107 | 'ticket_price_rows' => '', |
1108 | 1108 | 'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'), |
1109 | 1109 | 'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(), |
1110 | - 'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"', |
|
1111 | - 'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '', |
|
1110 | + 'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"', |
|
1111 | + 'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '', |
|
1112 | 1112 | 'total_price_rows' => count($prices) > 1 ? count($prices) : 1, |
1113 | 1113 | 'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '', |
1114 | 1114 | 'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts), |
1115 | 1115 | 'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts), |
1116 | - 'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ), |
|
1116 | + 'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)), |
|
1117 | 1117 | 'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'), |
1118 | 1118 | 'TKT_taxable' => $TKT_taxable, |
1119 | 1119 | 'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"', |
1120 | 1120 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1121 | - 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ), |
|
1121 | + 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE), |
|
1122 | 1122 | 'TKT_subtotal_amount' => $ticket_subtotal, |
1123 | - 'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ), |
|
1124 | - 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE, |
|
1123 | + 'tax_rows' => $this->_get_tax_rows($tktrow, $ticket), |
|
1124 | + 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE, |
|
1125 | 1125 | 'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '', |
1126 | 1126 | 'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable', |
1127 | 1127 | 'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable' |
1128 | 1128 | ); |
1129 | 1129 | |
1130 | - $template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1130 | + $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1131 | 1131 | |
1132 | 1132 | //handle rows that should NOT be empty |
1133 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1133 | + if (empty($template_args['TKT_start_date'])) { |
|
1134 | 1134 | //if empty then the start date will be now. |
1135 | - $template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp')); |
|
1136 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1135 | + $template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp')); |
|
1136 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1139 | + if (empty($template_args['TKT_end_date'])) { |
|
1140 | 1140 | |
1141 | 1141 | //get the earliest datetime (if present); |
1142 | - $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1142 | + $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1143 | 1143 | |
1144 | - if ( !empty( $earliest_dtt ) ) { |
|
1145 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
1144 | + if ( ! empty($earliest_dtt)) { |
|
1145 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
1146 | 1146 | } else { |
1147 | 1147 | //default so let's just use what's been set for the default date-time which is 30 days from now. |
1148 | - $template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") ) ); |
|
1148 | + $template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y"))); |
|
1149 | 1149 | } |
1150 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1150 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | //generate ticket_datetime items |
1154 | - if ( ! $default ) { |
|
1154 | + if ( ! $default) { |
|
1155 | 1155 | $dttrow = 1; |
1156 | - foreach ( $all_dtts as $dtt ) { |
|
1157 | - $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ); |
|
1156 | + foreach ($all_dtts as $dtt) { |
|
1157 | + $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default); |
|
1158 | 1158 | $dttrow++; |
1159 | 1159 | } |
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | $prcrow = 1; |
1163 | - foreach ( $prices as $price ) { |
|
1164 | - if ( $price->is_base_price() ) { |
|
1163 | + foreach ($prices as $price) { |
|
1164 | + if ($price->is_base_price()) { |
|
1165 | 1165 | $prcrow++; |
1166 | 1166 | continue; |
1167 | 1167 | } |
1168 | - $show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1 ? FALSE : TRUE; |
|
1169 | - $show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE; |
|
1170 | - $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create ); |
|
1168 | + $show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE; |
|
1169 | + $show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE; |
|
1170 | + $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create); |
|
1171 | 1171 | $prcrow++; |
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | //filter $template_args |
1175 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event ); |
|
1175 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event); |
|
1176 | 1176 | |
1177 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php'; |
|
1178 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1177 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php'; |
|
1178 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | |
1182 | 1182 | |
1183 | 1183 | |
1184 | 1184 | |
1185 | - protected function _get_tax_rows( $tktrow, $ticket ) { |
|
1185 | + protected function _get_tax_rows($tktrow, $ticket) { |
|
1186 | 1186 | $tax_rows = ''; |
1187 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1187 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1188 | 1188 | $template_args = array(); |
1189 | - $taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1190 | - foreach ( $taxes as $tax ) { |
|
1191 | - $tax_added = $this->_get_tax_added( $tax, $ticket ); |
|
1189 | + $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1190 | + foreach ($taxes as $tax) { |
|
1191 | + $tax_added = $this->_get_tax_added($tax, $ticket); |
|
1192 | 1192 | $template_args = array( |
1193 | - 'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1193 | + 'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1194 | 1194 | 'tax_id' => $tax->ID(), |
1195 | 1195 | 'tkt_row' => $tktrow, |
1196 | 1196 | 'tax_label' => $tax->get('PRC_name'), |
1197 | 1197 | 'tax_added' => $tax_added, |
1198 | - 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ), |
|
1198 | + 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE), |
|
1199 | 1199 | 'tax_amount' => $tax->get('PRC_amount') |
1200 | 1200 | ); |
1201 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event ); |
|
1202 | - $tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1201 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event); |
|
1202 | + $tax_rows .= EEH_Template::display_template($template, $template_args, TRUE); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | |
@@ -1207,81 +1207,81 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | |
1210 | - protected function _get_tax_added( EE_Price $tax, $ticket ) { |
|
1211 | - $subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal(); |
|
1210 | + protected function _get_tax_added(EE_Price $tax, $ticket) { |
|
1211 | + $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal(); |
|
1212 | 1212 | return $subtotal * $tax->get('PRC_amount') / 100; |
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | |
1216 | 1216 | |
1217 | 1217 | |
1218 | - protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) { |
|
1219 | - $send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1218 | + protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) { |
|
1219 | + $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1220 | 1220 | $template_args = array( |
1221 | 1221 | 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
1222 | 1222 | 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
1223 | 1223 | 'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices', |
1224 | - 'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ), |
|
1224 | + 'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled), |
|
1225 | 1225 | 'PRC_ID' => $default && empty($price) ? 0 : $price->ID(), |
1226 | 1226 | 'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'), |
1227 | 1227 | 'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'), |
1228 | 1228 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1229 | 1229 | 'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"', |
1230 | - 'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1231 | - 'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1232 | - 'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ), |
|
1233 | - 'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1234 | - 'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ), |
|
1230 | + 'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1231 | + 'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1232 | + 'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''), |
|
1233 | + 'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1234 | + 'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'), |
|
1235 | 1235 | 'show_trash_icon' => $show_trash ? '' : ' style="display:none;"', |
1236 | 1236 | 'show_create_button' => $show_create ? '' : ' style="display:none;"', |
1237 | - 'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'), |
|
1238 | - 'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1237 | + 'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'), |
|
1238 | + 'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1239 | 1239 | ); |
1240 | 1240 | |
1241 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event ); |
|
1241 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event); |
|
1242 | 1242 | |
1243 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php'; |
|
1244 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1243 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php'; |
|
1244 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | |
1248 | - protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1249 | - if ( $price->is_base_price() ) { |
|
1250 | - return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ); |
|
1248 | + protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1249 | + if ($price->is_base_price()) { |
|
1250 | + return $this->_get_base_price_template($tktrow, $prcrow, $price, $default); |
|
1251 | 1251 | } else { |
1252 | - return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled ); |
|
1252 | + return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled); |
|
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | |
1258 | - protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) { |
|
1258 | + protected function _get_base_price_template($tktrow, $prcrow, $price, $default) { |
|
1259 | 1259 | $template_args = array( |
1260 | 1260 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1261 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1262 | - 'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'), |
|
1261 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1262 | + 'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'), |
|
1263 | 1263 | 'PRT_name' => __('Price', 'event_espresso'), |
1264 | 1264 | 'price_selected_operator' => '+', |
1265 | 1265 | 'price_selected_is_percent' => 0 |
1266 | 1266 | ); |
1267 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php'; |
|
1267 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php'; |
|
1268 | 1268 | |
1269 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event ); |
|
1269 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event); |
|
1270 | 1270 | |
1271 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1271 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | |
1275 | 1275 | |
1276 | - protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1277 | - $select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]'; |
|
1278 | - $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) ); |
|
1279 | - $price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php'; |
|
1280 | - $all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array(); |
|
1281 | - $selected_price_type_id = $default && empty( $price ) ? 0 : $price->type(); |
|
1276 | + protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1277 | + $select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]'; |
|
1278 | + $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3')))); |
|
1279 | + $price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php'; |
|
1280 | + $all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array(); |
|
1281 | + $selected_price_type_id = $default && empty($price) ? 0 : $price->type(); |
|
1282 | 1282 | $price_option_spans = ''; |
1283 | 1283 | //setup pricetypes for selector |
1284 | - foreach ( $price_types as $price_type ) { |
|
1284 | + foreach ($price_types as $price_type) { |
|
1285 | 1285 | $all_price_types[] = array( |
1286 | 1286 | 'id' => $price_type->ID(), |
1287 | 1287 | 'text' => $price_type->get('PRT_name'), |
@@ -1293,50 +1293,50 @@ discard block |
||
1293 | 1293 | 'PRT_operator' => $price_type->is_discount() ? '-' : '+', |
1294 | 1294 | 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0 |
1295 | 1295 | ); |
1296 | - $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE ); |
|
1296 | + $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1299 | + $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1300 | 1300 | $main_name = $select_name; |
1301 | - $select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name; |
|
1301 | + $select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name; |
|
1302 | 1302 | |
1303 | 1303 | $template_args = array( |
1304 | 1304 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1305 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1306 | - 'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ), |
|
1305 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1306 | + 'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'), |
|
1307 | 1307 | 'main_name' => $main_name, |
1308 | 1308 | 'selected_price_type_id' => $selected_price_type_id, |
1309 | 1309 | 'price_option_spans' => $price_option_spans, |
1310 | - 'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ), |
|
1311 | - 'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ), |
|
1310 | + 'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'), |
|
1311 | + 'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0), |
|
1312 | 1312 | 'disabled' => $disabled |
1313 | 1313 | ); |
1314 | 1314 | |
1315 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event ); |
|
1315 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event); |
|
1316 | 1316 | |
1317 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1317 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1318 | 1318 | |
1319 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1319 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | |
1323 | 1323 | |
1324 | - protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) { |
|
1325 | - $dttid = !empty($dtt) ? $dtt->ID() : 0; |
|
1326 | - $displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1327 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1324 | + protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) { |
|
1325 | + $dttid = ! empty($dtt) ? $dtt->ID() : 0; |
|
1326 | + $displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1327 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1328 | 1328 | $template_args = array( |
1329 | - 'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow, |
|
1329 | + 'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow, |
|
1330 | 1330 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1331 | - 'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '', |
|
1332 | - 'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '', |
|
1333 | - 'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ), |
|
1331 | + 'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '', |
|
1332 | + 'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '', |
|
1333 | + 'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE), |
|
1334 | 1334 | 'tkt_status_class' => '', |
1335 | 1335 | ); |
1336 | 1336 | |
1337 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event ); |
|
1338 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1339 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1337 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event); |
|
1338 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1339 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1340 | 1340 | } |
1341 | 1341 | |
1342 | 1342 | |
@@ -1344,53 +1344,53 @@ discard block |
||
1344 | 1344 | protected function _get_ticket_js_structure($all_dtts, $all_tickets) { |
1345 | 1345 | $template_args = array( |
1346 | 1346 | 'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts), |
1347 | - 'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE), |
|
1348 | - 'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ), |
|
1347 | + 'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE), |
|
1348 | + 'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL), |
|
1349 | 1349 | 'default_price_rows' => '', |
1350 | 1350 | 'default_base_price_amount' => 0, |
1351 | 1351 | 'default_base_price_name' => '', |
1352 | 1352 | 'default_base_price_description' => '', |
1353 | - 'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ), |
|
1354 | - 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ), |
|
1353 | + 'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE), |
|
1354 | + 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE), |
|
1355 | 1355 | 'existing_available_datetime_tickets_list' => '', |
1356 | 1356 | 'existing_available_ticket_datetimes_list' => '', |
1357 | - 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ), |
|
1358 | - 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ) |
|
1357 | + 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE), |
|
1358 | + 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE) |
|
1359 | 1359 | ); |
1360 | 1360 | |
1361 | 1361 | $tktrow = 1; |
1362 | - foreach ( $all_tickets as $ticket ) { |
|
1363 | - $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE ); |
|
1362 | + foreach ($all_tickets as $ticket) { |
|
1363 | + $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE); |
|
1364 | 1364 | $tktrow++; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | |
1368 | 1368 | $dttrow = 1; |
1369 | - foreach ( $all_dtts as $dtt ) { |
|
1370 | - $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE ); |
|
1369 | + foreach ($all_dtts as $dtt) { |
|
1370 | + $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE); |
|
1371 | 1371 | $dttrow++; |
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | $default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices(); |
1375 | 1375 | $prcrow = 1; |
1376 | - foreach ( $default_prices as $price ) { |
|
1377 | - if ( $price->is_base_price() ) { |
|
1376 | + foreach ($default_prices as $price) { |
|
1377 | + if ($price->is_base_price()) { |
|
1378 | 1378 | $template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float'); |
1379 | 1379 | $template_args['default_base_price_name'] = $price->get('PRC_name'); |
1380 | 1380 | $template_args['default_base_price_description'] = $price->get('PRC_desc'); |
1381 | 1381 | $prcrow++; |
1382 | 1382 | continue; |
1383 | 1383 | } |
1384 | - $show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1 ? FALSE : TRUE; |
|
1385 | - $show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE; |
|
1386 | - $template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create ); |
|
1384 | + $show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE; |
|
1385 | + $show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE; |
|
1386 | + $template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create); |
|
1387 | 1387 | $prcrow++; |
1388 | 1388 | } |
1389 | 1389 | |
1390 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event ); |
|
1390 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event); |
|
1391 | 1391 | |
1392 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1393 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1392 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1393 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return EED_Recaptcha |
44 | 44 | */ |
45 | 45 | public static function instance() { |
46 | - return parent::get_instance( __CLASS__ ); |
|
46 | + return parent::get_instance(__CLASS__); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -59,32 +59,32 @@ discard block |
||
59 | 59 | if ( |
60 | 60 | EE_Registry::instance()->CFG->registration->use_captcha |
61 | 61 | && ! ( |
62 | - EE_Registry::instance()->REQ->get( 'step', '' ) === 'payment_options' |
|
63 | - && (boolean) EE_Registry::instance()->REQ->get( 'revisit', false ) === true |
|
62 | + EE_Registry::instance()->REQ->get('step', '') === 'payment_options' |
|
63 | + && (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true |
|
64 | 64 | ) |
65 | 65 | ) { |
66 | 66 | EED_Recaptcha::set_definitions(); |
67 | 67 | EED_Recaptcha::enqueue_styles_and_scripts(); |
68 | - add_action( 'wp', array( 'EED_Recaptcha', 'set_late_hooks' ), 1, 0 ); |
|
68 | + add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0); |
|
69 | 69 | add_action( |
70 | 70 | 'AHEE__before_spco_whats_next_buttons', |
71 | - array( 'EED_Recaptcha', 'display_recaptcha' ), 10, 0 |
|
71 | + array('EED_Recaptcha', 'display_recaptcha'), 10, 0 |
|
72 | 72 | ); |
73 | 73 | add_filter( |
74 | 74 | 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
75 | - array( 'EED_Recaptcha', 'not_a_robot' ), 10 |
|
75 | + array('EED_Recaptcha', 'not_a_robot'), 10 |
|
76 | 76 | ); |
77 | 77 | add_filter( |
78 | 78 | 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
79 | - array( 'EED_Recaptcha', 'not_a_robot' ), 10 |
|
79 | + array('EED_Recaptcha', 'not_a_robot'), 10 |
|
80 | 80 | ); |
81 | 81 | add_filter( |
82 | 82 | 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
83 | - array( 'EED_Recaptcha', 'recaptcha_response' ), 10, 1 |
|
83 | + array('EED_Recaptcha', 'recaptcha_response'), 10, 1 |
|
84 | 84 | ); |
85 | 85 | add_filter( |
86 | 86 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
87 | - array( 'EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method' ), 10, 1 |
|
87 | + array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method'), 10, 1 |
|
88 | 88 | ); |
89 | 89 | } |
90 | 90 | } |
@@ -103,18 +103,18 @@ discard block |
||
103 | 103 | if ( |
104 | 104 | EE_Registry::instance()->CFG->registration->use_captcha |
105 | 105 | && ! ( |
106 | - EE_Registry::instance()->REQ->get( 'step', '' ) === 'payment_options' |
|
107 | - && (boolean) EE_Registry::instance()->REQ->get( 'revisit', false ) === true |
|
106 | + EE_Registry::instance()->REQ->get('step', '') === 'payment_options' |
|
107 | + && (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true |
|
108 | 108 | ) |
109 | 109 | ) { |
110 | 110 | EED_Recaptcha::enqueue_styles_and_scripts(); |
111 | - add_filter( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', array( 'EED_Recaptcha', 'not_a_robot' ), 10 ); |
|
112 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', array( 'EED_Recaptcha', 'not_a_robot' ), 10 ); |
|
113 | - add_filter( 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', array( 'EED_Recaptcha', 'recaptcha_response' ), 10, 1 ); |
|
111 | + add_filter('FHEE__EED_Single_Page_Checkout__init___continue_reg', array('EED_Recaptcha', 'not_a_robot'), 10); |
|
112 | + add_filter('FHEE__EE_SPCO_Reg_Step__set_completed___completed', array('EED_Recaptcha', 'not_a_robot'), 10); |
|
113 | + add_filter('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', array('EED_Recaptcha', 'recaptcha_response'), 10, 1); |
|
114 | 114 | } |
115 | 115 | // admin settings |
116 | - add_action( 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', array( 'EED_Recaptcha', 'admin_settings' ), 10, 1 ); |
|
117 | - add_filter( 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', array( 'EED_Recaptcha', 'update_admin_settings' ), 10, 1 ); |
|
116 | + add_action('AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', array('EED_Recaptcha', 'admin_settings'), 10, 1); |
|
117 | + add_filter('FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', array('EED_Recaptcha', 'update_admin_settings'), 10, 1); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | * @return void |
127 | 127 | */ |
128 | 128 | public static function set_definitions() { |
129 | - if ( is_user_logged_in() ) { |
|
129 | + if (is_user_logged_in()) { |
|
130 | 130 | EED_Recaptcha::$_not_a_robot = true; |
131 | 131 | } |
132 | - define( 'RECAPTCHA_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
133 | - define( 'RECAPTCHA_BASE_URL', plugin_dir_url( __FILE__ )); |
|
132 | + define('RECAPTCHA_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
133 | + define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public static function set_late_hooks() { |
145 | 145 | add_filter( |
146 | 146 | 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
147 | - array( 'EED_Recaptcha', 'not_a_robot' ) |
|
147 | + array('EED_Recaptcha', 'not_a_robot') |
|
148 | 148 | ); |
149 | 149 | } |
150 | 150 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | * @return void |
158 | 158 | */ |
159 | 159 | public static function enqueue_styles_and_scripts() { |
160 | - wp_register_script( 'espresso_recaptcha', RECAPTCHA_BASE_URL . 'scripts' . DS . 'espresso_recaptcha.js', array( 'single_page_checkout' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
161 | - wp_register_script( 'google_recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . EE_Registry::instance()->CFG->registration->recaptcha_language, array( 'espresso_recaptcha' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
162 | - EE_Registry::$i18n_js_strings['no_SPCO_error'] = __( 'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
163 | - EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __( 'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
164 | - EE_Registry::$i18n_js_strings['recaptcha_fail'] = __( 'Please complete the anti-spam test before proceeding.', 'event_espresso' ); |
|
160 | + wp_register_script('espresso_recaptcha', RECAPTCHA_BASE_URL.'scripts'.DS.'espresso_recaptcha.js', array('single_page_checkout'), EVENT_ESPRESSO_VERSION, TRUE); |
|
161 | + wp_register_script('google_recaptcha', 'https://www.google.com/recaptcha/api.js?hl='.EE_Registry::instance()->CFG->registration->recaptcha_language, array('espresso_recaptcha'), EVENT_ESPRESSO_VERSION, TRUE); |
|
162 | + EE_Registry::$i18n_js_strings['no_SPCO_error'] = __('It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
163 | + EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __('There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
164 | + EE_Registry::$i18n_js_strings['recaptcha_fail'] = __('Please complete the anti-spam test before proceeding.', 'event_espresso'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @access public |
173 | 173 | * @param \WP $WP |
174 | 174 | */ |
175 | - public function run( $WP ) { |
|
175 | + public function run($WP) { |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -182,8 +182,7 @@ discard block |
||
182 | 182 | * @return boolean |
183 | 183 | */ |
184 | 184 | public static function not_a_robot() { |
185 | - $not_a_robot = is_bool( EED_Recaptcha::$_not_a_robot ) ? EED_Recaptcha::$_not_a_robot : |
|
186 | - EED_Recaptcha::recaptcha_passed(); |
|
185 | + $not_a_robot = is_bool(EED_Recaptcha::$_not_a_robot) ? EED_Recaptcha::$_not_a_robot : EED_Recaptcha::recaptcha_passed(); |
|
187 | 186 | return $not_a_robot; |
188 | 187 | } |
189 | 188 | |
@@ -199,22 +198,22 @@ discard block |
||
199 | 198 | */ |
200 | 199 | public static function display_recaptcha() { |
201 | 200 | // logged in means you have already passed a turing test of sorts |
202 | - if ( is_user_logged_in() ) { |
|
201 | + if (is_user_logged_in()) { |
|
203 | 202 | return; |
204 | 203 | } |
205 | 204 | // don't display if not using recaptcha or user is logged in |
206 | - if ( EE_Registry::instance()->CFG->registration->use_captcha ) { |
|
205 | + if (EE_Registry::instance()->CFG->registration->use_captcha) { |
|
207 | 206 | // only display if they have NOT passed the test yet |
208 | - if ( ! EED_Recaptcha::$_not_a_robot ) { |
|
207 | + if ( ! EED_Recaptcha::$_not_a_robot) { |
|
209 | 208 | EEH_Template::display_template( |
210 | - RECAPTCHA_BASE_PATH . DS . 'templates' . DS . 'recaptcha.template.php', |
|
209 | + RECAPTCHA_BASE_PATH.DS.'templates'.DS.'recaptcha.template.php', |
|
211 | 210 | array( |
212 | 211 | 'recaptcha_publickey' => EE_Registry::instance()->CFG->registration->recaptcha_publickey, |
213 | 212 | 'recaptcha_theme' => EE_Registry::instance()->CFG->registration->recaptcha_theme, |
214 | 213 | 'recaptcha_type' => EE_Registry::instance()->CFG->registration->recaptcha_type |
215 | 214 | ) |
216 | 215 | ); |
217 | - wp_enqueue_script( 'google_recaptcha' ); |
|
216 | + wp_enqueue_script('google_recaptcha'); |
|
218 | 217 | } |
219 | 218 | } |
220 | 219 | } |
@@ -245,17 +244,17 @@ discard block |
||
245 | 244 | */ |
246 | 245 | public static function recaptcha_passed() { |
247 | 246 | // logged in means you have already passed a turing test of sorts |
248 | - if ( is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha() ) { |
|
247 | + if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) { |
|
249 | 248 | return TRUE; |
250 | 249 | } |
251 | 250 | // was test already passed? |
252 | - $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data( 'recaptcha_passed' ); |
|
253 | - $recaptcha_passed = filter_var( $recaptcha_passed, FILTER_VALIDATE_BOOLEAN ); |
|
251 | + $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed'); |
|
252 | + $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
|
254 | 253 | // verify recaptcha |
255 | 254 | EED_Recaptcha::_get_recaptcha_response(); |
256 | - if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response ) { |
|
255 | + if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
257 | 256 | $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
258 | - EE_Registry::instance()->SSN->set_session_data( array( 'recaptcha_passed' => $recaptcha_passed )); |
|
257 | + EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
|
259 | 258 | EE_Registry::instance()->SSN->update(); |
260 | 259 | } |
261 | 260 | EED_Recaptcha::$_not_a_robot = $recaptcha_passed; |
@@ -271,8 +270,8 @@ discard block |
||
271 | 270 | * @param array $recaptcha_response |
272 | 271 | * @return boolean |
273 | 272 | */ |
274 | - public static function recaptcha_response( $recaptcha_response = array() ) { |
|
275 | - if ( EED_Recaptcha::_bypass_recaptcha() ) { |
|
273 | + public static function recaptcha_response($recaptcha_response = array()) { |
|
274 | + if (EED_Recaptcha::_bypass_recaptcha()) { |
|
276 | 275 | $recaptcha_response['bypass_recaptcha'] = TRUE; |
277 | 276 | $recaptcha_response['recaptcha_passed'] = TRUE; |
278 | 277 | } else { |
@@ -292,16 +291,16 @@ discard block |
||
292 | 291 | */ |
293 | 292 | private static function _bypass_recaptcha() { |
294 | 293 | // an array of key value pairs that must match exactly with the incoming request, in order to bypass recaptcha for the current request ONLY |
295 | - $bypass_request_params_array = apply_filters( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array() ); |
|
294 | + $bypass_request_params_array = apply_filters('FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array()); |
|
296 | 295 | // does $bypass_request_params_array have any values ? |
297 | - if ( empty( $bypass_request_params_array )) { |
|
296 | + if (empty($bypass_request_params_array)) { |
|
298 | 297 | return FALSE; |
299 | 298 | } |
300 | 299 | // initially set bypass to TRUE |
301 | 300 | $bypass_recaptcha = TRUE; |
302 | - foreach ( $bypass_request_params_array as $key => $value ) { |
|
301 | + foreach ($bypass_request_params_array as $key => $value) { |
|
303 | 302 | // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, otherwise carry over it's value. This way, one missed setting results in no bypass |
304 | - $bypass_recaptcha = isset( $_REQUEST[ $key ] ) && $_REQUEST[ $key ] === $value ? $bypass_recaptcha : FALSE; |
|
303 | + $bypass_recaptcha = isset($_REQUEST[$key]) && $_REQUEST[$key] === $value ? $bypass_recaptcha : FALSE; |
|
305 | 304 | } |
306 | 305 | return $bypass_recaptcha; |
307 | 306 | } |
@@ -316,7 +315,7 @@ discard block |
||
316 | 315 | * @return boolean |
317 | 316 | */ |
318 | 317 | private static function _get_recaptcha_response() { |
319 | - EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get( 'g-recaptcha-response', false ); |
|
318 | + EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get('g-recaptcha-response', false); |
|
320 | 319 | } |
321 | 320 | |
322 | 321 | |
@@ -330,26 +329,26 @@ discard block |
||
330 | 329 | */ |
331 | 330 | private static function _process_recaptcha_response() { |
332 | 331 | // verify library is loaded |
333 | - if ( ! class_exists( '\\ReCaptcha\\ReCaptcha' )) { |
|
334 | - require_once( RECAPTCHA_BASE_PATH . DS . 'autoload.php' ); |
|
332 | + if ( ! class_exists('\\ReCaptcha\\ReCaptcha')) { |
|
333 | + require_once(RECAPTCHA_BASE_PATH.DS.'autoload.php'); |
|
335 | 334 | } |
336 | 335 | // The response from reCAPTCHA |
337 | 336 | EED_Recaptcha::_get_recaptcha_response(); |
338 | 337 | $recaptcha_response = EED_Recaptcha::$_recaptcha_response; |
339 | 338 | // Was there a reCAPTCHA response? |
340 | - if ( $recaptcha_response ) { |
|
339 | + if ($recaptcha_response) { |
|
341 | 340 | // if allow_url_fopen is Off, then set a different request method |
342 | - $request_method = ! ini_get( 'allow_url_fopen' ) ? new \ReCaptcha\RequestMethod\SocketPost() : null; |
|
341 | + $request_method = ! ini_get('allow_url_fopen') ? new \ReCaptcha\RequestMethod\SocketPost() : null; |
|
343 | 342 | $recaptcha = new \ReCaptcha\ReCaptcha( |
344 | 343 | EE_Registry::instance()->CFG->registration->recaptcha_privatekey, |
345 | 344 | $request_method |
346 | 345 | ); |
347 | 346 | $recaptcha_response = $recaptcha->verify( |
348 | 347 | EED_Recaptcha::$_recaptcha_response, |
349 | - $_SERVER[ 'REMOTE_ADDR' ] |
|
348 | + $_SERVER['REMOTE_ADDR'] |
|
350 | 349 | ); |
351 | 350 | } |
352 | - if ( $recaptcha_response instanceof \ReCaptcha\Response && $recaptcha_response->isSuccess() ) { |
|
351 | + if ($recaptcha_response instanceof \ReCaptcha\Response && $recaptcha_response->isSuccess()) { |
|
353 | 352 | return TRUE; |
354 | 353 | } |
355 | 354 | // sorry... it appears you can't don't know what soup or hamburgers are !!! |
@@ -393,12 +392,12 @@ discard block |
||
393 | 392 | 'subsections' => apply_filters( |
394 | 393 | 'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections', |
395 | 394 | array( |
396 | - 'main_settings_hdr' => new EE_Form_Section_HTML( EEH_HTML::h2( __( 'reCAPTCHA Anti-spam Settings', 'event_espresso' ) . EEH_Template::get_help_tab_link( 'recaptcha_info' ))), |
|
395 | + 'main_settings_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(__('reCAPTCHA Anti-spam Settings', 'event_espresso').EEH_Template::get_help_tab_link('recaptcha_info'))), |
|
397 | 396 | 'main_settings' => EED_Recaptcha::_recaptcha_main_settings(), |
398 | - 'appearance_settings_hdr' => new EE_Form_Section_HTML( EEH_HTML::h2( __( 'reCAPTCHA Appearance', 'event_espresso' ) )), |
|
397 | + 'appearance_settings_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(__('reCAPTCHA Appearance', 'event_espresso'))), |
|
399 | 398 | 'appearance_settings' => EED_Recaptcha::_recaptcha_appearance_settings(), |
400 | 399 | // 'recaptcha_example' => new EE_Form_Section_HTML( EED_Recaptcha::display_recaptcha() ), |
401 | - 'required_fields_note' => new EE_Form_Section_HTML( EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' )) |
|
400 | + 'required_fields_note' => new EE_Form_Section_HTML(EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')) |
|
402 | 401 | ) |
403 | 402 | ) |
404 | 403 | ) |
@@ -425,28 +424,28 @@ discard block |
||
425 | 424 | array( |
426 | 425 | 'use_captcha' => new EE_Yes_No_Input( |
427 | 426 | array( |
428 | - 'html_label_text' => __( 'Use reCAPTCHA', 'event_espresso' ), |
|
427 | + 'html_label_text' => __('Use reCAPTCHA', 'event_espresso'), |
|
429 | 428 | 'html_help_text' => sprintf( |
430 | - __( 'reCAPTCHA is a free service that protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.', 'event_espresso' ), |
|
429 | + __('reCAPTCHA is a free service that protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.', 'event_espresso'), |
|
431 | 430 | '<a href="https://www.google.com/recaptcha/intro/index.html">', |
432 | 431 | '</a>' |
433 | 432 | ), |
434 | - 'default' => isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE, |
|
433 | + 'default' => isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE, |
|
435 | 434 | 'display_html_label_text' => FALSE |
436 | 435 | ) |
437 | 436 | ), |
438 | 437 | 'recaptcha_publickey' => new EE_Text_Input( |
439 | 438 | array( |
440 | - 'html_label_text' => __( 'Site Key', 'event_espresso' ), |
|
441 | - 'html_help_text' => __( 'The site key is used to display the widget on your site.', 'event_espresso' ), |
|
442 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : '' |
|
439 | + 'html_label_text' => __('Site Key', 'event_espresso'), |
|
440 | + 'html_help_text' => __('The site key is used to display the widget on your site.', 'event_espresso'), |
|
441 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_publickey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_publickey) : '' |
|
443 | 442 | ) |
444 | 443 | ), |
445 | 444 | 'recaptcha_privatekey' => new EE_Text_Input( |
446 | 445 | array( |
447 | - 'html_label_text' => __( 'Secret Key', 'event_espresso' ), |
|
448 | - 'html_help_text' => __( 'The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.', 'event_espresso' ), |
|
449 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : '' |
|
446 | + 'html_label_text' => __('Secret Key', 'event_espresso'), |
|
447 | + 'html_help_text' => __('The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.', 'event_espresso'), |
|
448 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) : '' |
|
450 | 449 | ) |
451 | 450 | ) |
452 | 451 | ) |
@@ -478,81 +477,81 @@ discard block |
||
478 | 477 | array( |
479 | 478 | 'recaptcha_theme' => new EE_Radio_Button_Input( |
480 | 479 | array( |
481 | - 'light' => __( 'Light', 'event_espresso' ), |
|
482 | - 'dark' => __( 'Dark', 'event_espresso' ) |
|
480 | + 'light' => __('Light', 'event_espresso'), |
|
481 | + 'dark' => __('Dark', 'event_espresso') |
|
483 | 482 | ), |
484 | 483 | array( |
485 | - 'html_label_text' => __( 'Theme', 'event_espresso' ), |
|
486 | - 'html_help_text' => __( 'The color theme of the widget.', 'event_espresso' ), |
|
487 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->recaptcha_theme : 'light', |
|
484 | + 'html_label_text' => __('Theme', 'event_espresso'), |
|
485 | + 'html_help_text' => __('The color theme of the widget.', 'event_espresso'), |
|
486 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_theme) ? EE_Registry::instance()->CFG->registration->recaptcha_theme : 'light', |
|
488 | 487 | 'display_html_label_text' => FALSE |
489 | 488 | ) |
490 | 489 | ), |
491 | 490 | 'recaptcha_type' => new EE_Radio_Button_Input( |
492 | 491 | array( |
493 | - 'image' => __( 'Image', 'event_espresso' ), |
|
494 | - 'audio' => __( 'Audio', 'event_espresso' ) |
|
492 | + 'image' => __('Image', 'event_espresso'), |
|
493 | + 'audio' => __('Audio', 'event_espresso') |
|
495 | 494 | ), |
496 | 495 | array( |
497 | - 'html_label_text' => __( 'Type', 'event_espresso' ), |
|
498 | - 'html_help_text' => __( 'The type of CAPTCHA to serve.', 'event_espresso' ), |
|
499 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_type ) ? EE_Registry::instance()->CFG->registration->recaptcha_type : 'image', |
|
496 | + 'html_label_text' => __('Type', 'event_espresso'), |
|
497 | + 'html_help_text' => __('The type of CAPTCHA to serve.', 'event_espresso'), |
|
498 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_type) ? EE_Registry::instance()->CFG->registration->recaptcha_type : 'image', |
|
500 | 499 | 'display_html_label_text' =>FALSE |
501 | 500 | ) |
502 | 501 | ), |
503 | 502 | 'recaptcha_language' => new EE_Select_Input( |
504 | 503 | array( |
505 | - 'ar' => __( 'Arabic', 'event_espresso' ), |
|
506 | - 'bg' => __( 'Bulgarian', 'event_espresso' ), |
|
507 | - 'ca' => __( 'Catalan', 'event_espresso' ), |
|
508 | - 'zh-CN' => __( 'Chinese (Simplified)', 'event_espresso' ), |
|
509 | - 'zh-TW' => __( 'Chinese (Traditional) ', 'event_espresso' ), |
|
510 | - 'hr' => __( 'Croatian', 'event_espresso' ), |
|
511 | - 'cs' => __( 'Czech', 'event_espresso' ), |
|
512 | - 'da' => __( 'Danish', 'event_espresso' ), |
|
513 | - 'nl' => __( 'Dutch', 'event_espresso' ), |
|
514 | - 'en-GB' => __( 'English (UK)', 'event_espresso' ), |
|
515 | - 'en' => __( 'English (US)', 'event_espresso' ), |
|
516 | - 'fil' => __( 'Filipino', 'event_espresso' ), |
|
517 | - 'fi' => __( 'Finnish', 'event_espresso' ), |
|
518 | - 'fr' => __( 'French', 'event_espresso' ), |
|
519 | - 'fr-CA' => __( 'French (Canadian)', 'event_espresso' ), |
|
520 | - 'de' => __( 'German', 'event_espresso' ), |
|
521 | - 'de-AT' => __( 'German (Austria)', 'event_espresso' ), |
|
522 | - 'de-CH' => __( 'German (Switzerland)', 'event_espresso' ), |
|
523 | - 'el' => __( 'Greek', 'event_espresso' ), |
|
524 | - 'iw' => __( 'Hebrew', 'event_espresso' ), |
|
525 | - 'hi' => __( 'Hindi', 'event_espresso' ), |
|
526 | - 'hu' => __( 'Hungarian', 'event_espresso' ), |
|
527 | - 'id' => __( 'Indonesian', 'event_espresso' ), |
|
528 | - 'it' => __( 'Italian', 'event_espresso' ), |
|
529 | - 'ja' => __( 'Japanese', 'event_espresso' ), |
|
530 | - 'ko' => __( 'Korean', 'event_espresso' ), |
|
531 | - 'lv' => __( 'Latvian', 'event_espresso' ), |
|
532 | - 'lt' => __( 'Lithuanian', 'event_espresso' ), |
|
533 | - 'no' => __( 'Norwegian', 'event_espresso' ), |
|
534 | - 'fa' => __( 'Persian', 'event_espresso' ), |
|
535 | - 'pl' => __( 'Polish', 'event_espresso' ), |
|
536 | - 'pt' => __( 'Portuguese', 'event_espresso' ), |
|
537 | - 'pt-BR' => __( 'Portuguese (Brazil)', 'event_espresso' ), |
|
538 | - 'pt-PT' => __( 'Portuguese (Portugal)', 'event_espresso' ), |
|
539 | - 'ro' => __( 'Romanian', 'event_espresso' ), |
|
540 | - 'ru' => __( 'Russian', 'event_espresso' ), |
|
541 | - 'sr' => __( 'Serbian', 'event_espresso' ), |
|
542 | - 'sk' => __( 'Slovak', 'event_espresso' ), |
|
543 | - 'sl' => __( 'Slovenian', 'event_espresso' ), |
|
544 | - 'es' => __( 'Spanish', 'event_espresso' ), |
|
545 | - 'es-419' => __( 'Spanish (Latin America)', 'event_espresso' ), |
|
546 | - 'sv' => __( 'Swedish', 'event_espresso' ), |
|
547 | - 'th' => __( 'Thai', 'event_espresso' ), |
|
548 | - 'tr' => __( 'Turkish', 'event_espresso' ), |
|
549 | - 'uk' => __( 'Ukrainian', 'event_espresso' ), |
|
550 | - 'vi' => __( 'Vietnamese', 'event_espresso') |
|
504 | + 'ar' => __('Arabic', 'event_espresso'), |
|
505 | + 'bg' => __('Bulgarian', 'event_espresso'), |
|
506 | + 'ca' => __('Catalan', 'event_espresso'), |
|
507 | + 'zh-CN' => __('Chinese (Simplified)', 'event_espresso'), |
|
508 | + 'zh-TW' => __('Chinese (Traditional) ', 'event_espresso'), |
|
509 | + 'hr' => __('Croatian', 'event_espresso'), |
|
510 | + 'cs' => __('Czech', 'event_espresso'), |
|
511 | + 'da' => __('Danish', 'event_espresso'), |
|
512 | + 'nl' => __('Dutch', 'event_espresso'), |
|
513 | + 'en-GB' => __('English (UK)', 'event_espresso'), |
|
514 | + 'en' => __('English (US)', 'event_espresso'), |
|
515 | + 'fil' => __('Filipino', 'event_espresso'), |
|
516 | + 'fi' => __('Finnish', 'event_espresso'), |
|
517 | + 'fr' => __('French', 'event_espresso'), |
|
518 | + 'fr-CA' => __('French (Canadian)', 'event_espresso'), |
|
519 | + 'de' => __('German', 'event_espresso'), |
|
520 | + 'de-AT' => __('German (Austria)', 'event_espresso'), |
|
521 | + 'de-CH' => __('German (Switzerland)', 'event_espresso'), |
|
522 | + 'el' => __('Greek', 'event_espresso'), |
|
523 | + 'iw' => __('Hebrew', 'event_espresso'), |
|
524 | + 'hi' => __('Hindi', 'event_espresso'), |
|
525 | + 'hu' => __('Hungarian', 'event_espresso'), |
|
526 | + 'id' => __('Indonesian', 'event_espresso'), |
|
527 | + 'it' => __('Italian', 'event_espresso'), |
|
528 | + 'ja' => __('Japanese', 'event_espresso'), |
|
529 | + 'ko' => __('Korean', 'event_espresso'), |
|
530 | + 'lv' => __('Latvian', 'event_espresso'), |
|
531 | + 'lt' => __('Lithuanian', 'event_espresso'), |
|
532 | + 'no' => __('Norwegian', 'event_espresso'), |
|
533 | + 'fa' => __('Persian', 'event_espresso'), |
|
534 | + 'pl' => __('Polish', 'event_espresso'), |
|
535 | + 'pt' => __('Portuguese', 'event_espresso'), |
|
536 | + 'pt-BR' => __('Portuguese (Brazil)', 'event_espresso'), |
|
537 | + 'pt-PT' => __('Portuguese (Portugal)', 'event_espresso'), |
|
538 | + 'ro' => __('Romanian', 'event_espresso'), |
|
539 | + 'ru' => __('Russian', 'event_espresso'), |
|
540 | + 'sr' => __('Serbian', 'event_espresso'), |
|
541 | + 'sk' => __('Slovak', 'event_espresso'), |
|
542 | + 'sl' => __('Slovenian', 'event_espresso'), |
|
543 | + 'es' => __('Spanish', 'event_espresso'), |
|
544 | + 'es-419' => __('Spanish (Latin America)', 'event_espresso'), |
|
545 | + 'sv' => __('Swedish', 'event_espresso'), |
|
546 | + 'th' => __('Thai', 'event_espresso'), |
|
547 | + 'tr' => __('Turkish', 'event_espresso'), |
|
548 | + 'uk' => __('Ukrainian', 'event_espresso'), |
|
549 | + 'vi' => __('Vietnamese', 'event_espresso') |
|
551 | 550 | ), |
552 | 551 | array( |
553 | - 'html_label_text' => __( 'Language', 'event_espresso' ), |
|
554 | - 'html_help_text' => __( 'Forces the widget to render in a specific language.', 'event_espresso' ), |
|
555 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en' |
|
552 | + 'html_label_text' => __('Language', 'event_espresso'), |
|
553 | + 'html_help_text' => __('Forces the widget to render in a specific language.', 'event_espresso'), |
|
554 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_language) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en' |
|
556 | 555 | ) |
557 | 556 | ) |
558 | 557 | ) |
@@ -600,25 +599,25 @@ discard block |
||
600 | 599 | * @param EE_Registration_Config $EE_Registration_Config |
601 | 600 | * @return array |
602 | 601 | */ |
603 | - public static function update_admin_settings( EE_Registration_Config $EE_Registration_Config ) { |
|
602 | + public static function update_admin_settings(EE_Registration_Config $EE_Registration_Config) { |
|
604 | 603 | try { |
605 | 604 | $recaptcha_settings_form = EED_Recaptcha::_recaptcha_settings_form(); |
606 | 605 | // if not displaying a form, then check for form submission |
607 | - if ( $recaptcha_settings_form->was_submitted() ) { |
|
606 | + if ($recaptcha_settings_form->was_submitted()) { |
|
608 | 607 | // capture form data |
609 | 608 | $recaptcha_settings_form->receive_form_submission(); |
610 | 609 | // validate form data |
611 | - if ( $recaptcha_settings_form->is_valid() ) { |
|
610 | + if ($recaptcha_settings_form->is_valid()) { |
|
612 | 611 | // grab validated data from form |
613 | 612 | $valid_data = $recaptcha_settings_form->valid_data(); |
614 | 613 | // user proofing recaptcha: If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message. |
615 | 614 | if ( |
616 | - apply_filters( 'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys', TRUE, $EE_Registration_Config ) |
|
615 | + apply_filters('FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys', TRUE, $EE_Registration_Config) |
|
617 | 616 | && $valid_data['main_settings']['use_captcha'] |
618 | - && ( ! $EE_Registration_Config->use_captcha && ( empty( $valid_data['main_settings']['recaptcha_publickey'] ) || empty( $valid_data['main_settings']['recaptcha_privatekey'] ))) |
|
617 | + && ( ! $EE_Registration_Config->use_captcha && (empty($valid_data['main_settings']['recaptcha_publickey']) || empty($valid_data['main_settings']['recaptcha_privatekey']))) |
|
619 | 618 | ) { |
620 | 619 | $valid_data['main_settings']['use_captcha'] = FALSE; |
621 | - EE_Error::add_error( __('The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
620 | + EE_Error::add_error(__('The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
622 | 621 | } |
623 | 622 | $EE_Registration_Config->use_captcha = $valid_data['main_settings']['use_captcha']; |
624 | 623 | $EE_Registration_Config->recaptcha_publickey = $valid_data['main_settings']['recaptcha_publickey']; |
@@ -627,12 +626,12 @@ discard block |
||
627 | 626 | $EE_Registration_Config->recaptcha_theme = $valid_data['appearance_settings']['recaptcha_theme']; |
628 | 627 | $EE_Registration_Config->recaptcha_language = $valid_data['appearance_settings']['recaptcha_language']; |
629 | 628 | } else { |
630 | - if ( $recaptcha_settings_form->submission_error_message() != '' ) { |
|
631 | - EE_Error::add_error( $recaptcha_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
629 | + if ($recaptcha_settings_form->submission_error_message() != '') { |
|
630 | + EE_Error::add_error($recaptcha_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
632 | 631 | } |
633 | 632 | } |
634 | 633 | } |
635 | - } catch( EE_Error $e ) { |
|
634 | + } catch (EE_Error $e) { |
|
636 | 635 | $e->get_error(); |
637 | 636 | } |
638 | 637 |
@@ -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 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | |
173 | 173 | public function get_shortcode_helper() { |
174 | - if ( ! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes ) { |
|
174 | + if ( ! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes) { |
|
175 | 175 | $this->_set_shortcode_helper(); |
176 | 176 | } |
177 | 177 | return $this->_shortcode_helper; |
@@ -185,25 +185,25 @@ discard block |
||
185 | 185 | * @param mixed (object|array) $extra_data extra incoming data (usually EE_Messages_Addressee) |
186 | 186 | * @return string parsed shortcode. |
187 | 187 | */ |
188 | - public function parser($shortcode, $data, $extra_data = array() ) { |
|
188 | + public function parser($shortcode, $data, $extra_data = array()) { |
|
189 | 189 | |
190 | 190 | //filter setup shortcodes |
191 | 191 | $this->_shortcodes = $this->get_shortcodes(); |
192 | 192 | |
193 | 193 | //we need to setup any dynamic shortcodes so that they work with the array_key_exists |
194 | - $sc = preg_match_all( '/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches ); |
|
195 | - $sc_to_verify = !empty($matches[0] ) ? $matches[0][0] . ']' : $shortcode; |
|
194 | + $sc = preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches); |
|
195 | + $sc_to_verify = ! empty($matches[0]) ? $matches[0][0].']' : $shortcode; |
|
196 | 196 | |
197 | 197 | //first we want to make sure this is a valid shortcode |
198 | - if ( !array_key_exists($sc_to_verify, $this->_shortcodes ) ) |
|
198 | + if ( ! array_key_exists($sc_to_verify, $this->_shortcodes)) |
|
199 | 199 | return false; //get out, this parser doesn't handle the incoming shortcode. |
200 | 200 | $this->_data = $data; |
201 | 201 | $this->_extra_data = $extra_data; |
202 | 202 | $this->_set_messages_properties(); |
203 | - $parsed = apply_filters( 'FHEE__' . get_class($this) . '__parser_after', $this->_parser($shortcode), $shortcode, $data, $extra_data, $this ); |
|
203 | + $parsed = apply_filters('FHEE__'.get_class($this).'__parser_after', $this->_parser($shortcode), $shortcode, $data, $extra_data, $this); |
|
204 | 204 | |
205 | 205 | //note the below filter applies to ALL shortcode parsers... be careful! |
206 | - $parsed = apply_filters( 'FHEE__EE_Shortcodes__parser_after', $parsed, $shortcode, $data, $extra_data, $this ); |
|
206 | + $parsed = apply_filters('FHEE__EE_Shortcodes__parser_after', $parsed, $shortcode, $data, $extra_data, $this); |
|
207 | 207 | return $parsed; |
208 | 208 | } |
209 | 209 | |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | * @return array array of shortcodes => description pairs |
220 | 220 | */ |
221 | 221 | public function get_shortcodes() { |
222 | - $this->_shortcodes = apply_filters( 'FHEE__' . get_class($this) . '__shortcodes', $this->_shortcodes, $this ); |
|
222 | + $this->_shortcodes = apply_filters('FHEE__'.get_class($this).'__shortcodes', $this->_shortcodes, $this); |
|
223 | 223 | |
224 | 224 | //note the below filter applies to ALL shortcode parsers... be careful! |
225 | - $this->_shortcodes = apply_filters( 'FHEE__EE_Shortcodes__shortcodes', $this->_shortcodes, $this ); |
|
225 | + $this->_shortcodes = apply_filters('FHEE__EE_Shortcodes__shortcodes', $this->_shortcodes, $this); |
|
226 | 226 | |
227 | 227 | return $this->_shortcodes; |
228 | 228 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param mixed (object|array) $data incoming data for the parser. The data could be either an object or array because there are some shortcodes that might be replaced by prepared data that has multiple items in a list (i.e. list of attendees in an event and we're showing fname/lname for each attendee). In this case data will be in an array. Otherwise the data shoudl be in a properly formatted object. The EEH_Parse_Shortcodes.helper.php describes the data object we're expecting. |
253 | 253 | * @return string parsed shortcode |
254 | 254 | */ |
255 | - abstract protected function _parser( $shortcode ); |
|
255 | + abstract protected function _parser($shortcode); |
|
256 | 256 | |
257 | 257 | |
258 | 258 | |
@@ -264,22 +264,22 @@ discard block |
||
264 | 264 | protected function _validate_list_requirements() { |
265 | 265 | |
266 | 266 | //first test to make sure we've got an array! |
267 | - if ( !is_array($this->_data) ) { |
|
268 | - throw new EE_Error( sprintf( __('Expecting an array for the data sent to %s. Instead it was %s', 'event_espresso'), get_class($this), gettype( $this->_data ) ) ); |
|
267 | + if ( ! is_array($this->_data)) { |
|
268 | + throw new EE_Error(sprintf(__('Expecting an array for the data sent to %s. Instead it was %s', 'event_espresso'), get_class($this), gettype($this->_data))); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | //next test to make sure we've got the required template in the index! |
272 | - if ( !isset( $this->_data['template'] ) ) { |
|
273 | - throw new EE_Error( sprintf( __('The incoming data does not have the required template index in its array', 'event_espresso') ) ); |
|
272 | + if ( ! isset($this->_data['template'])) { |
|
273 | + throw new EE_Error(sprintf(__('The incoming data does not have the required template index in its array', 'event_espresso'))); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | //next test to make sure we've got got a data index in the incoming data array |
277 | - if ( !isset( $this->_data['data'] ) ) |
|
278 | - throw new EE_Error( __('The incoming data does not have the required data index in its array', 'event_espresso') ); |
|
277 | + if ( ! isset($this->_data['data'])) |
|
278 | + throw new EE_Error(__('The incoming data does not have the required data index in its array', 'event_espresso')); |
|
279 | 279 | |
280 | 280 | //all is well let's make sure _extra_data always has the values needed. |
281 | 281 | //let's make sure that extra_data includes all templates (for later parsing if necessary) |
282 | - if ( empty( $this->_extra_data ) || ( empty( $this->_extra_data['data'] ) && empty( $this->_extra_data['template'] ) ) ) { |
|
282 | + if (empty($this->_extra_data) || (empty($this->_extra_data['data']) && empty($this->_extra_data['template']))) { |
|
283 | 283 | $this->_extra_data['data'] = $this->_data['data']; |
284 | 284 | $this->_extra_data['template'] = $this->_data['template']; |
285 | 285 | } |
@@ -296,16 +296,16 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return array An array with the attributes |
298 | 298 | */ |
299 | - protected function _get_shortcode_attrs( $shortcode ) { |
|
299 | + protected function _get_shortcode_attrs($shortcode) { |
|
300 | 300 | //make sure the required wp helper function is present |
301 | 301 | //require the shortcode file if necessary |
302 | - if ( ! function_exists( 'shortcode_parse_atts' ) ) { |
|
303 | - require_once( ABSPATH . WPINC . '/shortcodes.php'); |
|
302 | + if ( ! function_exists('shortcode_parse_atts')) { |
|
303 | + require_once(ABSPATH.WPINC.'/shortcodes.php'); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | //let's get any attributes that may be present and set the defaults. |
307 | - $shortcode_to_parse = str_replace( '[', '', str_replace( ']', '', $shortcode ) ); |
|
308 | - return shortcode_parse_atts( $shortcode_to_parse ); |
|
307 | + $shortcode_to_parse = str_replace('[', '', str_replace(']', '', $shortcode)); |
|
308 | + return shortcode_parse_atts($shortcode_to_parse); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | protected function _set_messages_properties() { |
322 | 322 | //should be in _extra_data |
323 | - if ( isset( $this->_extra_data['messenger'] ) ) { |
|
323 | + if (isset($this->_extra_data['messenger'])) { |
|
324 | 324 | $this->_messenger = $this->_extra_data['messenger']; |
325 | 325 | $this->_message_type = $this->_extra_data['message_type']; |
326 | 326 | $this->_context = $this->_extra_data['message'] instanceof EE_Message ? $this->_extra_data['message']->context() : ''; |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
7 | 7 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
8 | 8 | |
9 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * @param \WP_REST_Request $request |
47 | 47 | * @return \WP_REST_Response|\WP_Error |
48 | 48 | */ |
49 | - public static function handle_request_get_all( \WP_REST_Request $request) { |
|
49 | + public static function handle_request_get_all(\WP_REST_Request $request) { |
|
50 | 50 | $controller = new Read(); |
51 | - try{ |
|
51 | + try { |
|
52 | 52 | $matches = $controller->parse_route( |
53 | 53 | $request->get_route(), |
54 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~', |
|
55 | - array( 'version', 'model' ) |
|
54 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~', |
|
55 | + array('version', 'model') |
|
56 | 56 | ); |
57 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
58 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
59 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
57 | + $controller->set_requested_version($matches['version']); |
|
58 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
59 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
60 | 60 | return $controller->send_response( |
61 | 61 | new \WP_Error( |
62 | 62 | 'endpoint_parsing_error', |
63 | 63 | sprintf( |
64 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
64 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
65 | 65 | $model_name_singular |
66 | 66 | ) |
67 | 67 | ) |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | } |
70 | 70 | return $controller->send_response( |
71 | 71 | $controller->get_entities_from_model( |
72 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
72 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
73 | 73 | $request |
74 | 74 | ) |
75 | 75 | ); |
76 | - } catch( \Exception $e ) { |
|
77 | - return $controller->send_response( $e ); |
|
76 | + } catch (\Exception $e) { |
|
77 | + return $controller->send_response($e); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -84,21 +84,21 @@ discard block |
||
84 | 84 | * @param \WP_REST_Request $request |
85 | 85 | * @return \WP_REST_Response|\WP_Error |
86 | 86 | */ |
87 | - public static function handle_request_get_one( \WP_REST_Request $request ) { |
|
87 | + public static function handle_request_get_one(\WP_REST_Request $request) { |
|
88 | 88 | $controller = new Read(); |
89 | - try{ |
|
89 | + try { |
|
90 | 90 | $matches = $controller->parse_route( |
91 | 91 | $request->get_route(), |
92 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~', |
|
93 | - array( 'version', 'model', 'id' ) ); |
|
94 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
95 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
96 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
92 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~', |
|
93 | + array('version', 'model', 'id') ); |
|
94 | + $controller->set_requested_version($matches['version']); |
|
95 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
96 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
97 | 97 | return $controller->send_response( |
98 | 98 | new \WP_Error( |
99 | 99 | 'endpoint_parsing_error', |
100 | 100 | sprintf( |
101 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
101 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
102 | 102 | $model_name_singular |
103 | 103 | ) |
104 | 104 | ) |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | } |
107 | 107 | return $controller->send_response( |
108 | 108 | $controller->get_entity_from_model( |
109 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
109 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
110 | 110 | $request |
111 | 111 | ) |
112 | 112 | ); |
113 | - } catch( \Exception $e ) { |
|
114 | - return $controller->send_response( $e ); |
|
113 | + } catch (\Exception $e) { |
|
114 | + return $controller->send_response($e); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -123,40 +123,40 @@ discard block |
||
123 | 123 | * @param \WP_REST_Request $request |
124 | 124 | * @return \WP_REST_Response|\WP_Error |
125 | 125 | */ |
126 | - public static function handle_request_get_related( \WP_REST_Request $request ) { |
|
126 | + public static function handle_request_get_related(\WP_REST_Request $request) { |
|
127 | 127 | $controller = new Read(); |
128 | - try{ |
|
128 | + try { |
|
129 | 129 | $matches = $controller->parse_route( |
130 | 130 | $request->get_route(), |
131 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~', |
|
132 | - array( 'version', 'model', 'id', 'related_model' ) |
|
131 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~', |
|
132 | + array('version', 'model', 'id', 'related_model') |
|
133 | 133 | ); |
134 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
135 | - $main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
136 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) { |
|
134 | + $controller->set_requested_version($matches['version']); |
|
135 | + $main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
136 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) { |
|
137 | 137 | return $controller->send_response( |
138 | 138 | new \WP_Error( |
139 | 139 | 'endpoint_parsing_error', |
140 | 140 | sprintf( |
141 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
141 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
142 | 142 | $main_model_name_singular |
143 | 143 | ) |
144 | 144 | ) |
145 | 145 | ); |
146 | 146 | } |
147 | - $main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular ); |
|
147 | + $main_model = $controller->get_model_version_info()->load_model($main_model_name_singular); |
|
148 | 148 | //assume the related model name is plural and try to find the model's name |
149 | - $related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] ); |
|
150 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
149 | + $related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']); |
|
150 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
151 | 151 | //so the word didn't singularize well. Maybe that's just because it's a singular word? |
152 | - $related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] ); |
|
152 | + $related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']); |
|
153 | 153 | } |
154 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
154 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
155 | 155 | return $controller->send_response( |
156 | 156 | new \WP_Error( |
157 | 157 | 'endpoint_parsing_error', |
158 | 158 | sprintf( |
159 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
159 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
160 | 160 | $related_model_name_singular |
161 | 161 | ) |
162 | 162 | ) |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | |
166 | 166 | return $controller->send_response( |
167 | 167 | $controller->get_entities_from_relation( |
168 | - $request->get_param( 'id' ), |
|
169 | - $main_model->related_settings_for( $related_model_name_singular ) , |
|
168 | + $request->get_param('id'), |
|
169 | + $main_model->related_settings_for($related_model_name_singular), |
|
170 | 170 | $request |
171 | 171 | ) |
172 | 172 | ); |
173 | - } catch( \Exception $e ) { |
|
174 | - return $controller->send_response( $e ); |
|
173 | + } catch (\Exception $e) { |
|
174 | + return $controller->send_response($e); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -184,28 +184,28 @@ discard block |
||
184 | 184 | * @param \WP_REST_Request $request |
185 | 185 | * @return array |
186 | 186 | */ |
187 | - public function get_entities_from_model( $model, $request) { |
|
188 | - $query_params = $this->create_model_query_params( $model, $request->get_params() ); |
|
189 | - if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) { |
|
190 | - $model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ); |
|
187 | + public function get_entities_from_model($model, $request) { |
|
188 | + $query_params = $this->create_model_query_params($model, $request->get_params()); |
|
189 | + if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) { |
|
190 | + $model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()); |
|
191 | 191 | return new \WP_Error( |
192 | - sprintf( 'rest_%s_cannot_list', $model_name_plural ), |
|
192 | + sprintf('rest_%s_cannot_list', $model_name_plural), |
|
193 | 193 | sprintf( |
194 | - __( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ), |
|
194 | + __('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'), |
|
195 | 195 | $model_name_plural, |
196 | - Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) |
|
196 | + Capabilities::get_missing_permissions_string($model, $query_params['caps']) |
|
197 | 197 | ), |
198 | - array( 'status' => 403 ) |
|
198 | + array('status' => 403) |
|
199 | 199 | ); |
200 | 200 | } |
201 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
202 | - $this->_set_headers_from_query_params( $model, $query_params ); |
|
201 | + if ( ! $request->get_header('no_rest_headers')) { |
|
202 | + $this->_set_headers_from_query_params($model, $query_params); |
|
203 | 203 | } |
204 | 204 | /** @type array $results */ |
205 | - $results = $model->get_all_wpdb_results( $query_params ); |
|
205 | + $results = $model->get_all_wpdb_results($query_params); |
|
206 | 206 | $nice_results = array( ); |
207 | - foreach ( $results as $result ) { |
|
208 | - $nice_results[ ] = $this->create_entity_from_wpdb_result( |
|
207 | + foreach ($results as $result) { |
|
208 | + $nice_results[] = $this->create_entity_from_wpdb_result( |
|
209 | 209 | $model, |
210 | 210 | $result, |
211 | 211 | $request |
@@ -226,64 +226,64 @@ discard block |
||
226 | 226 | * @param \WP_REST_Request $request |
227 | 227 | * @return array |
228 | 228 | */ |
229 | - public function get_entities_from_relation( $id, $relation, $request ) { |
|
230 | - $context = $this->validate_context( $request->get_param( 'caps' )); |
|
229 | + public function get_entities_from_relation($id, $relation, $request) { |
|
230 | + $context = $this->validate_context($request->get_param('caps')); |
|
231 | 231 | $model = $relation->get_this_model(); |
232 | 232 | $related_model = $relation->get_other_model(); |
233 | 233 | //check if they can access the 1st model object |
234 | - $query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 ); |
|
235 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
234 | + $query_params = array(array($model->primary_key_name() => $id), 'limit' => 1); |
|
235 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
236 | 236 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
237 | 237 | } |
238 | 238 | $restricted_query_params = $query_params; |
239 | - $restricted_query_params[ 'caps' ] = $context; |
|
240 | - $this->_set_debug_info( 'main model query params', $restricted_query_params ); |
|
241 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) ); |
|
239 | + $restricted_query_params['caps'] = $context; |
|
240 | + $this->_set_debug_info('main model query params', $restricted_query_params); |
|
241 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context)); |
|
242 | 242 | |
243 | - if( |
|
243 | + if ( |
|
244 | 244 | ! ( |
245 | - Capabilities::current_user_has_partial_access_to( $related_model, $context ) |
|
246 | - && $model->exists( $restricted_query_params ) |
|
245 | + Capabilities::current_user_has_partial_access_to($related_model, $context) |
|
246 | + && $model->exists($restricted_query_params) |
|
247 | 247 | ) |
248 | - ){ |
|
249 | - if( $relation instanceof \EE_Belongs_To_Relation ) { |
|
250 | - $related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() ); |
|
251 | - }else{ |
|
252 | - $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() ); |
|
248 | + ) { |
|
249 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
250 | + $related_model_name_maybe_plural = strtolower($related_model->get_this_model_name()); |
|
251 | + } else { |
|
252 | + $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name()); |
|
253 | 253 | } |
254 | 254 | return new \WP_Error( |
255 | - sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ), |
|
255 | + sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural), |
|
256 | 256 | sprintf( |
257 | - __( 'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ), |
|
257 | + __('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'), |
|
258 | 258 | $related_model_name_maybe_plural, |
259 | 259 | $relation->get_this_model()->get_this_model_name(), |
260 | 260 | implode( |
261 | 261 | ',', |
262 | 262 | array_keys( |
263 | - Capabilities::get_missing_permissions( $related_model, $context ) |
|
263 | + Capabilities::get_missing_permissions($related_model, $context) |
|
264 | 264 | ) |
265 | 265 | ) |
266 | 266 | ), |
267 | - array( 'status' => 403 ) |
|
267 | + array('status' => 403) |
|
268 | 268 | ); |
269 | 269 | } |
270 | - $query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() ); |
|
271 | - $query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id; |
|
272 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
273 | - $query_params[ 'caps' ] = $context; |
|
274 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
275 | - $this->_set_headers_from_query_params( $relation->get_other_model(), $query_params ); |
|
270 | + $query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params()); |
|
271 | + $query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id; |
|
272 | + $query_params['default_where_conditions'] = 'none'; |
|
273 | + $query_params['caps'] = $context; |
|
274 | + if ( ! $request->get_header('no_rest_headers')) { |
|
275 | + $this->_set_headers_from_query_params($relation->get_other_model(), $query_params); |
|
276 | 276 | } |
277 | 277 | /** @type array $results */ |
278 | - $results = $relation->get_other_model()->get_all_wpdb_results( $query_params ); |
|
278 | + $results = $relation->get_other_model()->get_all_wpdb_results($query_params); |
|
279 | 279 | $nice_results = array(); |
280 | - foreach( $results as $result ) { |
|
280 | + foreach ($results as $result) { |
|
281 | 281 | $nice_result = $this->create_entity_from_wpdb_result( |
282 | 282 | $relation->get_other_model(), |
283 | 283 | $result, |
284 | 284 | $request |
285 | 285 | ); |
286 | - if( $relation instanceof \EE_HABTM_Relation ) { |
|
286 | + if ($relation instanceof \EE_HABTM_Relation) { |
|
287 | 287 | //put the unusual stuff (properties from the HABTM relation) first, and make sure |
288 | 288 | //if there are conflicts we prefer the properties from the main model |
289 | 289 | $join_model_result = $this->create_entity_from_wpdb_result( |
@@ -291,18 +291,18 @@ discard block |
||
291 | 291 | $result, |
292 | 292 | $request |
293 | 293 | ); |
294 | - $joined_result = array_merge( $nice_result, $join_model_result ); |
|
294 | + $joined_result = array_merge($nice_result, $join_model_result); |
|
295 | 295 | //but keep the meta stuff from the main model |
296 | - if( isset( $nice_result['meta'] ) ){ |
|
296 | + if (isset($nice_result['meta'])) { |
|
297 | 297 | $joined_result['meta'] = $nice_result['meta']; |
298 | 298 | } |
299 | 299 | $nice_result = $joined_result; |
300 | 300 | } |
301 | 301 | $nice_results[] = $nice_result; |
302 | 302 | } |
303 | - if( $relation instanceof \EE_Belongs_To_Relation ){ |
|
304 | - return array_shift( $nice_results ); |
|
305 | - }else{ |
|
303 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
304 | + return array_shift($nice_results); |
|
305 | + } else { |
|
306 | 306 | return $nice_results; |
307 | 307 | } |
308 | 308 | } |
@@ -315,30 +315,30 @@ discard block |
||
315 | 315 | * @param array $query_params |
316 | 316 | * @return void |
317 | 317 | */ |
318 | - protected function _set_headers_from_query_params( $model, $query_params ) { |
|
319 | - $this->_set_debug_info( 'model query params', $query_params ); |
|
320 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) ); |
|
318 | + protected function _set_headers_from_query_params($model, $query_params) { |
|
319 | + $this->_set_debug_info('model query params', $query_params); |
|
320 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps'])); |
|
321 | 321 | //normally the limit to a 2-part array, where the 2nd item is the limit |
322 | - if( ! isset( $query_params[ 'limit' ] ) ) { |
|
323 | - $query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
322 | + if ( ! isset($query_params['limit'])) { |
|
323 | + $query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
324 | 324 | } |
325 | - if( is_array( $query_params[ 'limit' ] ) ) { |
|
326 | - $limit_parts = $query_params[ 'limit' ]; |
|
325 | + if (is_array($query_params['limit'])) { |
|
326 | + $limit_parts = $query_params['limit']; |
|
327 | 327 | } else { |
328 | - $limit_parts = explode(',', $query_params[ 'limit' ] ); |
|
329 | - if( count( $limit_parts ) == 1 ){ |
|
330 | - $limit_parts = array(0, $limit_parts[ 0 ] ); |
|
328 | + $limit_parts = explode(',', $query_params['limit']); |
|
329 | + if (count($limit_parts) == 1) { |
|
330 | + $limit_parts = array(0, $limit_parts[0]); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | //remove the group by and having parts of the query, as those will |
334 | 334 | //make the sql query return an array of values, instead of just a single value |
335 | - unset( $query_params[ 'group_by' ], $query_params[ 'having' ], $query_params[ 'limit' ] ); |
|
336 | - $count = $model->count( $query_params, null, true ); |
|
335 | + unset($query_params['group_by'], $query_params['having'], $query_params['limit']); |
|
336 | + $count = $model->count($query_params, null, true); |
|
337 | 337 | |
338 | - $pages = $count / $limit_parts[ 1 ]; |
|
339 | - $this->_set_response_header( 'Total', $count, false ); |
|
340 | - $this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false ); |
|
341 | - $this->_set_response_header( 'TotalPages', ceil( $pages ), false ); |
|
338 | + $pages = $count / $limit_parts[1]; |
|
339 | + $this->_set_response_header('Total', $count, false); |
|
340 | + $this->_set_response_header('PageSize', $limit_parts[1], false); |
|
341 | + $this->_set_response_header('TotalPages', ceil($pages), false); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
@@ -351,47 +351,47 @@ discard block |
||
351 | 351 | * @param string $deprecated no longer used |
352 | 352 | * @return array ready for being converted into json for sending to client |
353 | 353 | */ |
354 | - public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) { |
|
355 | - if( ! $rest_request instanceof \WP_REST_Request ) { |
|
354 | + public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) { |
|
355 | + if ( ! $rest_request instanceof \WP_REST_Request) { |
|
356 | 356 | //ok so this was called in the old style, where the 3rd arg was |
357 | 357 | //$include, and the 4th arg was $context |
358 | 358 | //now setup the request just to avoid fatal errors, although we won't be able |
359 | 359 | //to truly make use of it because it's kinda devoid of info |
360 | 360 | $rest_request = new \WP_REST_Request(); |
361 | - $rest_request->set_param( 'include', $rest_request ); |
|
362 | - $rest_request->set_param( 'caps', $deprecated ); |
|
361 | + $rest_request->set_param('include', $rest_request); |
|
362 | + $rest_request->set_param('caps', $deprecated); |
|
363 | 363 | } |
364 | - if( $rest_request->get_param( 'caps' ) == null ) { |
|
365 | - $rest_request->set_param( 'caps', \EEM_Base::caps_read ); |
|
364 | + if ($rest_request->get_param('caps') == null) { |
|
365 | + $rest_request->set_param('caps', \EEM_Base::caps_read); |
|
366 | 366 | } |
367 | - $entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row ); |
|
368 | - $entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array ); |
|
369 | - $entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array ); |
|
370 | - $entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request ); |
|
371 | - $entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array ); |
|
367 | + $entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row); |
|
368 | + $entity_array = $this->_add_extra_fields($model, $db_row, $entity_array); |
|
369 | + $entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array); |
|
370 | + $entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request); |
|
371 | + $entity_array = $this->_include_requested_models($model, $rest_request, $entity_array); |
|
372 | 372 | $entity_array = apply_filters( |
373 | 373 | 'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal', |
374 | 374 | $entity_array, |
375 | 375 | $model, |
376 | - $rest_request->get_param( 'caps' ), |
|
376 | + $rest_request->get_param('caps'), |
|
377 | 377 | $rest_request, |
378 | 378 | $this |
379 | 379 | ); |
380 | 380 | $result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields( |
381 | 381 | $entity_array, |
382 | 382 | $model, |
383 | - $rest_request->get_param( 'caps' ), |
|
383 | + $rest_request->get_param('caps'), |
|
384 | 384 | $this->get_model_version_info() |
385 | 385 | ); |
386 | 386 | $this->_set_debug_info( |
387 | 387 | 'inaccessible fields', |
388 | - array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) ) |
|
388 | + array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields)) |
|
389 | 389 | ); |
390 | 390 | return apply_filters( |
391 | 391 | 'FHEE__Read__create_entity_from_wpdb_results__entity_return', |
392 | 392 | $result_without_inaccessible_fields, |
393 | 393 | $model, |
394 | - $rest_request->get_param( 'caps' ) |
|
394 | + $rest_request->get_param('caps') |
|
395 | 395 | ); |
396 | 396 | } |
397 | 397 | |
@@ -403,38 +403,38 @@ discard block |
||
403 | 403 | * @param array $db_row |
404 | 404 | * @return array entity mostly ready for converting to JSON and sending in the response |
405 | 405 | */ |
406 | - protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) { |
|
407 | - $result = $model->deduce_fields_n_values_from_cols_n_values( $db_row ); |
|
408 | - $result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) ); |
|
409 | - foreach( $result as $field_name => $raw_field_value ) { |
|
406 | + protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) { |
|
407 | + $result = $model->deduce_fields_n_values_from_cols_n_values($db_row); |
|
408 | + $result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model)); |
|
409 | + foreach ($result as $field_name => $raw_field_value) { |
|
410 | 410 | $field_obj = $model->field_settings_for($field_name); |
411 | - $field_value = $field_obj->prepare_for_set_from_db( $raw_field_value ); |
|
412 | - if( $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_ignored() ) ){ |
|
413 | - unset( $result[ $field_name ] ); |
|
414 | - }elseif( |
|
415 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() ) |
|
416 | - ){ |
|
417 | - $result[ $field_name ] = array( |
|
418 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
419 | - 'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
411 | + $field_value = $field_obj->prepare_for_set_from_db($raw_field_value); |
|
412 | + if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) { |
|
413 | + unset($result[$field_name]); |
|
414 | + }elseif ( |
|
415 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format()) |
|
416 | + ) { |
|
417 | + $result[$field_name] = array( |
|
418 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
419 | + 'rendered' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
420 | 420 | ); |
421 | - }elseif( |
|
422 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() ) |
|
423 | - ){ |
|
424 | - $result[ $field_name ] = array( |
|
425 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
426 | - 'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
421 | + }elseif ( |
|
422 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format()) |
|
423 | + ) { |
|
424 | + $result[$field_name] = array( |
|
425 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
426 | + 'pretty' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
427 | 427 | ); |
428 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
429 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
428 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
429 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
430 | 430 | $field_obj, |
431 | 431 | $field_value, |
432 | 432 | $this->get_model_version_info()->requested_version() |
433 | 433 | ); |
434 | 434 | } else { |
435 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
435 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
436 | 436 | $field_obj, |
437 | - $field_obj->prepare_for_get( $field_value ), |
|
437 | + $field_obj->prepare_for_get($field_value), |
|
438 | 438 | $this->get_model_version_info()->requested_version() |
439 | 439 | ); |
440 | 440 | } |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | * @param array $entity_array |
450 | 450 | * @return array modified entity |
451 | 451 | */ |
452 | - protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) { |
|
453 | - if( $model instanceof \EEM_CPT_Base ) { |
|
454 | - $entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ); |
|
452 | + protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) { |
|
453 | + if ($model instanceof \EEM_CPT_Base) { |
|
454 | + $entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]); |
|
455 | 455 | } |
456 | 456 | return $entity_array; |
457 | 457 | } |
@@ -465,20 +465,20 @@ discard block |
||
465 | 465 | * @param array $entity_array |
466 | 466 | * @return array the _links item in the entity |
467 | 467 | */ |
468 | - protected function _get_entity_links( $model, $db_row, $entity_array ) { |
|
468 | + protected function _get_entity_links($model, $db_row, $entity_array) { |
|
469 | 469 | //add basic links |
470 | 470 | $links = array( |
471 | 471 | 'self' => array( |
472 | 472 | array( |
473 | 473 | 'href' => $this->get_versioned_link_to( |
474 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] |
|
474 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()] |
|
475 | 475 | ) |
476 | 476 | ) |
477 | 477 | ), |
478 | 478 | 'collection' => array( |
479 | 479 | array( |
480 | 480 | 'href' => $this->get_versioned_link_to( |
481 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) |
|
481 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()) |
|
482 | 482 | ) |
483 | 483 | ) |
484 | 484 | ), |
@@ -486,24 +486,24 @@ discard block |
||
486 | 486 | |
487 | 487 | //add link to the wp core endpoint, if wp api is active |
488 | 488 | global $wp_rest_server; |
489 | - if( $model instanceof \EEM_CPT_Base && |
|
489 | + if ($model instanceof \EEM_CPT_Base && |
|
490 | 490 | $wp_rest_server instanceof \WP_REST_Server && |
491 | - $wp_rest_server->get_route_options( '/wp/v2/posts' ) ) { |
|
492 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array( |
|
491 | + $wp_rest_server->get_route_options('/wp/v2/posts')) { |
|
492 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array( |
|
493 | 493 | array( |
494 | - 'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ), |
|
494 | + 'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]), |
|
495 | 495 | 'single' => true |
496 | 496 | ) |
497 | 497 | ); |
498 | 498 | } |
499 | 499 | |
500 | 500 | //add links to related models |
501 | - foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
502 | - $related_model_part = Read::get_related_entity_name( $relation_name, $relation_obj ); |
|
503 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array( |
|
501 | + foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) { |
|
502 | + $related_model_part = Read::get_related_entity_name($relation_name, $relation_obj); |
|
503 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array( |
|
504 | 504 | array( |
505 | 505 | 'href' => $this->get_versioned_link_to( |
506 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part |
|
506 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part |
|
507 | 507 | ), |
508 | 508 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false |
509 | 509 | ) |
@@ -519,51 +519,51 @@ discard block |
||
519 | 519 | * @param array $entity_array |
520 | 520 | * @return array the modified entity |
521 | 521 | */ |
522 | - protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array ) { |
|
523 | - $includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' ); |
|
524 | - $includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model ); |
|
522 | + protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array) { |
|
523 | + $includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), ''); |
|
524 | + $includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model); |
|
525 | 525 | //if they passed in * or didn't specify any includes, return everything |
526 | - if( ! in_array( '*', $includes_for_this_model ) |
|
527 | - && ! empty( $includes_for_this_model ) ) { |
|
528 | - if( $model->has_primary_key_field() ) { |
|
526 | + if ( ! in_array('*', $includes_for_this_model) |
|
527 | + && ! empty($includes_for_this_model)) { |
|
528 | + if ($model->has_primary_key_field()) { |
|
529 | 529 | //always include the primary key. ya just gotta know that at least |
530 | 530 | $includes_for_this_model[] = $model->primary_key_name(); |
531 | 531 | } |
532 | - if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) { |
|
532 | + if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) { |
|
533 | 533 | $includes_for_this_model[] = '_calculated_fields'; |
534 | 534 | } |
535 | - $entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) ); |
|
535 | + $entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model)); |
|
536 | 536 | } |
537 | - $relation_settings = $this->get_model_version_info()->relation_settings( $model ); |
|
538 | - foreach( $relation_settings as $relation_name => $relation_obj ) { |
|
537 | + $relation_settings = $this->get_model_version_info()->relation_settings($model); |
|
538 | + foreach ($relation_settings as $relation_name => $relation_obj) { |
|
539 | 539 | $related_fields_to_include = $this->explode_and_get_items_prefixed_with( |
540 | - $rest_request->get_param( 'include' ), |
|
540 | + $rest_request->get_param('include'), |
|
541 | 541 | $relation_name |
542 | 542 | ); |
543 | 543 | $related_fields_to_calculate = $this->explode_and_get_items_prefixed_with( |
544 | - $rest_request->get_param( 'calculate' ), |
|
544 | + $rest_request->get_param('calculate'), |
|
545 | 545 | $relation_name |
546 | 546 | ); |
547 | 547 | //did they specify they wanted to include a related model, or |
548 | 548 | //specific fields from a related model? |
549 | 549 | //or did they specify to calculate a field from a related model? |
550 | - if( $related_fields_to_include || $related_fields_to_calculate ) { |
|
550 | + if ($related_fields_to_include || $related_fields_to_calculate) { |
|
551 | 551 | //if so, we should include at least some part of the related model |
552 | 552 | $pretend_related_request = new \WP_REST_Request(); |
553 | 553 | $pretend_related_request->set_query_params( |
554 | 554 | array( |
555 | - 'caps' => $rest_request->get_param( 'caps' ), |
|
555 | + 'caps' => $rest_request->get_param('caps'), |
|
556 | 556 | 'include' => $related_fields_to_include, |
557 | 557 | 'calculate' => $related_fields_to_calculate, |
558 | 558 | ) |
559 | 559 | ); |
560 | - $pretend_related_request->add_header( 'no_rest_headers', true ); |
|
560 | + $pretend_related_request->add_header('no_rest_headers', true); |
|
561 | 561 | $related_results = $this->get_entities_from_relation( |
562 | - $entity_array[ $model->primary_key_name() ], |
|
562 | + $entity_array[$model->primary_key_name()], |
|
563 | 563 | $relation_obj, |
564 | 564 | $pretend_related_request |
565 | 565 | ); |
566 | - $entity_array[ Read::get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error |
|
566 | + $entity_array[Read::get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error |
|
567 | 567 | ? null |
568 | 568 | : $related_results; |
569 | 569 | } |
@@ -577,8 +577,8 @@ discard block |
||
577 | 577 | * @param array $arr |
578 | 578 | * @return array |
579 | 579 | */ |
580 | - private function _remove_model_names_from_array( $arr ) { |
|
581 | - return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) ); |
|
580 | + private function _remove_model_names_from_array($arr) { |
|
581 | + return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models)); |
|
582 | 582 | } |
583 | 583 | /** |
584 | 584 | * Gets the calculated fields for the response |
@@ -588,15 +588,15 @@ discard block |
||
588 | 588 | * @param \WP_REST_Request $rest_request |
589 | 589 | * @return array the _calculations item in the entity |
590 | 590 | */ |
591 | - protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) { |
|
591 | + protected function _get_entity_calculations($model, $wpdb_row, $rest_request) { |
|
592 | 592 | $calculated_fields = $this->explode_and_get_items_prefixed_with( |
593 | - $rest_request->get_param( 'calculate' ), |
|
593 | + $rest_request->get_param('calculate'), |
|
594 | 594 | '' |
595 | 595 | ); |
596 | 596 | //note: setting calculate=* doesn't do anything |
597 | 597 | $calculated_fields_to_return = new \stdClass(); |
598 | - foreach( $calculated_fields as $field_to_calculate ) { |
|
599 | - try{ |
|
598 | + foreach ($calculated_fields as $field_to_calculate) { |
|
599 | + try { |
|
600 | 600 | $calculated_fields_to_return->$field_to_calculate = Model_Data_Translator::prepare_field_value_for_json( |
601 | 601 | null, |
602 | 602 | $this->_fields_calculator->retrieve_calculated_field_value( |
@@ -608,10 +608,10 @@ discard block |
||
608 | 608 | ), |
609 | 609 | $this->get_model_version_info()->requested_version() |
610 | 610 | ); |
611 | - } catch( Rest_Exception $e ) { |
|
611 | + } catch (Rest_Exception $e) { |
|
612 | 612 | //if we don't have permission to read it, just leave it out. but let devs know about the problem |
613 | 613 | $this->_set_response_header( |
614 | - 'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']', |
|
614 | + 'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']', |
|
615 | 615 | $e->getMessage(), |
616 | 616 | true |
617 | 617 | ); |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * @param string $link_part_after_version_and_slash eg "events/10/datetimes" |
626 | 626 | * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes" |
627 | 627 | */ |
628 | - public function get_versioned_link_to( $link_part_after_version_and_slash ) { |
|
628 | + public function get_versioned_link_to($link_part_after_version_and_slash) { |
|
629 | 629 | return rest_url( |
630 | 630 | \EED_Core_Rest_Api::ee_api_namespace |
631 | 631 | . $this->get_model_version_info()->requested_version() |
@@ -641,11 +641,11 @@ discard block |
||
641 | 641 | * @param \EE_Model_Relation_Base $relation_obj |
642 | 642 | * @return string |
643 | 643 | */ |
644 | - public static function get_related_entity_name( $relation_name, $relation_obj ){ |
|
645 | - if( $relation_obj instanceof \EE_Belongs_To_Relation ) { |
|
646 | - return strtolower( $relation_name ); |
|
647 | - }else{ |
|
648 | - return \EEH_Inflector::pluralize_and_lower( $relation_name ); |
|
644 | + public static function get_related_entity_name($relation_name, $relation_obj) { |
|
645 | + if ($relation_obj instanceof \EE_Belongs_To_Relation) { |
|
646 | + return strtolower($relation_name); |
|
647 | + } else { |
|
648 | + return \EEH_Inflector::pluralize_and_lower($relation_name); |
|
649 | 649 | } |
650 | 650 | } |
651 | 651 | |
@@ -658,43 +658,43 @@ discard block |
||
658 | 658 | * @param \WP_REST_Request $request |
659 | 659 | * @return array |
660 | 660 | */ |
661 | - public function get_entity_from_model( $model, $request ) { |
|
662 | - $query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1); |
|
663 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
661 | + public function get_entity_from_model($model, $request) { |
|
662 | + $query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1); |
|
663 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
664 | 664 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
665 | 665 | } |
666 | 666 | $restricted_query_params = $query_params; |
667 | - $restricted_query_params[ 'caps' ] = $this->validate_context( $request->get_param( 'caps' ) ); |
|
668 | - $this->_set_debug_info( 'model query params', $restricted_query_params ); |
|
669 | - $model_rows = $model->get_all_wpdb_results( $restricted_query_params ); |
|
670 | - if ( ! empty ( $model_rows ) ) { |
|
667 | + $restricted_query_params['caps'] = $this->validate_context($request->get_param('caps')); |
|
668 | + $this->_set_debug_info('model query params', $restricted_query_params); |
|
669 | + $model_rows = $model->get_all_wpdb_results($restricted_query_params); |
|
670 | + if ( ! empty ($model_rows)) { |
|
671 | 671 | return $this->create_entity_from_wpdb_result( |
672 | 672 | $model, |
673 | - array_shift( $model_rows ), |
|
673 | + array_shift($model_rows), |
|
674 | 674 | $request ); |
675 | 675 | } else { |
676 | 676 | //ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities |
677 | - $lowercase_model_name = strtolower( $model->get_this_model_name() ); |
|
678 | - $model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params ); |
|
679 | - if( ! empty( $model_rows_found_sans_restrictions ) ) { |
|
677 | + $lowercase_model_name = strtolower($model->get_this_model_name()); |
|
678 | + $model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params); |
|
679 | + if ( ! empty($model_rows_found_sans_restrictions)) { |
|
680 | 680 | //you got shafted- it existed but we didn't want to tell you! |
681 | 681 | return new \WP_Error( |
682 | 682 | 'rest_user_cannot_read', |
683 | 683 | sprintf( |
684 | - __( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ), |
|
685 | - strtolower( $model->get_this_model_name() ), |
|
684 | + __('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'), |
|
685 | + strtolower($model->get_this_model_name()), |
|
686 | 686 | Capabilities::get_missing_permissions_string( |
687 | 687 | $model, |
688 | - $this->validate_context( $request->get_param( 'caps' ) ) ) |
|
688 | + $this->validate_context($request->get_param('caps')) ) |
|
689 | 689 | ), |
690 | - array( 'status' => 403 ) |
|
690 | + array('status' => 403) |
|
691 | 691 | ); |
692 | 692 | } else { |
693 | 693 | //it's not you. It just doesn't exist |
694 | 694 | return new \WP_Error( |
695 | - sprintf( 'rest_%s_invalid_id', $lowercase_model_name ), |
|
696 | - sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ), |
|
697 | - array( 'status' => 404 ) |
|
695 | + sprintf('rest_%s_invalid_id', $lowercase_model_name), |
|
696 | + sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name), |
|
697 | + array('status' => 404) |
|
698 | 698 | ); |
699 | 699 | } |
700 | 700 | } |
@@ -707,14 +707,14 @@ discard block |
||
707 | 707 | * @param string $context |
708 | 708 | * @return string array key of EEM_Base::cap_contexts_to_cap_action_map() |
709 | 709 | */ |
710 | - public function validate_context( $context ) { |
|
711 | - if( ! $context ) { |
|
710 | + public function validate_context($context) { |
|
711 | + if ( ! $context) { |
|
712 | 712 | $context = \EEM_Base::caps_read; |
713 | 713 | } |
714 | 714 | $valid_contexts = \EEM_Base::valid_cap_contexts(); |
715 | - if( in_array( $context, $valid_contexts ) ){ |
|
715 | + if (in_array($context, $valid_contexts)) { |
|
716 | 716 | return $context; |
717 | - }else{ |
|
717 | + } else { |
|
718 | 718 | return \EEM_Base::caps_read; |
719 | 719 | } |
720 | 720 | } |
@@ -733,77 +733,77 @@ discard block |
||
733 | 733 | * that absolutely no results should be returned |
734 | 734 | * @throws \EE_Error |
735 | 735 | */ |
736 | - public function create_model_query_params( $model, $query_parameters ) { |
|
736 | + public function create_model_query_params($model, $query_parameters) { |
|
737 | 737 | $model_query_params = array( ); |
738 | - if ( isset( $query_parameters[ 'where' ] ) ) { |
|
739 | - $model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
740 | - $query_parameters[ 'where' ], |
|
738 | + if (isset($query_parameters['where'])) { |
|
739 | + $model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
740 | + $query_parameters['where'], |
|
741 | 741 | $model, |
742 | 742 | $this->get_model_version_info()->requested_version() |
743 | 743 | ); |
744 | 744 | } |
745 | - if ( isset( $query_parameters[ 'order_by' ] ) ) { |
|
746 | - $order_by = $query_parameters[ 'order_by' ]; |
|
747 | - } elseif ( isset( $query_parameters[ 'orderby' ] ) ) { |
|
748 | - $order_by = $query_parameters[ 'orderby' ]; |
|
749 | - }else{ |
|
745 | + if (isset($query_parameters['order_by'])) { |
|
746 | + $order_by = $query_parameters['order_by']; |
|
747 | + } elseif (isset($query_parameters['orderby'])) { |
|
748 | + $order_by = $query_parameters['orderby']; |
|
749 | + } else { |
|
750 | 750 | $order_by = null; |
751 | 751 | } |
752 | - if( $order_by !== null ){ |
|
753 | - $model_query_params[ 'order_by' ] = $order_by; |
|
752 | + if ($order_by !== null) { |
|
753 | + $model_query_params['order_by'] = $order_by; |
|
754 | 754 | } |
755 | - if ( isset( $query_parameters[ 'group_by' ] ) ) { |
|
756 | - $group_by = $query_parameters[ 'group_by' ]; |
|
757 | - } elseif ( isset( $query_parameters[ 'groupby' ] ) ) { |
|
758 | - $group_by = $query_parameters[ 'groupby' ]; |
|
759 | - }else{ |
|
760 | - $group_by = array_keys( $model->get_combined_primary_key_fields() ); |
|
755 | + if (isset($query_parameters['group_by'])) { |
|
756 | + $group_by = $query_parameters['group_by']; |
|
757 | + } elseif (isset($query_parameters['groupby'])) { |
|
758 | + $group_by = $query_parameters['groupby']; |
|
759 | + } else { |
|
760 | + $group_by = array_keys($model->get_combined_primary_key_fields()); |
|
761 | 761 | } |
762 | - if( $group_by !== null ){ |
|
763 | - $model_query_params[ 'group_by' ] = $group_by; |
|
762 | + if ($group_by !== null) { |
|
763 | + $model_query_params['group_by'] = $group_by; |
|
764 | 764 | } |
765 | - if ( isset( $query_parameters[ 'having' ] ) ) { |
|
766 | - $model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
767 | - $query_parameters[ 'having' ], |
|
765 | + if (isset($query_parameters['having'])) { |
|
766 | + $model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
767 | + $query_parameters['having'], |
|
768 | 768 | $model, |
769 | 769 | $this->get_model_version_info()->requested_version() |
770 | 770 | ); |
771 | 771 | } |
772 | - if ( isset( $query_parameters[ 'order' ] ) ) { |
|
773 | - $model_query_params[ 'order' ] = $query_parameters[ 'order' ]; |
|
772 | + if (isset($query_parameters['order'])) { |
|
773 | + $model_query_params['order'] = $query_parameters['order']; |
|
774 | 774 | } |
775 | - if ( isset( $query_parameters[ 'mine' ] ) ){ |
|
776 | - $model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params ); |
|
775 | + if (isset($query_parameters['mine'])) { |
|
776 | + $model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params); |
|
777 | 777 | } |
778 | - if( isset( $query_parameters[ 'limit' ] ) ) { |
|
778 | + if (isset($query_parameters['limit'])) { |
|
779 | 779 | //limit should be either a string like '23' or '23,43', or an array with two items in it |
780 | - if( ! is_array( $query_parameters[ 'limit' ] ) ) { |
|
781 | - $limit_array = explode(',', (string)$query_parameters['limit']); |
|
782 | - }else { |
|
783 | - $limit_array = $query_parameters[ 'limit' ]; |
|
780 | + if ( ! is_array($query_parameters['limit'])) { |
|
781 | + $limit_array = explode(',', (string) $query_parameters['limit']); |
|
782 | + } else { |
|
783 | + $limit_array = $query_parameters['limit']; |
|
784 | 784 | } |
785 | 785 | $sanitized_limit = array(); |
786 | - foreach( $limit_array as $key => $limit_part ) { |
|
787 | - if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) { |
|
786 | + foreach ($limit_array as $key => $limit_part) { |
|
787 | + if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) { |
|
788 | 788 | throw new \EE_Error( |
789 | 789 | sprintf( |
790 | - __( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ), |
|
791 | - json_encode( $query_parameters[ 'limit' ] ) |
|
790 | + __('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'), |
|
791 | + json_encode($query_parameters['limit']) |
|
792 | 792 | ) |
793 | 793 | ); |
794 | 794 | } |
795 | - $sanitized_limit[] = (int)$limit_part; |
|
795 | + $sanitized_limit[] = (int) $limit_part; |
|
796 | 796 | } |
797 | - $model_query_params[ 'limit' ] = implode( ',', $sanitized_limit ); |
|
798 | - }else{ |
|
799 | - $model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
797 | + $model_query_params['limit'] = implode(',', $sanitized_limit); |
|
798 | + } else { |
|
799 | + $model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
800 | 800 | } |
801 | - if( isset( $query_parameters[ 'caps' ] ) ) { |
|
802 | - $model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] ); |
|
803 | - }else{ |
|
804 | - $model_query_params[ 'caps' ] = \EEM_Base::caps_read; |
|
801 | + if (isset($query_parameters['caps'])) { |
|
802 | + $model_query_params['caps'] = $this->validate_context($query_parameters['caps']); |
|
803 | + } else { |
|
804 | + $model_query_params['caps'] = \EEM_Base::caps_read; |
|
805 | 805 | } |
806 | - return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model ); |
|
806 | + return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | |
@@ -815,13 +815,13 @@ discard block |
||
815 | 815 | * @param array $query_params sub-array from @see EEM_Base::get_all() |
816 | 816 | * @return array |
817 | 817 | */ |
818 | - public function prepare_rest_query_params_key_for_models( $model, $query_params ) { |
|
818 | + public function prepare_rest_query_params_key_for_models($model, $query_params) { |
|
819 | 819 | $model_ready_query_params = array(); |
820 | - foreach( $query_params as $key => $value ) { |
|
821 | - if( is_array( $value ) ) { |
|
822 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value ); |
|
823 | - }else{ |
|
824 | - $model_ready_query_params[ $key ] = $value; |
|
820 | + foreach ($query_params as $key => $value) { |
|
821 | + if (is_array($value)) { |
|
822 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value); |
|
823 | + } else { |
|
824 | + $model_ready_query_params[$key] = $value; |
|
825 | 825 | } |
826 | 826 | } |
827 | 827 | return $model_ready_query_params; |
@@ -835,13 +835,13 @@ discard block |
||
835 | 835 | * @param $query_params |
836 | 836 | * @return array |
837 | 837 | */ |
838 | - public function prepare_rest_query_params_values_for_models( $model, $query_params ) { |
|
838 | + public function prepare_rest_query_params_values_for_models($model, $query_params) { |
|
839 | 839 | $model_ready_query_params = array(); |
840 | - foreach( $query_params as $key => $value ) { |
|
841 | - if( is_array( $value ) ) { |
|
842 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value ); |
|
840 | + foreach ($query_params as $key => $value) { |
|
841 | + if (is_array($value)) { |
|
842 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value); |
|
843 | 843 | } else { |
844 | - $model_ready_query_params[ $key ] = $value; |
|
844 | + $model_ready_query_params[$key] = $value; |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | return $model_ready_query_params; |
@@ -856,33 +856,33 @@ discard block |
||
856 | 856 | * we only return strings starting with that and a period; if no prefix was specified |
857 | 857 | * we return all items containing NO periods |
858 | 858 | */ |
859 | - public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) { |
|
860 | - if( is_string( $string_to_explode ) ) { |
|
861 | - $exploded_contents = explode( ',', $string_to_explode ); |
|
862 | - } else if( is_array( $string_to_explode ) ) { |
|
859 | + public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) { |
|
860 | + if (is_string($string_to_explode)) { |
|
861 | + $exploded_contents = explode(',', $string_to_explode); |
|
862 | + } else if (is_array($string_to_explode)) { |
|
863 | 863 | $exploded_contents = $string_to_explode; |
864 | 864 | } else { |
865 | 865 | $exploded_contents = array(); |
866 | 866 | } |
867 | 867 | //if the string was empty, we want an empty array |
868 | - $exploded_contents = array_filter( $exploded_contents ); |
|
868 | + $exploded_contents = array_filter($exploded_contents); |
|
869 | 869 | $contents_with_prefix = array(); |
870 | - foreach( $exploded_contents as $item ) { |
|
871 | - $item = trim( $item ); |
|
870 | + foreach ($exploded_contents as $item) { |
|
871 | + $item = trim($item); |
|
872 | 872 | //if no prefix was provided, so we look for items with no "." in them |
873 | - if( ! $prefix ) { |
|
873 | + if ( ! $prefix) { |
|
874 | 874 | //does this item have a period? |
875 | - if( strpos( $item, '.' ) === false ) { |
|
875 | + if (strpos($item, '.') === false) { |
|
876 | 876 | //if not, then its what we're looking for |
877 | 877 | $contents_with_prefix[] = $item; |
878 | 878 | } |
879 | - } else if( strpos( $item, $prefix . '.' ) === 0 ) { |
|
879 | + } else if (strpos($item, $prefix.'.') === 0) { |
|
880 | 880 | //this item has the prefix and a period, grab it |
881 | 881 | $contents_with_prefix[] = substr( |
882 | 882 | $item, |
883 | - strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' ) |
|
883 | + strpos($item, $prefix.'.') + strlen($prefix.'.') |
|
884 | 884 | ); |
885 | - } else if( $item === $prefix ) { |
|
885 | + } else if ($item === $prefix) { |
|
886 | 886 | //this item is JUST the prefix |
887 | 887 | //so let's grab everything after, which is a blank string |
888 | 888 | $contents_with_prefix[] = ''; |
@@ -905,33 +905,33 @@ discard block |
||
905 | 905 | * the fields for that model, with the model's name removed from each. |
906 | 906 | * If $include_string was blank or '*' returns an empty array |
907 | 907 | */ |
908 | - public function extract_includes_for_this_model( $include_string, $model_name = null ) { |
|
909 | - if( is_array( $include_string ) ) { |
|
910 | - $include_string = implode( ',', $include_string ); |
|
908 | + public function extract_includes_for_this_model($include_string, $model_name = null) { |
|
909 | + if (is_array($include_string)) { |
|
910 | + $include_string = implode(',', $include_string); |
|
911 | 911 | } |
912 | - if( $include_string === '*' || $include_string === '' ) { |
|
912 | + if ($include_string === '*' || $include_string === '') { |
|
913 | 913 | return array(); |
914 | 914 | } |
915 | - $includes = explode( ',', $include_string ); |
|
915 | + $includes = explode(',', $include_string); |
|
916 | 916 | $extracted_fields_to_include = array(); |
917 | - if( $model_name ){ |
|
918 | - foreach( $includes as $field_to_include ) { |
|
919 | - $field_to_include = trim( $field_to_include ); |
|
920 | - if( strpos( $field_to_include, $model_name . '.' ) === 0 ) { |
|
917 | + if ($model_name) { |
|
918 | + foreach ($includes as $field_to_include) { |
|
919 | + $field_to_include = trim($field_to_include); |
|
920 | + if (strpos($field_to_include, $model_name.'.') === 0) { |
|
921 | 921 | //found the model name at the exact start |
922 | - $field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include ); |
|
922 | + $field_sans_model_name = str_replace($model_name.'.', '', $field_to_include); |
|
923 | 923 | $extracted_fields_to_include[] = $field_sans_model_name; |
924 | - }elseif( $field_to_include == $model_name ){ |
|
924 | + }elseif ($field_to_include == $model_name) { |
|
925 | 925 | $extracted_fields_to_include[] = '*'; |
926 | 926 | } |
927 | 927 | } |
928 | - }else{ |
|
928 | + } else { |
|
929 | 929 | //look for ones with no period |
930 | - foreach( $includes as $field_to_include ) { |
|
931 | - $field_to_include = trim( $field_to_include ); |
|
930 | + foreach ($includes as $field_to_include) { |
|
931 | + $field_to_include = trim($field_to_include); |
|
932 | 932 | if ( |
933 | - strpos( $field_to_include, '.' ) === false |
|
934 | - && ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include ) |
|
933 | + strpos($field_to_include, '.') === false |
|
934 | + && ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include) |
|
935 | 935 | ) { |
936 | 936 | $extracted_fields_to_include[] = $field_to_include; |
937 | 937 | } |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param WP_Query $wp_query |
40 | 40 | * @param array $CPT |
41 | 41 | */ |
42 | - public function __construct( $wp_query, $CPT = array() ) { |
|
43 | - if ( $wp_query instanceof WP_Query ) { |
|
42 | + public function __construct($wp_query, $CPT = array()) { |
|
43 | + if ($wp_query instanceof WP_Query) { |
|
44 | 44 | $WP_Query = $wp_query; |
45 | 45 | $this->CPT = $CPT; |
46 | 46 | } else { |
47 | - $WP_Query = isset( $wp_query[ 'WP_Query' ] ) ? $wp_query[ 'WP_Query' ] : null; |
|
48 | - $this->CPT = isset( $wp_query[ 'CPT' ] ) ? $wp_query[ 'CPT' ] : null; |
|
47 | + $WP_Query = isset($wp_query['WP_Query']) ? $wp_query['WP_Query'] : null; |
|
48 | + $this->CPT = isset($wp_query['CPT']) ? $wp_query['CPT'] : null; |
|
49 | 49 | } |
50 | 50 | // !!!!!!!!!! IMPORTANT !!!!!!!!!!!! |
51 | 51 | // here's the list of available filters in the WP_Query object |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | // 'posts_fields' |
60 | 60 | // 'posts_join' |
61 | 61 | $this->_add_filters(); |
62 | - if ( $WP_Query instanceof WP_Query ) { |
|
63 | - $WP_Query->is_espresso_event_single = is_singular() && isset( $WP_Query->query->post_type ) && $WP_Query->query->post_type == 'espresso_events' ? TRUE : FALSE; |
|
62 | + if ($WP_Query instanceof WP_Query) { |
|
63 | + $WP_Query->is_espresso_event_single = is_singular() && isset($WP_Query->query->post_type) && $WP_Query->query->post_type == 'espresso_events' ? TRUE : FALSE; |
|
64 | 64 | $WP_Query->is_espresso_event_archive = is_post_type_archive('espresso_events') ? TRUE : FALSE; |
65 | - $WP_Query->is_espresso_event_taxonomy = is_tax( 'espresso_event_categories' ) ? TRUE : FALSE; |
|
65 | + $WP_Query->is_espresso_event_taxonomy = is_tax('espresso_event_categories') ? TRUE : FALSE; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | } |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | * (which will get removed in case the next call to get_posts ISN'T |
75 | 75 | * for event CPTs) |
76 | 76 | */ |
77 | - protected function _add_filters(){ |
|
78 | - add_filter( 'posts_fields', array( $this, 'posts_fields' ), 1, 2 ); |
|
79 | - add_filter( 'posts_join', array( $this, 'posts_join' ), 1, 2 ); |
|
80 | - add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 ); |
|
77 | + protected function _add_filters() { |
|
78 | + add_filter('posts_fields', array($this, 'posts_fields'), 1, 2); |
|
79 | + add_filter('posts_join', array($this, 'posts_join'), 1, 2); |
|
80 | + add_filter('posts_where', array($this, 'posts_where'), 10, 2); |
|
81 | 81 | // add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 ); |
82 | - add_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1, 2 ); |
|
83 | - add_filter( 'posts_groupby', array( $this, 'posts_groupby' ), 1, 2 ); |
|
82 | + add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2); |
|
83 | + add_filter('posts_groupby', array($this, 'posts_groupby'), 1, 2); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | * This is to avoid applying this CPT strategy for other posts or CPTs (eg, |
91 | 91 | * we don't want to join to the datetime table when querying for venues, do we!?) |
92 | 92 | */ |
93 | - protected function _remove_filters(){ |
|
94 | - remove_filter( 'posts_fields', array( $this, 'posts_fields' ), 1 ); |
|
95 | - remove_filter( 'posts_join', array( $this, 'posts_join' ), 1 ); |
|
96 | - remove_filter( 'posts_where', array( $this, 'posts_where' ), 10 ); |
|
93 | + protected function _remove_filters() { |
|
94 | + remove_filter('posts_fields', array($this, 'posts_fields'), 1); |
|
95 | + remove_filter('posts_join', array($this, 'posts_join'), 1); |
|
96 | + remove_filter('posts_where', array($this, 'posts_where'), 10); |
|
97 | 97 | // remove_filter( 'the_posts', array( $this, 'the_posts' ), 1 ); |
98 | - remove_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1 ); |
|
99 | - remove_filter( 'posts_groupby', array( $this, 'posts_groupby' ), 1 ); |
|
98 | + remove_filter('posts_orderby', array($this, 'posts_orderby'), 1); |
|
99 | + remove_filter('posts_groupby', array($this, 'posts_groupby'), 1); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param WP_Query $wp_query |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public function posts_fields( $SQL, WP_Query $wp_query ) { |
|
112 | + public function posts_fields($SQL, WP_Query $wp_query) { |
|
113 | 113 | if ( |
114 | 114 | $wp_query instanceof WP_Query |
115 | 115 | && |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | ) |
121 | 121 | ) { |
122 | 122 | // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement |
123 | - $SQL .= ', ' . EEM_Datetime::instance()->table() . '.* ' ; |
|
124 | - if ( $wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy ) { |
|
123 | + $SQL .= ', '.EEM_Datetime::instance()->table().'.* '; |
|
124 | + if ($wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy) { |
|
125 | 125 | // because we only want to retrieve the next upcoming datetime for each event: |
126 | 126 | // add something like ", MIN( wp_esp_datetime.DTT_EVT_start ) as event_start_date " to WP Query SELECT statement |
127 | - $SQL .= ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ; |
|
127 | + $SQL .= ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date '; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | return $SQL; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @internal param \WP_Query $WP_Query |
142 | 142 | * @return string |
143 | 143 | */ |
144 | - public function posts_join( $SQL, WP_Query $wp_query ) { |
|
144 | + public function posts_join($SQL, WP_Query $wp_query) { |
|
145 | 145 | if ( |
146 | 146 | $wp_query instanceof WP_Query |
147 | 147 | && |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ) |
153 | 153 | ) { |
154 | 154 | // adds something like " LEFT JOIN wp_esp_datetime ON ( wp_esp_datetime.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
155 | - $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name() . ' ) '; |
|
155 | + $SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name().' ) '; |
|
156 | 156 | } |
157 | 157 | return $SQL; |
158 | 158 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param WP_Query $wp_query |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public function posts_where( $SQL, WP_Query $wp_query ) { |
|
170 | + public function posts_where($SQL, WP_Query $wp_query) { |
|
171 | 171 | // global $wpdb; |
172 | 172 | if ( |
173 | 173 | $wp_query instanceof WP_Query |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | || $wp_query->is_espresso_event_taxonomy |
178 | 178 | ) |
179 | 179 | ) { |
180 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive ) || ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events ) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events ) { |
|
181 | - $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . current_time( 'mysql', true ) . '" '; |
|
180 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive) || ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events) { |
|
181 | + $SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.current_time('mysql', true).'" '; |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | return $SQL; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param WP_Query $wp_query |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - public function posts_orderby( $SQL, WP_Query $wp_query ) { |
|
197 | + public function posts_orderby($SQL, WP_Query $wp_query) { |
|
198 | 198 | if ( |
199 | 199 | $wp_query instanceof WP_Query |
200 | 200 | && |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param WP_Query $wp_query |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public function posts_groupby( $SQL, WP_Query $wp_query ) { |
|
221 | + public function posts_groupby($SQL, WP_Query $wp_query) { |
|
222 | 222 | if ( |
223 | 223 | $wp_query instanceof WP_Query |
224 | 224 | && |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | // we're joining to the datetimes table, where there can be MANY datetimes for a single event, but we want to only show each event only once |
232 | 232 | // (whereas if we didn't group them by the post's ID, then we would end up with many repeats) |
233 | 233 | global $wpdb; |
234 | - $SQL = $wpdb->posts . '.ID '; |
|
234 | + $SQL = $wpdb->posts.'.ID '; |
|
235 | 235 | } |
236 | 236 | return $SQL; |
237 | 237 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @param WP_Query $wp_query |
247 | 247 | * @return array |
248 | 248 | */ |
249 | - public function the_posts( $posts, WP_Query $wp_query ) { |
|
249 | + public function the_posts($posts, WP_Query $wp_query) { |
|
250 | 250 | return $posts; |
251 | 251 | } |
252 | 252 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param $single |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public function get_EE_post_type_metadata( $meta_value = NULL, $post_id, $meta_key, $single ) { |
|
265 | + public function get_EE_post_type_metadata($meta_value = NULL, $post_id, $meta_key, $single) { |
|
266 | 266 | return $meta_value; |
267 | 267 | } |
268 | 268 |