@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | use EventEspresso\core\exceptions\InvalidSessionDataException; |
| 3 | 3 | use EventEspresso\core\services\cache\CacheStorageInterface; |
| 4 | 4 | |
| 5 | -if (!defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
| 5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
| 6 | 6 | /** |
| 7 | 7 | * |
| 8 | 8 | * EE_Session class |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * array for defining default session vars |
| 109 | 109 | * @var array |
| 110 | 110 | */ |
| 111 | - private $_default_session_vars = array ( |
|
| 111 | + private $_default_session_vars = array( |
|
| 112 | 112 | 'id' => null, |
| 113 | 113 | 'user_id' => null, |
| 114 | 114 | 'ip_address' => null, |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | // check if class object is instantiated |
| 137 | 137 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: |
| 138 | 138 | // add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
| 139 | - if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
| 140 | - self::$_instance = new self($cache_storage, $encryption ); |
|
| 139 | + if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) { |
|
| 140 | + self::$_instance = new self($cache_storage, $encryption); |
|
| 141 | 141 | } |
| 142 | 142 | return self::$_instance; |
| 143 | 143 | } |
@@ -152,15 +152,15 @@ discard block |
||
| 152 | 152 | * @throws \EE_Error |
| 153 | 153 | * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
| 154 | 154 | */ |
| 155 | - protected function __construct(CacheStorageInterface $cache_storage, EE_Encryption $encryption = null ) { |
|
| 155 | + protected function __construct(CacheStorageInterface $cache_storage, EE_Encryption $encryption = null) { |
|
| 156 | 156 | |
| 157 | 157 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
| 158 | - if ( ! apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
| 158 | + if ( ! apply_filters('FHEE_load_EE_Session', true)) { |
|
| 159 | 159 | return; |
| 160 | 160 | } |
| 161 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 162 | - if ( ! defined( 'ESPRESSO_SESSION' ) ) { |
|
| 163 | - define( 'ESPRESSO_SESSION', true ); |
|
| 161 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 162 | + if ( ! defined('ESPRESSO_SESSION')) { |
|
| 163 | + define('ESPRESSO_SESSION', true); |
|
| 164 | 164 | } |
| 165 | 165 | // default session lifespan in seconds |
| 166 | 166 | $this->_lifespan = apply_filters( |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | * } |
| 175 | 175 | */ |
| 176 | 176 | // retrieve session options from db |
| 177 | - $session_settings = (array) get_option( 'ee_session_settings', array() ); |
|
| 178 | - if ( ! empty( $session_settings )) { |
|
| 177 | + $session_settings = (array) get_option('ee_session_settings', array()); |
|
| 178 | + if ( ! empty($session_settings)) { |
|
| 179 | 179 | // cycle though existing session options |
| 180 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
| 180 | + foreach ($session_settings as $var_name => $session_setting) { |
|
| 181 | 181 | // set values for class properties |
| 182 | - $var_name = '_' . $var_name; |
|
| 182 | + $var_name = '_'.$var_name; |
|
| 183 | 183 | $this->{$var_name} = $session_setting; |
| 184 | 184 | } |
| 185 | 185 | } |
@@ -190,15 +190,15 @@ discard block |
||
| 190 | 190 | // encrypt data via: $this->encryption->encrypt(); |
| 191 | 191 | $this->encryption = $encryption; |
| 192 | 192 | // filter hook allows outside functions/classes/plugins to change default empty cart |
| 193 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
| 194 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
| 193 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
| 194 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
| 195 | 195 | // apply default session vars |
| 196 | 196 | $this->_set_defaults(); |
| 197 | 197 | add_action('AHEE__EE_System__initialize', array($this, 'open_session')); |
| 198 | 198 | // check request for 'clear_session' param |
| 199 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
| 199 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
| 200 | 200 | // once everything is all said and done, |
| 201 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
| 201 | + add_action('shutdown', array($this, 'update'), 100); |
|
| 202 | 202 | $this->configure_garbage_collection_filters(); |
| 203 | 203 | } |
| 204 | 204 | |
@@ -286,11 +286,11 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | private function _set_defaults() { |
| 288 | 288 | // set some defaults |
| 289 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
| 290 | - if ( is_array( $default_var )) { |
|
| 291 | - $this->_session_data[ $key ] = array(); |
|
| 289 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
| 290 | + if (is_array($default_var)) { |
|
| 291 | + $this->_session_data[$key] = array(); |
|
| 292 | 292 | } else { |
| 293 | - $this->_session_data[ $key ] = ''; |
|
| 293 | + $this->_session_data[$key] = ''; |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | } |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | * @param \EE_Checkout $checkout |
| 346 | 346 | * @return bool |
| 347 | 347 | */ |
| 348 | - public function set_checkout( EE_Checkout $checkout ) { |
|
| 348 | + public function set_checkout(EE_Checkout $checkout) { |
|
| 349 | 349 | $this->_session_data['checkout'] = $checkout; |
| 350 | 350 | return TRUE; |
| 351 | 351 | } |
@@ -378,9 +378,9 @@ discard block |
||
| 378 | 378 | * @return bool |
| 379 | 379 | * @throws \EE_Error |
| 380 | 380 | */ |
| 381 | - public function set_transaction( EE_Transaction $transaction ) { |
|
| 381 | + public function set_transaction(EE_Transaction $transaction) { |
|
| 382 | 382 | // first remove the session from the transaction before we save the transaction in the session |
| 383 | - $transaction->set_txn_session_data( NULL ); |
|
| 383 | + $transaction->set_txn_session_data(NULL); |
|
| 384 | 384 | $this->_session_data['transaction'] = $transaction; |
| 385 | 385 | return TRUE; |
| 386 | 386 | } |
@@ -416,15 +416,15 @@ discard block |
||
| 416 | 416 | * @param bool $reset_cache |
| 417 | 417 | * @return array |
| 418 | 418 | */ |
| 419 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
| 420 | - if ( $reset_cache ) { |
|
| 419 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
| 420 | + if ($reset_cache) { |
|
| 421 | 421 | $this->reset_cart(); |
| 422 | 422 | $this->reset_checkout(); |
| 423 | 423 | $this->reset_transaction(); |
| 424 | 424 | } |
| 425 | - if ( ! empty( $key )) { |
|
| 426 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
| 427 | - } else { |
|
| 425 | + if ( ! empty($key)) { |
|
| 426 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
| 427 | + } else { |
|
| 428 | 428 | return $this->_session_data; |
| 429 | 429 | } |
| 430 | 430 | } |
@@ -437,20 +437,20 @@ discard block |
||
| 437 | 437 | * @param array $data |
| 438 | 438 | * @return TRUE on success, FALSE on fail |
| 439 | 439 | */ |
| 440 | - public function set_session_data( $data ) { |
|
| 440 | + public function set_session_data($data) { |
|
| 441 | 441 | |
| 442 | 442 | // nothing ??? bad data ??? go home! |
| 443 | - if ( empty( $data ) || ! is_array( $data )) { |
|
| 444 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 443 | + if (empty($data) || ! is_array($data)) { |
|
| 444 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 445 | 445 | return FALSE; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - foreach ( $data as $key =>$value ) { |
|
| 449 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
| 450 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 448 | + foreach ($data as $key =>$value) { |
|
| 449 | + if (isset($this->_default_session_vars[$key])) { |
|
| 450 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
| 451 | 451 | return FALSE; |
| 452 | 452 | } else { |
| 453 | - $this->_session_data[ $key ] = $value; |
|
| 453 | + $this->_session_data[$key] = $value; |
|
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | 456 | |
@@ -468,9 +468,9 @@ discard block |
||
| 468 | 468 | * @throws \EE_Error |
| 469 | 469 | */ |
| 470 | 470 | private function _espresso_session() { |
| 471 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 471 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 472 | 472 | // check that session has started |
| 473 | - if ( session_id() === '' ) { |
|
| 473 | + if (session_id() === '') { |
|
| 474 | 474 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
| 475 | 475 | session_start(); |
| 476 | 476 | } |
@@ -479,39 +479,39 @@ discard block |
||
| 479 | 479 | // and the visitors IP |
| 480 | 480 | $this->_ip_address = $this->_visitor_ip(); |
| 481 | 481 | // set the "user agent" |
| 482 | - $this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
| 482 | + $this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
| 483 | 483 | // now let's retrieve what's in the db |
| 484 | 484 | $session_data = $this->_retrieve_session_data(); |
| 485 | - if (! empty($session_data)) { |
|
| 485 | + if ( ! empty($session_data)) { |
|
| 486 | 486 | // get the current time in UTC |
| 487 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
| 487 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
| 488 | 488 | // and reset the session expiration |
| 489 | - $this->_expiration = isset( $session_data['expiration'] ) |
|
| 489 | + $this->_expiration = isset($session_data['expiration']) |
|
| 490 | 490 | ? $session_data['expiration'] |
| 491 | 491 | : $this->_time + $this->_lifespan; |
| 492 | 492 | } else { |
| 493 | 493 | // set initial site access time and the session expiration |
| 494 | 494 | $this->_set_init_access_and_expiration(); |
| 495 | 495 | // set referer |
| 496 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) |
|
| 497 | - ? esc_attr( $_SERVER['HTTP_REFERER'] ) |
|
| 496 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) |
|
| 497 | + ? esc_attr($_SERVER['HTTP_REFERER']) |
|
| 498 | 498 | : ''; |
| 499 | 499 | // no previous session = go back and create one (on top of the data above) |
| 500 | 500 | return FALSE; |
| 501 | 501 | } |
| 502 | 502 | // now the user agent |
| 503 | - if ( $session_data['user_agent'] !== $this->_user_agent ) { |
|
| 503 | + if ($session_data['user_agent'] !== $this->_user_agent) { |
|
| 504 | 504 | return FALSE; |
| 505 | 505 | } |
| 506 | 506 | // wait a minute... how old are you? |
| 507 | - if ( $this->_time > $this->_expiration ) { |
|
| 507 | + if ($this->_time > $this->_expiration) { |
|
| 508 | 508 | // yer too old fer me! |
| 509 | 509 | $this->_expired = true; |
| 510 | 510 | // wipe out everything that isn't a default session datum |
| 511 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
| 511 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
| 512 | 512 | } |
| 513 | 513 | // make event espresso session data available to plugin |
| 514 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
| 514 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
| 515 | 515 | return TRUE; |
| 516 | 516 | |
| 517 | 517 | } |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | */ |
| 528 | 528 | protected function _retrieve_session_data() |
| 529 | 529 | { |
| 530 | - $ssn_key = EE_Session::session_id_prefix . $this->_sid; |
|
| 530 | + $ssn_key = EE_Session::session_id_prefix.$this->_sid; |
|
| 531 | 531 | try { |
| 532 | 532 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
| 533 | 533 | $session_data = $this->cache_storage->get($ssn_key, false); |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | } |
| 537 | 537 | if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
| 538 | 538 | $hash_check = $this->cache_storage->get( |
| 539 | - EE_Session::hash_check_prefix . $this->_sid, |
|
| 539 | + EE_Session::hash_check_prefix.$this->_sid, |
|
| 540 | 540 | false |
| 541 | 541 | ); |
| 542 | 542 | if ($hash_check && $hash_check !== md5($session_data)) { |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', |
| 547 | 547 | 'event_espresso' |
| 548 | 548 | ), |
| 549 | - EE_Session::session_id_prefix . $this->_sid |
|
| 549 | + EE_Session::session_id_prefix.$this->_sid |
|
| 550 | 550 | ), |
| 551 | 551 | __FILE__, __FUNCTION__, __LINE__ |
| 552 | 552 | ); |
@@ -558,17 +558,17 @@ discard block |
||
| 558 | 558 | $row = $wpdb->get_row( |
| 559 | 559 | $wpdb->prepare( |
| 560 | 560 | "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1", |
| 561 | - '_transient_' . $ssn_key |
|
| 561 | + '_transient_'.$ssn_key |
|
| 562 | 562 | ) |
| 563 | 563 | ); |
| 564 | 564 | $session_data = is_object($row) ? $row->option_value : null; |
| 565 | 565 | if ($session_data) { |
| 566 | 566 | $session_data = preg_replace_callback( |
| 567 | 567 | '!s:(d+):"(.*?)";!', |
| 568 | - function ($match) { |
|
| 568 | + function($match) { |
|
| 569 | 569 | return $match[1] === strlen($match[2]) |
| 570 | 570 | ? $match[0] |
| 571 | - : 's:' . strlen($match[2]) . ':"' . $match[2] . '";'; |
|
| 571 | + : 's:'.strlen($match[2]).':"'.$match[2].'";'; |
|
| 572 | 572 | }, |
| 573 | 573 | $session_data |
| 574 | 574 | ); |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | 'event_espresso' |
| 590 | 590 | ); |
| 591 | 591 | $msg .= WP_DEBUG |
| 592 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
| 592 | + ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data) |
|
| 593 | 593 | : ''; |
| 594 | 594 | throw new InvalidSessionDataException($msg, 0, $e); |
| 595 | 595 | } |
@@ -602,11 +602,11 @@ discard block |
||
| 602 | 602 | 'event_espresso' |
| 603 | 603 | ); |
| 604 | 604 | $msg .= WP_DEBUG |
| 605 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
| 605 | + ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data) |
|
| 606 | 606 | : ''; |
| 607 | 607 | throw new InvalidSessionDataException($msg); |
| 608 | 608 | } |
| 609 | - if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) { |
|
| 609 | + if (isset($session_data['transaction']) && absint($session_data['transaction']) !== 0) { |
|
| 610 | 610 | $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID( |
| 611 | 611 | $session_data['transaction'] |
| 612 | 612 | ); |
@@ -627,12 +627,12 @@ discard block |
||
| 627 | 627 | */ |
| 628 | 628 | protected function _generate_session_id() { |
| 629 | 629 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
| 630 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
| 631 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
| 630 | + if (isset($_REQUEST['EESID'])) { |
|
| 631 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
| 632 | 632 | } else { |
| 633 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
| 633 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
| 634 | 634 | } |
| 635 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
| 635 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | |
@@ -644,20 +644,20 @@ discard block |
||
| 644 | 644 | */ |
| 645 | 645 | protected function _get_sid_salt() { |
| 646 | 646 | // was session id salt already saved to db ? |
| 647 | - if ( empty( $this->_sid_salt ) ) { |
|
| 647 | + if (empty($this->_sid_salt)) { |
|
| 648 | 648 | // no? then maybe use WP defined constant |
| 649 | - if ( defined( 'AUTH_SALT' ) ) { |
|
| 649 | + if (defined('AUTH_SALT')) { |
|
| 650 | 650 | $this->_sid_salt = AUTH_SALT; |
| 651 | 651 | } |
| 652 | 652 | // if salt doesn't exist or is too short |
| 653 | - if ( strlen( $this->_sid_salt ) < 32 ) { |
|
| 653 | + if (strlen($this->_sid_salt) < 32) { |
|
| 654 | 654 | // create a new one |
| 655 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
| 655 | + $this->_sid_salt = wp_generate_password(64); |
|
| 656 | 656 | } |
| 657 | 657 | // and save it as a permanent session setting |
| 658 | - $session_settings = get_option( 'ee_session_settings' ); |
|
| 659 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
| 660 | - update_option( 'ee_session_settings', $session_settings ); |
|
| 658 | + $session_settings = get_option('ee_session_settings'); |
|
| 659 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
| 660 | + update_option('ee_session_settings', $session_settings); |
|
| 661 | 661 | } |
| 662 | 662 | return $this->_sid_salt; |
| 663 | 663 | } |
@@ -686,19 +686,19 @@ discard block |
||
| 686 | 686 | * @return TRUE on success, FALSE on fail |
| 687 | 687 | * @throws \EE_Error |
| 688 | 688 | */ |
| 689 | - public function update( $new_session = FALSE ) { |
|
| 690 | - $this->_session_data = isset( $this->_session_data ) |
|
| 691 | - && is_array( $this->_session_data ) |
|
| 692 | - && isset( $this->_session_data['id']) |
|
| 689 | + public function update($new_session = FALSE) { |
|
| 690 | + $this->_session_data = isset($this->_session_data) |
|
| 691 | + && is_array($this->_session_data) |
|
| 692 | + && isset($this->_session_data['id']) |
|
| 693 | 693 | ? $this->_session_data |
| 694 | 694 | : array(); |
| 695 | - if ( empty( $this->_session_data )) { |
|
| 695 | + if (empty($this->_session_data)) { |
|
| 696 | 696 | $this->_set_defaults(); |
| 697 | 697 | } |
| 698 | 698 | $session_data = array(); |
| 699 | - foreach ( $this->_session_data as $key => $value ) { |
|
| 699 | + foreach ($this->_session_data as $key => $value) { |
|
| 700 | 700 | |
| 701 | - switch( $key ) { |
|
| 701 | + switch ($key) { |
|
| 702 | 702 | |
| 703 | 703 | case 'id' : |
| 704 | 704 | // session ID |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | break; |
| 717 | 717 | |
| 718 | 718 | case 'init_access' : |
| 719 | - $session_data['init_access'] = absint( $value ); |
|
| 719 | + $session_data['init_access'] = absint($value); |
|
| 720 | 720 | break; |
| 721 | 721 | |
| 722 | 722 | case 'last_access' : |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | |
| 727 | 727 | case 'expiration' : |
| 728 | 728 | // when the session expires |
| 729 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
| 729 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
| 730 | 730 | ? $this->_expiration |
| 731 | 731 | : $session_data['init_access'] + $this->_lifespan; |
| 732 | 732 | break; |
@@ -738,11 +738,11 @@ discard block |
||
| 738 | 738 | |
| 739 | 739 | case 'pages_visited' : |
| 740 | 740 | $page_visit = $this->_get_page_visit(); |
| 741 | - if ( $page_visit ) { |
|
| 741 | + if ($page_visit) { |
|
| 742 | 742 | // set pages visited where the first will be the http referrer |
| 743 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
| 743 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
| 744 | 744 | // we'll only save the last 10 page visits. |
| 745 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
| 745 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
| 746 | 746 | } |
| 747 | 747 | break; |
| 748 | 748 | |
@@ -756,9 +756,9 @@ discard block |
||
| 756 | 756 | |
| 757 | 757 | $this->_session_data = $session_data; |
| 758 | 758 | // creating a new session does not require saving to the db just yet |
| 759 | - if ( ! $new_session ) { |
|
| 759 | + if ( ! $new_session) { |
|
| 760 | 760 | // ready? let's save |
| 761 | - if ( $this->_save_session_to_db() ) { |
|
| 761 | + if ($this->_save_session_to_db()) { |
|
| 762 | 762 | return TRUE; |
| 763 | 763 | } else { |
| 764 | 764 | return FALSE; |
@@ -778,9 +778,9 @@ discard block |
||
| 778 | 778 | * @throws \EE_Error |
| 779 | 779 | */ |
| 780 | 780 | private function _create_espresso_session( ) { |
| 781 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
| 781 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
| 782 | 782 | // use the update function for now with $new_session arg set to TRUE |
| 783 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
| 783 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | EE_Registry::instance()->REQ->front_ajax |
| 801 | 801 | || ( |
| 802 | 802 | // OR an admin request that is NOT AJAX |
| 803 | - ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
| 803 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
| 804 | 804 | && is_admin() |
| 805 | 805 | ) |
| 806 | 806 | || ( |
@@ -813,8 +813,8 @@ discard block |
||
| 813 | 813 | return false; |
| 814 | 814 | } |
| 815 | 815 | $transaction = $this->transaction(); |
| 816 | - if ( $transaction instanceof EE_Transaction ) { |
|
| 817 | - if ( ! $transaction->ID() ) { |
|
| 816 | + if ($transaction instanceof EE_Transaction) { |
|
| 817 | + if ( ! $transaction->ID()) { |
|
| 818 | 818 | $transaction->save(); |
| 819 | 819 | } |
| 820 | 820 | $this->_session_data['transaction'] = $transaction->ID(); |
@@ -823,19 +823,19 @@ discard block |
||
| 823 | 823 | $session_data = serialize($this->_session_data); |
| 824 | 824 | // do we need to also encode it to avoid corrupted data when saved to the db? |
| 825 | 825 | $session_data = $this->_use_encryption |
| 826 | - ? $this->encryption->base64_string_encode( $session_data ) |
|
| 826 | + ? $this->encryption->base64_string_encode($session_data) |
|
| 827 | 827 | : $session_data; |
| 828 | 828 | // maybe save hash check |
| 829 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
| 829 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
| 830 | 830 | $this->cache_storage->add( |
| 831 | - EE_Session::hash_check_prefix . $this->_sid, |
|
| 831 | + EE_Session::hash_check_prefix.$this->_sid, |
|
| 832 | 832 | md5($session_data), |
| 833 | 833 | $this->_lifespan |
| 834 | 834 | ); |
| 835 | 835 | } |
| 836 | 836 | // we're using the Transient API for storing session data, |
| 837 | 837 | return $this->cache_storage->add( |
| 838 | - EE_Session::session_id_prefix . $this->_sid, |
|
| 838 | + EE_Session::session_id_prefix.$this->_sid, |
|
| 839 | 839 | $session_data, |
| 840 | 840 | $this->_lifespan |
| 841 | 841 | ); |
@@ -864,10 +864,10 @@ discard block |
||
| 864 | 864 | 'HTTP_FORWARDED', |
| 865 | 865 | 'REMOTE_ADDR' |
| 866 | 866 | ); |
| 867 | - foreach ( $server_keys as $key ){ |
|
| 868 | - if ( isset( $_SERVER[ $key ] )) { |
|
| 869 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
| 870 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
| 867 | + foreach ($server_keys as $key) { |
|
| 868 | + if (isset($_SERVER[$key])) { |
|
| 869 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
| 870 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
| 871 | 871 | $visitor_ip = $ip; |
| 872 | 872 | } |
| 873 | 873 | } |
@@ -886,32 +886,32 @@ discard block |
||
| 886 | 886 | * @return string |
| 887 | 887 | */ |
| 888 | 888 | public function _get_page_visit() { |
| 889 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
| 889 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
| 890 | 890 | // check for request url |
| 891 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
| 891 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 892 | 892 | $http_host = ''; |
| 893 | 893 | $page_id = '?'; |
| 894 | 894 | $e_reg = ''; |
| 895 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
| 896 | - $ru_bits = explode( '?', $request_uri ); |
|
| 895 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
| 896 | + $ru_bits = explode('?', $request_uri); |
|
| 897 | 897 | $request_uri = $ru_bits[0]; |
| 898 | 898 | // check for and grab host as well |
| 899 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
| 900 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
| 899 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
| 900 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
| 901 | 901 | } |
| 902 | 902 | // check for page_id in SERVER REQUEST |
| 903 | - if ( isset( $_REQUEST['page_id'] )) { |
|
| 903 | + if (isset($_REQUEST['page_id'])) { |
|
| 904 | 904 | // rebuild $e_reg without any of the extra parameters |
| 905 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
| 905 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
| 906 | 906 | } |
| 907 | 907 | // check for $e_reg in SERVER REQUEST |
| 908 | - if ( isset( $_REQUEST['ee'] )) { |
|
| 908 | + if (isset($_REQUEST['ee'])) { |
|
| 909 | 909 | // rebuild $e_reg without any of the extra parameters |
| 910 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
| 910 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
| 911 | 911 | } |
| 912 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
| 912 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
| 913 | 913 | } |
| 914 | - return $page_visit !== home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
| 914 | + return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
| 915 | 915 | |
| 916 | 916 | } |
| 917 | 917 | |
@@ -941,14 +941,14 @@ discard block |
||
| 941 | 941 | * @return void |
| 942 | 942 | * @throws \EE_Error |
| 943 | 943 | */ |
| 944 | - public function clear_session( $class = '', $function = '' ) { |
|
| 944 | + public function clear_session($class = '', $function = '') { |
|
| 945 | 945 | //echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span> <b style="font-size:10px;"> ' . __LINE__ . ' </b></h3>'; |
| 946 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
| 946 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
| 947 | 947 | $this->reset_cart(); |
| 948 | 948 | $this->reset_checkout(); |
| 949 | 949 | $this->reset_transaction(); |
| 950 | 950 | // wipe out everything that isn't a default session datum |
| 951 | - $this->reset_data( array_keys( $this->_session_data )); |
|
| 951 | + $this->reset_data(array_keys($this->_session_data)); |
|
| 952 | 952 | // reset initial site access time and the session expiration |
| 953 | 953 | $this->_set_init_access_and_expiration(); |
| 954 | 954 | $this->_save_session_to_db(); |
@@ -963,42 +963,42 @@ discard block |
||
| 963 | 963 | * @param bool $show_all_notices |
| 964 | 964 | * @return TRUE on success, FALSE on fail |
| 965 | 965 | */ |
| 966 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
| 966 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
| 967 | 967 | // if $data_to_reset is not in an array, then put it in one |
| 968 | - if ( ! is_array( $data_to_reset ) ) { |
|
| 969 | - $data_to_reset = array ( $data_to_reset ); |
|
| 968 | + if ( ! is_array($data_to_reset)) { |
|
| 969 | + $data_to_reset = array($data_to_reset); |
|
| 970 | 970 | } |
| 971 | 971 | // nothing ??? go home! |
| 972 | - if ( empty( $data_to_reset )) { |
|
| 973 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 972 | + if (empty($data_to_reset)) { |
|
| 973 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 974 | 974 | return FALSE; |
| 975 | 975 | } |
| 976 | 976 | $return_value = TRUE; |
| 977 | 977 | // since $data_to_reset is an array, cycle through the values |
| 978 | - foreach ( $data_to_reset as $reset ) { |
|
| 978 | + foreach ($data_to_reset as $reset) { |
|
| 979 | 979 | |
| 980 | 980 | // first check to make sure it is a valid session var |
| 981 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
| 981 | + if (isset($this->_session_data[$reset])) { |
|
| 982 | 982 | // then check to make sure it is not a default var |
| 983 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
| 983 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
| 984 | 984 | // remove session var |
| 985 | - unset( $this->_session_data[ $reset ] ); |
|
| 986 | - if ( $show_all_notices ) { |
|
| 987 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 985 | + unset($this->_session_data[$reset]); |
|
| 986 | + if ($show_all_notices) { |
|
| 987 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
| 988 | 988 | } |
| 989 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
| 989 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
| 990 | 990 | |
| 991 | 991 | } else { |
| 992 | 992 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
| 993 | - if ( $show_all_notices ) { |
|
| 994 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 993 | + if ($show_all_notices) { |
|
| 994 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
| 995 | 995 | } |
| 996 | 996 | $return_value = FALSE; |
| 997 | 997 | } |
| 998 | 998 | |
| 999 | - } else if ( $show_all_notices ) { |
|
| 999 | + } else if ($show_all_notices) { |
|
| 1000 | 1000 | // oops! that session var does not exist! |
| 1001 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1001 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
| 1002 | 1002 | $return_value = FALSE; |
| 1003 | 1003 | } |
| 1004 | 1004 | |
@@ -1017,8 +1017,8 @@ discard block |
||
| 1017 | 1017 | * @throws \EE_Error |
| 1018 | 1018 | */ |
| 1019 | 1019 | public function wp_loaded() { |
| 1020 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
| 1021 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
| 1020 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
| 1021 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
| 1022 | 1022 | } |
| 1023 | 1023 | } |
| 1024 | 1024 | |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | // or use that for the new transient cleanup query limit |
| 1055 | 1055 | add_filter( |
| 1056 | 1056 | 'FHEE__TransientCacheStorage__clearExpiredTransients__limit', |
| 1057 | - function () use ($expired_session_transient_delete_query_limit) { |
|
| 1057 | + function() use ($expired_session_transient_delete_query_limit) { |
|
| 1058 | 1058 | return $expired_session_transient_delete_query_limit; |
| 1059 | 1059 | } |
| 1060 | 1060 | ); |
@@ -1068,34 +1068,34 @@ discard block |
||
| 1068 | 1068 | * @param $data1 |
| 1069 | 1069 | * @return string |
| 1070 | 1070 | */ |
| 1071 | - private function find_serialize_error( $data1 ) { |
|
| 1071 | + private function find_serialize_error($data1) { |
|
| 1072 | 1072 | $error = '<pre>'; |
| 1073 | 1073 | $data2 = preg_replace_callback( |
| 1074 | 1074 | '!s:(\d+):"(.*?)";!', |
| 1075 | - function ( $match ) { |
|
| 1076 | - return ( $match[1] === strlen( $match[2] ) ) |
|
| 1075 | + function($match) { |
|
| 1076 | + return ($match[1] === strlen($match[2])) |
|
| 1077 | 1077 | ? $match[0] |
| 1078 | 1078 | : 's:' |
| 1079 | - . strlen( $match[2] ) |
|
| 1079 | + . strlen($match[2]) |
|
| 1080 | 1080 | . ':"' |
| 1081 | 1081 | . $match[2] |
| 1082 | 1082 | . '";'; |
| 1083 | 1083 | }, |
| 1084 | 1084 | $data1 |
| 1085 | 1085 | ); |
| 1086 | - $max = ( strlen( $data1 ) > strlen( $data2 ) ) ? strlen( $data1 ) : strlen( $data2 ); |
|
| 1087 | - $error .= $data1 . PHP_EOL; |
|
| 1088 | - $error .= $data2 . PHP_EOL; |
|
| 1089 | - for ( $i = 0; $i < $max; $i++ ) { |
|
| 1090 | - if ( @$data1[ $i ] !== @$data2[ $i ] ) { |
|
| 1091 | - $error .= 'Difference ' . @$data1[ $i ] . ' != ' . @$data2[ $i ] . PHP_EOL; |
|
| 1092 | - $error .= "\t-> ORD number " . ord( @$data1[ $i ] ) . ' != ' . ord( @$data2[ $i ] ) . PHP_EOL; |
|
| 1093 | - $error .= "\t-> Line Number = $i" . PHP_EOL; |
|
| 1094 | - $start = ( $i - 20 ); |
|
| 1095 | - $start = ( $start < 0 ) ? 0 : $start; |
|
| 1086 | + $max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2); |
|
| 1087 | + $error .= $data1.PHP_EOL; |
|
| 1088 | + $error .= $data2.PHP_EOL; |
|
| 1089 | + for ($i = 0; $i < $max; $i++) { |
|
| 1090 | + if (@$data1[$i] !== @$data2[$i]) { |
|
| 1091 | + $error .= 'Difference '.@$data1[$i].' != '.@$data2[$i].PHP_EOL; |
|
| 1092 | + $error .= "\t-> ORD number ".ord(@$data1[$i]).' != '.ord(@$data2[$i]).PHP_EOL; |
|
| 1093 | + $error .= "\t-> Line Number = $i".PHP_EOL; |
|
| 1094 | + $start = ($i - 20); |
|
| 1095 | + $start = ($start < 0) ? 0 : $start; |
|
| 1096 | 1096 | $length = 40; |
| 1097 | 1097 | $point = $max - $i; |
| 1098 | - if ( $point < 20 ) { |
|
| 1098 | + if ($point < 20) { |
|
| 1099 | 1099 | $rlength = 1; |
| 1100 | 1100 | $rpoint = -$point; |
| 1101 | 1101 | } else { |
@@ -1104,16 +1104,16 @@ discard block |
||
| 1104 | 1104 | } |
| 1105 | 1105 | $error .= "\t-> Section Data1 = "; |
| 1106 | 1106 | $error .= substr_replace( |
| 1107 | - substr( $data1, $start, $length ), |
|
| 1108 | - "<b style=\"color:green\">{$data1[ $i ]}</b>", |
|
| 1107 | + substr($data1, $start, $length), |
|
| 1108 | + "<b style=\"color:green\">{$data1[$i]}</b>", |
|
| 1109 | 1109 | $rpoint, |
| 1110 | 1110 | $rlength |
| 1111 | 1111 | ); |
| 1112 | 1112 | $error .= PHP_EOL; |
| 1113 | 1113 | $error .= "\t-> Section Data2 = "; |
| 1114 | 1114 | $error .= substr_replace( |
| 1115 | - substr( $data2, $start, $length ), |
|
| 1116 | - "<b style=\"color:red\">{$data2[ $i ]}</b>", |
|
| 1115 | + substr($data2, $start, $length), |
|
| 1116 | + "<b style=\"color:red\">{$data2[$i]}</b>", |
|
| 1117 | 1117 | $rpoint, |
| 1118 | 1118 | $rlength |
| 1119 | 1119 | ); |
@@ -77,7 +77,7 @@ |
||
| 77 | 77 | extract($attributes, EXTR_OVERWRITE); |
| 78 | 78 | $event_id = isset($event_id) ? $event_id : 0; |
| 79 | 79 | $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
| 80 | - if (! $event instanceof EE_Event) { |
|
| 80 | + if ( ! $event instanceof EE_Event) { |
|
| 81 | 81 | new ExceptionStackTraceDisplay( |
| 82 | 82 | new InvalidArgumentException( |
| 83 | 83 | sprintf( |
@@ -24,82 +24,82 @@ |
||
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * the actual shortcode tag that gets registered with WordPress |
|
| 29 | - * |
|
| 30 | - * @return string |
|
| 31 | - */ |
|
| 32 | - public function getTag() |
|
| 33 | - { |
|
| 34 | - return 'ESPRESSO_TICKET_SELECTOR'; |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * the time in seconds to cache the results of the processShortcode() method |
|
| 41 | - * 0 means the processShortcode() results will NOT be cached at all |
|
| 42 | - * |
|
| 43 | - * @return int |
|
| 44 | - */ |
|
| 45 | - public function cacheExpiration() |
|
| 46 | - { |
|
| 47 | - return 0; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
| 53 | - * this may be required for shortcodes that utilize a corresponding module, |
|
| 54 | - * and need to enqueue assets for that module |
|
| 55 | - * |
|
| 56 | - * @return void |
|
| 57 | - */ |
|
| 58 | - public function initializeShortcode() |
|
| 59 | - { |
|
| 60 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 61 | - $this->shortcodeHasBeenInitialized(); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * callback that runs when the shortcode is encountered in post content. |
|
| 68 | - * IMPORTANT !!! |
|
| 69 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
| 70 | - * |
|
| 71 | - * @param array $attributes |
|
| 72 | - * @return string |
|
| 73 | - * @throws InvalidArgumentException |
|
| 74 | - */ |
|
| 75 | - public function processShortcode($attributes = array()) |
|
| 76 | - { |
|
| 77 | - extract($attributes, EXTR_OVERWRITE); |
|
| 78 | - $event_id = isset($event_id) ? $event_id : 0; |
|
| 79 | - $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
| 80 | - if (! $event instanceof EE_Event) { |
|
| 81 | - new ExceptionStackTraceDisplay( |
|
| 82 | - new InvalidArgumentException( |
|
| 83 | - sprintf( |
|
| 84 | - esc_html__( |
|
| 85 | - 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that it\'s value corresponds to a valid Event ID.', |
|
| 86 | - 'event_espresso' |
|
| 87 | - ), |
|
| 88 | - $this->getTag(), |
|
| 89 | - $event_id, |
|
| 90 | - 'event_id', |
|
| 91 | - '<br />' |
|
| 92 | - ) |
|
| 93 | - ) |
|
| 94 | - ); |
|
| 95 | - return ''; |
|
| 96 | - } |
|
| 97 | - ob_start(); |
|
| 98 | - do_action('AHEE_event_details_before_post', $event_id); |
|
| 99 | - espresso_ticket_selector($event); |
|
| 100 | - do_action('AHEE_event_details_after_post'); |
|
| 101 | - return ob_get_clean(); |
|
| 102 | - } |
|
| 27 | + /** |
|
| 28 | + * the actual shortcode tag that gets registered with WordPress |
|
| 29 | + * |
|
| 30 | + * @return string |
|
| 31 | + */ |
|
| 32 | + public function getTag() |
|
| 33 | + { |
|
| 34 | + return 'ESPRESSO_TICKET_SELECTOR'; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * the time in seconds to cache the results of the processShortcode() method |
|
| 41 | + * 0 means the processShortcode() results will NOT be cached at all |
|
| 42 | + * |
|
| 43 | + * @return int |
|
| 44 | + */ |
|
| 45 | + public function cacheExpiration() |
|
| 46 | + { |
|
| 47 | + return 0; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
| 53 | + * this may be required for shortcodes that utilize a corresponding module, |
|
| 54 | + * and need to enqueue assets for that module |
|
| 55 | + * |
|
| 56 | + * @return void |
|
| 57 | + */ |
|
| 58 | + public function initializeShortcode() |
|
| 59 | + { |
|
| 60 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 61 | + $this->shortcodeHasBeenInitialized(); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * callback that runs when the shortcode is encountered in post content. |
|
| 68 | + * IMPORTANT !!! |
|
| 69 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
| 70 | + * |
|
| 71 | + * @param array $attributes |
|
| 72 | + * @return string |
|
| 73 | + * @throws InvalidArgumentException |
|
| 74 | + */ |
|
| 75 | + public function processShortcode($attributes = array()) |
|
| 76 | + { |
|
| 77 | + extract($attributes, EXTR_OVERWRITE); |
|
| 78 | + $event_id = isset($event_id) ? $event_id : 0; |
|
| 79 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
| 80 | + if (! $event instanceof EE_Event) { |
|
| 81 | + new ExceptionStackTraceDisplay( |
|
| 82 | + new InvalidArgumentException( |
|
| 83 | + sprintf( |
|
| 84 | + esc_html__( |
|
| 85 | + 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that it\'s value corresponds to a valid Event ID.', |
|
| 86 | + 'event_espresso' |
|
| 87 | + ), |
|
| 88 | + $this->getTag(), |
|
| 89 | + $event_id, |
|
| 90 | + 'event_id', |
|
| 91 | + '<br />' |
|
| 92 | + ) |
|
| 93 | + ) |
|
| 94 | + ); |
|
| 95 | + return ''; |
|
| 96 | + } |
|
| 97 | + ob_start(); |
|
| 98 | + do_action('AHEE_event_details_before_post', $event_id); |
|
| 99 | + espresso_ticket_selector($event); |
|
| 100 | + do_action('AHEE_event_details_after_post'); |
|
| 101 | + return ob_get_clean(); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | } |
@@ -5,9 +5,9 @@ |
||
| 5 | 5 | interface SessionIdentifierInterface |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * @return string |
|
| 10 | - */ |
|
| 11 | - public function id(); |
|
| 8 | + /** |
|
| 9 | + * @return string |
|
| 10 | + */ |
|
| 11 | + public function id(); |
|
| 12 | 12 | |
| 13 | 13 | } |
| 14 | 14 | \ No newline at end of file |
@@ -199,13 +199,13 @@ discard block |
||
| 199 | 199 | ); |
| 200 | 200 | return CollectionLoader::ENTITY_ADDED; |
| 201 | 201 | } |
| 202 | - do_action( |
|
| 203 | - 'FHEE__CollectionLoader__addEntityToCollection__entity_not_added', |
|
| 204 | - $this, |
|
| 205 | - $this->collection_details->collectionName(), |
|
| 206 | - $this->collection_details |
|
| 207 | - ); |
|
| 208 | - return CollectionLoader::ENTITY_NOT_ADDED; |
|
| 202 | + do_action( |
|
| 203 | + 'FHEE__CollectionLoader__addEntityToCollection__entity_not_added', |
|
| 204 | + $this, |
|
| 205 | + $this->collection_details->collectionName(), |
|
| 206 | + $this->collection_details |
|
| 207 | + ); |
|
| 208 | + return CollectionLoader::ENTITY_NOT_ADDED; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -220,37 +220,37 @@ discard block |
||
| 220 | 220 | * @throws \EventEspresso\core\exceptions\InvalidEntityException |
| 221 | 221 | */ |
| 222 | 222 | protected function setIdentifier( $entity, $identifier ) { |
| 223 | - switch($this->collection_details->identifierType()) { |
|
| 224 | - // every unique object gets added to the collection, but not duplicates of the exact same object |
|
| 225 | - case CollectionDetails::ID_OBJECT_HASH : |
|
| 226 | - $identifier = spl_object_hash($entity); |
|
| 227 | - break; |
|
| 228 | - // only one entity per class can be added to collection, like a singleton |
|
| 229 | - case CollectionDetails::ID_CLASS_NAME : |
|
| 230 | - $identifier = get_class($entity); |
|
| 231 | - break; |
|
| 232 | - // objects added to the collection based on entity callback, so the entity itself decides |
|
| 233 | - case CollectionDetails::ID_CALLBACK_METHOD : |
|
| 234 | - $identifier_callback = $this->collection_details->identifierCallback(); |
|
| 235 | - if ( ! method_exists($entity, $identifier_callback)) { |
|
| 236 | - throw new InvalidEntityException( |
|
| 237 | - $entity, |
|
| 238 | - $this->collection_details->getCollectionInterface(), |
|
| 239 | - sprintf( |
|
| 240 | - __( |
|
| 241 | - 'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance |
|
| 223 | + switch($this->collection_details->identifierType()) { |
|
| 224 | + // every unique object gets added to the collection, but not duplicates of the exact same object |
|
| 225 | + case CollectionDetails::ID_OBJECT_HASH : |
|
| 226 | + $identifier = spl_object_hash($entity); |
|
| 227 | + break; |
|
| 228 | + // only one entity per class can be added to collection, like a singleton |
|
| 229 | + case CollectionDetails::ID_CLASS_NAME : |
|
| 230 | + $identifier = get_class($entity); |
|
| 231 | + break; |
|
| 232 | + // objects added to the collection based on entity callback, so the entity itself decides |
|
| 233 | + case CollectionDetails::ID_CALLBACK_METHOD : |
|
| 234 | + $identifier_callback = $this->collection_details->identifierCallback(); |
|
| 235 | + if ( ! method_exists($entity, $identifier_callback)) { |
|
| 236 | + throw new InvalidEntityException( |
|
| 237 | + $entity, |
|
| 238 | + $this->collection_details->getCollectionInterface(), |
|
| 239 | + sprintf( |
|
| 240 | + __( |
|
| 241 | + 'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance |
|
| 242 | 242 | of "%2$s", but does not contain this method.', |
| 243 | - 'event_espresso' |
|
| 244 | - ), |
|
| 245 | - $identifier_callback, |
|
| 246 | - get_class($entity) |
|
| 247 | - ) |
|
| 248 | - ); |
|
| 249 | - } |
|
| 250 | - $identifier = $entity->{$identifier_callback}(); |
|
| 251 | - break; |
|
| 252 | - |
|
| 253 | - } |
|
| 243 | + 'event_espresso' |
|
| 244 | + ), |
|
| 245 | + $identifier_callback, |
|
| 246 | + get_class($entity) |
|
| 247 | + ) |
|
| 248 | + ); |
|
| 249 | + } |
|
| 250 | + $identifier = $entity->{$identifier_callback}(); |
|
| 251 | + break; |
|
| 252 | + |
|
| 253 | + } |
|
| 254 | 254 | return apply_filters( |
| 255 | 255 | 'FHEE__CollectionLoader__addEntityToCollection__identifier', |
| 256 | 256 | $identifier, |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | // with these parameters |
| 141 | 141 | $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
| 142 | 142 | // then md5 the above to control it's length, add all of our prefixes, and truncate |
| 143 | - return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
| 143 | + return substr($this->cachePrefix().$id_prefix.'-'.md5($cache_id), 0, 182); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | return ' |
| 171 | 171 | <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;"> |
| 172 | 172 | <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px"> |
| 173 | - <b>' . $type . '</b><span style="color:#999"> : </span> |
|
| 174 | - <span>' . $cache_id . '</span> |
|
| 175 | - <span style="margin-left:2em;">' . __FILE__ . '</span> |
|
| 173 | + <b>' . $type.'</b><span style="color:#999"> : </span> |
|
| 174 | + <span>' . $cache_id.'</span> |
|
| 175 | + <span style="margin-left:2em;">' . __FILE__.'</span> |
|
| 176 | 176 | </p> |
| 177 | 177 | </div>'; |
| 178 | 178 | } |
@@ -19,140 +19,140 @@ discard block |
||
| 19 | 19 | class BasicCacheManager implements CacheManagerInterface |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @type string |
|
| 24 | - */ |
|
| 25 | - const CACHE_PREFIX = 'ee_cache_'; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var CacheStorageInterface $cache_storage |
|
| 30 | - */ |
|
| 31 | - private $cache_storage; |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * BasicCacheManager constructor. |
|
| 37 | - * |
|
| 38 | - * @param CacheStorageInterface $cache_storage [required] |
|
| 39 | - */ |
|
| 40 | - public function __construct(CacheStorageInterface $cache_storage) |
|
| 41 | - { |
|
| 42 | - $this->cache_storage = $cache_storage; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * returns a string that will be prepended to all cache identifiers |
|
| 49 | - * |
|
| 50 | - * @return string |
|
| 51 | - */ |
|
| 52 | - public function cachePrefix() |
|
| 53 | - { |
|
| 54 | - return BasicCacheManager::CACHE_PREFIX; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @param string $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types. |
|
| 61 | - * May also be helpful to include an additional specific identifier, |
|
| 62 | - * such as a post ID as part of the $id_prefix so that individual caches |
|
| 63 | - * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
| 64 | - * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
| 65 | - * @param string $cache_id [required] Additional identifying details that make this cache unique. |
|
| 66 | - * It is advisable to use some of the actual data |
|
| 67 | - * that is used to generate the content being cached, |
|
| 68 | - * in order to guarantee that the cache id is unique for that content. |
|
| 69 | - * The cache id will be md5'd before usage to make it more db friendly, |
|
| 70 | - * and the entire cache id string will be truncated to 190 characters. |
|
| 71 | - * @param Closure $callback [required] since the point of caching is to avoid generating content when not |
|
| 72 | - * necessary, |
|
| 73 | - * we wrap our content creation in a Closure so that it is not executed until needed. |
|
| 74 | - * @param int $expiration |
|
| 75 | - * @return Closure|mixed |
|
| 76 | - */ |
|
| 77 | - public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS) |
|
| 78 | - { |
|
| 79 | - $content = ''; |
|
| 80 | - $expiration = absint( |
|
| 81 | - apply_filters( |
|
| 82 | - 'FHEE__CacheManager__get__cache_expiration', |
|
| 83 | - $expiration, |
|
| 84 | - $id_prefix, |
|
| 85 | - $cache_id |
|
| 86 | - ) |
|
| 87 | - ); |
|
| 88 | - $cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id); |
|
| 89 | - // is caching enabled for this content ? |
|
| 90 | - if ($expiration) { |
|
| 91 | - $content = $this->cache_storage->get($cache_id); |
|
| 92 | - } |
|
| 93 | - // any existing content ? |
|
| 94 | - if (empty($content)) { |
|
| 95 | - // nope! let's generate some new stuff |
|
| 96 | - $content = $callback(); |
|
| 97 | - // save the new content if caching is enabled |
|
| 98 | - if ($expiration) { |
|
| 99 | - $this->cache_storage->add($cache_id, $content, $expiration); |
|
| 100 | - if (EE_DEBUG) { |
|
| 101 | - $content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE'); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - } else { |
|
| 105 | - if (EE_DEBUG) { |
|
| 106 | - $content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT'); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - return $content; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Generates a unique identifier string for the cache |
|
| 116 | - * |
|
| 117 | - * @param string $id_prefix [required] see BasicCacheManager::get() |
|
| 118 | - * @param string $cache_id [required] see BasicCacheManager::get() |
|
| 119 | - * @return string |
|
| 120 | - */ |
|
| 121 | - private function generateCacheIdentifier($id_prefix, $cache_id) |
|
| 122 | - { |
|
| 123 | - // let's make the cached content unique for this "page" |
|
| 124 | - $cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL); |
|
| 125 | - // with these parameters |
|
| 126 | - $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
|
| 127 | - // then md5 the above to control it's length, add all of our prefixes, and truncate |
|
| 128 | - return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
| 135 | - * or a specific ID targeting a single cache item |
|
| 136 | - * @return void |
|
| 137 | - */ |
|
| 138 | - public function clear($cache_id) |
|
| 139 | - { |
|
| 140 | - // ensure incoming arg is in an array |
|
| 141 | - $cache_id = is_array($cache_id) ? $cache_id : array($cache_id); |
|
| 142 | - // delete corresponding transients for the supplied id prefix |
|
| 143 | - $this->cache_storage->deleteMany($cache_id); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
| 150 | - * or a specific ID targeting a single cache item |
|
| 151 | - * @param string $type |
|
| 152 | - * @return string |
|
| 153 | - */ |
|
| 154 | - private function displayCacheNotice($cache_id, $type) { |
|
| 155 | - return ' |
|
| 22 | + /** |
|
| 23 | + * @type string |
|
| 24 | + */ |
|
| 25 | + const CACHE_PREFIX = 'ee_cache_'; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var CacheStorageInterface $cache_storage |
|
| 30 | + */ |
|
| 31 | + private $cache_storage; |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * BasicCacheManager constructor. |
|
| 37 | + * |
|
| 38 | + * @param CacheStorageInterface $cache_storage [required] |
|
| 39 | + */ |
|
| 40 | + public function __construct(CacheStorageInterface $cache_storage) |
|
| 41 | + { |
|
| 42 | + $this->cache_storage = $cache_storage; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * returns a string that will be prepended to all cache identifiers |
|
| 49 | + * |
|
| 50 | + * @return string |
|
| 51 | + */ |
|
| 52 | + public function cachePrefix() |
|
| 53 | + { |
|
| 54 | + return BasicCacheManager::CACHE_PREFIX; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @param string $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types. |
|
| 61 | + * May also be helpful to include an additional specific identifier, |
|
| 62 | + * such as a post ID as part of the $id_prefix so that individual caches |
|
| 63 | + * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
| 64 | + * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
| 65 | + * @param string $cache_id [required] Additional identifying details that make this cache unique. |
|
| 66 | + * It is advisable to use some of the actual data |
|
| 67 | + * that is used to generate the content being cached, |
|
| 68 | + * in order to guarantee that the cache id is unique for that content. |
|
| 69 | + * The cache id will be md5'd before usage to make it more db friendly, |
|
| 70 | + * and the entire cache id string will be truncated to 190 characters. |
|
| 71 | + * @param Closure $callback [required] since the point of caching is to avoid generating content when not |
|
| 72 | + * necessary, |
|
| 73 | + * we wrap our content creation in a Closure so that it is not executed until needed. |
|
| 74 | + * @param int $expiration |
|
| 75 | + * @return Closure|mixed |
|
| 76 | + */ |
|
| 77 | + public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS) |
|
| 78 | + { |
|
| 79 | + $content = ''; |
|
| 80 | + $expiration = absint( |
|
| 81 | + apply_filters( |
|
| 82 | + 'FHEE__CacheManager__get__cache_expiration', |
|
| 83 | + $expiration, |
|
| 84 | + $id_prefix, |
|
| 85 | + $cache_id |
|
| 86 | + ) |
|
| 87 | + ); |
|
| 88 | + $cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id); |
|
| 89 | + // is caching enabled for this content ? |
|
| 90 | + if ($expiration) { |
|
| 91 | + $content = $this->cache_storage->get($cache_id); |
|
| 92 | + } |
|
| 93 | + // any existing content ? |
|
| 94 | + if (empty($content)) { |
|
| 95 | + // nope! let's generate some new stuff |
|
| 96 | + $content = $callback(); |
|
| 97 | + // save the new content if caching is enabled |
|
| 98 | + if ($expiration) { |
|
| 99 | + $this->cache_storage->add($cache_id, $content, $expiration); |
|
| 100 | + if (EE_DEBUG) { |
|
| 101 | + $content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE'); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + } else { |
|
| 105 | + if (EE_DEBUG) { |
|
| 106 | + $content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT'); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + return $content; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Generates a unique identifier string for the cache |
|
| 116 | + * |
|
| 117 | + * @param string $id_prefix [required] see BasicCacheManager::get() |
|
| 118 | + * @param string $cache_id [required] see BasicCacheManager::get() |
|
| 119 | + * @return string |
|
| 120 | + */ |
|
| 121 | + private function generateCacheIdentifier($id_prefix, $cache_id) |
|
| 122 | + { |
|
| 123 | + // let's make the cached content unique for this "page" |
|
| 124 | + $cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL); |
|
| 125 | + // with these parameters |
|
| 126 | + $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
|
| 127 | + // then md5 the above to control it's length, add all of our prefixes, and truncate |
|
| 128 | + return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
| 135 | + * or a specific ID targeting a single cache item |
|
| 136 | + * @return void |
|
| 137 | + */ |
|
| 138 | + public function clear($cache_id) |
|
| 139 | + { |
|
| 140 | + // ensure incoming arg is in an array |
|
| 141 | + $cache_id = is_array($cache_id) ? $cache_id : array($cache_id); |
|
| 142 | + // delete corresponding transients for the supplied id prefix |
|
| 143 | + $this->cache_storage->deleteMany($cache_id); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
| 150 | + * or a specific ID targeting a single cache item |
|
| 151 | + * @param string $type |
|
| 152 | + * @return string |
|
| 153 | + */ |
|
| 154 | + private function displayCacheNotice($cache_id, $type) { |
|
| 155 | + return ' |
|
| 156 | 156 | <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;"> |
| 157 | 157 | <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px"> |
| 158 | 158 | <b>' . $type . '</b><span style="color:#999"> : </span> |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | <span style="margin-left:2em;">' . __FILE__ . '</span> |
| 161 | 161 | </p> |
| 162 | 162 | </div>'; |
| 163 | - } |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | // End of file BasicCacheManager.php |
@@ -21,219 +21,219 @@ |
||
| 21 | 21 | abstract class EspressoShortcode implements ShortcodeInterface |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * transient prefix |
|
| 26 | - * |
|
| 27 | - * @type string |
|
| 28 | - */ |
|
| 29 | - const CACHE_TRANSIENT_PREFIX = 'ee_sc_'; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var PostRelatedCacheManager $cache_manager |
|
| 33 | - */ |
|
| 34 | - private $cache_manager; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * true if ShortcodeInterface::initializeShortcode() has been called |
|
| 38 | - * if false, then that will get called before processing |
|
| 39 | - * |
|
| 40 | - * @var boolean $initialized |
|
| 41 | - */ |
|
| 42 | - private $initialized = false; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * EspressoShortcode constructor |
|
| 48 | - * |
|
| 49 | - * @param PostRelatedCacheManager $cache_manager |
|
| 50 | - */ |
|
| 51 | - public function __construct(PostRelatedCacheManager $cache_manager) |
|
| 52 | - { |
|
| 53 | - $this->cache_manager = $cache_manager; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @return void |
|
| 60 | - */ |
|
| 61 | - public function shortcodeHasBeenInitialized() |
|
| 62 | - { |
|
| 63 | - $this->initialized = true; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * enqueues scripts then processes the shortcode |
|
| 70 | - * |
|
| 71 | - * @param array $attributes |
|
| 72 | - * @return string |
|
| 73 | - * @throws EE_Error |
|
| 74 | - */ |
|
| 75 | - final public function processShortcodeCallback($attributes = array()) |
|
| 76 | - { |
|
| 77 | - if ($this instanceof EnqueueAssetsInterface) { |
|
| 78 | - if (is_admin()) { |
|
| 79 | - $this->enqueueAdminScripts(); |
|
| 80 | - } else { |
|
| 81 | - $this->enqueueScripts(); |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - return $this->shortcodeContent( |
|
| 85 | - $this->sanitizeAttributes((array)$attributes) |
|
| 86 | - ); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * If shortcode caching is enabled for the shortcode, |
|
| 93 | - * and cached results exist, then that will be returned |
|
| 94 | - * else new content will be generated. |
|
| 95 | - * If caching is enabled, then the new content will be cached for later. |
|
| 96 | - * |
|
| 97 | - * @param array $attributes |
|
| 98 | - * @return mixed|string |
|
| 99 | - * @throws EE_Error |
|
| 100 | - */ |
|
| 101 | - private function shortcodeContent(array $attributes) |
|
| 102 | - { |
|
| 103 | - $shortcode = $this; |
|
| 104 | - $post_ID = $this->currentPostID(); |
|
| 105 | - // something like "SC_EVENTS-123" |
|
| 106 | - $cache_ID = $this->shortcodeCacheID($post_ID); |
|
| 107 | - $this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID); |
|
| 108 | - return $this->cache_manager->get( |
|
| 109 | - $cache_ID, |
|
| 110 | - // serialized attributes |
|
| 111 | - wp_json_encode($attributes), |
|
| 112 | - // Closure for generating content if cache is expired |
|
| 113 | - function () use ($shortcode, $attributes) { |
|
| 114 | - if($shortcode->initialized === false){ |
|
| 115 | - $shortcode->initializeShortcode(); |
|
| 116 | - } |
|
| 117 | - return $shortcode->processShortcode($attributes); |
|
| 118 | - }, |
|
| 119 | - // filterable cache expiration set by each shortcode |
|
| 120 | - apply_filters( |
|
| 121 | - 'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration', |
|
| 122 | - $this->cacheExpiration(), |
|
| 123 | - $this->getTag(), |
|
| 124 | - $this |
|
| 125 | - ) |
|
| 126 | - ); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @return int |
|
| 133 | - * @throws EE_Error |
|
| 134 | - */ |
|
| 135 | - private function currentPostID() |
|
| 136 | - { |
|
| 137 | - // try to get EE_Event any way we can |
|
| 138 | - $event = EEH_Event_View::get_event(); |
|
| 139 | - // then get some kind of ID |
|
| 140 | - if ($event instanceof \EE_Event) { |
|
| 141 | - $post_ID = $event->ID(); |
|
| 142 | - } else { |
|
| 143 | - global $post; |
|
| 144 | - $post_ID = $post->ID; |
|
| 145 | - } |
|
| 146 | - return $post_ID; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * @param int $post_ID |
|
| 153 | - * @return string |
|
| 154 | - * @throws EE_Error |
|
| 155 | - */ |
|
| 156 | - private function shortcodeCacheID($post_ID) |
|
| 157 | - { |
|
| 158 | - $tag = str_replace('ESPRESSO_', '', $this->getTag()); |
|
| 159 | - return "SC_{$tag}-{$post_ID}"; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * array for defining custom attribute sanitization callbacks, |
|
| 166 | - * where keys match keys in your attributes array, |
|
| 167 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
| 168 | - * So for example, if you had an integer attribute named "event_id" |
|
| 169 | - * that you wanted to be sanitized using absint(), |
|
| 170 | - * then you would return the following: |
|
| 171 | - * array('event_id' => 'absint') |
|
| 172 | - * Entering 'skip_sanitization' for the callback value |
|
| 173 | - * means that no sanitization will be applied |
|
| 174 | - * on the assumption that the attribute |
|
| 175 | - * will be sanitized at some point... right? |
|
| 176 | - * You wouldn't pass around unsanitized attributes would you? |
|
| 177 | - * That would be very Tom Foolery of you!!! |
|
| 178 | - * |
|
| 179 | - * @return array |
|
| 180 | - */ |
|
| 181 | - protected function customAttributeSanitizationMap() |
|
| 182 | - { |
|
| 183 | - return array(); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Performs basic sanitization on shortcode attributes |
|
| 190 | - * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
| 191 | - * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
| 192 | - * This can be overridden using the customAttributeSanitizationMap() method (see above), |
|
| 193 | - * all other attributes would be sanitized using the defaults in the switch statement below |
|
| 194 | - * |
|
| 195 | - * @param array $attributes |
|
| 196 | - * @return array |
|
| 197 | - */ |
|
| 198 | - private function sanitizeAttributes(array $attributes) |
|
| 199 | - { |
|
| 200 | - $custom_sanitization = $this->customAttributeSanitizationMap(); |
|
| 201 | - foreach ($attributes as $key => $value) { |
|
| 202 | - // is a custom sanitization callback specified ? |
|
| 203 | - if (isset($custom_sanitization[$key])) { |
|
| 204 | - $callback = $custom_sanitization[$key]; |
|
| 205 | - if ($callback === 'skip_sanitization') { |
|
| 206 | - $attributes[$key] = $value; |
|
| 207 | - continue; |
|
| 208 | - } |
|
| 209 | - if (function_exists($callback)) { |
|
| 210 | - $attributes[$key] = $callback($value); |
|
| 211 | - continue; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - switch (true) { |
|
| 215 | - case $value === null : |
|
| 216 | - case is_int($value) : |
|
| 217 | - case is_float($value) : |
|
| 218 | - // typical booleans |
|
| 219 | - case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) : |
|
| 220 | - $attributes[$key] = $value; |
|
| 221 | - break; |
|
| 222 | - case is_string($value) : |
|
| 223 | - $attributes[$key] = sanitize_text_field($value); |
|
| 224 | - break; |
|
| 225 | - case is_array($value) : |
|
| 226 | - $attributes[$key] = $this->sanitizeAttributes($value); |
|
| 227 | - break; |
|
| 228 | - default : |
|
| 229 | - // only remaining data types are Object and Resource |
|
| 230 | - // which are not allowed as shortcode attributes |
|
| 231 | - $attributes[$key] = null; |
|
| 232 | - break; |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - return $attributes; |
|
| 236 | - } |
|
| 24 | + /** |
|
| 25 | + * transient prefix |
|
| 26 | + * |
|
| 27 | + * @type string |
|
| 28 | + */ |
|
| 29 | + const CACHE_TRANSIENT_PREFIX = 'ee_sc_'; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var PostRelatedCacheManager $cache_manager |
|
| 33 | + */ |
|
| 34 | + private $cache_manager; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * true if ShortcodeInterface::initializeShortcode() has been called |
|
| 38 | + * if false, then that will get called before processing |
|
| 39 | + * |
|
| 40 | + * @var boolean $initialized |
|
| 41 | + */ |
|
| 42 | + private $initialized = false; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * EspressoShortcode constructor |
|
| 48 | + * |
|
| 49 | + * @param PostRelatedCacheManager $cache_manager |
|
| 50 | + */ |
|
| 51 | + public function __construct(PostRelatedCacheManager $cache_manager) |
|
| 52 | + { |
|
| 53 | + $this->cache_manager = $cache_manager; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @return void |
|
| 60 | + */ |
|
| 61 | + public function shortcodeHasBeenInitialized() |
|
| 62 | + { |
|
| 63 | + $this->initialized = true; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * enqueues scripts then processes the shortcode |
|
| 70 | + * |
|
| 71 | + * @param array $attributes |
|
| 72 | + * @return string |
|
| 73 | + * @throws EE_Error |
|
| 74 | + */ |
|
| 75 | + final public function processShortcodeCallback($attributes = array()) |
|
| 76 | + { |
|
| 77 | + if ($this instanceof EnqueueAssetsInterface) { |
|
| 78 | + if (is_admin()) { |
|
| 79 | + $this->enqueueAdminScripts(); |
|
| 80 | + } else { |
|
| 81 | + $this->enqueueScripts(); |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + return $this->shortcodeContent( |
|
| 85 | + $this->sanitizeAttributes((array)$attributes) |
|
| 86 | + ); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * If shortcode caching is enabled for the shortcode, |
|
| 93 | + * and cached results exist, then that will be returned |
|
| 94 | + * else new content will be generated. |
|
| 95 | + * If caching is enabled, then the new content will be cached for later. |
|
| 96 | + * |
|
| 97 | + * @param array $attributes |
|
| 98 | + * @return mixed|string |
|
| 99 | + * @throws EE_Error |
|
| 100 | + */ |
|
| 101 | + private function shortcodeContent(array $attributes) |
|
| 102 | + { |
|
| 103 | + $shortcode = $this; |
|
| 104 | + $post_ID = $this->currentPostID(); |
|
| 105 | + // something like "SC_EVENTS-123" |
|
| 106 | + $cache_ID = $this->shortcodeCacheID($post_ID); |
|
| 107 | + $this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID); |
|
| 108 | + return $this->cache_manager->get( |
|
| 109 | + $cache_ID, |
|
| 110 | + // serialized attributes |
|
| 111 | + wp_json_encode($attributes), |
|
| 112 | + // Closure for generating content if cache is expired |
|
| 113 | + function () use ($shortcode, $attributes) { |
|
| 114 | + if($shortcode->initialized === false){ |
|
| 115 | + $shortcode->initializeShortcode(); |
|
| 116 | + } |
|
| 117 | + return $shortcode->processShortcode($attributes); |
|
| 118 | + }, |
|
| 119 | + // filterable cache expiration set by each shortcode |
|
| 120 | + apply_filters( |
|
| 121 | + 'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration', |
|
| 122 | + $this->cacheExpiration(), |
|
| 123 | + $this->getTag(), |
|
| 124 | + $this |
|
| 125 | + ) |
|
| 126 | + ); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @return int |
|
| 133 | + * @throws EE_Error |
|
| 134 | + */ |
|
| 135 | + private function currentPostID() |
|
| 136 | + { |
|
| 137 | + // try to get EE_Event any way we can |
|
| 138 | + $event = EEH_Event_View::get_event(); |
|
| 139 | + // then get some kind of ID |
|
| 140 | + if ($event instanceof \EE_Event) { |
|
| 141 | + $post_ID = $event->ID(); |
|
| 142 | + } else { |
|
| 143 | + global $post; |
|
| 144 | + $post_ID = $post->ID; |
|
| 145 | + } |
|
| 146 | + return $post_ID; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * @param int $post_ID |
|
| 153 | + * @return string |
|
| 154 | + * @throws EE_Error |
|
| 155 | + */ |
|
| 156 | + private function shortcodeCacheID($post_ID) |
|
| 157 | + { |
|
| 158 | + $tag = str_replace('ESPRESSO_', '', $this->getTag()); |
|
| 159 | + return "SC_{$tag}-{$post_ID}"; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * array for defining custom attribute sanitization callbacks, |
|
| 166 | + * where keys match keys in your attributes array, |
|
| 167 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
| 168 | + * So for example, if you had an integer attribute named "event_id" |
|
| 169 | + * that you wanted to be sanitized using absint(), |
|
| 170 | + * then you would return the following: |
|
| 171 | + * array('event_id' => 'absint') |
|
| 172 | + * Entering 'skip_sanitization' for the callback value |
|
| 173 | + * means that no sanitization will be applied |
|
| 174 | + * on the assumption that the attribute |
|
| 175 | + * will be sanitized at some point... right? |
|
| 176 | + * You wouldn't pass around unsanitized attributes would you? |
|
| 177 | + * That would be very Tom Foolery of you!!! |
|
| 178 | + * |
|
| 179 | + * @return array |
|
| 180 | + */ |
|
| 181 | + protected function customAttributeSanitizationMap() |
|
| 182 | + { |
|
| 183 | + return array(); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Performs basic sanitization on shortcode attributes |
|
| 190 | + * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
| 191 | + * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
| 192 | + * This can be overridden using the customAttributeSanitizationMap() method (see above), |
|
| 193 | + * all other attributes would be sanitized using the defaults in the switch statement below |
|
| 194 | + * |
|
| 195 | + * @param array $attributes |
|
| 196 | + * @return array |
|
| 197 | + */ |
|
| 198 | + private function sanitizeAttributes(array $attributes) |
|
| 199 | + { |
|
| 200 | + $custom_sanitization = $this->customAttributeSanitizationMap(); |
|
| 201 | + foreach ($attributes as $key => $value) { |
|
| 202 | + // is a custom sanitization callback specified ? |
|
| 203 | + if (isset($custom_sanitization[$key])) { |
|
| 204 | + $callback = $custom_sanitization[$key]; |
|
| 205 | + if ($callback === 'skip_sanitization') { |
|
| 206 | + $attributes[$key] = $value; |
|
| 207 | + continue; |
|
| 208 | + } |
|
| 209 | + if (function_exists($callback)) { |
|
| 210 | + $attributes[$key] = $callback($value); |
|
| 211 | + continue; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + switch (true) { |
|
| 215 | + case $value === null : |
|
| 216 | + case is_int($value) : |
|
| 217 | + case is_float($value) : |
|
| 218 | + // typical booleans |
|
| 219 | + case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) : |
|
| 220 | + $attributes[$key] = $value; |
|
| 221 | + break; |
|
| 222 | + case is_string($value) : |
|
| 223 | + $attributes[$key] = sanitize_text_field($value); |
|
| 224 | + break; |
|
| 225 | + case is_array($value) : |
|
| 226 | + $attributes[$key] = $this->sanitizeAttributes($value); |
|
| 227 | + break; |
|
| 228 | + default : |
|
| 229 | + // only remaining data types are Object and Resource |
|
| 230 | + // which are not allowed as shortcode attributes |
|
| 231 | + $attributes[$key] = null; |
|
| 232 | + break; |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + return $attributes; |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | |
@@ -10,15 +10,15 @@ discard block |
||
| 10 | 10 | class EES_Espresso_Events extends EES_Shortcode { |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * @deprecated 4.9.27 |
|
| 14 | - * @return void |
|
| 13 | + * @deprecated 4.9.27 |
|
| 14 | + * @return void |
|
| 15 | 15 | */ |
| 16 | 16 | public static function set_hooks() { |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * @deprecated 4.9.27 |
|
| 21 | - * @return void |
|
| 20 | + * @deprecated 4.9.27 |
|
| 21 | + * @return void |
|
| 22 | 22 | */ |
| 23 | 23 | public static function set_hooks_admin() { |
| 24 | 24 | } |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * @deprecated 4.9.27 |
|
| 30 | - * @param WP $WP |
|
| 29 | + * @deprecated 4.9.27 |
|
| 30 | + * @param WP $WP |
|
| 31 | 31 | * @return void |
| 32 | 32 | */ |
| 33 | 33 | public function run( WP $WP ) { |
@@ -36,21 +36,21 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * @deprecated 4.9.27 |
|
| 40 | - * @param array $attributes |
|
| 39 | + * @deprecated 4.9.27 |
|
| 40 | + * @param array $attributes |
|
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | 43 | public function process_shortcode( $attributes = array() ) { |
| 44 | - \EE_Error::doing_it_wrong( |
|
| 45 | - __METHOD__, |
|
| 46 | - __( |
|
| 47 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEvents instead.', |
|
| 48 | - 'event_espresso' |
|
| 49 | - ), |
|
| 50 | - '4.9.27' |
|
| 51 | - ); |
|
| 52 | - return ''; |
|
| 53 | - } |
|
| 44 | + \EE_Error::doing_it_wrong( |
|
| 45 | + __METHOD__, |
|
| 46 | + __( |
|
| 47 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEvents instead.', |
|
| 48 | + 'event_espresso' |
|
| 49 | + ), |
|
| 50 | + '4.9.27' |
|
| 51 | + ); |
|
| 52 | + return ''; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | use EventEspresso\core\services\loaders\LoaderInterface; |
| 5 | 5 | |
| 6 | 6 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 7 | - exit('No direct script access allowed'); |
|
| 7 | + exit('No direct script access allowed'); |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | |
@@ -24,228 +24,228 @@ discard block |
||
| 24 | 24 | class EE_Load_Espresso_Core implements EEI_Request_Decorator, EEI_Request_Stack_Core_App |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @type LoaderInterface $loader |
|
| 29 | - */ |
|
| 30 | - protected $loader; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @var EE_Request $request |
|
| 34 | - */ |
|
| 35 | - protected $request; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @var EE_Response $response |
|
| 39 | - */ |
|
| 40 | - protected $response; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var EE_Dependency_Map $dependency_map |
|
| 44 | - */ |
|
| 45 | - protected $dependency_map; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var EE_Registry $registry |
|
| 49 | - */ |
|
| 50 | - protected $registry; |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * EE_Load_Espresso_Core constructor |
|
| 56 | - */ |
|
| 57 | - public function __construct() |
|
| 58 | - { |
|
| 59 | - espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php'); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * handle |
|
| 66 | - * sets hooks for running rest of system |
|
| 67 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 68 | - * starting EE Addons from any other point may lead to problems |
|
| 69 | - * |
|
| 70 | - * @param EE_Request $request |
|
| 71 | - * @param EE_Response $response |
|
| 72 | - * @return EE_Response |
|
| 73 | - * @throws EE_Error |
|
| 74 | - * @throws InvalidDataTypeException |
|
| 75 | - * @throws InvalidInterfaceException |
|
| 76 | - * @throws InvalidArgumentException |
|
| 77 | - */ |
|
| 78 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
| 79 | - { |
|
| 80 | - $this->request = $request; |
|
| 81 | - $this->response = $response; |
|
| 82 | - // info about how to load classes required by other classes |
|
| 83 | - $this->dependency_map = $this->_load_dependency_map(); |
|
| 84 | - // central repository for classes |
|
| 85 | - $this->registry = $this->_load_registry(); |
|
| 86 | - // PSR4 Autoloaders |
|
| 87 | - $this->registry->load_core('EE_Psr4AutoloaderInit'); |
|
| 88 | - do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
| 89 | - $this->loader = $this->registry->create('EventEspresso\core\services\loaders\Loader'); |
|
| 90 | - $this->dependency_map->setLoader($this->loader); |
|
| 91 | - // build DI container |
|
| 92 | - $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
| 93 | - $OpenCoffeeShop->addRecipes(); |
|
| 94 | - // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
| 95 | - // create and cache the CommandBus, and also add middleware |
|
| 96 | - $this->registry->create( |
|
| 97 | - 'CommandBusInterface', |
|
| 98 | - array( |
|
| 99 | - null, |
|
| 100 | - apply_filters( |
|
| 101 | - 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
| 102 | - array( |
|
| 103 | - $this->registry->create('CapChecker'), |
|
| 104 | - $this->registry->create('AddActionHook'), |
|
| 105 | - ) |
|
| 106 | - ), |
|
| 107 | - ), |
|
| 108 | - true |
|
| 109 | - ); |
|
| 110 | - // workarounds for PHP < 5.3 |
|
| 111 | - $this->_load_class_tools(); |
|
| 112 | - // load interfaces |
|
| 113 | - espresso_load_required('EEI_Payment_Method_Interfaces', |
|
| 114 | - EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php'); |
|
| 115 | - // deprecated functions |
|
| 116 | - espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
| 117 | - // WP cron jobs |
|
| 118 | - $this->registry->load_core('Cron_Tasks'); |
|
| 119 | - $this->registry->load_core('EE_Request_Handler'); |
|
| 120 | - $this->registry->load_core('EE_System'); |
|
| 121 | - return $this->response; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * @return EE_Request |
|
| 128 | - */ |
|
| 129 | - public function request() |
|
| 130 | - { |
|
| 131 | - return $this->request; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * @return EE_Response |
|
| 138 | - */ |
|
| 139 | - public function response() |
|
| 140 | - { |
|
| 141 | - return $this->response; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @return EE_Dependency_Map |
|
| 148 | - * @throws EE_Error |
|
| 149 | - */ |
|
| 150 | - public function dependency_map() |
|
| 151 | - { |
|
| 152 | - if (! $this->dependency_map instanceof EE_Dependency_Map) { |
|
| 153 | - throw new EE_Error( |
|
| 154 | - sprintf( |
|
| 155 | - __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
| 156 | - print_r($this->dependency_map, true) |
|
| 157 | - ) |
|
| 158 | - ); |
|
| 159 | - } |
|
| 160 | - return $this->dependency_map; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * @return EE_Registry |
|
| 167 | - * @throws EE_Error |
|
| 168 | - */ |
|
| 169 | - public function registry() |
|
| 170 | - { |
|
| 171 | - if (! $this->registry instanceof EE_Registry) { |
|
| 172 | - throw new EE_Error( |
|
| 173 | - sprintf( |
|
| 174 | - __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
| 175 | - print_r($this->registry, true) |
|
| 176 | - ) |
|
| 177 | - ); |
|
| 178 | - } |
|
| 179 | - return $this->registry; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * @return EE_Dependency_Map |
|
| 186 | - */ |
|
| 187 | - private function _load_dependency_map() |
|
| 188 | - { |
|
| 189 | - if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) { |
|
| 190 | - EE_Error::add_error( |
|
| 191 | - __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
| 192 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 193 | - ); |
|
| 194 | - wp_die(EE_Error::get_notices()); |
|
| 195 | - } |
|
| 196 | - require_once(EE_CORE . 'EE_Dependency_Map.core.php'); |
|
| 197 | - return EE_Dependency_Map::instance($this->request, $this->response); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * @return EE_Registry |
|
| 204 | - */ |
|
| 205 | - private function _load_registry() |
|
| 206 | - { |
|
| 207 | - if (! is_readable(EE_CORE . 'EE_Registry.core.php')) { |
|
| 208 | - EE_Error::add_error( |
|
| 209 | - __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
| 210 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 211 | - ); |
|
| 212 | - wp_die(EE_Error::get_notices()); |
|
| 213 | - } |
|
| 214 | - require_once(EE_CORE . 'EE_Registry.core.php'); |
|
| 215 | - return EE_Registry::instance($this->dependency_map); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * @return void |
|
| 222 | - */ |
|
| 223 | - private function _load_class_tools() |
|
| 224 | - { |
|
| 225 | - if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) { |
|
| 226 | - EE_Error::add_error( |
|
| 227 | - __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
| 228 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 229 | - ); |
|
| 230 | - } |
|
| 231 | - require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * called after the request stack has been fully processed |
|
| 238 | - * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
| 239 | - * |
|
| 240 | - * @param EE_Request $request |
|
| 241 | - * @param EE_Response $response |
|
| 242 | - */ |
|
| 243 | - public function handle_response(EE_Request $request, EE_Response $response) |
|
| 244 | - { |
|
| 245 | - if ($response->plugin_deactivated()) { |
|
| 246 | - espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
| 247 | - } |
|
| 248 | - } |
|
| 27 | + /** |
|
| 28 | + * @type LoaderInterface $loader |
|
| 29 | + */ |
|
| 30 | + protected $loader; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @var EE_Request $request |
|
| 34 | + */ |
|
| 35 | + protected $request; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @var EE_Response $response |
|
| 39 | + */ |
|
| 40 | + protected $response; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var EE_Dependency_Map $dependency_map |
|
| 44 | + */ |
|
| 45 | + protected $dependency_map; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var EE_Registry $registry |
|
| 49 | + */ |
|
| 50 | + protected $registry; |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * EE_Load_Espresso_Core constructor |
|
| 56 | + */ |
|
| 57 | + public function __construct() |
|
| 58 | + { |
|
| 59 | + espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php'); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * handle |
|
| 66 | + * sets hooks for running rest of system |
|
| 67 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 68 | + * starting EE Addons from any other point may lead to problems |
|
| 69 | + * |
|
| 70 | + * @param EE_Request $request |
|
| 71 | + * @param EE_Response $response |
|
| 72 | + * @return EE_Response |
|
| 73 | + * @throws EE_Error |
|
| 74 | + * @throws InvalidDataTypeException |
|
| 75 | + * @throws InvalidInterfaceException |
|
| 76 | + * @throws InvalidArgumentException |
|
| 77 | + */ |
|
| 78 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
| 79 | + { |
|
| 80 | + $this->request = $request; |
|
| 81 | + $this->response = $response; |
|
| 82 | + // info about how to load classes required by other classes |
|
| 83 | + $this->dependency_map = $this->_load_dependency_map(); |
|
| 84 | + // central repository for classes |
|
| 85 | + $this->registry = $this->_load_registry(); |
|
| 86 | + // PSR4 Autoloaders |
|
| 87 | + $this->registry->load_core('EE_Psr4AutoloaderInit'); |
|
| 88 | + do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
| 89 | + $this->loader = $this->registry->create('EventEspresso\core\services\loaders\Loader'); |
|
| 90 | + $this->dependency_map->setLoader($this->loader); |
|
| 91 | + // build DI container |
|
| 92 | + $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
| 93 | + $OpenCoffeeShop->addRecipes(); |
|
| 94 | + // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
| 95 | + // create and cache the CommandBus, and also add middleware |
|
| 96 | + $this->registry->create( |
|
| 97 | + 'CommandBusInterface', |
|
| 98 | + array( |
|
| 99 | + null, |
|
| 100 | + apply_filters( |
|
| 101 | + 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
| 102 | + array( |
|
| 103 | + $this->registry->create('CapChecker'), |
|
| 104 | + $this->registry->create('AddActionHook'), |
|
| 105 | + ) |
|
| 106 | + ), |
|
| 107 | + ), |
|
| 108 | + true |
|
| 109 | + ); |
|
| 110 | + // workarounds for PHP < 5.3 |
|
| 111 | + $this->_load_class_tools(); |
|
| 112 | + // load interfaces |
|
| 113 | + espresso_load_required('EEI_Payment_Method_Interfaces', |
|
| 114 | + EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php'); |
|
| 115 | + // deprecated functions |
|
| 116 | + espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
| 117 | + // WP cron jobs |
|
| 118 | + $this->registry->load_core('Cron_Tasks'); |
|
| 119 | + $this->registry->load_core('EE_Request_Handler'); |
|
| 120 | + $this->registry->load_core('EE_System'); |
|
| 121 | + return $this->response; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * @return EE_Request |
|
| 128 | + */ |
|
| 129 | + public function request() |
|
| 130 | + { |
|
| 131 | + return $this->request; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * @return EE_Response |
|
| 138 | + */ |
|
| 139 | + public function response() |
|
| 140 | + { |
|
| 141 | + return $this->response; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @return EE_Dependency_Map |
|
| 148 | + * @throws EE_Error |
|
| 149 | + */ |
|
| 150 | + public function dependency_map() |
|
| 151 | + { |
|
| 152 | + if (! $this->dependency_map instanceof EE_Dependency_Map) { |
|
| 153 | + throw new EE_Error( |
|
| 154 | + sprintf( |
|
| 155 | + __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
| 156 | + print_r($this->dependency_map, true) |
|
| 157 | + ) |
|
| 158 | + ); |
|
| 159 | + } |
|
| 160 | + return $this->dependency_map; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * @return EE_Registry |
|
| 167 | + * @throws EE_Error |
|
| 168 | + */ |
|
| 169 | + public function registry() |
|
| 170 | + { |
|
| 171 | + if (! $this->registry instanceof EE_Registry) { |
|
| 172 | + throw new EE_Error( |
|
| 173 | + sprintf( |
|
| 174 | + __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
| 175 | + print_r($this->registry, true) |
|
| 176 | + ) |
|
| 177 | + ); |
|
| 178 | + } |
|
| 179 | + return $this->registry; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * @return EE_Dependency_Map |
|
| 186 | + */ |
|
| 187 | + private function _load_dependency_map() |
|
| 188 | + { |
|
| 189 | + if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) { |
|
| 190 | + EE_Error::add_error( |
|
| 191 | + __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
| 192 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 193 | + ); |
|
| 194 | + wp_die(EE_Error::get_notices()); |
|
| 195 | + } |
|
| 196 | + require_once(EE_CORE . 'EE_Dependency_Map.core.php'); |
|
| 197 | + return EE_Dependency_Map::instance($this->request, $this->response); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * @return EE_Registry |
|
| 204 | + */ |
|
| 205 | + private function _load_registry() |
|
| 206 | + { |
|
| 207 | + if (! is_readable(EE_CORE . 'EE_Registry.core.php')) { |
|
| 208 | + EE_Error::add_error( |
|
| 209 | + __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
| 210 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 211 | + ); |
|
| 212 | + wp_die(EE_Error::get_notices()); |
|
| 213 | + } |
|
| 214 | + require_once(EE_CORE . 'EE_Registry.core.php'); |
|
| 215 | + return EE_Registry::instance($this->dependency_map); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * @return void |
|
| 222 | + */ |
|
| 223 | + private function _load_class_tools() |
|
| 224 | + { |
|
| 225 | + if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) { |
|
| 226 | + EE_Error::add_error( |
|
| 227 | + __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
| 228 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 229 | + ); |
|
| 230 | + } |
|
| 231 | + require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * called after the request stack has been fully processed |
|
| 238 | + * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
| 239 | + * |
|
| 240 | + * @param EE_Request $request |
|
| 241 | + * @param EE_Response $response |
|
| 242 | + */ |
|
| 243 | + public function handle_response(EE_Request $request, EE_Response $response) |
|
| 244 | + { |
|
| 245 | + if ($response->plugin_deactivated()) { |
|
| 246 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | |
@@ -6,24 +6,33 @@ discard block |
||
| 6 | 6 | <?php if ( $disabled ) : ?> |
| 7 | 7 | <input type="hidden" id="edit-ticket-TKT_start_date-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" > |
| 8 | 8 | <input type="text" name="archived_ticket[TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" disabled> |
| 9 | - <?php else : ?> |
|
| 10 | - <input id="edit-ticket-TKT_start_date-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp ee-datepicker" value="<?php echo $TKT_start_date; ?>" data-context="start-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_end_date" data-next-field=".edit-ticket-TKT_end_date"> |
|
| 9 | + <?php else { |
|
| 10 | + : ?> |
|
| 11 | + <input id="edit-ticket-TKT_start_date-<?php echo $tkt_row; |
|
| 12 | +} |
|
| 13 | +?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp ee-datepicker" value="<?php echo $TKT_start_date; ?>" data-context="start-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_end_date" data-next-field=".edit-ticket-TKT_end_date"> |
|
| 11 | 14 | <?php endif; ?> |
| 12 | 15 | </td> |
| 13 | 16 | <td> |
| 14 | 17 | <?php if ( $disabled ) : ?> |
| 15 | 18 | <input type="hidden" id="edit-ticket-TKT_end_date-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" > |
| 16 | 19 | <input type="text" name="archived_ticket[TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" disabled> |
| 17 | - <?php else : ?> |
|
| 18 | - <input id="edit-ticket-TKT_end_date-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp ee-datepicker" value="<?php echo $TKT_end_date; ?>" data-context="end-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_start_date" data-next-field=".edit-ticket-TKT_qty"> |
|
| 20 | + <?php else { |
|
| 21 | + : ?> |
|
| 22 | + <input id="edit-ticket-TKT_end_date-<?php echo $tkt_row; |
|
| 23 | +} |
|
| 24 | +?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp ee-datepicker" value="<?php echo $TKT_end_date; ?>" data-context="end-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_start_date" data-next-field=".edit-ticket-TKT_qty"> |
|
| 19 | 25 | <?php endif; ?> |
| 20 | 26 | </td> |
| 21 | 27 | <td> |
| 22 | 28 | <?php if ( $disabled ) : ?> |
| 23 | 29 | <input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; ?>" type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>"> |
| 24 | 30 | <input type="text" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>" disabled> |
| 25 | - <?php else : ?> |
|
| 26 | - <input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>"> |
|
| 31 | + <?php else { |
|
| 32 | + : ?> |
|
| 33 | + <input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; |
|
| 34 | +} |
|
| 35 | +?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>"> |
|
| 27 | 36 | <?php endif; ?> |
| 28 | 37 | <input type="hidden" id="edit-ticket-TKT_base_price_ID-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price_ID]" value="<?php echo $TKT_base_price_ID; ?>"> |
| 29 | 38 | </td> |
@@ -31,8 +40,11 @@ discard block |
||
| 31 | 40 | <?php if ( $disabled ) : ?> |
| 32 | 41 | <input type="hidden" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>"> |
| 33 | 42 | <input type="text" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>" disabled> |
| 34 | - <?php else : ?> |
|
| 35 | - <input type="text" id="edit-ticket-TKT_qty-<?php echo $tkt_row; ?>" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>"> |
|
| 43 | + <?php else { |
|
| 44 | + : ?> |
|
| 45 | + <input type="text" id="edit-ticket-TKT_qty-<?php echo $tkt_row; |
|
| 46 | +} |
|
| 47 | +?>" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>"> |
|
| 36 | 48 | <?php endif; ?> |
| 37 | 49 | </td> |
| 38 | 50 | <!--<td><span class="ticket-display-row-TKT_price"><?php //echo $TKT_price; ?></span></td>--> |
@@ -78,24 +90,33 @@ discard block |
||
| 78 | 90 | <?php if ( $disabled ) : ?> |
| 79 | 91 | <input type="hidden" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>"> |
| 80 | 92 | <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>" disabled> |
| 81 | - <?php else : ?> |
|
| 82 | - <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>"> |
|
| 93 | + <?php else { |
|
| 94 | + : ?> |
|
| 95 | + <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; |
|
| 96 | +} |
|
| 97 | +?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>"> |
|
| 83 | 98 | <?php endif; ?> |
| 84 | 99 | </td> |
| 85 | 100 | <td> |
| 86 | 101 | <?php if ( $disabled ) : ?> |
| 87 | 102 | <input type="hidden" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>"> |
| 88 | 103 | <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>" disabled> |
| 89 | - <?php else: ?> |
|
| 90 | - <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>"> |
|
| 104 | + <?php else { |
|
| 105 | + : ?> |
|
| 106 | + <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; |
|
| 107 | +} |
|
| 108 | +?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>"> |
|
| 91 | 109 | <?php endif; ?> |
| 92 | 110 | </td> |
| 93 | 111 | <td> |
| 94 | 112 | <?php if ( $disabled ) : ?> |
| 95 | 113 | <input type="hidden" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>"> |
| 96 | 114 | <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>" disabled> |
| 97 | - <?php else : ?> |
|
| 98 | - <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>"> |
|
| 115 | + <?php else { |
|
| 116 | + : ?> |
|
| 117 | + <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; |
|
| 118 | +} |
|
| 119 | +?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>"> |
|
| 99 | 120 | <?php endif; ?> |
| 100 | 121 | </td> |
| 101 | 122 | </tr> |
@@ -116,8 +137,11 @@ discard block |
||
| 116 | 137 | ?> |
| 117 | 138 | <input class="TKT-taxable-checkbox" type="hidden" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="<?php echo $tax_value; ?>"> |
| 118 | 139 | <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?> disabled> |
| 119 | - <?php else : ?> |
|
| 120 | - <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>> |
|
| 140 | + <?php else { |
|
| 141 | + : ?> |
|
| 142 | + <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; |
|
| 143 | +} |
|
| 144 | +?>" type="checkbox" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>> |
|
| 121 | 145 | <?php endif; ?> |
| 122 | 146 | <label for="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>"> <?php esc_html_e('This ticket is taxable.', 'event_espresso'); ?> |
| 123 | 147 | <?php } //end tax_rows check ?> |