@@ -204,7 +204,7 @@ |
||
204 | 204 | //to help avoid memory limit errors |
205 | 205 | //EEH_Debug_Tools::instance()->measure_memory( 'db content initialized for ' . get_class( $this), true ); |
206 | 206 | gc_collect_cycles(); |
207 | - }else{ |
|
207 | + } else{ |
|
208 | 208 | //ask the data migration manager to init this addon's data |
209 | 209 | //when migrations are finished because we can't do it now |
210 | 210 | EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( $this->name() ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * class constructor |
96 | 96 | */ |
97 | 97 | public function __construct() { |
98 | - add_action( 'AHEE__EE_System__load_controllers__load_admin_controllers', array( $this, 'admin_init' ) ); |
|
98 | + add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($this, 'admin_init')); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | /** |
104 | 104 | * @param mixed $version |
105 | 105 | */ |
106 | - public function set_version( $version = NULL ) { |
|
106 | + public function set_version($version = NULL) { |
|
107 | 107 | $this->_version = $version; |
108 | 108 | } |
109 | 109 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | /** |
122 | 122 | * @param mixed $min_core_version |
123 | 123 | */ |
124 | - public function set_min_core_version( $min_core_version = NULL ) { |
|
124 | + public function set_min_core_version($min_core_version = NULL) { |
|
125 | 125 | $this->_min_core_version = $min_core_version; |
126 | 126 | } |
127 | 127 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param string $addon_name |
143 | 143 | * @return boolean |
144 | 144 | */ |
145 | - public function set_name( $addon_name ) { |
|
145 | + public function set_name($addon_name) { |
|
146 | 146 | return $this->_addon_name = $addon_name; |
147 | 147 | } |
148 | 148 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | /** |
171 | 171 | * @param string $plugin_basename |
172 | 172 | */ |
173 | - public function set_plugin_basename( $plugin_basename ) { |
|
173 | + public function set_plugin_basename($plugin_basename) { |
|
174 | 174 | |
175 | 175 | $this->_plugin_basename = $plugin_basename; |
176 | 176 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | /** |
191 | 191 | * @param string $plugin_slug |
192 | 192 | */ |
193 | - public function set_plugin_slug( $plugin_slug ) { |
|
193 | + public function set_plugin_slug($plugin_slug) { |
|
194 | 194 | |
195 | 195 | $this->_plugin_slug = $plugin_slug; |
196 | 196 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @param string $plugin_action_slug |
212 | 212 | */ |
213 | - public function set_plugin_action_slug( $plugin_action_slug ) { |
|
213 | + public function set_plugin_action_slug($plugin_action_slug) { |
|
214 | 214 | |
215 | 215 | $this->_plugin_action_slug = $plugin_action_slug; |
216 | 216 | } |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | /** |
231 | 231 | * @param array $plugins_page_row |
232 | 232 | */ |
233 | - public function set_plugins_page_row( $plugins_page_row = array() ) { |
|
233 | + public function set_plugins_page_row($plugins_page_row = array()) { |
|
234 | 234 | // sigh.... check for example content that I stupidly merged to master and remove it if found |
235 | - if ( ! is_array( $plugins_page_row ) && strpos( $plugins_page_row, '<h3>Promotions Addon Upsell Info</h3>' ) !== false ) { |
|
235 | + if ( ! is_array($plugins_page_row) && strpos($plugins_page_row, '<h3>Promotions Addon Upsell Info</h3>') !== false) { |
|
236 | 236 | $plugins_page_row = ''; |
237 | 237 | } |
238 | 238 | $this->_plugins_page_row = $plugins_page_row; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | do_action("AHEE__{$classname}__new_install"); |
251 | 251 | do_action('AHEE__EE_Addon__new_install', $this); |
252 | 252 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
253 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' ) ); |
|
253 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -265,18 +265,18 @@ discard block |
||
265 | 265 | do_action("AHEE__{$classname}__reactivation"); |
266 | 266 | do_action('AHEE__EE_Addon__reactivation', $this); |
267 | 267 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
268 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' ) ); |
|
268 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | |
272 | 272 | |
273 | - public function deactivation(){ |
|
273 | + public function deactivation() { |
|
274 | 274 | $classname = get_class($this); |
275 | 275 | // echo "Deactivating $classname";die; |
276 | 276 | do_action("AHEE__{$classname}__deactivation"); |
277 | 277 | do_action('AHEE__EE_Addon__deactivation', $this); |
278 | 278 | //check if the site no longer needs to be in maintenance mode |
279 | - EE_Register_Addon::deregister( $this->name() ); |
|
279 | + EE_Register_Addon::deregister($this->name()); |
|
280 | 280 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
281 | 281 | } |
282 | 282 | |
@@ -292,16 +292,16 @@ discard block |
||
292 | 292 | * @return void |
293 | 293 | * @throws \EE_Error |
294 | 294 | */ |
295 | - public function initialize_db_if_no_migrations_required( $verify_schema = true ) { |
|
296 | - if( $verify_schema === '' ) { |
|
295 | + public function initialize_db_if_no_migrations_required($verify_schema = true) { |
|
296 | + if ($verify_schema === '') { |
|
297 | 297 | //wp core bug imo: if no args are passed to `do_action('some_hook_name')` besides the hook's name |
298 | 298 | //(ie, no 2nd or 3rd arguments), instead of calling the registered callbacks with no arguments, it |
299 | 299 | //calls them with an argument of an empty string (ie ""), which evaluates to false |
300 | 300 | //so we need to treat the empty string as if nothing had been passed, and should instead use the default |
301 | 301 | $verify_schema = true; |
302 | 302 | } |
303 | - if ( EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
304 | - if( $verify_schema ) { |
|
303 | + if (EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
304 | + if ($verify_schema) { |
|
305 | 305 | $this->initialize_db(); |
306 | 306 | } |
307 | 307 | $this->initialize_default_data(); |
@@ -319,15 +319,15 @@ discard block |
||
319 | 319 | * other data needs to be verified) |
320 | 320 | */ |
321 | 321 | EEH_Activation::initialize_db_content(); |
322 | - update_option( 'ee_flush_rewrite_rules', TRUE ); |
|
322 | + update_option('ee_flush_rewrite_rules', TRUE); |
|
323 | 323 | //in case there are lots of addons being activated at once, let's force garbage collection |
324 | 324 | //to help avoid memory limit errors |
325 | 325 | //EEH_Debug_Tools::instance()->measure_memory( 'db content initialized for ' . get_class( $this), true ); |
326 | 326 | gc_collect_cycles(); |
327 | - }else{ |
|
327 | + } else { |
|
328 | 328 | //ask the data migration manager to init this addon's data |
329 | 329 | //when migrations are finished because we can't do it now |
330 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( $this->name() ); |
|
330 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for($this->name()); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function initialize_db() { |
343 | 343 | //find the migration script that sets the database to be compatible with the code |
344 | - $current_dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms( $this->name() ); |
|
345 | - if( $current_dms_name ){ |
|
346 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $current_dms_name ); |
|
347 | - $current_data_migration_script->set_migrating( FALSE ); |
|
344 | + $current_dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms($this->name()); |
|
345 | + if ($current_dms_name) { |
|
346 | + $current_data_migration_script = EE_Registry::instance()->load_dms($current_dms_name); |
|
347 | + $current_data_migration_script->set_migrating(FALSE); |
|
348 | 348 | $current_data_migration_script->schema_changes_before_migration(); |
349 | 349 | $current_data_migration_script->schema_changes_after_migration(); |
350 | - if ( $current_data_migration_script->get_errors() ) { |
|
351 | - foreach( $current_data_migration_script->get_errors() as $error ) { |
|
352 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
350 | + if ($current_data_migration_script->get_errors()) { |
|
351 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
352 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * default data) |
382 | 382 | * @param EE_Addon $addon the addon that called this |
383 | 383 | */ |
384 | - do_action( 'AHEE__EE_Addon__initialize_default_data__begin', $this ); |
|
384 | + do_action('AHEE__EE_Addon__initialize_default_data__begin', $this); |
|
385 | 385 | //override to insert default data. It is safe to use the models here |
386 | 386 | //because the site should not be in maintenance mode |
387 | 387 | } |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
402 | 402 | //also it's possible there is new default data that needs to be added |
403 | 403 | add_action( |
404 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' ) |
|
404 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required') |
|
405 | 405 | ); |
406 | 406 | } |
407 | 407 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | do_action("AHEE__{$classname}__downgrade"); |
416 | 416 | do_action('AHEE__EE_Addon__downgrade', $this); |
417 | 417 | //it's possible there's old default data that needs to be double-checked |
418 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' ) ); |
|
418 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * plugin activation only. In the future, we'll want to do it on plugin updates too |
427 | 427 | * @return bool |
428 | 428 | */ |
429 | - public function set_db_update_option_name(){ |
|
429 | + public function set_db_update_option_name() { |
|
430 | 430 | EE_Error::doing_it_wrong(__FUNCTION__, __('EE_Addon::set_db_update_option_name was renamed to EE_Addon::set_activation_indicator_option', 'event_espresso'), '4.3.0.alpha.016'); |
431 | 431 | //let's just handle this on the next request, ok? right now we're just not really ready |
432 | 432 | return $this->set_activation_indicator_option(); |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | */ |
455 | 455 | public function set_activation_indicator_option() { |
456 | 456 | // let's just handle this on the next request, ok? right now we're just not really ready |
457 | - return update_option( $this->get_activation_indicator_option_name(), TRUE ); |
|
457 | + return update_option($this->get_activation_indicator_option_name(), TRUE); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | * Gets the name of the wp option which is used to temporarily indicate that this addon was activated |
463 | 463 | * @return string |
464 | 464 | */ |
465 | - public function get_activation_indicator_option_name(){ |
|
466 | - return 'ee_activation_' . $this->name(); |
|
465 | + public function get_activation_indicator_option_name() { |
|
466 | + return 'ee_activation_'.$this->name(); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | * Used by EE_System to set the request type of this addon. Should not be used by addon developers |
474 | 474 | * @param int $req_type |
475 | 475 | */ |
476 | - public function set_req_type( $req_type ) { |
|
476 | + public function set_req_type($req_type) { |
|
477 | 477 | $this->_req_type = $req_type; |
478 | 478 | } |
479 | 479 | |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | * of addons |
485 | 485 | */ |
486 | 486 | public function detect_req_type() { |
487 | - if( ! $this->_req_type ){ |
|
487 | + if ( ! $this->_req_type) { |
|
488 | 488 | $this->detect_activation_or_upgrade(); |
489 | 489 | } |
490 | 490 | return $this->_req_type; |
@@ -497,36 +497,36 @@ discard block |
||
497 | 497 | * Should only be called once per request |
498 | 498 | * @return void |
499 | 499 | */ |
500 | - public function detect_activation_or_upgrade(){ |
|
500 | + public function detect_activation_or_upgrade() { |
|
501 | 501 | $activation_history_for_addon = $this->get_activation_history(); |
502 | 502 | // d($activation_history_for_addon); |
503 | 503 | $request_type = EE_System::detect_req_type_given_activation_history($activation_history_for_addon, $this->get_activation_indicator_option_name(), $this->version()); |
504 | 504 | $this->set_req_type($request_type); |
505 | 505 | $classname = get_class($this); |
506 | - switch($request_type){ |
|
506 | + switch ($request_type) { |
|
507 | 507 | case EE_System::req_type_new_activation: |
508 | - do_action( "AHEE__{$classname}__detect_activations_or_upgrades__new_activation" ); |
|
509 | - do_action( 'AHEE__EE_Addon__detect_activations_or_upgrades__new_activation', $this ); |
|
508 | + do_action("AHEE__{$classname}__detect_activations_or_upgrades__new_activation"); |
|
509 | + do_action('AHEE__EE_Addon__detect_activations_or_upgrades__new_activation', $this); |
|
510 | 510 | $this->new_install(); |
511 | - $this->update_list_of_installed_versions( $activation_history_for_addon ); |
|
511 | + $this->update_list_of_installed_versions($activation_history_for_addon); |
|
512 | 512 | break; |
513 | 513 | case EE_System::req_type_reactivation: |
514 | - do_action( "AHEE__{$classname}__detect_activations_or_upgrades__reactivation" ); |
|
515 | - do_action( 'AHEE__EE_Addon__detect_activations_or_upgrades__reactivation', $this ); |
|
514 | + do_action("AHEE__{$classname}__detect_activations_or_upgrades__reactivation"); |
|
515 | + do_action('AHEE__EE_Addon__detect_activations_or_upgrades__reactivation', $this); |
|
516 | 516 | $this->reactivation(); |
517 | - $this->update_list_of_installed_versions( $activation_history_for_addon ); |
|
517 | + $this->update_list_of_installed_versions($activation_history_for_addon); |
|
518 | 518 | break; |
519 | 519 | case EE_System::req_type_upgrade: |
520 | - do_action( "AHEE__{$classname}__detect_activations_or_upgrades__upgrade" ); |
|
521 | - do_action( 'AHEE__EE_Addon__detect_activations_or_upgrades__upgrade', $this ); |
|
520 | + do_action("AHEE__{$classname}__detect_activations_or_upgrades__upgrade"); |
|
521 | + do_action('AHEE__EE_Addon__detect_activations_or_upgrades__upgrade', $this); |
|
522 | 522 | $this->upgrade(); |
523 | - $this->update_list_of_installed_versions($activation_history_for_addon ); |
|
523 | + $this->update_list_of_installed_versions($activation_history_for_addon); |
|
524 | 524 | break; |
525 | 525 | case EE_System::req_type_downgrade: |
526 | - do_action( "AHEE__{$classname}__detect_activations_or_upgrades__downgrade" ); |
|
527 | - do_action( 'AHEE__EE_Addon__detect_activations_or_upgrades__downgrade', $this ); |
|
526 | + do_action("AHEE__{$classname}__detect_activations_or_upgrades__downgrade"); |
|
527 | + do_action('AHEE__EE_Addon__detect_activations_or_upgrades__downgrade', $this); |
|
528 | 528 | $this->downgrade(); |
529 | - $this->update_list_of_installed_versions($activation_history_for_addon ); |
|
529 | + $this->update_list_of_installed_versions($activation_history_for_addon); |
|
530 | 530 | break; |
531 | 531 | case EE_System::req_type_normal: |
532 | 532 | default: |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | break; |
535 | 535 | } |
536 | 536 | |
537 | - do_action( "AHEE__{$classname}__detect_if_activation_or_upgrade__complete" ); |
|
537 | + do_action("AHEE__{$classname}__detect_if_activation_or_upgrade__complete"); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | /** |
@@ -543,17 +543,17 @@ discard block |
||
543 | 543 | * @param string $current_version_to_add |
544 | 544 | * @return boolean success |
545 | 545 | */ |
546 | - public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
|
547 | - if( ! $version_history ) { |
|
546 | + public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) { |
|
547 | + if ( ! $version_history) { |
|
548 | 548 | $version_history = $this->get_activation_history(); |
549 | 549 | } |
550 | - if( $current_version_to_add === NULL){ |
|
550 | + if ($current_version_to_add === NULL) { |
|
551 | 551 | $current_version_to_add = $this->version(); |
552 | 552 | } |
553 | - $version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() ); |
|
553 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
554 | 554 | // resave |
555 | 555 | // echo "updating list of installed versions:".$this->get_activation_history_option_name();d($version_history); |
556 | - return update_option( $this->get_activation_history_option_name(), $version_history ); |
|
556 | + return update_option($this->get_activation_history_option_name(), $version_history); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
@@ -561,8 +561,8 @@ discard block |
||
561 | 561 | * of this addon |
562 | 562 | * @return string |
563 | 563 | */ |
564 | - public function get_activation_history_option_name(){ |
|
565 | - return self::ee_addon_version_history_option_prefix . $this->name(); |
|
564 | + public function get_activation_history_option_name() { |
|
565 | + return self::ee_addon_version_history_option_prefix.$this->name(); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | * Gets the wp option which stores the activation history for this addon |
572 | 572 | * @return array |
573 | 573 | */ |
574 | - public function get_activation_history(){ |
|
574 | + public function get_activation_history() { |
|
575 | 575 | return get_option($this->get_activation_history_option_name(), NULL); |
576 | 576 | } |
577 | 577 | |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | /** |
581 | 581 | * @param string $config_section |
582 | 582 | */ |
583 | - public function set_config_section( $config_section = '' ) { |
|
584 | - $this->_config_section = ! empty( $config_section ) ? $config_section : 'addons'; |
|
583 | + public function set_config_section($config_section = '') { |
|
584 | + $this->_config_section = ! empty($config_section) ? $config_section : 'addons'; |
|
585 | 585 | } |
586 | 586 | /** |
587 | 587 | * filepath to the main file, which can be used for register_activation_hook, register_deactivation_hook, etc. |
@@ -594,14 +594,14 @@ discard block |
||
594 | 594 | * Sets the filepath to the main plugin file |
595 | 595 | * @param string $filepath |
596 | 596 | */ |
597 | - public function set_main_plugin_file( $filepath ) { |
|
597 | + public function set_main_plugin_file($filepath) { |
|
598 | 598 | $this->_main_plugin_file = $filepath; |
599 | 599 | } |
600 | 600 | /** |
601 | 601 | * gets the filepath to teh main file |
602 | 602 | * @return string |
603 | 603 | */ |
604 | - public function get_main_plugin_file(){ |
|
604 | + public function get_main_plugin_file() { |
|
605 | 605 | return $this->_main_plugin_file; |
606 | 606 | } |
607 | 607 | |
@@ -611,15 +611,15 @@ discard block |
||
611 | 611 | * @return string |
612 | 612 | */ |
613 | 613 | public function get_main_plugin_file_basename() { |
614 | - return plugin_basename( $this->get_main_plugin_file() ); |
|
614 | + return plugin_basename($this->get_main_plugin_file()); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
618 | 618 | * Gets the folder name which contains the main plugin file |
619 | 619 | * @return string |
620 | 620 | */ |
621 | - public function get_main_plugin_file_dirname(){ |
|
622 | - return dirname( $this->get_main_plugin_file() ); |
|
621 | + public function get_main_plugin_file_dirname() { |
|
622 | + return dirname($this->get_main_plugin_file()); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | |
@@ -628,11 +628,11 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @return void |
630 | 630 | */ |
631 | - public function admin_init(){ |
|
631 | + public function admin_init() { |
|
632 | 632 | // is admin and not in M-Mode ? |
633 | - if ( is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
634 | - add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 ); |
|
635 | - add_filter( 'after_plugin_row_' . $this->_plugin_basename, array( $this, 'after_plugin_row' ), 10, 3 ); |
|
633 | + if (is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
634 | + add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2); |
|
635 | + add_filter('after_plugin_row_'.$this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3); |
|
636 | 636 | } |
637 | 637 | } |
638 | 638 | |
@@ -647,10 +647,10 @@ discard block |
||
647 | 647 | * @param $file |
648 | 648 | * @return array |
649 | 649 | */ |
650 | - public function plugin_action_links( $links, $file ) { |
|
651 | - if ( $file === $this->plugin_basename() && $this->plugin_action_slug() !== '' ) { |
|
650 | + public function plugin_action_links($links, $file) { |
|
651 | + if ($file === $this->plugin_basename() && $this->plugin_action_slug() !== '') { |
|
652 | 652 | // before other links |
653 | - array_unshift( $links, '<a href="admin.php?page=' . $this->plugin_action_slug() . '">' . __( 'Settings' ) . '</a>' ); |
|
653 | + array_unshift($links, '<a href="admin.php?page='.$this->plugin_action_slug().'">'.__('Settings').'</a>'); |
|
654 | 654 | } |
655 | 655 | return $links; |
656 | 656 | } |
@@ -668,17 +668,17 @@ discard block |
||
668 | 668 | * @param $status |
669 | 669 | * @return void |
670 | 670 | */ |
671 | - public function after_plugin_row( $plugin_file, $plugin_data, $status ) { |
|
671 | + public function after_plugin_row($plugin_file, $plugin_data, $status) { |
|
672 | 672 | |
673 | 673 | $after_plugin_row = ''; |
674 | - if ( $plugin_file === $this->plugin_basename() && $this->get_plugins_page_row() !== '' ) { |
|
674 | + if ($plugin_file === $this->plugin_basename() && $this->get_plugins_page_row() !== '') { |
|
675 | 675 | $class = $status ? 'active' : 'inactive'; |
676 | 676 | $plugins_page_row = $this->get_plugins_page_row(); |
677 | - $link_text = isset( $plugins_page_row[ 'link_text' ] ) ? $plugins_page_row[ 'link_text' ] : ''; |
|
678 | - $link_url = isset( $plugins_page_row[ 'link_url' ] ) ? $plugins_page_row[ 'link_url' ] : ''; |
|
679 | - $description = isset( $plugins_page_row[ 'description' ] ) ? $plugins_page_row[ 'description' ] : $plugins_page_row; |
|
680 | - if ( ! empty( $link_text ) && ! empty( $link_url ) && ! empty( $description )) { |
|
681 | - $after_plugin_row .= '<tr id="' . sanitize_title( $plugin_file ) . '-ee-addon" class="' . $class . '">'; |
|
677 | + $link_text = isset($plugins_page_row['link_text']) ? $plugins_page_row['link_text'] : ''; |
|
678 | + $link_url = isset($plugins_page_row['link_url']) ? $plugins_page_row['link_url'] : ''; |
|
679 | + $description = isset($plugins_page_row['description']) ? $plugins_page_row['description'] : $plugins_page_row; |
|
680 | + if ( ! empty($link_text) && ! empty($link_url) && ! empty($description)) { |
|
681 | + $after_plugin_row .= '<tr id="'.sanitize_title($plugin_file).'-ee-addon" class="'.$class.'">'; |
|
682 | 682 | $after_plugin_row .= '<th class="check-column" scope="row"></th>'; |
683 | 683 | $after_plugin_row .= '<td class="ee-addon-upsell-info-title-td plugin-title column-primary">'; |
684 | 684 | $after_plugin_row .= '<style> |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | </style>'; |
721 | 721 | $after_plugin_row .= ' |
722 | 722 | <p class="ee-addon-upsell-info-dv"> |
723 | - <a class="ee-button" href="' . $link_url . '">' . $link_text . ' <span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span></a> |
|
723 | + <a class="ee-button" href="' . $link_url.'">'.$link_text.' <span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span></a> |
|
724 | 724 | </p>'; |
725 | 725 | $after_plugin_row .= '</td>'; |
726 | 726 | $after_plugin_row .= '<td class="ee-addon-upsell-info-desc-td column-description desc">'; |
@@ -282,16 +282,16 @@ discard block |
||
282 | 282 | |
283 | 283 | |
284 | 284 | |
285 | - /** |
|
286 | - * Takes care of double-checking that we're not in maintenance mode, and then |
|
287 | - * initializing this addon's necessary initial data. This is called by default on new activations |
|
288 | - * and reactivations |
|
289 | - * |
|
290 | - * @param boolean $verify_schema whether to verify the database's schema for this addon, or just its data. |
|
291 | - * This is a resource-intensive job so we prefer to only do it when necessary |
|
292 | - * @return void |
|
293 | - * @throws \EE_Error |
|
294 | - */ |
|
285 | + /** |
|
286 | + * Takes care of double-checking that we're not in maintenance mode, and then |
|
287 | + * initializing this addon's necessary initial data. This is called by default on new activations |
|
288 | + * and reactivations |
|
289 | + * |
|
290 | + * @param boolean $verify_schema whether to verify the database's schema for this addon, or just its data. |
|
291 | + * This is a resource-intensive job so we prefer to only do it when necessary |
|
292 | + * @return void |
|
293 | + * @throws \EE_Error |
|
294 | + */ |
|
295 | 295 | public function initialize_db_if_no_migrations_required( $verify_schema = true ) { |
296 | 296 | if( $verify_schema === '' ) { |
297 | 297 | //wp core bug imo: if no args are passed to `do_action('some_hook_name')` besides the hook's name |
@@ -307,11 +307,11 @@ discard block |
||
307 | 307 | $this->initialize_default_data(); |
308 | 308 | //@todo: this will probably need to be adjusted in 4.4 as the array changed formats I believe |
309 | 309 | EE_Data_Migration_Manager::instance()->update_current_database_state_to( |
310 | - array( |
|
311 | - 'slug' => $this->name(), |
|
312 | - 'version' => $this->version() |
|
313 | - ) |
|
314 | - ); |
|
310 | + array( |
|
311 | + 'slug' => $this->name(), |
|
312 | + 'version' => $this->version() |
|
313 | + ) |
|
314 | + ); |
|
315 | 315 | /* make sure core's data is a-ok |
316 | 316 | * (at the time of writing, we especially want to verify all the caps are present |
317 | 317 | * because payment method type capabilities are added dynamically, and it's |
@@ -355,11 +355,11 @@ discard block |
||
355 | 355 | } |
356 | 356 | //if not DMS was found that should be ok. This addon just doesn't require any database changes |
357 | 357 | EE_Data_Migration_Manager::instance()->update_current_database_state_to( |
358 | - array( |
|
359 | - 'slug' => $this->name(), |
|
360 | - 'version' => $this->version() |
|
361 | - ) |
|
362 | - ); |
|
358 | + array( |
|
359 | + 'slug' => $this->name(), |
|
360 | + 'version' => $this->version() |
|
361 | + ) |
|
362 | + ); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
402 | 402 | //also it's possible there is new default data that needs to be added |
403 | 403 | add_action( |
404 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' ) |
|
405 | - ); |
|
404 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' ) |
|
405 | + ); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
@@ -624,9 +624,9 @@ discard block |
||
624 | 624 | |
625 | 625 | |
626 | 626 | /** |
627 | - * sets hooks used in the admin |
|
628 | - * |
|
629 | - * @return void |
|
627 | + * sets hooks used in the admin |
|
628 | + * |
|
629 | + * @return void |
|
630 | 630 | */ |
631 | 631 | public function admin_init(){ |
632 | 632 | // is admin and not in M-Mode ? |
@@ -737,16 +737,16 @@ discard block |
||
737 | 737 | |
738 | 738 | |
739 | 739 | |
740 | - /** |
|
741 | - * a safe space for addons to add additional logic like setting hooks |
|
742 | - * that will run immediately after addon registration |
|
743 | - * making this a great place for code that needs to be "omnipresent" |
|
744 | - * |
|
745 | - * @since 4.9.26 |
|
746 | - */ |
|
740 | + /** |
|
741 | + * a safe space for addons to add additional logic like setting hooks |
|
742 | + * that will run immediately after addon registration |
|
743 | + * making this a great place for code that needs to be "omnipresent" |
|
744 | + * |
|
745 | + * @since 4.9.26 |
|
746 | + */ |
|
747 | 747 | public function after_registration() |
748 | - { |
|
749 | - // cricket chirp... cricket chirp... |
|
748 | + { |
|
749 | + // cricket chirp... cricket chirp... |
|
750 | 750 | } |
751 | 751 | |
752 | 752 |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | |
121 | 121 | /** |
122 | - * @param mixed $min_core_version |
|
122 | + * @param string $min_core_version |
|
123 | 123 | */ |
124 | 124 | public function set_min_core_version( $min_core_version = NULL ) { |
125 | 125 | $this->_min_core_version = $min_core_version; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * Sets addon_name |
142 | 142 | * @param string $addon_name |
143 | - * @return boolean |
|
143 | + * @return string |
|
144 | 144 | */ |
145 | 145 | public function set_name( $addon_name ) { |
146 | 146 | return $this->_addon_name = $addon_name; |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_Foreign_Key_Field_Base.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_Foreign_Key_Field_Base.php'); |
|
3 | 3 | |
4 | 4 | class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base |
5 | 5 | { |
@@ -4,17 +4,17 @@ |
||
4 | 4 | class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base |
5 | 5 | { |
6 | 6 | |
7 | - /** |
|
8 | - * removes all tags when setting |
|
9 | - * |
|
10 | - * @param string $value_inputted_for_field_on_model_object |
|
11 | - * @return string |
|
12 | - */ |
|
13 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
14 | - { |
|
15 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
16 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
17 | - } |
|
18 | - return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
19 | - } |
|
7 | + /** |
|
8 | + * removes all tags when setting |
|
9 | + * |
|
10 | + * @param string $value_inputted_for_field_on_model_object |
|
11 | + * @return string |
|
12 | + */ |
|
13 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
14 | + { |
|
15 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
16 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
17 | + } |
|
18 | + return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
19 | + } |
|
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_DB_Only_Field_Base.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Used by EE_Belongs_To_Any_Relations and EE_Has_Many_Any_Relations to identify the model the foreign key points to. |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_DB_Only_Field_Base.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php'); |
|
3 | 3 | |
4 | 4 | class EE_DB_Only_Text_Field extends EE_DB_Only_Field_Base |
5 | 5 | { |
@@ -13,93 +13,93 @@ |
||
13 | 13 | class EE_Has_Many_Relation extends EE_Model_Relation_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the |
|
18 | - * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but |
|
19 | - * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get |
|
20 | - * related models across the relation, and add-and-remove the relationships. |
|
21 | - * |
|
22 | - * @param boolean $block_deletes For this type of r elation, we block by default. If there are |
|
23 | - * related models across this relation, block (prevent and add an |
|
24 | - * error) the deletion of this model |
|
25 | - * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the |
|
26 | - * default |
|
27 | - */ |
|
28 | - public function __construct($block_deletes = true, $blocking_delete_error_message = null) |
|
29 | - { |
|
30 | - parent::__construct($block_deletes, $blocking_delete_error_message); |
|
31 | - } |
|
16 | + /** |
|
17 | + * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the |
|
18 | + * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but |
|
19 | + * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get |
|
20 | + * related models across the relation, and add-and-remove the relationships. |
|
21 | + * |
|
22 | + * @param boolean $block_deletes For this type of r elation, we block by default. If there are |
|
23 | + * related models across this relation, block (prevent and add an |
|
24 | + * error) the deletion of this model |
|
25 | + * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the |
|
26 | + * default |
|
27 | + */ |
|
28 | + public function __construct($block_deletes = true, $blocking_delete_error_message = null) |
|
29 | + { |
|
30 | + parent::__construct($block_deletes, $blocking_delete_error_message); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Gets the SQL string for performing the join between this model and the other model. |
|
36 | - * |
|
37 | - * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
38 | - * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
39 | - * other_model_primary_table.fk" etc |
|
40 | - * @throws \EE_Error |
|
41 | - */ |
|
42 | - public function get_join_statement($model_relation_chain) |
|
43 | - { |
|
44 | - //create the sql string like |
|
45 | - // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
46 | - $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
47 | - $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
48 | - $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, |
|
49 | - $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
50 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, |
|
51 | - $this->get_other_model()->get_this_model_name()) . $other_table_fk_field->get_table_alias(); |
|
52 | - $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
34 | + /** |
|
35 | + * Gets the SQL string for performing the join between this model and the other model. |
|
36 | + * |
|
37 | + * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
38 | + * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
39 | + * other_model_primary_table.fk" etc |
|
40 | + * @throws \EE_Error |
|
41 | + */ |
|
42 | + public function get_join_statement($model_relation_chain) |
|
43 | + { |
|
44 | + //create the sql string like |
|
45 | + // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
46 | + $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
47 | + $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
48 | + $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, |
|
49 | + $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
50 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, |
|
51 | + $this->get_other_model()->get_this_model_name()) . $other_table_fk_field->get_table_alias(); |
|
52 | + $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
53 | 53 | |
54 | - return $this->_left_join($fk_table, $fk_table_alias, $other_table_fk_field->get_table_column(), $pk_table_alias, |
|
55 | - $this_table_pk_field->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
56 | - } |
|
54 | + return $this->_left_join($fk_table, $fk_table_alias, $other_table_fk_field->get_table_column(), $pk_table_alias, |
|
55 | + $this_table_pk_field->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
61 | - * you like. |
|
62 | - * |
|
63 | - * @param EE_Base_Class|int $this_obj_or_id |
|
64 | - * @param EE_Base_Class|int $other_obj_or_id |
|
65 | - * @param array $extra_join_model_fields_n_values |
|
66 | - * @return \EE_Base_Class |
|
67 | - * @throws \EE_Error |
|
68 | - */ |
|
69 | - public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
70 | - { |
|
71 | - $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
72 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
59 | + /** |
|
60 | + * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
61 | + * you like. |
|
62 | + * |
|
63 | + * @param EE_Base_Class|int $this_obj_or_id |
|
64 | + * @param EE_Base_Class|int $other_obj_or_id |
|
65 | + * @param array $extra_join_model_fields_n_values |
|
66 | + * @return \EE_Base_Class |
|
67 | + * @throws \EE_Error |
|
68 | + */ |
|
69 | + public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
70 | + { |
|
71 | + $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
72 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
73 | 73 | |
74 | - //find the field on the other model which is a foreign key to this model |
|
75 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
76 | - if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) { |
|
77 | - //set that field on the other model to this model's ID |
|
78 | - $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
79 | - $other_model_obj->save(); |
|
80 | - } |
|
81 | - return $other_model_obj; |
|
82 | - } |
|
74 | + //find the field on the other model which is a foreign key to this model |
|
75 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
76 | + if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) { |
|
77 | + //set that field on the other model to this model's ID |
|
78 | + $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
79 | + $other_model_obj->save(); |
|
80 | + } |
|
81 | + return $other_model_obj; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
87 | - * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
88 | - * |
|
89 | - * @param EE_Base_Class|int $this_obj_or_id |
|
90 | - * @param EE_Base_Class|int $other_obj_or_id |
|
91 | - * @param array $where_query |
|
92 | - * @return \EE_Base_Class |
|
93 | - * @throws \EE_Error |
|
94 | - */ |
|
95 | - public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
96 | - { |
|
97 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
98 | - //find the field on the other model which is a foreign key to this model |
|
99 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
100 | - //set that field on the other model to this model's ID |
|
101 | - $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
102 | - $other_model_obj->save(); |
|
103 | - return $other_model_obj; |
|
104 | - } |
|
85 | + /** |
|
86 | + * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
87 | + * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
88 | + * |
|
89 | + * @param EE_Base_Class|int $this_obj_or_id |
|
90 | + * @param EE_Base_Class|int $other_obj_or_id |
|
91 | + * @param array $where_query |
|
92 | + * @return \EE_Base_Class |
|
93 | + * @throws \EE_Error |
|
94 | + */ |
|
95 | + public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
96 | + { |
|
97 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
98 | + //find the field on the other model which is a foreign key to this model |
|
99 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
100 | + //set that field on the other model to this model's ID |
|
101 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
102 | + $other_model_obj->save(); |
|
103 | + return $other_model_obj; |
|
104 | + } |
|
105 | 105 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * increments reserved by amount passed by $qty |
254 | 254 | * |
255 | 255 | * @param int $qty |
256 | - * @return boolean |
|
256 | + * @return boolean|null |
|
257 | 257 | */ |
258 | 258 | public function increase_reserved( $qty = 1 ) { |
259 | 259 | $reserved = $this->reserved() + absint( $qty ); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * decrements (subtracts) reserved by amount passed by $qty |
267 | 267 | * |
268 | 268 | * @param int $qty |
269 | - * @return boolean |
|
269 | + * @return boolean|null |
|
270 | 270 | */ |
271 | 271 | public function decrease_reserved( $qty = 1 ) { |
272 | 272 | $reserved = $this->reserved() - absint( $qty ); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @param string $dt_frmt - string representation of date format defaults to WP settings |
412 | 412 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with |
413 | 413 | * the end date ie: Jan 01 "to" Dec 31 |
414 | - * @return mixed string on success, FALSE on fail |
|
414 | + * @return string string on success, FALSE on fail |
|
415 | 415 | * @throws \EE_Error |
416 | 416 | */ |
417 | 417 | public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | * @param string $tm_format string representation of time format defaults to 'g:i a' |
484 | 484 | * @param string $conjunction conjunction junction what's your function ? |
485 | 485 | * this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
486 | - * @return mixed string on success, FALSE on fail |
|
486 | + * @return string string on success, FALSE on fail |
|
487 | 487 | * @throws \EE_Error |
488 | 488 | */ |
489 | 489 | public function time_range( $tm_format = '', $conjunction = ' - ' ) { |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | |
359 | 359 | |
360 | 360 | |
361 | - /** |
|
362 | - * get event start date. Provide either the date format, or NULL to re-use the |
|
363 | - * last-used format, or '' to use the default date format |
|
364 | - * |
|
365 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
366 | - * @return mixed string on success, FALSE on fail |
|
367 | - */ |
|
361 | + /** |
|
362 | + * get event start date. Provide either the date format, or NULL to re-use the |
|
363 | + * last-used format, or '' to use the default date format |
|
364 | + * |
|
365 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
366 | + * @return mixed string on success, FALSE on fail |
|
367 | + */ |
|
368 | 368 | public function start_date( $dt_frmt = '' ) { |
369 | 369 | return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
370 | 370 | } |
@@ -381,13 +381,13 @@ discard block |
||
381 | 381 | |
382 | 382 | |
383 | 383 | |
384 | - /** |
|
385 | - * get end date. Provide either the date format, or NULL to re-use the |
|
386 | - * last-used format, or '' to use the default date format |
|
387 | - * |
|
388 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
389 | - * @return mixed string on success, FALSE on fail |
|
390 | - */ |
|
384 | + /** |
|
385 | + * get end date. Provide either the date format, or NULL to re-use the |
|
386 | + * last-used format, or '' to use the default date format |
|
387 | + * |
|
388 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
389 | + * @return mixed string on success, FALSE on fail |
|
390 | + */ |
|
391 | 391 | public function end_date( $dt_frmt = '' ) { |
392 | 392 | return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
393 | 393 | } |
@@ -531,14 +531,14 @@ discard block |
||
531 | 531 | //start and end date are the same but times are different |
532 | 532 | case ( $this->start_date() === $this->end_date() ) : |
533 | 533 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
534 | - . $conjunction |
|
535 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
534 | + . $conjunction |
|
535 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
536 | 536 | break; |
537 | 537 | //all other conditions |
538 | 538 | default : |
539 | 539 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
540 | - . $conjunction |
|
541 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
540 | + . $conjunction |
|
541 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
542 | 542 | break; |
543 | 543 | } |
544 | 544 | return $output; |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | |
623 | 623 | |
624 | 624 | /** |
625 | - * get end date and time |
|
626 | - * |
|
627 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
628 | - * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
629 | - * @return mixed string on success, FALSE on fail |
|
630 | - */ |
|
631 | - public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
625 | + * get end date and time |
|
626 | + * |
|
627 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
628 | + * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
629 | + * @return mixed string on success, FALSE on fail |
|
630 | + */ |
|
631 | + public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
632 | 632 | return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
633 | 633 | } |
634 | 634 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * date_format and the second value is the time format |
75 | 75 | * @return EE_Datetime |
76 | 76 | */ |
77 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
78 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
79 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
77 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
78 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
79 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * the website will be used. |
88 | 88 | * @return EE_Datetime |
89 | 89 | */ |
90 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
91 | - return new self( $props_n_values, TRUE, $timezone ); |
|
90 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
91 | + return new self($props_n_values, TRUE, $timezone); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * @param $name |
98 | 98 | */ |
99 | - public function set_name( $name ) { |
|
100 | - $this->set( 'DTT_name', $name ); |
|
99 | + public function set_name($name) { |
|
100 | + $this->set('DTT_name', $name); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * @param $description |
107 | 107 | */ |
108 | - public function set_description( $description ) { |
|
109 | - $this->set( 'DTT_description', $description ); |
|
108 | + public function set_description($description) { |
|
109 | + $this->set('DTT_description', $description); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
120 | 120 | */ |
121 | - public function set_start_date( $date ) { |
|
122 | - $this->_set_date_for( $date, 'DTT_EVT_start' ); |
|
121 | + public function set_start_date($date) { |
|
122 | + $this->_set_date_for($date, 'DTT_EVT_start'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
133 | 133 | */ |
134 | - public function set_start_time( $time ) { |
|
135 | - $this->_set_time_for( $time, 'DTT_EVT_start' ); |
|
134 | + public function set_start_time($time) { |
|
135 | + $this->_set_time_for($time, 'DTT_EVT_start'); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
146 | 146 | */ |
147 | - public function set_end_date( $date ) { |
|
148 | - $this->_set_date_for( $date, 'DTT_EVT_end' ); |
|
147 | + public function set_end_date($date) { |
|
148 | + $this->_set_date_for($date, 'DTT_EVT_end'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
159 | 159 | */ |
160 | - public function set_end_time( $time ) { |
|
161 | - $this->_set_time_for( $time, 'DTT_EVT_end' ); |
|
160 | + public function set_end_time($time) { |
|
161 | + $this->_set_time_for($time, 'DTT_EVT_end'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param int $reg_limit |
172 | 172 | */ |
173 | - public function set_reg_limit( $reg_limit ) { |
|
174 | - $this->set( 'DTT_reg_limit', $reg_limit ); |
|
173 | + public function set_reg_limit($reg_limit) { |
|
174 | + $this->set('DTT_reg_limit', $reg_limit); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @return mixed int on success, FALSE on fail |
184 | 184 | */ |
185 | 185 | public function sold() { |
186 | - return $this->get_raw( 'DTT_sold' ); |
|
186 | + return $this->get_raw('DTT_sold'); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param int $sold |
195 | 195 | */ |
196 | - public function set_sold( $sold ) { |
|
196 | + public function set_sold($sold) { |
|
197 | 197 | // sold can not go below zero |
198 | - $sold = max( 0, $sold ); |
|
199 | - $this->set( 'DTT_sold', $sold ); |
|
198 | + $sold = max(0, $sold); |
|
199 | + $this->set('DTT_sold', $sold); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | * increments sold by amount passed by $qty |
206 | 206 | * @param int $qty |
207 | 207 | */ |
208 | - public function increase_sold( $qty = 1 ) { |
|
208 | + public function increase_sold($qty = 1) { |
|
209 | 209 | $sold = $this->sold() + $qty; |
210 | 210 | // remove ticket reservation |
211 | - $this->decrease_reserved( $qty ); |
|
212 | - $this->set_sold( $sold ); |
|
211 | + $this->decrease_reserved($qty); |
|
212 | + $this->set_sold($sold); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | * decrements (subtracts) sold amount passed by $qty |
219 | 219 | * @param int $qty |
220 | 220 | */ |
221 | - public function decrease_sold( $qty = 1 ) { |
|
221 | + public function decrease_sold($qty = 1) { |
|
222 | 222 | $sold = $this->sold() - $qty; |
223 | - $this->set_sold( $sold ); |
|
223 | + $this->set_sold($sold); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @return int |
232 | 232 | */ |
233 | 233 | public function reserved() { |
234 | - return $this->get_raw( 'DTT_reserved' ); |
|
234 | + return $this->get_raw('DTT_reserved'); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @param int $reserved |
243 | 243 | */ |
244 | - public function set_reserved( $reserved ) { |
|
244 | + public function set_reserved($reserved) { |
|
245 | 245 | // reserved can not go below zero |
246 | - $reserved = max( 0, (int) $reserved ); |
|
247 | - $this->set( 'DTT_reserved', $reserved ); |
|
246 | + $reserved = max(0, (int) $reserved); |
|
247 | + $this->set('DTT_reserved', $reserved); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | * @param int $qty |
256 | 256 | * @return boolean |
257 | 257 | */ |
258 | - public function increase_reserved( $qty = 1 ) { |
|
259 | - $reserved = $this->reserved() + absint( $qty ); |
|
260 | - return $this->set_reserved( $reserved ); |
|
258 | + public function increase_reserved($qty = 1) { |
|
259 | + $reserved = $this->reserved() + absint($qty); |
|
260 | + return $this->set_reserved($reserved); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | * @param int $qty |
269 | 269 | * @return boolean |
270 | 270 | */ |
271 | - public function decrease_reserved( $qty = 1 ) { |
|
272 | - $reserved = $this->reserved() - absint( $qty ); |
|
273 | - return $this->set_reserved( $reserved ); |
|
271 | + public function decrease_reserved($qty = 1) { |
|
272 | + $reserved = $this->reserved() - absint($qty); |
|
273 | + return $this->set_reserved($reserved); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @return string |
292 | 292 | */ |
293 | 293 | public function name() { |
294 | - return $this->get( 'DTT_name' ); |
|
294 | + return $this->get('DTT_name'); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @return string |
302 | 302 | */ |
303 | 303 | public function description() { |
304 | - return $this->get( 'DTT_description' ); |
|
304 | + return $this->get('DTT_description'); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @return boolean TRUE if is primary, FALSE if not. |
312 | 312 | */ |
313 | 313 | public function is_primary() { |
314 | - return $this->get( 'DTT_is_primary' ); |
|
314 | + return $this->get('DTT_is_primary'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @return int The order of the datetime for this event. |
322 | 322 | */ |
323 | 323 | public function order() { |
324 | - return $this->get( 'DTT_order' ); |
|
324 | + return $this->get('DTT_order'); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @return int |
332 | 332 | */ |
333 | 333 | public function parent() { |
334 | - return $this->get( 'DTT_parent' ); |
|
334 | + return $this->get('DTT_parent'); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
@@ -347,10 +347,10 @@ discard block |
||
347 | 347 | * @param bool $echo - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats) |
348 | 348 | * @return string|bool string on success, FALSE on fail |
349 | 349 | */ |
350 | - private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) { |
|
350 | + private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) { |
|
351 | 351 | $field_name = "DTT_EVT_{$start_or_end}"; |
352 | - $dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo ); |
|
353 | - if ( ! $echo ) { |
|
352 | + $dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo); |
|
353 | + if ( ! $echo) { |
|
354 | 354 | return $dtt; |
355 | 355 | } |
356 | 356 | return ''; |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
366 | 366 | * @return mixed string on success, FALSE on fail |
367 | 367 | */ |
368 | - public function start_date( $dt_frmt = '' ) { |
|
369 | - return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
|
368 | + public function start_date($dt_frmt = '') { |
|
369 | + return $this->_show_datetime('D', 'start', $dt_frmt); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -375,8 +375,8 @@ discard block |
||
375 | 375 | * Echoes start_date() |
376 | 376 | * @param string $dt_frmt |
377 | 377 | */ |
378 | - public function e_start_date( $dt_frmt = '' ) { |
|
379 | - $this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE ); |
|
378 | + public function e_start_date($dt_frmt = '') { |
|
379 | + $this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
389 | 389 | * @return mixed string on success, FALSE on fail |
390 | 390 | */ |
391 | - public function end_date( $dt_frmt = '' ) { |
|
392 | - return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
|
391 | + public function end_date($dt_frmt = '') { |
|
392 | + return $this->_show_datetime('D', 'end', $dt_frmt); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | * Echoes the end date. See end_date() |
399 | 399 | * @param string $dt_frmt |
400 | 400 | */ |
401 | - public function e_end_date( $dt_frmt = '' ) { |
|
402 | - $this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE ); |
|
401 | + public function e_end_date($dt_frmt = '') { |
|
402 | + $this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | * @return mixed string on success, FALSE on fail |
415 | 415 | * @throws \EE_Error |
416 | 416 | */ |
417 | - public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
418 | - $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt; |
|
419 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) ); |
|
420 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) ); |
|
421 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
417 | + public function date_range($dt_frmt = '', $conjunction = ' - ') { |
|
418 | + $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt; |
|
419 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)); |
|
420 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)); |
|
421 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | * @param string $conjunction |
429 | 429 | * @throws \EE_Error |
430 | 430 | */ |
431 | - public function e_date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
432 | - echo $this->date_range( $dt_frmt, $conjunction ); |
|
431 | + public function e_date_range($dt_frmt = '', $conjunction = ' - ') { |
|
432 | + echo $this->date_range($dt_frmt, $conjunction); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
441 | 441 | * @return mixed string on success, FALSE on fail |
442 | 442 | */ |
443 | - public function start_time( $tm_format = '' ) { |
|
444 | - return $this->_show_datetime( 'T', 'start', NULL, $tm_format ); |
|
443 | + public function start_time($tm_format = '') { |
|
444 | + return $this->_show_datetime('T', 'start', NULL, $tm_format); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | /** |
450 | 450 | * @param string $tm_format |
451 | 451 | */ |
452 | - public function e_start_time( $tm_format = '' ) { |
|
453 | - $this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE ); |
|
452 | + public function e_start_time($tm_format = '') { |
|
453 | + $this->_show_datetime('T', 'start', NULL, $tm_format, TRUE); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
462 | 462 | * @return mixed string on success, FALSE on fail |
463 | 463 | */ |
464 | - public function end_time( $tm_format = '' ) { |
|
465 | - return $this->_show_datetime( 'T', 'end', NULL, $tm_format ); |
|
464 | + public function end_time($tm_format = '') { |
|
465 | + return $this->_show_datetime('T', 'end', NULL, $tm_format); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | |
@@ -470,8 +470,8 @@ discard block |
||
470 | 470 | /** |
471 | 471 | * @param string $tm_format |
472 | 472 | */ |
473 | - public function e_end_time( $tm_format = '' ) { |
|
474 | - $this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE ); |
|
473 | + public function e_end_time($tm_format = '') { |
|
474 | + $this->_show_datetime('T', 'end', NULL, $tm_format, TRUE); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | |
@@ -486,11 +486,11 @@ discard block |
||
486 | 486 | * @return mixed string on success, FALSE on fail |
487 | 487 | * @throws \EE_Error |
488 | 488 | */ |
489 | - public function time_range( $tm_format = '', $conjunction = ' - ' ) { |
|
490 | - $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
491 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) ); |
|
492 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ) ); |
|
493 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
489 | + public function time_range($tm_format = '', $conjunction = ' - ') { |
|
490 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
491 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $tm_format)); |
|
492 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $tm_format)); |
|
493 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | * @param string $conjunction |
501 | 501 | * @throws \EE_Error |
502 | 502 | */ |
503 | - public function e_time_range( $tm_format = '', $conjunction = ' - ' ) { |
|
504 | - echo $this->time_range( $tm_format, $conjunction ); |
|
503 | + public function e_time_range($tm_format = '', $conjunction = ' - ') { |
|
504 | + echo $this->time_range($tm_format, $conjunction); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | |
@@ -517,28 +517,28 @@ discard block |
||
517 | 517 | * @return string |
518 | 518 | * @throws \EE_Error |
519 | 519 | */ |
520 | - public function date_and_time_range( $dt_format = '', $tm_format = '', $conjunction = ' - ' ) { |
|
520 | + public function date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') { |
|
521 | 521 | $dt_format = $dt_format !== '' ? $dt_format : $this->_dt_frmt; |
522 | 522 | $tm_format = $tm_format !== '' ? $tm_format : $this->_tm_frmt; |
523 | - $full_format = $dt_format . ' ' . $tm_format; |
|
523 | + $full_format = $dt_format.' '.$tm_format; |
|
524 | 524 | |
525 | 525 | //the range output depends on various conditions |
526 | - switch ( true ) { |
|
526 | + switch (true) { |
|
527 | 527 | //start date timestamp and end date timestamp are the same. |
528 | - case ( $this->get_raw( 'DTT_EVT_start' ) === $this->get_raw( 'DTT_EVT_end' ) ) : |
|
529 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ); |
|
528 | + case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')) : |
|
529 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format); |
|
530 | 530 | break; |
531 | 531 | //start and end date are the same but times are different |
532 | - case ( $this->start_date() === $this->end_date() ) : |
|
533 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
532 | + case ($this->start_date() === $this->end_date()) : |
|
533 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
534 | 534 | . $conjunction |
535 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
535 | + . $this->get_i18n_datetime('DTT_EVT_end', $tm_format); |
|
536 | 536 | break; |
537 | 537 | //all other conditions |
538 | 538 | default : |
539 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
539 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
540 | 540 | . $conjunction |
541 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
541 | + . $this->get_i18n_datetime('DTT_EVT_end', $full_format); |
|
542 | 542 | break; |
543 | 543 | } |
544 | 544 | return $output; |
@@ -556,8 +556,8 @@ discard block |
||
556 | 556 | * @return void |
557 | 557 | * @throws \EE_Error |
558 | 558 | */ |
559 | - public function e_date_and_time_range( $dt_format = '', $tm_format = '', $conjunction = ' - ' ) { |
|
560 | - echo $this->date_and_time_range( $dt_format, $tm_format, $conjunction ); |
|
559 | + public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') { |
|
560 | + echo $this->date_and_time_range($dt_format, $tm_format, $conjunction); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
@@ -569,8 +569,8 @@ discard block |
||
569 | 569 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
570 | 570 | * @return mixed string on success, FALSE on fail |
571 | 571 | */ |
572 | - public function start_date_and_time( $dt_format = '', $tm_format = '' ) { |
|
573 | - return $this->_show_datetime( '', 'start', $dt_format, $tm_format ); |
|
572 | + public function start_date_and_time($dt_format = '', $tm_format = '') { |
|
573 | + return $this->_show_datetime('', 'start', $dt_format, $tm_format); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | |
@@ -579,8 +579,8 @@ discard block |
||
579 | 579 | * @param string $dt_frmt |
580 | 580 | * @param string $tm_format |
581 | 581 | */ |
582 | - public function e_start_date_and_time( $dt_frmt = '', $tm_format = '' ) { |
|
583 | - $this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE ); |
|
582 | + public function e_start_date_and_time($dt_frmt = '', $tm_format = '') { |
|
583 | + $this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | |
@@ -594,11 +594,11 @@ discard block |
||
594 | 594 | * @param bool $round_up |
595 | 595 | * @return float|int|mixed |
596 | 596 | */ |
597 | - public function length( $units = 'seconds', $round_up = FALSE ) { |
|
598 | - $start = $this->get_raw( 'DTT_EVT_start' ); |
|
599 | - $end = $this->get_raw( 'DTT_EVT_end' ); |
|
597 | + public function length($units = 'seconds', $round_up = FALSE) { |
|
598 | + $start = $this->get_raw('DTT_EVT_start'); |
|
599 | + $end = $this->get_raw('DTT_EVT_end'); |
|
600 | 600 | $length_in_units = $end - $start; |
601 | - switch ( $units ) { |
|
601 | + switch ($units) { |
|
602 | 602 | //NOTE: We purposefully don't use "break;" in order to chain the divisions |
603 | 603 | /** @noinspection PhpMissingBreakStatementInspection */ |
604 | 604 | case 'days': |
@@ -611,10 +611,10 @@ discard block |
||
611 | 611 | $length_in_units /= 60; |
612 | 612 | case 'seconds': |
613 | 613 | default: |
614 | - $length_in_units = ceil( $length_in_units ); |
|
614 | + $length_in_units = ceil($length_in_units); |
|
615 | 615 | } |
616 | - if ( $round_up ) { |
|
617 | - $length_in_units = max( $length_in_units, 1 ); |
|
616 | + if ($round_up) { |
|
617 | + $length_in_units = max($length_in_units, 1); |
|
618 | 618 | } |
619 | 619 | return $length_in_units; |
620 | 620 | } |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * @return mixed string on success, FALSE on fail |
630 | 630 | */ |
631 | 631 | public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
632 | - return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
|
632 | + return $this->_show_datetime('', 'end', $dt_frmt, $tm_format); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | * @param string $dt_frmt |
639 | 639 | * @param string $tm_format |
640 | 640 | */ |
641 | - public function e_end_date_and_time( $dt_frmt = '', $tm_format = '' ) { |
|
642 | - $this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE ); |
|
641 | + public function e_end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
642 | + $this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | * @return int |
651 | 651 | */ |
652 | 652 | public function start() { |
653 | - return $this->get_raw( 'DTT_EVT_start' ); |
|
653 | + return $this->get_raw('DTT_EVT_start'); |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | * @return int |
662 | 662 | */ |
663 | 663 | public function end() { |
664 | - return $this->get_raw( 'DTT_EVT_end' ); |
|
664 | + return $this->get_raw('DTT_EVT_end'); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | * @return mixed int on success, FALSE on fail |
673 | 673 | */ |
674 | 674 | public function reg_limit() { |
675 | - return $this->get_raw( 'DTT_reg_limit' ); |
|
675 | + return $this->get_raw('DTT_reg_limit'); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | |
@@ -700,15 +700,15 @@ discard block |
||
700 | 700 | * the spaces remaining for this particular datetime, hence the flag. |
701 | 701 | * @return int |
702 | 702 | */ |
703 | - public function spaces_remaining( $consider_tickets = FALSE ) { |
|
703 | + public function spaces_remaining($consider_tickets = FALSE) { |
|
704 | 704 | // tickets remaining available for purchase |
705 | 705 | //no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF |
706 | 706 | $dtt_remaining = $this->reg_limit() - $this->sold_and_reserved(); |
707 | - if ( ! $consider_tickets ) { |
|
707 | + if ( ! $consider_tickets) { |
|
708 | 708 | return $dtt_remaining; |
709 | 709 | } |
710 | 710 | $tickets_remaining = $this->tickets_remaining(); |
711 | - return min( $dtt_remaining, $tickets_remaining ); |
|
711 | + return min($dtt_remaining, $tickets_remaining); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | |
@@ -719,19 +719,19 @@ discard block |
||
719 | 719 | * @param array $query_params like EEM_Base::get_all's |
720 | 720 | * @return int |
721 | 721 | */ |
722 | - public function tickets_remaining( $query_params = array() ) { |
|
722 | + public function tickets_remaining($query_params = array()) { |
|
723 | 723 | $sum = 0; |
724 | - $tickets = $this->tickets( $query_params ); |
|
725 | - if ( ! empty( $tickets ) ) { |
|
726 | - foreach ( $tickets as $ticket ) { |
|
727 | - if ( $ticket instanceof EE_Ticket ) { |
|
724 | + $tickets = $this->tickets($query_params); |
|
725 | + if ( ! empty($tickets)) { |
|
726 | + foreach ($tickets as $ticket) { |
|
727 | + if ($ticket instanceof EE_Ticket) { |
|
728 | 728 | // get the actual amount of tickets that can be sold |
729 | - $qty = $ticket->qty( 'saleable' ); |
|
730 | - if ( $qty === EE_INF ) { |
|
729 | + $qty = $ticket->qty('saleable'); |
|
730 | + if ($qty === EE_INF) { |
|
731 | 731 | return EE_INF; |
732 | 732 | } |
733 | 733 | // no negative ticket quantities plz |
734 | - if ( $qty > 0 ) { |
|
734 | + if ($qty > 0) { |
|
735 | 735 | $sum += $qty; |
736 | 736 | } |
737 | 737 | } |
@@ -748,8 +748,8 @@ discard block |
||
748 | 748 | * @param array $query_params like EEM_Base::get_all's |
749 | 749 | * @return int |
750 | 750 | */ |
751 | - public function sum_tickets_initially_available( $query_params = array() ) { |
|
752 | - return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' ); |
|
751 | + public function sum_tickets_initially_available($query_params = array()) { |
|
752 | + return $this->sum_related('Ticket', $query_params, 'TKT_qty'); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | * @return int |
762 | 762 | */ |
763 | 763 | public function total_tickets_available_at_this_datetime() { |
764 | - return $this->spaces_remaining( true ); |
|
764 | + return $this->spaces_remaining(true); |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | * @return boolean |
773 | 773 | */ |
774 | 774 | public function is_upcoming() { |
775 | - return ( $this->get_raw( 'DTT_EVT_start' ) > time() ); |
|
775 | + return ($this->get_raw('DTT_EVT_start') > time()); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | * @return boolean |
783 | 783 | */ |
784 | 784 | public function is_active() { |
785 | - return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() ); |
|
785 | + return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time()); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | * @return boolean |
793 | 793 | */ |
794 | 794 | public function is_expired() { |
795 | - return ( $this->get_raw( 'DTT_EVT_end' ) < time() ); |
|
795 | + return ($this->get_raw('DTT_EVT_end') < time()); |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | |
@@ -803,16 +803,16 @@ discard block |
||
803 | 803 | */ |
804 | 804 | public function get_active_status() { |
805 | 805 | $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime(); |
806 | - if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) { |
|
806 | + if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) { |
|
807 | 807 | return EE_Datetime::sold_out; |
808 | 808 | } |
809 | - if ( $this->is_expired() ) { |
|
809 | + if ($this->is_expired()) { |
|
810 | 810 | return EE_Datetime::expired; |
811 | 811 | } |
812 | - if ( $this->is_upcoming() ) { |
|
812 | + if ($this->is_upcoming()) { |
|
813 | 813 | return EE_Datetime::upcoming; |
814 | 814 | } |
815 | - if ( $this->is_active() ) { |
|
815 | + if ($this->is_active()) { |
|
816 | 816 | return EE_Datetime::active; |
817 | 817 | } |
818 | 818 | return NULL; |
@@ -826,24 +826,24 @@ discard block |
||
826 | 826 | * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty. |
827 | 827 | * @return string |
828 | 828 | */ |
829 | - public function get_dtt_display_name( $use_dtt_name = FALSE ) { |
|
830 | - if ( $use_dtt_name ) { |
|
829 | + public function get_dtt_display_name($use_dtt_name = FALSE) { |
|
830 | + if ($use_dtt_name) { |
|
831 | 831 | $dtt_name = $this->name(); |
832 | - if ( !empty( $dtt_name ) ) { |
|
832 | + if ( ! empty($dtt_name)) { |
|
833 | 833 | return $dtt_name; |
834 | 834 | } |
835 | 835 | } |
836 | 836 | //first condition is to see if the months are different |
837 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
838 | - $display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' ); |
|
837 | + if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) { |
|
838 | + $display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a'); |
|
839 | 839 | //next condition is if its the same month but different day |
840 | 840 | } |
841 | 841 | else { |
842 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
843 | - $display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' ); |
|
842 | + if (date('m', $this->get_raw('DTT_EVT_start')) == date('m', $this->get_raw('DTT_EVT_end')) && date('d', $this->get_raw('DTT_EVT_start')) != date('d', $this->get_raw('DTT_EVT_end'))) { |
|
843 | + $display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y'); |
|
844 | 844 | } |
845 | 845 | else { |
846 | - $display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' ); |
|
846 | + $display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a'); |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | return $display_date; |
@@ -857,8 +857,8 @@ discard block |
||
857 | 857 | *@param array $query_params see EEM_Base::get_all() |
858 | 858 | * @return EE_Ticket[] |
859 | 859 | */ |
860 | - public function tickets( $query_params = array() ) { |
|
861 | - return $this->get_many_related( 'Ticket', $query_params ); |
|
860 | + public function tickets($query_params = array()) { |
|
861 | + return $this->get_many_related('Ticket', $query_params); |
|
862 | 862 | } |
863 | 863 | |
864 | 864 | |
@@ -868,21 +868,21 @@ discard block |
||
868 | 868 | * @param array $query_params like EEM_Base::get_all's |
869 | 869 | * @return EE_Ticket[] |
870 | 870 | */ |
871 | - public function ticket_types_available_for_purchase( $query_params = array() ) { |
|
871 | + public function ticket_types_available_for_purchase($query_params = array()) { |
|
872 | 872 | // first check if datetime is valid |
873 | - if ( ! ( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) { |
|
873 | + if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) { |
|
874 | 874 | return array(); |
875 | 875 | } |
876 | - if ( empty( $query_params ) ) { |
|
876 | + if (empty($query_params)) { |
|
877 | 877 | $query_params = array( |
878 | 878 | array( |
879 | - 'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ), |
|
880 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
879 | + 'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')), |
|
880 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
881 | 881 | 'TKT_deleted' => false |
882 | 882 | ) |
883 | 883 | ); |
884 | 884 | } |
885 | - return $this->tickets( $query_params ); |
|
885 | + return $this->tickets($query_params); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | * @return EE_Event |
893 | 893 | */ |
894 | 894 | public function event() { |
895 | - return $this->get_first_related( 'Event' ); |
|
895 | + return $this->get_first_related('Event'); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | |
@@ -904,13 +904,13 @@ discard block |
||
904 | 904 | */ |
905 | 905 | public function update_sold() { |
906 | 906 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
907 | - array( array( |
|
907 | + array(array( |
|
908 | 908 | 'STS_ID' => EEM_Registration::status_id_approved, |
909 | 909 | 'REG_deleted' => 0, |
910 | 910 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
911 | - ) ) |
|
911 | + )) |
|
912 | 912 | ); |
913 | - $this->set( 'DTT_sold', $count_regs_for_this_datetime ); |
|
913 | + $this->set('DTT_sold', $count_regs_for_this_datetime); |
|
914 | 914 | $this->save(); |
915 | 915 | return $count_regs_for_this_datetime; |
916 | 916 | } |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | |
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * @param array $props_n_values incoming values |
|
66 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
67 | - * used.) |
|
68 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
69 | - * date_format and the second value is the time format |
|
70 | - * @return EE_Ticket |
|
71 | - * @throws \EE_Error |
|
72 | - */ |
|
64 | + /** |
|
65 | + * @param array $props_n_values incoming values |
|
66 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
67 | + * used.) |
|
68 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
69 | + * date_format and the second value is the time format |
|
70 | + * @return EE_Ticket |
|
71 | + * @throws \EE_Error |
|
72 | + */ |
|
73 | 73 | public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
74 | 74 | $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
75 | 75 | return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
@@ -77,36 +77,36 @@ discard block |
||
77 | 77 | |
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * @param array $props_n_values incoming values from the database |
|
82 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
83 | - * the website will be used. |
|
84 | - * @return EE_Ticket |
|
85 | - * @throws \EE_Error |
|
86 | - */ |
|
80 | + /** |
|
81 | + * @param array $props_n_values incoming values from the database |
|
82 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
83 | + * the website will be used. |
|
84 | + * @return EE_Ticket |
|
85 | + * @throws \EE_Error |
|
86 | + */ |
|
87 | 87 | public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
88 | 88 | return new self( $props_n_values, TRUE, $timezone ); |
89 | 89 | } |
90 | 90 | |
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * @return bool |
|
95 | - * @throws \EE_Error |
|
96 | - */ |
|
93 | + /** |
|
94 | + * @return bool |
|
95 | + * @throws \EE_Error |
|
96 | + */ |
|
97 | 97 | public function parent() { |
98 | 98 | return $this->get( 'TKT_parent' ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * return if a ticket has quantities available for purchase |
|
105 | - * |
|
106 | - * @param int $DTT_ID the primary key for a particular datetime |
|
107 | - * @return boolean |
|
108 | - * @throws \EE_Error |
|
109 | - */ |
|
103 | + /** |
|
104 | + * return if a ticket has quantities available for purchase |
|
105 | + * |
|
106 | + * @param int $DTT_ID the primary key for a particular datetime |
|
107 | + * @return boolean |
|
108 | + * @throws \EE_Error |
|
109 | + */ |
|
110 | 110 | public function available( $DTT_ID = 0 ) { |
111 | 111 | // are we checking availability for a particular datetime ? |
112 | 112 | if ( $DTT_ID ) { |
@@ -123,14 +123,14 @@ discard block |
||
123 | 123 | |
124 | 124 | |
125 | 125 | |
126 | - /** |
|
127 | - * Using the start date and end date this method calculates whether the ticket is On Sale, Pending, or Expired |
|
128 | - * |
|
129 | - * @param bool $display true = we'll return a localized string, otherwise we just return the value of the relevant status const |
|
130 | - * @param bool | null $remaining if it is already known that tickets are available, then simply pass a bool to save further processing |
|
131 | - * @return mixed status int if the display string isn't requested |
|
132 | - * @throws \EE_Error |
|
133 | - */ |
|
126 | + /** |
|
127 | + * Using the start date and end date this method calculates whether the ticket is On Sale, Pending, or Expired |
|
128 | + * |
|
129 | + * @param bool $display true = we'll return a localized string, otherwise we just return the value of the relevant status const |
|
130 | + * @param bool | null $remaining if it is already known that tickets are available, then simply pass a bool to save further processing |
|
131 | + * @return mixed status int if the display string isn't requested |
|
132 | + * @throws \EE_Error |
|
133 | + */ |
|
134 | 134 | public function ticket_status( $display = FALSE, $remaining = null ) { |
135 | 135 | $remaining = is_bool( $remaining ) ? $remaining : $this->is_remaining(); |
136 | 136 | if ( ! $remaining ) { |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | |
154 | 154 | |
155 | 155 | |
156 | - /** |
|
157 | - * The purpose of this method is to simply return a boolean for whether there are any tickets remaining for sale considering ALL the factors used for figuring that out. |
|
158 | - * |
|
159 | - * @access public |
|
160 | - * @param int $DTT_ID if an int above 0 is included here then we get a specific dtt. |
|
161 | - * @return boolean true = tickets remaining, false not. |
|
162 | - * @throws \EE_Error |
|
163 | - */ |
|
156 | + /** |
|
157 | + * The purpose of this method is to simply return a boolean for whether there are any tickets remaining for sale considering ALL the factors used for figuring that out. |
|
158 | + * |
|
159 | + * @access public |
|
160 | + * @param int $DTT_ID if an int above 0 is included here then we get a specific dtt. |
|
161 | + * @return boolean true = tickets remaining, false not. |
|
162 | + * @throws \EE_Error |
|
163 | + */ |
|
164 | 164 | public function is_remaining( $DTT_ID = 0 ) { |
165 | 165 | $num_remaining = $this->remaining( $DTT_ID ); |
166 | 166 | if ( $num_remaining === 0 ) { |
@@ -174,76 +174,76 @@ discard block |
||
174 | 174 | |
175 | 175 | |
176 | 176 | |
177 | - /** |
|
178 | - * return the total number of tickets available for purchase |
|
179 | - * |
|
180 | - * @param int $DTT_ID the primary key for a particular datetime. |
|
181 | - * set to 0 for all related datetimes |
|
182 | - * @return int |
|
183 | - * @throws \EE_Error |
|
184 | - */ |
|
177 | + /** |
|
178 | + * return the total number of tickets available for purchase |
|
179 | + * |
|
180 | + * @param int $DTT_ID the primary key for a particular datetime. |
|
181 | + * set to 0 for all related datetimes |
|
182 | + * @return int |
|
183 | + * @throws \EE_Error |
|
184 | + */ |
|
185 | 185 | public function remaining( $DTT_ID = 0 ) { |
186 | 186 | return $this->real_quantity_on_ticket('saleable', $DTT_ID ); |
187 | 187 | } |
188 | 188 | |
189 | 189 | |
190 | 190 | |
191 | - /** |
|
192 | - * Gets min |
|
193 | - * |
|
194 | - * @return int |
|
195 | - * @throws \EE_Error |
|
196 | - */ |
|
191 | + /** |
|
192 | + * Gets min |
|
193 | + * |
|
194 | + * @return int |
|
195 | + * @throws \EE_Error |
|
196 | + */ |
|
197 | 197 | public function min() { |
198 | 198 | return $this->get( 'TKT_min' ); |
199 | 199 | } |
200 | 200 | |
201 | 201 | |
202 | 202 | |
203 | - /** |
|
204 | - * return if a ticket is no longer available cause its available dates have expired. |
|
205 | - * |
|
206 | - * @return boolean |
|
207 | - * @throws \EE_Error |
|
208 | - */ |
|
203 | + /** |
|
204 | + * return if a ticket is no longer available cause its available dates have expired. |
|
205 | + * |
|
206 | + * @return boolean |
|
207 | + * @throws \EE_Error |
|
208 | + */ |
|
209 | 209 | public function is_expired() { |
210 | 210 | return ( $this->get_raw( 'TKT_end_date' ) < time() ); |
211 | 211 | } |
212 | 212 | |
213 | 213 | |
214 | 214 | |
215 | - /** |
|
216 | - * Return if a ticket is yet to go on sale or not |
|
217 | - * |
|
218 | - * @return boolean |
|
219 | - * @throws \EE_Error |
|
220 | - */ |
|
215 | + /** |
|
216 | + * Return if a ticket is yet to go on sale or not |
|
217 | + * |
|
218 | + * @return boolean |
|
219 | + * @throws \EE_Error |
|
220 | + */ |
|
221 | 221 | public function is_pending() { |
222 | 222 | return ( $this->get_raw( 'TKT_start_date' ) > time() ); |
223 | 223 | } |
224 | 224 | |
225 | 225 | |
226 | 226 | |
227 | - /** |
|
228 | - * Return if a ticket is on sale or not |
|
229 | - * |
|
230 | - * @return boolean |
|
231 | - * @throws \EE_Error |
|
232 | - */ |
|
227 | + /** |
|
228 | + * Return if a ticket is on sale or not |
|
229 | + * |
|
230 | + * @return boolean |
|
231 | + * @throws \EE_Error |
|
232 | + */ |
|
233 | 233 | public function is_on_sale() { |
234 | 234 | return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() ); |
235 | 235 | } |
236 | 236 | |
237 | 237 | |
238 | 238 | |
239 | - /** |
|
240 | - * This returns the chronologically last datetime that this ticket is associated with |
|
241 | - * |
|
242 | - * @param string $dt_frmt |
|
243 | - * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
|
244 | - * @return string |
|
245 | - * @throws \EE_Error |
|
246 | - */ |
|
239 | + /** |
|
240 | + * This returns the chronologically last datetime that this ticket is associated with |
|
241 | + * |
|
242 | + * @param string $dt_frmt |
|
243 | + * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
|
244 | + * @return string |
|
245 | + * @throws \EE_Error |
|
246 | + */ |
|
247 | 247 | public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
248 | 248 | $first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : ''; |
249 | 249 | $last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : ''; |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | |
254 | 254 | |
255 | 255 | |
256 | - /** |
|
257 | - * This returns the chronologically first datetime that this ticket is associated with |
|
258 | - * |
|
259 | - * @return EE_Datetime |
|
260 | - * @throws \EE_Error |
|
261 | - */ |
|
256 | + /** |
|
257 | + * This returns the chronologically first datetime that this ticket is associated with |
|
258 | + * |
|
259 | + * @return EE_Datetime |
|
260 | + * @throws \EE_Error |
|
261 | + */ |
|
262 | 262 | public function first_datetime() { |
263 | 263 | $datetimes = $this->datetimes( array( 'limit' => 1 ) ); |
264 | 264 | return reset( $datetimes ); |
@@ -266,14 +266,14 @@ discard block |
||
266 | 266 | |
267 | 267 | |
268 | 268 | |
269 | - /** |
|
270 | - * Gets all the datetimes this ticket can be used for attending. |
|
271 | - * Unless otherwise specified, orders datetimes by start date. |
|
272 | - * |
|
273 | - * @param array $query_params see EEM_Base::get_all() |
|
274 | - * @return EE_Datetime[]|EE_Base_Class[] |
|
275 | - * @throws \EE_Error |
|
276 | - */ |
|
269 | + /** |
|
270 | + * Gets all the datetimes this ticket can be used for attending. |
|
271 | + * Unless otherwise specified, orders datetimes by start date. |
|
272 | + * |
|
273 | + * @param array $query_params see EEM_Base::get_all() |
|
274 | + * @return EE_Datetime[]|EE_Base_Class[] |
|
275 | + * @throws \EE_Error |
|
276 | + */ |
|
277 | 277 | public function datetimes( $query_params = array() ) { |
278 | 278 | if ( ! isset( $query_params[ 'order_by' ] ) ) { |
279 | 279 | $query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC'; |
@@ -283,12 +283,12 @@ discard block |
||
283 | 283 | |
284 | 284 | |
285 | 285 | |
286 | - /** |
|
287 | - * This returns the chronologically last datetime that this ticket is associated with |
|
288 | - * |
|
289 | - * @return EE_Datetime |
|
290 | - * @throws \EE_Error |
|
291 | - */ |
|
286 | + /** |
|
287 | + * This returns the chronologically last datetime that this ticket is associated with |
|
288 | + * |
|
289 | + * @return EE_Datetime |
|
290 | + * @throws \EE_Error |
|
291 | + */ |
|
292 | 292 | public function last_datetime() { |
293 | 293 | $datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) ); |
294 | 294 | return end( $datetimes ); |
@@ -296,19 +296,19 @@ discard block |
||
296 | 296 | |
297 | 297 | |
298 | 298 | |
299 | - /** |
|
300 | - * This returns the total tickets sold depending on the given parameters. |
|
301 | - * |
|
302 | - * @param string $what Can be one of two options: 'ticket', 'datetime'. |
|
303 | - * 'ticket' = total ticket sales for all datetimes this ticket is related to |
|
304 | - * 'datetime' = total ticket sales for a specified datetime (required $dtt_id) |
|
305 | - * 'datetime' = total ticket sales in the datetime_ticket table. |
|
306 | - * If $dtt_id is not given then we return an array of sales indexed by datetime. |
|
307 | - * If $dtt_id IS given then we return the tickets sold for that given datetime. |
|
308 | - * @param int $dtt_id [optional] include the dtt_id with $what = 'datetime'. |
|
309 | - * @return mixed (array|int) how many tickets have sold |
|
310 | - * @throws \EE_Error |
|
311 | - */ |
|
299 | + /** |
|
300 | + * This returns the total tickets sold depending on the given parameters. |
|
301 | + * |
|
302 | + * @param string $what Can be one of two options: 'ticket', 'datetime'. |
|
303 | + * 'ticket' = total ticket sales for all datetimes this ticket is related to |
|
304 | + * 'datetime' = total ticket sales for a specified datetime (required $dtt_id) |
|
305 | + * 'datetime' = total ticket sales in the datetime_ticket table. |
|
306 | + * If $dtt_id is not given then we return an array of sales indexed by datetime. |
|
307 | + * If $dtt_id IS given then we return the tickets sold for that given datetime. |
|
308 | + * @param int $dtt_id [optional] include the dtt_id with $what = 'datetime'. |
|
309 | + * @return mixed (array|int) how many tickets have sold |
|
310 | + * @throws \EE_Error |
|
311 | + */ |
|
312 | 312 | public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) { |
313 | 313 | $total = 0; |
314 | 314 | $tickets_sold = $this->_all_tickets_sold(); |
@@ -333,12 +333,12 @@ discard block |
||
333 | 333 | |
334 | 334 | |
335 | 335 | |
336 | - /** |
|
337 | - * This returns an array indexed by datetime_id for tickets sold with this ticket. |
|
338 | - * |
|
339 | - * @return EE_Ticket[] |
|
340 | - * @throws \EE_Error |
|
341 | - */ |
|
336 | + /** |
|
337 | + * This returns an array indexed by datetime_id for tickets sold with this ticket. |
|
338 | + * |
|
339 | + * @return EE_Ticket[] |
|
340 | + * @throws \EE_Error |
|
341 | + */ |
|
342 | 342 | protected function _all_tickets_sold() { |
343 | 343 | $datetimes = $this->get_many_related( 'Datetime' ); |
344 | 344 | $tickets_sold = array(); |
@@ -354,29 +354,29 @@ discard block |
||
354 | 354 | |
355 | 355 | |
356 | 356 | |
357 | - /** |
|
358 | - * This returns the base price object for the ticket. |
|
359 | - * |
|
360 | - * @param bool $return_array whether to return as an array indexed by price id or just the object. |
|
361 | - * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[] |
|
362 | - * @throws \EE_Error |
|
363 | - */ |
|
357 | + /** |
|
358 | + * This returns the base price object for the ticket. |
|
359 | + * |
|
360 | + * @param bool $return_array whether to return as an array indexed by price id or just the object. |
|
361 | + * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[] |
|
362 | + * @throws \EE_Error |
|
363 | + */ |
|
364 | 364 | public function base_price( $return_array = FALSE ) { |
365 | 365 | $_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price ); |
366 | 366 | return $return_array |
367 | - ? $this->get_many_related( 'Price', array( $_where ) ) |
|
368 | - : $this->get_first_related( 'Price', array( $_where ) ); |
|
367 | + ? $this->get_many_related( 'Price', array( $_where ) ) |
|
368 | + : $this->get_first_related( 'Price', array( $_where ) ); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | |
372 | 372 | |
373 | - /** |
|
374 | - * This returns ONLY the price modifiers for the ticket (i.e. no taxes or base price) |
|
375 | - * |
|
376 | - * @access public |
|
377 | - * @return EE_Price[] |
|
378 | - * @throws \EE_Error |
|
379 | - */ |
|
373 | + /** |
|
374 | + * This returns ONLY the price modifiers for the ticket (i.e. no taxes or base price) |
|
375 | + * |
|
376 | + * @access public |
|
377 | + * @return EE_Price[] |
|
378 | + * @throws \EE_Error |
|
379 | + */ |
|
380 | 380 | public function price_modifiers() { |
381 | 381 | $query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) ); |
382 | 382 | return $this->prices( $query_params ); |
@@ -384,132 +384,132 @@ discard block |
||
384 | 384 | |
385 | 385 | |
386 | 386 | |
387 | - /** |
|
388 | - * Gets all the prices that combine to form the final price of this ticket |
|
389 | - * |
|
390 | - * @param array $query_params like EEM_Base::get_all |
|
391 | - * @return EE_Price[]|EE_Base_Class[] |
|
392 | - * @throws \EE_Error |
|
393 | - */ |
|
387 | + /** |
|
388 | + * Gets all the prices that combine to form the final price of this ticket |
|
389 | + * |
|
390 | + * @param array $query_params like EEM_Base::get_all |
|
391 | + * @return EE_Price[]|EE_Base_Class[] |
|
392 | + * @throws \EE_Error |
|
393 | + */ |
|
394 | 394 | public function prices( $query_params = array() ) { |
395 | 395 | return $this->get_many_related( 'Price', $query_params ); |
396 | 396 | } |
397 | 397 | |
398 | 398 | |
399 | 399 | |
400 | - /** |
|
401 | - * Gets all the ticket applicabilities (ie, relations between datetimes and tickets) |
|
402 | - * |
|
403 | - * @param array $query_params see EEM_Base::get_all() |
|
404 | - * @return EE_Datetime_Ticket|EE_Base_Class[] |
|
405 | - * @throws \EE_Error |
|
406 | - */ |
|
400 | + /** |
|
401 | + * Gets all the ticket applicabilities (ie, relations between datetimes and tickets) |
|
402 | + * |
|
403 | + * @param array $query_params see EEM_Base::get_all() |
|
404 | + * @return EE_Datetime_Ticket|EE_Base_Class[] |
|
405 | + * @throws \EE_Error |
|
406 | + */ |
|
407 | 407 | public function datetime_tickets( $query_params = array() ) { |
408 | 408 | return $this->get_many_related( 'Datetime_Ticket', $query_params ); |
409 | 409 | } |
410 | 410 | |
411 | 411 | |
412 | 412 | |
413 | - /** |
|
414 | - * Gets all the datetimes from the db ordered by DTT_order |
|
415 | - * |
|
416 | - * @param boolean $show_expired |
|
417 | - * @param boolean $show_deleted |
|
418 | - * @return EE_Datetime[] |
|
419 | - * @throws \EE_Error |
|
420 | - */ |
|
413 | + /** |
|
414 | + * Gets all the datetimes from the db ordered by DTT_order |
|
415 | + * |
|
416 | + * @param boolean $show_expired |
|
417 | + * @param boolean $show_deleted |
|
418 | + * @return EE_Datetime[] |
|
419 | + * @throws \EE_Error |
|
420 | + */ |
|
421 | 421 | public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) { |
422 | 422 | return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted ); |
423 | 423 | } |
424 | 424 | |
425 | 425 | |
426 | 426 | |
427 | - /** |
|
428 | - * Gets ID |
|
429 | - * |
|
430 | - * @return string |
|
431 | - * @throws \EE_Error |
|
432 | - */ |
|
427 | + /** |
|
428 | + * Gets ID |
|
429 | + * |
|
430 | + * @return string |
|
431 | + * @throws \EE_Error |
|
432 | + */ |
|
433 | 433 | public function ID() { |
434 | 434 | return $this->get( 'TKT_ID' ); |
435 | 435 | } |
436 | 436 | |
437 | 437 | |
438 | 438 | |
439 | - /** |
|
440 | - * get the author of the ticket. |
|
441 | - * |
|
442 | - * @since 4.5.0 |
|
443 | - * @return int |
|
444 | - * @throws \EE_Error |
|
445 | - */ |
|
439 | + /** |
|
440 | + * get the author of the ticket. |
|
441 | + * |
|
442 | + * @since 4.5.0 |
|
443 | + * @return int |
|
444 | + * @throws \EE_Error |
|
445 | + */ |
|
446 | 446 | public function wp_user() { |
447 | 447 | return $this->get('TKT_wp_user'); |
448 | 448 | } |
449 | 449 | |
450 | 450 | |
451 | 451 | |
452 | - /** |
|
453 | - * Gets the template for the ticket |
|
454 | - * |
|
455 | - * @return EE_Ticket_Template|EE_Base_Class |
|
456 | - * @throws \EE_Error |
|
457 | - */ |
|
452 | + /** |
|
453 | + * Gets the template for the ticket |
|
454 | + * |
|
455 | + * @return EE_Ticket_Template|EE_Base_Class |
|
456 | + * @throws \EE_Error |
|
457 | + */ |
|
458 | 458 | public function template() { |
459 | 459 | return $this->get_first_related( 'Ticket_Template' ); |
460 | 460 | } |
461 | 461 | |
462 | 462 | |
463 | 463 | |
464 | - /** |
|
465 | - * Simply returns an array of EE_Price objects that are taxes. |
|
466 | - * |
|
467 | - * @return EE_Price[] |
|
468 | - * @throws \EE_Error |
|
469 | - */ |
|
464 | + /** |
|
465 | + * Simply returns an array of EE_Price objects that are taxes. |
|
466 | + * |
|
467 | + * @return EE_Price[] |
|
468 | + * @throws \EE_Error |
|
469 | + */ |
|
470 | 470 | public function get_ticket_taxes_for_admin() { |
471 | 471 | return EE_Taxes::get_taxes_for_admin(); |
472 | 472 | } |
473 | 473 | |
474 | 474 | |
475 | 475 | |
476 | - /** |
|
477 | - * @return float |
|
478 | - * @throws \EE_Error |
|
479 | - */ |
|
476 | + /** |
|
477 | + * @return float |
|
478 | + * @throws \EE_Error |
|
479 | + */ |
|
480 | 480 | public function ticket_price() { |
481 | 481 | return $this->get( 'TKT_price' ); |
482 | 482 | } |
483 | 483 | |
484 | 484 | |
485 | 485 | |
486 | - /** |
|
487 | - * @return mixed |
|
488 | - * @throws \EE_Error |
|
489 | - */ |
|
486 | + /** |
|
487 | + * @return mixed |
|
488 | + * @throws \EE_Error |
|
489 | + */ |
|
490 | 490 | public function pretty_price() { |
491 | 491 | return $this->get_pretty( 'TKT_price' ); |
492 | 492 | } |
493 | 493 | |
494 | 494 | |
495 | 495 | |
496 | - /** |
|
497 | - * @return bool |
|
498 | - * @throws \EE_Error |
|
499 | - */ |
|
496 | + /** |
|
497 | + * @return bool |
|
498 | + * @throws \EE_Error |
|
499 | + */ |
|
500 | 500 | public function is_free() { |
501 | 501 | return $this->get_ticket_total_with_taxes() === 0; |
502 | 502 | } |
503 | 503 | |
504 | 504 | |
505 | 505 | |
506 | - /** |
|
507 | - * get_ticket_total_with_taxes |
|
508 | - * |
|
509 | - * @param bool $no_cache |
|
510 | - * @return float |
|
511 | - * @throws \EE_Error |
|
512 | - */ |
|
506 | + /** |
|
507 | + * get_ticket_total_with_taxes |
|
508 | + * |
|
509 | + * @param bool $no_cache |
|
510 | + * @return float |
|
511 | + * @throws \EE_Error |
|
512 | + */ |
|
513 | 513 | public function get_ticket_total_with_taxes( $no_cache = FALSE ) { |
514 | 514 | if ($this->_ticket_total_with_taxes === null || $no_cache ) { |
515 | 515 | $this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin(); |
@@ -526,201 +526,201 @@ discard block |
||
526 | 526 | |
527 | 527 | |
528 | 528 | |
529 | - /** |
|
530 | - * @return float |
|
531 | - * @throws \EE_Error |
|
532 | - */ |
|
529 | + /** |
|
530 | + * @return float |
|
531 | + * @throws \EE_Error |
|
532 | + */ |
|
533 | 533 | public function get_ticket_subtotal() { |
534 | 534 | return EE_Taxes::get_subtotal_for_admin( $this ); |
535 | 535 | } |
536 | 536 | |
537 | 537 | |
538 | 538 | |
539 | - /** |
|
540 | - * Returns the total taxes applied to this ticket |
|
541 | - * |
|
542 | - * @return float |
|
543 | - * @throws \EE_Error |
|
544 | - */ |
|
539 | + /** |
|
540 | + * Returns the total taxes applied to this ticket |
|
541 | + * |
|
542 | + * @return float |
|
543 | + * @throws \EE_Error |
|
544 | + */ |
|
545 | 545 | public function get_ticket_taxes_total_for_admin() { |
546 | 546 | return EE_Taxes::get_total_taxes_for_admin( $this ); |
547 | 547 | } |
548 | 548 | |
549 | 549 | |
550 | 550 | |
551 | - /** |
|
552 | - * Sets name |
|
553 | - * |
|
554 | - * @param string $name |
|
555 | - * @throws \EE_Error |
|
556 | - */ |
|
551 | + /** |
|
552 | + * Sets name |
|
553 | + * |
|
554 | + * @param string $name |
|
555 | + * @throws \EE_Error |
|
556 | + */ |
|
557 | 557 | public function set_name( $name ) { |
558 | 558 | $this->set( 'TKT_name', $name ); |
559 | 559 | } |
560 | 560 | |
561 | 561 | |
562 | 562 | |
563 | - /** |
|
564 | - * Gets description |
|
565 | - * |
|
566 | - * @return string |
|
567 | - * @throws \EE_Error |
|
568 | - */ |
|
563 | + /** |
|
564 | + * Gets description |
|
565 | + * |
|
566 | + * @return string |
|
567 | + * @throws \EE_Error |
|
568 | + */ |
|
569 | 569 | public function description() { |
570 | 570 | return $this->get( 'TKT_description' ); |
571 | 571 | } |
572 | 572 | |
573 | 573 | |
574 | 574 | |
575 | - /** |
|
576 | - * Sets description |
|
577 | - * |
|
578 | - * @param string $description |
|
579 | - * @throws \EE_Error |
|
580 | - */ |
|
575 | + /** |
|
576 | + * Sets description |
|
577 | + * |
|
578 | + * @param string $description |
|
579 | + * @throws \EE_Error |
|
580 | + */ |
|
581 | 581 | public function set_description( $description ) { |
582 | 582 | $this->set( 'TKT_description', $description ); |
583 | 583 | } |
584 | 584 | |
585 | 585 | |
586 | 586 | |
587 | - /** |
|
588 | - * Gets start_date |
|
589 | - * |
|
590 | - * @param string $dt_frmt |
|
591 | - * @param string $tm_frmt |
|
592 | - * @return string |
|
593 | - * @throws \EE_Error |
|
594 | - */ |
|
587 | + /** |
|
588 | + * Gets start_date |
|
589 | + * |
|
590 | + * @param string $dt_frmt |
|
591 | + * @param string $tm_frmt |
|
592 | + * @return string |
|
593 | + * @throws \EE_Error |
|
594 | + */ |
|
595 | 595 | public function start_date( $dt_frmt = '', $tm_frmt = '' ) { |
596 | 596 | return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt ); |
597 | 597 | } |
598 | 598 | |
599 | 599 | |
600 | 600 | |
601 | - /** |
|
602 | - * Sets start_date |
|
603 | - * |
|
604 | - * @param string $start_date |
|
605 | - * @return void |
|
606 | - * @throws \EE_Error |
|
607 | - */ |
|
601 | + /** |
|
602 | + * Sets start_date |
|
603 | + * |
|
604 | + * @param string $start_date |
|
605 | + * @return void |
|
606 | + * @throws \EE_Error |
|
607 | + */ |
|
608 | 608 | public function set_start_date( $start_date ) { |
609 | 609 | $this->_set_date_time( 'B', $start_date, 'TKT_start_date' ); |
610 | 610 | } |
611 | 611 | |
612 | 612 | |
613 | 613 | |
614 | - /** |
|
615 | - * Gets end_date |
|
616 | - * |
|
617 | - * @param string $dt_frmt |
|
618 | - * @param string $tm_frmt |
|
619 | - * @return string |
|
620 | - * @throws \EE_Error |
|
621 | - */ |
|
614 | + /** |
|
615 | + * Gets end_date |
|
616 | + * |
|
617 | + * @param string $dt_frmt |
|
618 | + * @param string $tm_frmt |
|
619 | + * @return string |
|
620 | + * @throws \EE_Error |
|
621 | + */ |
|
622 | 622 | public function end_date( $dt_frmt = '', $tm_frmt = '' ) { |
623 | 623 | return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt ); |
624 | 624 | } |
625 | 625 | |
626 | 626 | |
627 | 627 | |
628 | - /** |
|
629 | - * Sets end_date |
|
630 | - * |
|
631 | - * @param string $end_date |
|
632 | - * @return void |
|
633 | - * @throws \EE_Error |
|
634 | - */ |
|
628 | + /** |
|
629 | + * Sets end_date |
|
630 | + * |
|
631 | + * @param string $end_date |
|
632 | + * @return void |
|
633 | + * @throws \EE_Error |
|
634 | + */ |
|
635 | 635 | public function set_end_date( $end_date ) { |
636 | 636 | $this->_set_date_time( 'B', $end_date, 'TKT_end_date' ); |
637 | 637 | } |
638 | 638 | |
639 | 639 | |
640 | 640 | |
641 | - /** |
|
642 | - * Sets sell until time |
|
643 | - * |
|
644 | - * @since 4.5.0 |
|
645 | - * @param string $time a string representation of the sell until time (ex 9am or 7:30pm) |
|
646 | - * @throws \EE_Error |
|
647 | - */ |
|
641 | + /** |
|
642 | + * Sets sell until time |
|
643 | + * |
|
644 | + * @since 4.5.0 |
|
645 | + * @param string $time a string representation of the sell until time (ex 9am or 7:30pm) |
|
646 | + * @throws \EE_Error |
|
647 | + */ |
|
648 | 648 | public function set_end_time( $time ) { |
649 | 649 | $this->_set_time_for( $time, 'TKT_end_date' ); |
650 | 650 | } |
651 | 651 | |
652 | 652 | |
653 | 653 | |
654 | - /** |
|
655 | - * Sets min |
|
656 | - * |
|
657 | - * @param int $min |
|
658 | - * @return void |
|
659 | - * @throws \EE_Error |
|
660 | - */ |
|
654 | + /** |
|
655 | + * Sets min |
|
656 | + * |
|
657 | + * @param int $min |
|
658 | + * @return void |
|
659 | + * @throws \EE_Error |
|
660 | + */ |
|
661 | 661 | public function set_min( $min ) { |
662 | 662 | $this->set( 'TKT_min', $min ); |
663 | 663 | } |
664 | 664 | |
665 | 665 | |
666 | 666 | |
667 | - /** |
|
668 | - * Gets max |
|
669 | - * |
|
670 | - * @return int |
|
671 | - * @throws \EE_Error |
|
672 | - */ |
|
667 | + /** |
|
668 | + * Gets max |
|
669 | + * |
|
670 | + * @return int |
|
671 | + * @throws \EE_Error |
|
672 | + */ |
|
673 | 673 | public function max() { |
674 | 674 | return $this->get( 'TKT_max' ); |
675 | 675 | } |
676 | 676 | |
677 | 677 | |
678 | 678 | |
679 | - /** |
|
680 | - * Sets max |
|
681 | - * |
|
682 | - * @param int $max |
|
683 | - * @return void |
|
684 | - * @throws \EE_Error |
|
685 | - */ |
|
679 | + /** |
|
680 | + * Sets max |
|
681 | + * |
|
682 | + * @param int $max |
|
683 | + * @return void |
|
684 | + * @throws \EE_Error |
|
685 | + */ |
|
686 | 686 | public function set_max( $max ) { |
687 | 687 | $this->set( 'TKT_max', $max ); |
688 | 688 | } |
689 | 689 | |
690 | 690 | |
691 | 691 | |
692 | - /** |
|
693 | - * Sets price |
|
694 | - * |
|
695 | - * @param float $price |
|
696 | - * @return void |
|
697 | - * @throws \EE_Error |
|
698 | - */ |
|
692 | + /** |
|
693 | + * Sets price |
|
694 | + * |
|
695 | + * @param float $price |
|
696 | + * @return void |
|
697 | + * @throws \EE_Error |
|
698 | + */ |
|
699 | 699 | public function set_price( $price ) { |
700 | 700 | $this->set( 'TKT_price', $price ); |
701 | 701 | } |
702 | 702 | |
703 | 703 | |
704 | 704 | |
705 | - /** |
|
706 | - * Gets sold |
|
707 | - * |
|
708 | - * @return int |
|
709 | - * @throws \EE_Error |
|
710 | - */ |
|
705 | + /** |
|
706 | + * Gets sold |
|
707 | + * |
|
708 | + * @return int |
|
709 | + * @throws \EE_Error |
|
710 | + */ |
|
711 | 711 | public function sold() { |
712 | 712 | return $this->get_raw( 'TKT_sold' ); |
713 | 713 | } |
714 | 714 | |
715 | 715 | |
716 | 716 | |
717 | - /** |
|
718 | - * Sets sold |
|
719 | - * |
|
720 | - * @param int $sold |
|
721 | - * @return void |
|
722 | - * @throws \EE_Error |
|
723 | - */ |
|
717 | + /** |
|
718 | + * Sets sold |
|
719 | + * |
|
720 | + * @param int $sold |
|
721 | + * @return void |
|
722 | + * @throws \EE_Error |
|
723 | + */ |
|
724 | 724 | public function set_sold( $sold ) { |
725 | 725 | // sold can not go below zero |
726 | 726 | $sold = max( 0, $sold ); |
@@ -729,13 +729,13 @@ discard block |
||
729 | 729 | |
730 | 730 | |
731 | 731 | |
732 | - /** |
|
733 | - * increments sold by amount passed by $qty |
|
734 | - * |
|
735 | - * @param int $qty |
|
736 | - * @return void |
|
737 | - * @throws \EE_Error |
|
738 | - */ |
|
732 | + /** |
|
733 | + * increments sold by amount passed by $qty |
|
734 | + * |
|
735 | + * @param int $qty |
|
736 | + * @return void |
|
737 | + * @throws \EE_Error |
|
738 | + */ |
|
739 | 739 | public function increase_sold( $qty = 1 ) { |
740 | 740 | $sold = $this->sold() + $qty; |
741 | 741 | // remove ticket reservation, but don't adjust datetime reservations, because that will happen |
@@ -747,13 +747,13 @@ discard block |
||
747 | 747 | |
748 | 748 | |
749 | 749 | |
750 | - /** |
|
751 | - * Increases sold on related datetimes |
|
752 | - * |
|
753 | - * @param int $qty |
|
754 | - * @return void |
|
755 | - * @throws \EE_Error |
|
756 | - */ |
|
750 | + /** |
|
751 | + * Increases sold on related datetimes |
|
752 | + * |
|
753 | + * @param int $qty |
|
754 | + * @return void |
|
755 | + * @throws \EE_Error |
|
756 | + */ |
|
757 | 757 | protected function _increase_sold_for_datetimes( $qty = 1 ) { |
758 | 758 | $datetimes = $this->datetimes(); |
759 | 759 | if ( is_array( $datetimes ) ) { |
@@ -768,13 +768,13 @@ discard block |
||
768 | 768 | |
769 | 769 | |
770 | 770 | |
771 | - /** |
|
772 | - * decrements (subtracts) sold by amount passed by $qty |
|
773 | - * |
|
774 | - * @param int $qty |
|
775 | - * @return void |
|
776 | - * @throws \EE_Error |
|
777 | - */ |
|
771 | + /** |
|
772 | + * decrements (subtracts) sold by amount passed by $qty |
|
773 | + * |
|
774 | + * @param int $qty |
|
775 | + * @return void |
|
776 | + * @throws \EE_Error |
|
777 | + */ |
|
778 | 778 | public function decrease_sold( $qty = 1 ) { |
779 | 779 | $sold = $this->sold() - $qty; |
780 | 780 | $this->_decrease_sold_for_datetimes( $qty ); |
@@ -783,13 +783,13 @@ discard block |
||
783 | 783 | |
784 | 784 | |
785 | 785 | |
786 | - /** |
|
787 | - * Decreases sold on related datetimes |
|
788 | - * |
|
789 | - * @param int $qty |
|
790 | - * @return void |
|
791 | - * @throws \EE_Error |
|
792 | - */ |
|
786 | + /** |
|
787 | + * Decreases sold on related datetimes |
|
788 | + * |
|
789 | + * @param int $qty |
|
790 | + * @return void |
|
791 | + * @throws \EE_Error |
|
792 | + */ |
|
793 | 793 | protected function _decrease_sold_for_datetimes( $qty = 1 ) { |
794 | 794 | $datetimes = $this->datetimes(); |
795 | 795 | if ( is_array( $datetimes ) ) { |
@@ -804,25 +804,25 @@ discard block |
||
804 | 804 | |
805 | 805 | |
806 | 806 | |
807 | - /** |
|
808 | - * Gets qty of reserved tickets |
|
809 | - * |
|
810 | - * @return int |
|
811 | - * @throws \EE_Error |
|
812 | - */ |
|
807 | + /** |
|
808 | + * Gets qty of reserved tickets |
|
809 | + * |
|
810 | + * @return int |
|
811 | + * @throws \EE_Error |
|
812 | + */ |
|
813 | 813 | public function reserved() { |
814 | 814 | return $this->get_raw( 'TKT_reserved' ); |
815 | 815 | } |
816 | 816 | |
817 | 817 | |
818 | 818 | |
819 | - /** |
|
820 | - * Sets reserved |
|
821 | - * |
|
822 | - * @param int $reserved |
|
823 | - * @return void |
|
824 | - * @throws \EE_Error |
|
825 | - */ |
|
819 | + /** |
|
820 | + * Sets reserved |
|
821 | + * |
|
822 | + * @param int $reserved |
|
823 | + * @return void |
|
824 | + * @throws \EE_Error |
|
825 | + */ |
|
826 | 826 | public function set_reserved( $reserved ) { |
827 | 827 | // reserved can not go below zero |
828 | 828 | $reserved = max( 0, (int) $reserved ); |
@@ -831,13 +831,13 @@ discard block |
||
831 | 831 | |
832 | 832 | |
833 | 833 | |
834 | - /** |
|
835 | - * increments reserved by amount passed by $qty |
|
836 | - * |
|
837 | - * @param int $qty |
|
838 | - * @return void |
|
839 | - * @throws \EE_Error |
|
840 | - */ |
|
834 | + /** |
|
835 | + * increments reserved by amount passed by $qty |
|
836 | + * |
|
837 | + * @param int $qty |
|
838 | + * @return void |
|
839 | + * @throws \EE_Error |
|
840 | + */ |
|
841 | 841 | public function increase_reserved( $qty = 1 ) { |
842 | 842 | $qty = absint( $qty ); |
843 | 843 | $reserved = $this->reserved() + $qty; |
@@ -847,13 +847,13 @@ discard block |
||
847 | 847 | |
848 | 848 | |
849 | 849 | |
850 | - /** |
|
851 | - * Increases sold on related datetimes |
|
852 | - * |
|
853 | - * @param int $qty |
|
854 | - * @return void |
|
855 | - * @throws \EE_Error |
|
856 | - */ |
|
850 | + /** |
|
851 | + * Increases sold on related datetimes |
|
852 | + * |
|
853 | + * @param int $qty |
|
854 | + * @return void |
|
855 | + * @throws \EE_Error |
|
856 | + */ |
|
857 | 857 | protected function _increase_reserved_for_datetimes( $qty = 1 ) { |
858 | 858 | $datetimes = $this->datetimes(); |
859 | 859 | if ( is_array( $datetimes ) ) { |
@@ -868,14 +868,14 @@ discard block |
||
868 | 868 | |
869 | 869 | |
870 | 870 | |
871 | - /** |
|
872 | - * decrements (subtracts) reserved by amount passed by $qty |
|
873 | - * |
|
874 | - * @param int $qty |
|
875 | - * @param bool $adjust_datetimes |
|
876 | - * @return void |
|
877 | - * @throws \EE_Error |
|
878 | - */ |
|
871 | + /** |
|
872 | + * decrements (subtracts) reserved by amount passed by $qty |
|
873 | + * |
|
874 | + * @param int $qty |
|
875 | + * @param bool $adjust_datetimes |
|
876 | + * @return void |
|
877 | + * @throws \EE_Error |
|
878 | + */ |
|
879 | 879 | public function decrease_reserved( $qty = 1, $adjust_datetimes = true ) { |
880 | 880 | $reserved = $this->reserved() - absint( $qty ); |
881 | 881 | if ( $adjust_datetimes ) { |
@@ -886,13 +886,13 @@ discard block |
||
886 | 886 | |
887 | 887 | |
888 | 888 | |
889 | - /** |
|
890 | - * Increases sold on related datetimes |
|
891 | - * |
|
892 | - * @param int $qty |
|
893 | - * @return void |
|
894 | - * @throws \EE_Error |
|
895 | - */ |
|
889 | + /** |
|
890 | + * Increases sold on related datetimes |
|
891 | + * |
|
892 | + * @param int $qty |
|
893 | + * @return void |
|
894 | + * @throws \EE_Error |
|
895 | + */ |
|
896 | 896 | protected function _decrease_reserved_for_datetimes( $qty = 1 ) { |
897 | 897 | $datetimes = $this->datetimes(); |
898 | 898 | if ( is_array( $datetimes ) ) { |
@@ -907,18 +907,18 @@ discard block |
||
907 | 907 | |
908 | 908 | |
909 | 909 | |
910 | - /** |
|
911 | - * Gets ticket quantity |
|
912 | - * |
|
913 | - * @param string $context ticket quantity is somewhat subjective depending on the exact information sought |
|
914 | - * therefore $context can be one of three values: '', 'reg_limit', or 'saleable' |
|
915 | - * '' (default) quantity is the actual db value for TKT_qty, unaffected by other objects |
|
916 | - * REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes |
|
917 | - * SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and |
|
918 | - * is therefore the truest measure of tickets that can be purchased at the moment |
|
919 | - * @return int |
|
920 | - * @throws \EE_Error |
|
921 | - */ |
|
910 | + /** |
|
911 | + * Gets ticket quantity |
|
912 | + * |
|
913 | + * @param string $context ticket quantity is somewhat subjective depending on the exact information sought |
|
914 | + * therefore $context can be one of three values: '', 'reg_limit', or 'saleable' |
|
915 | + * '' (default) quantity is the actual db value for TKT_qty, unaffected by other objects |
|
916 | + * REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes |
|
917 | + * SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and |
|
918 | + * is therefore the truest measure of tickets that can be purchased at the moment |
|
919 | + * @return int |
|
920 | + * @throws \EE_Error |
|
921 | + */ |
|
922 | 922 | public function qty( $context = '' ) { |
923 | 923 | switch ( $context ) { |
924 | 924 | case 'reg_limit' : |
@@ -932,19 +932,19 @@ discard block |
||
932 | 932 | |
933 | 933 | |
934 | 934 | |
935 | - /** |
|
936 | - * Gets ticket quantity |
|
937 | - * |
|
938 | - * @param string $context ticket quantity is somewhat subjective depending on the exact information sought |
|
939 | - * therefore $context can be one of two values: 'reg_limit', or 'saleable' |
|
940 | - * REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes |
|
941 | - * SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and |
|
942 | - * is therefore the truest measure of tickets that can be purchased at the moment |
|
943 | - * @param int $DTT_ID the primary key for a particular datetime. |
|
944 | - * set to 0 for all related datetimes |
|
945 | - * @return int |
|
946 | - * @throws \EE_Error |
|
947 | - */ |
|
935 | + /** |
|
936 | + * Gets ticket quantity |
|
937 | + * |
|
938 | + * @param string $context ticket quantity is somewhat subjective depending on the exact information sought |
|
939 | + * therefore $context can be one of two values: 'reg_limit', or 'saleable' |
|
940 | + * REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes |
|
941 | + * SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and |
|
942 | + * is therefore the truest measure of tickets that can be purchased at the moment |
|
943 | + * @param int $DTT_ID the primary key for a particular datetime. |
|
944 | + * set to 0 for all related datetimes |
|
945 | + * @return int |
|
946 | + * @throws \EE_Error |
|
947 | + */ |
|
948 | 948 | public function real_quantity_on_ticket( $context = 'reg_limit', $DTT_ID = 0 ) { |
949 | 949 | $raw = $this->get_raw( 'TKT_qty' ); |
950 | 950 | // return immediately if it's zero |
@@ -1027,212 +1027,212 @@ discard block |
||
1027 | 1027 | |
1028 | 1028 | |
1029 | 1029 | |
1030 | - /** |
|
1031 | - * Gets uses |
|
1032 | - * |
|
1033 | - * @return int |
|
1034 | - * @throws \EE_Error |
|
1035 | - */ |
|
1030 | + /** |
|
1031 | + * Gets uses |
|
1032 | + * |
|
1033 | + * @return int |
|
1034 | + * @throws \EE_Error |
|
1035 | + */ |
|
1036 | 1036 | public function uses() { |
1037 | 1037 | return $this->get( 'TKT_uses' ); |
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | |
1041 | 1041 | |
1042 | - /** |
|
1043 | - * Sets uses |
|
1044 | - * |
|
1045 | - * @param int $uses |
|
1046 | - * @return void |
|
1047 | - * @throws \EE_Error |
|
1048 | - */ |
|
1042 | + /** |
|
1043 | + * Sets uses |
|
1044 | + * |
|
1045 | + * @param int $uses |
|
1046 | + * @return void |
|
1047 | + * @throws \EE_Error |
|
1048 | + */ |
|
1049 | 1049 | public function set_uses( $uses ) { |
1050 | 1050 | $this->set( 'TKT_uses', $uses ); |
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | |
1054 | 1054 | |
1055 | - /** |
|
1056 | - * returns whether ticket is required or not. |
|
1057 | - * |
|
1058 | - * @return boolean |
|
1059 | - * @throws \EE_Error |
|
1060 | - */ |
|
1055 | + /** |
|
1056 | + * returns whether ticket is required or not. |
|
1057 | + * |
|
1058 | + * @return boolean |
|
1059 | + * @throws \EE_Error |
|
1060 | + */ |
|
1061 | 1061 | public function required() { |
1062 | 1062 | return $this->get( 'TKT_required' ); |
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | |
1066 | 1066 | |
1067 | - /** |
|
1068 | - * sets the TKT_required property |
|
1069 | - * |
|
1070 | - * @param boolean $required |
|
1071 | - * @return void |
|
1072 | - * @throws \EE_Error |
|
1073 | - */ |
|
1067 | + /** |
|
1068 | + * sets the TKT_required property |
|
1069 | + * |
|
1070 | + * @param boolean $required |
|
1071 | + * @return void |
|
1072 | + * @throws \EE_Error |
|
1073 | + */ |
|
1074 | 1074 | public function set_required( $required ) { |
1075 | 1075 | $this->set( 'TKT_required', $required ); |
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | |
1079 | 1079 | |
1080 | - /** |
|
1081 | - * Gets taxable |
|
1082 | - * |
|
1083 | - * @return boolean |
|
1084 | - * @throws \EE_Error |
|
1085 | - */ |
|
1080 | + /** |
|
1081 | + * Gets taxable |
|
1082 | + * |
|
1083 | + * @return boolean |
|
1084 | + * @throws \EE_Error |
|
1085 | + */ |
|
1086 | 1086 | public function taxable() { |
1087 | 1087 | return $this->get( 'TKT_taxable' ); |
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | |
1091 | 1091 | |
1092 | - /** |
|
1093 | - * Sets taxable |
|
1094 | - * |
|
1095 | - * @param boolean $taxable |
|
1096 | - * @return void |
|
1097 | - * @throws \EE_Error |
|
1098 | - */ |
|
1092 | + /** |
|
1093 | + * Sets taxable |
|
1094 | + * |
|
1095 | + * @param boolean $taxable |
|
1096 | + * @return void |
|
1097 | + * @throws \EE_Error |
|
1098 | + */ |
|
1099 | 1099 | public function set_taxable( $taxable ) { |
1100 | 1100 | $this->set( 'TKT_taxable', $taxable ); |
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | |
1104 | 1104 | |
1105 | - /** |
|
1106 | - * Gets is_default |
|
1107 | - * |
|
1108 | - * @return boolean |
|
1109 | - * @throws \EE_Error |
|
1110 | - */ |
|
1105 | + /** |
|
1106 | + * Gets is_default |
|
1107 | + * |
|
1108 | + * @return boolean |
|
1109 | + * @throws \EE_Error |
|
1110 | + */ |
|
1111 | 1111 | public function is_default() { |
1112 | 1112 | return $this->get( 'TKT_is_default' ); |
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | |
1116 | 1116 | |
1117 | - /** |
|
1118 | - * Sets is_default |
|
1119 | - * |
|
1120 | - * @param boolean $is_default |
|
1121 | - * @return void |
|
1122 | - * @throws \EE_Error |
|
1123 | - */ |
|
1117 | + /** |
|
1118 | + * Sets is_default |
|
1119 | + * |
|
1120 | + * @param boolean $is_default |
|
1121 | + * @return void |
|
1122 | + * @throws \EE_Error |
|
1123 | + */ |
|
1124 | 1124 | public function set_is_default( $is_default ) { |
1125 | 1125 | $this->set( 'TKT_is_default', $is_default ); |
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | |
1129 | 1129 | |
1130 | - /** |
|
1131 | - * Gets order |
|
1132 | - * |
|
1133 | - * @return int |
|
1134 | - * @throws \EE_Error |
|
1135 | - */ |
|
1130 | + /** |
|
1131 | + * Gets order |
|
1132 | + * |
|
1133 | + * @return int |
|
1134 | + * @throws \EE_Error |
|
1135 | + */ |
|
1136 | 1136 | public function order() { |
1137 | 1137 | return $this->get( 'TKT_order' ); |
1138 | 1138 | } |
1139 | 1139 | |
1140 | 1140 | |
1141 | 1141 | |
1142 | - /** |
|
1143 | - * Sets order |
|
1144 | - * |
|
1145 | - * @param int $order |
|
1146 | - * @return void |
|
1147 | - * @throws \EE_Error |
|
1148 | - */ |
|
1142 | + /** |
|
1143 | + * Sets order |
|
1144 | + * |
|
1145 | + * @param int $order |
|
1146 | + * @return void |
|
1147 | + * @throws \EE_Error |
|
1148 | + */ |
|
1149 | 1149 | public function set_order( $order ) { |
1150 | 1150 | $this->set( 'TKT_order', $order ); |
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | |
1154 | 1154 | |
1155 | - /** |
|
1156 | - * Gets row |
|
1157 | - * |
|
1158 | - * @return int |
|
1159 | - * @throws \EE_Error |
|
1160 | - */ |
|
1155 | + /** |
|
1156 | + * Gets row |
|
1157 | + * |
|
1158 | + * @return int |
|
1159 | + * @throws \EE_Error |
|
1160 | + */ |
|
1161 | 1161 | public function row() { |
1162 | 1162 | return $this->get( 'TKT_row' ); |
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | |
1166 | 1166 | |
1167 | - /** |
|
1168 | - * Sets row |
|
1169 | - * |
|
1170 | - * @param int $row |
|
1171 | - * @return void |
|
1172 | - * @throws \EE_Error |
|
1173 | - */ |
|
1167 | + /** |
|
1168 | + * Sets row |
|
1169 | + * |
|
1170 | + * @param int $row |
|
1171 | + * @return void |
|
1172 | + * @throws \EE_Error |
|
1173 | + */ |
|
1174 | 1174 | public function set_row( $row ) { |
1175 | 1175 | $this->set( 'TKT_row', $row ); |
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | |
1179 | 1179 | |
1180 | - /** |
|
1181 | - * Gets deleted |
|
1182 | - * |
|
1183 | - * @return boolean |
|
1184 | - * @throws \EE_Error |
|
1185 | - */ |
|
1180 | + /** |
|
1181 | + * Gets deleted |
|
1182 | + * |
|
1183 | + * @return boolean |
|
1184 | + * @throws \EE_Error |
|
1185 | + */ |
|
1186 | 1186 | public function deleted() { |
1187 | 1187 | return $this->get( 'TKT_deleted' ); |
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | |
1191 | 1191 | |
1192 | - /** |
|
1193 | - * Sets deleted |
|
1194 | - * |
|
1195 | - * @param boolean $deleted |
|
1196 | - * @return void |
|
1197 | - * @throws \EE_Error |
|
1198 | - */ |
|
1192 | + /** |
|
1193 | + * Sets deleted |
|
1194 | + * |
|
1195 | + * @param boolean $deleted |
|
1196 | + * @return void |
|
1197 | + * @throws \EE_Error |
|
1198 | + */ |
|
1199 | 1199 | public function set_deleted( $deleted ) { |
1200 | 1200 | $this->set( 'TKT_deleted', $deleted ); |
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | |
1204 | 1204 | |
1205 | - /** |
|
1206 | - * Gets parent |
|
1207 | - * |
|
1208 | - * @return int |
|
1209 | - * @throws \EE_Error |
|
1210 | - */ |
|
1205 | + /** |
|
1206 | + * Gets parent |
|
1207 | + * |
|
1208 | + * @return int |
|
1209 | + * @throws \EE_Error |
|
1210 | + */ |
|
1211 | 1211 | public function parent_ID() { |
1212 | 1212 | return $this->get( 'TKT_parent' ); |
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | |
1216 | 1216 | |
1217 | - /** |
|
1218 | - * Sets parent |
|
1219 | - * |
|
1220 | - * @param int $parent |
|
1221 | - * @return void |
|
1222 | - * @throws \EE_Error |
|
1223 | - */ |
|
1217 | + /** |
|
1218 | + * Sets parent |
|
1219 | + * |
|
1220 | + * @param int $parent |
|
1221 | + * @return void |
|
1222 | + * @throws \EE_Error |
|
1223 | + */ |
|
1224 | 1224 | public function set_parent_ID( $parent ) { |
1225 | 1225 | $this->set( 'TKT_parent', $parent ); |
1226 | 1226 | } |
1227 | 1227 | |
1228 | 1228 | |
1229 | 1229 | |
1230 | - /** |
|
1231 | - * Gets a string which is handy for showing in gateways etc that describes the ticket. |
|
1232 | - * |
|
1233 | - * @return string |
|
1234 | - * @throws \EE_Error |
|
1235 | - */ |
|
1230 | + /** |
|
1231 | + * Gets a string which is handy for showing in gateways etc that describes the ticket. |
|
1232 | + * |
|
1233 | + * @return string |
|
1234 | + * @throws \EE_Error |
|
1235 | + */ |
|
1236 | 1236 | public function name_and_info() { |
1237 | 1237 | $times = array(); |
1238 | 1238 | foreach ( $this->datetimes() as $datetime ) { |
@@ -1243,50 +1243,50 @@ discard block |
||
1243 | 1243 | |
1244 | 1244 | |
1245 | 1245 | |
1246 | - /** |
|
1247 | - * Gets name |
|
1248 | - * |
|
1249 | - * @return string |
|
1250 | - * @throws \EE_Error |
|
1251 | - */ |
|
1246 | + /** |
|
1247 | + * Gets name |
|
1248 | + * |
|
1249 | + * @return string |
|
1250 | + * @throws \EE_Error |
|
1251 | + */ |
|
1252 | 1252 | public function name() { |
1253 | 1253 | return $this->get( 'TKT_name' ); |
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | |
1257 | 1257 | |
1258 | - /** |
|
1259 | - * Gets price |
|
1260 | - * |
|
1261 | - * @return float |
|
1262 | - * @throws \EE_Error |
|
1263 | - */ |
|
1258 | + /** |
|
1259 | + * Gets price |
|
1260 | + * |
|
1261 | + * @return float |
|
1262 | + * @throws \EE_Error |
|
1263 | + */ |
|
1264 | 1264 | public function price() { |
1265 | 1265 | return $this->get( 'TKT_price' ); |
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | |
1269 | 1269 | |
1270 | - /** |
|
1271 | - * Gets all the registrations for this ticket |
|
1272 | - * |
|
1273 | - * @param array $query_params like EEM_Base::get_all's |
|
1274 | - * @return EE_Registration[]|EE_Base_Class[] |
|
1275 | - * @throws \EE_Error |
|
1276 | - */ |
|
1270 | + /** |
|
1271 | + * Gets all the registrations for this ticket |
|
1272 | + * |
|
1273 | + * @param array $query_params like EEM_Base::get_all's |
|
1274 | + * @return EE_Registration[]|EE_Base_Class[] |
|
1275 | + * @throws \EE_Error |
|
1276 | + */ |
|
1277 | 1277 | public function registrations( $query_params = array() ) { |
1278 | 1278 | return $this->get_many_related( 'Registration', $query_params ); |
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | |
1282 | 1282 | |
1283 | - /** |
|
1284 | - * Updates the TKT_sold attribute (and saves) based on the number of APPROVED registrations for this ticket. |
|
1285 | - * into account |
|
1286 | - * |
|
1287 | - * @return int |
|
1288 | - * @throws \EE_Error |
|
1289 | - */ |
|
1283 | + /** |
|
1284 | + * Updates the TKT_sold attribute (and saves) based on the number of APPROVED registrations for this ticket. |
|
1285 | + * into account |
|
1286 | + * |
|
1287 | + * @return int |
|
1288 | + * @throws \EE_Error |
|
1289 | + */ |
|
1290 | 1290 | public function update_tickets_sold() { |
1291 | 1291 | $count_regs_for_this_ticket = $this->count_registrations( array( array( 'STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0 ) ) ); |
1292 | 1292 | $this->set_sold( $count_regs_for_this_ticket ); |
@@ -1318,21 +1318,21 @@ discard block |
||
1318 | 1318 | |
1319 | 1319 | |
1320 | 1320 | |
1321 | - /** |
|
1322 | - * Implementation of the EEI_Event_Relation interface method |
|
1323 | - * |
|
1324 | - * @see EEI_Event_Relation for comments |
|
1325 | - * @return EE_Event |
|
1326 | - * @throws \EE_Error |
|
1327 | - * @throws UnexpectedEntityException |
|
1328 | - */ |
|
1321 | + /** |
|
1322 | + * Implementation of the EEI_Event_Relation interface method |
|
1323 | + * |
|
1324 | + * @see EEI_Event_Relation for comments |
|
1325 | + * @return EE_Event |
|
1326 | + * @throws \EE_Error |
|
1327 | + * @throws UnexpectedEntityException |
|
1328 | + */ |
|
1329 | 1329 | public function get_related_event() { |
1330 | 1330 | //get one datetime to use for getting the event |
1331 | 1331 | $datetime = $this->first_datetime(); |
1332 | 1332 | if ( ! $datetime instanceof \EE_Datetime ) { |
1333 | 1333 | throw new UnexpectedEntityException( |
1334 | 1334 | $datetime, |
1335 | - 'EE_Datetime', |
|
1335 | + 'EE_Datetime', |
|
1336 | 1336 | sprintf( |
1337 | 1337 | __( 'The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'), |
1338 | 1338 | $datetime->name() |
@@ -1343,7 +1343,7 @@ discard block |
||
1343 | 1343 | if ( ! $event instanceof \EE_Event ) { |
1344 | 1344 | throw new UnexpectedEntityException( |
1345 | 1345 | $event, |
1346 | - 'EE_Event', |
|
1346 | + 'EE_Event', |
|
1347 | 1347 | sprintf( |
1348 | 1348 | __( 'The ticket (%s) is not associated with a valid event.', 'event_espresso'), |
1349 | 1349 | $this->name() |
@@ -1355,14 +1355,14 @@ discard block |
||
1355 | 1355 | |
1356 | 1356 | |
1357 | 1357 | |
1358 | - /** |
|
1359 | - * Implementation of the EEI_Event_Relation interface method |
|
1360 | - * |
|
1361 | - * @see EEI_Event_Relation for comments |
|
1362 | - * @return string |
|
1363 | - * @throws UnexpectedEntityException |
|
1364 | - * @throws \EE_Error |
|
1365 | - */ |
|
1358 | + /** |
|
1359 | + * Implementation of the EEI_Event_Relation interface method |
|
1360 | + * |
|
1361 | + * @see EEI_Event_Relation for comments |
|
1362 | + * @return string |
|
1363 | + * @throws UnexpectedEntityException |
|
1364 | + * @throws \EE_Error |
|
1365 | + */ |
|
1366 | 1366 | public function get_event_name() { |
1367 | 1367 | $event = $this->get_related_event(); |
1368 | 1368 | return $event instanceof EE_Event ? $event->name() : ''; |
@@ -1370,14 +1370,14 @@ discard block |
||
1370 | 1370 | |
1371 | 1371 | |
1372 | 1372 | |
1373 | - /** |
|
1374 | - * Implementation of the EEI_Event_Relation interface method |
|
1375 | - * |
|
1376 | - * @see EEI_Event_Relation for comments |
|
1377 | - * @return int |
|
1378 | - * @throws UnexpectedEntityException |
|
1379 | - * @throws \EE_Error |
|
1380 | - */ |
|
1373 | + /** |
|
1374 | + * Implementation of the EEI_Event_Relation interface method |
|
1375 | + * |
|
1376 | + * @see EEI_Event_Relation for comments |
|
1377 | + * @return int |
|
1378 | + * @throws UnexpectedEntityException |
|
1379 | + * @throws \EE_Error |
|
1380 | + */ |
|
1381 | 1381 | public function get_event_ID() { |
1382 | 1382 | $event = $this->get_related_event(); |
1383 | 1383 | return $event instanceof EE_Event ? $event->ID() : 0; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\UnexpectedEntityException; |
2 | 2 | |
3 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | /** |
7 | 7 | * Event Espresso |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * @return EE_Ticket |
71 | 71 | * @throws \EE_Error |
72 | 72 | */ |
73 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
74 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
75 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
73 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
74 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
75 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * @return EE_Ticket |
85 | 85 | * @throws \EE_Error |
86 | 86 | */ |
87 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
88 | - return new self( $props_n_values, TRUE, $timezone ); |
|
87 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
88 | + return new self($props_n_values, TRUE, $timezone); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @throws \EE_Error |
96 | 96 | */ |
97 | 97 | public function parent() { |
98 | - return $this->get( 'TKT_parent' ); |
|
98 | + return $this->get('TKT_parent'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | * @return boolean |
108 | 108 | * @throws \EE_Error |
109 | 109 | */ |
110 | - public function available( $DTT_ID = 0 ) { |
|
110 | + public function available($DTT_ID = 0) { |
|
111 | 111 | // are we checking availability for a particular datetime ? |
112 | - if ( $DTT_ID ) { |
|
112 | + if ($DTT_ID) { |
|
113 | 113 | // get that datetime object |
114 | - $datetime = $this->get_first_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) ); |
|
114 | + $datetime = $this->get_first_related('Datetime', array(array('DTT_ID' => $DTT_ID))); |
|
115 | 115 | // if ticket sales for this datetime have exceeded the reg limit... |
116 | - if ( $datetime instanceof EE_Datetime && $datetime->sold_out() ) { |
|
116 | + if ($datetime instanceof EE_Datetime && $datetime->sold_out()) { |
|
117 | 117 | return FALSE; |
118 | 118 | } |
119 | 119 | } |
@@ -131,22 +131,22 @@ discard block |
||
131 | 131 | * @return mixed status int if the display string isn't requested |
132 | 132 | * @throws \EE_Error |
133 | 133 | */ |
134 | - public function ticket_status( $display = FALSE, $remaining = null ) { |
|
135 | - $remaining = is_bool( $remaining ) ? $remaining : $this->is_remaining(); |
|
136 | - if ( ! $remaining ) { |
|
137 | - return $display ? EEH_Template::pretty_status( EE_Ticket::sold_out, FALSE, 'sentence' ) : EE_Ticket::sold_out; |
|
134 | + public function ticket_status($display = FALSE, $remaining = null) { |
|
135 | + $remaining = is_bool($remaining) ? $remaining : $this->is_remaining(); |
|
136 | + if ( ! $remaining) { |
|
137 | + return $display ? EEH_Template::pretty_status(EE_Ticket::sold_out, FALSE, 'sentence') : EE_Ticket::sold_out; |
|
138 | 138 | } |
139 | - if ( $this->get( 'TKT_deleted' ) ) { |
|
140 | - return $display ? EEH_Template::pretty_status( EE_Ticket::archived, FALSE, 'sentence' ) : EE_Ticket::archived; |
|
139 | + if ($this->get('TKT_deleted')) { |
|
140 | + return $display ? EEH_Template::pretty_status(EE_Ticket::archived, FALSE, 'sentence') : EE_Ticket::archived; |
|
141 | 141 | } |
142 | - if ( $this->is_expired() ) { |
|
143 | - return $display ? EEH_Template::pretty_status( EE_Ticket::expired, FALSE, 'sentence' ) : EE_Ticket::expired; |
|
142 | + if ($this->is_expired()) { |
|
143 | + return $display ? EEH_Template::pretty_status(EE_Ticket::expired, FALSE, 'sentence') : EE_Ticket::expired; |
|
144 | 144 | } |
145 | - if ( $this->is_pending() ) { |
|
146 | - return $display ? EEH_Template::pretty_status( EE_Ticket::pending, FALSE, 'sentence' ) : EE_Ticket::pending; |
|
145 | + if ($this->is_pending()) { |
|
146 | + return $display ? EEH_Template::pretty_status(EE_Ticket::pending, FALSE, 'sentence') : EE_Ticket::pending; |
|
147 | 147 | } |
148 | - if ( $this->is_on_sale() ) { |
|
149 | - return $display ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence' ) : EE_Ticket::onsale; |
|
148 | + if ($this->is_on_sale()) { |
|
149 | + return $display ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : EE_Ticket::onsale; |
|
150 | 150 | } |
151 | 151 | return ''; |
152 | 152 | } |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | * @return boolean true = tickets remaining, false not. |
162 | 162 | * @throws \EE_Error |
163 | 163 | */ |
164 | - public function is_remaining( $DTT_ID = 0 ) { |
|
165 | - $num_remaining = $this->remaining( $DTT_ID ); |
|
166 | - if ( $num_remaining === 0 ) { |
|
164 | + public function is_remaining($DTT_ID = 0) { |
|
165 | + $num_remaining = $this->remaining($DTT_ID); |
|
166 | + if ($num_remaining === 0) { |
|
167 | 167 | return FALSE; |
168 | 168 | } |
169 | - if ( $num_remaining > 0 && $num_remaining < $this->min() ) { |
|
169 | + if ($num_remaining > 0 && $num_remaining < $this->min()) { |
|
170 | 170 | return FALSE; |
171 | 171 | } |
172 | 172 | return TRUE; |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | * @return int |
183 | 183 | * @throws \EE_Error |
184 | 184 | */ |
185 | - public function remaining( $DTT_ID = 0 ) { |
|
186 | - return $this->real_quantity_on_ticket('saleable', $DTT_ID ); |
|
185 | + public function remaining($DTT_ID = 0) { |
|
186 | + return $this->real_quantity_on_ticket('saleable', $DTT_ID); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @throws \EE_Error |
196 | 196 | */ |
197 | 197 | public function min() { |
198 | - return $this->get( 'TKT_min' ); |
|
198 | + return $this->get('TKT_min'); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @throws \EE_Error |
208 | 208 | */ |
209 | 209 | public function is_expired() { |
210 | - return ( $this->get_raw( 'TKT_end_date' ) < time() ); |
|
210 | + return ($this->get_raw('TKT_end_date') < time()); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @throws \EE_Error |
220 | 220 | */ |
221 | 221 | public function is_pending() { |
222 | - return ( $this->get_raw( 'TKT_start_date' ) > time() ); |
|
222 | + return ($this->get_raw('TKT_start_date') > time()); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @throws \EE_Error |
232 | 232 | */ |
233 | 233 | public function is_on_sale() { |
234 | - return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() ); |
|
234 | + return ($this->get_raw('TKT_start_date') < time() && $this->get_raw('TKT_end_date') > time()); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * @return string |
245 | 245 | * @throws \EE_Error |
246 | 246 | */ |
247 | - public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
248 | - $first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : ''; |
|
249 | - $last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : ''; |
|
247 | + public function date_range($dt_frmt = '', $conjunction = ' - ') { |
|
248 | + $first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date($dt_frmt) : ''; |
|
249 | + $last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date($dt_frmt) : ''; |
|
250 | 250 | |
251 | - return $first_date && $last_date ? $first_date . $conjunction . $last_date : ''; |
|
251 | + return $first_date && $last_date ? $first_date.$conjunction.$last_date : ''; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | * @throws \EE_Error |
261 | 261 | */ |
262 | 262 | public function first_datetime() { |
263 | - $datetimes = $this->datetimes( array( 'limit' => 1 ) ); |
|
264 | - return reset( $datetimes ); |
|
263 | + $datetimes = $this->datetimes(array('limit' => 1)); |
|
264 | + return reset($datetimes); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | * @return EE_Datetime[]|EE_Base_Class[] |
275 | 275 | * @throws \EE_Error |
276 | 276 | */ |
277 | - public function datetimes( $query_params = array() ) { |
|
278 | - if ( ! isset( $query_params[ 'order_by' ] ) ) { |
|
279 | - $query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC'; |
|
277 | + public function datetimes($query_params = array()) { |
|
278 | + if ( ! isset($query_params['order_by'])) { |
|
279 | + $query_params['order_by']['DTT_order'] = 'ASC'; |
|
280 | 280 | } |
281 | - return $this->get_many_related( 'Datetime', $query_params ); |
|
281 | + return $this->get_many_related('Datetime', $query_params); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @throws \EE_Error |
291 | 291 | */ |
292 | 292 | public function last_datetime() { |
293 | - $datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) ); |
|
294 | - return end( $datetimes ); |
|
293 | + $datetimes = $this->datetimes(array('limit' => 1, 'order_by' => array('DTT_EVT_start' => 'DESC'))); |
|
294 | + return end($datetimes); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -309,22 +309,22 @@ discard block |
||
309 | 309 | * @return mixed (array|int) how many tickets have sold |
310 | 310 | * @throws \EE_Error |
311 | 311 | */ |
312 | - public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) { |
|
312 | + public function tickets_sold($what = 'ticket', $dtt_id = NULL) { |
|
313 | 313 | $total = 0; |
314 | 314 | $tickets_sold = $this->_all_tickets_sold(); |
315 | - switch ( $what ) { |
|
315 | + switch ($what) { |
|
316 | 316 | case 'ticket' : |
317 | - return $tickets_sold[ 'ticket' ]; |
|
317 | + return $tickets_sold['ticket']; |
|
318 | 318 | break; |
319 | 319 | case 'datetime' : |
320 | - if ( empty( $tickets_sold[ 'datetime' ] ) ) { |
|
320 | + if (empty($tickets_sold['datetime'])) { |
|
321 | 321 | return $total; |
322 | 322 | } |
323 | - if ( ! empty( $dtt_id ) && ! isset( $tickets_sold[ 'datetime' ][ $dtt_id ] ) ) { |
|
324 | - EE_Error::add_error( __( 'You\'ve requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included. Are you SURE that is a datetime related to this ticket?', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
323 | + if ( ! empty($dtt_id) && ! isset($tickets_sold['datetime'][$dtt_id])) { |
|
324 | + EE_Error::add_error(__('You\'ve requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included. Are you SURE that is a datetime related to this ticket?', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
325 | 325 | return $total; |
326 | 326 | } |
327 | - return empty( $dtt_id ) ? $tickets_sold[ 'datetime' ] : $tickets_sold[ 'datetime' ][ $dtt_id ]; |
|
327 | + return empty($dtt_id) ? $tickets_sold['datetime'] : $tickets_sold['datetime'][$dtt_id]; |
|
328 | 328 | break; |
329 | 329 | default: |
330 | 330 | return $total; |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | * @throws \EE_Error |
341 | 341 | */ |
342 | 342 | protected function _all_tickets_sold() { |
343 | - $datetimes = $this->get_many_related( 'Datetime' ); |
|
343 | + $datetimes = $this->get_many_related('Datetime'); |
|
344 | 344 | $tickets_sold = array(); |
345 | - if ( ! empty( $datetimes ) ) { |
|
346 | - foreach ( $datetimes as $datetime ) { |
|
347 | - $tickets_sold[ 'datetime' ][ $datetime->ID() ] = $datetime->get( 'DTT_sold' ); |
|
345 | + if ( ! empty($datetimes)) { |
|
346 | + foreach ($datetimes as $datetime) { |
|
347 | + $tickets_sold['datetime'][$datetime->ID()] = $datetime->get('DTT_sold'); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | //Tickets sold |
351 | - $tickets_sold[ 'ticket' ] = $this->sold(); |
|
351 | + $tickets_sold['ticket'] = $this->sold(); |
|
352 | 352 | return $tickets_sold; |
353 | 353 | } |
354 | 354 | |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[] |
362 | 362 | * @throws \EE_Error |
363 | 363 | */ |
364 | - public function base_price( $return_array = FALSE ) { |
|
365 | - $_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price ); |
|
364 | + public function base_price($return_array = FALSE) { |
|
365 | + $_where = array('Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price); |
|
366 | 366 | return $return_array |
367 | - ? $this->get_many_related( 'Price', array( $_where ) ) |
|
368 | - : $this->get_first_related( 'Price', array( $_where ) ); |
|
367 | + ? $this->get_many_related('Price', array($_where)) |
|
368 | + : $this->get_first_related('Price', array($_where)); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @throws \EE_Error |
379 | 379 | */ |
380 | 380 | public function price_modifiers() { |
381 | - $query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) ); |
|
382 | - return $this->prices( $query_params ); |
|
381 | + $query_params = array(0 => array('Price_Type.PBT_ID' => array('NOT IN', array(EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax)))); |
|
382 | + return $this->prices($query_params); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | |
@@ -391,8 +391,8 @@ discard block |
||
391 | 391 | * @return EE_Price[]|EE_Base_Class[] |
392 | 392 | * @throws \EE_Error |
393 | 393 | */ |
394 | - public function prices( $query_params = array() ) { |
|
395 | - return $this->get_many_related( 'Price', $query_params ); |
|
394 | + public function prices($query_params = array()) { |
|
395 | + return $this->get_many_related('Price', $query_params); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * @return EE_Datetime_Ticket|EE_Base_Class[] |
405 | 405 | * @throws \EE_Error |
406 | 406 | */ |
407 | - public function datetime_tickets( $query_params = array() ) { |
|
408 | - return $this->get_many_related( 'Datetime_Ticket', $query_params ); |
|
407 | + public function datetime_tickets($query_params = array()) { |
|
408 | + return $this->get_many_related('Datetime_Ticket', $query_params); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | * @return EE_Datetime[] |
419 | 419 | * @throws \EE_Error |
420 | 420 | */ |
421 | - public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) { |
|
422 | - return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted ); |
|
421 | + public function datetimes_ordered($show_expired = TRUE, $show_deleted = FALSE) { |
|
422 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_ticket_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @throws \EE_Error |
432 | 432 | */ |
433 | 433 | public function ID() { |
434 | - return $this->get( 'TKT_ID' ); |
|
434 | + return $this->get('TKT_ID'); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | * @throws \EE_Error |
457 | 457 | */ |
458 | 458 | public function template() { |
459 | - return $this->get_first_related( 'Ticket_Template' ); |
|
459 | + return $this->get_first_related('Ticket_Template'); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @throws \EE_Error |
479 | 479 | */ |
480 | 480 | public function ticket_price() { |
481 | - return $this->get( 'TKT_price' ); |
|
481 | + return $this->get('TKT_price'); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | * @throws \EE_Error |
489 | 489 | */ |
490 | 490 | public function pretty_price() { |
491 | - return $this->get_pretty( 'TKT_price' ); |
|
491 | + return $this->get_pretty('TKT_price'); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | |
@@ -510,8 +510,8 @@ discard block |
||
510 | 510 | * @return float |
511 | 511 | * @throws \EE_Error |
512 | 512 | */ |
513 | - public function get_ticket_total_with_taxes( $no_cache = FALSE ) { |
|
514 | - if ($this->_ticket_total_with_taxes === null || $no_cache ) { |
|
513 | + public function get_ticket_total_with_taxes($no_cache = FALSE) { |
|
514 | + if ($this->_ticket_total_with_taxes === null || $no_cache) { |
|
515 | 515 | $this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin(); |
516 | 516 | } |
517 | 517 | return (float) $this->_ticket_total_with_taxes; |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | |
521 | 521 | |
522 | 522 | public function ensure_TKT_Price_correct() { |
523 | - $this->set( 'TKT_price', EE_Taxes::get_subtotal_for_admin( $this ) ); |
|
523 | + $this->set('TKT_price', EE_Taxes::get_subtotal_for_admin($this)); |
|
524 | 524 | $this->save(); |
525 | 525 | } |
526 | 526 | |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | * @throws \EE_Error |
532 | 532 | */ |
533 | 533 | public function get_ticket_subtotal() { |
534 | - return EE_Taxes::get_subtotal_for_admin( $this ); |
|
534 | + return EE_Taxes::get_subtotal_for_admin($this); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | * @throws \EE_Error |
544 | 544 | */ |
545 | 545 | public function get_ticket_taxes_total_for_admin() { |
546 | - return EE_Taxes::get_total_taxes_for_admin( $this ); |
|
546 | + return EE_Taxes::get_total_taxes_for_admin($this); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | * @param string $name |
555 | 555 | * @throws \EE_Error |
556 | 556 | */ |
557 | - public function set_name( $name ) { |
|
558 | - $this->set( 'TKT_name', $name ); |
|
557 | + public function set_name($name) { |
|
558 | + $this->set('TKT_name', $name); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | * @throws \EE_Error |
568 | 568 | */ |
569 | 569 | public function description() { |
570 | - return $this->get( 'TKT_description' ); |
|
570 | + return $this->get('TKT_description'); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | |
@@ -578,8 +578,8 @@ discard block |
||
578 | 578 | * @param string $description |
579 | 579 | * @throws \EE_Error |
580 | 580 | */ |
581 | - public function set_description( $description ) { |
|
582 | - $this->set( 'TKT_description', $description ); |
|
581 | + public function set_description($description) { |
|
582 | + $this->set('TKT_description', $description); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | |
@@ -592,8 +592,8 @@ discard block |
||
592 | 592 | * @return string |
593 | 593 | * @throws \EE_Error |
594 | 594 | */ |
595 | - public function start_date( $dt_frmt = '', $tm_frmt = '' ) { |
|
596 | - return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt ); |
|
595 | + public function start_date($dt_frmt = '', $tm_frmt = '') { |
|
596 | + return $this->_get_datetime('TKT_start_date', $dt_frmt, $tm_frmt); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | |
@@ -605,8 +605,8 @@ discard block |
||
605 | 605 | * @return void |
606 | 606 | * @throws \EE_Error |
607 | 607 | */ |
608 | - public function set_start_date( $start_date ) { |
|
609 | - $this->_set_date_time( 'B', $start_date, 'TKT_start_date' ); |
|
608 | + public function set_start_date($start_date) { |
|
609 | + $this->_set_date_time('B', $start_date, 'TKT_start_date'); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
@@ -619,8 +619,8 @@ discard block |
||
619 | 619 | * @return string |
620 | 620 | * @throws \EE_Error |
621 | 621 | */ |
622 | - public function end_date( $dt_frmt = '', $tm_frmt = '' ) { |
|
623 | - return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt ); |
|
622 | + public function end_date($dt_frmt = '', $tm_frmt = '') { |
|
623 | + return $this->_get_datetime('TKT_end_date', $dt_frmt, $tm_frmt); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | |
@@ -632,8 +632,8 @@ discard block |
||
632 | 632 | * @return void |
633 | 633 | * @throws \EE_Error |
634 | 634 | */ |
635 | - public function set_end_date( $end_date ) { |
|
636 | - $this->_set_date_time( 'B', $end_date, 'TKT_end_date' ); |
|
635 | + public function set_end_date($end_date) { |
|
636 | + $this->_set_date_time('B', $end_date, 'TKT_end_date'); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | |
@@ -645,8 +645,8 @@ discard block |
||
645 | 645 | * @param string $time a string representation of the sell until time (ex 9am or 7:30pm) |
646 | 646 | * @throws \EE_Error |
647 | 647 | */ |
648 | - public function set_end_time( $time ) { |
|
649 | - $this->_set_time_for( $time, 'TKT_end_date' ); |
|
648 | + public function set_end_time($time) { |
|
649 | + $this->_set_time_for($time, 'TKT_end_date'); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | |
@@ -658,8 +658,8 @@ discard block |
||
658 | 658 | * @return void |
659 | 659 | * @throws \EE_Error |
660 | 660 | */ |
661 | - public function set_min( $min ) { |
|
662 | - $this->set( 'TKT_min', $min ); |
|
661 | + public function set_min($min) { |
|
662 | + $this->set('TKT_min', $min); |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | * @throws \EE_Error |
672 | 672 | */ |
673 | 673 | public function max() { |
674 | - return $this->get( 'TKT_max' ); |
|
674 | + return $this->get('TKT_max'); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | * @return void |
684 | 684 | * @throws \EE_Error |
685 | 685 | */ |
686 | - public function set_max( $max ) { |
|
687 | - $this->set( 'TKT_max', $max ); |
|
686 | + public function set_max($max) { |
|
687 | + $this->set('TKT_max', $max); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | * @return void |
697 | 697 | * @throws \EE_Error |
698 | 698 | */ |
699 | - public function set_price( $price ) { |
|
700 | - $this->set( 'TKT_price', $price ); |
|
699 | + public function set_price($price) { |
|
700 | + $this->set('TKT_price', $price); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | * @throws \EE_Error |
710 | 710 | */ |
711 | 711 | public function sold() { |
712 | - return $this->get_raw( 'TKT_sold' ); |
|
712 | + return $this->get_raw('TKT_sold'); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | |
@@ -721,10 +721,10 @@ discard block |
||
721 | 721 | * @return void |
722 | 722 | * @throws \EE_Error |
723 | 723 | */ |
724 | - public function set_sold( $sold ) { |
|
724 | + public function set_sold($sold) { |
|
725 | 725 | // sold can not go below zero |
726 | - $sold = max( 0, $sold ); |
|
727 | - $this->set( 'TKT_sold', $sold ); |
|
726 | + $sold = max(0, $sold); |
|
727 | + $this->set('TKT_sold', $sold); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | |
@@ -736,13 +736,13 @@ discard block |
||
736 | 736 | * @return void |
737 | 737 | * @throws \EE_Error |
738 | 738 | */ |
739 | - public function increase_sold( $qty = 1 ) { |
|
739 | + public function increase_sold($qty = 1) { |
|
740 | 740 | $sold = $this->sold() + $qty; |
741 | 741 | // remove ticket reservation, but don't adjust datetime reservations, because that will happen |
742 | 742 | // via \EE_Datetime::increase_sold() when \EE_Ticket::_increase_sold_for_datetimes() is called |
743 | - $this->decrease_reserved( $qty, false ); |
|
744 | - $this->_increase_sold_for_datetimes( $qty ); |
|
745 | - $this->set_sold( $sold ); |
|
743 | + $this->decrease_reserved($qty, false); |
|
744 | + $this->_increase_sold_for_datetimes($qty); |
|
745 | + $this->set_sold($sold); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | |
@@ -754,12 +754,12 @@ discard block |
||
754 | 754 | * @return void |
755 | 755 | * @throws \EE_Error |
756 | 756 | */ |
757 | - protected function _increase_sold_for_datetimes( $qty = 1 ) { |
|
757 | + protected function _increase_sold_for_datetimes($qty = 1) { |
|
758 | 758 | $datetimes = $this->datetimes(); |
759 | - if ( is_array( $datetimes ) ) { |
|
760 | - foreach ( $datetimes as $datetime ) { |
|
761 | - if ( $datetime instanceof EE_Datetime ) { |
|
762 | - $datetime->increase_sold( $qty ); |
|
759 | + if (is_array($datetimes)) { |
|
760 | + foreach ($datetimes as $datetime) { |
|
761 | + if ($datetime instanceof EE_Datetime) { |
|
762 | + $datetime->increase_sold($qty); |
|
763 | 763 | $datetime->save(); |
764 | 764 | } |
765 | 765 | } |
@@ -775,10 +775,10 @@ discard block |
||
775 | 775 | * @return void |
776 | 776 | * @throws \EE_Error |
777 | 777 | */ |
778 | - public function decrease_sold( $qty = 1 ) { |
|
778 | + public function decrease_sold($qty = 1) { |
|
779 | 779 | $sold = $this->sold() - $qty; |
780 | - $this->_decrease_sold_for_datetimes( $qty ); |
|
781 | - $this->set_sold( $sold ); |
|
780 | + $this->_decrease_sold_for_datetimes($qty); |
|
781 | + $this->set_sold($sold); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | |
@@ -790,12 +790,12 @@ discard block |
||
790 | 790 | * @return void |
791 | 791 | * @throws \EE_Error |
792 | 792 | */ |
793 | - protected function _decrease_sold_for_datetimes( $qty = 1 ) { |
|
793 | + protected function _decrease_sold_for_datetimes($qty = 1) { |
|
794 | 794 | $datetimes = $this->datetimes(); |
795 | - if ( is_array( $datetimes ) ) { |
|
796 | - foreach ( $datetimes as $datetime ) { |
|
797 | - if ( $datetime instanceof EE_Datetime ) { |
|
798 | - $datetime->decrease_sold( $qty ); |
|
795 | + if (is_array($datetimes)) { |
|
796 | + foreach ($datetimes as $datetime) { |
|
797 | + if ($datetime instanceof EE_Datetime) { |
|
798 | + $datetime->decrease_sold($qty); |
|
799 | 799 | $datetime->save(); |
800 | 800 | } |
801 | 801 | } |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | * @throws \EE_Error |
812 | 812 | */ |
813 | 813 | public function reserved() { |
814 | - return $this->get_raw( 'TKT_reserved' ); |
|
814 | + return $this->get_raw('TKT_reserved'); |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | |
@@ -823,10 +823,10 @@ discard block |
||
823 | 823 | * @return void |
824 | 824 | * @throws \EE_Error |
825 | 825 | */ |
826 | - public function set_reserved( $reserved ) { |
|
826 | + public function set_reserved($reserved) { |
|
827 | 827 | // reserved can not go below zero |
828 | - $reserved = max( 0, (int) $reserved ); |
|
829 | - $this->set( 'TKT_reserved', $reserved ); |
|
828 | + $reserved = max(0, (int) $reserved); |
|
829 | + $this->set('TKT_reserved', $reserved); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | |
@@ -838,11 +838,11 @@ discard block |
||
838 | 838 | * @return void |
839 | 839 | * @throws \EE_Error |
840 | 840 | */ |
841 | - public function increase_reserved( $qty = 1 ) { |
|
842 | - $qty = absint( $qty ); |
|
841 | + public function increase_reserved($qty = 1) { |
|
842 | + $qty = absint($qty); |
|
843 | 843 | $reserved = $this->reserved() + $qty; |
844 | - $this->_increase_reserved_for_datetimes( $qty ); |
|
845 | - $this->set_reserved( $reserved ); |
|
844 | + $this->_increase_reserved_for_datetimes($qty); |
|
845 | + $this->set_reserved($reserved); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | |
@@ -854,12 +854,12 @@ discard block |
||
854 | 854 | * @return void |
855 | 855 | * @throws \EE_Error |
856 | 856 | */ |
857 | - protected function _increase_reserved_for_datetimes( $qty = 1 ) { |
|
857 | + protected function _increase_reserved_for_datetimes($qty = 1) { |
|
858 | 858 | $datetimes = $this->datetimes(); |
859 | - if ( is_array( $datetimes ) ) { |
|
860 | - foreach ( $datetimes as $datetime ) { |
|
861 | - if ( $datetime instanceof EE_Datetime ) { |
|
862 | - $datetime->increase_reserved( $qty ); |
|
859 | + if (is_array($datetimes)) { |
|
860 | + foreach ($datetimes as $datetime) { |
|
861 | + if ($datetime instanceof EE_Datetime) { |
|
862 | + $datetime->increase_reserved($qty); |
|
863 | 863 | $datetime->save(); |
864 | 864 | } |
865 | 865 | } |
@@ -876,12 +876,12 @@ discard block |
||
876 | 876 | * @return void |
877 | 877 | * @throws \EE_Error |
878 | 878 | */ |
879 | - public function decrease_reserved( $qty = 1, $adjust_datetimes = true ) { |
|
880 | - $reserved = $this->reserved() - absint( $qty ); |
|
881 | - if ( $adjust_datetimes ) { |
|
882 | - $this->_decrease_reserved_for_datetimes( $qty ); |
|
879 | + public function decrease_reserved($qty = 1, $adjust_datetimes = true) { |
|
880 | + $reserved = $this->reserved() - absint($qty); |
|
881 | + if ($adjust_datetimes) { |
|
882 | + $this->_decrease_reserved_for_datetimes($qty); |
|
883 | 883 | } |
884 | - $this->set_reserved( $reserved ); |
|
884 | + $this->set_reserved($reserved); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | |
@@ -893,12 +893,12 @@ discard block |
||
893 | 893 | * @return void |
894 | 894 | * @throws \EE_Error |
895 | 895 | */ |
896 | - protected function _decrease_reserved_for_datetimes( $qty = 1 ) { |
|
896 | + protected function _decrease_reserved_for_datetimes($qty = 1) { |
|
897 | 897 | $datetimes = $this->datetimes(); |
898 | - if ( is_array( $datetimes ) ) { |
|
899 | - foreach ( $datetimes as $datetime ) { |
|
900 | - if ( $datetime instanceof EE_Datetime ) { |
|
901 | - $datetime->decrease_reserved( $qty ); |
|
898 | + if (is_array($datetimes)) { |
|
899 | + foreach ($datetimes as $datetime) { |
|
900 | + if ($datetime instanceof EE_Datetime) { |
|
901 | + $datetime->decrease_reserved($qty); |
|
902 | 902 | $datetime->save(); |
903 | 903 | } |
904 | 904 | } |
@@ -919,14 +919,14 @@ discard block |
||
919 | 919 | * @return int |
920 | 920 | * @throws \EE_Error |
921 | 921 | */ |
922 | - public function qty( $context = '' ) { |
|
923 | - switch ( $context ) { |
|
922 | + public function qty($context = '') { |
|
923 | + switch ($context) { |
|
924 | 924 | case 'reg_limit' : |
925 | 925 | return $this->real_quantity_on_ticket(); |
926 | 926 | case 'saleable' : |
927 | - return $this->real_quantity_on_ticket( 'saleable' ); |
|
927 | + return $this->real_quantity_on_ticket('saleable'); |
|
928 | 928 | default: |
929 | - return $this->get_raw( 'TKT_qty' ); |
|
929 | + return $this->get_raw('TKT_qty'); |
|
930 | 930 | } |
931 | 931 | } |
932 | 932 | |
@@ -945,15 +945,15 @@ discard block |
||
945 | 945 | * @return int |
946 | 946 | * @throws \EE_Error |
947 | 947 | */ |
948 | - public function real_quantity_on_ticket( $context = 'reg_limit', $DTT_ID = 0 ) { |
|
949 | - $raw = $this->get_raw( 'TKT_qty' ); |
|
948 | + public function real_quantity_on_ticket($context = 'reg_limit', $DTT_ID = 0) { |
|
949 | + $raw = $this->get_raw('TKT_qty'); |
|
950 | 950 | // return immediately if it's zero |
951 | - if ( $raw === 0 ) { |
|
951 | + if ($raw === 0) { |
|
952 | 952 | return $raw; |
953 | 953 | } |
954 | 954 | //echo "\n\n<br />Ticket: " . $this->name() . '<br />'; |
955 | 955 | // ensure qty doesn't exceed raw value for THIS ticket |
956 | - $qty = min( EE_INF, $raw ); |
|
956 | + $qty = min(EE_INF, $raw); |
|
957 | 957 | //echo "\n . qty: " . $qty . '<br />'; |
958 | 958 | // calculate this ticket's total sales and reservations |
959 | 959 | $sold_and_reserved_for_this_ticket = $this->sold() + $this->reserved(); |
@@ -962,23 +962,23 @@ discard block |
||
962 | 962 | //echo "\n . sold_and_reserved_for_this_ticket: " . $sold_and_reserved_for_this_ticket . '<br />'; |
963 | 963 | // first we need to calculate the maximum number of tickets available for the datetime |
964 | 964 | // do we want data for one datetime or all of them ? |
965 | - $query_params = $DTT_ID ? array( array( 'DTT_ID' => $DTT_ID ) ) : array(); |
|
966 | - $datetimes = $this->datetimes( $query_params ); |
|
967 | - if ( is_array( $datetimes ) && ! empty( $datetimes ) ) { |
|
968 | - foreach ( $datetimes as $datetime ) { |
|
969 | - if ( $datetime instanceof EE_Datetime ) { |
|
965 | + $query_params = $DTT_ID ? array(array('DTT_ID' => $DTT_ID)) : array(); |
|
966 | + $datetimes = $this->datetimes($query_params); |
|
967 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
968 | + foreach ($datetimes as $datetime) { |
|
969 | + if ($datetime instanceof EE_Datetime) { |
|
970 | 970 | $datetime->refresh_from_db(); |
971 | 971 | //echo "\n . . datetime name: " . $datetime->name() . '<br />'; |
972 | 972 | //echo "\n . . datetime ID: " . $datetime->ID() . '<br />'; |
973 | 973 | // initialize with no restrictions for each datetime |
974 | 974 | // but adjust datetime qty based on datetime reg limit |
975 | - $datetime_qty = min( EE_INF, $datetime->reg_limit() ); |
|
975 | + $datetime_qty = min(EE_INF, $datetime->reg_limit()); |
|
976 | 976 | //echo "\n . . . datetime reg_limit: " . $datetime->reg_limit() . '<br />'; |
977 | 977 | //echo "\n . . . datetime_qty: " . $datetime_qty . '<br />'; |
978 | 978 | // if we want the actual saleable amount, then we need to consider OTHER ticket sales |
979 | 979 | // and reservations for this datetime, that do NOT include sales and reservations |
980 | 980 | // for this ticket (so we add $this->sold() and $this->reserved() back in) |
981 | - if ( $context === 'saleable' ) { |
|
981 | + if ($context === 'saleable') { |
|
982 | 982 | $datetime_qty = max( |
983 | 983 | $datetime_qty - $datetime->sold_and_reserved() + $sold_and_reserved_for_this_ticket, |
984 | 984 | 0 |
@@ -990,16 +990,16 @@ discard block |
||
990 | 990 | $datetime_qty = ! $datetime->sold_out() ? $datetime_qty : 0; |
991 | 991 | //echo "\n . . . datetime_qty: " . $datetime_qty . '<br />'; |
992 | 992 | } |
993 | - $qty = min( $datetime_qty, $qty ); |
|
993 | + $qty = min($datetime_qty, $qty); |
|
994 | 994 | //echo "\n . . qty: " . $qty . '<br />'; |
995 | 995 | } |
996 | 996 | } |
997 | 997 | } |
998 | 998 | // NOW that we know the maximum number of tickets available for the datetime |
999 | 999 | // we can finally factor in the details for this specific ticket |
1000 | - if ( $qty > 0 && $context === 'saleable' ) { |
|
1000 | + if ($qty > 0 && $context === 'saleable') { |
|
1001 | 1001 | // and subtract the sales for THIS ticket |
1002 | - $qty = max( $qty - $sold_and_reserved_for_this_ticket, 0 ); |
|
1002 | + $qty = max($qty - $sold_and_reserved_for_this_ticket, 0); |
|
1003 | 1003 | //echo "\n . qty: " . $qty . '<br />'; |
1004 | 1004 | } |
1005 | 1005 | //echo "\nFINAL QTY: " . $qty . "<br /><br />"; |
@@ -1015,14 +1015,14 @@ discard block |
||
1015 | 1015 | * @return void |
1016 | 1016 | * @throws \EE_Error |
1017 | 1017 | */ |
1018 | - public function set_qty( $qty ) { |
|
1018 | + public function set_qty($qty) { |
|
1019 | 1019 | $datetimes = $this->datetimes(); |
1020 | - foreach ( $datetimes as $datetime ) { |
|
1021 | - if ( $datetime instanceof EE_Datetime ) { |
|
1022 | - $qty = min( $qty, $datetime->reg_limit() ); |
|
1020 | + foreach ($datetimes as $datetime) { |
|
1021 | + if ($datetime instanceof EE_Datetime) { |
|
1022 | + $qty = min($qty, $datetime->reg_limit()); |
|
1023 | 1023 | } |
1024 | 1024 | } |
1025 | - $this->set( 'TKT_qty', $qty ); |
|
1025 | + $this->set('TKT_qty', $qty); |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | * @throws \EE_Error |
1035 | 1035 | */ |
1036 | 1036 | public function uses() { |
1037 | - return $this->get( 'TKT_uses' ); |
|
1037 | + return $this->get('TKT_uses'); |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | |
@@ -1046,8 +1046,8 @@ discard block |
||
1046 | 1046 | * @return void |
1047 | 1047 | * @throws \EE_Error |
1048 | 1048 | */ |
1049 | - public function set_uses( $uses ) { |
|
1050 | - $this->set( 'TKT_uses', $uses ); |
|
1049 | + public function set_uses($uses) { |
|
1050 | + $this->set('TKT_uses', $uses); |
|
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | * @throws \EE_Error |
1060 | 1060 | */ |
1061 | 1061 | public function required() { |
1062 | - return $this->get( 'TKT_required' ); |
|
1062 | + return $this->get('TKT_required'); |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | * @return void |
1072 | 1072 | * @throws \EE_Error |
1073 | 1073 | */ |
1074 | - public function set_required( $required ) { |
|
1075 | - $this->set( 'TKT_required', $required ); |
|
1074 | + public function set_required($required) { |
|
1075 | + $this->set('TKT_required', $required); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | |
@@ -1084,7 +1084,7 @@ discard block |
||
1084 | 1084 | * @throws \EE_Error |
1085 | 1085 | */ |
1086 | 1086 | public function taxable() { |
1087 | - return $this->get( 'TKT_taxable' ); |
|
1087 | + return $this->get('TKT_taxable'); |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | |
@@ -1096,8 +1096,8 @@ discard block |
||
1096 | 1096 | * @return void |
1097 | 1097 | * @throws \EE_Error |
1098 | 1098 | */ |
1099 | - public function set_taxable( $taxable ) { |
|
1100 | - $this->set( 'TKT_taxable', $taxable ); |
|
1099 | + public function set_taxable($taxable) { |
|
1100 | + $this->set('TKT_taxable', $taxable); |
|
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | * @throws \EE_Error |
1110 | 1110 | */ |
1111 | 1111 | public function is_default() { |
1112 | - return $this->get( 'TKT_is_default' ); |
|
1112 | + return $this->get('TKT_is_default'); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | |
@@ -1121,8 +1121,8 @@ discard block |
||
1121 | 1121 | * @return void |
1122 | 1122 | * @throws \EE_Error |
1123 | 1123 | */ |
1124 | - public function set_is_default( $is_default ) { |
|
1125 | - $this->set( 'TKT_is_default', $is_default ); |
|
1124 | + public function set_is_default($is_default) { |
|
1125 | + $this->set('TKT_is_default', $is_default); |
|
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | |
@@ -1134,7 +1134,7 @@ discard block |
||
1134 | 1134 | * @throws \EE_Error |
1135 | 1135 | */ |
1136 | 1136 | public function order() { |
1137 | - return $this->get( 'TKT_order' ); |
|
1137 | + return $this->get('TKT_order'); |
|
1138 | 1138 | } |
1139 | 1139 | |
1140 | 1140 | |
@@ -1146,8 +1146,8 @@ discard block |
||
1146 | 1146 | * @return void |
1147 | 1147 | * @throws \EE_Error |
1148 | 1148 | */ |
1149 | - public function set_order( $order ) { |
|
1150 | - $this->set( 'TKT_order', $order ); |
|
1149 | + public function set_order($order) { |
|
1150 | + $this->set('TKT_order', $order); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | * @throws \EE_Error |
1160 | 1160 | */ |
1161 | 1161 | public function row() { |
1162 | - return $this->get( 'TKT_row' ); |
|
1162 | + return $this->get('TKT_row'); |
|
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | |
@@ -1171,8 +1171,8 @@ discard block |
||
1171 | 1171 | * @return void |
1172 | 1172 | * @throws \EE_Error |
1173 | 1173 | */ |
1174 | - public function set_row( $row ) { |
|
1175 | - $this->set( 'TKT_row', $row ); |
|
1174 | + public function set_row($row) { |
|
1175 | + $this->set('TKT_row', $row); |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | * @throws \EE_Error |
1185 | 1185 | */ |
1186 | 1186 | public function deleted() { |
1187 | - return $this->get( 'TKT_deleted' ); |
|
1187 | + return $this->get('TKT_deleted'); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | |
@@ -1196,8 +1196,8 @@ discard block |
||
1196 | 1196 | * @return void |
1197 | 1197 | * @throws \EE_Error |
1198 | 1198 | */ |
1199 | - public function set_deleted( $deleted ) { |
|
1200 | - $this->set( 'TKT_deleted', $deleted ); |
|
1199 | + public function set_deleted($deleted) { |
|
1200 | + $this->set('TKT_deleted', $deleted); |
|
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | * @throws \EE_Error |
1210 | 1210 | */ |
1211 | 1211 | public function parent_ID() { |
1212 | - return $this->get( 'TKT_parent' ); |
|
1212 | + return $this->get('TKT_parent'); |
|
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | |
@@ -1221,8 +1221,8 @@ discard block |
||
1221 | 1221 | * @return void |
1222 | 1222 | * @throws \EE_Error |
1223 | 1223 | */ |
1224 | - public function set_parent_ID( $parent ) { |
|
1225 | - $this->set( 'TKT_parent', $parent ); |
|
1224 | + public function set_parent_ID($parent) { |
|
1225 | + $this->set('TKT_parent', $parent); |
|
1226 | 1226 | } |
1227 | 1227 | |
1228 | 1228 | |
@@ -1235,10 +1235,10 @@ discard block |
||
1235 | 1235 | */ |
1236 | 1236 | public function name_and_info() { |
1237 | 1237 | $times = array(); |
1238 | - foreach ( $this->datetimes() as $datetime ) { |
|
1238 | + foreach ($this->datetimes() as $datetime) { |
|
1239 | 1239 | $times[] = $datetime->start_date_and_time(); |
1240 | 1240 | } |
1241 | - return $this->name() . ' @ ' . implode( ', ', $times ) . ' for ' . $this->pretty_price(); |
|
1241 | + return $this->name().' @ '.implode(', ', $times).' for '.$this->pretty_price(); |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | * @throws \EE_Error |
1251 | 1251 | */ |
1252 | 1252 | public function name() { |
1253 | - return $this->get( 'TKT_name' ); |
|
1253 | + return $this->get('TKT_name'); |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | * @throws \EE_Error |
1263 | 1263 | */ |
1264 | 1264 | public function price() { |
1265 | - return $this->get( 'TKT_price' ); |
|
1265 | + return $this->get('TKT_price'); |
|
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | |
@@ -1274,8 +1274,8 @@ discard block |
||
1274 | 1274 | * @return EE_Registration[]|EE_Base_Class[] |
1275 | 1275 | * @throws \EE_Error |
1276 | 1276 | */ |
1277 | - public function registrations( $query_params = array() ) { |
|
1278 | - return $this->get_many_related( 'Registration', $query_params ); |
|
1277 | + public function registrations($query_params = array()) { |
|
1278 | + return $this->get_many_related('Registration', $query_params); |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | |
@@ -1288,8 +1288,8 @@ discard block |
||
1288 | 1288 | * @throws \EE_Error |
1289 | 1289 | */ |
1290 | 1290 | public function update_tickets_sold() { |
1291 | - $count_regs_for_this_ticket = $this->count_registrations( array( array( 'STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0 ) ) ); |
|
1292 | - $this->set_sold( $count_regs_for_this_ticket ); |
|
1291 | + $count_regs_for_this_ticket = $this->count_registrations(array(array('STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0))); |
|
1292 | + $this->set_sold($count_regs_for_this_ticket); |
|
1293 | 1293 | $this->save(); |
1294 | 1294 | return $count_regs_for_this_ticket; |
1295 | 1295 | } |
@@ -1301,7 +1301,7 @@ discard block |
||
1301 | 1301 | * @param array $query_params like EEM_Base::get_all's |
1302 | 1302 | * @return int |
1303 | 1303 | */ |
1304 | - public function count_registrations( $query_params = array() ) { |
|
1304 | + public function count_registrations($query_params = array()) { |
|
1305 | 1305 | return $this->count_related('Registration', $query_params); |
1306 | 1306 | } |
1307 | 1307 | |
@@ -1329,23 +1329,23 @@ discard block |
||
1329 | 1329 | public function get_related_event() { |
1330 | 1330 | //get one datetime to use for getting the event |
1331 | 1331 | $datetime = $this->first_datetime(); |
1332 | - if ( ! $datetime instanceof \EE_Datetime ) { |
|
1332 | + if ( ! $datetime instanceof \EE_Datetime) { |
|
1333 | 1333 | throw new UnexpectedEntityException( |
1334 | 1334 | $datetime, |
1335 | 1335 | 'EE_Datetime', |
1336 | 1336 | sprintf( |
1337 | - __( 'The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'), |
|
1337 | + __('The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'), |
|
1338 | 1338 | $datetime->name() |
1339 | 1339 | ) |
1340 | 1340 | ); |
1341 | 1341 | } |
1342 | 1342 | $event = $datetime->event(); |
1343 | - if ( ! $event instanceof \EE_Event ) { |
|
1343 | + if ( ! $event instanceof \EE_Event) { |
|
1344 | 1344 | throw new UnexpectedEntityException( |
1345 | 1345 | $event, |
1346 | 1346 | 'EE_Event', |
1347 | 1347 | sprintf( |
1348 | - __( 'The ticket (%s) is not associated with a valid event.', 'event_espresso'), |
|
1348 | + __('The ticket (%s) is not associated with a valid event.', 'event_espresso'), |
|
1349 | 1349 | $this->name() |
1350 | 1350 | ) |
1351 | 1351 | ); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $VNU_ID |
70 | 70 | ); |
71 | 71 | extract($template_args, EXTR_OVERWRITE); |
72 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
72 | + include EE_TEMPLATES.'json_linked_data_for_event.template.php'; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @param string $location |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - public static function location( $location = null ) { |
|
86 | - return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
|
85 | + public static function location($location = null) { |
|
86 | + return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
|
87 | 87 | . $location |
88 | 88 | . '</div>' : ''; |
89 | 89 | } |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @param string $name |
99 | 99 | * @return string |
100 | 100 | */ |
101 | - public static function name( $name = null ) { |
|
102 | - return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : ''; |
|
101 | + public static function name($name = null) { |
|
102 | + return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : ''; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * @param EEI_Address $obj_with_address |
113 | 113 | * @return string |
114 | 114 | */ |
115 | - public static function streetAddress( EEI_Address $obj_with_address = null ) { |
|
115 | + public static function streetAddress(EEI_Address $obj_with_address = null) { |
|
116 | 116 | return $obj_with_address->address() !== null && $obj_with_address->address() !== '' |
117 | - ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : ''; |
|
117 | + ? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : ''; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | * @param EEI_Address $obj_with_address |
128 | 128 | * @return string |
129 | 129 | */ |
130 | - public static function postOfficeBoxNumber( EEI_Address $obj_with_address = null ) { |
|
130 | + public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null) { |
|
131 | 131 | // regex check for some form of PO Box or P.O. Box, etc, etc, etc |
132 | - if ( preg_match( |
|
132 | + if (preg_match( |
|
133 | 133 | "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", |
134 | 134 | $obj_with_address->address2() |
135 | - ) ) { |
|
135 | + )) { |
|
136 | 136 | return $obj_with_address->address2() !== null && $obj_with_address->address2() !== '' |
137 | - ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : ''; |
|
137 | + ? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : ''; |
|
138 | 138 | } else { |
139 | 139 | return $obj_with_address->address2(); |
140 | 140 | } |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | * @param EEI_Address $obj_with_address |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public static function addressLocality( EEI_Address $obj_with_address = null ) { |
|
153 | + public static function addressLocality(EEI_Address $obj_with_address = null) { |
|
154 | 154 | return $obj_with_address->city() !== null && $obj_with_address->city() !== '' |
155 | - ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : ''; |
|
155 | + ? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : ''; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | * @param EEI_Address $obj_with_address |
166 | 166 | * @return string |
167 | 167 | */ |
168 | - public static function addressRegion( EEI_Address $obj_with_address = null ) { |
|
168 | + public static function addressRegion(EEI_Address $obj_with_address = null) { |
|
169 | 169 | $state = $obj_with_address->state_name(); |
170 | - if ( ! empty( $state ) ) { |
|
171 | - return '<span itemprop="addressRegion">' . $state . '</span>'; |
|
170 | + if ( ! empty($state)) { |
|
171 | + return '<span itemprop="addressRegion">'.$state.'</span>'; |
|
172 | 172 | } else { |
173 | 173 | return ''; |
174 | 174 | } |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | * @param EEI_Address $obj_with_address |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - public static function addressCountry( EEI_Address $obj_with_address = null ) { |
|
187 | + public static function addressCountry(EEI_Address $obj_with_address = null) { |
|
188 | 188 | $country = $obj_with_address->country_name(); |
189 | - if ( ! empty( $country ) ) { |
|
190 | - return '<span itemprop="addressCountry">' . $country . '</span>'; |
|
189 | + if ( ! empty($country)) { |
|
190 | + return '<span itemprop="addressCountry">'.$country.'</span>'; |
|
191 | 191 | } else { |
192 | 192 | return ''; |
193 | 193 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param EEI_Address $obj_with_address |
204 | 204 | * @return string |
205 | 205 | */ |
206 | - public static function postalCode( EEI_Address $obj_with_address = null ) { |
|
206 | + public static function postalCode(EEI_Address $obj_with_address = null) { |
|
207 | 207 | return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' |
208 | 208 | . $obj_with_address->zip() |
209 | 209 | . '</span>' : ''; |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | * @param string $phone_nmbr |
220 | 220 | * @return string |
221 | 221 | */ |
222 | - public static function telephone( $phone_nmbr = null ) { |
|
223 | - return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' |
|
222 | + public static function telephone($phone_nmbr = null) { |
|
223 | + return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>' |
|
224 | 224 | : ''; |
225 | 225 | } |
226 | 226 | |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | * @param array $attributes - array of additional link attributes in attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' ) |
237 | 237 | * @return string (link) |
238 | 238 | */ |
239 | - public static function url( $url = null, $text = null, $attributes = array() ) { |
|
239 | + public static function url($url = null, $text = null, $attributes = array()) { |
|
240 | 240 | $atts = ''; |
241 | - foreach ( $attributes as $attribute => $value ) { |
|
242 | - $atts .= ' ' . $attribute . '="' . $value . '"'; |
|
241 | + foreach ($attributes as $attribute => $value) { |
|
242 | + $atts .= ' '.$attribute.'="'.$value.'"'; |
|
243 | 243 | } |
244 | 244 | $text = $text !== null && $text !== '' ? $text : $url; |
245 | - return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>' |
|
245 | + return $url !== null && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>' |
|
246 | 246 | : ''; |
247 | 247 | } |
248 | 248 |
@@ -17,62 +17,62 @@ discard block |
||
17 | 17 | class EEH_Schema { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * generates JSON-based linked data for an event |
|
22 | - * |
|
23 | - * @param \EE_Event $event |
|
24 | - */ |
|
25 | - public static function add_json_linked_data_for_event(\EE_Event $event) |
|
26 | - { |
|
27 | - $template_args = array( |
|
28 | - 'event_permalink' => '', |
|
29 | - 'event_name' => '', |
|
30 | - 'event_description' => '', |
|
31 | - 'event_start' => '', |
|
32 | - 'event_end' => '', |
|
33 | - 'currency' => '', |
|
34 | - 'event_tickets' => array(), |
|
35 | - 'venue_name' => '', |
|
36 | - 'venue_url' => '', |
|
37 | - 'venue_locality' => '', |
|
38 | - 'venue_region' => '', |
|
39 | - 'event_image' => '', |
|
40 | - ); |
|
41 | - $template_args['event_permalink'] = $event->get_permalink(); |
|
42 | - $template_args['event_name'] = $event->name(); |
|
43 | - $template_args['event_description'] = $event->description(); |
|
44 | - $template_args['event_start'] = $event->primary_datetime()->start_date(DateTime::ATOM); |
|
45 | - $template_args['event_end'] = $event->primary_datetime()->end_date(DateTime::ATOM); |
|
46 | - $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
|
47 | - foreach ($event->tickets() as $ticket) { |
|
48 | - $ID = $ticket->ID(); |
|
49 | - $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
50 | - $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
51 | - $template_args['event_tickets'][$ID]['price'] = number_format( |
|
52 | - $ticket->price(), |
|
53 | - EE_Registry::instance()->CFG->currency->dec_plc, |
|
54 | - EE_Registry::instance()->CFG->currency->dec_mrk, |
|
55 | - EE_Registry::instance()->CFG->currency->thsnds |
|
56 | - ); |
|
57 | - } |
|
58 | - $VNU_ID = espresso_venue_id(); |
|
59 | - if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
60 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
61 | - $template_args['venue_name'] = get_the_title($VNU_ID); |
|
62 | - $template_args['venue_url'] = get_permalink($VNU_ID); |
|
63 | - $template_args['venue_locality'] = $venue->city(); |
|
64 | - $template_args['venue_region'] = $venue->state_name(); |
|
65 | - } |
|
66 | - $template_args['event_image'] = $event->feature_image_url(); |
|
67 | - $template_args = apply_filters( |
|
68 | - 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args', |
|
69 | - $template_args, |
|
70 | - $event, |
|
71 | - $VNU_ID |
|
72 | - ); |
|
73 | - extract($template_args, EXTR_OVERWRITE); |
|
74 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
75 | - } |
|
20 | + /** |
|
21 | + * generates JSON-based linked data for an event |
|
22 | + * |
|
23 | + * @param \EE_Event $event |
|
24 | + */ |
|
25 | + public static function add_json_linked_data_for_event(\EE_Event $event) |
|
26 | + { |
|
27 | + $template_args = array( |
|
28 | + 'event_permalink' => '', |
|
29 | + 'event_name' => '', |
|
30 | + 'event_description' => '', |
|
31 | + 'event_start' => '', |
|
32 | + 'event_end' => '', |
|
33 | + 'currency' => '', |
|
34 | + 'event_tickets' => array(), |
|
35 | + 'venue_name' => '', |
|
36 | + 'venue_url' => '', |
|
37 | + 'venue_locality' => '', |
|
38 | + 'venue_region' => '', |
|
39 | + 'event_image' => '', |
|
40 | + ); |
|
41 | + $template_args['event_permalink'] = $event->get_permalink(); |
|
42 | + $template_args['event_name'] = $event->name(); |
|
43 | + $template_args['event_description'] = $event->description(); |
|
44 | + $template_args['event_start'] = $event->primary_datetime()->start_date(DateTime::ATOM); |
|
45 | + $template_args['event_end'] = $event->primary_datetime()->end_date(DateTime::ATOM); |
|
46 | + $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
|
47 | + foreach ($event->tickets() as $ticket) { |
|
48 | + $ID = $ticket->ID(); |
|
49 | + $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
50 | + $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
51 | + $template_args['event_tickets'][$ID]['price'] = number_format( |
|
52 | + $ticket->price(), |
|
53 | + EE_Registry::instance()->CFG->currency->dec_plc, |
|
54 | + EE_Registry::instance()->CFG->currency->dec_mrk, |
|
55 | + EE_Registry::instance()->CFG->currency->thsnds |
|
56 | + ); |
|
57 | + } |
|
58 | + $VNU_ID = espresso_venue_id(); |
|
59 | + if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
60 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
61 | + $template_args['venue_name'] = get_the_title($VNU_ID); |
|
62 | + $template_args['venue_url'] = get_permalink($VNU_ID); |
|
63 | + $template_args['venue_locality'] = $venue->city(); |
|
64 | + $template_args['venue_region'] = $venue->state_name(); |
|
65 | + } |
|
66 | + $template_args['event_image'] = $event->feature_image_url(); |
|
67 | + $template_args = apply_filters( |
|
68 | + 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args', |
|
69 | + $template_args, |
|
70 | + $event, |
|
71 | + $VNU_ID |
|
72 | + ); |
|
73 | + extract($template_args, EXTR_OVERWRITE); |
|
74 | + include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | /** |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public static function location( $location = null ) { |
88 | 88 | return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
89 | - . $location |
|
90 | - . '</div>' : ''; |
|
89 | + . $location |
|
90 | + . '</div>' : ''; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public static function postalCode( EEI_Address $obj_with_address = null ) { |
209 | 209 | return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' |
210 | - . $obj_with_address->zip() |
|
211 | - . '</span>' : ''; |
|
210 | + . $obj_with_address->zip() |
|
211 | + . '</span>' : ''; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Event Espresso |
@@ -16,35 +16,35 @@ discard block |
||
16 | 16 | |
17 | 17 | |
18 | 18 | if ( ! function_exists('espresso_get_template_part')) { |
19 | - /** |
|
20 | - * espresso_get_template_part |
|
21 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
22 | - * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
23 | - * |
|
24 | - * @param string $slug The slug name for the generic template. |
|
25 | - * @param string $name The name of the specialised template. |
|
26 | - * @return string the html output for the formatted money value |
|
27 | - */ |
|
28 | - function espresso_get_template_part($slug = null, $name = null) |
|
29 | - { |
|
30 | - EEH_Template::get_template_part($slug, $name); |
|
31 | - } |
|
19 | + /** |
|
20 | + * espresso_get_template_part |
|
21 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
22 | + * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
23 | + * |
|
24 | + * @param string $slug The slug name for the generic template. |
|
25 | + * @param string $name The name of the specialised template. |
|
26 | + * @return string the html output for the formatted money value |
|
27 | + */ |
|
28 | + function espresso_get_template_part($slug = null, $name = null) |
|
29 | + { |
|
30 | + EEH_Template::get_template_part($slug, $name); |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | if ( ! function_exists('espresso_get_object_css_class')) { |
36 | - /** |
|
37 | - * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
38 | - * |
|
39 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
40 | - * @param string $prefix added to the beginning of the generated class |
|
41 | - * @param string $suffix added to the end of the generated class |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
45 | - { |
|
46 | - return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | - } |
|
36 | + /** |
|
37 | + * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
38 | + * |
|
39 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
40 | + * @param string $prefix added to the beginning of the generated class |
|
41 | + * @param string $suffix added to the end of the generated class |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
45 | + { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -59,631 +59,631 @@ discard block |
||
59 | 59 | class EEH_Template |
60 | 60 | { |
61 | 61 | |
62 | - private static $_espresso_themes = array(); |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
67 | - * |
|
68 | - * @return boolean |
|
69 | - */ |
|
70 | - public static function is_espresso_theme() |
|
71 | - { |
|
72 | - return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
77 | - * load it's functions.php file ( if not already loaded ) |
|
78 | - * |
|
79 | - * @return void |
|
80 | - */ |
|
81 | - public static function load_espresso_theme_functions() |
|
82 | - { |
|
83 | - if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
84 | - if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
85 | - require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
86 | - } |
|
87 | - } |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
93 | - * |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - public static function get_espresso_themes() |
|
97 | - { |
|
98 | - if (empty(EEH_Template::$_espresso_themes)) { |
|
99 | - $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
100 | - if (empty($espresso_themes)) { |
|
101 | - return array(); |
|
102 | - } |
|
103 | - if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
104 | - unset($espresso_themes[$key]); |
|
105 | - } |
|
106 | - EEH_Template::$_espresso_themes = array(); |
|
107 | - foreach ($espresso_themes as $espresso_theme) { |
|
108 | - EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
109 | - } |
|
110 | - } |
|
111 | - return EEH_Template::$_espresso_themes; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * EEH_Template::get_template_part |
|
117 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
118 | - * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
119 | - * filtering based off of the entire template part name |
|
120 | - * |
|
121 | - * @param string $slug The slug name for the generic template. |
|
122 | - * @param string $name The name of the specialised template. |
|
123 | - * @param array $template_args |
|
124 | - * @param bool $return_string |
|
125 | - * @return string the html output for the formatted money value |
|
126 | - */ |
|
127 | - public static function get_template_part( |
|
128 | - $slug = null, |
|
129 | - $name = null, |
|
130 | - $template_args = array(), |
|
131 | - $return_string = false |
|
132 | - ) { |
|
133 | - do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
134 | - $templates = array(); |
|
135 | - $name = (string)$name; |
|
136 | - if ($name != '') { |
|
137 | - $templates[] = "{$slug}-{$name}.php"; |
|
138 | - } |
|
139 | - // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
140 | - if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
141 | - EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * locate_template |
|
148 | - * locate a template file by looking in the following places, in the following order: |
|
149 | - * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
150 | - * <assumed full absolute server path> |
|
151 | - * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
152 | - * <server path up to>/wp-content/uploads/espresso/templates/ |
|
153 | - * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
154 | - * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
155 | - * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
156 | - * as soon as the template is found in one of these locations, it will be returned or loaded |
|
157 | - * Example: |
|
158 | - * You are using the WordPress Twenty Sixteen theme, |
|
159 | - * and you want to customize the "some-event.template.php" template, |
|
160 | - * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
161 | - * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
162 | - * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
163 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
164 | - * /relative/path/to/some-event.template.php |
|
165 | - * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
166 | - * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
167 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
168 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
169 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
170 | - * Had you passed an absolute path to your template that was in some other location, |
|
171 | - * ie: "/absolute/path/to/some-event.template.php" |
|
172 | - * then the search would have been : |
|
173 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
174 | - * /absolute/path/to/some-event.template.php |
|
175 | - * and stopped there upon finding it in the second location |
|
176 | - * |
|
177 | - * @param array|string $templates array of template file names including extension (or just a single string) |
|
178 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
179 | - * @param boolean $load whether to pass the located template path on to the |
|
180 | - * EEH_Template::display_template() method or simply return it |
|
181 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
182 | - * string |
|
183 | - * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
184 | - * generate a custom template or not. Used in places where you don't actually |
|
185 | - * load the template, you just want to know if there's a custom version of it. |
|
186 | - * @return mixed |
|
187 | - */ |
|
188 | - public static function locate_template( |
|
189 | - $templates = array(), |
|
190 | - $template_args = array(), |
|
191 | - $load = true, |
|
192 | - $return_string = true, |
|
193 | - $check_if_custom = false |
|
194 | - ) { |
|
195 | - // first use WP locate_template to check for template in the current theme folder |
|
196 | - $template_path = locate_template($templates); |
|
197 | - |
|
198 | - if ($check_if_custom && ! empty($template_path)) { |
|
199 | - return true; |
|
200 | - } |
|
201 | - |
|
202 | - // not in the theme |
|
203 | - if (empty($template_path)) { |
|
204 | - // not even a template to look for ? |
|
205 | - if (empty($templates)) { |
|
206 | - // get post_type |
|
207 | - $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
208 | - // get array of EE Custom Post Types |
|
209 | - $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
|
210 | - // build template name based on request |
|
211 | - if (isset($EE_CPTs[$post_type])) { |
|
212 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
213 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
214 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
215 | - } |
|
216 | - } |
|
217 | - // currently active EE template theme |
|
218 | - $current_theme = EE_Config::get_current_theme(); |
|
219 | - |
|
220 | - // array of paths to folders that may contain templates |
|
221 | - $template_folder_paths = array( |
|
222 | - // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
223 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
224 | - // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
225 | - EVENT_ESPRESSO_TEMPLATE_DIR, |
|
226 | - ); |
|
227 | - |
|
228 | - //add core plugin folders for checking only if we're not $check_if_custom |
|
229 | - if ( ! $check_if_custom) { |
|
230 | - $core_paths = array( |
|
231 | - // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
232 | - EE_PUBLIC . $current_theme, |
|
233 | - // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
234 | - EE_TEMPLATES . $current_theme, |
|
235 | - // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
236 | - EE_PLUGIN_DIR_PATH, |
|
237 | - ); |
|
238 | - $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
239 | - } |
|
240 | - |
|
241 | - // now filter that array |
|
242 | - $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
243 | - $template_folder_paths); |
|
244 | - $templates = is_array($templates) ? $templates : array($templates); |
|
245 | - $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
246 | - // array to hold all possible template paths |
|
247 | - $full_template_paths = array(); |
|
248 | - |
|
249 | - // loop through $templates |
|
250 | - foreach ($templates as $template) { |
|
251 | - // normalize directory separators |
|
252 | - $template = EEH_File::standardise_directory_separators($template); |
|
253 | - $file_name = basename($template); |
|
254 | - $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
255 | - // while looping through all template folder paths |
|
256 | - foreach ($template_folder_paths as $template_folder_path) { |
|
257 | - // normalize directory separators |
|
258 | - $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
259 | - // determine if any common base path exists between the two paths |
|
260 | - $common_base_path = EEH_Template::_find_common_base_path( |
|
261 | - array($template_folder_path, $template_path_minus_file_name) |
|
262 | - ); |
|
263 | - if ($common_base_path !== '') { |
|
264 | - // both paths have a common base, so just tack the filename onto our search path |
|
265 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
266 | - } else { |
|
267 | - // no common base path, so let's just concatenate |
|
268 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
269 | - } |
|
270 | - // build up our template locations array by adding our resolved paths |
|
271 | - $full_template_paths[] = $resolved_path; |
|
272 | - } |
|
273 | - // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
274 | - array_unshift($full_template_paths, $template); |
|
275 | - // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
276 | - array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
277 | - } |
|
278 | - // filter final array of full template paths |
|
279 | - $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
280 | - $full_template_paths, $file_name); |
|
281 | - // now loop through our final array of template location paths and check each location |
|
282 | - foreach ((array)$full_template_paths as $full_template_path) { |
|
283 | - if (is_readable($full_template_path)) { |
|
284 | - $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
285 | - // hook that can be used to display the full template path that will be used |
|
286 | - do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
287 | - break; |
|
288 | - } |
|
289 | - } |
|
290 | - } |
|
291 | - // if we got it and you want to see it... |
|
292 | - if ($template_path && $load && ! $check_if_custom) { |
|
293 | - if ($return_string) { |
|
294 | - return EEH_Template::display_template($template_path, $template_args, true); |
|
295 | - } else { |
|
296 | - EEH_Template::display_template($template_path, $template_args, false); |
|
297 | - } |
|
298 | - } |
|
299 | - return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * _find_common_base_path |
|
305 | - * given two paths, this determines if there is a common base path between the two |
|
306 | - * |
|
307 | - * @param array $paths |
|
308 | - * @return string |
|
309 | - */ |
|
310 | - protected static function _find_common_base_path($paths) |
|
311 | - { |
|
312 | - $last_offset = 0; |
|
313 | - $common_base_path = ''; |
|
314 | - while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
315 | - $dir_length = $index - $last_offset + 1; |
|
316 | - $directory = substr($paths[0], $last_offset, $dir_length); |
|
317 | - foreach ($paths as $path) { |
|
318 | - if (substr($path, $last_offset, $dir_length) != $directory) { |
|
319 | - return $common_base_path; |
|
320 | - } |
|
321 | - } |
|
322 | - $common_base_path .= $directory; |
|
323 | - $last_offset = $index + 1; |
|
324 | - } |
|
325 | - return substr($common_base_path, 0, -1); |
|
326 | - } |
|
327 | - |
|
328 | - |
|
329 | - /** |
|
330 | - * load and display a template |
|
331 | - * |
|
332 | - * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
333 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
334 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
335 | - * @return mixed string |
|
336 | - */ |
|
337 | - public static function display_template($template_path = false, $template_args = array(), $return_string = false) |
|
338 | - { |
|
339 | - |
|
340 | - /** |
|
341 | - * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
342 | - * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
343 | - * the display_template method are templates we DON'T want modified (usually because of js |
|
344 | - * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
345 | - * using this. |
|
346 | - * |
|
347 | - * @since 4.6.0 |
|
348 | - */ |
|
349 | - $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
350 | - $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
351 | - |
|
352 | - // you gimme nuttin - YOU GET NUTTIN !! |
|
353 | - if ( ! $template_path || ! is_readable($template_path)) { |
|
354 | - return ''; |
|
355 | - } |
|
356 | - // if $template_args are not in an array, then make it so |
|
357 | - if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
358 | - $template_args = array($template_args); |
|
359 | - } |
|
360 | - extract((array)$template_args); |
|
361 | - |
|
362 | - if ($return_string) { |
|
363 | - // because we want to return a string, we are going to capture the output |
|
364 | - ob_start(); |
|
365 | - include($template_path); |
|
366 | - return ob_get_clean(); |
|
367 | - } else { |
|
368 | - include($template_path); |
|
369 | - } |
|
370 | - return ''; |
|
371 | - } |
|
372 | - |
|
373 | - |
|
374 | - /** |
|
375 | - * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
376 | - * |
|
377 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
378 | - * @param string $prefix added to the beginning of the generated class |
|
379 | - * @param string $suffix added to the end of the generated class |
|
380 | - * @return string |
|
381 | - */ |
|
382 | - public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
383 | - { |
|
384 | - // in the beginning... |
|
385 | - $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
386 | - // da muddle |
|
387 | - $class = ''; |
|
388 | - // the end |
|
389 | - $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
390 | - // is the passed object an EE object ? |
|
391 | - if ($object instanceof EE_Base_Class) { |
|
392 | - // grab the exact type of object |
|
393 | - $obj_class = get_class($object); |
|
394 | - // depending on the type of object... |
|
395 | - switch ($obj_class) { |
|
396 | - // no specifics just yet... |
|
397 | - default : |
|
398 | - $class = strtolower(str_replace('_', '-', $obj_class)); |
|
399 | - $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
400 | - |
|
401 | - } |
|
402 | - } |
|
403 | - return $prefix . $class . $suffix; |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * EEH_Template::format_currency |
|
410 | - * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
411 | - * the country currency settings from the supplied country ISO code |
|
412 | - * |
|
413 | - * @param float $amount raw money value |
|
414 | - * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
415 | - * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
416 | - * @param string $CNT_ISO 2 letter ISO code for a country |
|
417 | - * @param string $cur_code_span_class |
|
418 | - * @return string the html output for the formatted money value |
|
419 | - * @throws \EE_Error |
|
420 | - */ |
|
421 | - public static function format_currency( |
|
422 | - $amount = null, |
|
423 | - $return_raw = false, |
|
424 | - $display_code = true, |
|
425 | - $CNT_ISO = '', |
|
426 | - $cur_code_span_class = 'currency-code' |
|
427 | - ) { |
|
428 | - // ensure amount was received |
|
429 | - if ($amount === null) { |
|
430 | - $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
431 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
432 | - return ''; |
|
433 | - } |
|
434 | - //ensure amount is float |
|
435 | - $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
436 | - $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
437 | - // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
438 | - $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
439 | - // still a number or was amount converted to a string like "free" ? |
|
440 | - if (is_float($amount_formatted)) { |
|
441 | - // was a country ISO code passed ? if so generate currency config object for that country |
|
442 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
443 | - // verify results |
|
444 | - if ( ! $mny instanceof EE_Currency_Config) { |
|
445 | - // set default config country currency settings |
|
446 | - $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
447 | - ? EE_Registry::instance()->CFG->currency |
|
448 | - : new EE_Currency_Config(); |
|
449 | - } |
|
450 | - // format float |
|
451 | - $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
452 | - // add formatting ? |
|
453 | - if ( ! $return_raw) { |
|
454 | - // add currency sign |
|
455 | - if ($mny->sign_b4) { |
|
456 | - if ($amount >= 0) { |
|
457 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
458 | - } else { |
|
459 | - $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
460 | - } |
|
461 | - |
|
462 | - } else { |
|
463 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
464 | - } |
|
465 | - |
|
466 | - // filter to allow global setting of display_code |
|
467 | - $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
468 | - |
|
469 | - // add currency code ? |
|
470 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
471 | - } |
|
472 | - // filter results |
|
473 | - $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
|
474 | - $amount_formatted, $mny, $return_raw); |
|
475 | - } |
|
476 | - // clean up vars |
|
477 | - unset($mny); |
|
478 | - // return formatted currency amount |
|
479 | - return $amount_formatted; |
|
480 | - } |
|
481 | - |
|
482 | - |
|
483 | - /** |
|
484 | - * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
485 | - * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
486 | - * related status model or model object (i.e. in documentation etc.) |
|
487 | - * |
|
488 | - * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
489 | - * match, then 'Unknown' will be returned. |
|
490 | - * @param boolean $plural Whether to return plural or not |
|
491 | - * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
492 | - * @return string The localized label for the status id. |
|
493 | - */ |
|
494 | - public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
495 | - { |
|
496 | - /** @type EEM_Status $EEM_Status */ |
|
497 | - $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
498 | - $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
499 | - $schema); |
|
500 | - return $status[$status_id]; |
|
501 | - } |
|
502 | - |
|
503 | - |
|
504 | - /** |
|
505 | - * This helper just returns a button or link for the given parameters |
|
506 | - * |
|
507 | - * @param string $url the url for the link |
|
508 | - * @param string $label What is the label you want displayed for the button |
|
509 | - * @param string $class what class is used for the button (defaults to 'button-primary') |
|
510 | - * @param string $icon |
|
511 | - * @param string $title |
|
512 | - * @return string the html output for the button |
|
513 | - */ |
|
514 | - public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
515 | - { |
|
516 | - $icon_html = ''; |
|
517 | - if ( ! empty($icon)) { |
|
518 | - $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
519 | - $dashicons = array_filter($dashicons); |
|
520 | - $count = count($dashicons); |
|
521 | - $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
522 | - foreach ($dashicons as $dashicon) { |
|
523 | - $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
524 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
525 | - } |
|
526 | - $icon_html .= $count > 1 ? '</span>' : ''; |
|
527 | - } |
|
528 | - $label = ! empty($icon) ? $icon_html . $label : $label; |
|
529 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
530 | - return $button; |
|
531 | - } |
|
532 | - |
|
533 | - |
|
534 | - /** |
|
535 | - * This returns a generated link that will load the related help tab on admin pages. |
|
536 | - * |
|
537 | - * @param string $help_tab_id the id for the connected help tab |
|
538 | - * @param bool|string $page The page identifier for the page the help tab is on |
|
539 | - * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
540 | - * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
541 | - * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
542 | - * @return string generated link |
|
543 | - */ |
|
544 | - public static function get_help_tab_link( |
|
545 | - $help_tab_id, |
|
546 | - $page = false, |
|
547 | - $action = false, |
|
548 | - $icon_style = false, |
|
549 | - $help_text = false |
|
550 | - ) { |
|
551 | - |
|
552 | - if ( ! $page) { |
|
553 | - $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
554 | - } |
|
555 | - |
|
556 | - if ( ! $action) { |
|
557 | - $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
558 | - } |
|
559 | - |
|
560 | - $action = empty($action) ? 'default' : $action; |
|
561 | - |
|
562 | - |
|
563 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
564 | - $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
565 | - $help_text = ! $help_text ? '' : $help_text; |
|
566 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
567 | - 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
568 | - } |
|
569 | - |
|
570 | - |
|
571 | - /** |
|
572 | - * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
573 | - * |
|
574 | - * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
575 | - * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
576 | - * @param EE_Help_Tour |
|
577 | - * @return string html |
|
578 | - */ |
|
579 | - public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
580 | - { |
|
581 | - $id = $tour->get_slug(); |
|
582 | - $stops = $tour->get_stops(); |
|
583 | - |
|
584 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
585 | - |
|
586 | - foreach ($stops as $stop) { |
|
587 | - $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
588 | - $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
589 | - |
|
590 | - //if container is set to modal then let's make sure we set the options accordingly |
|
591 | - if (empty($data_id) && empty($data_class)) { |
|
592 | - $stop['options']['modal'] = true; |
|
593 | - $stop['options']['expose'] = true; |
|
594 | - } |
|
595 | - |
|
596 | - $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
597 | - $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
598 | - $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
599 | - |
|
600 | - //options |
|
601 | - if (isset($stop['options']) && is_array($stop['options'])) { |
|
602 | - $options = ' data-options="'; |
|
603 | - foreach ($stop['options'] as $option => $value) { |
|
604 | - $options .= $option . ':' . $value . ';'; |
|
605 | - } |
|
606 | - $options .= '"'; |
|
607 | - } else { |
|
608 | - $options = ''; |
|
609 | - } |
|
610 | - |
|
611 | - //let's put all together |
|
612 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
613 | - } |
|
614 | - |
|
615 | - $content .= '</ol>'; |
|
616 | - return $content; |
|
617 | - } |
|
618 | - |
|
619 | - |
|
620 | - /** |
|
621 | - * This is a helper method to generate a status legend for a given status array. |
|
622 | - * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
623 | - * status_array. |
|
624 | - * |
|
625 | - * @param array $status_array array of statuses that will make up the legend. In format: |
|
626 | - * array( |
|
627 | - * 'status_item' => 'status_name' |
|
628 | - * ) |
|
629 | - * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
630 | - * the legend. |
|
631 | - * @throws EE_Error |
|
632 | - * @return string html structure for status. |
|
633 | - */ |
|
634 | - public static function status_legend($status_array, $active_status = '') |
|
635 | - { |
|
636 | - if ( ! is_array($status_array)) { |
|
637 | - throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
638 | - 'event_espresso')); |
|
639 | - } |
|
640 | - |
|
641 | - $setup_array = array(); |
|
642 | - foreach ($status_array as $item => $status) { |
|
643 | - $setup_array[$item] = array( |
|
644 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
645 | - 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
646 | - 'status' => $status, |
|
647 | - ); |
|
648 | - } |
|
649 | - |
|
650 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
651 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
652 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
653 | - foreach ($setup_array as $item => $details) { |
|
654 | - $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
655 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
656 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
657 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
658 | - $content .= '</dt>' . "\n"; |
|
659 | - } |
|
660 | - $content .= '</dl>' . "\n"; |
|
661 | - $content .= '</div>' . "\n"; |
|
662 | - return $content; |
|
663 | - } |
|
664 | - |
|
665 | - |
|
666 | - /** |
|
667 | - * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
668 | - * that's nice for presenting in the wp admin |
|
669 | - * |
|
670 | - * @param mixed $data |
|
671 | - * @return string |
|
672 | - */ |
|
673 | - public static function layout_array_as_table($data) |
|
674 | - { |
|
675 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
676 | - $data = (array)$data; |
|
677 | - } |
|
678 | - ob_start(); |
|
679 | - if (is_array($data)) { |
|
680 | - if (EEH_Array::is_associative_array($data)) { |
|
681 | - ?> |
|
62 | + private static $_espresso_themes = array(); |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
67 | + * |
|
68 | + * @return boolean |
|
69 | + */ |
|
70 | + public static function is_espresso_theme() |
|
71 | + { |
|
72 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
77 | + * load it's functions.php file ( if not already loaded ) |
|
78 | + * |
|
79 | + * @return void |
|
80 | + */ |
|
81 | + public static function load_espresso_theme_functions() |
|
82 | + { |
|
83 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
84 | + if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
85 | + require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
86 | + } |
|
87 | + } |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
93 | + * |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + public static function get_espresso_themes() |
|
97 | + { |
|
98 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
99 | + $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
100 | + if (empty($espresso_themes)) { |
|
101 | + return array(); |
|
102 | + } |
|
103 | + if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
104 | + unset($espresso_themes[$key]); |
|
105 | + } |
|
106 | + EEH_Template::$_espresso_themes = array(); |
|
107 | + foreach ($espresso_themes as $espresso_theme) { |
|
108 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
109 | + } |
|
110 | + } |
|
111 | + return EEH_Template::$_espresso_themes; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * EEH_Template::get_template_part |
|
117 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
118 | + * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
119 | + * filtering based off of the entire template part name |
|
120 | + * |
|
121 | + * @param string $slug The slug name for the generic template. |
|
122 | + * @param string $name The name of the specialised template. |
|
123 | + * @param array $template_args |
|
124 | + * @param bool $return_string |
|
125 | + * @return string the html output for the formatted money value |
|
126 | + */ |
|
127 | + public static function get_template_part( |
|
128 | + $slug = null, |
|
129 | + $name = null, |
|
130 | + $template_args = array(), |
|
131 | + $return_string = false |
|
132 | + ) { |
|
133 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
134 | + $templates = array(); |
|
135 | + $name = (string)$name; |
|
136 | + if ($name != '') { |
|
137 | + $templates[] = "{$slug}-{$name}.php"; |
|
138 | + } |
|
139 | + // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
140 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
141 | + EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * locate_template |
|
148 | + * locate a template file by looking in the following places, in the following order: |
|
149 | + * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
150 | + * <assumed full absolute server path> |
|
151 | + * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
152 | + * <server path up to>/wp-content/uploads/espresso/templates/ |
|
153 | + * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
154 | + * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
155 | + * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
156 | + * as soon as the template is found in one of these locations, it will be returned or loaded |
|
157 | + * Example: |
|
158 | + * You are using the WordPress Twenty Sixteen theme, |
|
159 | + * and you want to customize the "some-event.template.php" template, |
|
160 | + * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
161 | + * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
162 | + * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
163 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
164 | + * /relative/path/to/some-event.template.php |
|
165 | + * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
166 | + * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
167 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
168 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
169 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
170 | + * Had you passed an absolute path to your template that was in some other location, |
|
171 | + * ie: "/absolute/path/to/some-event.template.php" |
|
172 | + * then the search would have been : |
|
173 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
174 | + * /absolute/path/to/some-event.template.php |
|
175 | + * and stopped there upon finding it in the second location |
|
176 | + * |
|
177 | + * @param array|string $templates array of template file names including extension (or just a single string) |
|
178 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
179 | + * @param boolean $load whether to pass the located template path on to the |
|
180 | + * EEH_Template::display_template() method or simply return it |
|
181 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
182 | + * string |
|
183 | + * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
184 | + * generate a custom template or not. Used in places where you don't actually |
|
185 | + * load the template, you just want to know if there's a custom version of it. |
|
186 | + * @return mixed |
|
187 | + */ |
|
188 | + public static function locate_template( |
|
189 | + $templates = array(), |
|
190 | + $template_args = array(), |
|
191 | + $load = true, |
|
192 | + $return_string = true, |
|
193 | + $check_if_custom = false |
|
194 | + ) { |
|
195 | + // first use WP locate_template to check for template in the current theme folder |
|
196 | + $template_path = locate_template($templates); |
|
197 | + |
|
198 | + if ($check_if_custom && ! empty($template_path)) { |
|
199 | + return true; |
|
200 | + } |
|
201 | + |
|
202 | + // not in the theme |
|
203 | + if (empty($template_path)) { |
|
204 | + // not even a template to look for ? |
|
205 | + if (empty($templates)) { |
|
206 | + // get post_type |
|
207 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
208 | + // get array of EE Custom Post Types |
|
209 | + $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
|
210 | + // build template name based on request |
|
211 | + if (isset($EE_CPTs[$post_type])) { |
|
212 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
213 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
214 | + $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
215 | + } |
|
216 | + } |
|
217 | + // currently active EE template theme |
|
218 | + $current_theme = EE_Config::get_current_theme(); |
|
219 | + |
|
220 | + // array of paths to folders that may contain templates |
|
221 | + $template_folder_paths = array( |
|
222 | + // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
223 | + EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
224 | + // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
225 | + EVENT_ESPRESSO_TEMPLATE_DIR, |
|
226 | + ); |
|
227 | + |
|
228 | + //add core plugin folders for checking only if we're not $check_if_custom |
|
229 | + if ( ! $check_if_custom) { |
|
230 | + $core_paths = array( |
|
231 | + // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
232 | + EE_PUBLIC . $current_theme, |
|
233 | + // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
234 | + EE_TEMPLATES . $current_theme, |
|
235 | + // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
236 | + EE_PLUGIN_DIR_PATH, |
|
237 | + ); |
|
238 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
239 | + } |
|
240 | + |
|
241 | + // now filter that array |
|
242 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
243 | + $template_folder_paths); |
|
244 | + $templates = is_array($templates) ? $templates : array($templates); |
|
245 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
246 | + // array to hold all possible template paths |
|
247 | + $full_template_paths = array(); |
|
248 | + |
|
249 | + // loop through $templates |
|
250 | + foreach ($templates as $template) { |
|
251 | + // normalize directory separators |
|
252 | + $template = EEH_File::standardise_directory_separators($template); |
|
253 | + $file_name = basename($template); |
|
254 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
255 | + // while looping through all template folder paths |
|
256 | + foreach ($template_folder_paths as $template_folder_path) { |
|
257 | + // normalize directory separators |
|
258 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
259 | + // determine if any common base path exists between the two paths |
|
260 | + $common_base_path = EEH_Template::_find_common_base_path( |
|
261 | + array($template_folder_path, $template_path_minus_file_name) |
|
262 | + ); |
|
263 | + if ($common_base_path !== '') { |
|
264 | + // both paths have a common base, so just tack the filename onto our search path |
|
265 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
266 | + } else { |
|
267 | + // no common base path, so let's just concatenate |
|
268 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
269 | + } |
|
270 | + // build up our template locations array by adding our resolved paths |
|
271 | + $full_template_paths[] = $resolved_path; |
|
272 | + } |
|
273 | + // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
274 | + array_unshift($full_template_paths, $template); |
|
275 | + // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
276 | + array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
277 | + } |
|
278 | + // filter final array of full template paths |
|
279 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
280 | + $full_template_paths, $file_name); |
|
281 | + // now loop through our final array of template location paths and check each location |
|
282 | + foreach ((array)$full_template_paths as $full_template_path) { |
|
283 | + if (is_readable($full_template_path)) { |
|
284 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
285 | + // hook that can be used to display the full template path that will be used |
|
286 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
287 | + break; |
|
288 | + } |
|
289 | + } |
|
290 | + } |
|
291 | + // if we got it and you want to see it... |
|
292 | + if ($template_path && $load && ! $check_if_custom) { |
|
293 | + if ($return_string) { |
|
294 | + return EEH_Template::display_template($template_path, $template_args, true); |
|
295 | + } else { |
|
296 | + EEH_Template::display_template($template_path, $template_args, false); |
|
297 | + } |
|
298 | + } |
|
299 | + return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * _find_common_base_path |
|
305 | + * given two paths, this determines if there is a common base path between the two |
|
306 | + * |
|
307 | + * @param array $paths |
|
308 | + * @return string |
|
309 | + */ |
|
310 | + protected static function _find_common_base_path($paths) |
|
311 | + { |
|
312 | + $last_offset = 0; |
|
313 | + $common_base_path = ''; |
|
314 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
315 | + $dir_length = $index - $last_offset + 1; |
|
316 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
317 | + foreach ($paths as $path) { |
|
318 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
319 | + return $common_base_path; |
|
320 | + } |
|
321 | + } |
|
322 | + $common_base_path .= $directory; |
|
323 | + $last_offset = $index + 1; |
|
324 | + } |
|
325 | + return substr($common_base_path, 0, -1); |
|
326 | + } |
|
327 | + |
|
328 | + |
|
329 | + /** |
|
330 | + * load and display a template |
|
331 | + * |
|
332 | + * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
333 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
334 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
335 | + * @return mixed string |
|
336 | + */ |
|
337 | + public static function display_template($template_path = false, $template_args = array(), $return_string = false) |
|
338 | + { |
|
339 | + |
|
340 | + /** |
|
341 | + * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
342 | + * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
343 | + * the display_template method are templates we DON'T want modified (usually because of js |
|
344 | + * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
345 | + * using this. |
|
346 | + * |
|
347 | + * @since 4.6.0 |
|
348 | + */ |
|
349 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
350 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
351 | + |
|
352 | + // you gimme nuttin - YOU GET NUTTIN !! |
|
353 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
354 | + return ''; |
|
355 | + } |
|
356 | + // if $template_args are not in an array, then make it so |
|
357 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
358 | + $template_args = array($template_args); |
|
359 | + } |
|
360 | + extract((array)$template_args); |
|
361 | + |
|
362 | + if ($return_string) { |
|
363 | + // because we want to return a string, we are going to capture the output |
|
364 | + ob_start(); |
|
365 | + include($template_path); |
|
366 | + return ob_get_clean(); |
|
367 | + } else { |
|
368 | + include($template_path); |
|
369 | + } |
|
370 | + return ''; |
|
371 | + } |
|
372 | + |
|
373 | + |
|
374 | + /** |
|
375 | + * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
376 | + * |
|
377 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
378 | + * @param string $prefix added to the beginning of the generated class |
|
379 | + * @param string $suffix added to the end of the generated class |
|
380 | + * @return string |
|
381 | + */ |
|
382 | + public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
383 | + { |
|
384 | + // in the beginning... |
|
385 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
386 | + // da muddle |
|
387 | + $class = ''; |
|
388 | + // the end |
|
389 | + $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
390 | + // is the passed object an EE object ? |
|
391 | + if ($object instanceof EE_Base_Class) { |
|
392 | + // grab the exact type of object |
|
393 | + $obj_class = get_class($object); |
|
394 | + // depending on the type of object... |
|
395 | + switch ($obj_class) { |
|
396 | + // no specifics just yet... |
|
397 | + default : |
|
398 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
399 | + $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
400 | + |
|
401 | + } |
|
402 | + } |
|
403 | + return $prefix . $class . $suffix; |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * EEH_Template::format_currency |
|
410 | + * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
411 | + * the country currency settings from the supplied country ISO code |
|
412 | + * |
|
413 | + * @param float $amount raw money value |
|
414 | + * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
415 | + * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
416 | + * @param string $CNT_ISO 2 letter ISO code for a country |
|
417 | + * @param string $cur_code_span_class |
|
418 | + * @return string the html output for the formatted money value |
|
419 | + * @throws \EE_Error |
|
420 | + */ |
|
421 | + public static function format_currency( |
|
422 | + $amount = null, |
|
423 | + $return_raw = false, |
|
424 | + $display_code = true, |
|
425 | + $CNT_ISO = '', |
|
426 | + $cur_code_span_class = 'currency-code' |
|
427 | + ) { |
|
428 | + // ensure amount was received |
|
429 | + if ($amount === null) { |
|
430 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
431 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
432 | + return ''; |
|
433 | + } |
|
434 | + //ensure amount is float |
|
435 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
436 | + $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
437 | + // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
438 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
439 | + // still a number or was amount converted to a string like "free" ? |
|
440 | + if (is_float($amount_formatted)) { |
|
441 | + // was a country ISO code passed ? if so generate currency config object for that country |
|
442 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
443 | + // verify results |
|
444 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
445 | + // set default config country currency settings |
|
446 | + $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
447 | + ? EE_Registry::instance()->CFG->currency |
|
448 | + : new EE_Currency_Config(); |
|
449 | + } |
|
450 | + // format float |
|
451 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
452 | + // add formatting ? |
|
453 | + if ( ! $return_raw) { |
|
454 | + // add currency sign |
|
455 | + if ($mny->sign_b4) { |
|
456 | + if ($amount >= 0) { |
|
457 | + $amount_formatted = $mny->sign . $amount_formatted; |
|
458 | + } else { |
|
459 | + $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
460 | + } |
|
461 | + |
|
462 | + } else { |
|
463 | + $amount_formatted = $amount_formatted . $mny->sign; |
|
464 | + } |
|
465 | + |
|
466 | + // filter to allow global setting of display_code |
|
467 | + $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
468 | + |
|
469 | + // add currency code ? |
|
470 | + $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
471 | + } |
|
472 | + // filter results |
|
473 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
|
474 | + $amount_formatted, $mny, $return_raw); |
|
475 | + } |
|
476 | + // clean up vars |
|
477 | + unset($mny); |
|
478 | + // return formatted currency amount |
|
479 | + return $amount_formatted; |
|
480 | + } |
|
481 | + |
|
482 | + |
|
483 | + /** |
|
484 | + * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
485 | + * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
486 | + * related status model or model object (i.e. in documentation etc.) |
|
487 | + * |
|
488 | + * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
489 | + * match, then 'Unknown' will be returned. |
|
490 | + * @param boolean $plural Whether to return plural or not |
|
491 | + * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
492 | + * @return string The localized label for the status id. |
|
493 | + */ |
|
494 | + public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
495 | + { |
|
496 | + /** @type EEM_Status $EEM_Status */ |
|
497 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
498 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
499 | + $schema); |
|
500 | + return $status[$status_id]; |
|
501 | + } |
|
502 | + |
|
503 | + |
|
504 | + /** |
|
505 | + * This helper just returns a button or link for the given parameters |
|
506 | + * |
|
507 | + * @param string $url the url for the link |
|
508 | + * @param string $label What is the label you want displayed for the button |
|
509 | + * @param string $class what class is used for the button (defaults to 'button-primary') |
|
510 | + * @param string $icon |
|
511 | + * @param string $title |
|
512 | + * @return string the html output for the button |
|
513 | + */ |
|
514 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
515 | + { |
|
516 | + $icon_html = ''; |
|
517 | + if ( ! empty($icon)) { |
|
518 | + $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
519 | + $dashicons = array_filter($dashicons); |
|
520 | + $count = count($dashicons); |
|
521 | + $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
522 | + foreach ($dashicons as $dashicon) { |
|
523 | + $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
524 | + $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
525 | + } |
|
526 | + $icon_html .= $count > 1 ? '</span>' : ''; |
|
527 | + } |
|
528 | + $label = ! empty($icon) ? $icon_html . $label : $label; |
|
529 | + $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
530 | + return $button; |
|
531 | + } |
|
532 | + |
|
533 | + |
|
534 | + /** |
|
535 | + * This returns a generated link that will load the related help tab on admin pages. |
|
536 | + * |
|
537 | + * @param string $help_tab_id the id for the connected help tab |
|
538 | + * @param bool|string $page The page identifier for the page the help tab is on |
|
539 | + * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
540 | + * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
541 | + * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
542 | + * @return string generated link |
|
543 | + */ |
|
544 | + public static function get_help_tab_link( |
|
545 | + $help_tab_id, |
|
546 | + $page = false, |
|
547 | + $action = false, |
|
548 | + $icon_style = false, |
|
549 | + $help_text = false |
|
550 | + ) { |
|
551 | + |
|
552 | + if ( ! $page) { |
|
553 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
554 | + } |
|
555 | + |
|
556 | + if ( ! $action) { |
|
557 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
558 | + } |
|
559 | + |
|
560 | + $action = empty($action) ? 'default' : $action; |
|
561 | + |
|
562 | + |
|
563 | + $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
564 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
565 | + $help_text = ! $help_text ? '' : $help_text; |
|
566 | + return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
567 | + 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
568 | + } |
|
569 | + |
|
570 | + |
|
571 | + /** |
|
572 | + * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
573 | + * |
|
574 | + * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
575 | + * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
576 | + * @param EE_Help_Tour |
|
577 | + * @return string html |
|
578 | + */ |
|
579 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
580 | + { |
|
581 | + $id = $tour->get_slug(); |
|
582 | + $stops = $tour->get_stops(); |
|
583 | + |
|
584 | + $content = '<ol style="display:none" id="' . $id . '">'; |
|
585 | + |
|
586 | + foreach ($stops as $stop) { |
|
587 | + $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
588 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
589 | + |
|
590 | + //if container is set to modal then let's make sure we set the options accordingly |
|
591 | + if (empty($data_id) && empty($data_class)) { |
|
592 | + $stop['options']['modal'] = true; |
|
593 | + $stop['options']['expose'] = true; |
|
594 | + } |
|
595 | + |
|
596 | + $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
597 | + $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
598 | + $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
599 | + |
|
600 | + //options |
|
601 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
602 | + $options = ' data-options="'; |
|
603 | + foreach ($stop['options'] as $option => $value) { |
|
604 | + $options .= $option . ':' . $value . ';'; |
|
605 | + } |
|
606 | + $options .= '"'; |
|
607 | + } else { |
|
608 | + $options = ''; |
|
609 | + } |
|
610 | + |
|
611 | + //let's put all together |
|
612 | + $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
613 | + } |
|
614 | + |
|
615 | + $content .= '</ol>'; |
|
616 | + return $content; |
|
617 | + } |
|
618 | + |
|
619 | + |
|
620 | + /** |
|
621 | + * This is a helper method to generate a status legend for a given status array. |
|
622 | + * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
623 | + * status_array. |
|
624 | + * |
|
625 | + * @param array $status_array array of statuses that will make up the legend. In format: |
|
626 | + * array( |
|
627 | + * 'status_item' => 'status_name' |
|
628 | + * ) |
|
629 | + * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
630 | + * the legend. |
|
631 | + * @throws EE_Error |
|
632 | + * @return string html structure for status. |
|
633 | + */ |
|
634 | + public static function status_legend($status_array, $active_status = '') |
|
635 | + { |
|
636 | + if ( ! is_array($status_array)) { |
|
637 | + throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
638 | + 'event_espresso')); |
|
639 | + } |
|
640 | + |
|
641 | + $setup_array = array(); |
|
642 | + foreach ($status_array as $item => $status) { |
|
643 | + $setup_array[$item] = array( |
|
644 | + 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
645 | + 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
646 | + 'status' => $status, |
|
647 | + ); |
|
648 | + } |
|
649 | + |
|
650 | + $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
651 | + $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
652 | + $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
653 | + foreach ($setup_array as $item => $details) { |
|
654 | + $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
655 | + $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
656 | + $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
657 | + $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
658 | + $content .= '</dt>' . "\n"; |
|
659 | + } |
|
660 | + $content .= '</dl>' . "\n"; |
|
661 | + $content .= '</div>' . "\n"; |
|
662 | + return $content; |
|
663 | + } |
|
664 | + |
|
665 | + |
|
666 | + /** |
|
667 | + * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
668 | + * that's nice for presenting in the wp admin |
|
669 | + * |
|
670 | + * @param mixed $data |
|
671 | + * @return string |
|
672 | + */ |
|
673 | + public static function layout_array_as_table($data) |
|
674 | + { |
|
675 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
676 | + $data = (array)$data; |
|
677 | + } |
|
678 | + ob_start(); |
|
679 | + if (is_array($data)) { |
|
680 | + if (EEH_Array::is_associative_array($data)) { |
|
681 | + ?> |
|
682 | 682 | <table class="widefat"> |
683 | 683 | <tbody> |
684 | 684 | <?php |
685 | - foreach ($data as $data_key => $data_values) { |
|
686 | - ?> |
|
685 | + foreach ($data as $data_key => $data_values) { |
|
686 | + ?> |
|
687 | 687 | <tr> |
688 | 688 | <td> |
689 | 689 | <?php echo $data_key; ?> |
@@ -693,247 +693,247 @@ discard block |
||
693 | 693 | </td> |
694 | 694 | </tr> |
695 | 695 | <?php |
696 | - } ?> |
|
696 | + } ?> |
|
697 | 697 | </tbody> |
698 | 698 | </table> |
699 | 699 | <?php |
700 | - } else { |
|
701 | - ?> |
|
700 | + } else { |
|
701 | + ?> |
|
702 | 702 | <ul> |
703 | 703 | <?php |
704 | - foreach ($data as $datum) { |
|
705 | - echo "<li>"; |
|
706 | - echo self::layout_array_as_table($datum); |
|
707 | - echo "</li>"; |
|
708 | - } ?> |
|
704 | + foreach ($data as $datum) { |
|
705 | + echo "<li>"; |
|
706 | + echo self::layout_array_as_table($datum); |
|
707 | + echo "</li>"; |
|
708 | + } ?> |
|
709 | 709 | </ul> |
710 | 710 | <?php |
711 | - } |
|
712 | - } else { |
|
713 | - //simple value |
|
714 | - echo esc_html($data); |
|
715 | - } |
|
716 | - return ob_get_clean(); |
|
717 | - } |
|
718 | - |
|
719 | - |
|
720 | - /** |
|
721 | - * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
722 | - * |
|
723 | - * @since 4.4.0 |
|
724 | - * @see self:get_paging_html() for argument docs. |
|
725 | - * @param $total_items |
|
726 | - * @param $current |
|
727 | - * @param $per_page |
|
728 | - * @param $url |
|
729 | - * @param bool $show_num_field |
|
730 | - * @param string $paged_arg_name |
|
731 | - * @param array $items_label |
|
732 | - * @return string |
|
733 | - */ |
|
734 | - public static function paging_html( |
|
735 | - $total_items, |
|
736 | - $current, |
|
737 | - $per_page, |
|
738 | - $url, |
|
739 | - $show_num_field = true, |
|
740 | - $paged_arg_name = 'paged', |
|
741 | - $items_label = array() |
|
742 | - ) { |
|
743 | - echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
744 | - $items_label); |
|
745 | - } |
|
746 | - |
|
747 | - |
|
748 | - /** |
|
749 | - * A method for generating paging similar to WP_List_Table |
|
750 | - * |
|
751 | - * @since 4.4.0 |
|
752 | - * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
753 | - * @param integer $total_items How many total items there are to page. |
|
754 | - * @param integer $current What the current page is. |
|
755 | - * @param integer $per_page How many items per page. |
|
756 | - * @param string $url What the base url for page links is. |
|
757 | - * @param boolean $show_num_field Whether to show the input for changing page number. |
|
758 | - * @param string $paged_arg_name The name of the key for the paged query argument. |
|
759 | - * @param array $items_label An array of singular/plural values for the items label: |
|
760 | - * array( |
|
761 | - * 'single' => 'item', |
|
762 | - * 'plural' => 'items' |
|
763 | - * ) |
|
764 | - * @return string |
|
765 | - */ |
|
766 | - public static function get_paging_html( |
|
767 | - $total_items, |
|
768 | - $current, |
|
769 | - $per_page, |
|
770 | - $url, |
|
771 | - $show_num_field = true, |
|
772 | - $paged_arg_name = 'paged', |
|
773 | - $items_label = array() |
|
774 | - ) { |
|
775 | - $page_links = array(); |
|
776 | - $disable_first = $disable_last = ''; |
|
777 | - $total_items = (int)$total_items; |
|
778 | - $per_page = (int)$per_page; |
|
779 | - $current = (int)$current; |
|
780 | - $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
781 | - |
|
782 | - //filter items_label |
|
783 | - $items_label = apply_filters( |
|
784 | - 'FHEE__EEH_Template__get_paging_html__items_label', |
|
785 | - $items_label |
|
786 | - ); |
|
787 | - |
|
788 | - if (empty($items_label) |
|
789 | - || ! is_array($items_label) |
|
790 | - || ! isset($items_label['single']) |
|
791 | - || ! isset($items_label['plural']) |
|
792 | - ) { |
|
793 | - $items_label = array( |
|
794 | - 'single' => __('1 item', 'event_espresso'), |
|
795 | - 'plural' => __('%s items', 'event_espresso'), |
|
796 | - ); |
|
797 | - } else { |
|
798 | - $items_label = array( |
|
799 | - 'single' => '1 ' . esc_html($items_label['single']), |
|
800 | - 'plural' => '%s ' . esc_html($items_label['plural']), |
|
801 | - ); |
|
802 | - } |
|
803 | - |
|
804 | - $total_pages = ceil($total_items / $per_page); |
|
805 | - |
|
806 | - if ($total_pages <= 1) { |
|
807 | - return ''; |
|
808 | - } |
|
809 | - |
|
810 | - $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
811 | - |
|
812 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
813 | - |
|
814 | - if ($current === 1) { |
|
815 | - $disable_first = ' disabled'; |
|
816 | - } |
|
817 | - if ($current == $total_pages) { |
|
818 | - $disable_last = ' disabled'; |
|
819 | - } |
|
820 | - |
|
821 | - $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
822 | - 'first-page' . $disable_first, |
|
823 | - esc_attr__('Go to the first page'), |
|
824 | - esc_url(remove_query_arg($paged_arg_name, $url)), |
|
825 | - '«' |
|
826 | - ); |
|
827 | - |
|
828 | - $page_links[] = sprintf( |
|
829 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
830 | - 'prev-page' . $disable_first, |
|
831 | - esc_attr__('Go to the previous page'), |
|
832 | - esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
833 | - '‹' |
|
834 | - ); |
|
835 | - |
|
836 | - if ( ! $show_num_field) { |
|
837 | - $html_current_page = $current; |
|
838 | - } else { |
|
839 | - $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
840 | - esc_attr__('Current page'), |
|
841 | - $current, |
|
842 | - strlen($total_pages) |
|
843 | - ); |
|
844 | - } |
|
845 | - |
|
846 | - $html_total_pages = sprintf( |
|
847 | - '<span class="total-pages">%s</span>', |
|
848 | - number_format_i18n($total_pages) |
|
849 | - ); |
|
850 | - $page_links[] = sprintf( |
|
851 | - _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
852 | - $html_current_page, |
|
853 | - $html_total_pages, |
|
854 | - '<span class="paging-input">', |
|
855 | - '</span>' |
|
856 | - ); |
|
857 | - |
|
858 | - $page_links[] = sprintf( |
|
859 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
860 | - 'next-page' . $disable_last, |
|
861 | - esc_attr__('Go to the next page'), |
|
862 | - esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
863 | - '›' |
|
864 | - ); |
|
865 | - |
|
866 | - $page_links[] = sprintf( |
|
867 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
868 | - 'last-page' . $disable_last, |
|
869 | - esc_attr__('Go to the last page'), |
|
870 | - esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
871 | - '»' |
|
872 | - ); |
|
873 | - |
|
874 | - $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
875 | - // set page class |
|
876 | - if ($total_pages) { |
|
877 | - $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
878 | - } else { |
|
879 | - $page_class = ' no-pages'; |
|
880 | - } |
|
881 | - |
|
882 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
883 | - } |
|
884 | - |
|
885 | - |
|
886 | - /** |
|
887 | - * @param string $wrap_class |
|
888 | - * @param string $wrap_id |
|
889 | - * @return string |
|
890 | - */ |
|
891 | - public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
892 | - { |
|
893 | - $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
894 | - if ( |
|
895 | - ! $admin && |
|
896 | - ! apply_filters( |
|
897 | - 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
898 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
899 | - ) |
|
900 | - ) { |
|
901 | - return ''; |
|
902 | - } |
|
903 | - $tag = $admin ? 'span' : 'div'; |
|
904 | - $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
905 | - $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
906 | - $attributes .= ! empty($wrap_class) |
|
907 | - ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
908 | - : ' class="powered-by-event-espresso-credit"'; |
|
909 | - $query_args = array_merge( |
|
910 | - array( |
|
911 | - 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
912 | - 'utm_source' => 'powered_by_event_espresso', |
|
913 | - 'utm_medium' => 'link', |
|
914 | - 'utm_campaign' => 'powered_by', |
|
915 | - ), |
|
916 | - $query_args |
|
917 | - ); |
|
918 | - $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
919 | - $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
920 | - $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
921 | - $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
922 | - return (string)apply_filters( |
|
923 | - 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
924 | - sprintf( |
|
925 | - esc_html_x( |
|
926 | - '%1$sOnline event registration and ticketing powered by %2$s', |
|
927 | - 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
928 | - 'event_espresso' |
|
929 | - ), |
|
930 | - "<{$tag}{$attributes}>", |
|
931 | - "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>" |
|
932 | - ), |
|
933 | - $wrap_class, |
|
934 | - $wrap_id |
|
935 | - ); |
|
936 | - } |
|
711 | + } |
|
712 | + } else { |
|
713 | + //simple value |
|
714 | + echo esc_html($data); |
|
715 | + } |
|
716 | + return ob_get_clean(); |
|
717 | + } |
|
718 | + |
|
719 | + |
|
720 | + /** |
|
721 | + * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
722 | + * |
|
723 | + * @since 4.4.0 |
|
724 | + * @see self:get_paging_html() for argument docs. |
|
725 | + * @param $total_items |
|
726 | + * @param $current |
|
727 | + * @param $per_page |
|
728 | + * @param $url |
|
729 | + * @param bool $show_num_field |
|
730 | + * @param string $paged_arg_name |
|
731 | + * @param array $items_label |
|
732 | + * @return string |
|
733 | + */ |
|
734 | + public static function paging_html( |
|
735 | + $total_items, |
|
736 | + $current, |
|
737 | + $per_page, |
|
738 | + $url, |
|
739 | + $show_num_field = true, |
|
740 | + $paged_arg_name = 'paged', |
|
741 | + $items_label = array() |
|
742 | + ) { |
|
743 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
744 | + $items_label); |
|
745 | + } |
|
746 | + |
|
747 | + |
|
748 | + /** |
|
749 | + * A method for generating paging similar to WP_List_Table |
|
750 | + * |
|
751 | + * @since 4.4.0 |
|
752 | + * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
753 | + * @param integer $total_items How many total items there are to page. |
|
754 | + * @param integer $current What the current page is. |
|
755 | + * @param integer $per_page How many items per page. |
|
756 | + * @param string $url What the base url for page links is. |
|
757 | + * @param boolean $show_num_field Whether to show the input for changing page number. |
|
758 | + * @param string $paged_arg_name The name of the key for the paged query argument. |
|
759 | + * @param array $items_label An array of singular/plural values for the items label: |
|
760 | + * array( |
|
761 | + * 'single' => 'item', |
|
762 | + * 'plural' => 'items' |
|
763 | + * ) |
|
764 | + * @return string |
|
765 | + */ |
|
766 | + public static function get_paging_html( |
|
767 | + $total_items, |
|
768 | + $current, |
|
769 | + $per_page, |
|
770 | + $url, |
|
771 | + $show_num_field = true, |
|
772 | + $paged_arg_name = 'paged', |
|
773 | + $items_label = array() |
|
774 | + ) { |
|
775 | + $page_links = array(); |
|
776 | + $disable_first = $disable_last = ''; |
|
777 | + $total_items = (int)$total_items; |
|
778 | + $per_page = (int)$per_page; |
|
779 | + $current = (int)$current; |
|
780 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
781 | + |
|
782 | + //filter items_label |
|
783 | + $items_label = apply_filters( |
|
784 | + 'FHEE__EEH_Template__get_paging_html__items_label', |
|
785 | + $items_label |
|
786 | + ); |
|
787 | + |
|
788 | + if (empty($items_label) |
|
789 | + || ! is_array($items_label) |
|
790 | + || ! isset($items_label['single']) |
|
791 | + || ! isset($items_label['plural']) |
|
792 | + ) { |
|
793 | + $items_label = array( |
|
794 | + 'single' => __('1 item', 'event_espresso'), |
|
795 | + 'plural' => __('%s items', 'event_espresso'), |
|
796 | + ); |
|
797 | + } else { |
|
798 | + $items_label = array( |
|
799 | + 'single' => '1 ' . esc_html($items_label['single']), |
|
800 | + 'plural' => '%s ' . esc_html($items_label['plural']), |
|
801 | + ); |
|
802 | + } |
|
803 | + |
|
804 | + $total_pages = ceil($total_items / $per_page); |
|
805 | + |
|
806 | + if ($total_pages <= 1) { |
|
807 | + return ''; |
|
808 | + } |
|
809 | + |
|
810 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
811 | + |
|
812 | + $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
813 | + |
|
814 | + if ($current === 1) { |
|
815 | + $disable_first = ' disabled'; |
|
816 | + } |
|
817 | + if ($current == $total_pages) { |
|
818 | + $disable_last = ' disabled'; |
|
819 | + } |
|
820 | + |
|
821 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
822 | + 'first-page' . $disable_first, |
|
823 | + esc_attr__('Go to the first page'), |
|
824 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
825 | + '«' |
|
826 | + ); |
|
827 | + |
|
828 | + $page_links[] = sprintf( |
|
829 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
830 | + 'prev-page' . $disable_first, |
|
831 | + esc_attr__('Go to the previous page'), |
|
832 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
833 | + '‹' |
|
834 | + ); |
|
835 | + |
|
836 | + if ( ! $show_num_field) { |
|
837 | + $html_current_page = $current; |
|
838 | + } else { |
|
839 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
840 | + esc_attr__('Current page'), |
|
841 | + $current, |
|
842 | + strlen($total_pages) |
|
843 | + ); |
|
844 | + } |
|
845 | + |
|
846 | + $html_total_pages = sprintf( |
|
847 | + '<span class="total-pages">%s</span>', |
|
848 | + number_format_i18n($total_pages) |
|
849 | + ); |
|
850 | + $page_links[] = sprintf( |
|
851 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
852 | + $html_current_page, |
|
853 | + $html_total_pages, |
|
854 | + '<span class="paging-input">', |
|
855 | + '</span>' |
|
856 | + ); |
|
857 | + |
|
858 | + $page_links[] = sprintf( |
|
859 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
860 | + 'next-page' . $disable_last, |
|
861 | + esc_attr__('Go to the next page'), |
|
862 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
863 | + '›' |
|
864 | + ); |
|
865 | + |
|
866 | + $page_links[] = sprintf( |
|
867 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
868 | + 'last-page' . $disable_last, |
|
869 | + esc_attr__('Go to the last page'), |
|
870 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
871 | + '»' |
|
872 | + ); |
|
873 | + |
|
874 | + $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
875 | + // set page class |
|
876 | + if ($total_pages) { |
|
877 | + $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
878 | + } else { |
|
879 | + $page_class = ' no-pages'; |
|
880 | + } |
|
881 | + |
|
882 | + return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
883 | + } |
|
884 | + |
|
885 | + |
|
886 | + /** |
|
887 | + * @param string $wrap_class |
|
888 | + * @param string $wrap_id |
|
889 | + * @return string |
|
890 | + */ |
|
891 | + public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
892 | + { |
|
893 | + $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
894 | + if ( |
|
895 | + ! $admin && |
|
896 | + ! apply_filters( |
|
897 | + 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
898 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
899 | + ) |
|
900 | + ) { |
|
901 | + return ''; |
|
902 | + } |
|
903 | + $tag = $admin ? 'span' : 'div'; |
|
904 | + $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
905 | + $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
906 | + $attributes .= ! empty($wrap_class) |
|
907 | + ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
908 | + : ' class="powered-by-event-espresso-credit"'; |
|
909 | + $query_args = array_merge( |
|
910 | + array( |
|
911 | + 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
912 | + 'utm_source' => 'powered_by_event_espresso', |
|
913 | + 'utm_medium' => 'link', |
|
914 | + 'utm_campaign' => 'powered_by', |
|
915 | + ), |
|
916 | + $query_args |
|
917 | + ); |
|
918 | + $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
919 | + $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
920 | + $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
921 | + $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
922 | + return (string)apply_filters( |
|
923 | + 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
924 | + sprintf( |
|
925 | + esc_html_x( |
|
926 | + '%1$sOnline event registration and ticketing powered by %2$s', |
|
927 | + 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
928 | + 'event_espresso' |
|
929 | + ), |
|
930 | + "<{$tag}{$attributes}>", |
|
931 | + "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>" |
|
932 | + ), |
|
933 | + $wrap_class, |
|
934 | + $wrap_id |
|
935 | + ); |
|
936 | + } |
|
937 | 937 | |
938 | 938 | |
939 | 939 | } //end EEH_Template class |
@@ -950,33 +950,33 @@ discard block |
||
950 | 950 | |
951 | 951 | |
952 | 952 | if ( ! function_exists('espresso_pagination')) { |
953 | - /** |
|
954 | - * espresso_pagination |
|
955 | - * |
|
956 | - * @access public |
|
957 | - * @return void |
|
958 | - */ |
|
959 | - function espresso_pagination() |
|
960 | - { |
|
961 | - global $wp_query; |
|
962 | - $big = 999999999; // need an unlikely integer |
|
963 | - $pagination = paginate_links( |
|
964 | - array( |
|
965 | - 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
966 | - 'format' => '?paged=%#%', |
|
967 | - 'current' => max(1, get_query_var('paged')), |
|
968 | - 'total' => $wp_query->max_num_pages, |
|
969 | - 'show_all' => true, |
|
970 | - 'end_size' => 10, |
|
971 | - 'mid_size' => 6, |
|
972 | - 'prev_next' => true, |
|
973 | - 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
974 | - 'next_text' => __('NEXT ›', 'event_espresso'), |
|
975 | - 'type' => 'plain', |
|
976 | - 'add_args' => false, |
|
977 | - 'add_fragment' => '', |
|
978 | - ) |
|
979 | - ); |
|
980 | - echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
981 | - } |
|
953 | + /** |
|
954 | + * espresso_pagination |
|
955 | + * |
|
956 | + * @access public |
|
957 | + * @return void |
|
958 | + */ |
|
959 | + function espresso_pagination() |
|
960 | + { |
|
961 | + global $wp_query; |
|
962 | + $big = 999999999; // need an unlikely integer |
|
963 | + $pagination = paginate_links( |
|
964 | + array( |
|
965 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
966 | + 'format' => '?paged=%#%', |
|
967 | + 'current' => max(1, get_query_var('paged')), |
|
968 | + 'total' => $wp_query->max_num_pages, |
|
969 | + 'show_all' => true, |
|
970 | + 'end_size' => 10, |
|
971 | + 'mid_size' => 6, |
|
972 | + 'prev_next' => true, |
|
973 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
974 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
975 | + 'type' => 'plain', |
|
976 | + 'add_args' => false, |
|
977 | + 'add_fragment' => '', |
|
978 | + ) |
|
979 | + ); |
|
980 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
981 | + } |
|
982 | 982 | } |
983 | 983 | \ No newline at end of file |