@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | * set session data |
| 365 | 365 | * @access public |
| 366 | 366 | * @param array $data |
| 367 | - * @return TRUE on success, FALSE on fail |
|
| 367 | + * @return boolean on success, FALSE on fail |
|
| 368 | 368 | */ |
| 369 | 369 | public function set_session_data( $data ) { |
| 370 | 370 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | /** |
| 393 | 393 | * @initiate session |
| 394 | 394 | * @access private |
| 395 | - * @return TRUE on success, FALSE on fail |
|
| 395 | + * @return boolean on success, FALSE on fail |
|
| 396 | 396 | * @throws \EE_Error |
| 397 | 397 | */ |
| 398 | 398 | private function _espresso_session() { |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | * @update session data prior to saving to the db |
| 532 | 532 | * @access public |
| 533 | 533 | * @param bool $new_session |
| 534 | - * @return TRUE on success, FALSE on fail |
|
| 534 | + * @return boolean on success, FALSE on fail |
|
| 535 | 535 | */ |
| 536 | 536 | public function update( $new_session = FALSE ) { |
| 537 | 537 | $this->_session_data = isset( $this->_session_data ) |
@@ -797,7 +797,7 @@ discard block |
||
| 797 | 797 | * @access public |
| 798 | 798 | * @param array $data_to_reset |
| 799 | 799 | * @param bool $show_all_notices |
| 800 | - * @return TRUE on success, FALSE on fail |
|
| 800 | + * @return boolean on success, FALSE on fail |
|
| 801 | 801 | */ |
| 802 | 802 | public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
| 803 | 803 | // if $data_to_reset is not in an array, then put it in one |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\exceptions\InvalidSessionDataException; |
| 2 | 2 | |
| 3 | -if (!defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
| 4 | 4 | /** |
| 5 | 5 | * |
| 6 | 6 | * EE_Session class |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * array for defining default session vars |
| 92 | 92 | * @var array |
| 93 | 93 | */ |
| 94 | - private $_default_session_vars = array ( |
|
| 94 | + private $_default_session_vars = array( |
|
| 95 | 95 | 'id' => NULL, |
| 96 | 96 | 'user_id' => NULL, |
| 97 | 97 | 'ip_address' => NULL, |
@@ -111,12 +111,12 @@ discard block |
||
| 111 | 111 | * @throws InvalidSessionDataException |
| 112 | 112 | * @throws \EE_Error |
| 113 | 113 | */ |
| 114 | - public static function instance( EE_Encryption $encryption = null ) { |
|
| 114 | + public static function instance(EE_Encryption $encryption = null) { |
|
| 115 | 115 | // check if class object is instantiated |
| 116 | 116 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: |
| 117 | 117 | // add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
| 118 | - if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
| 119 | - self::$_instance = new self( $encryption ); |
|
| 118 | + if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) { |
|
| 119 | + self::$_instance = new self($encryption); |
|
| 120 | 120 | } |
| 121 | 121 | return self::$_instance; |
| 122 | 122 | } |
@@ -132,15 +132,15 @@ discard block |
||
| 132 | 132 | * @throws \EE_Error |
| 133 | 133 | * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
| 134 | 134 | */ |
| 135 | - protected function __construct( EE_Encryption $encryption = null ) { |
|
| 135 | + protected function __construct(EE_Encryption $encryption = null) { |
|
| 136 | 136 | |
| 137 | 137 | // 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' ); |
| 138 | - if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) { |
|
| 138 | + if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) { |
|
| 139 | 139 | return; |
| 140 | 140 | } |
| 141 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 142 | - if ( ! defined( 'ESPRESSO_SESSION' ) ) { |
|
| 143 | - define( 'ESPRESSO_SESSION', true ); |
|
| 141 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 142 | + if ( ! defined('ESPRESSO_SESSION')) { |
|
| 143 | + define('ESPRESSO_SESSION', true); |
|
| 144 | 144 | } |
| 145 | 145 | // default session lifespan in seconds |
| 146 | 146 | $this->_lifespan = apply_filters( |
@@ -154,12 +154,12 @@ discard block |
||
| 154 | 154 | * } |
| 155 | 155 | */ |
| 156 | 156 | // retrieve session options from db |
| 157 | - $session_settings = (array) get_option( 'ee_session_settings', array() ); |
|
| 158 | - if ( ! empty( $session_settings )) { |
|
| 157 | + $session_settings = (array) get_option('ee_session_settings', array()); |
|
| 158 | + if ( ! empty($session_settings)) { |
|
| 159 | 159 | // cycle though existing session options |
| 160 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
| 160 | + foreach ($session_settings as $var_name => $session_setting) { |
|
| 161 | 161 | // set values for class properties |
| 162 | - $var_name = '_' . $var_name; |
|
| 162 | + $var_name = '_'.$var_name; |
|
| 163 | 163 | $this->{$var_name} = $session_setting; |
| 164 | 164 | } |
| 165 | 165 | } |
@@ -169,16 +169,16 @@ discard block |
||
| 169 | 169 | // encrypt data via: $this->encryption->encrypt(); |
| 170 | 170 | $this->encryption = $encryption; |
| 171 | 171 | // filter hook allows outside functions/classes/plugins to change default empty cart |
| 172 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
| 173 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
| 172 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
| 173 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
| 174 | 174 | // apply default session vars |
| 175 | 175 | $this->_set_defaults(); |
| 176 | 176 | add_action('AHEE__EE_System__initialize', array($this, 'open_session')); |
| 177 | 177 | // check request for 'clear_session' param |
| 178 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
| 178 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
| 179 | 179 | // once everything is all said and done, |
| 180 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
| 181 | - add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 ); |
|
| 180 | + add_action('shutdown', array($this, 'update'), 100); |
|
| 181 | + add_action('shutdown', array($this, 'garbage_collection'), 999); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
@@ -223,11 +223,11 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | private function _set_defaults() { |
| 225 | 225 | // set some defaults |
| 226 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
| 227 | - if ( is_array( $default_var )) { |
|
| 228 | - $this->_session_data[ $key ] = array(); |
|
| 226 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
| 227 | + if (is_array($default_var)) { |
|
| 228 | + $this->_session_data[$key] = array(); |
|
| 229 | 229 | } else { |
| 230 | - $this->_session_data[ $key ] = ''; |
|
| 230 | + $this->_session_data[$key] = ''; |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @param \EE_Cart $cart |
| 250 | 250 | * @return bool |
| 251 | 251 | */ |
| 252 | - public function set_cart( EE_Cart $cart ) { |
|
| 252 | + public function set_cart(EE_Cart $cart) { |
|
| 253 | 253 | $this->_session_data['cart'] = $cart; |
| 254 | 254 | return TRUE; |
| 255 | 255 | } |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * @return \EE_Cart |
| 270 | 270 | */ |
| 271 | 271 | public function cart() { |
| 272 | - return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL; |
|
| 272 | + return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @param \EE_Checkout $checkout |
| 279 | 279 | * @return bool |
| 280 | 280 | */ |
| 281 | - public function set_checkout( EE_Checkout $checkout ) { |
|
| 281 | + public function set_checkout(EE_Checkout $checkout) { |
|
| 282 | 282 | $this->_session_data['checkout'] = $checkout; |
| 283 | 283 | return TRUE; |
| 284 | 284 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * @return \EE_Checkout |
| 299 | 299 | */ |
| 300 | 300 | public function checkout() { |
| 301 | - return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL; |
|
| 301 | + return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | * @return bool |
| 309 | 309 | * @throws \EE_Error |
| 310 | 310 | */ |
| 311 | - public function set_transaction( EE_Transaction $transaction ) { |
|
| 311 | + public function set_transaction(EE_Transaction $transaction) { |
|
| 312 | 312 | // first remove the session from the transaction before we save the transaction in the session |
| 313 | - $transaction->set_txn_session_data( NULL ); |
|
| 313 | + $transaction->set_txn_session_data(NULL); |
|
| 314 | 314 | $this->_session_data['transaction'] = $transaction; |
| 315 | 315 | return TRUE; |
| 316 | 316 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * @return \EE_Transaction |
| 331 | 331 | */ |
| 332 | 332 | public function transaction() { |
| 333 | - return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL; |
|
| 333 | + return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | |
@@ -342,15 +342,15 @@ discard block |
||
| 342 | 342 | * @param bool $reset_cache |
| 343 | 343 | * @return array |
| 344 | 344 | */ |
| 345 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
| 346 | - if ( $reset_cache ) { |
|
| 345 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
| 346 | + if ($reset_cache) { |
|
| 347 | 347 | $this->reset_cart(); |
| 348 | 348 | $this->reset_checkout(); |
| 349 | 349 | $this->reset_transaction(); |
| 350 | 350 | } |
| 351 | - if ( ! empty( $key )) { |
|
| 352 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
| 353 | - } else { |
|
| 351 | + if ( ! empty($key)) { |
|
| 352 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
| 353 | + } else { |
|
| 354 | 354 | return $this->_session_data; |
| 355 | 355 | } |
| 356 | 356 | } |
@@ -363,20 +363,20 @@ discard block |
||
| 363 | 363 | * @param array $data |
| 364 | 364 | * @return TRUE on success, FALSE on fail |
| 365 | 365 | */ |
| 366 | - public function set_session_data( $data ) { |
|
| 366 | + public function set_session_data($data) { |
|
| 367 | 367 | |
| 368 | 368 | // nothing ??? bad data ??? go home! |
| 369 | - if ( empty( $data ) || ! is_array( $data )) { |
|
| 370 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 369 | + if (empty($data) || ! is_array($data)) { |
|
| 370 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 371 | 371 | return FALSE; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - foreach ( $data as $key =>$value ) { |
|
| 375 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
| 376 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 374 | + foreach ($data as $key =>$value) { |
|
| 375 | + if (isset($this->_default_session_vars[$key])) { |
|
| 376 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
| 377 | 377 | return FALSE; |
| 378 | 378 | } else { |
| 379 | - $this->_session_data[ $key ] = $value; |
|
| 379 | + $this->_session_data[$key] = $value; |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | |
@@ -394,9 +394,9 @@ discard block |
||
| 394 | 394 | * @throws \EE_Error |
| 395 | 395 | */ |
| 396 | 396 | private function _espresso_session() { |
| 397 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 397 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 398 | 398 | // check that session has started |
| 399 | - if ( session_id() === '' ) { |
|
| 399 | + if (session_id() === '') { |
|
| 400 | 400 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
| 401 | 401 | session_start(); |
| 402 | 402 | } |
@@ -405,38 +405,38 @@ discard block |
||
| 405 | 405 | // and the visitors IP |
| 406 | 406 | $this->_ip_address = $this->_visitor_ip(); |
| 407 | 407 | // set the "user agent" |
| 408 | - $this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
| 408 | + $this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
| 409 | 409 | // now let's retrieve what's in the db |
| 410 | 410 | $session_data = $this->_retrieve_session_data(); |
| 411 | - if (! empty($session_data)) { |
|
| 411 | + if ( ! empty($session_data)) { |
|
| 412 | 412 | // get the current time in UTC |
| 413 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
| 413 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
| 414 | 414 | // and reset the session expiration |
| 415 | - $this->_expiration = isset( $session_data['expiration'] ) |
|
| 415 | + $this->_expiration = isset($session_data['expiration']) |
|
| 416 | 416 | ? $session_data['expiration'] |
| 417 | 417 | : $this->_time + $this->_lifespan; |
| 418 | 418 | } else { |
| 419 | 419 | // set initial site access time and the session expiration |
| 420 | 420 | $this->_set_init_access_and_expiration(); |
| 421 | 421 | // set referer |
| 422 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) |
|
| 423 | - ? esc_attr( $_SERVER['HTTP_REFERER'] ) |
|
| 422 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) |
|
| 423 | + ? esc_attr($_SERVER['HTTP_REFERER']) |
|
| 424 | 424 | : ''; |
| 425 | 425 | // no previous session = go back and create one (on top of the data above) |
| 426 | 426 | return FALSE; |
| 427 | 427 | } |
| 428 | 428 | // now the user agent |
| 429 | - if ( $session_data['user_agent'] !== $this->_user_agent ) { |
|
| 429 | + if ($session_data['user_agent'] !== $this->_user_agent) { |
|
| 430 | 430 | return FALSE; |
| 431 | 431 | } |
| 432 | 432 | // wait a minute... how old are you? |
| 433 | - if ( $this->_time > $this->_expiration ) { |
|
| 433 | + if ($this->_time > $this->_expiration) { |
|
| 434 | 434 | // yer too old fer me! |
| 435 | 435 | // wipe out everything that isn't a default session datum |
| 436 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
| 436 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
| 437 | 437 | } |
| 438 | 438 | // make event espresso session data available to plugin |
| 439 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
| 439 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
| 440 | 440 | return TRUE; |
| 441 | 441 | |
| 442 | 442 | } |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | protected function _retrieve_session_data() |
| 454 | 454 | { |
| 455 | - $ssn_key = EE_Session::session_id_prefix . $this->_sid; |
|
| 455 | + $ssn_key = EE_Session::session_id_prefix.$this->_sid; |
|
| 456 | 456 | try { |
| 457 | 457 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
| 458 | 458 | $session_data = get_transient($ssn_key); |
@@ -460,12 +460,12 @@ discard block |
||
| 460 | 460 | return array(); |
| 461 | 461 | } |
| 462 | 462 | if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
| 463 | - $hash_check = get_transient(EE_Session::hash_check_prefix . $this->_sid); |
|
| 463 | + $hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid); |
|
| 464 | 464 | if ($hash_check && $hash_check !== md5($session_data)) { |
| 465 | 465 | EE_Error::add_error( |
| 466 | 466 | sprintf( |
| 467 | 467 | __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'), |
| 468 | - EE_Session::session_id_prefix . $this->_sid |
|
| 468 | + EE_Session::session_id_prefix.$this->_sid |
|
| 469 | 469 | ), |
| 470 | 470 | __FILE__, __FUNCTION__, __LINE__ |
| 471 | 471 | ); |
@@ -477,17 +477,17 @@ discard block |
||
| 477 | 477 | $row = $wpdb->get_row( |
| 478 | 478 | $wpdb->prepare( |
| 479 | 479 | "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1", |
| 480 | - '_transient_' . $ssn_key |
|
| 480 | + '_transient_'.$ssn_key |
|
| 481 | 481 | ) |
| 482 | 482 | ); |
| 483 | 483 | $session_data = is_object($row) ? $row->option_value : null; |
| 484 | 484 | if ($session_data) { |
| 485 | 485 | $session_data = preg_replace_callback( |
| 486 | 486 | '!s:(d+):"(.*?)";!', |
| 487 | - function ($match) { |
|
| 487 | + function($match) { |
|
| 488 | 488 | return $match[1] === strlen($match[2]) |
| 489 | 489 | ? $match[0] |
| 490 | - : 's:' . strlen($match[2]) . ':"' . $match[2] . '";'; |
|
| 490 | + : 's:'.strlen($match[2]).':"'.$match[2].'";'; |
|
| 491 | 491 | }, |
| 492 | 492 | $session_data |
| 493 | 493 | ); |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | 'event_espresso' |
| 509 | 509 | ); |
| 510 | 510 | $msg .= WP_DEBUG |
| 511 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
| 511 | + ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data) |
|
| 512 | 512 | : ''; |
| 513 | 513 | throw new InvalidSessionDataException($msg, 0, $e); |
| 514 | 514 | } |
@@ -521,11 +521,11 @@ discard block |
||
| 521 | 521 | 'event_espresso' |
| 522 | 522 | ); |
| 523 | 523 | $msg .= WP_DEBUG |
| 524 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
| 524 | + ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data) |
|
| 525 | 525 | : ''; |
| 526 | 526 | throw new InvalidSessionDataException($msg); |
| 527 | 527 | } |
| 528 | - if ( isset( $this->_session_data['transaction'] ) && absint( $this->_session_data['transaction'] ) !== 0 ) { |
|
| 528 | + if (isset($this->_session_data['transaction']) && absint($this->_session_data['transaction']) !== 0) { |
|
| 529 | 529 | $this->_session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID( |
| 530 | 530 | $this->_session_data['transaction'] |
| 531 | 531 | ); |
@@ -546,12 +546,12 @@ discard block |
||
| 546 | 546 | */ |
| 547 | 547 | protected function _generate_session_id() { |
| 548 | 548 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
| 549 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
| 550 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
| 549 | + if (isset($_REQUEST['EESID'])) { |
|
| 550 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
| 551 | 551 | } else { |
| 552 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
| 552 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
| 553 | 553 | } |
| 554 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
| 554 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | |
@@ -563,20 +563,20 @@ discard block |
||
| 563 | 563 | */ |
| 564 | 564 | protected function _get_sid_salt() { |
| 565 | 565 | // was session id salt already saved to db ? |
| 566 | - if ( empty( $this->_sid_salt ) ) { |
|
| 566 | + if (empty($this->_sid_salt)) { |
|
| 567 | 567 | // no? then maybe use WP defined constant |
| 568 | - if ( defined( 'AUTH_SALT' ) ) { |
|
| 568 | + if (defined('AUTH_SALT')) { |
|
| 569 | 569 | $this->_sid_salt = AUTH_SALT; |
| 570 | 570 | } |
| 571 | 571 | // if salt doesn't exist or is too short |
| 572 | - if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) { |
|
| 572 | + if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) { |
|
| 573 | 573 | // create a new one |
| 574 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
| 574 | + $this->_sid_salt = wp_generate_password(64); |
|
| 575 | 575 | } |
| 576 | 576 | // and save it as a permanent session setting |
| 577 | - $session_settings = get_option( 'ee_session_settings' ); |
|
| 578 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
| 579 | - update_option( 'ee_session_settings', $session_settings ); |
|
| 577 | + $session_settings = get_option('ee_session_settings'); |
|
| 578 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
| 579 | + update_option('ee_session_settings', $session_settings); |
|
| 580 | 580 | } |
| 581 | 581 | return $this->_sid_salt; |
| 582 | 582 | } |
@@ -604,19 +604,19 @@ discard block |
||
| 604 | 604 | * @param bool $new_session |
| 605 | 605 | * @return TRUE on success, FALSE on fail |
| 606 | 606 | */ |
| 607 | - public function update( $new_session = FALSE ) { |
|
| 608 | - $this->_session_data = isset( $this->_session_data ) |
|
| 609 | - && is_array( $this->_session_data ) |
|
| 610 | - && isset( $this->_session_data['id']) |
|
| 607 | + public function update($new_session = FALSE) { |
|
| 608 | + $this->_session_data = isset($this->_session_data) |
|
| 609 | + && is_array($this->_session_data) |
|
| 610 | + && isset($this->_session_data['id']) |
|
| 611 | 611 | ? $this->_session_data |
| 612 | 612 | : array(); |
| 613 | - if ( empty( $this->_session_data )) { |
|
| 613 | + if (empty($this->_session_data)) { |
|
| 614 | 614 | $this->_set_defaults(); |
| 615 | 615 | } |
| 616 | 616 | $session_data = array(); |
| 617 | - foreach ( $this->_session_data as $key => $value ) { |
|
| 617 | + foreach ($this->_session_data as $key => $value) { |
|
| 618 | 618 | |
| 619 | - switch( $key ) { |
|
| 619 | + switch ($key) { |
|
| 620 | 620 | |
| 621 | 621 | case 'id' : |
| 622 | 622 | // session ID |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | break; |
| 635 | 635 | |
| 636 | 636 | case 'init_access' : |
| 637 | - $session_data['init_access'] = absint( $value ); |
|
| 637 | + $session_data['init_access'] = absint($value); |
|
| 638 | 638 | break; |
| 639 | 639 | |
| 640 | 640 | case 'last_access' : |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | |
| 645 | 645 | case 'expiration' : |
| 646 | 646 | // when the session expires |
| 647 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
| 647 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
| 648 | 648 | ? $this->_expiration |
| 649 | 649 | : $session_data['init_access'] + $this->_lifespan; |
| 650 | 650 | break; |
@@ -656,11 +656,11 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | case 'pages_visited' : |
| 658 | 658 | $page_visit = $this->_get_page_visit(); |
| 659 | - if ( $page_visit ) { |
|
| 659 | + if ($page_visit) { |
|
| 660 | 660 | // set pages visited where the first will be the http referrer |
| 661 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
| 661 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
| 662 | 662 | // we'll only save the last 10 page visits. |
| 663 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
| 663 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
| 664 | 664 | } |
| 665 | 665 | break; |
| 666 | 666 | |
@@ -674,9 +674,9 @@ discard block |
||
| 674 | 674 | |
| 675 | 675 | $this->_session_data = $session_data; |
| 676 | 676 | // creating a new session does not require saving to the db just yet |
| 677 | - if ( ! $new_session ) { |
|
| 677 | + if ( ! $new_session) { |
|
| 678 | 678 | // ready? let's save |
| 679 | - if ( $this->_save_session_to_db() ) { |
|
| 679 | + if ($this->_save_session_to_db()) { |
|
| 680 | 680 | return TRUE; |
| 681 | 681 | } else { |
| 682 | 682 | return FALSE; |
@@ -695,9 +695,9 @@ discard block |
||
| 695 | 695 | * @return bool |
| 696 | 696 | */ |
| 697 | 697 | private function _create_espresso_session( ) { |
| 698 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
| 698 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
| 699 | 699 | // use the update function for now with $new_session arg set to TRUE |
| 700 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
| 700 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | |
@@ -723,15 +723,15 @@ discard block |
||
| 723 | 723 | // OR an admin request that is NOT AJAX |
| 724 | 724 | || ( |
| 725 | 725 | is_admin() |
| 726 | - && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
| 726 | + && ! (defined('DOING_AJAX') && DOING_AJAX) |
|
| 727 | 727 | ) |
| 728 | 728 | ) |
| 729 | 729 | ) { |
| 730 | 730 | return false; |
| 731 | 731 | } |
| 732 | 732 | $transaction = $this->transaction(); |
| 733 | - if ( $transaction instanceof EE_Transaction ) { |
|
| 734 | - if ( ! $transaction->ID() ) { |
|
| 733 | + if ($transaction instanceof EE_Transaction) { |
|
| 734 | + if ( ! $transaction->ID()) { |
|
| 735 | 735 | $transaction->save(); |
| 736 | 736 | } |
| 737 | 737 | $this->_session_data['transaction'] = $transaction->ID(); |
@@ -739,13 +739,13 @@ discard block |
||
| 739 | 739 | // then serialize all of our session data |
| 740 | 740 | $session_data = serialize($this->_session_data); |
| 741 | 741 | // do we need to also encode it to avoid corrupted data when saved to the db? |
| 742 | - $session_data = $this->_use_encryption ? $this->encryption->base64_string_encode( $session_data ) : $session_data; |
|
| 742 | + $session_data = $this->_use_encryption ? $this->encryption->base64_string_encode($session_data) : $session_data; |
|
| 743 | 743 | // maybe save hash check |
| 744 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
| 745 | - set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan ); |
|
| 744 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
| 745 | + set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan); |
|
| 746 | 746 | } |
| 747 | 747 | // we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient( transient ID, data, expiry ) |
| 748 | - return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan ); |
|
| 748 | + return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan); |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | |
@@ -771,10 +771,10 @@ discard block |
||
| 771 | 771 | 'HTTP_FORWARDED', |
| 772 | 772 | 'REMOTE_ADDR' |
| 773 | 773 | ); |
| 774 | - foreach ( $server_keys as $key ){ |
|
| 775 | - if ( isset( $_SERVER[ $key ] )) { |
|
| 776 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
| 777 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
| 774 | + foreach ($server_keys as $key) { |
|
| 775 | + if (isset($_SERVER[$key])) { |
|
| 776 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
| 777 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
| 778 | 778 | $visitor_ip = $ip; |
| 779 | 779 | } |
| 780 | 780 | } |
@@ -793,32 +793,32 @@ discard block |
||
| 793 | 793 | * @return string |
| 794 | 794 | */ |
| 795 | 795 | public function _get_page_visit() { |
| 796 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
| 796 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
| 797 | 797 | // check for request url |
| 798 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
| 798 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 799 | 799 | $http_host = ''; |
| 800 | 800 | $page_id = '?'; |
| 801 | 801 | $e_reg = ''; |
| 802 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
| 803 | - $ru_bits = explode( '?', $request_uri ); |
|
| 802 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
| 803 | + $ru_bits = explode('?', $request_uri); |
|
| 804 | 804 | $request_uri = $ru_bits[0]; |
| 805 | 805 | // check for and grab host as well |
| 806 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
| 807 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
| 806 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
| 807 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
| 808 | 808 | } |
| 809 | 809 | // check for page_id in SERVER REQUEST |
| 810 | - if ( isset( $_REQUEST['page_id'] )) { |
|
| 810 | + if (isset($_REQUEST['page_id'])) { |
|
| 811 | 811 | // rebuild $e_reg without any of the extra parameters |
| 812 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
| 812 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
| 813 | 813 | } |
| 814 | 814 | // check for $e_reg in SERVER REQUEST |
| 815 | - if ( isset( $_REQUEST['ee'] )) { |
|
| 815 | + if (isset($_REQUEST['ee'])) { |
|
| 816 | 816 | // rebuild $e_reg without any of the extra parameters |
| 817 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
| 817 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
| 818 | 818 | } |
| 819 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
| 819 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
| 820 | 820 | } |
| 821 | - return $page_visit !== home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
| 821 | + return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
| 822 | 822 | |
| 823 | 823 | } |
| 824 | 824 | |
@@ -847,14 +847,14 @@ discard block |
||
| 847 | 847 | * @param string $function |
| 848 | 848 | * @return void |
| 849 | 849 | */ |
| 850 | - public function clear_session( $class = '', $function = '' ) { |
|
| 850 | + public function clear_session($class = '', $function = '') { |
|
| 851 | 851 | //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>'; |
| 852 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
| 852 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
| 853 | 853 | $this->reset_cart(); |
| 854 | 854 | $this->reset_checkout(); |
| 855 | 855 | $this->reset_transaction(); |
| 856 | 856 | // wipe out everything that isn't a default session datum |
| 857 | - $this->reset_data( array_keys( $this->_session_data )); |
|
| 857 | + $this->reset_data(array_keys($this->_session_data)); |
|
| 858 | 858 | // reset initial site access time and the session expiration |
| 859 | 859 | $this->_set_init_access_and_expiration(); |
| 860 | 860 | $this->_save_session_to_db(); |
@@ -869,42 +869,42 @@ discard block |
||
| 869 | 869 | * @param bool $show_all_notices |
| 870 | 870 | * @return TRUE on success, FALSE on fail |
| 871 | 871 | */ |
| 872 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
| 872 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
| 873 | 873 | // if $data_to_reset is not in an array, then put it in one |
| 874 | - if ( ! is_array( $data_to_reset ) ) { |
|
| 875 | - $data_to_reset = array ( $data_to_reset ); |
|
| 874 | + if ( ! is_array($data_to_reset)) { |
|
| 875 | + $data_to_reset = array($data_to_reset); |
|
| 876 | 876 | } |
| 877 | 877 | // nothing ??? go home! |
| 878 | - if ( empty( $data_to_reset )) { |
|
| 879 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 878 | + if (empty($data_to_reset)) { |
|
| 879 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 880 | 880 | return FALSE; |
| 881 | 881 | } |
| 882 | 882 | $return_value = TRUE; |
| 883 | 883 | // since $data_to_reset is an array, cycle through the values |
| 884 | - foreach ( $data_to_reset as $reset ) { |
|
| 884 | + foreach ($data_to_reset as $reset) { |
|
| 885 | 885 | |
| 886 | 886 | // first check to make sure it is a valid session var |
| 887 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
| 887 | + if (isset($this->_session_data[$reset])) { |
|
| 888 | 888 | // then check to make sure it is not a default var |
| 889 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
| 889 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
| 890 | 890 | // remove session var |
| 891 | - unset( $this->_session_data[ $reset ] ); |
|
| 892 | - if ( $show_all_notices ) { |
|
| 893 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 891 | + unset($this->_session_data[$reset]); |
|
| 892 | + if ($show_all_notices) { |
|
| 893 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
| 894 | 894 | } |
| 895 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
| 895 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
| 896 | 896 | |
| 897 | 897 | } else { |
| 898 | 898 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
| 899 | - if ( $show_all_notices ) { |
|
| 900 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 899 | + if ($show_all_notices) { |
|
| 900 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
| 901 | 901 | } |
| 902 | 902 | $return_value = FALSE; |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - } else if ( $show_all_notices ) { |
|
| 905 | + } else if ($show_all_notices) { |
|
| 906 | 906 | // oops! that session var does not exist! |
| 907 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 907 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
| 908 | 908 | $return_value = FALSE; |
| 909 | 909 | } |
| 910 | 910 | |
@@ -924,8 +924,8 @@ discard block |
||
| 924 | 924 | * @access public |
| 925 | 925 | */ |
| 926 | 926 | public function wp_loaded() { |
| 927 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
| 928 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
| 927 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
| 928 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
| 929 | 929 | } |
| 930 | 930 | } |
| 931 | 931 | |
@@ -950,24 +950,24 @@ discard block |
||
| 950 | 950 | */ |
| 951 | 951 | public function garbage_collection() { |
| 952 | 952 | // only perform during regular requests |
| 953 | - if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) { |
|
| 953 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
| 954 | 954 | /** @type WPDB $wpdb */ |
| 955 | 955 | global $wpdb; |
| 956 | 956 | // since transient expiration timestamps are set in the future, we can compare against NOW |
| 957 | 957 | $expiration = time(); |
| 958 | - $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 ); |
|
| 958 | + $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2); |
|
| 959 | 959 | // filter the query limit. Set to 0 to turn off garbage collection |
| 960 | - $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 )); |
|
| 960 | + $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50)); |
|
| 961 | 961 | // non-zero LIMIT means take out the trash |
| 962 | - if ( $expired_session_transient_delete_query_limit ) { |
|
| 962 | + if ($expired_session_transient_delete_query_limit) { |
|
| 963 | 963 | //array of transient keys that require garbage collection |
| 964 | 964 | $session_keys = array( |
| 965 | 965 | EE_Session::session_id_prefix, |
| 966 | 966 | EE_Session::hash_check_prefix, |
| 967 | 967 | ); |
| 968 | - foreach ( $session_keys as $session_key ) { |
|
| 969 | - $session_key = str_replace( '_', '\_', $session_key ); |
|
| 970 | - $session_key = '\_transient\_timeout\_' . $session_key . '%'; |
|
| 968 | + foreach ($session_keys as $session_key) { |
|
| 969 | + $session_key = str_replace('_', '\_', $session_key); |
|
| 970 | + $session_key = '\_transient\_timeout\_'.$session_key.'%'; |
|
| 971 | 971 | $SQL = " |
| 972 | 972 | SELECT option_name |
| 973 | 973 | FROM {$wpdb->options} |
@@ -977,25 +977,25 @@ discard block |
||
| 977 | 977 | OR option_value > {$too_far_in_the_the_future} ) |
| 978 | 978 | LIMIT {$expired_session_transient_delete_query_limit} |
| 979 | 979 | "; |
| 980 | - $expired_sessions = $wpdb->get_col( $SQL ); |
|
| 980 | + $expired_sessions = $wpdb->get_col($SQL); |
|
| 981 | 981 | // valid results? |
| 982 | - if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) { |
|
| 982 | + if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) { |
|
| 983 | 983 | // format array of results into something usable within the actual DELETE query's IN clause |
| 984 | 984 | $expired = array(); |
| 985 | - foreach ( $expired_sessions as $expired_session ) { |
|
| 986 | - $expired[ ] = "'" . $expired_session . "'"; |
|
| 987 | - $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'"; |
|
| 985 | + foreach ($expired_sessions as $expired_session) { |
|
| 986 | + $expired[] = "'".$expired_session."'"; |
|
| 987 | + $expired[] = "'".str_replace('timeout_', '', $expired_session)."'"; |
|
| 988 | 988 | } |
| 989 | - $expired = implode( ', ', $expired ); |
|
| 989 | + $expired = implode(', ', $expired); |
|
| 990 | 990 | $SQL = " |
| 991 | 991 | DELETE FROM {$wpdb->options} |
| 992 | 992 | WHERE option_name |
| 993 | 993 | IN ( $expired ); |
| 994 | 994 | "; |
| 995 | - $results = $wpdb->query( $SQL ); |
|
| 995 | + $results = $wpdb->query($SQL); |
|
| 996 | 996 | // if something went wrong, then notify the admin |
| 997 | - if ( $results instanceof WP_Error && is_admin() ) { |
|
| 998 | - EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 997 | + if ($results instanceof WP_Error && is_admin()) { |
|
| 998 | + EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
| 999 | 999 | } |
| 1000 | 1000 | } |
| 1001 | 1001 | } |
@@ -1016,34 +1016,34 @@ discard block |
||
| 1016 | 1016 | * @param $data1 |
| 1017 | 1017 | * @return string |
| 1018 | 1018 | */ |
| 1019 | - private function find_serialize_error( $data1 ) { |
|
| 1019 | + private function find_serialize_error($data1) { |
|
| 1020 | 1020 | $error = "<pre>"; |
| 1021 | 1021 | $data2 = preg_replace_callback( |
| 1022 | 1022 | '!s:(\d+):"(.*?)";!', |
| 1023 | - function ( $match ) { |
|
| 1024 | - return ( $match[1] === strlen( $match[2] ) ) |
|
| 1023 | + function($match) { |
|
| 1024 | + return ($match[1] === strlen($match[2])) |
|
| 1025 | 1025 | ? $match[0] |
| 1026 | 1026 | : 's:' |
| 1027 | - . strlen( $match[2] ) |
|
| 1027 | + . strlen($match[2]) |
|
| 1028 | 1028 | . ':"' |
| 1029 | 1029 | . $match[2] |
| 1030 | 1030 | . '";'; |
| 1031 | 1031 | }, |
| 1032 | 1032 | $data1 |
| 1033 | 1033 | ); |
| 1034 | - $max = ( strlen( $data1 ) > strlen( $data2 ) ) ? strlen( $data1 ) : strlen( $data2 ); |
|
| 1035 | - $error .= $data1 . PHP_EOL; |
|
| 1036 | - $error .= $data2 . PHP_EOL; |
|
| 1037 | - for ( $i = 0; $i < $max; $i++ ) { |
|
| 1038 | - if ( @$data1[ $i ] !== @$data2[ $i ] ) { |
|
| 1039 | - $error .= "Difference " . @$data1[ $i ] . " != " . @$data2[ $i ] . PHP_EOL; |
|
| 1040 | - $error .= "\t-> ORD number " . ord( @$data1[ $i ] ) . " != " . ord( @$data2[ $i ] ) . PHP_EOL; |
|
| 1041 | - $error .= "\t-> Line Number = $i" . PHP_EOL; |
|
| 1042 | - $start = ( $i - 20 ); |
|
| 1043 | - $start = ( $start < 0 ) ? 0 : $start; |
|
| 1034 | + $max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2); |
|
| 1035 | + $error .= $data1.PHP_EOL; |
|
| 1036 | + $error .= $data2.PHP_EOL; |
|
| 1037 | + for ($i = 0; $i < $max; $i++) { |
|
| 1038 | + if (@$data1[$i] !== @$data2[$i]) { |
|
| 1039 | + $error .= "Difference ".@$data1[$i]." != ".@$data2[$i].PHP_EOL; |
|
| 1040 | + $error .= "\t-> ORD number ".ord(@$data1[$i])." != ".ord(@$data2[$i]).PHP_EOL; |
|
| 1041 | + $error .= "\t-> Line Number = $i".PHP_EOL; |
|
| 1042 | + $start = ($i - 20); |
|
| 1043 | + $start = ($start < 0) ? 0 : $start; |
|
| 1044 | 1044 | $length = 40; |
| 1045 | 1045 | $point = $max - $i; |
| 1046 | - if ( $point < 20 ) { |
|
| 1046 | + if ($point < 20) { |
|
| 1047 | 1047 | $rlength = 1; |
| 1048 | 1048 | $rpoint = -$point; |
| 1049 | 1049 | } else { |
@@ -1052,16 +1052,16 @@ discard block |
||
| 1052 | 1052 | } |
| 1053 | 1053 | $error .= "\t-> Section Data1 = "; |
| 1054 | 1054 | $error .= substr_replace( |
| 1055 | - substr( $data1, $start, $length ), |
|
| 1056 | - "<b style=\"color:green\">{$data1[ $i ]}</b>", |
|
| 1055 | + substr($data1, $start, $length), |
|
| 1056 | + "<b style=\"color:green\">{$data1[$i]}</b>", |
|
| 1057 | 1057 | $rpoint, |
| 1058 | 1058 | $rlength |
| 1059 | 1059 | ); |
| 1060 | 1060 | $error .= PHP_EOL; |
| 1061 | 1061 | $error .= "\t-> Section Data2 = "; |
| 1062 | 1062 | $error .= substr_replace( |
| 1063 | - substr( $data2, $start, $length ), |
|
| 1064 | - "<b style=\"color:red\">{$data2[ $i ]}</b>", |
|
| 1063 | + substr($data2, $start, $length), |
|
| 1064 | + "<b style=\"color:red\">{$data2[$i]}</b>", |
|
| 1065 | 1065 | $rpoint, |
| 1066 | 1066 | $rlength |
| 1067 | 1067 | ); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @since 4.5.0 |
| 12 | 12 | * |
| 13 | 13 | */ |
| 14 | -class EE_Model_Form_Section extends EE_Form_Section_Proper{ |
|
| 14 | +class EE_Model_Form_Section extends EE_Form_Section_Proper { |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * |
@@ -36,36 +36,36 @@ discard block |
||
| 36 | 36 | * } |
| 37 | 37 | * @throws EE_Error |
| 38 | 38 | */ |
| 39 | - public function __construct($options_array = array()){ |
|
| 40 | - if(isset($options_array['model']) && $options_array['model'] instanceof EEM_Base){ |
|
| 39 | + public function __construct($options_array = array()) { |
|
| 40 | + if (isset($options_array['model']) && $options_array['model'] instanceof EEM_Base) { |
|
| 41 | 41 | $this->_model = $options_array['model']; |
| 42 | 42 | } |
| 43 | - if( ! $this->_model || ! $this->_model instanceof EEM_Base ){ |
|
| 43 | + if ( ! $this->_model || ! $this->_model instanceof EEM_Base) { |
|
| 44 | 44 | throw new EE_Error(sprintf(__("Model Form Sections must first specify the _model property to be a subclass of EEM_Base", "event_espresso"))); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if(isset($options_array['subsection_args'])){ |
|
| 47 | + if (isset($options_array['subsection_args'])) { |
|
| 48 | 48 | $subsection_args = $options_array['subsection_args']; |
| 49 | - }else{ |
|
| 49 | + } else { |
|
| 50 | 50 | $subsection_args = array(); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | //gather fields and relations to convert to inputs |
| 54 | 54 | //but if they're just going to exclude a field anyways, don't bother converting it to an input |
| 55 | 55 | $exclude = $this->_subsections; |
| 56 | - if(isset($options_array['exclude'])){ |
|
| 57 | - $exclude = array_merge($exclude,array_flip($options_array['exclude'])); |
|
| 56 | + if (isset($options_array['exclude'])) { |
|
| 57 | + $exclude = array_merge($exclude, array_flip($options_array['exclude'])); |
|
| 58 | 58 | } |
| 59 | 59 | $model_fields = array_diff_key($this->_model->field_settings(), $exclude); |
| 60 | 60 | $model_relations = array_diff_key($this->_model->relation_settings(), $exclude); |
| 61 | 61 | //convert fields and relations to inputs |
| 62 | 62 | $this->_subsections = array_merge( |
| 63 | 63 | $this->_convert_model_fields_to_inputs($model_fields), |
| 64 | - $this->_convert_model_relations_to_inputs($model_relations,$subsection_args), |
|
| 64 | + $this->_convert_model_relations_to_inputs($model_relations, $subsection_args), |
|
| 65 | 65 | $this->_subsections |
| 66 | 66 | ); |
| 67 | 67 | parent::__construct($options_array); |
| 68 | - if(isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class){ |
|
| 68 | + if (isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class) { |
|
| 69 | 69 | $this->populate_model_obj($options_array['model_object']); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | * } |
| 84 | 84 | * @return array |
| 85 | 85 | */ |
| 86 | - protected function _convert_model_relations_to_inputs($relations,$subsection_args = array()){ |
|
| 86 | + protected function _convert_model_relations_to_inputs($relations, $subsection_args = array()) { |
|
| 87 | 87 | $inputs = array(); |
| 88 | - foreach( $relations as $relation_name => $relation_obj ) { |
|
| 88 | + foreach ($relations as $relation_name => $relation_obj) { |
|
| 89 | 89 | $input_constructor_args = array( |
| 90 | 90 | array_merge( |
| 91 | 91 | array( |
@@ -96,19 +96,19 @@ discard block |
||
| 96 | 96 | ) |
| 97 | 97 | ); |
| 98 | 98 | $input = NULL; |
| 99 | - switch(get_class($relation_obj)){ |
|
| 99 | + switch (get_class($relation_obj)) { |
|
| 100 | 100 | case 'EE_HABTM_Relation': |
| 101 | - if(isset($subsection_args[$relation_name]) && |
|
| 102 | - isset($subsection_args[$relation_name]['model_objects'])){ |
|
| 101 | + if (isset($subsection_args[$relation_name]) && |
|
| 102 | + isset($subsection_args[$relation_name]['model_objects'])) { |
|
| 103 | 103 | $model_objects = $subsection_args[$relation_name]['model_objects']; |
| 104 | - }else{ |
|
| 104 | + } else { |
|
| 105 | 105 | $model_objects = $relation_obj->get_other_model()->get_all(); |
| 106 | 106 | } |
| 107 | - $input = new EE_Select_Multi_Model_Input($model_objects,$input_constructor_args); |
|
| 107 | + $input = new EE_Select_Multi_Model_Input($model_objects, $input_constructor_args); |
|
| 108 | 108 | break; |
| 109 | 109 | default: |
| 110 | 110 | } |
| 111 | - if($input){ |
|
| 111 | + if ($input) { |
|
| 112 | 112 | $inputs[$relation_name] = $input; |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | * @throws EE_Error |
| 124 | 124 | * @return EE_Form_Input_Base[] |
| 125 | 125 | */ |
| 126 | - protected function _convert_model_fields_to_inputs( $model_fields = array() ){ |
|
| 126 | + protected function _convert_model_fields_to_inputs($model_fields = array()) { |
|
| 127 | 127 | $inputs = array(); |
| 128 | - foreach( $model_fields as $field_name=>$model_field ){ |
|
| 129 | - if ( $model_field instanceof EE_Model_Field_Base ) { |
|
| 128 | + foreach ($model_fields as $field_name=>$model_field) { |
|
| 129 | + if ($model_field instanceof EE_Model_Field_Base) { |
|
| 130 | 130 | $input_constructor_args = array( |
| 131 | 131 | array( |
| 132 | 132 | 'required'=> ! $model_field->is_nullable() && $model_field->get_default_value() === NULL, |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | 'default'=>$model_field->get_default_value(), |
| 135 | 135 | ) |
| 136 | 136 | ); |
| 137 | - switch(get_class($model_field)){ |
|
| 137 | + switch (get_class($model_field)) { |
|
| 138 | 138 | case 'EE_All_Caps_Text_Field': |
| 139 | 139 | case 'EE_Any_Foreign_Model_Name_Field': |
| 140 | 140 | $input_class = 'EE_Text_Input'; |
@@ -143,16 +143,16 @@ discard block |
||
| 143 | 143 | $input_class = 'EE_Yes_No_Input'; |
| 144 | 144 | break; |
| 145 | 145 | case 'EE_Datetime_Field': |
| 146 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 146 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 147 | 147 | break; |
| 148 | 148 | case 'EE_Email_Field': |
| 149 | 149 | $input_class = 'EE_Email_Input'; |
| 150 | 150 | break; |
| 151 | 151 | case 'EE_Enum_Integer_Field': |
| 152 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 152 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 153 | 153 | break; |
| 154 | 154 | case 'EE_Enum_Text_Field': |
| 155 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 155 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 156 | 156 | break; |
| 157 | 157 | case 'EE_Float_Field': |
| 158 | 158 | $input_class = 'EE_Float_Input'; |
@@ -161,15 +161,15 @@ discard block |
||
| 161 | 161 | case 'EE_Foreign_Key_String_Field': |
| 162 | 162 | case 'EE_WP_User_Field': |
| 163 | 163 | $models_pointed_to = $model_field instanceof EE_Field_With_Model_Name ? $model_field->get_model_class_names_pointed_to() : array(); |
| 164 | - if(true || is_array($models_pointed_to) && count($models_pointed_to) > 1){ |
|
| 164 | + if (true || is_array($models_pointed_to) && count($models_pointed_to) > 1) { |
|
| 165 | 165 | $input_class = 'EE_Text_Input'; |
| 166 | - }else{ |
|
| 166 | + } else { |
|
| 167 | 167 | //so its just one model |
| 168 | 168 | $model_name = is_array($models_pointed_to) ? reset($models_pointed_to) : $models_pointed_to; |
| 169 | 169 | $model = EE_Registry::instance()->load_model($model_name); |
| 170 | 170 | $model_names = $model->get_all_names(array('limit'=>10)); |
| 171 | - if($model_field->is_nullable()){ |
|
| 172 | - array_unshift( $model_names, __( "Please Select", 'event_espresso' )); |
|
| 171 | + if ($model_field->is_nullable()) { |
|
| 172 | + array_unshift($model_names, __("Please Select", 'event_espresso')); |
|
| 173 | 173 | } |
| 174 | 174 | $input_constructor_args[1] = $input_constructor_args[0]; |
| 175 | 175 | $input_constructor_args[0] = $model_names; |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | break; |
| 179 | 179 | case 'EE_Full_HTML_Field': |
| 180 | 180 | $input_class = 'EE_Text_Area_Input'; |
| 181 | - $input_constructor_args[ 0 ]['validation_strategies'] = array( new EE_Full_HTML_Validation_Strategy() ); |
|
| 181 | + $input_constructor_args[0]['validation_strategies'] = array(new EE_Full_HTML_Validation_Strategy()); |
|
| 182 | 182 | break; |
| 183 | 183 | case 'EE_Infinite_Integer': |
| 184 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 184 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 185 | 185 | break; |
| 186 | 186 | case 'EE_Integer_Field': |
| 187 | 187 | $input_class = 'EE_Text_Input'; |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | $input_class = 'EE_Text_Area_Input'; |
| 191 | 191 | break; |
| 192 | 192 | case 'EE_Money_Field': |
| 193 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 193 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 194 | 194 | break; |
| 195 | 195 | case 'EE_Post_Content_Field': |
| 196 | 196 | $input_class = 'EE_Text_Area_Input'; |
| 197 | - $input_constructor_args[ 0 ][ 'validation_strategies' ] = array( new EE_Full_HTML_Validation_Strategy() ); |
|
| 197 | + $input_constructor_args[0]['validation_strategies'] = array(new EE_Full_HTML_Validation_Strategy()); |
|
| 198 | 198 | break; |
| 199 | 199 | case 'EE_Plain_Text_Field': |
| 200 | 200 | $input_class = 'EE_Text_Input'; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | break; |
| 212 | 212 | case 'EE_Simple_HTML_Field': |
| 213 | 213 | $input_class = 'EE_Text_Area_Input'; |
| 214 | - $input_constructor_args[ 0 ][ 'validation_strategies' ] = array( new EE_Simple_HTML_Validation_Strategy() ); |
|
| 214 | + $input_constructor_args[0]['validation_strategies'] = array(new EE_Simple_HTML_Validation_Strategy()); |
|
| 215 | 215 | break; |
| 216 | 216 | case 'EE_Slug_Field': |
| 217 | 217 | $input_class = 'EE_Text_Input'; |
@@ -220,13 +220,13 @@ discard block |
||
| 220 | 220 | $input_class = 'EE_Yes_No_Input'; |
| 221 | 221 | break; |
| 222 | 222 | case 'EE_WP_Post_Status_Field': |
| 223 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 223 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 224 | 224 | break; |
| 225 | 225 | case 'EE_WP_Post_Type_Field': |
| 226 | - throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field))); |
|
| 226 | + throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field))); |
|
| 227 | 227 | break; |
| 228 | 228 | default: |
| 229 | - throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"),get_class($model_field))); |
|
| 229 | + throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"), get_class($model_field))); |
|
| 230 | 230 | } |
| 231 | 231 | $reflection = new ReflectionClass($input_class); |
| 232 | 232 | $input = $reflection->newInstanceArgs($input_constructor_args); |
@@ -245,21 +245,21 @@ discard block |
||
| 245 | 245 | * @param EE_Base_Class $model_obj |
| 246 | 246 | * @return void |
| 247 | 247 | */ |
| 248 | - public function populate_model_obj($model_obj){ |
|
| 248 | + public function populate_model_obj($model_obj) { |
|
| 249 | 249 | $model_obj = $this->_model->ensure_is_obj($model_obj); |
| 250 | 250 | $this->_model_object = $model_obj; |
| 251 | 251 | $defaults = $model_obj->model_field_array(); |
| 252 | - foreach($this->_model->relation_settings() as $relation_name => $relation_obj){ |
|
| 252 | + foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) { |
|
| 253 | 253 | $form_inputs = $this->inputs(); |
| 254 | - if(isset($form_inputs[$relation_name])){ |
|
| 255 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
| 254 | + if (isset($form_inputs[$relation_name])) { |
|
| 255 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
| 256 | 256 | //then we only expect there to be one |
| 257 | 257 | $related_item = $this->_model_object->get_first_related($relation_name); |
| 258 | 258 | $defaults[$relation_name] = $related_item->ID(); |
| 259 | - }else{ |
|
| 259 | + } else { |
|
| 260 | 260 | $related_items = $this->_model_object->get_many_related($relation_name); |
| 261 | 261 | $ids = array(); |
| 262 | - foreach($related_items as $related_item){ |
|
| 262 | + foreach ($related_items as $related_item) { |
|
| 263 | 263 | $ids[] = $related_item->ID(); |
| 264 | 264 | } |
| 265 | 265 | $defaults[$relation_name] = $ids; |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | * values are their normalized values |
| 282 | 282 | * @return array |
| 283 | 283 | */ |
| 284 | - public function inputs_values_corresponding_to_model_fields(){ |
|
| 285 | - return array_intersect_key($this->input_values(),$this->_model->field_settings()); |
|
| 284 | + public function inputs_values_corresponding_to_model_fields() { |
|
| 285 | + return array_intersect_key($this->input_values(), $this->_model->field_settings()); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | |
@@ -293,17 +293,17 @@ discard block |
||
| 293 | 293 | * @param array $req_data should usually be $_REQUEST (the default). |
| 294 | 294 | * @return void |
| 295 | 295 | */ |
| 296 | - public function _normalize( $req_data ) { |
|
| 297 | - parent::_normalize( $req_data ); |
|
| 296 | + public function _normalize($req_data) { |
|
| 297 | + parent::_normalize($req_data); |
|
| 298 | 298 | //create or set the model object, if it isn't already |
| 299 | - if( ! $this->_model_object ){ |
|
| 299 | + if ( ! $this->_model_object) { |
|
| 300 | 300 | //check to see if the form indicates a PK, in which case we want to only retrieve it and update it |
| 301 | 301 | $pk_name = $this->_model->primary_key_name(); |
| 302 | 302 | $model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name)); |
| 303 | - if($model_obj){ |
|
| 303 | + if ($model_obj) { |
|
| 304 | 304 | $this->_model_object = $model_obj; |
| 305 | - }else{ |
|
| 306 | - $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name() ); |
|
| 305 | + } else { |
|
| 306 | + $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name()); |
|
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -318,24 +318,24 @@ discard block |
||
| 318 | 318 | * @return int, 1 on a successful update, the ID of |
| 319 | 319 | * the new entry on insert; 0 on failure |
| 320 | 320 | */ |
| 321 | - public function save(){ |
|
| 322 | - if( ! $this->_model_object){ |
|
| 323 | - throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"),get_class($this->_model))); |
|
| 321 | + public function save() { |
|
| 322 | + if ( ! $this->_model_object) { |
|
| 323 | + throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"), get_class($this->_model))); |
|
| 324 | 324 | } |
| 325 | 325 | //ok so the model object is set. Just set it with the submitted form data |
| 326 | - foreach($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value){ |
|
| 326 | + foreach ($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value) { |
|
| 327 | 327 | //only set the non-primary key |
| 328 | - if($field_name != $this->_model->primary_key_name()){ |
|
| 329 | - $this->_model_object->set($field_name,$field_value); |
|
| 328 | + if ($field_name != $this->_model->primary_key_name()) { |
|
| 329 | + $this->_model_object->set($field_name, $field_value); |
|
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | - $success = $this->_model_object->save(); |
|
| 333 | - foreach($this->_model->relation_settings() as $relation_name => $relation_obj){ |
|
| 334 | - if(isset($this->_subsections[$relation_name])){ |
|
| 332 | + $success = $this->_model_object->save(); |
|
| 333 | + foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) { |
|
| 334 | + if (isset($this->_subsections[$relation_name])) { |
|
| 335 | 335 | $success = $this->_save_related_info($relation_name); |
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | - do_action( 'AHEE__EE_Model_Form_Section__save__done', $this, $success ); |
|
| 338 | + do_action('AHEE__EE_Model_Form_Section__save__done', $this, $success); |
|
| 339 | 339 | return $success; |
| 340 | 340 | } |
| 341 | 341 | |
@@ -348,29 +348,29 @@ discard block |
||
| 348 | 348 | * @return bool |
| 349 | 349 | * @throws EE_Error |
| 350 | 350 | */ |
| 351 | - protected function _save_related_info($relation_name){ |
|
| 351 | + protected function _save_related_info($relation_name) { |
|
| 352 | 352 | $relation_obj = $this->_model->related_settings_for($relation_name); |
| 353 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
| 353 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
| 354 | 354 | //there is just a foreign key on this model pointing to that one |
| 355 | 355 | $this->_model_object->_add_relation_to($this->get_input_value($relation_name), $relation_name); |
| 356 | - }elseif($relation_obj instanceof EE_Has_Many_Relation){ |
|
| 356 | + }elseif ($relation_obj instanceof EE_Has_Many_Relation) { |
|
| 357 | 357 | //then we want to consider all of its currently-related things. |
| 358 | 358 | //if they're in this list, keep them |
| 359 | 359 | //if they're not in this list, remove them |
| 360 | 360 | //and lastly add all the new items |
| 361 | 361 | throw new EE_Error(sprintf(__('Automatic saving of related info across a "has many" relation is not yet supported', "event_espresso"))); |
| 362 | - }elseif($relation_obj instanceof EE_HABTM_Relation){ |
|
| 362 | + }elseif ($relation_obj instanceof EE_HABTM_Relation) { |
|
| 363 | 363 | //delete everything NOT in this list |
| 364 | 364 | $normalized_input_value = $this->get_input_value($relation_name); |
| 365 | - if($normalized_input_value && is_array($normalized_input_value)){ |
|
| 365 | + if ($normalized_input_value && is_array($normalized_input_value)) { |
|
| 366 | 366 | $where_query_params = array( |
| 367 | - $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN',$normalized_input_value)); |
|
| 368 | - }else{ |
|
| 367 | + $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN', $normalized_input_value)); |
|
| 368 | + } else { |
|
| 369 | 369 | $where_query_params = array(); |
| 370 | 370 | } |
| 371 | - $this->_model_object->_remove_relations( $relation_name, $where_query_params ); |
|
| 372 | - foreach($normalized_input_value as $id){ |
|
| 373 | - $this->_model_object->_add_relation_to( $id, $relation_name ); |
|
| 371 | + $this->_model_object->_remove_relations($relation_name, $where_query_params); |
|
| 372 | + foreach ($normalized_input_value as $id) { |
|
| 373 | + $this->_model_object->_add_relation_to($id, $relation_name); |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | return TRUE; |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | * Gets the model of this model form |
| 383 | 383 | * @return EEM_Base |
| 384 | 384 | */ |
| 385 | - public function get_model(){ |
|
| 385 | + public function get_model() { |
|
| 386 | 386 | return $this->_model; |
| 387 | 387 | } |
| 388 | 388 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | * when receive_form_submission($req_data) was called. |
| 396 | 396 | * @return EE_Base_Class |
| 397 | 397 | */ |
| 398 | - public function get_model_object(){ |
|
| 398 | + public function get_model_object() { |
|
| 399 | 399 | return $this->_model_object; |
| 400 | 400 | } |
| 401 | 401 | |
@@ -405,10 +405,10 @@ discard block |
||
| 405 | 405 | * gets teh default name of this form section if none is specified |
| 406 | 406 | * @return string |
| 407 | 407 | */ |
| 408 | - protected function _set_default_name_if_empty(){ |
|
| 409 | - if( ! $this->_name ){ |
|
| 410 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
| 411 | - $this->_name = $default_name; |
|
| 408 | + protected function _set_default_name_if_empty() { |
|
| 409 | + if ( ! $this->_name) { |
|
| 410 | + $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form"; |
|
| 411 | + $this->_name = $default_name; |
|
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 3 | 3 | exit('NO direct script access allowed'); |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
| 45 | 45 | * @return \Payments_Admin_Page |
| 46 | 46 | */ |
| 47 | - public function __construct( $routing = TRUE ) { |
|
| 48 | - parent::__construct( $routing ); |
|
| 47 | + public function __construct($routing = TRUE) { |
|
| 48 | + parent::__construct($routing); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | |
@@ -130,19 +130,19 @@ discard block |
||
| 130 | 130 | protected function _set_page_config() { |
| 131 | 131 | $payment_method_list_config = array( |
| 132 | 132 | 'nav' => array( |
| 133 | - 'label' => __( 'Payment Methods', 'event_espresso' ), |
|
| 133 | + 'label' => __('Payment Methods', 'event_espresso'), |
|
| 134 | 134 | 'order' => 10 |
| 135 | 135 | ), |
| 136 | 136 | 'metaboxes' => $this->_default_espresso_metaboxes, |
| 137 | 137 | 'help_tabs' => array_merge( |
| 138 | 138 | array( |
| 139 | 139 | 'payment_methods_overview_help_tab' => array( |
| 140 | - 'title' => __( 'Payment Methods Overview', 'event_espresso' ), |
|
| 140 | + 'title' => __('Payment Methods Overview', 'event_espresso'), |
|
| 141 | 141 | 'filename' => 'payment_methods_overview' |
| 142 | 142 | ) |
| 143 | 143 | ), |
| 144 | 144 | $this->_add_payment_method_help_tabs() ), |
| 145 | - 'help_tour' => array( 'Payment_Methods_Selection_Help_Tour' ), |
|
| 145 | + 'help_tour' => array('Payment_Methods_Selection_Help_Tour'), |
|
| 146 | 146 | 'require_nonce' => false |
| 147 | 147 | ); |
| 148 | 148 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | ) |
| 161 | 161 | ), |
| 162 | 162 | //'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ), |
| 163 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
| 163 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 164 | 164 | 'require_nonce' => FALSE |
| 165 | 165 | ), |
| 166 | 166 | 'payment_log'=>array( |
@@ -179,17 +179,17 @@ discard block |
||
| 179 | 179 | /** |
| 180 | 180 | * @return array |
| 181 | 181 | */ |
| 182 | - protected function _add_payment_method_help_tabs(){ |
|
| 182 | + protected function _add_payment_method_help_tabs() { |
|
| 183 | 183 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
| 184 | 184 | $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
| 185 | 185 | $all_pmt_help_tabs_config = array(); |
| 186 | - foreach( $payment_method_types as $payment_method_type ){ |
|
| 187 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
| 186 | + foreach ($payment_method_types as $payment_method_type) { |
|
| 187 | + if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) { |
|
| 188 | 188 | continue; |
| 189 | 189 | } |
| 190 | - foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){ |
|
| 191 | - $template_args = isset( $config[ 'template_args' ] ) ? $config[ 'template_args' ] : array(); |
|
| 192 | - $template_args[ 'admin_page_obj' ] = $this; |
|
| 190 | + foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
| 191 | + $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
|
| 192 | + $template_args['admin_page_obj'] = $this; |
|
| 193 | 193 | $all_pmt_help_tabs_config[$help_tab_name] = array( |
| 194 | 194 | 'title'=>$config['title'], |
| 195 | 195 | 'content'=>EEH_Template::display_template( |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | |
| 218 | 218 | public function load_scripts_styles() { |
| 219 | - wp_enqueue_script( 'ee_admin_js' ); |
|
| 220 | - wp_enqueue_script( 'ee-text-links' ); |
|
| 221 | - wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 219 | + wp_enqueue_script('ee_admin_js'); |
|
| 220 | + wp_enqueue_script('ee-text-links'); |
|
| 221 | + wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | public function load_scripts_styles_default() { |
| 229 | 229 | //styles |
| 230 | - wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION ); |
|
| 231 | - wp_enqueue_style( 'espresso_payments' ); |
|
| 232 | - wp_enqueue_style( 'ee-text-links' ); |
|
| 230 | + wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 231 | + wp_enqueue_style('espresso_payments'); |
|
| 232 | + wp_enqueue_style('ee-text-links'); |
|
| 233 | 233 | //scripts |
| 234 | 234 | } |
| 235 | 235 | |
@@ -243,44 +243,44 @@ discard block |
||
| 243 | 243 | * to the loading process. However, people MUST setup the details for the payment method so its safe to do a |
| 244 | 244 | * recheck here. |
| 245 | 245 | */ |
| 246 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
| 246 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
| 247 | 247 | EEM_Payment_Method::instance()->verify_button_urls(); |
| 248 | 248 | //setup tabs, one for each payment method type |
| 249 | 249 | $tabs = array(); |
| 250 | 250 | $payment_methods = array(); |
| 251 | - foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) { |
|
| 251 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
| 252 | 252 | // we don't want to show admin-only PMTs for now |
| 253 | - if ( $pmt_obj instanceof EE_PMT_Admin_Only ) { |
|
| 253 | + if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
| 254 | 254 | continue; |
| 255 | 255 | } |
| 256 | 256 | //check access |
| 257 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
| 257 | + if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) { |
|
| 258 | 258 | continue; |
| 259 | 259 | } |
| 260 | 260 | //check for any active pms of that type |
| 261 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() ); |
|
| 262 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
| 261 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
| 262 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
| 263 | 263 | $payment_method = EE_Payment_Method::new_instance( |
| 264 | 264 | array( |
| 265 | - 'PMD_slug' =>sanitize_key( $pmt_obj->system_name() ), |
|
| 265 | + 'PMD_slug' =>sanitize_key($pmt_obj->system_name()), |
|
| 266 | 266 | 'PMD_type' =>$pmt_obj->system_name(), |
| 267 | 267 | 'PMD_name' =>$pmt_obj->pretty_name(), |
| 268 | 268 | 'PMD_admin_name' =>$pmt_obj->pretty_name() |
| 269 | 269 | ) |
| 270 | 270 | ); |
| 271 | 271 | } |
| 272 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
| 272 | + $payment_methods[$payment_method->slug()] = $payment_method; |
|
| 273 | 273 | } |
| 274 | - $payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods ); |
|
| 275 | - foreach( $payment_methods as $payment_method ) { |
|
| 276 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
| 274 | + $payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods); |
|
| 275 | + foreach ($payment_methods as $payment_method) { |
|
| 276 | + if ($payment_method instanceof EE_Payment_Method) { |
|
| 277 | 277 | add_meta_box( |
| 278 | 278 | //html id |
| 279 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
| 279 | + 'espresso_'.$payment_method->slug().'_payment_settings', |
|
| 280 | 280 | //title |
| 281 | - sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
| 281 | + sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
| 282 | 282 | //callback |
| 283 | - array( $this, 'payment_method_settings_meta_box' ), |
|
| 283 | + array($this, 'payment_method_settings_meta_box'), |
|
| 284 | 284 | //post type |
| 285 | 285 | null, |
| 286 | 286 | //context |
@@ -288,19 +288,19 @@ discard block |
||
| 288 | 288 | //priority |
| 289 | 289 | 'default', |
| 290 | 290 | //callback args |
| 291 | - array( 'payment_method' => $payment_method ) |
|
| 291 | + array('payment_method' => $payment_method) |
|
| 292 | 292 | ); |
| 293 | 293 | //setup for tabbed content |
| 294 | - $tabs[ $payment_method->slug() ] = array( |
|
| 294 | + $tabs[$payment_method->slug()] = array( |
|
| 295 | 295 | 'label' => $payment_method->admin_name(), |
| 296 | 296 | 'class' => $payment_method->active() ? 'gateway-active' : '', |
| 297 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
| 298 | - 'title' => __( 'Modify this Payment Method', 'event_espresso' ), |
|
| 297 | + 'href' => 'espresso_'.$payment_method->slug().'_payment_settings', |
|
| 298 | + 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
| 299 | 299 | 'slug' => $payment_method->slug() |
| 300 | 300 | ); |
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() ); |
|
| 303 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug()); |
|
| 304 | 304 | $this->display_admin_page_with_sidebar(); |
| 305 | 305 | |
| 306 | 306 | } |
@@ -311,20 +311,20 @@ discard block |
||
| 311 | 311 | * _get_active_payment_method_slug |
| 312 | 312 | * @return string |
| 313 | 313 | */ |
| 314 | - protected function _get_active_payment_method_slug(){ |
|
| 314 | + protected function _get_active_payment_method_slug() { |
|
| 315 | 315 | $payment_method_slug = FALSE; |
| 316 | 316 | //decide which payment method tab to open first, as dictated by the request's 'payment_method' |
| 317 | - if ( isset( $this->_req_data['payment_method'] )) { |
|
| 317 | + if (isset($this->_req_data['payment_method'])) { |
|
| 318 | 318 | // if they provided the current payment method, use it |
| 319 | - $payment_method_slug = sanitize_key( $this->_req_data['payment_method'] ); |
|
| 319 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
| 320 | 320 | } |
| 321 | - $payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug ))); |
|
| 321 | + $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
| 322 | 322 | // if that didn't work or wasn't provided, find another way to select the current pm |
| 323 | - if ( ! $this->_verify_payment_method( $payment_method )) { |
|
| 323 | + if ( ! $this->_verify_payment_method($payment_method)) { |
|
| 324 | 324 | // like, looking for an active one |
| 325 | - $payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' ); |
|
| 325 | + $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
| 326 | 326 | // test that one as well |
| 327 | - if ( $this->_verify_payment_method( $payment_method )) { |
|
| 327 | + if ($this->_verify_payment_method($payment_method)) { |
|
| 328 | 328 | $payment_method_slug = $payment_method->slug(); |
| 329 | 329 | } else { |
| 330 | 330 | $payment_method_slug = 'paypal_standard'; |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | * @param \EE_Payment_Method $payment_method |
| 343 | 343 | * @return boolean |
| 344 | 344 | */ |
| 345 | - protected function _verify_payment_method( $payment_method ){ |
|
| 345 | + protected function _verify_payment_method($payment_method) { |
|
| 346 | 346 | if ( |
| 347 | 347 | $payment_method instanceof EE_Payment_Method && |
| 348 | 348 | $payment_method->type_obj() instanceof EE_PMT_Base && |
| 349 | - EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' ) |
|
| 349 | + EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access') |
|
| 350 | 350 | ) { |
| 351 | 351 | return TRUE; |
| 352 | 352 | } |
@@ -363,21 +363,21 @@ discard block |
||
| 363 | 363 | * @return string |
| 364 | 364 | * @throws EE_Error |
| 365 | 365 | */ |
| 366 | - public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){ |
|
| 367 | - $payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL; |
|
| 368 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
| 369 | - throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' ))); |
|
| 366 | + public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) { |
|
| 367 | + $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL; |
|
| 368 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
| 369 | + throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso'))); |
|
| 370 | 370 | } |
| 371 | 371 | $payment_method_scopes = $payment_method->active(); |
| 372 | 372 | // if the payment method really exists show its form, otherwise the activation template |
| 373 | - if ( $payment_method->ID() && ! empty( $payment_method_scopes )) { |
|
| 374 | - $form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
| 375 | - if ( $form->form_data_present_in( $this->_req_data )) { |
|
| 376 | - $form->receive_form_submission( $this->_req_data ); |
|
| 373 | + if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
| 374 | + $form = $this->_generate_payment_method_settings_form($payment_method); |
|
| 375 | + if ($form->form_data_present_in($this->_req_data)) { |
|
| 376 | + $form->receive_form_submission($this->_req_data); |
|
| 377 | 377 | } |
| 378 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
| 378 | + echo $form->form_open().$form->get_html_and_js().$form->form_close(); |
|
| 379 | 379 | } else { |
| 380 | - echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js(); |
|
| 380 | + echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | |
@@ -390,14 +390,14 @@ discard block |
||
| 390 | 390 | * @param \EE_Payment_Method $payment_method |
| 391 | 391 | * @return \EE_Form_Section_Proper |
| 392 | 392 | */ |
| 393 | - protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) { |
|
| 394 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
| 393 | + protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) { |
|
| 394 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
| 395 | 395 | return new EE_Form_Section_Proper(); |
| 396 | 396 | } |
| 397 | 397 | return new EE_Form_Section_Proper( |
| 398 | 398 | array( |
| 399 | - 'name' => $payment_method->slug() . '_settings_form', |
|
| 400 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
| 399 | + 'name' => $payment_method->slug().'_settings_form', |
|
| 400 | + 'html_id' => $payment_method->slug().'_settings_form', |
|
| 401 | 401 | 'action' => EE_Admin_Page::add_query_args_and_nonce( |
| 402 | 402 | array( |
| 403 | 403 | 'action' => 'update_payment_method', |
@@ -409,12 +409,12 @@ discard block |
||
| 409 | 409 | 'subsections' => apply_filters( |
| 410 | 410 | 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
| 411 | 411 | array( |
| 412 | - 'pci_dss_compliance_' . $payment_method->slug() => $this->_pci_dss_compliance( $payment_method ), |
|
| 413 | - 'currency_support_' . $payment_method->slug() => $this->_currency_support( $payment_method ), |
|
| 414 | - 'payment_method_settings_' . $payment_method->slug() => $this->_payment_method_settings( $payment_method ), |
|
| 415 | - 'update_' . $payment_method->slug() => $this->_update_payment_method_button( $payment_method ), |
|
| 416 | - 'deactivate_' . $payment_method->slug() => $this->_deactivate_payment_method_button( $payment_method ), |
|
| 417 | - 'fine_print_' . $payment_method->slug() => $this->_fine_print() |
|
| 412 | + 'pci_dss_compliance_'.$payment_method->slug() => $this->_pci_dss_compliance($payment_method), |
|
| 413 | + 'currency_support_'.$payment_method->slug() => $this->_currency_support($payment_method), |
|
| 414 | + 'payment_method_settings_'.$payment_method->slug() => $this->_payment_method_settings($payment_method), |
|
| 415 | + 'update_'.$payment_method->slug() => $this->_update_payment_method_button($payment_method), |
|
| 416 | + 'deactivate_'.$payment_method->slug() => $this->_deactivate_payment_method_button($payment_method), |
|
| 417 | + 'fine_print_'.$payment_method->slug() => $this->_fine_print() |
|
| 418 | 418 | ), |
| 419 | 419 | $payment_method |
| 420 | 420 | ) |
@@ -431,19 +431,19 @@ discard block |
||
| 431 | 431 | * @param \EE_Payment_Method $payment_method |
| 432 | 432 | * @return \EE_Form_Section_Proper |
| 433 | 433 | */ |
| 434 | - protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) { |
|
| 435 | - if ( $payment_method->type_obj()->requires_https() ) { |
|
| 434 | + protected function _pci_dss_compliance(EE_Payment_Method $payment_method) { |
|
| 435 | + if ($payment_method->type_obj()->requires_https()) { |
|
| 436 | 436 | return new EE_Form_Section_HTML( |
| 437 | 437 | EEH_HTML::tr( |
| 438 | 438 | EEH_HTML::th( |
| 439 | 439 | EEH_HTML::label( |
| 440 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
| 440 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
| 441 | 441 | ) |
| 442 | - ) . |
|
| 442 | + ). |
|
| 443 | 443 | EEH_HTML::td( |
| 444 | - EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) . |
|
| 445 | - EEH_HTML::br() . |
|
| 446 | - __( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' )) |
|
| 444 | + EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')). |
|
| 445 | + EEH_HTML::br(). |
|
| 446 | + __('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso')) |
|
| 447 | 447 | ) |
| 448 | 448 | ) |
| 449 | 449 | ); |
@@ -461,19 +461,19 @@ discard block |
||
| 461 | 461 | * @param \EE_Payment_Method $payment_method |
| 462 | 462 | * @return \EE_Form_Section_Proper |
| 463 | 463 | */ |
| 464 | - protected function _currency_support( EE_Payment_Method $payment_method ) { |
|
| 465 | - if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) { |
|
| 464 | + protected function _currency_support(EE_Payment_Method $payment_method) { |
|
| 465 | + if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
| 466 | 466 | return new EE_Form_Section_HTML( |
| 467 | 467 | EEH_HTML::tr( |
| 468 | 468 | EEH_HTML::th( |
| 469 | 469 | EEH_HTML::label( |
| 470 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
| 470 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
| 471 | 471 | ) |
| 472 | - ) . |
|
| 472 | + ). |
|
| 473 | 473 | EEH_HTML::td( |
| 474 | 474 | EEH_HTML::strong( |
| 475 | 475 | sprintf( |
| 476 | - __( 'This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
| 476 | + __('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
| 477 | 477 | EE_Config::instance()->currency->code |
| 478 | 478 | ) |
| 479 | 479 | ) |
@@ -493,9 +493,9 @@ discard block |
||
| 493 | 493 | * @param \EE_Payment_Method $payment_method |
| 494 | 494 | * @return \EE_Form_Section_HTML |
| 495 | 495 | */ |
| 496 | - protected function _payment_method_settings( EE_Payment_Method $payment_method ) { |
|
| 496 | + protected function _payment_method_settings(EE_Payment_Method $payment_method) { |
|
| 497 | 497 | //modify the form so we only have/show fields that will be implemented for this version |
| 498 | - return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() ); |
|
| 498 | + return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | |
@@ -508,8 +508,8 @@ discard block |
||
| 508 | 508 | * @return \EE_Payment_Method_Form |
| 509 | 509 | * @throws \EE_Error |
| 510 | 510 | */ |
| 511 | - protected function _simplify_form( $form_section, $payment_method_name = '' ){ |
|
| 512 | - if ( $form_section instanceof EE_Payment_Method_Form ) { |
|
| 511 | + protected function _simplify_form($form_section, $payment_method_name = '') { |
|
| 512 | + if ($form_section instanceof EE_Payment_Method_Form) { |
|
| 513 | 513 | $form_section->exclude( |
| 514 | 514 | array( |
| 515 | 515 | 'PMD_type', //dont want them changing the type |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | ); |
| 521 | 521 | return $form_section; |
| 522 | 522 | } else { |
| 523 | - throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name )); |
|
| 523 | + throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name)); |
|
| 524 | 524 | } |
| 525 | 525 | } |
| 526 | 526 | |
@@ -533,19 +533,19 @@ discard block |
||
| 533 | 533 | * @param \EE_Payment_Method $payment_method |
| 534 | 534 | * @return \EE_Form_Section_HTML |
| 535 | 535 | */ |
| 536 | - protected function _update_payment_method_button( EE_Payment_Method $payment_method ) { |
|
| 536 | + protected function _update_payment_method_button(EE_Payment_Method $payment_method) { |
|
| 537 | 537 | $update_button = new EE_Submit_Input( |
| 538 | 538 | array( |
| 539 | 539 | 'name' => 'submit', |
| 540 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
| 541 | - 'default' => sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
| 540 | + 'html_id' => 'save_'.$payment_method->slug().'_settings', |
|
| 541 | + 'default' => sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()), |
|
| 542 | 542 | 'html_label' => EEH_HTML::nbsp() |
| 543 | 543 | ) |
| 544 | 544 | ); |
| 545 | 545 | return new EE_Form_Section_HTML( |
| 546 | - EEH_HTML::no_row( EEH_HTML::br(2) ) . |
|
| 546 | + EEH_HTML::no_row(EEH_HTML::br(2)). |
|
| 547 | 547 | EEH_HTML::tr( |
| 548 | - EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) . |
|
| 548 | + EEH_HTML::th(__('Update Settings', 'event_espresso')). |
|
| 549 | 549 | EEH_HTML::td( |
| 550 | 550 | $update_button->get_html_for_input() |
| 551 | 551 | ) |
@@ -562,11 +562,11 @@ discard block |
||
| 562 | 562 | * @param \EE_Payment_Method $payment_method |
| 563 | 563 | * @return \EE_Form_Section_Proper |
| 564 | 564 | */ |
| 565 | - protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
| 566 | - $link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() ); |
|
| 565 | + protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) { |
|
| 566 | + $link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name()); |
|
| 567 | 567 | return new EE_Form_Section_HTML( |
| 568 | 568 | EEH_HTML::tr( |
| 569 | - EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) . |
|
| 569 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')). |
|
| 570 | 570 | EEH_HTML::td( |
| 571 | 571 | EEH_HTML::link( |
| 572 | 572 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | ), |
| 579 | 579 | $link_text_and_title, |
| 580 | 580 | $link_text_and_title, |
| 581 | - 'deactivate_' . $payment_method->slug(), |
|
| 581 | + 'deactivate_'.$payment_method->slug(), |
|
| 582 | 582 | 'espresso-button button-secondary' |
| 583 | 583 | ) |
| 584 | 584 | ) |
@@ -594,12 +594,12 @@ discard block |
||
| 594 | 594 | * @param \EE_Payment_Method $payment_method |
| 595 | 595 | * @return \EE_Form_Section_Proper |
| 596 | 596 | */ |
| 597 | - protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
| 598 | - $link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() ); |
|
| 597 | + protected function _activate_payment_method_button(EE_Payment_Method $payment_method) { |
|
| 598 | + $link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name()); |
|
| 599 | 599 | return new EE_Form_Section_Proper( |
| 600 | 600 | array( |
| 601 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
| 602 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
| 601 | + 'name' => 'activate_'.$payment_method->slug().'_settings_form', |
|
| 602 | + 'html_id' => 'activate_'.$payment_method->slug().'_settings_form', |
|
| 603 | 603 | 'action' => '#', |
| 604 | 604 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
| 605 | 605 | 'subsections' => apply_filters( |
@@ -607,17 +607,17 @@ discard block |
||
| 607 | 607 | array( |
| 608 | 608 | new EE_Form_Section_HTML( |
| 609 | 609 | EEH_HTML::tr( |
| 610 | - EEH_HTML::td( $payment_method->type_obj()->introductory_html(), |
|
| 610 | + EEH_HTML::td($payment_method->type_obj()->introductory_html(), |
|
| 611 | 611 | '', |
| 612 | 612 | '', |
| 613 | 613 | '', |
| 614 | 614 | 'colspan="2"' |
| 615 | 615 | ) |
| 616 | - ) . |
|
| 616 | + ). |
|
| 617 | 617 | EEH_HTML::tr( |
| 618 | 618 | EEH_HTML::th( |
| 619 | - EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' )) |
|
| 620 | - ) . |
|
| 619 | + EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
| 620 | + ). |
|
| 621 | 621 | EEH_HTML::td( |
| 622 | 622 | EEH_HTML::link( |
| 623 | 623 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | ), |
| 630 | 630 | $link_text_and_title, |
| 631 | 631 | $link_text_and_title, |
| 632 | - 'activate_' . $payment_method->slug(), |
|
| 632 | + 'activate_'.$payment_method->slug(), |
|
| 633 | 633 | 'espresso-button-green button-primary' |
| 634 | 634 | ) |
| 635 | 635 | ) |
@@ -651,9 +651,9 @@ discard block |
||
| 651 | 651 | protected function _fine_print() { |
| 652 | 652 | return new EE_Form_Section_HTML( |
| 653 | 653 | EEH_HTML::tr( |
| 654 | - EEH_HTML::th() . |
|
| 654 | + EEH_HTML::th(). |
|
| 655 | 655 | EEH_HTML::td( |
| 656 | - EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' ) |
|
| 656 | + EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
| 657 | 657 | ) |
| 658 | 658 | ) |
| 659 | 659 | ); |
@@ -665,15 +665,15 @@ discard block |
||
| 665 | 665 | * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
| 666 | 666 | * @global WP_User $current_user |
| 667 | 667 | */ |
| 668 | - protected function _activate_payment_method(){ |
|
| 669 | - if(isset($this->_req_data['payment_method_type'])){ |
|
| 668 | + protected function _activate_payment_method() { |
|
| 669 | + if (isset($this->_req_data['payment_method_type'])) { |
|
| 670 | 670 | $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
| 671 | 671 | //see if one exists |
| 672 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
| 673 | - $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type ); |
|
| 672 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
| 673 | + $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type); |
|
| 674 | 674 | |
| 675 | - $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
| 676 | - }else{ |
|
| 675 | + $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
| 676 | + } else { |
|
| 677 | 677 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
| 678 | 678 | } |
| 679 | 679 | } |
@@ -681,14 +681,14 @@ discard block |
||
| 681 | 681 | /** |
| 682 | 682 | * Deactivates the payment method with the specified slug, and redirects. |
| 683 | 683 | */ |
| 684 | - protected function _deactivate_payment_method(){ |
|
| 685 | - if(isset($this->_req_data['payment_method'])){ |
|
| 684 | + protected function _deactivate_payment_method() { |
|
| 685 | + if (isset($this->_req_data['payment_method'])) { |
|
| 686 | 686 | $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
| 687 | 687 | //deactivate it |
| 688 | 688 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
| 689 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug ); |
|
| 690 | - $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug)); |
|
| 691 | - }else{ |
|
| 689 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
| 690 | + $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug)); |
|
| 691 | + } else { |
|
| 692 | 692 | $this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default')); |
| 693 | 693 | } |
| 694 | 694 | } |
@@ -702,46 +702,46 @@ discard block |
||
| 702 | 702 | * subsequently called 'headers_sent_func' which is _payment_methods_list) |
| 703 | 703 | * @return void |
| 704 | 704 | */ |
| 705 | - protected function _update_payment_method(){ |
|
| 706 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
| 705 | + protected function _update_payment_method() { |
|
| 706 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 707 | 707 | //ok let's find which gateway form to use based on the form input |
| 708 | 708 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
| 709 | 709 | /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
| 710 | 710 | $correct_pmt_form_to_use = NULL; |
| 711 | 711 | $payment_method = NULL; |
| 712 | - foreach( EEM_Payment_Method::instance()->get_all() as $payment_method){ |
|
| 712 | + foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) { |
|
| 713 | 713 | //get the form and simplify it, like what we do when we display it |
| 714 | - $pmt_form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
| 715 | - if($pmt_form->form_data_present_in($this->_req_data)){ |
|
| 714 | + $pmt_form = $this->_generate_payment_method_settings_form($payment_method); |
|
| 715 | + if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
| 716 | 716 | $correct_pmt_form_to_use = $pmt_form; |
| 717 | 717 | break; |
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | 720 | //if we couldn't find the correct payment method type... |
| 721 | - if( ! $correct_pmt_form_to_use ){ |
|
| 721 | + if ( ! $correct_pmt_form_to_use) { |
|
| 722 | 722 | EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
| 723 | 723 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
| 724 | 724 | } |
| 725 | 725 | $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
| 726 | - if($correct_pmt_form_to_use->is_valid()){ |
|
| 727 | - $subsection_name = 'payment_method_settings_' . $payment_method->slug(); |
|
| 728 | - $payment_settings_subform = $correct_pmt_form_to_use->get_subsection( $subsection_name ); |
|
| 729 | - if( ! $payment_settings_subform instanceof EE_Payment_Method_Form ) { |
|
| 726 | + if ($correct_pmt_form_to_use->is_valid()) { |
|
| 727 | + $subsection_name = 'payment_method_settings_'.$payment_method->slug(); |
|
| 728 | + $payment_settings_subform = $correct_pmt_form_to_use->get_subsection($subsection_name); |
|
| 729 | + if ( ! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
| 730 | 730 | throw new EE_Error( |
| 731 | 731 | sprintf( |
| 732 | - __( 'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.','event_espresso' ), |
|
| 732 | + __('The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.', 'event_espresso'), |
|
| 733 | 733 | $subsection_name |
| 734 | 734 | ) |
| 735 | 735 | ); |
| 736 | 736 | } |
| 737 | 737 | $payment_settings_subform->save(); |
| 738 | 738 | /** @var $pm EE_Payment_Method */ |
| 739 | - $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
| 740 | - }else{ |
|
| 739 | + $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
| 740 | + } else { |
|
| 741 | 741 | EE_Error::add_error( |
| 742 | 742 | sprintf( |
| 743 | 743 | __('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'), |
| 744 | - $payment_method instanceof EE_PMT_Base ? $payment_method->pretty_name() : __( '"(unknown)"', 'event_espresso' ) |
|
| 744 | + $payment_method instanceof EE_PMT_Base ? $payment_method->pretty_name() : __('"(unknown)"', 'event_espresso') |
|
| 745 | 745 | ), |
| 746 | 746 | __FILE__, |
| 747 | 747 | __FUNCTION__, |
@@ -758,11 +758,11 @@ discard block |
||
| 758 | 758 | protected function _payment_settings() { |
| 759 | 759 | |
| 760 | 760 | $this->_template_args['values'] = $this->_yes_no_values; |
| 761 | - $this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE; |
|
| 761 | + $this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE; |
|
| 762 | 762 | |
| 763 | - $this->_set_add_edit_form_tags( 'update_payment_settings' ); |
|
| 764 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
| 765 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE ); |
|
| 763 | + $this->_set_add_edit_form_tags('update_payment_settings'); |
|
| 764 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
| 765 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE); |
|
| 766 | 766 | $this->display_admin_page_with_sidebar(); |
| 767 | 767 | |
| 768 | 768 | } |
@@ -776,8 +776,8 @@ discard block |
||
| 776 | 776 | * @return array |
| 777 | 777 | */ |
| 778 | 778 | protected function _update_payment_settings() { |
| 779 | - EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
| 780 | - EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG ); |
|
| 779 | + EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
| 780 | + EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG); |
|
| 781 | 781 | |
| 782 | 782 | // $superform = new EE_Form_Section_Proper( |
| 783 | 783 | // array( |
@@ -797,9 +797,9 @@ discard block |
||
| 797 | 797 | // $this->_redirect_after_action( 0, 'settings', 'updated', array( 'action' => 'payment_settings' ) ); |
| 798 | 798 | // } |
| 799 | 799 | |
| 800 | - $what = __('Payment Settings','event_espresso'); |
|
| 801 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 802 | - $this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) ); |
|
| 800 | + $what = __('Payment Settings', 'event_espresso'); |
|
| 801 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__); |
|
| 802 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings')); |
|
| 803 | 803 | |
| 804 | 804 | } |
| 805 | 805 | protected function _payment_log_overview_list_table() { |
@@ -825,18 +825,18 @@ discard block |
||
| 825 | 825 | * @param bool $count |
| 826 | 826 | * @return array |
| 827 | 827 | */ |
| 828 | - public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){ |
|
| 829 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
| 828 | + public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) { |
|
| 829 | + EE_Registry::instance()->load_model('Change_Log'); |
|
| 830 | 830 | //we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
| 831 | - $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
| 831 | + $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
| 832 | 832 | //check if they've selected a specific payment method |
| 833 | - if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){ |
|
| 833 | + if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
| 834 | 834 | $query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'], |
| 835 | 835 | 'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']); |
| 836 | 836 | } |
| 837 | 837 | //take into account search |
| 838 | - if(isset($this->_req_data['s']) && $this->_req_data['s']){ |
|
| 839 | - $similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%'); |
|
| 838 | + if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
| 839 | + $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%'); |
|
| 840 | 840 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
| 841 | 841 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
| 842 | 842 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
@@ -851,48 +851,48 @@ discard block |
||
| 851 | 851 | $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
| 852 | 852 | |
| 853 | 853 | } |
| 854 | - if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){ |
|
| 854 | + if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) { |
|
| 855 | 855 | //add date |
| 856 | - $start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] ); |
|
| 857 | - $end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] ); |
|
| 856 | + $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
| 857 | + $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
| 858 | 858 | //make sure our timestamps start and end right at the boundaries for each day |
| 859 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
| 860 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
| 859 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
| 860 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
| 861 | 861 | |
| 862 | 862 | //convert to timestamps |
| 863 | - $start_date = strtotime( $start_date ); |
|
| 864 | - $end_date = strtotime( $end_date ); |
|
| 863 | + $start_date = strtotime($start_date); |
|
| 864 | + $end_date = strtotime($end_date); |
|
| 865 | 865 | |
| 866 | 866 | //makes sure start date is the lowest value and vice versa |
| 867 | - $start_date = min( $start_date, $end_date ); |
|
| 868 | - $end_date = max( $start_date, $end_date ); |
|
| 867 | + $start_date = min($start_date, $end_date); |
|
| 868 | + $end_date = max($start_date, $end_date); |
|
| 869 | 869 | |
| 870 | 870 | //convert for query |
| 871 | - $start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
|
| 872 | - $end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
|
| 871 | + $start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
| 872 | + $end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
| 873 | 873 | |
| 874 | - $query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date)); |
|
| 874 | + $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
| 875 | 875 | |
| 876 | 876 | } |
| 877 | - if($count){ |
|
| 877 | + if ($count) { |
|
| 878 | 878 | return EEM_Change_Log::instance()->count($query_params); |
| 879 | 879 | } |
| 880 | - if(isset($this->_req_data['order'])){ |
|
| 881 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
| 880 | + if (isset($this->_req_data['order'])) { |
|
| 881 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
| 882 | 882 | $query_params['order_by'] = array('LOG_time' => $sort); |
| 883 | - }else{ |
|
| 883 | + } else { |
|
| 884 | 884 | $query_params['order_by'] = array('LOG_time' => 'DESC'); |
| 885 | 885 | } |
| 886 | - $offset = ($current_page-1)*$per_page; |
|
| 886 | + $offset = ($current_page - 1) * $per_page; |
|
| 887 | 887 | |
| 888 | - if( ! isset($this->_req_data['download_results'])){ |
|
| 889 | - $query_params['limit'] = array( $offset, $per_page ); |
|
| 888 | + if ( ! isset($this->_req_data['download_results'])) { |
|
| 889 | + $query_params['limit'] = array($offset, $per_page); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | |
| 893 | 893 | |
| 894 | 894 | //now they've requested to instead just download the file instead of viewing it. |
| 895 | - if(isset($this->_req_data['download_results'])){ |
|
| 895 | + if (isset($this->_req_data['download_results'])) { |
|
| 896 | 896 | $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
| 897 | 897 | header('Content-Disposition: attachment'); |
| 898 | 898 | header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url())); |
@@ -914,36 +914,36 @@ discard block |
||
| 914 | 914 | * @param EE_Change_Log $logB |
| 915 | 915 | * @return int |
| 916 | 916 | */ |
| 917 | - protected function _sort_logs_again($logA,$logB){ |
|
| 917 | + protected function _sort_logs_again($logA, $logB) { |
|
| 918 | 918 | $timeA = $logA->get_raw('LOG_time'); |
| 919 | 919 | $timeB = $logB->get_raw('LOG_time'); |
| 920 | - if($timeA == $timeB){ |
|
| 920 | + if ($timeA == $timeB) { |
|
| 921 | 921 | return 0; |
| 922 | 922 | } |
| 923 | 923 | $comparison = $timeA < $timeB ? -1 : 1; |
| 924 | - if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){ |
|
| 924 | + if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
| 925 | 925 | return $comparison * -1; |
| 926 | - }else{ |
|
| 926 | + } else { |
|
| 927 | 927 | return $comparison; |
| 928 | 928 | } |
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | protected function _payment_log_details() { |
| 932 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
| 932 | + EE_Registry::instance()->load_model('Change_Log'); |
|
| 933 | 933 | /** @var $payment_log EE_Change_Log */ |
| 934 | 934 | $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
| 935 | 935 | $payment_method = NULL; |
| 936 | 936 | $transaction = NULL; |
| 937 | - if( $payment_log instanceof EE_Change_Log ){ |
|
| 938 | - if( $payment_log->object() instanceof EE_Payment ){ |
|
| 937 | + if ($payment_log instanceof EE_Change_Log) { |
|
| 938 | + if ($payment_log->object() instanceof EE_Payment) { |
|
| 939 | 939 | $payment_method = $payment_log->object()->payment_method(); |
| 940 | 940 | $transaction = $payment_log->object()->transaction(); |
| 941 | - }elseif($payment_log->object() instanceof EE_Payment_Method){ |
|
| 941 | + }elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
| 942 | 942 | $payment_method = $payment_log->object(); |
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | 945 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 946 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
| 946 | + EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php', |
|
| 947 | 947 | array( |
| 948 | 948 | 'payment_log'=>$payment_log, |
| 949 | 949 | 'payment_method'=>$payment_method, |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION')){ |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | 3 | exit('No direct script access allowed'); |
| 4 | 4 | } |
| 5 | 5 | /** |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | * @type $name string the name for this form section, if you want to explicitly define it |
| 80 | 80 | * } |
| 81 | 81 | */ |
| 82 | - public function __construct( $options_array = array() ) { |
|
| 82 | + public function __construct($options_array = array()) { |
|
| 83 | 83 | // used by display strategies |
| 84 | 84 | // assign incoming values to properties |
| 85 | - foreach( $options_array as $key => $value ) { |
|
| 86 | - $key = '_' . $key; |
|
| 87 | - if ( property_exists( $this, $key ) && empty( $this->{$key} )) { |
|
| 85 | + foreach ($options_array as $key => $value) { |
|
| 86 | + $key = '_'.$key; |
|
| 87 | + if (property_exists($this, $key) && empty($this->{$key} )) { |
|
| 88 | 88 | $this->{$key} = $value; |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -97,10 +97,10 @@ discard block |
||
| 97 | 97 | * @param $name |
| 98 | 98 | * @throws \EE_Error |
| 99 | 99 | */ |
| 100 | - protected function _construct_finalize( $parent_form_section, $name ){ |
|
| 100 | + protected function _construct_finalize($parent_form_section, $name) { |
|
| 101 | 101 | $this->_construction_finalized = TRUE; |
| 102 | 102 | $this->_parent_section = $parent_form_section; |
| 103 | - if( $name !== null ) { |
|
| 103 | + if ($name !== null) { |
|
| 104 | 104 | $this->_name = $name; |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | * @return void |
| 112 | 112 | * @throws \EE_Error |
| 113 | 113 | */ |
| 114 | - public function ensure_construct_finalized_called(){ |
|
| 115 | - if( ! $this->_construction_finalized ){ |
|
| 116 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
| 114 | + public function ensure_construct_finalized_called() { |
|
| 115 | + if ( ! $this->_construction_finalized) { |
|
| 116 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | /** |
| 132 | 132 | * @param string $action |
| 133 | 133 | */ |
| 134 | - public function set_action( $action ) { |
|
| 134 | + public function set_action($action) { |
|
| 135 | 135 | $this->_action = $action; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @return string |
| 142 | 142 | */ |
| 143 | 143 | public function method() { |
| 144 | - return ! empty( $this->_method ) ? $this->_method : 'POST'; |
|
| 144 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | /** |
| 150 | 150 | * @param string $method |
| 151 | 151 | */ |
| 152 | - public function set_method( $method ) { |
|
| 153 | - switch ( $method ) { |
|
| 152 | + public function set_method($method) { |
|
| 153 | + switch ($method) { |
|
| 154 | 154 | case 'get' : |
| 155 | 155 | case 'GET' : |
| 156 | 156 | $this->_method = 'GET'; |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | * |
| 170 | 170 | * @throws \EE_Error |
| 171 | 171 | */ |
| 172 | - protected function _set_default_html_id_if_empty(){ |
|
| 173 | - if( ! $this->_html_id ){ |
|
| 174 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
|
| 175 | - $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
|
| 176 | - }else{ |
|
| 177 | - $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
|
| 172 | + protected function _set_default_html_id_if_empty() { |
|
| 173 | + if ( ! $this->_html_id) { |
|
| 174 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
| 175 | + $this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name()); |
|
| 176 | + } else { |
|
| 177 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | * @param $name |
| 187 | 187 | * @return string |
| 188 | 188 | */ |
| 189 | - private function _prep_name_for_html_id( $name ) { |
|
| 190 | - return sanitize_key( str_replace( array( ' ', ' ', '_' ), '-', $name )); |
|
| 189 | + private function _prep_name_for_html_id($name) { |
|
| 190 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * and so might stop working anytime. |
| 202 | 202 | * @return string |
| 203 | 203 | */ |
| 204 | - public function get_html_and_js(){ |
|
| 204 | + public function get_html_and_js() { |
|
| 205 | 205 | return $this->get_html(); |
| 206 | 206 | } |
| 207 | 207 | |
@@ -217,9 +217,9 @@ discard block |
||
| 217 | 217 | * @param bool $add_pound_sign |
| 218 | 218 | * @return string |
| 219 | 219 | */ |
| 220 | - public function html_id( $add_pound_sign = FALSE ){ |
|
| 220 | + public function html_id($add_pound_sign = FALSE) { |
|
| 221 | 221 | $this->_set_default_html_id_if_empty(); |
| 222 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
| 222 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | /** |
| 228 | 228 | * @return string |
| 229 | 229 | */ |
| 230 | - public function html_class(){ |
|
| 230 | + public function html_class() { |
|
| 231 | 231 | return $this->_html_class; |
| 232 | 232 | } |
| 233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | /** |
| 237 | 237 | * @return string |
| 238 | 238 | */ |
| 239 | - public function html_style(){ |
|
| 239 | + public function html_style() { |
|
| 240 | 240 | return $this->_html_style; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | /** |
| 246 | 246 | * @param mixed $html_class |
| 247 | 247 | */ |
| 248 | - public function set_html_class( $html_class ) { |
|
| 248 | + public function set_html_class($html_class) { |
|
| 249 | 249 | $this->_html_class = $html_class; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | /** |
| 255 | 255 | * @param mixed $html_id |
| 256 | 256 | */ |
| 257 | - public function set_html_id( $html_id ) { |
|
| 257 | + public function set_html_id($html_id) { |
|
| 258 | 258 | $this->_html_id = $html_id; |
| 259 | 259 | } |
| 260 | 260 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | /** |
| 264 | 264 | * @param mixed $html_style |
| 265 | 265 | */ |
| 266 | - public function set_html_style( $html_style ) { |
|
| 266 | + public function set_html_style($html_style) { |
|
| 267 | 267 | $this->_html_style = $html_style; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | /** |
| 273 | 273 | * @param string $other_html_attributes |
| 274 | 274 | */ |
| 275 | - public function set_other_html_attributes( $other_html_attributes ) { |
|
| 275 | + public function set_other_html_attributes($other_html_attributes) { |
|
| 276 | 276 | $this->_other_html_attributes = $other_html_attributes; |
| 277 | 277 | } |
| 278 | 278 | |
@@ -292,9 +292,9 @@ discard block |
||
| 292 | 292 | * @throws EE_Error |
| 293 | 293 | * @return string |
| 294 | 294 | */ |
| 295 | - public function name(){ |
|
| 296 | - if( ! $this->_construction_finalized ){ |
|
| 297 | - throw new EE_Error(sprintf( __( 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso' ), get_class($this) ) ); |
|
| 295 | + public function name() { |
|
| 296 | + if ( ! $this->_construction_finalized) { |
|
| 297 | + throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso'), get_class($this))); |
|
| 298 | 298 | } |
| 299 | 299 | return $this->_name; |
| 300 | 300 | } |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | * Gets the parent section |
| 306 | 306 | * @return EE_Form_Section_Proper |
| 307 | 307 | */ |
| 308 | - public function parent_section(){ |
|
| 308 | + public function parent_section() { |
|
| 309 | 309 | return $this->_parent_section; |
| 310 | 310 | } |
| 311 | 311 | |
@@ -318,18 +318,18 @@ discard block |
||
| 318 | 318 | * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
| 319 | 319 | * @return string |
| 320 | 320 | */ |
| 321 | - public function form_open( $action = '', $method = '', $other_attributes = '' ) { |
|
| 322 | - if ( ! empty( $action )) { |
|
| 323 | - $this->set_action( $action ); |
|
| 321 | + public function form_open($action = '', $method = '', $other_attributes = '') { |
|
| 322 | + if ( ! empty($action)) { |
|
| 323 | + $this->set_action($action); |
|
| 324 | 324 | } |
| 325 | - if ( ! empty( $method )) { |
|
| 326 | - $this->set_method( $method ); |
|
| 325 | + if ( ! empty($method)) { |
|
| 326 | + $this->set_method($method); |
|
| 327 | 327 | } |
| 328 | - $html = EEH_HTML::nl( 1, 'form' ) . '<form'; |
|
| 329 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
| 330 | - $html .= ' action="' . $this->action() . '"'; |
|
| 331 | - $html .= ' method="' . $this->method() . '"'; |
|
| 332 | - $html .= $other_attributes . '>'; |
|
| 328 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
| 329 | + $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : ''; |
|
| 330 | + $html .= ' action="'.$this->action().'"'; |
|
| 331 | + $html .= ' method="'.$this->method().'"'; |
|
| 332 | + $html .= $other_attributes.'>'; |
|
| 333 | 333 | return $html; |
| 334 | 334 | } |
| 335 | 335 | |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | * @return string |
| 341 | 341 | */ |
| 342 | 342 | public function form_close() { |
| 343 | - return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl(); |
|
| 343 | + return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl(); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | /** |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | * Default does nothing, but child classes can override |
| 350 | 350 | * @return void |
| 351 | 351 | */ |
| 352 | - public function enqueue_js(){ |
|
| 352 | + public function enqueue_js() { |
|
| 353 | 353 | //defaults to enqueue NO js or css |
| 354 | 354 | } |
| 355 | 355 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @param array $form_other_js_data |
| 366 | 366 | * @return array |
| 367 | 367 | */ |
| 368 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
| 368 | + public function get_other_js_data($form_other_js_data = array()) { |
|
| 369 | 369 | return $form_other_js_data; |
| 370 | 370 | } |
| 371 | 371 | |
@@ -383,20 +383,20 @@ discard block |
||
| 383 | 383 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
| 384 | 384 | * @return EE_Form_Section_Base |
| 385 | 385 | */ |
| 386 | - public function find_section_from_path( $form_section_path ) { |
|
| 387 | - if( strpos( $form_section_path, '/' ) === 0 ) { |
|
| 388 | - $form_section_path = substr( $form_section_path, strlen( '/' ) ); |
|
| 386 | + public function find_section_from_path($form_section_path) { |
|
| 387 | + if (strpos($form_section_path, '/') === 0) { |
|
| 388 | + $form_section_path = substr($form_section_path, strlen('/')); |
|
| 389 | 389 | } |
| 390 | - if( empty( $form_section_path ) ) { |
|
| 390 | + if (empty($form_section_path)) { |
|
| 391 | 391 | return $this; |
| 392 | 392 | } |
| 393 | - if( strpos( $form_section_path, '../' ) === 0 ) { |
|
| 393 | + if (strpos($form_section_path, '../') === 0) { |
|
| 394 | 394 | $parent = $this->parent_section(); |
| 395 | 395 | |
| 396 | - $form_section_path = substr( $form_section_path, strlen( '../' ) ); |
|
| 397 | - if( $parent instanceof EE_Form_Section_Base ) { |
|
| 398 | - return $parent->find_section_from_path( $form_section_path ); |
|
| 399 | - } elseif( empty( $form_section_path ) ) { |
|
| 396 | + $form_section_path = substr($form_section_path, strlen('../')); |
|
| 397 | + if ($parent instanceof EE_Form_Section_Base) { |
|
| 398 | + return $parent->find_section_from_path($form_section_path); |
|
| 399 | + } elseif (empty($form_section_path)) { |
|
| 400 | 400 | return $this; |
| 401 | 401 | } |
| 402 | 402 | } |
@@ -57,11 +57,11 @@ |
||
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @param array $req_data |
|
| 62 | - * @throws EE_Error |
|
| 63 | - */ |
|
| 64 | - public function _normalize( $req_data ) { |
|
| 60 | + /** |
|
| 61 | + * @param array $req_data |
|
| 62 | + * @throws EE_Error |
|
| 63 | + */ |
|
| 64 | + public function _normalize( $req_data ) { |
|
| 65 | 65 | parent::_normalize( $req_data ); |
| 66 | 66 | $paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' ); |
| 67 | 67 | $paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' ); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -21,35 +21,35 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * @param EE_PMT_Paypal_Standard $payment_method_type |
| 23 | 23 | */ |
| 24 | - public function __construct( $payment_method_type ){ |
|
| 24 | + public function __construct($payment_method_type) { |
|
| 25 | 25 | parent::__construct( |
| 26 | 26 | array( |
| 27 | 27 | 'payment_method_type' => $payment_method_type, |
| 28 | 28 | 'extra_meta_inputs' => array( |
| 29 | - 'paypal_id' => new EE_Text_Input( array( |
|
| 30 | - 'html_label_text' => sprintf( __( "Paypal Email %s", 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
| 31 | - 'html_help_text' => __( "Typically [email protected]", 'event_espresso' ), |
|
| 29 | + 'paypal_id' => new EE_Text_Input(array( |
|
| 30 | + 'html_label_text' => sprintf(__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
| 31 | + 'html_help_text' => __("Typically [email protected]", 'event_espresso'), |
|
| 32 | 32 | 'required' => true |
| 33 | - ) ), |
|
| 34 | - 'image_url' => new EE_Admin_File_Uploader_Input( array( |
|
| 35 | - 'html_help_text' => __( "Used for your business/personal logo on the PayPal page", 'event_espresso' ), |
|
| 36 | - 'html_label_text' => __( 'Image URL', 'event_espresso' ) |
|
| 37 | - ) ), |
|
| 38 | - 'paypal_taxes' => new EE_Yes_No_Input( array( |
|
| 39 | - 'html_label_text' => sprintf( __( 'Paypal Calculates Taxes %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
| 40 | - 'html_help_text' => __( 'Whether Paypal should add taxes to the order', 'event_espresso' ), |
|
| 33 | + )), |
|
| 34 | + 'image_url' => new EE_Admin_File_Uploader_Input(array( |
|
| 35 | + 'html_help_text' => __("Used for your business/personal logo on the PayPal page", 'event_espresso'), |
|
| 36 | + 'html_label_text' => __('Image URL', 'event_espresso') |
|
| 37 | + )), |
|
| 38 | + 'paypal_taxes' => new EE_Yes_No_Input(array( |
|
| 39 | + 'html_label_text' => sprintf(__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
| 40 | + 'html_help_text' => __('Whether Paypal should add taxes to the order', 'event_espresso'), |
|
| 41 | 41 | 'default' => false |
| 42 | - ) ), |
|
| 43 | - 'paypal_shipping' => new EE_Yes_No_Input( array( |
|
| 44 | - 'html_label_text' => sprintf( __( 'Paypal Calculates Shipping %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
| 45 | - 'html_help_text' => __( 'Whether Paypal should add shipping surcharges', 'event_espresso' ), |
|
| 42 | + )), |
|
| 43 | + 'paypal_shipping' => new EE_Yes_No_Input(array( |
|
| 44 | + 'html_label_text' => sprintf(__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
| 45 | + 'html_help_text' => __('Whether Paypal should add shipping surcharges', 'event_espresso'), |
|
| 46 | 46 | 'default' => false |
| 47 | - ) ), |
|
| 48 | - 'shipping_details' => new EE_Select_Input( array( |
|
| 49 | - EE_PMT_Paypal_Standard::shipping_info_none => __( "Do not prompt for an address", 'event_espresso' ), |
|
| 50 | - EE_PMT_Paypal_Standard::shipping_info_optional => __( "Prompt for an address, but do not require it", 'event_espresso' ), |
|
| 51 | - EE_PMT_Paypal_Standard::shipping_info_required => __( "Prompt for an address, and require it", 'event_espresso' ) |
|
| 52 | - ) ) |
|
| 47 | + )), |
|
| 48 | + 'shipping_details' => new EE_Select_Input(array( |
|
| 49 | + EE_PMT_Paypal_Standard::shipping_info_none => __("Do not prompt for an address", 'event_espresso'), |
|
| 50 | + EE_PMT_Paypal_Standard::shipping_info_optional => __("Prompt for an address, but do not require it", 'event_espresso'), |
|
| 51 | + EE_PMT_Paypal_Standard::shipping_info_required => __("Prompt for an address, and require it", 'event_espresso') |
|
| 52 | + )) |
|
| 53 | 53 | ) |
| 54 | 54 | ) |
| 55 | 55 | ); |
@@ -61,28 +61,28 @@ discard block |
||
| 61 | 61 | * @param array $req_data |
| 62 | 62 | * @throws EE_Error |
| 63 | 63 | */ |
| 64 | - public function _normalize( $req_data ) { |
|
| 65 | - parent::_normalize( $req_data ); |
|
| 66 | - $paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' ); |
|
| 67 | - $paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' ); |
|
| 68 | - $paypal_requests_address_info = $this->get_input_value( 'shipping_details' ); |
|
| 64 | + public function _normalize($req_data) { |
|
| 65 | + parent::_normalize($req_data); |
|
| 66 | + $paypal_calculates_shipping = $this->get_input_value('paypal_shipping'); |
|
| 67 | + $paypal_calculates_taxes = $this->get_input_value('paypal_taxes'); |
|
| 68 | + $paypal_requests_address_info = $this->get_input_value('shipping_details'); |
|
| 69 | 69 | if ( |
| 70 | - ( $paypal_calculates_shipping || $paypal_calculates_taxes ) && |
|
| 70 | + ($paypal_calculates_shipping || $paypal_calculates_taxes) && |
|
| 71 | 71 | $paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none |
| 72 | 72 | ) { |
| 73 | 73 | //they want paypal to calculate taxes or shipping. They need to ask for |
| 74 | 74 | //address info, otherwise paypal can't calculate taxes or shipping |
| 75 | 75 | /** @type EE_Select_Input $shipping_details_input */ |
| 76 | - $shipping_details_input = $this->get_input( 'shipping_details' ); |
|
| 77 | - $shipping_details_input->set_default( EE_PMT_Paypal_Standard::shipping_info_optional ); |
|
| 76 | + $shipping_details_input = $this->get_input('shipping_details'); |
|
| 77 | + $shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional); |
|
| 78 | 78 | $shipping_details_input_options = $shipping_details_input->options(); |
| 79 | 79 | EE_Error::add_attention( |
| 80 | 80 | sprintf( |
| 81 | - __( 'Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso' ), |
|
| 82 | - strip_tags( $shipping_details_input->html_label_text() ), |
|
| 83 | - isset( $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] ) |
|
| 84 | - ? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] |
|
| 85 | - : __( 'Unknown', 'event_espresso' ) |
|
| 81 | + __('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'), |
|
| 82 | + strip_tags($shipping_details_input->html_label_text()), |
|
| 83 | + isset($shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional]) |
|
| 84 | + ? $shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional] |
|
| 85 | + : __('Unknown', 'event_espresso') |
|
| 86 | 86 | ), |
| 87 | 87 | __FILE__, __FUNCTION__, __LINE__ |
| 88 | 88 | ); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @return EED_Add_New_State |
| 17 | 17 | */ |
| 18 | 18 | public static function instance() { |
| 19 | - return parent::get_instance( __CLASS__ ); |
|
| 19 | + return parent::get_instance(__CLASS__); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -27,16 +27,16 @@ discard block |
||
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | 29 | public static function set_hooks() { |
| 30 | - add_action( 'wp_loaded', array( 'EED_Add_New_State', 'set_definitions' ), 2 ); |
|
| 31 | - add_action( 'wp_enqueue_scripts', array( 'EED_Add_New_State', 'translate_js_strings' ), 0 ); |
|
| 32 | - add_action( 'wp_enqueue_scripts', array( 'EED_Add_New_State', 'wp_enqueue_scripts' ), 10 ); |
|
| 33 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
| 34 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
| 35 | - add_filter( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array( 'EED_Add_New_State', 'unset_new_state_request_params' ), 10, 1 ); |
|
| 36 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array( 'EED_Add_New_State', 'inject_new_reg_state_into_options' ), 10, 5 ); |
|
| 37 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array( 'EED_Add_New_State', 'inject_new_reg_country_into_options' ), 10, 5 ); |
|
| 38 | - add_filter( 'FHEE__EE_State_Select_Input____construct__state_options', array( 'EED_Add_New_State', 'state_options' ), 10, 1 ); |
|
| 39 | - add_filter( 'FHEE__EE_Country_Select_Input____construct__country_options', array( 'EED_Add_New_State', 'country_options' ), 10, 1 ); |
|
| 30 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
| 31 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0); |
|
| 32 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10); |
|
| 33 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 34 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 35 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
| 36 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
| 37 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
| 38 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', array('EED_Add_New_State', 'state_options'), 10, 1); |
|
| 39 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', array('EED_Add_New_State', 'country_options'), 10, 1); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -46,20 +46,20 @@ discard block |
||
| 46 | 46 | * @return void |
| 47 | 47 | */ |
| 48 | 48 | public static function set_hooks_admin() { |
| 49 | - add_action( 'wp_loaded', array( 'EED_Add_New_State', 'set_definitions' ), 2 ); |
|
| 50 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
| 51 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
| 52 | - add_action( 'wp_ajax_espresso_add_new_state', array( 'EED_Add_New_State', 'add_new_state' )); |
|
| 53 | - add_action( 'wp_ajax_nopriv_espresso_add_new_state', array( 'EED_Add_New_State', 'add_new_state' )); |
|
| 54 | - add_filter( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array( 'EED_Add_New_State', 'unset_new_state_request_params' ), 10, 1 ); |
|
| 55 | - add_action( 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', array( 'EED_Add_New_State', 'update_country_settings' ), 10, 3 ); |
|
| 56 | - add_action( 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', array( 'EED_Add_New_State', 'update_country_settings' ), 10, 3 ); |
|
| 57 | - add_filter( 'FHEE__EE_State_Select_Input____construct__state_options', array( 'EED_Add_New_State', 'state_options' ), 10, 1 ); |
|
| 58 | - add_filter( 'FHEE__EE_Country_Select_Input____construct__country_options', array( 'EED_Add_New_State', 'country_options' ), 10, 1 ); |
|
| 49 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
| 50 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 51 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 52 | + add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
| 53 | + add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
| 54 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
| 55 | + add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
| 56 | + add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
| 57 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', array('EED_Add_New_State', 'state_options'), 10, 1); |
|
| 58 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', array('EED_Add_New_State', 'country_options'), 10, 1); |
|
| 59 | 59 | //add_filter( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', array( 'EED_Add_New_State', 'filter_checkout_request_params' ), 10, 1 ); |
| 60 | - add_filter( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', array( 'EED_Add_New_State', 'filter_checkout_request_params' ), 10, 1 ); |
|
| 61 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array( 'EED_Add_New_State', 'inject_new_reg_state_into_options' ), 10, 5 ); |
|
| 62 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array( 'EED_Add_New_State', 'inject_new_reg_country_into_options' ), 10, 5 ); |
|
| 60 | + add_filter('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1); |
|
| 61 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
| 62 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | * @return void |
| 72 | 72 | */ |
| 73 | 73 | public static function set_definitions() { |
| 74 | - define( 'ANS_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
| 75 | - define( 'ANS_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
| 74 | + define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
| 75 | + define('ANS_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param \WP $WP |
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | - public function run( $WP ) { |
|
| 87 | + public function run($WP) { |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | * @return void |
| 113 | 113 | */ |
| 114 | 114 | public static function wp_enqueue_scripts() { |
| 115 | - if ( apply_filters( 'EED_Single_Page_Checkout__SPCO_active', false ) ) { |
|
| 116 | - wp_register_script( 'add_new_state', ANS_ASSETS_URL . 'add_new_state.js', array( 'espresso_core', 'single_page_checkout' ), EVENT_ESPRESSO_VERSION, true ); |
|
| 117 | - wp_enqueue_script( 'add_new_state' ); |
|
| 115 | + if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) { |
|
| 116 | + wp_register_script('add_new_state', ANS_ASSETS_URL.'add_new_state.js', array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true); |
|
| 117 | + wp_enqueue_script('add_new_state'); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
@@ -128,34 +128,34 @@ discard block |
||
| 128 | 128 | * @return string |
| 129 | 129 | */ |
| 130 | 130 | // public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){ |
| 131 | - public static function display_add_new_state_micro_form( EE_Form_Section_Proper $question_group_reg_form ){ |
|
| 131 | + public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form) { |
|
| 132 | 132 | // only add the 'new_state_micro_form' when displaying reg forms, |
| 133 | 133 | // not during processing since we process the 'new_state_micro_form' in it's own AJAX request |
| 134 | - $action = EE_Registry::instance()->REQ->get( 'action', '' ); |
|
| 134 | + $action = EE_Registry::instance()->REQ->get('action', ''); |
|
| 135 | 135 | // is the "state" question in this form section? |
| 136 | - $input = $question_group_reg_form->get_subsection( 'state' ); |
|
| 137 | - if ( $action === 'process_reg_step' || $action === 'update_reg_step' ) { |
|
| 136 | + $input = $question_group_reg_form->get_subsection('state'); |
|
| 137 | + if ($action === 'process_reg_step' || $action === 'update_reg_step') { |
|
| 138 | 138 | //ok then all we need to do is make sure the input's HTML name is consistent |
| 139 | 139 | //by forcing it to set it now, like it did while getting the form for display |
| 140 | - if( $input instanceof EE_State_Select_Input ) { |
|
| 140 | + if ($input instanceof EE_State_Select_Input) { |
|
| 141 | 141 | $input->html_name(); |
| 142 | 142 | } |
| 143 | 143 | return $question_group_reg_form; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // we're only doing this for state select inputs |
| 147 | - if ( $input instanceof EE_State_Select_Input ) { |
|
| 147 | + if ($input instanceof EE_State_Select_Input) { |
|
| 148 | 148 | // grab any set values from the request |
| 149 | - $country_name = str_replace( 'state', 'nsmf_new_state_country', $input->html_name() ); |
|
| 150 | - $state_name = str_replace( 'state', 'nsmf_new_state_name', $input->html_name() ); |
|
| 151 | - $abbrv_name = str_replace( 'state', 'nsmf_new_state_abbrv', $input->html_name() ); |
|
| 152 | - $new_state_submit_id = str_replace( 'state', 'new_state', $input->html_id() ); |
|
| 149 | + $country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name()); |
|
| 150 | + $state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name()); |
|
| 151 | + $abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name()); |
|
| 152 | + $new_state_submit_id = str_replace('state', 'new_state', $input->html_id()); |
|
| 153 | 153 | $country_options = array(); |
| 154 | 154 | $countries = EEM_Country::instance()->get_all_countries(); |
| 155 | - if ( ! empty( $countries )) { |
|
| 156 | - foreach( $countries as $country ){ |
|
| 157 | - if ( $country instanceof EE_Country ) { |
|
| 158 | - $country_options[ $country->ID() ] = $country->name(); |
|
| 155 | + if ( ! empty($countries)) { |
|
| 156 | + foreach ($countries as $country) { |
|
| 157 | + if ($country instanceof EE_Country) { |
|
| 158 | + $country_options[$country->ID()] = $country->name(); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | // add hidden input to indicate that a new state is being added |
| 169 | 169 | 'add_new_state' => new EE_Hidden_Input( |
| 170 | 170 | array( |
| 171 | - 'html_name' => str_replace( 'state', 'nsmf_add_new_state', $input->html_name() ), |
|
| 172 | - 'html_id' => str_replace( 'state', 'nsmf_add_new_state', $input->html_id() ), |
|
| 171 | + 'html_name' => str_replace('state', 'nsmf_add_new_state', $input->html_name()), |
|
| 172 | + 'html_id' => str_replace('state', 'nsmf_add_new_state', $input->html_id()), |
|
| 173 | 173 | 'default' => 0 |
| 174 | 174 | ) |
| 175 | 175 | ), |
@@ -181,10 +181,10 @@ discard block |
||
| 181 | 181 | '', |
| 182 | 182 | __('click here to add a new state/province', 'event_espresso'), |
| 183 | 183 | '', |
| 184 | - 'display-' . $input->html_id(), |
|
| 184 | + 'display-'.$input->html_id(), |
|
| 185 | 185 | 'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js', |
| 186 | 186 | '', |
| 187 | - 'data-target="' . $input->html_id() . '"' |
|
| 187 | + 'data-target="'.$input->html_id().'"' |
|
| 188 | 188 | ) |
| 189 | 189 | ) |
| 190 | 190 | ), |
@@ -192,13 +192,13 @@ discard block |
||
| 192 | 192 | 'add_new_state_micro_form' =>new EE_Form_Section_HTML( |
| 193 | 193 | apply_filters( |
| 194 | 194 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form', |
| 195 | - EEH_HTML::div( '', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', 'display: none;' ) . |
|
| 196 | - EEH_HTML::h6( __('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso')) . |
|
| 197 | - EEH_HTML::ul() . |
|
| 198 | - EEH_HTML::li( __('first select the Country that your State/Province belongs to', 'event_espresso') ) . |
|
| 199 | - EEH_HTML::li( __('enter the name of your State/Province', 'event_espresso') ) . |
|
| 200 | - EEH_HTML::li( __('enter a two to six letter abbreviation for the name of your State/Province', 'event_espresso') ) . |
|
| 201 | - EEH_HTML::li( __('click the ADD button', 'event_espresso') ) . |
|
| 195 | + EEH_HTML::div('', $input->html_id().'-dv', 'ee-form-add-new-state-dv', 'display: none;'). |
|
| 196 | + EEH_HTML::h6(__('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso')). |
|
| 197 | + EEH_HTML::ul(). |
|
| 198 | + EEH_HTML::li(__('first select the Country that your State/Province belongs to', 'event_espresso')). |
|
| 199 | + EEH_HTML::li(__('enter the name of your State/Province', 'event_espresso')). |
|
| 200 | + EEH_HTML::li(__('enter a two to six letter abbreviation for the name of your State/Province', 'event_espresso')). |
|
| 201 | + EEH_HTML::li(__('click the ADD button', 'event_espresso')). |
|
| 202 | 202 | EEH_HTML::ulx() |
| 203 | 203 | ) |
| 204 | 204 | ), |
@@ -207,10 +207,10 @@ discard block |
||
| 207 | 207 | $country_options, |
| 208 | 208 | array( |
| 209 | 209 | 'html_name' => $country_name, |
| 210 | - 'html_id' => str_replace( 'state', 'nsmf_new_state_country', $input->html_id() ), |
|
| 211 | - 'html_class' => $input->html_class() . ' new-state-country', |
|
| 210 | + 'html_id' => str_replace('state', 'nsmf_new_state_country', $input->html_id()), |
|
| 211 | + 'html_class' => $input->html_class().' new-state-country', |
|
| 212 | 212 | 'html_label_text' => __('New State/Province Country', 'event_espresso'), |
| 213 | - 'default' => EE_Registry::instance()->REQ->get( $country_name, '' ), |
|
| 213 | + 'default' => EE_Registry::instance()->REQ->get($country_name, ''), |
|
| 214 | 214 | 'required' => false |
| 215 | 215 | ) |
| 216 | 216 | ), |
@@ -218,23 +218,23 @@ discard block |
||
| 218 | 218 | 'new_state_name' => new EE_Text_Input( |
| 219 | 219 | array( |
| 220 | 220 | 'html_name' => $state_name, |
| 221 | - 'html_id' => str_replace( 'state', 'nsmf_new_state_name', $input->html_id() ), |
|
| 222 | - 'html_class' => $input->html_class() . ' new-state-state', |
|
| 221 | + 'html_id' => str_replace('state', 'nsmf_new_state_name', $input->html_id()), |
|
| 222 | + 'html_class' => $input->html_class().' new-state-state', |
|
| 223 | 223 | 'html_label_text' => __('New State/Province Name', 'event_espresso'), |
| 224 | - 'default' => EE_Registry::instance()->REQ->get( $state_name, '' ), |
|
| 224 | + 'default' => EE_Registry::instance()->REQ->get($state_name, ''), |
|
| 225 | 225 | 'required' => false |
| 226 | 226 | ) |
| 227 | 227 | ), |
| 228 | - 'spacer' => new EE_Form_Section_HTML( EEH_HTML::br() ), |
|
| 228 | + 'spacer' => new EE_Form_Section_HTML(EEH_HTML::br()), |
|
| 229 | 229 | // NEW STATE NAME |
| 230 | 230 | 'new_state_abbrv' => new EE_Text_Input( |
| 231 | 231 | array( |
| 232 | 232 | 'html_name' => $abbrv_name, |
| 233 | - 'html_id' => str_replace( 'state', 'nsmf_new_state_abbrv', $input->html_id() ), |
|
| 234 | - 'html_class' => $input->html_class() . ' new-state-abbrv', |
|
| 233 | + 'html_id' => str_replace('state', 'nsmf_new_state_abbrv', $input->html_id()), |
|
| 234 | + 'html_class' => $input->html_class().' new-state-abbrv', |
|
| 235 | 235 | 'html_label_text' => __('New State/Province Abbreviation', 'event_espresso'), |
| 236 | 236 | 'html_other_attributes' => 'size="24"', |
| 237 | - 'default' => EE_Registry::instance()->REQ->get( $abbrv_name, '' ), |
|
| 237 | + 'default' => EE_Registry::instance()->REQ->get($abbrv_name, ''), |
|
| 238 | 238 | 'required' => false |
| 239 | 239 | ) |
| 240 | 240 | ), |
@@ -242,15 +242,15 @@ discard block |
||
| 242 | 242 | 'add_new_state_submit_button' => new EE_Form_Section_HTML( |
| 243 | 243 | apply_filters( |
| 244 | 244 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button', |
| 245 | - EEH_HTML::nbsp(3) . |
|
| 245 | + EEH_HTML::nbsp(3). |
|
| 246 | 246 | EEH_HTML::link( |
| 247 | 247 | '', |
| 248 | 248 | __('ADD', 'event_espresso'), |
| 249 | 249 | '', |
| 250 | - 'submit-' . $new_state_submit_id, |
|
| 250 | + 'submit-'.$new_state_submit_id, |
|
| 251 | 251 | 'ee-form-add-new-state-submit button button-secondary', |
| 252 | 252 | '', |
| 253 | - 'data-target="' . $new_state_submit_id . '"' |
|
| 253 | + 'data-target="'.$new_state_submit_id.'"' |
|
| 254 | 254 | ) |
| 255 | 255 | ) |
| 256 | 256 | ), |
@@ -258,18 +258,18 @@ discard block |
||
| 258 | 258 | 'add_new_state_extra' => new EE_Form_Section_HTML( |
| 259 | 259 | apply_filters( |
| 260 | 260 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra', |
| 261 | - EEH_HTML::br(2) . |
|
| 262 | - EEH_HTML::div( '', '', 'small-text' ) . |
|
| 263 | - EEH_HTML::strong( __('Don\'t know your State/Province Abbreviation?', 'event_espresso') ) . |
|
| 264 | - EEH_HTML::br() . |
|
| 261 | + EEH_HTML::br(2). |
|
| 262 | + EEH_HTML::div('', '', 'small-text'). |
|
| 263 | + EEH_HTML::strong(__('Don\'t know your State/Province Abbreviation?', 'event_espresso')). |
|
| 264 | + EEH_HTML::br(). |
|
| 265 | 265 | sprintf( |
| 266 | 266 | __('You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).', 'event_espresso'), |
| 267 | - EEH_HTML::link( 'http://en.wikipedia.org/wiki/ISO_3166-2', 'http://en.wikipedia.org/wiki/ISO_3166-2', '', '', 'ee-form-add-new-state-wiki-lnk' ) |
|
| 268 | - ) . |
|
| 269 | - EEH_HTML::divx() . |
|
| 270 | - EEH_HTML::br() . |
|
| 271 | - EEH_HTML::link( '', __('cancel new state/province', 'event_espresso'), '', 'hide-' . $input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '', 'data-target="' . $input->html_id() . '"' ) . |
|
| 272 | - EEH_HTML::divx() . |
|
| 267 | + EEH_HTML::link('http://en.wikipedia.org/wiki/ISO_3166-2', 'http://en.wikipedia.org/wiki/ISO_3166-2', '', '', 'ee-form-add-new-state-wiki-lnk') |
|
| 268 | + ). |
|
| 269 | + EEH_HTML::divx(). |
|
| 270 | + EEH_HTML::br(). |
|
| 271 | + EEH_HTML::link('', __('cancel new state/province', 'event_espresso'), '', 'hide-'.$input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '', 'data-target="'.$input->html_id().'"'). |
|
| 272 | + EEH_HTML::divx(). |
|
| 273 | 273 | EEH_HTML::br() |
| 274 | 274 | ) |
| 275 | 275 | ) |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | ) |
| 278 | 278 | ) |
| 279 | 279 | ); |
| 280 | - $question_group_reg_form->add_subsections( array( 'new_state_micro_form' => $new_state_micro_form ), 'state', false ); |
|
| 280 | + $question_group_reg_form->add_subsections(array('new_state_micro_form' => $new_state_micro_form), 'state', false); |
|
| 281 | 281 | } |
| 282 | 282 | return $question_group_reg_form; |
| 283 | 283 | } |
@@ -295,50 +295,50 @@ discard block |
||
| 295 | 295 | public static function add_new_state() { |
| 296 | 296 | $REQ = EE_Registry::instance()->load_core('Request_Handler'); |
| 297 | 297 | if ( |
| 298 | - $REQ->is_set( 'nsmf_add_new_state' ) |
|
| 299 | - && $REQ->get( 'nsmf_add_new_state' ) == 1 |
|
| 298 | + $REQ->is_set('nsmf_add_new_state') |
|
| 299 | + && $REQ->get('nsmf_add_new_state') == 1 |
|
| 300 | 300 | ) { |
| 301 | 301 | EE_Registry::instance()->load_model('State'); |
| 302 | 302 | // grab country ISO code, new state name, and new state abbreviation |
| 303 | - $state_country = $REQ->is_set( 'nsmf_new_state_country' ) |
|
| 304 | - ? sanitize_text_field( $REQ->get( 'nsmf_new_state_country' ) ) |
|
| 303 | + $state_country = $REQ->is_set('nsmf_new_state_country') |
|
| 304 | + ? sanitize_text_field($REQ->get('nsmf_new_state_country')) |
|
| 305 | 305 | : false; |
| 306 | - $state_name = $REQ->is_set( 'nsmf_new_state_name' ) |
|
| 307 | - ? sanitize_text_field( $REQ->get( 'nsmf_new_state_name' ) ) |
|
| 306 | + $state_name = $REQ->is_set('nsmf_new_state_name') |
|
| 307 | + ? sanitize_text_field($REQ->get('nsmf_new_state_name')) |
|
| 308 | 308 | : false; |
| 309 | - $state_abbr = $REQ->is_set( 'nsmf_new_state_abbrv' ) |
|
| 310 | - ? sanitize_text_field( $REQ->get( 'nsmf_new_state_abbrv' ) ) |
|
| 309 | + $state_abbr = $REQ->is_set('nsmf_new_state_abbrv') |
|
| 310 | + ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv')) |
|
| 311 | 311 | : false; |
| 312 | 312 | //echo '<h4>$state_country : ' . $state_country . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
| 313 | 313 | //echo '<h4>$state_name : ' . $state_name . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
| 314 | 314 | //echo '<h4>$state_abbr : ' . $state_abbr . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
| 315 | 315 | |
| 316 | - if ( $state_country && $state_name && $state_abbr ) { |
|
| 317 | - $new_state = EED_Add_New_State::save_new_state_to_db( array( |
|
| 318 | - 'CNT_ISO'=> strtoupper( $state_country ), |
|
| 319 | - 'STA_abbrev' => strtoupper( $state_abbr ), |
|
| 320 | - 'STA_name' => ucwords( $state_name ), |
|
| 316 | + if ($state_country && $state_name && $state_abbr) { |
|
| 317 | + $new_state = EED_Add_New_State::save_new_state_to_db(array( |
|
| 318 | + 'CNT_ISO'=> strtoupper($state_country), |
|
| 319 | + 'STA_abbrev' => strtoupper($state_abbr), |
|
| 320 | + 'STA_name' => ucwords($state_name), |
|
| 321 | 321 | 'STA_active' => FALSE |
| 322 | 322 | )); |
| 323 | 323 | |
| 324 | - if ( $new_state instanceof EE_State ) { |
|
| 324 | + if ($new_state instanceof EE_State) { |
|
| 325 | 325 | // clean house |
| 326 | - EE_Registry::instance()->REQ->un_set( 'nsmf_add_new_state' ); |
|
| 327 | - EE_Registry::instance()->REQ->un_set( 'nsmf_new_state_country' ); |
|
| 328 | - EE_Registry::instance()->REQ->un_set( 'nsmf_new_state_name' ); |
|
| 329 | - EE_Registry::instance()->REQ->un_set( 'nsmf_new_state_abbrv' ); |
|
| 326 | + EE_Registry::instance()->REQ->un_set('nsmf_add_new_state'); |
|
| 327 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_country'); |
|
| 328 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_name'); |
|
| 329 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv'); |
|
| 330 | 330 | |
| 331 | 331 | // get any existing new states |
| 332 | 332 | $new_states = EE_Registry::instance()->SSN->get_session_data( |
| 333 | 333 | 'nsmf_new_states' |
| 334 | 334 | ); |
| 335 | - $new_states[ $new_state->ID() ] = $new_state; |
|
| 335 | + $new_states[$new_state->ID()] = $new_state; |
|
| 336 | 336 | EE_Registry::instance()->SSN->set_session_data( |
| 337 | - array( 'nsmf_new_states' => $new_states ) |
|
| 337 | + array('nsmf_new_states' => $new_states) |
|
| 338 | 338 | ); |
| 339 | 339 | |
| 340 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
| 341 | - echo json_encode( array( |
|
| 340 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 341 | + echo json_encode(array( |
|
| 342 | 342 | 'success' => TRUE, |
| 343 | 343 | 'id' => $new_state->ID(), |
| 344 | 344 | 'name' => $new_state->name(), |
@@ -353,12 +353,12 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | } else { |
| 356 | - $error = __( 'A new State/Province could not be added because invalid or missing data was received.', 'event_espresso' ); |
|
| 357 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
| 358 | - echo json_encode( array( 'error' => $error )); |
|
| 356 | + $error = __('A new State/Province could not be added because invalid or missing data was received.', 'event_espresso'); |
|
| 357 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 358 | + echo json_encode(array('error' => $error)); |
|
| 359 | 359 | exit(); |
| 360 | 360 | } else { |
| 361 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 361 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | } |
@@ -376,11 +376,11 @@ discard block |
||
| 376 | 376 | * @param array $request_params |
| 377 | 377 | * @return array |
| 378 | 378 | */ |
| 379 | - public static function filter_checkout_request_params ( $request_params ) { |
|
| 380 | - foreach ( $request_params as $form_section ) { |
|
| 381 | - if ( is_array( $form_section )) { |
|
| 382 | - EED_Add_New_State::unset_new_state_request_params( $form_section ); |
|
| 383 | - EED_Add_New_State::filter_checkout_request_params( $form_section ); |
|
| 379 | + public static function filter_checkout_request_params($request_params) { |
|
| 380 | + foreach ($request_params as $form_section) { |
|
| 381 | + if (is_array($form_section)) { |
|
| 382 | + EED_Add_New_State::unset_new_state_request_params($form_section); |
|
| 383 | + EED_Add_New_State::filter_checkout_request_params($form_section); |
|
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | return $request_params; |
@@ -395,12 +395,12 @@ discard block |
||
| 395 | 395 | * @param array $request_params |
| 396 | 396 | * @return boolean |
| 397 | 397 | */ |
| 398 | - public static function unset_new_state_request_params ( $request_params ) { |
|
| 399 | - unset( $request_params[ 'new_state_micro_form' ] ); |
|
| 400 | - unset( $request_params[ 'new_state_micro_add_new_state' ] ); |
|
| 401 | - unset( $request_params[ 'new_state_micro_new_state_country' ] ); |
|
| 402 | - unset( $request_params[ 'new_state_micro_new_state_name' ] ); |
|
| 403 | - unset( $request_params[ 'new_state_micro_new_state_abbrv' ] ); |
|
| 398 | + public static function unset_new_state_request_params($request_params) { |
|
| 399 | + unset($request_params['new_state_micro_form']); |
|
| 400 | + unset($request_params['new_state_micro_add_new_state']); |
|
| 401 | + unset($request_params['new_state_micro_new_state_country']); |
|
| 402 | + unset($request_params['new_state_micro_new_state_name']); |
|
| 403 | + unset($request_params['new_state_micro_new_state_abbrv']); |
|
| 404 | 404 | return $request_params; |
| 405 | 405 | } |
| 406 | 406 | |
@@ -413,25 +413,25 @@ discard block |
||
| 413 | 413 | * @param array $props_n_values |
| 414 | 414 | * @return boolean |
| 415 | 415 | */ |
| 416 | - public static function save_new_state_to_db ( $props_n_values = array() ) { |
|
| 416 | + public static function save_new_state_to_db($props_n_values = array()) { |
|
| 417 | 417 | // EEH_Debug_Tools::printr( $props_n_values, '$props_n_values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 418 | - $existing_state = EEM_State::instance()->get_all( array( $props_n_values, 'limit' => 1 )); |
|
| 419 | - if ( ! empty( $existing_state )) { |
|
| 420 | - return array_pop( $existing_state ); |
|
| 418 | + $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1)); |
|
| 419 | + if ( ! empty($existing_state)) { |
|
| 420 | + return array_pop($existing_state); |
|
| 421 | 421 | } |
| 422 | - $new_state = EE_State::new_instance( $props_n_values ); |
|
| 423 | - if ( $new_state instanceof EE_State ) { |
|
| 422 | + $new_state = EE_State::new_instance($props_n_values); |
|
| 423 | + if ($new_state instanceof EE_State) { |
|
| 424 | 424 | // if not non-ajax admin |
| 425 | - $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(); |
|
| 425 | + $new_state_key = 'new-state-added-'.$new_state->country_iso().'-'.$new_state->abbrev(); |
|
| 426 | 426 | $new_state_notice = sprintf( |
| 427 | - __( 'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', 'event_espresso' ), |
|
| 428 | - '<b>' . $new_state->name() . '</b>', |
|
| 429 | - '<b>' . $new_state->abbrev() . '</b>', |
|
| 430 | - '<b>' . $new_state->country()->name() . '</b>', |
|
| 431 | - '<a href="' . add_query_arg( array( 'page' => 'espresso_general_settings', 'action' => 'country_settings', 'country' => $new_state->country_iso() ), admin_url( 'admin.php' )) . '">' . __( 'Event Espresso - General Settings > Countries Tab', 'event_espresso' ) . '</a>', |
|
| 427 | + __('A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', 'event_espresso'), |
|
| 428 | + '<b>'.$new_state->name().'</b>', |
|
| 429 | + '<b>'.$new_state->abbrev().'</b>', |
|
| 430 | + '<b>'.$new_state->country()->name().'</b>', |
|
| 431 | + '<a href="'.add_query_arg(array('page' => 'espresso_general_settings', 'action' => 'country_settings', 'country' => $new_state->country_iso()), admin_url('admin.php')).'">'.__('Event Espresso - General Settings > Countries Tab', 'event_espresso').'</a>', |
|
| 432 | 432 | '<br />' |
| 433 | 433 | ); |
| 434 | - EE_Error::add_persistent_admin_notice( $new_state_key, $new_state_notice ); |
|
| 434 | + EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice); |
|
| 435 | 435 | $new_state->save(); |
| 436 | 436 | EEM_State::instance()->reset_cached_states(); |
| 437 | 437 | return $new_state; |
@@ -450,22 +450,22 @@ discard block |
||
| 450 | 450 | * @param array $cols_n_values |
| 451 | 451 | * @return boolean |
| 452 | 452 | */ |
| 453 | - public static function update_country_settings( $CNT_ISO = '', $STA_ID = '', $cols_n_values = array() ) { |
|
| 454 | - $CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : FALSE; |
|
| 455 | - if ( ! $CNT_ISO ) { |
|
| 456 | - EE_Error::add_error( __( 'An invalid or missing Country ISO Code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 453 | + public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array()) { |
|
| 454 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : FALSE; |
|
| 455 | + if ( ! $CNT_ISO) { |
|
| 456 | + EE_Error::add_error(__('An invalid or missing Country ISO Code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 457 | 457 | } |
| 458 | - $STA_abbrev = is_array( $cols_n_values ) && isset( $cols_n_values['STA_abbrev'] ) ? $cols_n_values['STA_abbrev'] : FALSE; |
|
| 459 | - if ( ! $STA_abbrev && ! empty( $STA_ID )) { |
|
| 460 | - $state = EEM_State::instance()->get_one_by_ID( $STA_ID ); |
|
| 461 | - if ( $state instanceof EE_State ) { |
|
| 458 | + $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev'] : FALSE; |
|
| 459 | + if ( ! $STA_abbrev && ! empty($STA_ID)) { |
|
| 460 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
| 461 | + if ($state instanceof EE_State) { |
|
| 462 | 462 | $STA_abbrev = $state->abbrev(); |
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | - if ( ! $STA_abbrev ) { |
|
| 466 | - EE_Error::add_error( __( 'An invalid or missing State Abbreviation was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 465 | + if ( ! $STA_abbrev) { |
|
| 466 | + EE_Error::add_error(__('An invalid or missing State Abbreviation was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 467 | 467 | } |
| 468 | - EE_Error::dismiss_persistent_admin_notice( $CNT_ISO . '-' . $STA_abbrev, TRUE, TRUE ); |
|
| 468 | + EE_Error::dismiss_persistent_admin_notice($CNT_ISO.'-'.$STA_abbrev, TRUE, TRUE); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | |
@@ -481,19 +481,19 @@ discard block |
||
| 481 | 481 | * @param $answer |
| 482 | 482 | * @return bool |
| 483 | 483 | */ |
| 484 | - public static function inject_new_reg_state_into_options( $state_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer ) { |
|
| 485 | - if ( $answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_state ) { |
|
| 484 | + public static function inject_new_reg_state_into_options($state_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer) { |
|
| 485 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_state) { |
|
| 486 | 486 | $STA_ID = $answer->value(); |
| 487 | - if ( ! empty( $STA_ID ) ) { |
|
| 488 | - $state = EEM_State::instance()->get_one_by_ID( $STA_ID ); |
|
| 489 | - if ( $state instanceof EE_State ) { |
|
| 487 | + if ( ! empty($STA_ID)) { |
|
| 488 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
| 489 | + if ($state instanceof EE_State) { |
|
| 490 | 490 | $country = $state->country(); |
| 491 | - if ( $country instanceof EE_Country ) { |
|
| 492 | - if ( ! isset( $state_options[ $country->name() ] )) { |
|
| 493 | - $state_options[ $country->name() ] = array(); |
|
| 491 | + if ($country instanceof EE_Country) { |
|
| 492 | + if ( ! isset($state_options[$country->name()])) { |
|
| 493 | + $state_options[$country->name()] = array(); |
|
| 494 | 494 | } |
| 495 | - if ( ! isset( $state_options[ $country->name() ][ $STA_ID ] )) { |
|
| 496 | - $state_options[ $country->name() ][ $STA_ID ] = $state->name(); |
|
| 495 | + if ( ! isset($state_options[$country->name()][$STA_ID])) { |
|
| 496 | + $state_options[$country->name()][$STA_ID] = $state->name(); |
|
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | 499 | } |
@@ -515,14 +515,14 @@ discard block |
||
| 515 | 515 | * @param $answer |
| 516 | 516 | * @return bool |
| 517 | 517 | */ |
| 518 | - public static function inject_new_reg_country_into_options( $country_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer ) { |
|
| 519 | - if ( $answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_country ) { |
|
| 518 | + public static function inject_new_reg_country_into_options($country_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer) { |
|
| 519 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_country) { |
|
| 520 | 520 | $CNT_ISO = $answer->value(); |
| 521 | - if ( ! empty( $CNT_ISO ) ) { |
|
| 522 | - $country = EEM_Country::instance()->get_one_by_ID( $CNT_ISO ); |
|
| 523 | - if ( $country instanceof EE_Country ) { |
|
| 524 | - if ( ! isset( $country_options[ $CNT_ISO ] ) ) { |
|
| 525 | - $country_options[ $CNT_ISO ] = $country->name(); |
|
| 521 | + if ( ! empty($CNT_ISO)) { |
|
| 522 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
| 523 | + if ($country instanceof EE_Country) { |
|
| 524 | + if ( ! isset($country_options[$CNT_ISO])) { |
|
| 525 | + $country_options[$CNT_ISO] = $country->name(); |
|
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | } |
@@ -539,14 +539,14 @@ discard block |
||
| 539 | 539 | * @param EE_State[] $state_options |
| 540 | 540 | * @return boolean |
| 541 | 541 | */ |
| 542 | - public static function state_options( $state_options = array() ) { |
|
| 542 | + public static function state_options($state_options = array()) { |
|
| 543 | 543 | $new_states = EED_Add_New_State::_get_new_states(); |
| 544 | - foreach ( $new_states as $new_state ) { |
|
| 544 | + foreach ($new_states as $new_state) { |
|
| 545 | 545 | if ( |
| 546 | 546 | $new_state instanceof EE_State |
| 547 | 547 | && $new_state->country() instanceof EE_Country |
| 548 | 548 | ) { |
| 549 | - $state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name(); |
|
| 549 | + $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name(); |
|
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | 552 | return $state_options; |
@@ -562,12 +562,12 @@ discard block |
||
| 562 | 562 | */ |
| 563 | 563 | protected static function _get_new_states() { |
| 564 | 564 | $new_states = array(); |
| 565 | - if ( EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
| 565 | + if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 566 | 566 | $new_states = EE_Registry::instance()->SSN->get_session_data( |
| 567 | 567 | 'nsmf_new_states' |
| 568 | 568 | ); |
| 569 | 569 | } |
| 570 | - return is_array( $new_states ) ? $new_states : array(); |
|
| 570 | + return is_array($new_states) ? $new_states : array(); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | |
@@ -579,14 +579,14 @@ discard block |
||
| 579 | 579 | * @param EE_Country[] $country_options |
| 580 | 580 | * @return boolean |
| 581 | 581 | */ |
| 582 | - public static function country_options( $country_options = array() ) { |
|
| 582 | + public static function country_options($country_options = array()) { |
|
| 583 | 583 | $new_states = EED_Add_New_State::_get_new_states(); |
| 584 | - foreach ( $new_states as $new_state ) { |
|
| 584 | + foreach ($new_states as $new_state) { |
|
| 585 | 585 | if ( |
| 586 | 586 | $new_state instanceof EE_State |
| 587 | 587 | && $new_state->country() instanceof EE_Country |
| 588 | 588 | ) { |
| 589 | - $country_options[ $new_state->country()->ID() ] = $new_state->country()->name(); |
|
| 589 | + $country_options[$new_state->country()->ID()] = $new_state->country()->name(); |
|
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | return $country_options; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @subpackage |
| 9 | 9 | * @author Mike Nelson |
| 10 | 10 | */ |
| 11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
| 11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * the input's name attribute |
@@ -143,54 +143,54 @@ discard block |
||
| 143 | 143 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
| 144 | 144 | * } |
| 145 | 145 | */ |
| 146 | - public function __construct( $input_args = array() ){ |
|
| 147 | - $input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
| 146 | + public function __construct($input_args = array()) { |
|
| 147 | + $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
| 148 | 148 | // the following properties must be cast as arrays |
| 149 | - if ( isset( $input_args['validation_strategies'] ) ) { |
|
| 150 | - foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) { |
|
| 151 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
| 152 | - $this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy; |
|
| 149 | + if (isset($input_args['validation_strategies'])) { |
|
| 150 | + foreach ((array) $input_args['validation_strategies'] as $validation_strategy) { |
|
| 151 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
| 152 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | - unset( $input_args['validation_strategies'] ); |
|
| 155 | + unset($input_args['validation_strategies']); |
|
| 156 | 156 | } |
| 157 | 157 | // loop thru incoming options |
| 158 | - foreach( $input_args as $key => $value ) { |
|
| 158 | + foreach ($input_args as $key => $value) { |
|
| 159 | 159 | // add underscore to $key to match property names |
| 160 | - $_key = '_' . $key; |
|
| 161 | - if ( property_exists( $this, $_key )) { |
|
| 160 | + $_key = '_'.$key; |
|
| 161 | + if (property_exists($this, $_key)) { |
|
| 162 | 162 | $this->{$_key} = $value; |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | // ensure that "required" is set correctly |
| 166 | 166 | $this->set_required( |
| 167 | - $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) |
|
| 168 | - ? $input_args[ 'required_validation_error_message' ] |
|
| 167 | + $this->_required, isset($input_args['required_validation_error_message']) |
|
| 168 | + ? $input_args['required_validation_error_message'] |
|
| 169 | 169 | : null |
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | 172 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
| 173 | 173 | |
| 174 | 174 | $this->_display_strategy->_construct_finalize($this); |
| 175 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
| 175 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
| 176 | 176 | $validation_strategy->_construct_finalize($this); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if( ! $this->_normalization_strategy){ |
|
| 179 | + if ( ! $this->_normalization_strategy) { |
|
| 180 | 180 | $this->_normalization_strategy = new EE_Text_Normalization(); |
| 181 | 181 | } |
| 182 | 182 | $this->_normalization_strategy->_construct_finalize($this); |
| 183 | 183 | |
| 184 | 184 | //at least we can use the normalization strategy to populate the default |
| 185 | - if( isset( $input_args[ 'default' ] ) ) { |
|
| 186 | - $this->set_default( $input_args[ 'default' ] ); |
|
| 185 | + if (isset($input_args['default'])) { |
|
| 186 | + $this->set_default($input_args['default']); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
| 189 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
| 190 | 190 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
| 191 | 191 | } |
| 192 | 192 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
| 193 | - parent::__construct( $input_args ); |
|
| 193 | + parent::__construct($input_args); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @throws \EE_Error |
| 203 | 203 | */ |
| 204 | - protected function _set_default_html_name_if_empty(){ |
|
| 205 | - if( ! $this->_html_name){ |
|
| 204 | + protected function _set_default_html_name_if_empty() { |
|
| 205 | + if ( ! $this->_html_name) { |
|
| 206 | 206 | $this->_html_name = $this->name(); |
| 207 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
| 208 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
| 207 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
| 208 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | } |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function _construct_finalize($parent_form_section, $name) { |
| 221 | 221 | parent::_construct_finalize($parent_form_section, $name); |
| 222 | - if( $this->_html_label === null && $this->_html_label_text === null ){ |
|
| 223 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
| 222 | + if ($this->_html_label === null && $this->_html_label_text === null) { |
|
| 223 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
| 224 | 224 | } |
| 225 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
| 225 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -230,9 +230,9 @@ discard block |
||
| 230 | 230 | * @return EE_Display_Strategy_Base |
| 231 | 231 | * @throws EE_Error |
| 232 | 232 | */ |
| 233 | - protected function _get_display_strategy(){ |
|
| 233 | + protected function _get_display_strategy() { |
|
| 234 | 234 | $this->ensure_construct_finalized_called(); |
| 235 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
| 235 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
| 236 | 236 | throw new EE_Error( |
| 237 | 237 | sprintf( |
| 238 | 238 | __( |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $this->html_id() |
| 244 | 244 | ) |
| 245 | 245 | ); |
| 246 | - }else{ |
|
| 246 | + } else { |
|
| 247 | 247 | return $this->_display_strategy; |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * Sets the display strategy. |
| 252 | 252 | * @param EE_Display_Strategy_Base $strategy |
| 253 | 253 | */ |
| 254 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
| 254 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
| 255 | 255 | $this->_display_strategy = $strategy; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * Sets the sanitization strategy |
| 260 | 260 | * @param EE_Normalization_Strategy_Base $strategy |
| 261 | 261 | */ |
| 262 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
| 262 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
| 263 | 263 | $this->_normalization_strategy = $strategy; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -285,14 +285,14 @@ discard block |
||
| 285 | 285 | * Gets the display strategy for this input |
| 286 | 286 | * @return EE_Display_Strategy_Base |
| 287 | 287 | */ |
| 288 | - public function get_display_strategy(){ |
|
| 288 | + public function get_display_strategy() { |
|
| 289 | 289 | return $this->_display_strategy; |
| 290 | 290 | } |
| 291 | 291 | /** |
| 292 | 292 | * Overwrites the display strategy |
| 293 | 293 | * @param EE_Display_Strategy_Base $display_strategy |
| 294 | 294 | */ |
| 295 | - public function set_display_strategy($display_strategy){ |
|
| 295 | + public function set_display_strategy($display_strategy) { |
|
| 296 | 296 | $this->_display_strategy = $display_strategy; |
| 297 | 297 | $this->_display_strategy->_construct_finalize($this); |
| 298 | 298 | } |
@@ -300,14 +300,14 @@ discard block |
||
| 300 | 300 | * Gets the normalization strategy set on this input |
| 301 | 301 | * @return EE_Normalization_Strategy_Base |
| 302 | 302 | */ |
| 303 | - public function get_normalization_strategy(){ |
|
| 303 | + public function get_normalization_strategy() { |
|
| 304 | 304 | return $this->_normalization_strategy; |
| 305 | 305 | } |
| 306 | 306 | /** |
| 307 | 307 | * Overwrites the normalization strategy |
| 308 | 308 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
| 309 | 309 | */ |
| 310 | - public function set_normalization_strategy($normalization_strategy){ |
|
| 310 | + public function set_normalization_strategy($normalization_strategy) { |
|
| 311 | 311 | $this->_normalization_strategy = $normalization_strategy; |
| 312 | 312 | $this->_normalization_strategy->_construct_finalize($this); |
| 313 | 313 | } |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * Returns all teh validation strategies which apply to this field, numerically indexed |
| 317 | 317 | * @return EE_Validation_Strategy_Base[] |
| 318 | 318 | */ |
| 319 | - public function get_validation_strategies(){ |
|
| 319 | + public function get_validation_strategies() { |
|
| 320 | 320 | return $this->_validation_strategies; |
| 321 | 321 | } |
| 322 | 322 | |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | * @param EE_Validation_Strategy_Base $validation_strategy |
| 328 | 328 | * @return void |
| 329 | 329 | */ |
| 330 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
| 331 | - $validation_strategy->_construct_finalize( $this ); |
|
| 330 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
| 331 | + $validation_strategy->_construct_finalize($this); |
|
| 332 | 332 | $this->_validation_strategies[] = $validation_strategy; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -339,8 +339,8 @@ discard block |
||
| 339 | 339 | * @param EE_Validation_Strategy_Base $validation_strategy |
| 340 | 340 | * @return void |
| 341 | 341 | */ |
| 342 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
| 343 | - $this->_add_validation_strategy( $validation_strategy ); |
|
| 342 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
| 343 | + $this->_add_validation_strategy($validation_strategy); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | |
@@ -350,13 +350,13 @@ discard block |
||
| 350 | 350 | * |
| 351 | 351 | * @param string $validation_strategy_classname |
| 352 | 352 | */ |
| 353 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
| 354 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
| 355 | - if( |
|
| 353 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
| 354 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
| 355 | + if ( |
|
| 356 | 356 | $validation_strategy instanceof $validation_strategy_classname |
| 357 | - || is_subclass_of( $validation_strategy, $validation_strategy_classname ) |
|
| 357 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
| 358 | 358 | ) { |
| 359 | - unset( $this->_validation_strategies[ $key ] ); |
|
| 359 | + unset($this->_validation_strategies[$key]); |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | } |
@@ -369,12 +369,12 @@ discard block |
||
| 369 | 369 | * @param array $validation_strategy_classnames |
| 370 | 370 | * @return bool |
| 371 | 371 | */ |
| 372 | - public function has_validation_strategy( $validation_strategy_classnames ) { |
|
| 373 | - $validation_strategy_classnames = is_array( $validation_strategy_classnames ) |
|
| 372 | + public function has_validation_strategy($validation_strategy_classnames) { |
|
| 373 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
| 374 | 374 | ? $validation_strategy_classnames |
| 375 | - : array( $validation_strategy_classnames ); |
|
| 376 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
| 377 | - if( in_array( $key, $validation_strategy_classnames ) ) { |
|
| 375 | + : array($validation_strategy_classnames); |
|
| 376 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
| 377 | + if (in_array($key, $validation_strategy_classnames)) { |
|
| 378 | 378 | return true; |
| 379 | 379 | } |
| 380 | 380 | } |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | * Gets the HTML |
| 388 | 388 | * @return string |
| 389 | 389 | */ |
| 390 | - public function get_html(){ |
|
| 390 | + public function get_html() { |
|
| 391 | 391 | return $this->_parent_section->get_html_for_input($this); |
| 392 | 392 | } |
| 393 | 393 | |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * @return string |
| 402 | 402 | * @throws \EE_Error |
| 403 | 403 | */ |
| 404 | - public function get_html_for_input(){ |
|
| 404 | + public function get_html_for_input() { |
|
| 405 | 405 | |
| 406 | 406 | return $this->_get_display_strategy()->display(); |
| 407 | 407 | } |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | * @return string |
| 413 | 413 | */ |
| 414 | 414 | public function html_other_attributes() { |
| 415 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
| 415 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | /** |
| 421 | 421 | * @param string $html_other_attributes |
| 422 | 422 | */ |
| 423 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
| 423 | + public function set_html_other_attributes($html_other_attributes) { |
|
| 424 | 424 | $this->_html_other_attributes = $html_other_attributes; |
| 425 | 425 | } |
| 426 | 426 | |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | * according to the form section's layout strategy |
| 430 | 430 | * @return string |
| 431 | 431 | */ |
| 432 | - public function get_html_for_label(){ |
|
| 432 | + public function get_html_for_label() { |
|
| 433 | 433 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
| 434 | 434 | } |
| 435 | 435 | /** |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | * according to the form section's layout strategy |
| 438 | 438 | * @return string |
| 439 | 439 | */ |
| 440 | - public function get_html_for_errors(){ |
|
| 440 | + public function get_html_for_errors() { |
|
| 441 | 441 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
| 442 | 442 | } |
| 443 | 443 | /** |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | * according to the form section's layout strategy |
| 446 | 446 | * @return string |
| 447 | 447 | */ |
| 448 | - public function get_html_for_help(){ |
|
| 448 | + public function get_html_for_help() { |
|
| 449 | 449 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
| 450 | 450 | } |
| 451 | 451 | /** |
@@ -454,18 +454,18 @@ discard block |
||
| 454 | 454 | * @return boolean |
| 455 | 455 | */ |
| 456 | 456 | protected function _validate() { |
| 457 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
| 458 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
| 459 | - try{ |
|
| 457 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
| 458 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
| 459 | + try { |
|
| 460 | 460 | $validation_strategy->validate($this->normalized_value()); |
| 461 | - }catch(EE_Validation_Error $e){ |
|
| 461 | + } catch (EE_Validation_Error $e) { |
|
| 462 | 462 | $this->add_validation_error($e); |
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | - if( $this->get_validation_errors()){ |
|
| 466 | + if ($this->get_validation_errors()) { |
|
| 467 | 467 | return false; |
| 468 | - }else{ |
|
| 468 | + } else { |
|
| 469 | 469 | return true; |
| 470 | 470 | } |
| 471 | 471 | } |
@@ -479,8 +479,8 @@ discard block |
||
| 479 | 479 | * @param string $value |
| 480 | 480 | * @return null|string |
| 481 | 481 | */ |
| 482 | - private function _sanitize( $value ) { |
|
| 483 | - return $value !== null ? stripslashes( html_entity_decode( trim( $value ) ) ) : null; |
|
| 482 | + private function _sanitize($value) { |
|
| 483 | + return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | |
@@ -494,25 +494,25 @@ discard block |
||
| 494 | 494 | * @return boolean whether or not there was an error |
| 495 | 495 | * @throws \EE_Error |
| 496 | 496 | */ |
| 497 | - protected function _normalize( $req_data ) { |
|
| 497 | + protected function _normalize($req_data) { |
|
| 498 | 498 | //any existing validation errors don't apply so clear them |
| 499 | 499 | $this->_validation_errors = array(); |
| 500 | 500 | try { |
| 501 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
| 501 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
| 502 | 502 | //super simple sanitization for now |
| 503 | - if ( is_array( $raw_input )) { |
|
| 503 | + if (is_array($raw_input)) { |
|
| 504 | 504 | $raw_value = array(); |
| 505 | - foreach( $raw_input as $key => $value ) { |
|
| 506 | - $raw_value[ $key ] = $this->_sanitize( $value ); |
|
| 505 | + foreach ($raw_input as $key => $value) { |
|
| 506 | + $raw_value[$key] = $this->_sanitize($value); |
|
| 507 | 507 | } |
| 508 | - $this->_set_raw_value( $raw_value ); |
|
| 508 | + $this->_set_raw_value($raw_value); |
|
| 509 | 509 | } else { |
| 510 | - $this->_set_raw_value( $this->_sanitize( $raw_input ) ); |
|
| 510 | + $this->_set_raw_value($this->_sanitize($raw_input)); |
|
| 511 | 511 | } |
| 512 | 512 | //we want to mostly leave the input alone in case we need to re-display it to the user |
| 513 | - $this->_set_normalized_value( $this->_normalization_strategy->normalize( $this->raw_value() ) ); |
|
| 514 | - } catch ( EE_Validation_Error $e ) { |
|
| 515 | - $this->add_validation_error( $e ); |
|
| 513 | + $this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value())); |
|
| 514 | + } catch (EE_Validation_Error $e) { |
|
| 515 | + $this->add_validation_error($e); |
|
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | /** |
| 522 | 522 | * @return string |
| 523 | 523 | */ |
| 524 | - public function html_name(){ |
|
| 524 | + public function html_name() { |
|
| 525 | 525 | $this->_set_default_html_name_if_empty(); |
| 526 | 526 | return $this->_html_name; |
| 527 | 527 | } |
@@ -531,8 +531,8 @@ discard block |
||
| 531 | 531 | /** |
| 532 | 532 | * @return string |
| 533 | 533 | */ |
| 534 | - public function html_label_id(){ |
|
| 535 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
| 534 | + public function html_label_id() { |
|
| 535 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | /** |
| 541 | 541 | * @return string |
| 542 | 542 | */ |
| 543 | - public function html_label_class(){ |
|
| 543 | + public function html_label_class() { |
|
| 544 | 544 | return $this->_html_label_class; |
| 545 | 545 | } |
| 546 | 546 | |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | /** |
| 550 | 550 | * @return string |
| 551 | 551 | */ |
| 552 | - public function html_label_style(){ |
|
| 552 | + public function html_label_style() { |
|
| 553 | 553 | return $this->_html_label_style; |
| 554 | 554 | } |
| 555 | 555 | |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | /** |
| 559 | 559 | * @return string |
| 560 | 560 | */ |
| 561 | - public function html_label_text(){ |
|
| 561 | + public function html_label_text() { |
|
| 562 | 562 | return $this->_html_label_text; |
| 563 | 563 | } |
| 564 | 564 | |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | /** |
| 568 | 568 | * @return string |
| 569 | 569 | */ |
| 570 | - public function html_help_text(){ |
|
| 570 | + public function html_help_text() { |
|
| 571 | 571 | return $this->_html_help_text; |
| 572 | 572 | } |
| 573 | 573 | |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | /** |
| 577 | 577 | * @return string |
| 578 | 578 | */ |
| 579 | - public function html_help_class(){ |
|
| 579 | + public function html_help_class() { |
|
| 580 | 580 | return $this->_html_help_class; |
| 581 | 581 | } |
| 582 | 582 | |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | /** |
| 586 | 586 | * @return string |
| 587 | 587 | */ |
| 588 | - public function html_help_style(){ |
|
| 588 | + public function html_help_style() { |
|
| 589 | 589 | return $this->_html_style; |
| 590 | 590 | } |
| 591 | 591 | /** |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | * in which case, we would have stored the malicious content to our database. |
| 599 | 599 | * @return string |
| 600 | 600 | */ |
| 601 | - public function raw_value(){ |
|
| 601 | + public function raw_value() { |
|
| 602 | 602 | return $this->_raw_value; |
| 603 | 603 | } |
| 604 | 604 | /** |
@@ -606,15 +606,15 @@ discard block |
||
| 606 | 606 | * it escapes all html entities |
| 607 | 607 | * @return string |
| 608 | 608 | */ |
| 609 | - public function raw_value_in_form(){ |
|
| 610 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
| 609 | + public function raw_value_in_form() { |
|
| 610 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
| 611 | 611 | } |
| 612 | 612 | /** |
| 613 | 613 | * returns the value after it's been sanitized, and then converted into it's proper type |
| 614 | 614 | * in PHP. Eg, a string, an int, an array, |
| 615 | 615 | * @return mixed |
| 616 | 616 | */ |
| 617 | - public function normalized_value(){ |
|
| 617 | + public function normalized_value() { |
|
| 618 | 618 | return $this->_normalized_value; |
| 619 | 619 | } |
| 620 | 620 | |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | * the best thing to display |
| 625 | 625 | * @return string |
| 626 | 626 | */ |
| 627 | - public function pretty_value(){ |
|
| 627 | + public function pretty_value() { |
|
| 628 | 628 | return $this->_normalized_value; |
| 629 | 629 | } |
| 630 | 630 | /** |
@@ -643,19 +643,19 @@ discard block |
||
| 643 | 643 | }</code> |
| 644 | 644 | * @return array |
| 645 | 645 | */ |
| 646 | - public function get_jquery_validation_rules(){ |
|
| 646 | + public function get_jquery_validation_rules() { |
|
| 647 | 647 | $jquery_validation_js = array(); |
| 648 | 648 | $jquery_validation_rules = array(); |
| 649 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
| 649 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
| 650 | 650 | $jquery_validation_rules = array_replace_recursive( |
| 651 | 651 | $jquery_validation_rules, |
| 652 | 652 | $validation_strategy->get_jquery_validation_rule_array() |
| 653 | 653 | ); |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - if(! empty($jquery_validation_rules)){ |
|
| 657 | - foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) { |
|
| 658 | - $jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules; |
|
| 656 | + if ( ! empty($jquery_validation_rules)) { |
|
| 657 | + foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
|
| 658 | + $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | return $jquery_validation_js; |
@@ -667,16 +667,16 @@ discard block |
||
| 667 | 667 | * @param mixed $value |
| 668 | 668 | * @return void |
| 669 | 669 | */ |
| 670 | - public function set_default($value){ |
|
| 671 | - $this->_set_normalized_value( $value ); |
|
| 672 | - $this->_set_raw_value( $value ); |
|
| 670 | + public function set_default($value) { |
|
| 671 | + $this->_set_normalized_value($value); |
|
| 672 | + $this->_set_raw_value($value); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /** |
| 676 | 676 | * Sets the normalized value on this input |
| 677 | 677 | * @param mixed $value |
| 678 | 678 | */ |
| 679 | - protected function _set_normalized_value( $value ) { |
|
| 679 | + protected function _set_normalized_value($value) { |
|
| 680 | 680 | $this->_normalized_value = $value; |
| 681 | 681 | } |
| 682 | 682 | |
@@ -684,8 +684,8 @@ discard block |
||
| 684 | 684 | * Sets the raw value on this input (ie, exactly as the user submitted it) |
| 685 | 685 | * @param mixed $value |
| 686 | 686 | */ |
| 687 | - protected function _set_raw_value( $value ) { |
|
| 688 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
| 687 | + protected function _set_raw_value($value) { |
|
| 688 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | * @param string $label |
| 694 | 694 | * @return void |
| 695 | 695 | */ |
| 696 | - public function set_html_label_text($label){ |
|
| 696 | + public function set_html_label_text($label) { |
|
| 697 | 697 | $this->_html_label_text = $label; |
| 698 | 698 | } |
| 699 | 699 | |
@@ -707,13 +707,13 @@ discard block |
||
| 707 | 707 | * @param boolean $required boolean |
| 708 | 708 | * @param null $required_text |
| 709 | 709 | */ |
| 710 | - public function set_required($required = true, $required_text = NULL ){ |
|
| 711 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
| 710 | + public function set_required($required = true, $required_text = NULL) { |
|
| 711 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
| 712 | 712 | //whether $required is a string or a boolean, we want to add a required validation strategy |
| 713 | - if ( $required ) { |
|
| 714 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
| 713 | + if ($required) { |
|
| 714 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
| 715 | 715 | } else { |
| 716 | - $this->remove_validation_strategy( 'EE_Required_Validation_Strategy' ); |
|
| 716 | + $this->remove_validation_strategy('EE_Required_Validation_Strategy'); |
|
| 717 | 717 | } |
| 718 | 718 | $this->_required = $required; |
| 719 | 719 | } |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | * Returns whether or not this field is required |
| 722 | 722 | * @return boolean |
| 723 | 723 | */ |
| 724 | - public function required(){ |
|
| 724 | + public function required() { |
|
| 725 | 725 | return $this->_required; |
| 726 | 726 | } |
| 727 | 727 | |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | /** |
| 731 | 731 | * @param string $required_css_class |
| 732 | 732 | */ |
| 733 | - public function set_required_css_class( $required_css_class ) { |
|
| 733 | + public function set_required_css_class($required_css_class) { |
|
| 734 | 734 | $this->_required_css_class = $required_css_class; |
| 735 | 735 | } |
| 736 | 736 | |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | * Sets the help text, in case |
| 750 | 750 | * @param string $text |
| 751 | 751 | */ |
| 752 | - public function set_html_help_text($text){ |
|
| 752 | + public function set_html_help_text($text) { |
|
| 753 | 753 | $this->_html_help_text = $text; |
| 754 | 754 | } |
| 755 | 755 | /** |
@@ -761,9 +761,9 @@ discard block |
||
| 761 | 761 | public function clean_sensitive_data() { |
| 762 | 762 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
| 763 | 763 | //if we need more logic than this we'll make a strategy for it |
| 764 | - if( $this->_sensitive_data_removal_strategy && |
|
| 765 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
| 766 | - $this->_set_raw_value( null ); |
|
| 764 | + if ($this->_sensitive_data_removal_strategy && |
|
| 765 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
| 766 | + $this->_set_raw_value(null); |
|
| 767 | 767 | } |
| 768 | 768 | //and clean the normalized value according to the appropriate strategy |
| 769 | 769 | $this->_set_normalized_value( |
@@ -780,10 +780,10 @@ discard block |
||
| 780 | 780 | * @param string $button_size |
| 781 | 781 | * @param string $other_attributes |
| 782 | 782 | */ |
| 783 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
| 783 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
| 784 | 784 | $button_css_attributes = 'button'; |
| 785 | 785 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
| 786 | - switch ( $button_size ) { |
|
| 786 | + switch ($button_size) { |
|
| 787 | 787 | case 'xs' : |
| 788 | 788 | case 'extra-small' : |
| 789 | 789 | $button_css_attributes .= ' button-xs'; |
@@ -804,8 +804,8 @@ discard block |
||
| 804 | 804 | default : |
| 805 | 805 | $button_css_attributes .= ''; |
| 806 | 806 | } |
| 807 | - $this->_button_css_attributes .= ! empty( $other_attributes ) |
|
| 808 | - ? $button_css_attributes . ' ' . $other_attributes |
|
| 807 | + $this->_button_css_attributes .= ! empty($other_attributes) |
|
| 808 | + ? $button_css_attributes.' '.$other_attributes |
|
| 809 | 809 | : $button_css_attributes; |
| 810 | 810 | } |
| 811 | 811 | |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | * @return string |
| 816 | 816 | */ |
| 817 | 817 | public function button_css_attributes() { |
| 818 | - if ( empty( $this->_button_css_attributes )) { |
|
| 818 | + if (empty($this->_button_css_attributes)) { |
|
| 819 | 819 | $this->set_button_css_attributes(); |
| 820 | 820 | } |
| 821 | 821 | return $this->_button_css_attributes; |
@@ -837,26 +837,26 @@ discard block |
||
| 837 | 837 | * @return mixed whatever the raw value of this form section is in the request data |
| 838 | 838 | * @throws \EE_Error |
| 839 | 839 | */ |
| 840 | - public function find_form_data_for_this_section( $req_data ){ |
|
| 840 | + public function find_form_data_for_this_section($req_data) { |
|
| 841 | 841 | // break up the html name by "[]" |
| 842 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
| 843 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
| 842 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
| 843 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
| 844 | 844 | } else { |
| 845 | 845 | $before_any_brackets = $this->html_name(); |
| 846 | 846 | } |
| 847 | 847 | // grab all of the segments |
| 848 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
| 849 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
| 850 | - $name_parts = $matches[ 1 ]; |
|
| 848 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
| 849 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
| 850 | + $name_parts = $matches[1]; |
|
| 851 | 851 | array_unshift($name_parts, $before_any_brackets); |
| 852 | - }else{ |
|
| 853 | - $name_parts = array( $before_any_brackets ); |
|
| 852 | + } else { |
|
| 853 | + $name_parts = array($before_any_brackets); |
|
| 854 | 854 | } |
| 855 | 855 | // now get the value for the input |
| 856 | 856 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
| 857 | 857 | // check if this thing's name is at the TOP level of the request data |
| 858 | - if( $value === null && isset( $req_data[ $this->name() ] ) ){ |
|
| 859 | - $value = $req_data[ $this->name() ]; |
|
| 858 | + if ($value === null && isset($req_data[$this->name()])) { |
|
| 859 | + $value = $req_data[$this->name()]; |
|
| 860 | 860 | } |
| 861 | 861 | return $value; |
| 862 | 862 | } |
@@ -869,18 +869,18 @@ discard block |
||
| 869 | 869 | * @param array $req_data |
| 870 | 870 | * @return array | NULL |
| 871 | 871 | */ |
| 872 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
| 873 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
| 874 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
| 875 | - if( empty($html_name_parts ) ){ |
|
| 876 | - return $req_data[ $first_part_to_consider ]; |
|
| 877 | - }else{ |
|
| 872 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
| 873 | + $first_part_to_consider = array_shift($html_name_parts); |
|
| 874 | + if (isset($req_data[$first_part_to_consider])) { |
|
| 875 | + if (empty($html_name_parts)) { |
|
| 876 | + return $req_data[$first_part_to_consider]; |
|
| 877 | + } else { |
|
| 878 | 878 | return $this->_find_form_data_for_this_section_using_name_parts( |
| 879 | 879 | $html_name_parts, |
| 880 | - $req_data[ $first_part_to_consider ] |
|
| 880 | + $req_data[$first_part_to_consider] |
|
| 881 | 881 | ); |
| 882 | 882 | } |
| 883 | - }else{ |
|
| 883 | + } else { |
|
| 884 | 884 | return NULL; |
| 885 | 885 | } |
| 886 | 886 | } |
@@ -894,14 +894,14 @@ discard block |
||
| 894 | 894 | * @return boolean |
| 895 | 895 | * @throws \EE_Error |
| 896 | 896 | */ |
| 897 | - public function form_data_present_in($req_data = NULL){ |
|
| 898 | - if( $req_data === NULL ){ |
|
| 897 | + public function form_data_present_in($req_data = NULL) { |
|
| 898 | + if ($req_data === NULL) { |
|
| 899 | 899 | $req_data = $_POST; |
| 900 | 900 | } |
| 901 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
| 902 | - if( $checked_value !== null ){ |
|
| 901 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
| 902 | + if ($checked_value !== null) { |
|
| 903 | 903 | return TRUE; |
| 904 | - }else{ |
|
| 904 | + } else { |
|
| 905 | 905 | return FALSE; |
| 906 | 906 | } |
| 907 | 907 | } |
@@ -912,8 +912,8 @@ discard block |
||
| 912 | 912 | * @param array $form_other_js_data |
| 913 | 913 | * @return array |
| 914 | 914 | */ |
| 915 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
| 916 | - $form_other_js_data = $this->get_other_js_data_from_strategies( $form_other_js_data ); |
|
| 915 | + public function get_other_js_data($form_other_js_data = array()) { |
|
| 916 | + $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data); |
|
| 917 | 917 | return $form_other_js_data; |
| 918 | 918 | } |
| 919 | 919 | |
@@ -926,10 +926,10 @@ discard block |
||
| 926 | 926 | * @param array $form_other_js_data |
| 927 | 927 | * @return array |
| 928 | 928 | */ |
| 929 | - public function get_other_js_data_from_strategies( $form_other_js_data = array() ) { |
|
| 930 | - $form_other_js_data = $this->get_display_strategy()->get_other_js_data( $form_other_js_data ); |
|
| 931 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
| 932 | - $form_other_js_data = $validation_strategy->get_other_js_data( $form_other_js_data ); |
|
| 929 | + public function get_other_js_data_from_strategies($form_other_js_data = array()) { |
|
| 930 | + $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data); |
|
| 931 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
| 932 | + $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data); |
|
| 933 | 933 | } |
| 934 | 934 | return $form_other_js_data; |
| 935 | 935 | } |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | * Override parent because we want to give our strategies an opportunity to enqueue some js and css |
| 939 | 939 | * @return void |
| 940 | 940 | */ |
| 941 | - public function enqueue_js(){ |
|
| 941 | + public function enqueue_js() { |
|
| 942 | 942 | //ask our display strategy and validation strategies if they have js to enqueue |
| 943 | 943 | $this->enqueue_js_from_strategies(); |
| 944 | 944 | } |
@@ -949,7 +949,7 @@ discard block |
||
| 949 | 949 | */ |
| 950 | 950 | public function enqueue_js_from_strategies() { |
| 951 | 951 | $this->get_display_strategy()->enqueue_js(); |
| 952 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
| 952 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
| 953 | 953 | $validation_strategy->enqueue_js(); |
| 954 | 954 | } |
| 955 | 955 | } |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | * @param WP_Query $wp_query |
| 40 | 40 | * @param array $CPT |
| 41 | 41 | */ |
| 42 | - public function __construct( $wp_query, $CPT = array() ) { |
|
| 43 | - if ( $wp_query instanceof WP_Query ) { |
|
| 42 | + public function __construct($wp_query, $CPT = array()) { |
|
| 43 | + if ($wp_query instanceof WP_Query) { |
|
| 44 | 44 | $WP_Query = $wp_query; |
| 45 | 45 | $this->CPT = $CPT; |
| 46 | 46 | } else { |
| 47 | - $WP_Query = isset( $wp_query[ 'WP_Query' ] ) ? $wp_query[ 'WP_Query' ] : null; |
|
| 48 | - $this->CPT = isset( $wp_query[ 'CPT' ] ) ? $wp_query[ 'CPT' ] : null; |
|
| 47 | + $WP_Query = isset($wp_query['WP_Query']) ? $wp_query['WP_Query'] : null; |
|
| 48 | + $this->CPT = isset($wp_query['CPT']) ? $wp_query['CPT'] : null; |
|
| 49 | 49 | } |
| 50 | 50 | // !!!!!!!!!! IMPORTANT !!!!!!!!!!!! |
| 51 | 51 | // here's the list of available filters in the WP_Query object |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | // 'posts_fields' |
| 60 | 60 | // 'posts_join' |
| 61 | 61 | $this->_add_filters(); |
| 62 | - if ( $WP_Query instanceof WP_Query ) { |
|
| 63 | - $WP_Query->is_espresso_event_single = is_singular() && isset( $WP_Query->query->post_type ) && $WP_Query->query->post_type == 'espresso_events' ? TRUE : FALSE; |
|
| 62 | + if ($WP_Query instanceof WP_Query) { |
|
| 63 | + $WP_Query->is_espresso_event_single = is_singular() && isset($WP_Query->query->post_type) && $WP_Query->query->post_type == 'espresso_events' ? TRUE : FALSE; |
|
| 64 | 64 | $WP_Query->is_espresso_event_archive = is_post_type_archive('espresso_events') ? TRUE : FALSE; |
| 65 | - $WP_Query->is_espresso_event_taxonomy = is_tax( 'espresso_event_categories' ) ? TRUE : FALSE; |
|
| 65 | + $WP_Query->is_espresso_event_taxonomy = is_tax('espresso_event_categories') ? TRUE : FALSE; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | } |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | * (which will get removed in case the next call to get_posts ISN'T |
| 75 | 75 | * for event CPTs) |
| 76 | 76 | */ |
| 77 | - protected function _add_filters(){ |
|
| 78 | - add_filter( 'posts_fields', array( $this, 'posts_fields' ), 1, 2 ); |
|
| 79 | - add_filter( 'posts_join', array( $this, 'posts_join' ), 1, 2 ); |
|
| 80 | - add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 ); |
|
| 77 | + protected function _add_filters() { |
|
| 78 | + add_filter('posts_fields', array($this, 'posts_fields'), 1, 2); |
|
| 79 | + add_filter('posts_join', array($this, 'posts_join'), 1, 2); |
|
| 80 | + add_filter('posts_where', array($this, 'posts_where'), 10, 2); |
|
| 81 | 81 | // add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 ); |
| 82 | - add_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1, 2 ); |
|
| 83 | - add_filter( 'posts_groupby', array( $this, 'posts_groupby' ), 1, 2 ); |
|
| 82 | + add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2); |
|
| 83 | + add_filter('posts_groupby', array($this, 'posts_groupby'), 1, 2); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
@@ -90,13 +90,13 @@ discard block |
||
| 90 | 90 | * This is to avoid applying this CPT strategy for other posts or CPTs (eg, |
| 91 | 91 | * we don't want to join to the datetime table when querying for venues, do we!?) |
| 92 | 92 | */ |
| 93 | - protected function _remove_filters(){ |
|
| 94 | - remove_filter( 'posts_fields', array( $this, 'posts_fields' ), 1 ); |
|
| 95 | - remove_filter( 'posts_join', array( $this, 'posts_join' ), 1 ); |
|
| 96 | - remove_filter( 'posts_where', array( $this, 'posts_where' ), 10 ); |
|
| 93 | + protected function _remove_filters() { |
|
| 94 | + remove_filter('posts_fields', array($this, 'posts_fields'), 1); |
|
| 95 | + remove_filter('posts_join', array($this, 'posts_join'), 1); |
|
| 96 | + remove_filter('posts_where', array($this, 'posts_where'), 10); |
|
| 97 | 97 | // remove_filter( 'the_posts', array( $this, 'the_posts' ), 1 ); |
| 98 | - remove_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1 ); |
|
| 99 | - remove_filter( 'posts_groupby', array( $this, 'posts_groupby' ), 1 ); |
|
| 98 | + remove_filter('posts_orderby', array($this, 'posts_orderby'), 1); |
|
| 99 | + remove_filter('posts_groupby', array($this, 'posts_groupby'), 1); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @param WP_Query $wp_query |
| 110 | 110 | * @return string |
| 111 | 111 | */ |
| 112 | - public function posts_fields( $SQL, WP_Query $wp_query ) { |
|
| 112 | + public function posts_fields($SQL, WP_Query $wp_query) { |
|
| 113 | 113 | if ( |
| 114 | 114 | $wp_query instanceof WP_Query |
| 115 | 115 | && |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | ) |
| 121 | 121 | ) { |
| 122 | 122 | // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement |
| 123 | - $SQL .= ', ' . EEM_Datetime::instance()->table() . '.* ' ; |
|
| 124 | - if ( $wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy ) { |
|
| 123 | + $SQL .= ', '.EEM_Datetime::instance()->table().'.* '; |
|
| 124 | + if ($wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy) { |
|
| 125 | 125 | // because we only want to retrieve the next upcoming datetime for each event: |
| 126 | 126 | // add something like ", MIN( wp_esp_datetime.DTT_EVT_start ) as event_start_date " to WP Query SELECT statement |
| 127 | - $SQL .= ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ; |
|
| 127 | + $SQL .= ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date '; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | return $SQL; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @internal param \WP_Query $WP_Query |
| 142 | 142 | * @return string |
| 143 | 143 | */ |
| 144 | - public function posts_join( $SQL, WP_Query $wp_query ) { |
|
| 144 | + public function posts_join($SQL, WP_Query $wp_query) { |
|
| 145 | 145 | if ( |
| 146 | 146 | $wp_query instanceof WP_Query |
| 147 | 147 | && |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | ) |
| 153 | 153 | ) { |
| 154 | 154 | // adds something like " LEFT JOIN wp_esp_datetime ON ( wp_esp_datetime.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
| 155 | - $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name() . ' ) '; |
|
| 155 | + $SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name().' ) '; |
|
| 156 | 156 | } |
| 157 | 157 | return $SQL; |
| 158 | 158 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param WP_Query $wp_query |
| 168 | 168 | * @return string |
| 169 | 169 | */ |
| 170 | - public function posts_where( $SQL, WP_Query $wp_query ) { |
|
| 170 | + public function posts_where($SQL, WP_Query $wp_query) { |
|
| 171 | 171 | // global $wpdb; |
| 172 | 172 | if ( |
| 173 | 173 | $wp_query instanceof WP_Query |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | || $wp_query->is_espresso_event_taxonomy |
| 178 | 178 | ) |
| 179 | 179 | ) { |
| 180 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive ) || ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events ) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events ) { |
|
| 181 | - $SQL .= ' AND ' . EEM_Datetime::instance()->table() . ".DTT_EVT_end > '" . current_time( 'mysql', true ) . "' "; |
|
| 180 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive) || ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events) { |
|
| 181 | + $SQL .= ' AND '.EEM_Datetime::instance()->table().".DTT_EVT_end > '".current_time('mysql', true)."' "; |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | return $SQL; |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @param WP_Query $wp_query |
| 195 | 195 | * @return string |
| 196 | 196 | */ |
| 197 | - public function posts_orderby( $SQL, WP_Query $wp_query ) { |
|
| 197 | + public function posts_orderby($SQL, WP_Query $wp_query) { |
|
| 198 | 198 | if ( |
| 199 | 199 | $wp_query instanceof WP_Query |
| 200 | 200 | && |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * @param WP_Query $wp_query |
| 219 | 219 | * @return string |
| 220 | 220 | */ |
| 221 | - public function posts_groupby( $SQL, WP_Query $wp_query ) { |
|
| 221 | + public function posts_groupby($SQL, WP_Query $wp_query) { |
|
| 222 | 222 | if ( |
| 223 | 223 | $wp_query instanceof WP_Query |
| 224 | 224 | && |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | // we're joining to the datetimes table, where there can be MANY datetimes for a single event, but we want to only show each event only once |
| 232 | 232 | // (whereas if we didn't group them by the post's ID, then we would end up with many repeats) |
| 233 | 233 | global $wpdb; |
| 234 | - $SQL = $wpdb->posts . '.ID '; |
|
| 234 | + $SQL = $wpdb->posts.'.ID '; |
|
| 235 | 235 | } |
| 236 | 236 | return $SQL; |
| 237 | 237 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @param WP_Query $wp_query |
| 247 | 247 | * @return array |
| 248 | 248 | */ |
| 249 | - public function the_posts( $posts, WP_Query $wp_query ) { |
|
| 249 | + public function the_posts($posts, WP_Query $wp_query) { |
|
| 250 | 250 | return $posts; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @param $single |
| 263 | 263 | * @return string |
| 264 | 264 | */ |
| 265 | - public function get_EE_post_type_metadata( $meta_value = NULL, $post_id, $meta_key, $single ) { |
|
| 265 | + public function get_EE_post_type_metadata($meta_value = NULL, $post_id, $meta_key, $single) { |
|
| 266 | 266 | return $meta_value; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
| 37 | 37 | { |
| 38 | 38 | if ( ! isset($fieldValues['ATT_full_name'])) { |
| 39 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
| 39 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : ''; |
|
| 40 | 40 | $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
| 41 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
| 41 | + $fieldValues['ATT_full_name'] = $fname.$lname; |
|
| 42 | 42 | } |
| 43 | 43 | if ( ! isset($fieldValues['ATT_slug'])) { |
| 44 | 44 | // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | public function full_name($apply_html_entities = false) |
| 272 | 272 | { |
| 273 | - $full_name = $this->fname() . ' ' . $this->lname(); |
|
| 273 | + $full_name = $this->fname().' '.$this->lname(); |
|
| 274 | 274 | return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | public function get_most_recent_registration_for_event($event_id) |
| 572 | 572 | { |
| 573 | 573 | return $this->get_first_related('Registration', |
| 574 | - array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' ); |
|
| 574 | + array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))); //, '=', 'OBJECT_K' ); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | public function get_billing_info_postmeta_name($payment_method) |
| 626 | 626 | { |
| 627 | 627 | if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
| 628 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
| 628 | + return 'billing_info_'.$payment_method->type_obj()->system_name(); |
|
| 629 | 629 | } else { |
| 630 | 630 | return null; |
| 631 | 631 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /** |
| 5 | 5 | * Event Espresso |
@@ -24,695 +24,695 @@ discard block |
||
| 24 | 24 | class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Sets some dynamic defaults |
|
| 29 | - * |
|
| 30 | - * @param array $fieldValues |
|
| 31 | - * @param bool $bydb |
|
| 32 | - * @param string $timezone |
|
| 33 | - * @param array $date_formats |
|
| 34 | - */ |
|
| 35 | - protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
| 36 | - { |
|
| 37 | - if ( ! isset($fieldValues['ATT_full_name'])) { |
|
| 38 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
| 39 | - $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
| 40 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
| 41 | - } |
|
| 42 | - if ( ! isset($fieldValues['ATT_slug'])) { |
|
| 43 | - // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
| 44 | - $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
| 45 | - } |
|
| 46 | - if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
| 47 | - $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
| 48 | - } |
|
| 49 | - parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @param array $props_n_values incoming values |
|
| 56 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 57 | - * used.) |
|
| 58 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 59 | - * date_format and the second value is the time format |
|
| 60 | - * @return EE_Attendee |
|
| 61 | - */ |
|
| 62 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 63 | - { |
|
| 64 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 65 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @param array $props_n_values incoming values from the database |
|
| 72 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 73 | - * the website will be used. |
|
| 74 | - * @return EE_Attendee |
|
| 75 | - */ |
|
| 76 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 77 | - { |
|
| 78 | - return new self($props_n_values, true, $timezone); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Set Attendee First Name |
|
| 85 | - * |
|
| 86 | - * @access public |
|
| 87 | - * @param string $fname |
|
| 88 | - */ |
|
| 89 | - public function set_fname($fname = '') |
|
| 90 | - { |
|
| 91 | - $this->set('ATT_fname', $fname); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Set Attendee Last Name |
|
| 98 | - * |
|
| 99 | - * @access public |
|
| 100 | - * @param string $lname |
|
| 101 | - */ |
|
| 102 | - public function set_lname($lname = '') |
|
| 103 | - { |
|
| 104 | - $this->set('ATT_lname', $lname); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Set Attendee Address |
|
| 111 | - * |
|
| 112 | - * @access public |
|
| 113 | - * @param string $address |
|
| 114 | - */ |
|
| 115 | - public function set_address($address = '') |
|
| 116 | - { |
|
| 117 | - $this->set('ATT_address', $address); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Set Attendee Address2 |
|
| 124 | - * |
|
| 125 | - * @access public |
|
| 126 | - * @param string $address2 |
|
| 127 | - */ |
|
| 128 | - public function set_address2($address2 = '') |
|
| 129 | - { |
|
| 130 | - $this->set('ATT_address2', $address2); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Set Attendee City |
|
| 137 | - * |
|
| 138 | - * @access public |
|
| 139 | - * @param string $city |
|
| 140 | - */ |
|
| 141 | - public function set_city($city = '') |
|
| 142 | - { |
|
| 143 | - $this->set('ATT_city', $city); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Set Attendee State ID |
|
| 150 | - * |
|
| 151 | - * @access public |
|
| 152 | - * @param int $STA_ID |
|
| 153 | - */ |
|
| 154 | - public function set_state($STA_ID = 0) |
|
| 155 | - { |
|
| 156 | - $this->set('STA_ID', $STA_ID); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Set Attendee Country ISO Code |
|
| 163 | - * |
|
| 164 | - * @access public |
|
| 165 | - * @param string $CNT_ISO |
|
| 166 | - */ |
|
| 167 | - public function set_country($CNT_ISO = '') |
|
| 168 | - { |
|
| 169 | - $this->set('CNT_ISO', $CNT_ISO); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Set Attendee Zip/Postal Code |
|
| 176 | - * |
|
| 177 | - * @access public |
|
| 178 | - * @param string $zip |
|
| 179 | - */ |
|
| 180 | - public function set_zip($zip = '') |
|
| 181 | - { |
|
| 182 | - $this->set('ATT_zip', $zip); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Set Attendee Email Address |
|
| 189 | - * |
|
| 190 | - * @access public |
|
| 191 | - * @param string $email |
|
| 192 | - */ |
|
| 193 | - public function set_email($email = '') |
|
| 194 | - { |
|
| 195 | - $this->set('ATT_email', $email); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Set Attendee Phone |
|
| 202 | - * |
|
| 203 | - * @access public |
|
| 204 | - * @param string $phone |
|
| 205 | - */ |
|
| 206 | - public function set_phone($phone = '') |
|
| 207 | - { |
|
| 208 | - $this->set('ATT_phone', $phone); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * set deleted |
|
| 215 | - * |
|
| 216 | - * @access public |
|
| 217 | - * @param bool $ATT_deleted |
|
| 218 | - */ |
|
| 219 | - public function set_deleted($ATT_deleted = false) |
|
| 220 | - { |
|
| 221 | - $this->set('ATT_deleted', $ATT_deleted); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Returns the value for the post_author id saved with the cpt |
|
| 228 | - * |
|
| 229 | - * @since 4.5.0 |
|
| 230 | - * @return int |
|
| 231 | - */ |
|
| 232 | - public function wp_user() |
|
| 233 | - { |
|
| 234 | - return $this->get('ATT_author'); |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * get Attendee First Name |
|
| 241 | - * |
|
| 242 | - * @access public |
|
| 243 | - * @return string |
|
| 244 | - */ |
|
| 245 | - public function fname() |
|
| 246 | - { |
|
| 247 | - return $this->get('ATT_fname'); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * echoes out the attendee's first name |
|
| 254 | - * |
|
| 255 | - * @return void |
|
| 256 | - */ |
|
| 257 | - public function e_full_name() |
|
| 258 | - { |
|
| 259 | - echo $this->full_name(); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * Returns the first and last name concatenated together with a space. |
|
| 266 | - * |
|
| 267 | - * @param bool $apply_html_entities |
|
| 268 | - * @return string |
|
| 269 | - */ |
|
| 270 | - public function full_name($apply_html_entities = false) |
|
| 271 | - { |
|
| 272 | - $full_name = $this->fname() . ' ' . $this->lname(); |
|
| 273 | - return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * get Attendee Last Name |
|
| 280 | - * |
|
| 281 | - * @access public |
|
| 282 | - * @return string |
|
| 283 | - */ |
|
| 284 | - public function lname() |
|
| 285 | - { |
|
| 286 | - return $this->get('ATT_lname'); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
| 293 | - * |
|
| 294 | - * @return array numerically indexed, with each part of the address that is known. |
|
| 295 | - * Eg, if the user only responded to state and country, |
|
| 296 | - * it would be array(0=>'Alabama',1=>'USA') |
|
| 297 | - * @return array |
|
| 298 | - */ |
|
| 299 | - public function full_address_as_array() |
|
| 300 | - { |
|
| 301 | - $full_address_array = array(); |
|
| 302 | - $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
| 303 | - foreach ($initial_address_fields as $address_field_name) { |
|
| 304 | - $address_fields_value = $this->get($address_field_name); |
|
| 305 | - if ( ! empty($address_fields_value)) { |
|
| 306 | - $full_address_array[] = $address_fields_value; |
|
| 307 | - } |
|
| 308 | - } |
|
| 309 | - //now handle state and country |
|
| 310 | - $state_obj = $this->state_obj(); |
|
| 311 | - if ( ! empty($state_obj)) { |
|
| 312 | - $full_address_array[] = $state_obj->name(); |
|
| 313 | - } |
|
| 314 | - $country_obj = $this->country_obj(); |
|
| 315 | - if ( ! empty($country_obj)) { |
|
| 316 | - $full_address_array[] = $country_obj->name(); |
|
| 317 | - } |
|
| 318 | - //lastly get the xip |
|
| 319 | - $zip_value = $this->zip(); |
|
| 320 | - if ( ! empty($zip_value)) { |
|
| 321 | - $full_address_array[] = $zip_value; |
|
| 322 | - } |
|
| 323 | - return $full_address_array; |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * get Attendee Address |
|
| 330 | - * |
|
| 331 | - * @return string |
|
| 332 | - */ |
|
| 333 | - public function address() |
|
| 334 | - { |
|
| 335 | - return $this->get('ATT_address'); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * get Attendee Address2 |
|
| 342 | - * |
|
| 343 | - * @return string |
|
| 344 | - */ |
|
| 345 | - public function address2() |
|
| 346 | - { |
|
| 347 | - return $this->get('ATT_address2'); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * get Attendee City |
|
| 354 | - * |
|
| 355 | - * @return string |
|
| 356 | - */ |
|
| 357 | - public function city() |
|
| 358 | - { |
|
| 359 | - return $this->get('ATT_city'); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * get Attendee State ID |
|
| 366 | - * |
|
| 367 | - * @return string |
|
| 368 | - */ |
|
| 369 | - public function state_ID() |
|
| 370 | - { |
|
| 371 | - return $this->get('STA_ID'); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * @return string |
|
| 378 | - */ |
|
| 379 | - public function state_abbrev() |
|
| 380 | - { |
|
| 381 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * Gets the state set to this attendee |
|
| 388 | - * |
|
| 389 | - * @return EE_State |
|
| 390 | - */ |
|
| 391 | - public function state_obj() |
|
| 392 | - { |
|
| 393 | - return $this->get_first_related('State'); |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - |
|
| 397 | - |
|
| 398 | - /** |
|
| 399 | - * Returns the state's name, otherwise 'Unknown' |
|
| 400 | - * |
|
| 401 | - * @return string |
|
| 402 | - */ |
|
| 403 | - public function state_name() |
|
| 404 | - { |
|
| 405 | - if ($this->state_obj()) { |
|
| 406 | - return $this->state_obj()->name(); |
|
| 407 | - } else { |
|
| 408 | - return ''; |
|
| 409 | - } |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * either displays the state abbreviation or the state name, as determined |
|
| 416 | - * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
| 417 | - * defaults to abbreviation |
|
| 418 | - * |
|
| 419 | - * @return string |
|
| 420 | - */ |
|
| 421 | - public function state() |
|
| 422 | - { |
|
| 423 | - if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
| 424 | - return $this->state_abbrev(); |
|
| 425 | - } else { |
|
| 426 | - return $this->state_name(); |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - |
|
| 431 | - |
|
| 432 | - /** |
|
| 433 | - * get Attendee Country ISO Code |
|
| 434 | - * |
|
| 435 | - * @return string |
|
| 436 | - */ |
|
| 437 | - public function country_ID() |
|
| 438 | - { |
|
| 439 | - return $this->get('CNT_ISO'); |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - |
|
| 443 | - |
|
| 444 | - /** |
|
| 445 | - * Gets country set for this attendee |
|
| 446 | - * |
|
| 447 | - * @return EE_Country |
|
| 448 | - */ |
|
| 449 | - public function country_obj() |
|
| 450 | - { |
|
| 451 | - return $this->get_first_related('Country'); |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * Returns the country's name if known, otherwise 'Unknown' |
|
| 458 | - * |
|
| 459 | - * @return string |
|
| 460 | - */ |
|
| 461 | - public function country_name() |
|
| 462 | - { |
|
| 463 | - if ($this->country_obj()) { |
|
| 464 | - return $this->country_obj()->name(); |
|
| 465 | - } else { |
|
| 466 | - return ''; |
|
| 467 | - } |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - |
|
| 471 | - |
|
| 472 | - /** |
|
| 473 | - * either displays the country ISO2 code or the country name, as determined |
|
| 474 | - * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
| 475 | - * defaults to abbreviation |
|
| 476 | - * |
|
| 477 | - * @return string |
|
| 478 | - */ |
|
| 479 | - public function country() |
|
| 480 | - { |
|
| 481 | - if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
| 482 | - return $this->country_ID(); |
|
| 483 | - } else { |
|
| 484 | - return $this->country_name(); |
|
| 485 | - } |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - |
|
| 489 | - |
|
| 490 | - /** |
|
| 491 | - * get Attendee Zip/Postal Code |
|
| 492 | - * |
|
| 493 | - * @return string |
|
| 494 | - */ |
|
| 495 | - public function zip() |
|
| 496 | - { |
|
| 497 | - return $this->get('ATT_zip'); |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - |
|
| 501 | - |
|
| 502 | - /** |
|
| 503 | - * get Attendee Email Address |
|
| 504 | - * |
|
| 505 | - * @return string |
|
| 506 | - */ |
|
| 507 | - public function email() |
|
| 508 | - { |
|
| 509 | - return $this->get('ATT_email'); |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - |
|
| 513 | - |
|
| 514 | - /** |
|
| 515 | - * get Attendee Phone # |
|
| 516 | - * |
|
| 517 | - * @return string |
|
| 518 | - */ |
|
| 519 | - public function phone() |
|
| 520 | - { |
|
| 521 | - return $this->get('ATT_phone'); |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - |
|
| 525 | - |
|
| 526 | - /** |
|
| 527 | - * get deleted |
|
| 528 | - * |
|
| 529 | - * @return bool |
|
| 530 | - */ |
|
| 531 | - public function deleted() |
|
| 532 | - { |
|
| 533 | - return $this->get('ATT_deleted'); |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * Gets registrations of this attendee |
|
| 540 | - * |
|
| 541 | - * @param array $query_params |
|
| 542 | - * @return EE_Registration[] |
|
| 543 | - */ |
|
| 544 | - public function get_registrations($query_params = array()) |
|
| 545 | - { |
|
| 546 | - return $this->get_many_related('Registration', $query_params); |
|
| 547 | - } |
|
| 548 | - |
|
| 549 | - |
|
| 550 | - |
|
| 551 | - /** |
|
| 552 | - * Gets the most recent registration of this attendee |
|
| 553 | - * |
|
| 554 | - * @return EE_Registration |
|
| 555 | - */ |
|
| 556 | - public function get_most_recent_registration() |
|
| 557 | - { |
|
| 558 | - return $this->get_first_related('Registration', |
|
| 559 | - array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
| 560 | - } |
|
| 561 | - |
|
| 562 | - |
|
| 563 | - |
|
| 564 | - /** |
|
| 565 | - * Gets the most recent registration for this attend at this event |
|
| 566 | - * |
|
| 567 | - * @param int $event_id |
|
| 568 | - * @return EE_Registration |
|
| 569 | - */ |
|
| 570 | - public function get_most_recent_registration_for_event($event_id) |
|
| 571 | - { |
|
| 572 | - return $this->get_first_related('Registration', |
|
| 573 | - array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' ); |
|
| 574 | - } |
|
| 575 | - |
|
| 576 | - |
|
| 577 | - |
|
| 578 | - /** |
|
| 579 | - * returns any events attached to this attendee ($_Event property); |
|
| 580 | - * |
|
| 581 | - * @return array |
|
| 582 | - */ |
|
| 583 | - public function events() |
|
| 584 | - { |
|
| 585 | - return $this->get_many_related('Event'); |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - |
|
| 589 | - |
|
| 590 | - /** |
|
| 591 | - * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
| 592 | - * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
| 593 | - * used to save the billing info |
|
| 594 | - * |
|
| 595 | - * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
| 596 | - * @return EE_Form_Section_Proper|null |
|
| 597 | - */ |
|
| 598 | - public function billing_info_for_payment_method($payment_method) |
|
| 599 | - { |
|
| 600 | - $pm_type = $payment_method->type_obj(); |
|
| 601 | - if ( ! $pm_type instanceof EE_PMT_Base) { |
|
| 602 | - return null; |
|
| 603 | - } |
|
| 604 | - $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
| 605 | - if ( ! $billing_info) { |
|
| 606 | - return null; |
|
| 607 | - } |
|
| 608 | - $billing_form = $pm_type->billing_form(); |
|
| 609 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 610 | - $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
| 611 | - } |
|
| 612 | - return $billing_form; |
|
| 613 | - } |
|
| 614 | - |
|
| 615 | - |
|
| 616 | - |
|
| 617 | - /** |
|
| 618 | - * Gets the postmeta key that holds this attendee's billing info for the |
|
| 619 | - * specified payment method |
|
| 620 | - * |
|
| 621 | - * @param EE_Payment_Method $payment_method |
|
| 622 | - * @return string |
|
| 623 | - */ |
|
| 624 | - public function get_billing_info_postmeta_name($payment_method) |
|
| 625 | - { |
|
| 626 | - if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 627 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
| 628 | - } else { |
|
| 629 | - return null; |
|
| 630 | - } |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - |
|
| 634 | - |
|
| 635 | - /** |
|
| 636 | - * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
| 637 | - * retrieve it |
|
| 638 | - * |
|
| 639 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
| 640 | - * @param EE_Payment_Method $payment_method |
|
| 641 | - * @return boolean |
|
| 642 | - */ |
|
| 643 | - public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
| 644 | - { |
|
| 645 | - if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
| 646 | - EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
| 647 | - return false; |
|
| 648 | - } |
|
| 649 | - $billing_form->clean_sensitive_data(); |
|
| 650 | - return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method), |
|
| 651 | - $billing_form->input_values(true)); |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - |
|
| 655 | - |
|
| 656 | - /** |
|
| 657 | - * Return the link to the admin details for the object. |
|
| 658 | - * |
|
| 659 | - * @return string |
|
| 660 | - */ |
|
| 661 | - public function get_admin_details_link() |
|
| 662 | - { |
|
| 663 | - return $this->get_admin_edit_link(); |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - |
|
| 667 | - |
|
| 668 | - /** |
|
| 669 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 670 | - * |
|
| 671 | - * @return string |
|
| 672 | - */ |
|
| 673 | - public function get_admin_edit_link() |
|
| 674 | - { |
|
| 675 | - EE_Registry::instance()->load_helper('URL'); |
|
| 676 | - return EEH_URL::add_query_args_and_nonce( |
|
| 677 | - array( |
|
| 678 | - 'page' => 'espresso_registrations', |
|
| 679 | - 'action' => 'edit_attendee', |
|
| 680 | - 'post' => $this->ID(), |
|
| 681 | - ), |
|
| 682 | - admin_url('admin.php') |
|
| 683 | - ); |
|
| 684 | - } |
|
| 685 | - |
|
| 686 | - |
|
| 687 | - |
|
| 688 | - /** |
|
| 689 | - * Returns the link to a settings page for the object. |
|
| 690 | - * |
|
| 691 | - * @return string |
|
| 692 | - */ |
|
| 693 | - public function get_admin_settings_link() |
|
| 694 | - { |
|
| 695 | - return $this->get_admin_edit_link(); |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - |
|
| 699 | - |
|
| 700 | - /** |
|
| 701 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 702 | - * |
|
| 703 | - * @return string |
|
| 704 | - */ |
|
| 705 | - public function get_admin_overview_link() |
|
| 706 | - { |
|
| 707 | - EE_Registry::instance()->load_helper('URL'); |
|
| 708 | - return EEH_URL::add_query_args_and_nonce( |
|
| 709 | - array( |
|
| 710 | - 'page' => 'espresso_registrations', |
|
| 711 | - 'action' => 'contact_list', |
|
| 712 | - ), |
|
| 713 | - admin_url('admin.php') |
|
| 714 | - ); |
|
| 715 | - } |
|
| 27 | + /** |
|
| 28 | + * Sets some dynamic defaults |
|
| 29 | + * |
|
| 30 | + * @param array $fieldValues |
|
| 31 | + * @param bool $bydb |
|
| 32 | + * @param string $timezone |
|
| 33 | + * @param array $date_formats |
|
| 34 | + */ |
|
| 35 | + protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
| 36 | + { |
|
| 37 | + if ( ! isset($fieldValues['ATT_full_name'])) { |
|
| 38 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
| 39 | + $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
| 40 | + $fieldValues['ATT_full_name'] = $fname . $lname; |
|
| 41 | + } |
|
| 42 | + if ( ! isset($fieldValues['ATT_slug'])) { |
|
| 43 | + // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
| 44 | + $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
| 45 | + } |
|
| 46 | + if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
| 47 | + $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
| 48 | + } |
|
| 49 | + parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @param array $props_n_values incoming values |
|
| 56 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 57 | + * used.) |
|
| 58 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 59 | + * date_format and the second value is the time format |
|
| 60 | + * @return EE_Attendee |
|
| 61 | + */ |
|
| 62 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 63 | + { |
|
| 64 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 65 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @param array $props_n_values incoming values from the database |
|
| 72 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 73 | + * the website will be used. |
|
| 74 | + * @return EE_Attendee |
|
| 75 | + */ |
|
| 76 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 77 | + { |
|
| 78 | + return new self($props_n_values, true, $timezone); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Set Attendee First Name |
|
| 85 | + * |
|
| 86 | + * @access public |
|
| 87 | + * @param string $fname |
|
| 88 | + */ |
|
| 89 | + public function set_fname($fname = '') |
|
| 90 | + { |
|
| 91 | + $this->set('ATT_fname', $fname); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Set Attendee Last Name |
|
| 98 | + * |
|
| 99 | + * @access public |
|
| 100 | + * @param string $lname |
|
| 101 | + */ |
|
| 102 | + public function set_lname($lname = '') |
|
| 103 | + { |
|
| 104 | + $this->set('ATT_lname', $lname); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Set Attendee Address |
|
| 111 | + * |
|
| 112 | + * @access public |
|
| 113 | + * @param string $address |
|
| 114 | + */ |
|
| 115 | + public function set_address($address = '') |
|
| 116 | + { |
|
| 117 | + $this->set('ATT_address', $address); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Set Attendee Address2 |
|
| 124 | + * |
|
| 125 | + * @access public |
|
| 126 | + * @param string $address2 |
|
| 127 | + */ |
|
| 128 | + public function set_address2($address2 = '') |
|
| 129 | + { |
|
| 130 | + $this->set('ATT_address2', $address2); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Set Attendee City |
|
| 137 | + * |
|
| 138 | + * @access public |
|
| 139 | + * @param string $city |
|
| 140 | + */ |
|
| 141 | + public function set_city($city = '') |
|
| 142 | + { |
|
| 143 | + $this->set('ATT_city', $city); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Set Attendee State ID |
|
| 150 | + * |
|
| 151 | + * @access public |
|
| 152 | + * @param int $STA_ID |
|
| 153 | + */ |
|
| 154 | + public function set_state($STA_ID = 0) |
|
| 155 | + { |
|
| 156 | + $this->set('STA_ID', $STA_ID); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Set Attendee Country ISO Code |
|
| 163 | + * |
|
| 164 | + * @access public |
|
| 165 | + * @param string $CNT_ISO |
|
| 166 | + */ |
|
| 167 | + public function set_country($CNT_ISO = '') |
|
| 168 | + { |
|
| 169 | + $this->set('CNT_ISO', $CNT_ISO); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Set Attendee Zip/Postal Code |
|
| 176 | + * |
|
| 177 | + * @access public |
|
| 178 | + * @param string $zip |
|
| 179 | + */ |
|
| 180 | + public function set_zip($zip = '') |
|
| 181 | + { |
|
| 182 | + $this->set('ATT_zip', $zip); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Set Attendee Email Address |
|
| 189 | + * |
|
| 190 | + * @access public |
|
| 191 | + * @param string $email |
|
| 192 | + */ |
|
| 193 | + public function set_email($email = '') |
|
| 194 | + { |
|
| 195 | + $this->set('ATT_email', $email); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Set Attendee Phone |
|
| 202 | + * |
|
| 203 | + * @access public |
|
| 204 | + * @param string $phone |
|
| 205 | + */ |
|
| 206 | + public function set_phone($phone = '') |
|
| 207 | + { |
|
| 208 | + $this->set('ATT_phone', $phone); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * set deleted |
|
| 215 | + * |
|
| 216 | + * @access public |
|
| 217 | + * @param bool $ATT_deleted |
|
| 218 | + */ |
|
| 219 | + public function set_deleted($ATT_deleted = false) |
|
| 220 | + { |
|
| 221 | + $this->set('ATT_deleted', $ATT_deleted); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Returns the value for the post_author id saved with the cpt |
|
| 228 | + * |
|
| 229 | + * @since 4.5.0 |
|
| 230 | + * @return int |
|
| 231 | + */ |
|
| 232 | + public function wp_user() |
|
| 233 | + { |
|
| 234 | + return $this->get('ATT_author'); |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * get Attendee First Name |
|
| 241 | + * |
|
| 242 | + * @access public |
|
| 243 | + * @return string |
|
| 244 | + */ |
|
| 245 | + public function fname() |
|
| 246 | + { |
|
| 247 | + return $this->get('ATT_fname'); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * echoes out the attendee's first name |
|
| 254 | + * |
|
| 255 | + * @return void |
|
| 256 | + */ |
|
| 257 | + public function e_full_name() |
|
| 258 | + { |
|
| 259 | + echo $this->full_name(); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * Returns the first and last name concatenated together with a space. |
|
| 266 | + * |
|
| 267 | + * @param bool $apply_html_entities |
|
| 268 | + * @return string |
|
| 269 | + */ |
|
| 270 | + public function full_name($apply_html_entities = false) |
|
| 271 | + { |
|
| 272 | + $full_name = $this->fname() . ' ' . $this->lname(); |
|
| 273 | + return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * get Attendee Last Name |
|
| 280 | + * |
|
| 281 | + * @access public |
|
| 282 | + * @return string |
|
| 283 | + */ |
|
| 284 | + public function lname() |
|
| 285 | + { |
|
| 286 | + return $this->get('ATT_lname'); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
| 293 | + * |
|
| 294 | + * @return array numerically indexed, with each part of the address that is known. |
|
| 295 | + * Eg, if the user only responded to state and country, |
|
| 296 | + * it would be array(0=>'Alabama',1=>'USA') |
|
| 297 | + * @return array |
|
| 298 | + */ |
|
| 299 | + public function full_address_as_array() |
|
| 300 | + { |
|
| 301 | + $full_address_array = array(); |
|
| 302 | + $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
| 303 | + foreach ($initial_address_fields as $address_field_name) { |
|
| 304 | + $address_fields_value = $this->get($address_field_name); |
|
| 305 | + if ( ! empty($address_fields_value)) { |
|
| 306 | + $full_address_array[] = $address_fields_value; |
|
| 307 | + } |
|
| 308 | + } |
|
| 309 | + //now handle state and country |
|
| 310 | + $state_obj = $this->state_obj(); |
|
| 311 | + if ( ! empty($state_obj)) { |
|
| 312 | + $full_address_array[] = $state_obj->name(); |
|
| 313 | + } |
|
| 314 | + $country_obj = $this->country_obj(); |
|
| 315 | + if ( ! empty($country_obj)) { |
|
| 316 | + $full_address_array[] = $country_obj->name(); |
|
| 317 | + } |
|
| 318 | + //lastly get the xip |
|
| 319 | + $zip_value = $this->zip(); |
|
| 320 | + if ( ! empty($zip_value)) { |
|
| 321 | + $full_address_array[] = $zip_value; |
|
| 322 | + } |
|
| 323 | + return $full_address_array; |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * get Attendee Address |
|
| 330 | + * |
|
| 331 | + * @return string |
|
| 332 | + */ |
|
| 333 | + public function address() |
|
| 334 | + { |
|
| 335 | + return $this->get('ATT_address'); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * get Attendee Address2 |
|
| 342 | + * |
|
| 343 | + * @return string |
|
| 344 | + */ |
|
| 345 | + public function address2() |
|
| 346 | + { |
|
| 347 | + return $this->get('ATT_address2'); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * get Attendee City |
|
| 354 | + * |
|
| 355 | + * @return string |
|
| 356 | + */ |
|
| 357 | + public function city() |
|
| 358 | + { |
|
| 359 | + return $this->get('ATT_city'); |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * get Attendee State ID |
|
| 366 | + * |
|
| 367 | + * @return string |
|
| 368 | + */ |
|
| 369 | + public function state_ID() |
|
| 370 | + { |
|
| 371 | + return $this->get('STA_ID'); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * @return string |
|
| 378 | + */ |
|
| 379 | + public function state_abbrev() |
|
| 380 | + { |
|
| 381 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * Gets the state set to this attendee |
|
| 388 | + * |
|
| 389 | + * @return EE_State |
|
| 390 | + */ |
|
| 391 | + public function state_obj() |
|
| 392 | + { |
|
| 393 | + return $this->get_first_related('State'); |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + |
|
| 397 | + |
|
| 398 | + /** |
|
| 399 | + * Returns the state's name, otherwise 'Unknown' |
|
| 400 | + * |
|
| 401 | + * @return string |
|
| 402 | + */ |
|
| 403 | + public function state_name() |
|
| 404 | + { |
|
| 405 | + if ($this->state_obj()) { |
|
| 406 | + return $this->state_obj()->name(); |
|
| 407 | + } else { |
|
| 408 | + return ''; |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * either displays the state abbreviation or the state name, as determined |
|
| 416 | + * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
| 417 | + * defaults to abbreviation |
|
| 418 | + * |
|
| 419 | + * @return string |
|
| 420 | + */ |
|
| 421 | + public function state() |
|
| 422 | + { |
|
| 423 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
| 424 | + return $this->state_abbrev(); |
|
| 425 | + } else { |
|
| 426 | + return $this->state_name(); |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + |
|
| 431 | + |
|
| 432 | + /** |
|
| 433 | + * get Attendee Country ISO Code |
|
| 434 | + * |
|
| 435 | + * @return string |
|
| 436 | + */ |
|
| 437 | + public function country_ID() |
|
| 438 | + { |
|
| 439 | + return $this->get('CNT_ISO'); |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + |
|
| 443 | + |
|
| 444 | + /** |
|
| 445 | + * Gets country set for this attendee |
|
| 446 | + * |
|
| 447 | + * @return EE_Country |
|
| 448 | + */ |
|
| 449 | + public function country_obj() |
|
| 450 | + { |
|
| 451 | + return $this->get_first_related('Country'); |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * Returns the country's name if known, otherwise 'Unknown' |
|
| 458 | + * |
|
| 459 | + * @return string |
|
| 460 | + */ |
|
| 461 | + public function country_name() |
|
| 462 | + { |
|
| 463 | + if ($this->country_obj()) { |
|
| 464 | + return $this->country_obj()->name(); |
|
| 465 | + } else { |
|
| 466 | + return ''; |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + |
|
| 471 | + |
|
| 472 | + /** |
|
| 473 | + * either displays the country ISO2 code or the country name, as determined |
|
| 474 | + * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
| 475 | + * defaults to abbreviation |
|
| 476 | + * |
|
| 477 | + * @return string |
|
| 478 | + */ |
|
| 479 | + public function country() |
|
| 480 | + { |
|
| 481 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
| 482 | + return $this->country_ID(); |
|
| 483 | + } else { |
|
| 484 | + return $this->country_name(); |
|
| 485 | + } |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + |
|
| 489 | + |
|
| 490 | + /** |
|
| 491 | + * get Attendee Zip/Postal Code |
|
| 492 | + * |
|
| 493 | + * @return string |
|
| 494 | + */ |
|
| 495 | + public function zip() |
|
| 496 | + { |
|
| 497 | + return $this->get('ATT_zip'); |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + |
|
| 501 | + |
|
| 502 | + /** |
|
| 503 | + * get Attendee Email Address |
|
| 504 | + * |
|
| 505 | + * @return string |
|
| 506 | + */ |
|
| 507 | + public function email() |
|
| 508 | + { |
|
| 509 | + return $this->get('ATT_email'); |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + |
|
| 513 | + |
|
| 514 | + /** |
|
| 515 | + * get Attendee Phone # |
|
| 516 | + * |
|
| 517 | + * @return string |
|
| 518 | + */ |
|
| 519 | + public function phone() |
|
| 520 | + { |
|
| 521 | + return $this->get('ATT_phone'); |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + |
|
| 525 | + |
|
| 526 | + /** |
|
| 527 | + * get deleted |
|
| 528 | + * |
|
| 529 | + * @return bool |
|
| 530 | + */ |
|
| 531 | + public function deleted() |
|
| 532 | + { |
|
| 533 | + return $this->get('ATT_deleted'); |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * Gets registrations of this attendee |
|
| 540 | + * |
|
| 541 | + * @param array $query_params |
|
| 542 | + * @return EE_Registration[] |
|
| 543 | + */ |
|
| 544 | + public function get_registrations($query_params = array()) |
|
| 545 | + { |
|
| 546 | + return $this->get_many_related('Registration', $query_params); |
|
| 547 | + } |
|
| 548 | + |
|
| 549 | + |
|
| 550 | + |
|
| 551 | + /** |
|
| 552 | + * Gets the most recent registration of this attendee |
|
| 553 | + * |
|
| 554 | + * @return EE_Registration |
|
| 555 | + */ |
|
| 556 | + public function get_most_recent_registration() |
|
| 557 | + { |
|
| 558 | + return $this->get_first_related('Registration', |
|
| 559 | + array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
| 560 | + } |
|
| 561 | + |
|
| 562 | + |
|
| 563 | + |
|
| 564 | + /** |
|
| 565 | + * Gets the most recent registration for this attend at this event |
|
| 566 | + * |
|
| 567 | + * @param int $event_id |
|
| 568 | + * @return EE_Registration |
|
| 569 | + */ |
|
| 570 | + public function get_most_recent_registration_for_event($event_id) |
|
| 571 | + { |
|
| 572 | + return $this->get_first_related('Registration', |
|
| 573 | + array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' ); |
|
| 574 | + } |
|
| 575 | + |
|
| 576 | + |
|
| 577 | + |
|
| 578 | + /** |
|
| 579 | + * returns any events attached to this attendee ($_Event property); |
|
| 580 | + * |
|
| 581 | + * @return array |
|
| 582 | + */ |
|
| 583 | + public function events() |
|
| 584 | + { |
|
| 585 | + return $this->get_many_related('Event'); |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + |
|
| 589 | + |
|
| 590 | + /** |
|
| 591 | + * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
| 592 | + * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
| 593 | + * used to save the billing info |
|
| 594 | + * |
|
| 595 | + * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
| 596 | + * @return EE_Form_Section_Proper|null |
|
| 597 | + */ |
|
| 598 | + public function billing_info_for_payment_method($payment_method) |
|
| 599 | + { |
|
| 600 | + $pm_type = $payment_method->type_obj(); |
|
| 601 | + if ( ! $pm_type instanceof EE_PMT_Base) { |
|
| 602 | + return null; |
|
| 603 | + } |
|
| 604 | + $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
| 605 | + if ( ! $billing_info) { |
|
| 606 | + return null; |
|
| 607 | + } |
|
| 608 | + $billing_form = $pm_type->billing_form(); |
|
| 609 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 610 | + $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
| 611 | + } |
|
| 612 | + return $billing_form; |
|
| 613 | + } |
|
| 614 | + |
|
| 615 | + |
|
| 616 | + |
|
| 617 | + /** |
|
| 618 | + * Gets the postmeta key that holds this attendee's billing info for the |
|
| 619 | + * specified payment method |
|
| 620 | + * |
|
| 621 | + * @param EE_Payment_Method $payment_method |
|
| 622 | + * @return string |
|
| 623 | + */ |
|
| 624 | + public function get_billing_info_postmeta_name($payment_method) |
|
| 625 | + { |
|
| 626 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 627 | + return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
| 628 | + } else { |
|
| 629 | + return null; |
|
| 630 | + } |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + |
|
| 634 | + |
|
| 635 | + /** |
|
| 636 | + * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
| 637 | + * retrieve it |
|
| 638 | + * |
|
| 639 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
| 640 | + * @param EE_Payment_Method $payment_method |
|
| 641 | + * @return boolean |
|
| 642 | + */ |
|
| 643 | + public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
| 644 | + { |
|
| 645 | + if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
| 646 | + EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
| 647 | + return false; |
|
| 648 | + } |
|
| 649 | + $billing_form->clean_sensitive_data(); |
|
| 650 | + return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method), |
|
| 651 | + $billing_form->input_values(true)); |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + |
|
| 655 | + |
|
| 656 | + /** |
|
| 657 | + * Return the link to the admin details for the object. |
|
| 658 | + * |
|
| 659 | + * @return string |
|
| 660 | + */ |
|
| 661 | + public function get_admin_details_link() |
|
| 662 | + { |
|
| 663 | + return $this->get_admin_edit_link(); |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + |
|
| 667 | + |
|
| 668 | + /** |
|
| 669 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 670 | + * |
|
| 671 | + * @return string |
|
| 672 | + */ |
|
| 673 | + public function get_admin_edit_link() |
|
| 674 | + { |
|
| 675 | + EE_Registry::instance()->load_helper('URL'); |
|
| 676 | + return EEH_URL::add_query_args_and_nonce( |
|
| 677 | + array( |
|
| 678 | + 'page' => 'espresso_registrations', |
|
| 679 | + 'action' => 'edit_attendee', |
|
| 680 | + 'post' => $this->ID(), |
|
| 681 | + ), |
|
| 682 | + admin_url('admin.php') |
|
| 683 | + ); |
|
| 684 | + } |
|
| 685 | + |
|
| 686 | + |
|
| 687 | + |
|
| 688 | + /** |
|
| 689 | + * Returns the link to a settings page for the object. |
|
| 690 | + * |
|
| 691 | + * @return string |
|
| 692 | + */ |
|
| 693 | + public function get_admin_settings_link() |
|
| 694 | + { |
|
| 695 | + return $this->get_admin_edit_link(); |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + |
|
| 699 | + |
|
| 700 | + /** |
|
| 701 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 702 | + * |
|
| 703 | + * @return string |
|
| 704 | + */ |
|
| 705 | + public function get_admin_overview_link() |
|
| 706 | + { |
|
| 707 | + EE_Registry::instance()->load_helper('URL'); |
|
| 708 | + return EEH_URL::add_query_args_and_nonce( |
|
| 709 | + array( |
|
| 710 | + 'page' => 'espresso_registrations', |
|
| 711 | + 'action' => 'contact_list', |
|
| 712 | + ), |
|
| 713 | + admin_url('admin.php') |
|
| 714 | + ); |
|
| 715 | + } |
|
| 716 | 716 | |
| 717 | 717 | |
| 718 | 718 | } |