@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | /** |
337 | 337 | * retrieve session data |
338 | 338 | * @access public |
339 | - * @param null $key |
|
339 | + * @param string|null $key |
|
340 | 340 | * @param bool $reset_cache |
341 | 341 | * @return array |
342 | 342 | */ |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * set session data |
361 | 361 | * @access public |
362 | 362 | * @param array $data |
363 | - * @return TRUE on success, FALSE on fail |
|
363 | + * @return boolean on success, FALSE on fail |
|
364 | 364 | */ |
365 | 365 | public function set_session_data( $data ) { |
366 | 366 | |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | /** |
391 | 391 | * @initiate session |
392 | 392 | * @access private |
393 | - * @return TRUE on success, FALSE on fail |
|
393 | + * @return boolean on success, FALSE on fail |
|
394 | 394 | * @throws \EE_Error |
395 | 395 | */ |
396 | 396 | private function _espresso_session() { |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @update session data prior to saving to the db |
522 | 522 | * @access public |
523 | 523 | * @param bool $new_session |
524 | - * @return TRUE on success, FALSE on fail |
|
524 | + * @return boolean on success, FALSE on fail |
|
525 | 525 | */ |
526 | 526 | public function update( $new_session = FALSE ) { |
527 | 527 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | * @access public |
792 | 792 | * @param array $data_to_reset |
793 | 793 | * @param bool $show_all_notices |
794 | - * @return TRUE on success, FALSE on fail |
|
794 | + * @return boolean on success, FALSE on fail |
|
795 | 795 | */ |
796 | 796 | public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
797 | 797 | // if $data_to_reset is not in an array, then put it in one |
@@ -137,11 +137,11 @@ |
||
137 | 137 | |
138 | 138 | |
139 | 139 | /** |
140 | - * private constructor to prevent direct creation |
|
141 | - * @Constructor |
|
142 | - * @access private |
|
143 | - * @return EE_Session |
|
144 | - */ |
|
140 | + * private constructor to prevent direct creation |
|
141 | + * @Constructor |
|
142 | + * @access private |
|
143 | + * @return EE_Session |
|
144 | + */ |
|
145 | 145 | private function __construct() { |
146 | 146 | |
147 | 147 | // 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' ); |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );/** |
3 | 5 | * |
4 | 6 | * Event Espresso |
@@ -349,7 +351,7 @@ discard block |
||
349 | 351 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
350 | 352 | if ( ! empty( $key )) { |
351 | 353 | return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
352 | - } else { |
|
354 | + } else { |
|
353 | 355 | return $this->_session_data; |
354 | 356 | } |
355 | 357 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * Event Espresso |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * array for defining default session vars |
105 | 105 | * @var array |
106 | 106 | */ |
107 | - private $_default_session_vars = array ( |
|
107 | + private $_default_session_vars = array( |
|
108 | 108 | 'id' => NULL, |
109 | 109 | 'user_id' => NULL, |
110 | 110 | 'ip_address' => NULL, |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * @access public |
127 | 127 | * @return EE_Session |
128 | 128 | */ |
129 | - public static function instance ( ) { |
|
129 | + public static function instance( ) { |
|
130 | 130 | // check if class object is instantiated |
131 | - if ( ! self::$_instance instanceof EE_Session ) { |
|
131 | + if ( ! self::$_instance instanceof EE_Session) { |
|
132 | 132 | self::$_instance = new self(); |
133 | 133 | } |
134 | 134 | return self::$_instance; |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | private function __construct() { |
146 | 146 | |
147 | 147 | // 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' ); |
148 | - if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) { |
|
148 | + if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) { |
|
149 | 149 | return NULL; |
150 | 150 | } |
151 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
152 | - define( 'ESPRESSO_SESSION', TRUE ); |
|
151 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
152 | + define('ESPRESSO_SESSION', TRUE); |
|
153 | 153 | // default session lifespan in seconds |
154 | 154 | $this->_lifespan = apply_filters( |
155 | 155 | 'FHEE__EE_Session__construct___lifespan', |
@@ -162,35 +162,35 @@ discard block |
||
162 | 162 | * } |
163 | 163 | */ |
164 | 164 | // retrieve session options from db |
165 | - $session_settings = get_option( 'ee_session_settings' ); |
|
166 | - if ( $session_settings !== FALSE ) { |
|
165 | + $session_settings = get_option('ee_session_settings'); |
|
166 | + if ($session_settings !== FALSE) { |
|
167 | 167 | // cycle though existing session options |
168 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
168 | + foreach ($session_settings as $var_name => $session_setting) { |
|
169 | 169 | // set values for class properties |
170 | - $var_name = '_' . $var_name; |
|
170 | + $var_name = '_'.$var_name; |
|
171 | 171 | $this->{$var_name} = $session_setting; |
172 | 172 | } |
173 | 173 | } |
174 | 174 | // are we using encryption? |
175 | - if ( $this->_use_encryption ) { |
|
175 | + if ($this->_use_encryption) { |
|
176 | 176 | // instantiate the class object making all properties and methods accessible via $this->encryption ex: $this->encryption->encrypt(); |
177 | - $this->encryption = EE_Registry::instance()->load_core( 'Encryption' ); |
|
177 | + $this->encryption = EE_Registry::instance()->load_core('Encryption'); |
|
178 | 178 | } |
179 | 179 | // filter hook allows outside functions/classes/plugins to change default empty cart |
180 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
181 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
180 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
181 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
182 | 182 | // apply default session vars |
183 | 183 | $this->_set_defaults(); |
184 | 184 | // check for existing session and retrieve it from db |
185 | - if ( ! $this->_espresso_session() ) { |
|
185 | + if ( ! $this->_espresso_session()) { |
|
186 | 186 | // or just start a new one |
187 | 187 | $this->_create_espresso_session(); |
188 | 188 | } |
189 | 189 | // check request for 'clear_session' param |
190 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
190 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
191 | 191 | // once everything is all said and done, |
192 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
193 | - add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 ); |
|
192 | + add_action('shutdown', array($this, 'update'), 100); |
|
193 | + add_action('shutdown', array($this, 'garbage_collection'), 999); |
|
194 | 194 | |
195 | 195 | } |
196 | 196 | |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | */ |
223 | 223 | private function _set_defaults() { |
224 | 224 | // set some defaults |
225 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
226 | - if ( is_array( $default_var )) { |
|
227 | - $this->_session_data[ $key ] = array(); |
|
225 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
226 | + if (is_array($default_var)) { |
|
227 | + $this->_session_data[$key] = array(); |
|
228 | 228 | } else { |
229 | - $this->_session_data[ $key ] = ''; |
|
229 | + $this->_session_data[$key] = ''; |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @param \EE_Cart $cart |
249 | 249 | * @return bool |
250 | 250 | */ |
251 | - public function set_cart( EE_Cart $cart ) { |
|
251 | + public function set_cart(EE_Cart $cart) { |
|
252 | 252 | $this->_session_data['cart'] = $cart; |
253 | 253 | return TRUE; |
254 | 254 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @return \EE_Cart |
269 | 269 | */ |
270 | 270 | public function cart() { |
271 | - return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL; |
|
271 | + return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @param \EE_Checkout $checkout |
278 | 278 | * @return bool |
279 | 279 | */ |
280 | - public function set_checkout( EE_Checkout $checkout ) { |
|
280 | + public function set_checkout(EE_Checkout $checkout) { |
|
281 | 281 | $this->_session_data['checkout'] = $checkout; |
282 | 282 | return TRUE; |
283 | 283 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @return \EE_Checkout |
298 | 298 | */ |
299 | 299 | public function checkout() { |
300 | - return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL; |
|
300 | + return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | * @param \EE_Transaction $transaction |
307 | 307 | * @return bool |
308 | 308 | */ |
309 | - public function set_transaction( EE_Transaction $transaction ) { |
|
309 | + public function set_transaction(EE_Transaction $transaction) { |
|
310 | 310 | // first remove the session from the transaction before we save the transaction in the session |
311 | - $transaction->set_txn_session_data( NULL ); |
|
311 | + $transaction->set_txn_session_data(NULL); |
|
312 | 312 | $this->_session_data['transaction'] = $transaction; |
313 | 313 | return TRUE; |
314 | 314 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return \EE_Transaction |
329 | 329 | */ |
330 | 330 | public function transaction() { |
331 | - return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL; |
|
331 | + return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | * @param bool $reset_cache |
341 | 341 | * @return array |
342 | 342 | */ |
343 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
344 | - if ( $reset_cache ) { |
|
343 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
344 | + if ($reset_cache) { |
|
345 | 345 | $this->reset_cart(); |
346 | 346 | $this->reset_checkout(); |
347 | 347 | $this->reset_transaction(); |
348 | 348 | } |
349 | - if ( ! empty( $key )) { |
|
350 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
351 | - } else { |
|
349 | + if ( ! empty($key)) { |
|
350 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
351 | + } else { |
|
352 | 352 | return $this->_session_data; |
353 | 353 | } |
354 | 354 | } |
@@ -361,20 +361,20 @@ discard block |
||
361 | 361 | * @param array $data |
362 | 362 | * @return TRUE on success, FALSE on fail |
363 | 363 | */ |
364 | - public function set_session_data( $data ) { |
|
364 | + public function set_session_data($data) { |
|
365 | 365 | |
366 | 366 | // nothing ??? bad data ??? go home! |
367 | - if ( empty( $data ) || ! is_array( $data )) { |
|
368 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
367 | + if (empty($data) || ! is_array($data)) { |
|
368 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
369 | 369 | return FALSE; |
370 | 370 | } |
371 | 371 | |
372 | - foreach ( $data as $key =>$value ) { |
|
373 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
374 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
372 | + foreach ($data as $key =>$value) { |
|
373 | + if (isset($this->_default_session_vars[$key])) { |
|
374 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
375 | 375 | return FALSE; |
376 | 376 | } else { |
377 | - $this->_session_data[ $key ] = $value; |
|
377 | + $this->_session_data[$key] = $value; |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | * @throws \EE_Error |
392 | 392 | */ |
393 | 393 | private function _espresso_session() { |
394 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
394 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
395 | 395 | // check that session has started |
396 | - if ( session_id() === '' ) { |
|
396 | + if (session_id() === '') { |
|
397 | 397 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
398 | 398 | session_start(); |
399 | 399 | } |
@@ -402,57 +402,57 @@ discard block |
||
402 | 402 | // and the visitors IP |
403 | 403 | $this->_ip_address = $this->_visitor_ip(); |
404 | 404 | // set the "user agent" |
405 | - $this->_user_agent = ( isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
405 | + $this->_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
406 | 406 | // now let's retrieve what's in the db |
407 | 407 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
408 | - $session_data = get_transient( EE_Session::session_id_prefix . $this->_sid ); |
|
409 | - if ( $session_data ) { |
|
410 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
411 | - $hash_check = get_transient( EE_Session::hash_check_prefix . $this->_sid ); |
|
412 | - if ( $hash_check && $hash_check !== md5( $session_data ) ) { |
|
408 | + $session_data = get_transient(EE_Session::session_id_prefix.$this->_sid); |
|
409 | + if ($session_data) { |
|
410 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
411 | + $hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid); |
|
412 | + if ($hash_check && $hash_check !== md5($session_data)) { |
|
413 | 413 | EE_Error::add_error( |
414 | 414 | sprintf( |
415 | - __( 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso' ), |
|
416 | - EE_Session::session_id_prefix . $this->_sid |
|
415 | + __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'), |
|
416 | + EE_Session::session_id_prefix.$this->_sid |
|
417 | 417 | ), |
418 | 418 | __FILE__, __FUNCTION__, __LINE__ |
419 | 419 | ); |
420 | 420 | } |
421 | 421 | } |
422 | 422 | // un-encrypt the data |
423 | - $session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data; |
|
423 | + $session_data = $this->_use_encryption ? $this->encryption->decrypt($session_data) : $session_data; |
|
424 | 424 | // unserialize |
425 | - $session_data = maybe_unserialize( $session_data ); |
|
425 | + $session_data = maybe_unserialize($session_data); |
|
426 | 426 | // just a check to make sure the session array is indeed an array |
427 | - if ( ! is_array( $session_data ) ) { |
|
427 | + if ( ! is_array($session_data)) { |
|
428 | 428 | // no?!?! then something is wrong |
429 | 429 | return FALSE; |
430 | 430 | } |
431 | 431 | // get the current time in UTC |
432 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
432 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
433 | 433 | // and reset the session expiration |
434 | - $this->_expiration = isset( $session_data['expiration'] ) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
434 | + $this->_expiration = isset($session_data['expiration']) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
435 | 435 | |
436 | 436 | } else { |
437 | 437 | // set initial site access time and the session expiration |
438 | 438 | $this->_set_init_access_and_expiration(); |
439 | 439 | // set referer |
440 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) ? esc_attr( $_SERVER['HTTP_REFERER'] ) : ''; |
|
440 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) ? esc_attr($_SERVER['HTTP_REFERER']) : ''; |
|
441 | 441 | // no previous session = go back and create one (on top of the data above) |
442 | 442 | return FALSE; |
443 | 443 | } |
444 | 444 | // now the user agent |
445 | - if ( $session_data['user_agent'] != $this->_user_agent ) { |
|
445 | + if ($session_data['user_agent'] != $this->_user_agent) { |
|
446 | 446 | return FALSE; |
447 | 447 | } |
448 | 448 | // wait a minute... how old are you? |
449 | - if ( $this->_time > $this->_expiration ) { |
|
449 | + if ($this->_time > $this->_expiration) { |
|
450 | 450 | // yer too old fer me! |
451 | 451 | // wipe out everything that isn't a default session datum |
452 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
452 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
453 | 453 | } |
454 | 454 | // make event espresso session data available to plugin |
455 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
455 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
456 | 456 | return TRUE; |
457 | 457 | |
458 | 458 | } |
@@ -470,12 +470,12 @@ discard block |
||
470 | 470 | */ |
471 | 471 | protected function _generate_session_id() { |
472 | 472 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
473 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
474 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
473 | + if (isset($_REQUEST['EESID'])) { |
|
474 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
475 | 475 | } else { |
476 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
476 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
477 | 477 | } |
478 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
478 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | |
@@ -487,20 +487,20 @@ discard block |
||
487 | 487 | */ |
488 | 488 | protected function _get_sid_salt() { |
489 | 489 | // was session id salt already saved to db ? |
490 | - if ( empty( $this->_sid_salt ) ) { |
|
490 | + if (empty($this->_sid_salt)) { |
|
491 | 491 | // no? then maybe use WP defined constant |
492 | - if ( defined( 'AUTH_SALT' ) ) { |
|
492 | + if (defined('AUTH_SALT')) { |
|
493 | 493 | $this->_sid_salt = AUTH_SALT; |
494 | 494 | } |
495 | 495 | // if salt doesn't exist or is too short |
496 | - if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) { |
|
496 | + if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) { |
|
497 | 497 | // create a new one |
498 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
498 | + $this->_sid_salt = wp_generate_password(64); |
|
499 | 499 | } |
500 | 500 | // and save it as a permanent session setting |
501 | - $session_settings = get_option( 'ee_session_settings' ); |
|
502 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
503 | - update_option( 'ee_session_settings', $session_settings ); |
|
501 | + $session_settings = get_option('ee_session_settings'); |
|
502 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
503 | + update_option('ee_session_settings', $session_settings); |
|
504 | 504 | } |
505 | 505 | return $this->_sid_salt; |
506 | 506 | } |
@@ -528,19 +528,19 @@ discard block |
||
528 | 528 | * @param bool $new_session |
529 | 529 | * @return TRUE on success, FALSE on fail |
530 | 530 | */ |
531 | - public function update( $new_session = FALSE ) { |
|
532 | - $this->_session_data = isset( $this->_session_data ) |
|
533 | - && is_array( $this->_session_data ) |
|
534 | - && isset( $this->_session_data['id']) |
|
531 | + public function update($new_session = FALSE) { |
|
532 | + $this->_session_data = isset($this->_session_data) |
|
533 | + && is_array($this->_session_data) |
|
534 | + && isset($this->_session_data['id']) |
|
535 | 535 | ? $this->_session_data |
536 | 536 | : NULL; |
537 | - if ( empty( $this->_session_data )) { |
|
537 | + if (empty($this->_session_data)) { |
|
538 | 538 | $this->_set_defaults(); |
539 | 539 | } |
540 | 540 | $session_data = array(); |
541 | - foreach ( $this->_session_data as $key => $value ) { |
|
541 | + foreach ($this->_session_data as $key => $value) { |
|
542 | 542 | |
543 | - switch( $key ) { |
|
543 | + switch ($key) { |
|
544 | 544 | |
545 | 545 | case 'id' : |
546 | 546 | // session ID |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | break; |
559 | 559 | |
560 | 560 | case 'init_access' : |
561 | - $session_data['init_access'] = absint( $value ); |
|
561 | + $session_data['init_access'] = absint($value); |
|
562 | 562 | break; |
563 | 563 | |
564 | 564 | case 'last_access' : |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | |
569 | 569 | case 'expiration' : |
570 | 570 | // when the session expires |
571 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
571 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
572 | 572 | ? $this->_expiration |
573 | 573 | : $session_data['init_access'] + $this->_lifespan; |
574 | 574 | break; |
@@ -580,11 +580,11 @@ discard block |
||
580 | 580 | |
581 | 581 | case 'pages_visited' : |
582 | 582 | $page_visit = $this->_get_page_visit(); |
583 | - if ( $page_visit ) { |
|
583 | + if ($page_visit) { |
|
584 | 584 | // set pages visited where the first will be the http referrer |
585 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
585 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
586 | 586 | // we'll only save the last 10 page visits. |
587 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
587 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
588 | 588 | } |
589 | 589 | break; |
590 | 590 | |
@@ -598,9 +598,9 @@ discard block |
||
598 | 598 | |
599 | 599 | $this->_session_data = $session_data; |
600 | 600 | // creating a new session does not require saving to the db just yet |
601 | - if ( ! $new_session ) { |
|
601 | + if ( ! $new_session) { |
|
602 | 602 | // ready? let's save |
603 | - if ( $this->_save_session_to_db() ) { |
|
603 | + if ($this->_save_session_to_db()) { |
|
604 | 604 | return TRUE; |
605 | 605 | } else { |
606 | 606 | return FALSE; |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | * @return bool |
622 | 622 | */ |
623 | 623 | private function _create_espresso_session( ) { |
624 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
624 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
625 | 625 | // use the update function for now with $new_session arg set to TRUE |
626 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
626 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | |
@@ -647,15 +647,15 @@ discard block |
||
647 | 647 | return FALSE; |
648 | 648 | } |
649 | 649 | // first serialize all of our session data |
650 | - $session_data = serialize( $this->_session_data ); |
|
650 | + $session_data = serialize($this->_session_data); |
|
651 | 651 | // encrypt it if we are using encryption |
652 | - $session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data; |
|
652 | + $session_data = $this->_use_encryption ? $this->encryption->encrypt($session_data) : $session_data; |
|
653 | 653 | // maybe save hash check |
654 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
655 | - set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan ); |
|
654 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
655 | + set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan); |
|
656 | 656 | } |
657 | 657 | // we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient( transient ID, data, expiry ) |
658 | - return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan ); |
|
658 | + return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | |
@@ -681,10 +681,10 @@ discard block |
||
681 | 681 | 'HTTP_FORWARDED', |
682 | 682 | 'REMOTE_ADDR' |
683 | 683 | ); |
684 | - foreach ( $server_keys as $key ){ |
|
685 | - if ( isset( $_SERVER[ $key ] )) { |
|
686 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
687 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
684 | + foreach ($server_keys as $key) { |
|
685 | + if (isset($_SERVER[$key])) { |
|
686 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
687 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
688 | 688 | $visitor_ip = $ip; |
689 | 689 | } |
690 | 690 | } |
@@ -705,45 +705,45 @@ discard block |
||
705 | 705 | public function _get_page_visit() { |
706 | 706 | |
707 | 707 | // echo '<h3>'. __CLASS__ .'->'.__FUNCTION__.' ( line no: ' . __LINE__ . ' )</h3>'; |
708 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
708 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
709 | 709 | |
710 | 710 | // check for request url |
711 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
711 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
712 | 712 | |
713 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
713 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
714 | 714 | |
715 | - $ru_bits = explode( '?', $request_uri ); |
|
715 | + $ru_bits = explode('?', $request_uri); |
|
716 | 716 | $request_uri = $ru_bits[0]; |
717 | 717 | //echo '<h1>$request_uri ' . $request_uri . '</h1>'; |
718 | 718 | |
719 | 719 | // check for and grab host as well |
720 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
721 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
720 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
721 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
722 | 722 | } else { |
723 | 723 | $http_host = ''; |
724 | 724 | } |
725 | 725 | //echo '<h1>$http_host ' . $http_host . '</h1>'; |
726 | 726 | |
727 | 727 | // check for page_id in SERVER REQUEST |
728 | - if ( isset( $_REQUEST['page_id'] )) { |
|
728 | + if (isset($_REQUEST['page_id'])) { |
|
729 | 729 | // rebuild $e_reg without any of the extra parameters |
730 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
730 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
731 | 731 | } else { |
732 | 732 | $page_id = '?'; |
733 | 733 | } |
734 | 734 | // check for $e_reg in SERVER REQUEST |
735 | - if ( isset( $_REQUEST['ee'] )) { |
|
735 | + if (isset($_REQUEST['ee'])) { |
|
736 | 736 | // rebuild $e_reg without any of the extra parameters |
737 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
737 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
738 | 738 | } else { |
739 | 739 | $e_reg = ''; |
740 | 740 | } |
741 | 741 | |
742 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
742 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
743 | 743 | |
744 | 744 | } |
745 | 745 | |
746 | - return $page_visit != home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
746 | + return $page_visit != home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
747 | 747 | |
748 | 748 | } |
749 | 749 | |
@@ -772,14 +772,14 @@ discard block |
||
772 | 772 | * @param string $function |
773 | 773 | * @return void |
774 | 774 | */ |
775 | - public function clear_session( $class = '', $function = '' ) { |
|
775 | + public function clear_session($class = '', $function = '') { |
|
776 | 776 | //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>'; |
777 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
777 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
778 | 778 | $this->reset_cart(); |
779 | 779 | $this->reset_checkout(); |
780 | 780 | $this->reset_transaction(); |
781 | 781 | // wipe out everything that isn't a default session datum |
782 | - $this->reset_data( array_keys( $this->_session_data )); |
|
782 | + $this->reset_data(array_keys($this->_session_data)); |
|
783 | 783 | // reset initial site access time and the session expiration |
784 | 784 | $this->_set_init_access_and_expiration(); |
785 | 785 | $this->_save_session_to_db(); |
@@ -794,42 +794,42 @@ discard block |
||
794 | 794 | * @param bool $show_all_notices |
795 | 795 | * @return TRUE on success, FALSE on fail |
796 | 796 | */ |
797 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
797 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
798 | 798 | // if $data_to_reset is not in an array, then put it in one |
799 | - if ( ! is_array( $data_to_reset ) ) { |
|
800 | - $data_to_reset = array ( $data_to_reset ); |
|
799 | + if ( ! is_array($data_to_reset)) { |
|
800 | + $data_to_reset = array($data_to_reset); |
|
801 | 801 | } |
802 | 802 | // nothing ??? go home! |
803 | - if ( empty( $data_to_reset )) { |
|
804 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
803 | + if (empty($data_to_reset)) { |
|
804 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
805 | 805 | return FALSE; |
806 | 806 | } |
807 | 807 | $return_value = TRUE; |
808 | 808 | // since $data_to_reset is an array, cycle through the values |
809 | - foreach ( $data_to_reset as $reset ) { |
|
809 | + foreach ($data_to_reset as $reset) { |
|
810 | 810 | |
811 | 811 | // first check to make sure it is a valid session var |
812 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
812 | + if (isset($this->_session_data[$reset])) { |
|
813 | 813 | // then check to make sure it is not a default var |
814 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
814 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
815 | 815 | // remove session var |
816 | - unset( $this->_session_data[ $reset ] ); |
|
817 | - if ( $show_all_notices ) { |
|
818 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
816 | + unset($this->_session_data[$reset]); |
|
817 | + if ($show_all_notices) { |
|
818 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
819 | 819 | } |
820 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
820 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
821 | 821 | |
822 | 822 | } else { |
823 | 823 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
824 | - if ( $show_all_notices ) { |
|
825 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
824 | + if ($show_all_notices) { |
|
825 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
826 | 826 | } |
827 | 827 | $return_value = FALSE; |
828 | 828 | } |
829 | 829 | |
830 | - } else if ( $show_all_notices ) { |
|
830 | + } else if ($show_all_notices) { |
|
831 | 831 | // oops! that session var does not exist! |
832 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
832 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
833 | 833 | $return_value = FALSE; |
834 | 834 | } |
835 | 835 | |
@@ -850,8 +850,8 @@ discard block |
||
850 | 850 | * @return string |
851 | 851 | */ |
852 | 852 | public function wp_loaded() { |
853 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
854 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
853 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
854 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | |
@@ -876,24 +876,24 @@ discard block |
||
876 | 876 | */ |
877 | 877 | public function garbage_collection() { |
878 | 878 | // only perform during regular requests |
879 | - if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) { |
|
879 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
880 | 880 | /** @type WPDB $wpdb */ |
881 | 881 | global $wpdb; |
882 | 882 | // since transient expiration timestamps are set in the future, we can compare against NOW |
883 | 883 | $expiration = time(); |
884 | - $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 ); |
|
884 | + $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2); |
|
885 | 885 | // filter the query limit. Set to 0 to turn off garbage collection |
886 | - $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 )); |
|
886 | + $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50)); |
|
887 | 887 | // non-zero LIMIT means take out the trash |
888 | - if ( $expired_session_transient_delete_query_limit ) { |
|
888 | + if ($expired_session_transient_delete_query_limit) { |
|
889 | 889 | //array of transient keys that require garbage collection |
890 | 890 | $session_keys = array( |
891 | 891 | EE_Session::session_id_prefix, |
892 | 892 | EE_Session::hash_check_prefix, |
893 | 893 | ); |
894 | - foreach ( $session_keys as $session_key ) { |
|
895 | - $session_key = str_replace( '_', '\_', $session_key ); |
|
896 | - $session_key = '\_transient\_timeout\_' . $session_key . '%'; |
|
894 | + foreach ($session_keys as $session_key) { |
|
895 | + $session_key = str_replace('_', '\_', $session_key); |
|
896 | + $session_key = '\_transient\_timeout\_'.$session_key.'%'; |
|
897 | 897 | $SQL = " |
898 | 898 | SELECT option_name |
899 | 899 | FROM {$wpdb->options} |
@@ -903,28 +903,28 @@ discard block |
||
903 | 903 | OR option_value > {$too_far_in_the_the_future} ) |
904 | 904 | LIMIT {$expired_session_transient_delete_query_limit} |
905 | 905 | "; |
906 | - $expired_sessions = $wpdb->get_col( $SQL ); |
|
906 | + $expired_sessions = $wpdb->get_col($SQL); |
|
907 | 907 | // valid results? |
908 | - if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) { |
|
908 | + if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) { |
|
909 | 909 | // format array of results into something usable within the actual DELETE query's IN clause |
910 | 910 | $expired = array(); |
911 | - foreach ( $expired_sessions as $expired_session ) { |
|
912 | - $expired[ ] = "'" . $expired_session . "'"; |
|
913 | - $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'"; |
|
911 | + foreach ($expired_sessions as $expired_session) { |
|
912 | + $expired[] = "'".$expired_session."'"; |
|
913 | + $expired[] = "'".str_replace('timeout_', '', $expired_session)."'"; |
|
914 | 914 | } |
915 | - $expired = implode( ', ', $expired ); |
|
915 | + $expired = implode(', ', $expired); |
|
916 | 916 | $SQL = " |
917 | 917 | DELETE FROM {$wpdb->options} |
918 | 918 | WHERE option_name |
919 | 919 | IN ( $expired ); |
920 | 920 | "; |
921 | - $results = $wpdb->query( $SQL ); |
|
921 | + $results = $wpdb->query($SQL); |
|
922 | 922 | // if something went wrong, then notify the admin |
923 | - if ( $results instanceof WP_Error && is_admin() ) { |
|
924 | - EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
923 | + if ($results instanceof WP_Error && is_admin()) { |
|
924 | + EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
925 | 925 | } |
926 | 926 | } |
927 | - do_action( 'FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit ); |
|
927 | + do_action('FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | } |
@@ -613,7 +613,7 @@ |
||
613 | 613 | * so that it will be done when migrations are finished |
614 | 614 | * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
615 | 615 | * however, |
616 | - * @param boolean $verify_db_schema if true will re-check the database tables have the correct schema. This is a resource-intensive job |
|
616 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. This is a resource-intensive job |
|
617 | 617 | * so we prefer to only do it when necessary |
618 | 618 | * @return void |
619 | 619 | */ |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -578,7 +580,7 @@ discard block |
||
578 | 580 | $espresso_db_update = array( $espresso_db_update=>array() ); |
579 | 581 | update_option( 'espresso_db_update', $espresso_db_update ); |
580 | 582 | } |
581 | - }else{ |
|
583 | + } else{ |
|
582 | 584 | $corrected_db_update = array(); |
583 | 585 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
584 | 586 | foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
@@ -588,7 +590,7 @@ discard block |
||
588 | 590 | //fix it! |
589 | 591 | $version_string = $should_be_array; |
590 | 592 | $corrected_db_update[$version_string] = array('unknown-date'); |
591 | - }else{ |
|
593 | + } else{ |
|
592 | 594 | //ok it checks out |
593 | 595 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
594 | 596 | } |
@@ -633,7 +635,7 @@ discard block |
||
633 | 635 | $addon->initialize_db_if_no_migrations_required(); |
634 | 636 | } |
635 | 637 | } |
636 | - }else{ |
|
638 | + } else{ |
|
637 | 639 | EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
638 | 640 | } |
639 | 641 | if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
@@ -703,7 +705,7 @@ discard block |
||
703 | 705 | //it a version we haven't seen before |
704 | 706 | if( $version_is_higher === 1 ){ |
705 | 707 | $req_type = EE_System::req_type_upgrade; |
706 | - }else{ |
|
708 | + } else{ |
|
707 | 709 | $req_type = EE_System::req_type_downgrade; |
708 | 710 | } |
709 | 711 | delete_option( $activation_indicator_option_name ); |
@@ -712,10 +714,10 @@ discard block |
||
712 | 714 | if( get_option( $activation_indicator_option_name, FALSE ) ){ |
713 | 715 | if ( $version_is_higher === -1 ){ |
714 | 716 | $req_type = EE_System::req_type_downgrade; |
715 | - }elseif( $version_is_higher === 0 ){ |
|
717 | + } elseif( $version_is_higher === 0 ){ |
|
716 | 718 | //we've seen this version before, but it's an activation. must be a reactivation |
717 | 719 | $req_type = EE_System::req_type_reactivation; |
718 | - }else{//$version_is_higher === 1 |
|
720 | + } else{//$version_is_higher === 1 |
|
719 | 721 | $req_type = EE_System::req_type_upgrade; |
720 | 722 | } |
721 | 723 | delete_option( $activation_indicator_option_name ); |
@@ -723,10 +725,10 @@ discard block |
||
723 | 725 | //we've seen this version before and the activation indicate doesn't show it was just activated |
724 | 726 | if ( $version_is_higher === -1 ){ |
725 | 727 | $req_type = EE_System::req_type_downgrade; |
726 | - }elseif( $version_is_higher === 0 ){ |
|
728 | + } elseif( $version_is_higher === 0 ){ |
|
727 | 729 | //we've seen this version before and it's not an activation. its normal request |
728 | 730 | $req_type = EE_System::req_type_normal; |
729 | - }else{//$version_is_higher === 1 |
|
731 | + } else{//$version_is_higher === 1 |
|
730 | 732 | $req_type = EE_System::req_type_upgrade; |
731 | 733 | } |
732 | 734 | } |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | |
204 | 204 | |
205 | 205 | /** |
206 | - * detect_if_activation_or_upgrade |
|
207 | - * |
|
208 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
209 | - * and either setting up the DB or setting up maintenance mode etc. |
|
210 | - * |
|
211 | - * @access public |
|
212 | - * @return void |
|
213 | - */ |
|
206 | + * detect_if_activation_or_upgrade |
|
207 | + * |
|
208 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
209 | + * and either setting up the DB or setting up maintenance mode etc. |
|
210 | + * |
|
211 | + * @access public |
|
212 | + * @return void |
|
213 | + */ |
|
214 | 214 | public function detect_if_activation_or_upgrade() { |
215 | 215 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
216 | 216 | |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | $query_params = array( 'page' => 'espresso_about' ); |
515 | 515 | |
516 | 516 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
517 | - $query_params['new_activation'] = TRUE; |
|
517 | + $query_params['new_activation'] = TRUE; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
521 | - $query_params['reactivation'] = TRUE; |
|
521 | + $query_params['reactivation'] = TRUE; |
|
522 | 522 | } |
523 | 523 | $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
524 | 524 | wp_safe_redirect( $url ); |
@@ -621,11 +621,11 @@ discard block |
||
621 | 621 | |
622 | 622 | |
623 | 623 | /** |
624 | - * _incompatible_addon_error |
|
625 | - * |
|
626 | - * @access public |
|
627 | - * @return void |
|
628 | - */ |
|
624 | + * _incompatible_addon_error |
|
625 | + * |
|
626 | + * @access public |
|
627 | + * @return void |
|
628 | + */ |
|
629 | 629 | private function _incompatible_addon_error() { |
630 | 630 | // get array of classes hooking into here |
631 | 631 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
@@ -747,14 +747,14 @@ discard block |
||
747 | 747 | |
748 | 748 | |
749 | 749 | /** |
750 | - * load_controllers |
|
751 | - * |
|
752 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
753 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
754 | - * |
|
755 | - * @access public |
|
756 | - * @return void |
|
757 | - */ |
|
750 | + * load_controllers |
|
751 | + * |
|
752 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
753 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
754 | + * |
|
755 | + * @access public |
|
756 | + * @return void |
|
757 | + */ |
|
758 | 758 | public function load_controllers() { |
759 | 759 | do_action( 'AHEE__EE_System__load_controllers__start' ); |
760 | 760 | // let's get it started |
@@ -771,13 +771,13 @@ discard block |
||
771 | 771 | |
772 | 772 | |
773 | 773 | /** |
774 | - * core_loaded_and_ready |
|
775 | - * |
|
776 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
777 | - * |
|
778 | - * @access public |
|
779 | - * @return void |
|
780 | - */ |
|
774 | + * core_loaded_and_ready |
|
775 | + * |
|
776 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
777 | + * |
|
778 | + * @access public |
|
779 | + * @return void |
|
780 | + */ |
|
781 | 781 | public function core_loaded_and_ready() { |
782 | 782 | do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
783 | 783 | do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
@@ -788,13 +788,13 @@ discard block |
||
788 | 788 | |
789 | 789 | |
790 | 790 | /** |
791 | - * initialize |
|
792 | - * |
|
793 | - * this is the best place to begin initializing client code |
|
794 | - * |
|
795 | - * @access public |
|
796 | - * @return void |
|
797 | - */ |
|
791 | + * initialize |
|
792 | + * |
|
793 | + * this is the best place to begin initializing client code |
|
794 | + * |
|
795 | + * @access public |
|
796 | + * @return void |
|
797 | + */ |
|
798 | 798 | public function initialize() { |
799 | 799 | do_action( 'AHEE__EE_System__initialize' ); |
800 | 800 | } |
@@ -802,13 +802,13 @@ discard block |
||
802 | 802 | |
803 | 803 | |
804 | 804 | /** |
805 | - * initialize_last |
|
806 | - * |
|
807 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
808 | - * |
|
809 | - * @access public |
|
810 | - * @return void |
|
811 | - */ |
|
805 | + * initialize_last |
|
806 | + * |
|
807 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
808 | + * |
|
809 | + * @access public |
|
810 | + * @return void |
|
811 | + */ |
|
812 | 812 | public function initialize_last() { |
813 | 813 | do_action( 'AHEE__EE_System__initialize_last' ); |
814 | 814 | } |
@@ -817,14 +817,14 @@ discard block |
||
817 | 817 | |
818 | 818 | |
819 | 819 | /** |
820 | - * set_hooks_for_shortcodes_modules_and_addons |
|
821 | - * |
|
822 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
823 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
824 | - * |
|
825 | - * @access public |
|
826 | - * @return void |
|
827 | - */ |
|
820 | + * set_hooks_for_shortcodes_modules_and_addons |
|
821 | + * |
|
822 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
823 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
824 | + * |
|
825 | + * @access public |
|
826 | + * @return void |
|
827 | + */ |
|
828 | 828 | public function set_hooks_for_shortcodes_modules_and_addons() { |
829 | 829 | // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
830 | 830 | } |
@@ -833,13 +833,13 @@ discard block |
||
833 | 833 | |
834 | 834 | |
835 | 835 | /** |
836 | - * do_not_cache |
|
837 | - * |
|
838 | - * sets no cache headers and defines no cache constants for WP plugins |
|
839 | - * |
|
840 | - * @access public |
|
841 | - * @return void |
|
842 | - */ |
|
836 | + * do_not_cache |
|
837 | + * |
|
838 | + * sets no cache headers and defines no cache constants for WP plugins |
|
839 | + * |
|
840 | + * @access public |
|
841 | + * @return void |
|
842 | + */ |
|
843 | 843 | public static function do_not_cache() { |
844 | 844 | // set no cache constants |
845 | 845 | if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | //Current post |
958 | 958 | global $post; |
959 | 959 | |
960 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
960 | + if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
961 | 961 | //Events Edit Current Event |
962 | 962 | $admin_bar->add_menu(array( |
963 | 963 | 'id' => 'espresso-toolbar-events-edit', |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public static function instance() { |
104 | 104 | // check if class object is instantiated |
105 | - if ( ! self::$_instance instanceof EE_System ) { |
|
105 | + if ( ! self::$_instance instanceof EE_System) { |
|
106 | 106 | self::$_instance = new self(); |
107 | 107 | } |
108 | 108 | return self::$_instance; |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * resets the instance and returns it |
114 | 114 | * @return EE_System |
115 | 115 | */ |
116 | - public static function reset(){ |
|
116 | + public static function reset() { |
|
117 | 117 | self::$_instance->_req_type = NULL; |
118 | 118 | //we need to reset the migration manager in order for it to detect DMSs properly |
119 | 119 | EE_Data_Migration_Manager::reset(); |
120 | 120 | //make sure none of the old hooks are left hanging around |
121 | - remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
121 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
122 | 122 | self::instance()->detect_activations_or_upgrades(); |
123 | 123 | self::instance()->perform_activations_upgrades_and_migrations(); |
124 | 124 | return self::instance(); |
@@ -134,26 +134,26 @@ discard block |
||
134 | 134 | * @access private |
135 | 135 | */ |
136 | 136 | private function __construct() { |
137 | - do_action( 'AHEE__EE_System__construct__begin', $this ); |
|
137 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
138 | 138 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
139 | - add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'load_espresso_addons' ) ); |
|
139 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
140 | 140 | // when an ee addon is activated, we want to call the core hook(s) again |
141 | 141 | // because the newly-activated addon didn't get a chance to run at all |
142 | - add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 ); |
|
142 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
143 | 143 | // detect whether install or upgrade |
144 | - add_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array( $this, 'detect_activations_or_upgrades' ), 3 ); |
|
144 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), 3); |
|
145 | 145 | // load EE_Config, EE_Textdomain, etc |
146 | - add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 5 ); |
|
146 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
147 | 147 | // load EE_Config, EE_Textdomain, etc |
148 | - add_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
148 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
149 | 149 | // you wanna get going? I wanna get going... let's get going! |
150 | - add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 9 ); |
|
150 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
151 | 151 | //other housekeeping |
152 | 152 | //exclude EE critical pages from wp_list_pages |
153 | - add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 ); |
|
153 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
154 | 154 | // ALL EE Addons should use the following hook point to attach their initial setup too |
155 | 155 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
156 | - do_action( 'AHEE__EE_System__construct__complete', $this ); |
|
156 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -173,30 +173,30 @@ discard block |
||
173 | 173 | public function load_espresso_addons() { |
174 | 174 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
175 | 175 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
176 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' ); |
|
176 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
177 | 177 | //load and setup EE_Capabilities |
178 | - EE_Registry::instance()->load_core( 'Capabilities' ); |
|
178 | + EE_Registry::instance()->load_core('Capabilities'); |
|
179 | 179 | //caps need to be initialized on every request so that capability maps are set. |
180 | 180 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
181 | 181 | EE_Registry::instance()->CAP->init_caps(); |
182 | - do_action( 'AHEE__EE_System__load_espresso_addons' ); |
|
182 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
183 | 183 | //if the WP API basic auth plugin isn't already loaded, load it now. |
184 | 184 | //We want it for mobile apps. Just include the entire plugin |
185 | 185 | //also, don't load the basic auth when a plugin is getting activated, because |
186 | 186 | //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
187 | 187 | //and causes a fatal error |
188 | - if( !function_exists( 'json_basic_auth_handler' ) |
|
189 | - && ! function_exists( 'json_basic_auth_error' ) |
|
188 | + if ( ! function_exists('json_basic_auth_handler') |
|
189 | + && ! function_exists('json_basic_auth_error') |
|
190 | 190 | && ! ( |
191 | - isset( $_GET[ 'action'] ) |
|
192 | - && in_array( $_GET[ 'action' ], array( 'activate', 'activate-selected' ) ) |
|
191 | + isset($_GET['action']) |
|
192 | + && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
193 | 193 | ) |
194 | 194 | && ! ( |
195 | - isset( $_GET['activate' ] ) |
|
196 | - && $_GET['activate' ] === 'true' |
|
195 | + isset($_GET['activate']) |
|
196 | + && $_GET['activate'] === 'true' |
|
197 | 197 | ) |
198 | 198 | ) { |
199 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
199 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | * @access public |
213 | 213 | * @return void |
214 | 214 | */ |
215 | - public function detect_activations_or_upgrades(){ |
|
215 | + public function detect_activations_or_upgrades() { |
|
216 | 216 | //first off: let's make sure to handle core |
217 | 217 | $this->detect_if_activation_or_upgrade(); |
218 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
218 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
219 | 219 | //detect teh request type for that addon |
220 | 220 | $addon->detect_activation_or_upgrade(); |
221 | 221 | } |
@@ -236,44 +236,44 @@ discard block |
||
236 | 236 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
237 | 237 | |
238 | 238 | // load M-Mode class |
239 | - EE_Registry::instance()->load_core( 'Maintenance_Mode' ); |
|
239 | + EE_Registry::instance()->load_core('Maintenance_Mode'); |
|
240 | 240 | // check if db has been updated, or if its a brand-new installation |
241 | 241 | |
242 | 242 | $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
243 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
243 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
244 | 244 | //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
245 | - if( $request_type != EE_System::req_type_normal){ |
|
245 | + if ($request_type != EE_System::req_type_normal) { |
|
246 | 246 | EE_Registry::instance()->load_helper('Activation'); |
247 | 247 | } |
248 | 248 | |
249 | - switch($request_type){ |
|
249 | + switch ($request_type) { |
|
250 | 250 | case EE_System::req_type_new_activation: |
251 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' ); |
|
252 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
251 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
252 | + $this->_handle_core_version_change($espresso_db_update); |
|
253 | 253 | break; |
254 | 254 | case EE_System::req_type_reactivation: |
255 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' ); |
|
256 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
255 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
256 | + $this->_handle_core_version_change($espresso_db_update); |
|
257 | 257 | break; |
258 | 258 | case EE_System::req_type_upgrade: |
259 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' ); |
|
259 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
260 | 260 | //migrations may be required now that we've upgraded |
261 | 261 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
262 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
262 | + $this->_handle_core_version_change($espresso_db_update); |
|
263 | 263 | // echo "done upgrade";die; |
264 | 264 | break; |
265 | 265 | case EE_System::req_type_downgrade: |
266 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' ); |
|
266 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
267 | 267 | //its possible migrations are no longer required |
268 | 268 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
269 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
269 | + $this->_handle_core_version_change($espresso_db_update); |
|
270 | 270 | break; |
271 | 271 | case EE_System::req_type_normal: |
272 | 272 | default: |
273 | 273 | // $this->_maybe_redirect_to_ee_about(); |
274 | 274 | break; |
275 | 275 | } |
276 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' ); |
|
276 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | * initializing the database later during the request |
282 | 282 | * @param array $espresso_db_update |
283 | 283 | */ |
284 | - protected function _handle_core_version_change( $espresso_db_update ){ |
|
285 | - $this->update_list_of_installed_versions( $espresso_db_update ); |
|
284 | + protected function _handle_core_version_change($espresso_db_update) { |
|
285 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
286 | 286 | //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
287 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )); |
|
287 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -299,44 +299,44 @@ discard block |
||
299 | 299 | * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table |
300 | 300 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
301 | 301 | */ |
302 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null){ |
|
303 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update ); |
|
304 | - if( ! $espresso_db_update){ |
|
305 | - $espresso_db_update = get_option( 'espresso_db_update' ); |
|
302 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) { |
|
303 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
304 | + if ( ! $espresso_db_update) { |
|
305 | + $espresso_db_update = get_option('espresso_db_update'); |
|
306 | 306 | } |
307 | 307 | // check that option is an array |
308 | - if( ! is_array( $espresso_db_update )) { |
|
308 | + if ( ! is_array($espresso_db_update)) { |
|
309 | 309 | // if option is FALSE, then it never existed |
310 | - if ( $espresso_db_update === FALSE ) { |
|
310 | + if ($espresso_db_update === FALSE) { |
|
311 | 311 | // make $espresso_db_update an array and save option with autoload OFF |
312 | - $espresso_db_update = array(); |
|
313 | - add_option( 'espresso_db_update', $espresso_db_update, '', 'no' ); |
|
312 | + $espresso_db_update = array(); |
|
313 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
314 | 314 | } else { |
315 | 315 | // option is NOT FALSE but also is NOT an array, so make it an array and save it |
316 | - $espresso_db_update = array( $espresso_db_update=>array() ); |
|
317 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
316 | + $espresso_db_update = array($espresso_db_update=>array()); |
|
317 | + update_option('espresso_db_update', $espresso_db_update); |
|
318 | 318 | } |
319 | - }else{ |
|
319 | + } else { |
|
320 | 320 | $corrected_db_update = array(); |
321 | 321 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
322 | - foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
|
323 | - if(is_int($should_be_version_string) && ! is_array($should_be_array)){ |
|
322 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
323 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
324 | 324 | //the key is an int, and the value IS NOT an array |
325 | 325 | //so it must be numerically-indexed, where values are versions installed... |
326 | 326 | //fix it! |
327 | 327 | $version_string = $should_be_array; |
328 | 328 | $corrected_db_update[$version_string] = array('unknown-date'); |
329 | - }else{ |
|
329 | + } else { |
|
330 | 330 | //ok it checks out |
331 | 331 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
332 | 332 | } |
333 | 333 | } |
334 | 334 | $espresso_db_update = $corrected_db_update; |
335 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
335 | + update_option('espresso_db_update', $espresso_db_update); |
|
336 | 336 | |
337 | 337 | } |
338 | 338 | |
339 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update ); |
|
339 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
340 | 340 | return $espresso_db_update; |
341 | 341 | } |
342 | 342 | |
@@ -355,34 +355,34 @@ discard block |
||
355 | 355 | * so we prefer to only do it when necessary |
356 | 356 | * @return void |
357 | 357 | */ |
358 | - public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){ |
|
358 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) { |
|
359 | 359 | $request_type = $this->detect_req_type(); |
360 | 360 | //only initialize system if we're not in maintenance mode. |
361 | - if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
362 | - update_option( 'ee_flush_rewrite_rules', TRUE ); |
|
361 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
362 | + update_option('ee_flush_rewrite_rules', TRUE); |
|
363 | 363 | |
364 | - if( $verify_schema ) { |
|
364 | + if ($verify_schema) { |
|
365 | 365 | EEH_Activation::initialize_db_and_folders(); |
366 | 366 | } |
367 | 367 | EEH_Activation::initialize_db_content(); |
368 | 368 | EEH_Activation::system_initialization(); |
369 | - if( $initialize_addons_too ) { |
|
369 | + if ($initialize_addons_too) { |
|
370 | 370 | $this->initialize_addons(); |
371 | 371 | } |
372 | - }else{ |
|
373 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
|
372 | + } else { |
|
373 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
374 | 374 | } |
375 | - if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
|
376 | - add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 ); |
|
375 | + if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) { |
|
376 | + add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
381 | 381 | * Initializes the db for all registered addons |
382 | 382 | */ |
383 | - public function initialize_addons(){ |
|
383 | + public function initialize_addons() { |
|
384 | 384 | //foreach registered addon, make sure its db is up-to-date too |
385 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
385 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
386 | 386 | $addon->initialize_db_if_no_migrations_required(); |
387 | 387 | } |
388 | 388 | } |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | * @param string $current_version_to_add version to be added to the version history |
395 | 395 | * @return boolean success as to whether or not this option was changed |
396 | 396 | */ |
397 | - public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
|
398 | - if( ! $version_history ) { |
|
397 | + public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) { |
|
398 | + if ( ! $version_history) { |
|
399 | 399 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
400 | 400 | } |
401 | - if( $current_version_to_add == NULL){ |
|
401 | + if ($current_version_to_add == NULL) { |
|
402 | 402 | $current_version_to_add = espresso_version(); |
403 | 403 | } |
404 | - $version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() ); |
|
404 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
405 | 405 | // re-save |
406 | - return update_option( 'espresso_db_update', $version_history ); |
|
406 | + return update_option('espresso_db_update', $version_history); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -420,10 +420,10 @@ discard block |
||
420 | 420 | * but still know if this is a new install or not |
421 | 421 | * @return int one of the constants on EE_System::req_type_ |
422 | 422 | */ |
423 | - public function detect_req_type( $espresso_db_update = NULL ){ |
|
424 | - if ( $this->_req_type === NULL ){ |
|
425 | - $espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
426 | - $this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() ); |
|
423 | + public function detect_req_type($espresso_db_update = NULL) { |
|
424 | + if ($this->_req_type === NULL) { |
|
425 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
426 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version()); |
|
427 | 427 | } |
428 | 428 | return $this->_req_type; |
429 | 429 | } |
@@ -439,39 +439,39 @@ discard block |
||
439 | 439 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version()) |
440 | 440 | * @return int one of the constants on EE_System::req_type_* |
441 | 441 | */ |
442 | - public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){ |
|
443 | - $version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ); |
|
444 | - if( $activation_history_for_addon ){ |
|
442 | + public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) { |
|
443 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
444 | + if ($activation_history_for_addon) { |
|
445 | 445 | //it exists, so this isn't a completely new install |
446 | 446 | //check if this version already in that list of previously installed versions |
447 | - if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) { |
|
447 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
448 | 448 | //it a version we haven't seen before |
449 | - if( $version_is_higher === 1 ){ |
|
449 | + if ($version_is_higher === 1) { |
|
450 | 450 | $req_type = EE_System::req_type_upgrade; |
451 | - }else{ |
|
451 | + } else { |
|
452 | 452 | $req_type = EE_System::req_type_downgrade; |
453 | 453 | } |
454 | - delete_option( $activation_indicator_option_name ); |
|
454 | + delete_option($activation_indicator_option_name); |
|
455 | 455 | } else { |
456 | 456 | // its not an update. maybe a reactivation? |
457 | - if( get_option( $activation_indicator_option_name, FALSE ) ){ |
|
458 | - if ( $version_is_higher === -1 ){ |
|
457 | + if (get_option($activation_indicator_option_name, FALSE)) { |
|
458 | + if ($version_is_higher === -1) { |
|
459 | 459 | $req_type = EE_System::req_type_downgrade; |
460 | - }elseif( $version_is_higher === 0 ){ |
|
460 | + }elseif ($version_is_higher === 0) { |
|
461 | 461 | //we've seen this version before, but it's an activation. must be a reactivation |
462 | 462 | $req_type = EE_System::req_type_reactivation; |
463 | - }else{//$version_is_higher === 1 |
|
463 | + } else {//$version_is_higher === 1 |
|
464 | 464 | $req_type = EE_System::req_type_upgrade; |
465 | 465 | } |
466 | - delete_option( $activation_indicator_option_name ); |
|
466 | + delete_option($activation_indicator_option_name); |
|
467 | 467 | } else { |
468 | 468 | //we've seen this version before and the activation indicate doesn't show it was just activated |
469 | - if ( $version_is_higher === -1 ){ |
|
469 | + if ($version_is_higher === -1) { |
|
470 | 470 | $req_type = EE_System::req_type_downgrade; |
471 | - }elseif( $version_is_higher === 0 ){ |
|
471 | + }elseif ($version_is_higher === 0) { |
|
472 | 472 | //we've seen this version before and it's not an activation. its normal request |
473 | 473 | $req_type = EE_System::req_type_normal; |
474 | - }else{//$version_is_higher === 1 |
|
474 | + } else {//$version_is_higher === 1 |
|
475 | 475 | $req_type = EE_System::req_type_upgrade; |
476 | 476 | } |
477 | 477 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | } else { |
480 | 480 | //brand new install |
481 | 481 | $req_type = EE_System::req_type_new_activation; |
482 | - delete_option( $activation_indicator_option_name ); |
|
482 | + delete_option($activation_indicator_option_name); |
|
483 | 483 | } |
484 | 484 | return $req_type; |
485 | 485 | } |
@@ -497,30 +497,30 @@ discard block |
||
497 | 497 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
498 | 498 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
499 | 499 | */ |
500 | - protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){ |
|
500 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) { |
|
501 | 501 | //find the most recently-activated version |
502 | 502 | $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
503 | 503 | $most_recently_active_version = '0.0.0.dev.000'; |
504 | - if( is_array( $activation_history_for_addon ) ){ |
|
505 | - foreach( $activation_history_for_addon as $version => $times_activated ){ |
|
504 | + if (is_array($activation_history_for_addon)) { |
|
505 | + foreach ($activation_history_for_addon as $version => $times_activated) { |
|
506 | 506 | //check there is a record of when this version was activated. Otherwise, |
507 | 507 | //mark it as unknown |
508 | - if( ! $times_activated ){ |
|
509 | - $times_activated = array( 'unknown-date'); |
|
508 | + if ( ! $times_activated) { |
|
509 | + $times_activated = array('unknown-date'); |
|
510 | 510 | } |
511 | - if( is_string( $times_activated ) ){ |
|
512 | - $times_activated = array( $times_activated ); |
|
511 | + if (is_string($times_activated)) { |
|
512 | + $times_activated = array($times_activated); |
|
513 | 513 | } |
514 | - foreach( $times_activated as $an_activation ){ |
|
515 | - if( $an_activation != 'unknown-date' && |
|
516 | - $an_activation > $most_recently_active_version_activation ){ |
|
514 | + foreach ($times_activated as $an_activation) { |
|
515 | + if ($an_activation != 'unknown-date' && |
|
516 | + $an_activation > $most_recently_active_version_activation) { |
|
517 | 517 | $most_recently_active_version = $version; |
518 | 518 | $most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation; |
519 | 519 | } |
520 | 520 | } |
521 | 521 | } |
522 | 522 | } |
523 | - return version_compare( $version_to_upgrade_to, $most_recently_active_version ); |
|
523 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | |
@@ -530,20 +530,20 @@ discard block |
||
530 | 530 | * @return void |
531 | 531 | */ |
532 | 532 | public function redirect_to_about_ee() { |
533 | - $notices = EE_Error::get_notices( FALSE ); |
|
533 | + $notices = EE_Error::get_notices(FALSE); |
|
534 | 534 | //if current user is an admin and it's not an ajax request |
535 | - if(EE_Registry::instance()->CAP->current_user_can( 'manage_options', 'espresso_about_default' ) && ! ( defined('DOING_AJAX') && DOING_AJAX ) && ! isset( $notices[ 'errors' ] ) ){ |
|
536 | - $query_params = array( 'page' => 'espresso_about' ); |
|
535 | + if (EE_Registry::instance()->CAP->current_user_can('manage_options', 'espresso_about_default') && ! (defined('DOING_AJAX') && DOING_AJAX) && ! isset($notices['errors'])) { |
|
536 | + $query_params = array('page' => 'espresso_about'); |
|
537 | 537 | |
538 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
|
538 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
539 | 539 | $query_params['new_activation'] = TRUE; |
540 | 540 | } |
541 | 541 | |
542 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
|
542 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
543 | 543 | $query_params['reactivation'] = TRUE; |
544 | 544 | } |
545 | - $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
|
546 | - wp_safe_redirect( $url ); |
|
545 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
546 | + wp_safe_redirect($url); |
|
547 | 547 | exit(); |
548 | 548 | } |
549 | 549 | } |
@@ -557,31 +557,31 @@ discard block |
||
557 | 557 | * |
558 | 558 | * @return void |
559 | 559 | */ |
560 | - public function load_core_configuration(){ |
|
561 | - do_action( 'AHEE__EE_System__load_core_configuration__begin', $this ); |
|
562 | - EE_Registry::instance()->load_core( 'EE_Load_Textdomain' ); |
|
560 | + public function load_core_configuration() { |
|
561 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
562 | + EE_Registry::instance()->load_core('EE_Load_Textdomain'); |
|
563 | 563 | //load textdomain |
564 | 564 | EE_Load_Textdomain::load_textdomain(); |
565 | 565 | // load and setup EE_Config and EE_Network_Config |
566 | - EE_Registry::instance()->load_core( 'Config' ); |
|
567 | - EE_Registry::instance()->load_core( 'Network_Config' ); |
|
566 | + EE_Registry::instance()->load_core('Config'); |
|
567 | + EE_Registry::instance()->load_core('Network_Config'); |
|
568 | 568 | // setup autoloaders |
569 | 569 | // enable logging? |
570 | - if ( EE_Registry::instance()->CFG->admin->use_full_logging ) { |
|
571 | - EE_Registry::instance()->load_core( 'Log' ); |
|
570 | + if (EE_Registry::instance()->CFG->admin->use_full_logging) { |
|
571 | + EE_Registry::instance()->load_core('Log'); |
|
572 | 572 | } |
573 | 573 | // check for activation errors |
574 | - $activation_errors = get_option( 'ee_plugin_activation_errors', FALSE ); |
|
575 | - if ( $activation_errors ) { |
|
576 | - EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
577 | - update_option( 'ee_plugin_activation_errors', FALSE ); |
|
574 | + $activation_errors = get_option('ee_plugin_activation_errors', FALSE); |
|
575 | + if ($activation_errors) { |
|
576 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
577 | + update_option('ee_plugin_activation_errors', FALSE); |
|
578 | 578 | } |
579 | 579 | // get model names |
580 | 580 | $this->_parse_model_names(); |
581 | 581 | |
582 | 582 | //load caf stuff a chance to play during the activation process too. |
583 | 583 | $this->_maybe_brew_regular(); |
584 | - do_action( 'AHEE__EE_System__load_core_configuration__complete', $this ); |
|
584 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -590,23 +590,23 @@ discard block |
||
590 | 590 | * |
591 | 591 | * @return void |
592 | 592 | */ |
593 | - private function _parse_model_names(){ |
|
593 | + private function _parse_model_names() { |
|
594 | 594 | //get all the files in the EE_MODELS folder that end in .model.php |
595 | - $models = glob( EE_MODELS.'*.model.php'); |
|
595 | + $models = glob(EE_MODELS.'*.model.php'); |
|
596 | 596 | $model_names = array(); |
597 | 597 | $non_abstract_db_models = array(); |
598 | - foreach( $models as $model ){ |
|
598 | + foreach ($models as $model) { |
|
599 | 599 | // get model classname |
600 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model ); |
|
601 | - $shortname = str_replace( 'EEM_', '', $classname ); |
|
600 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
601 | + $shortname = str_replace('EEM_', '', $classname); |
|
602 | 602 | $reflectionClass = new ReflectionClass($classname); |
603 | - if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){ |
|
603 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
604 | 604 | $non_abstract_db_models[$shortname] = $classname; |
605 | 605 | } |
606 | - $model_names[ $shortname ] = $classname; |
|
606 | + $model_names[$shortname] = $classname; |
|
607 | 607 | } |
608 | - EE_Registry::instance()->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names ); |
|
609 | - EE_Registry::instance()->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models ); |
|
608 | + EE_Registry::instance()->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
609 | + EE_Registry::instance()->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
@@ -616,8 +616,8 @@ discard block |
||
616 | 616 | * @return void |
617 | 617 | */ |
618 | 618 | private function _maybe_brew_regular() { |
619 | - if (( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) { |
|
620 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
619 | + if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
620 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
621 | 621 | } |
622 | 622 | } |
623 | 623 | |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * @return void |
635 | 635 | */ |
636 | 636 | public function register_shortcodes_modules_and_widgets() { |
637 | - do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
|
637 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
638 | 638 | // check for addons using old hookpoint |
639 | - if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) { |
|
639 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
640 | 640 | $this->_incompatible_addon_error(); |
641 | 641 | } |
642 | 642 | } |
@@ -650,19 +650,19 @@ discard block |
||
650 | 650 | */ |
651 | 651 | private function _incompatible_addon_error() { |
652 | 652 | // get array of classes hooking into here |
653 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
|
654 | - if ( ! empty( $class_names )) { |
|
655 | - $msg = __( 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso' ); |
|
653 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
654 | + if ( ! empty($class_names)) { |
|
655 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso'); |
|
656 | 656 | $msg .= '<ul>'; |
657 | - foreach ( $class_names as $class_name ) { |
|
658 | - $msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>'; |
|
657 | + foreach ($class_names as $class_name) { |
|
658 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>'; |
|
659 | 659 | } |
660 | 660 | $msg .= '</ul>'; |
661 | - $msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' ); |
|
661 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso'); |
|
662 | 662 | // save list of incompatible addons to wp-options for later use |
663 | - add_option( 'ee_incompatible_addons', $class_names, '', 'no' ); |
|
664 | - if ( is_admin() ) { |
|
665 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
663 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
664 | + if (is_admin()) { |
|
665 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | } |
@@ -679,25 +679,25 @@ discard block |
||
679 | 679 | * |
680 | 680 | * @return void |
681 | 681 | */ |
682 | - public function brew_espresso(){ |
|
683 | - do_action( 'AHEE__EE_System__brew_espresso__begin', $this ); |
|
682 | + public function brew_espresso() { |
|
683 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
684 | 684 | // load some final core systems |
685 | - add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 ); |
|
686 | - add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 ); |
|
687 | - add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 ); |
|
688 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
689 | - add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 ); |
|
690 | - add_action( 'init', array( $this, 'initialize' ), 10 ); |
|
691 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
692 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
693 | - add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 ); |
|
694 | - |
|
695 | - if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE ) ) { |
|
685 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
686 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
687 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
688 | + add_action('init', array($this, 'load_controllers'), 7); |
|
689 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
690 | + add_action('init', array($this, 'initialize'), 10); |
|
691 | + add_action('init', array($this, 'initialize_last'), 100); |
|
692 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
693 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
694 | + |
|
695 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) { |
|
696 | 696 | // pew pew pew |
697 | - EE_Registry::instance()->load_core( 'PUE' ); |
|
698 | - do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' ); |
|
697 | + EE_Registry::instance()->load_core('PUE'); |
|
698 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
699 | 699 | } |
700 | - do_action( 'AHEE__EE_System__brew_espresso__complete', $this ); |
|
700 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | */ |
712 | 712 | public function set_hooks_for_core() { |
713 | 713 | $this->_deactivate_incompatible_addons(); |
714 | - do_action( 'AHEE__EE_System__set_hooks_for_core' ); |
|
714 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | |
@@ -720,15 +720,15 @@ discard block |
||
720 | 720 | * Using the information gathered in EE_System::_incompatible_addon_error, |
721 | 721 | * deactivates any addons considered incompatible with the current version of EE |
722 | 722 | */ |
723 | - private function _deactivate_incompatible_addons(){ |
|
724 | - $incompatible_addons = get_option( 'ee_incompatible_addons', array() ); |
|
725 | - if ( ! empty( $incompatible_addons )) { |
|
726 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
727 | - foreach ( $active_plugins as $active_plugin ) { |
|
728 | - foreach ( $incompatible_addons as $incompatible_addon ) { |
|
729 | - if ( strpos( $active_plugin, $incompatible_addon ) !== FALSE ) { |
|
730 | - unset( $_GET['activate'] ); |
|
731 | - espresso_deactivate_plugin( $active_plugin ); |
|
723 | + private function _deactivate_incompatible_addons() { |
|
724 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
725 | + if ( ! empty($incompatible_addons)) { |
|
726 | + $active_plugins = get_option('active_plugins', array()); |
|
727 | + foreach ($active_plugins as $active_plugin) { |
|
728 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
729 | + if (strpos($active_plugin, $incompatible_addon) !== FALSE) { |
|
730 | + unset($_GET['activate']); |
|
731 | + espresso_deactivate_plugin($active_plugin); |
|
732 | 732 | } |
733 | 733 | } |
734 | 734 | } |
@@ -745,10 +745,10 @@ discard block |
||
745 | 745 | */ |
746 | 746 | public function perform_activations_upgrades_and_migrations() { |
747 | 747 | //first check if we had previously attempted to setup EE's directories but failed |
748 | - if( EEH_Activation::upload_directories_incomplete() ) { |
|
748 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
749 | 749 | EEH_Activation::create_upload_directories(); |
750 | 750 | } |
751 | - do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
751 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | * @return void |
761 | 761 | */ |
762 | 762 | public function load_CPTs_and_session() { |
763 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__start' ); |
|
763 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
764 | 764 | // register Custom Post Types |
765 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
766 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ); |
|
765 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
766 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | |
@@ -778,19 +778,19 @@ discard block |
||
778 | 778 | * @return void |
779 | 779 | */ |
780 | 780 | public function load_controllers() { |
781 | - do_action( 'AHEE__EE_System__load_controllers__start' ); |
|
781 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
782 | 782 | // let's get it started |
783 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
784 | - do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' ); |
|
785 | - EE_Registry::instance()->load_core( 'Front_Controller' ); |
|
786 | - } else if ( ! EE_FRONT_AJAX ) { |
|
787 | - do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' ); |
|
788 | - EE_Registry::instance()->load_core( 'Admin' ); |
|
789 | - } else if ( EE_Maintenance_Mode::instance()->level() ) { |
|
783 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
784 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
785 | + EE_Registry::instance()->load_core('Front_Controller'); |
|
786 | + } else if ( ! EE_FRONT_AJAX) { |
|
787 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
788 | + EE_Registry::instance()->load_core('Admin'); |
|
789 | + } else if (EE_Maintenance_Mode::instance()->level()) { |
|
790 | 790 | // still need to make sure template helper functions are loaded in M-Mode |
791 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
791 | + EE_Registry::instance()->load_helper('Template'); |
|
792 | 792 | } |
793 | - do_action( 'AHEE__EE_System__load_controllers__complete' ); |
|
793 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | |
@@ -804,10 +804,10 @@ discard block |
||
804 | 804 | * @return void |
805 | 805 | */ |
806 | 806 | public function core_loaded_and_ready() { |
807 | - do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
|
808 | - do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
807 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
808 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
809 | 809 | // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
810 | - EE_Registry::instance()->load_core( 'Session' ); |
|
810 | + EE_Registry::instance()->load_core('Session'); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | * @return void |
822 | 822 | */ |
823 | 823 | public function initialize() { |
824 | - do_action( 'AHEE__EE_System__initialize' ); |
|
824 | + do_action('AHEE__EE_System__initialize'); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * @return void |
836 | 836 | */ |
837 | 837 | public function initialize_last() { |
838 | - do_action( 'AHEE__EE_System__initialize_last' ); |
|
838 | + do_action('AHEE__EE_System__initialize_last'); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | |
@@ -867,21 +867,21 @@ discard block |
||
867 | 867 | */ |
868 | 868 | public static function do_not_cache() { |
869 | 869 | // set no cache constants |
870 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
871 | - define( 'DONOTCACHEPAGE', true ); |
|
870 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
871 | + define('DONOTCACHEPAGE', true); |
|
872 | 872 | } |
873 | - if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { |
|
874 | - define( 'DONOTCACHCEOBJECT', true ); |
|
873 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
874 | + define('DONOTCACHCEOBJECT', true); |
|
875 | 875 | } |
876 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
877 | - define( 'DONOTCACHEDB', true ); |
|
876 | + if ( ! defined('DONOTCACHEDB')) { |
|
877 | + define('DONOTCACHEDB', true); |
|
878 | 878 | } |
879 | 879 | // add no cache headers |
880 | - add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 ); |
|
880 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
881 | 881 | // plus a little extra for nginx and Google Chrome |
882 | - add_filter( 'nocache_headers', array( 'EE_System', 'extra_nocache_headers' ), 10, 1 ); |
|
882 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
883 | 883 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
884 | - remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); |
|
884 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | * @param $headers |
894 | 894 | * @return array |
895 | 895 | */ |
896 | - public static function extra_nocache_headers ( $headers ) { |
|
896 | + public static function extra_nocache_headers($headers) { |
|
897 | 897 | // for NGINX |
898 | 898 | $headers['X-Accel-Expires'] = 0; |
899 | 899 | // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
@@ -922,15 +922,15 @@ discard block |
||
922 | 922 | * @param $admin_bar |
923 | 923 | * @return void |
924 | 924 | */ |
925 | - public function espresso_toolbar_items( $admin_bar ) { |
|
925 | + public function espresso_toolbar_items($admin_bar) { |
|
926 | 926 | |
927 | 927 | // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
928 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) { |
|
928 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || ! EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) { |
|
929 | 929 | return; |
930 | 930 | } |
931 | 931 | |
932 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
933 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
932 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
933 | + EE_Registry::instance()->load_helper('URL'); |
|
934 | 934 | $menu_class = 'espresso_menu_item_class'; |
935 | 935 | //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
936 | 936 | //because they're only defined in each of their respective constructors |
@@ -942,20 +942,20 @@ discard block |
||
942 | 942 | //Top Level |
943 | 943 | $admin_bar->add_menu(array( |
944 | 944 | 'id' => 'espresso-toolbar', |
945 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>', |
|
945 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'._x('Event Espresso', 'admin bar menu group label', 'event_espresso').'</span>', |
|
946 | 946 | 'href' => $events_admin_url, |
947 | 947 | 'meta' => array( |
948 | 948 | 'title' => __('Event Espresso', 'event_espresso'), |
949 | - 'class' => $menu_class . 'first' |
|
949 | + 'class' => $menu_class.'first' |
|
950 | 950 | ), |
951 | 951 | )); |
952 | 952 | |
953 | 953 | //Events |
954 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) { |
|
954 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
955 | 955 | $admin_bar->add_menu(array( |
956 | 956 | 'id' => 'espresso-toolbar-events', |
957 | 957 | 'parent' => 'espresso-toolbar', |
958 | - 'title' => __( 'Events', 'event_espresso' ), |
|
958 | + 'title' => __('Events', 'event_espresso'), |
|
959 | 959 | 'href' => $events_admin_url, |
960 | 960 | 'meta' => array( |
961 | 961 | 'title' => __('Events', 'event_espresso'), |
@@ -966,13 +966,13 @@ discard block |
||
966 | 966 | } |
967 | 967 | |
968 | 968 | |
969 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) { |
|
969 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
970 | 970 | //Events Add New |
971 | 971 | $admin_bar->add_menu(array( |
972 | 972 | 'id' => 'espresso-toolbar-events-new', |
973 | 973 | 'parent' => 'espresso-toolbar-events', |
974 | 974 | 'title' => __('Add New', 'event_espresso'), |
975 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ), |
|
975 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url), |
|
976 | 976 | 'meta' => array( |
977 | 977 | 'title' => __('Add New', 'event_espresso'), |
978 | 978 | 'target' => '', |
@@ -981,18 +981,18 @@ discard block |
||
981 | 981 | )); |
982 | 982 | } |
983 | 983 | |
984 | - if ( is_single() && ( get_post_type() == 'espresso_events' ) ) { |
|
984 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
985 | 985 | |
986 | 986 | //Current post |
987 | 987 | global $post; |
988 | 988 | |
989 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
989 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) { |
|
990 | 990 | //Events Edit Current Event |
991 | 991 | $admin_bar->add_menu(array( |
992 | 992 | 'id' => 'espresso-toolbar-events-edit', |
993 | 993 | 'parent' => 'espresso-toolbar-events', |
994 | 994 | 'title' => __('Edit Event', 'event_espresso'), |
995 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ), |
|
995 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$post->ID), $events_admin_url), |
|
996 | 996 | 'meta' => array( |
997 | 997 | 'title' => __('Edit Event', 'event_espresso'), |
998 | 998 | 'target' => '', |
@@ -1004,11 +1004,11 @@ discard block |
||
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | //Events View |
1007 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) { |
|
1007 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) { |
|
1008 | 1008 | $admin_bar->add_menu(array( |
1009 | 1009 | 'id' => 'espresso-toolbar-events-view', |
1010 | 1010 | 'parent' => 'espresso-toolbar-events', |
1011 | - 'title' => __( 'View', 'event_espresso' ), |
|
1011 | + 'title' => __('View', 'event_espresso'), |
|
1012 | 1012 | 'href' => $events_admin_url, |
1013 | 1013 | 'meta' => array( |
1014 | 1014 | 'title' => __('View', 'event_espresso'), |
@@ -1018,12 +1018,12 @@ discard block |
||
1018 | 1018 | )); |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) { |
|
1021 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1022 | 1022 | //Events View All |
1023 | 1023 | $admin_bar->add_menu(array( |
1024 | 1024 | 'id' => 'espresso-toolbar-events-all', |
1025 | 1025 | 'parent' => 'espresso-toolbar-events-view', |
1026 | - 'title' => __( 'All', 'event_espresso' ), |
|
1026 | + 'title' => __('All', 'event_espresso'), |
|
1027 | 1027 | 'href' => $events_admin_url, |
1028 | 1028 | 'meta' => array( |
1029 | 1029 | 'title' => __('All', 'event_espresso'), |
@@ -1034,13 +1034,13 @@ discard block |
||
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | |
1037 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) { |
|
1037 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) { |
|
1038 | 1038 | //Events View Today |
1039 | 1039 | $admin_bar->add_menu(array( |
1040 | 1040 | 'id' => 'espresso-toolbar-events-today', |
1041 | 1041 | 'parent' => 'espresso-toolbar-events-view', |
1042 | 1042 | 'title' => __('Today', 'event_espresso'), |
1043 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ), |
|
1043 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url), |
|
1044 | 1044 | 'meta' => array( |
1045 | 1045 | 'title' => __('Today', 'event_espresso'), |
1046 | 1046 | 'target' => '', |
@@ -1050,13 +1050,13 @@ discard block |
||
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | |
1053 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) { |
|
1053 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) { |
|
1054 | 1054 | //Events View This Month |
1055 | 1055 | $admin_bar->add_menu(array( |
1056 | 1056 | 'id' => 'espresso-toolbar-events-month', |
1057 | 1057 | 'parent' => 'espresso-toolbar-events-view', |
1058 | - 'title' => __( 'This Month', 'event_espresso'), |
|
1059 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ), |
|
1058 | + 'title' => __('This Month', 'event_espresso'), |
|
1059 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url), |
|
1060 | 1060 | 'meta' => array( |
1061 | 1061 | 'title' => __('This Month', 'event_espresso'), |
1062 | 1062 | 'target' => '', |
@@ -1066,11 +1066,11 @@ discard block |
||
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | //Registration Overview |
1069 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) { |
|
1069 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) { |
|
1070 | 1070 | $admin_bar->add_menu(array( |
1071 | 1071 | 'id' => 'espresso-toolbar-registrations', |
1072 | 1072 | 'parent' => 'espresso-toolbar', |
1073 | - 'title' => __( 'Registrations', 'event_espresso' ), |
|
1073 | + 'title' => __('Registrations', 'event_espresso'), |
|
1074 | 1074 | 'href' => $reg_admin_url, |
1075 | 1075 | 'meta' => array( |
1076 | 1076 | 'title' => __('Registrations', 'event_espresso'), |
@@ -1081,12 +1081,12 @@ discard block |
||
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | //Registration Overview Today |
1084 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) { |
|
1084 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) { |
|
1085 | 1085 | $admin_bar->add_menu(array( |
1086 | 1086 | 'id' => 'espresso-toolbar-registrations-today', |
1087 | 1087 | 'parent' => 'espresso-toolbar-registrations', |
1088 | - 'title' => __( 'Today', 'event_espresso'), |
|
1089 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ), |
|
1088 | + 'title' => __('Today', 'event_espresso'), |
|
1089 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url), |
|
1090 | 1090 | 'meta' => array( |
1091 | 1091 | 'title' => __('Today', 'event_espresso'), |
1092 | 1092 | 'target' => '', |
@@ -1096,14 +1096,14 @@ discard block |
||
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | //Registration Overview Today Completed |
1099 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) { |
|
1099 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) { |
|
1100 | 1100 | $admin_bar->add_menu(array( |
1101 | 1101 | 'id' => 'espresso-toolbar-registrations-today-approved', |
1102 | 1102 | 'parent' => 'espresso-toolbar-registrations-today', |
1103 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1104 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1103 | + 'title' => __('Approved', 'event_espresso'), |
|
1104 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1105 | 1105 | 'meta' => array( |
1106 | - 'title' => __('Approved', 'event_espresso' ), |
|
1106 | + 'title' => __('Approved', 'event_espresso'), |
|
1107 | 1107 | 'target' => '', |
1108 | 1108 | 'class' => $menu_class |
1109 | 1109 | ), |
@@ -1111,14 +1111,14 @@ discard block |
||
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | //Registration Overview Today Pending\ |
1114 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) { |
|
1114 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) { |
|
1115 | 1115 | $admin_bar->add_menu(array( |
1116 | 1116 | 'id' => 'espresso-toolbar-registrations-today-pending', |
1117 | 1117 | 'parent' => 'espresso-toolbar-registrations-today', |
1118 | - 'title' => __( 'Pending', 'event_espresso' ), |
|
1119 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1118 | + 'title' => __('Pending', 'event_espresso'), |
|
1119 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1120 | 1120 | 'meta' => array( |
1121 | - 'title' => __('Pending Payment', 'event_espresso' ), |
|
1121 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1122 | 1122 | 'target' => '', |
1123 | 1123 | 'class' => $menu_class |
1124 | 1124 | ), |
@@ -1126,14 +1126,14 @@ discard block |
||
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | //Registration Overview Today Incomplete |
1129 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) { |
|
1129 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) { |
|
1130 | 1130 | $admin_bar->add_menu(array( |
1131 | 1131 | 'id' => 'espresso-toolbar-registrations-today-not-approved', |
1132 | 1132 | 'parent' => 'espresso-toolbar-registrations-today', |
1133 | - 'title' => __( 'Not Approved', 'event_espresso' ), |
|
1134 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1133 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1134 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1135 | 1135 | 'meta' => array( |
1136 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1136 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1137 | 1137 | 'target' => '', |
1138 | 1138 | 'class' => $menu_class |
1139 | 1139 | ), |
@@ -1141,12 +1141,12 @@ discard block |
||
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | //Registration Overview Today Incomplete |
1144 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) { |
|
1144 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) { |
|
1145 | 1145 | $admin_bar->add_menu(array( |
1146 | 1146 | 'id' => 'espresso-toolbar-registrations-today-cancelled', |
1147 | 1147 | 'parent' => 'espresso-toolbar-registrations-today', |
1148 | - 'title' => __( 'Cancelled', 'event_espresso'), |
|
1149 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1148 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1149 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1150 | 1150 | 'meta' => array( |
1151 | 1151 | 'title' => __('Cancelled', 'event_espresso'), |
1152 | 1152 | 'target' => '', |
@@ -1156,12 +1156,12 @@ discard block |
||
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | //Registration Overview This Month |
1159 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) { |
|
1159 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) { |
|
1160 | 1160 | $admin_bar->add_menu(array( |
1161 | 1161 | 'id' => 'espresso-toolbar-registrations-month', |
1162 | 1162 | 'parent' => 'espresso-toolbar-registrations', |
1163 | - 'title' => __( 'This Month', 'event_espresso' ), |
|
1164 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ), |
|
1163 | + 'title' => __('This Month', 'event_espresso'), |
|
1164 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url), |
|
1165 | 1165 | 'meta' => array( |
1166 | 1166 | 'title' => __('This Month', 'event_espresso'), |
1167 | 1167 | 'target' => '', |
@@ -1171,12 +1171,12 @@ discard block |
||
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | //Registration Overview This Month Approved |
1174 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) { |
|
1174 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) { |
|
1175 | 1175 | $admin_bar->add_menu(array( |
1176 | 1176 | 'id' => 'espresso-toolbar-registrations-month-approved', |
1177 | 1177 | 'parent' => 'espresso-toolbar-registrations-month', |
1178 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1179 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1178 | + 'title' => __('Approved', 'event_espresso'), |
|
1179 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1180 | 1180 | 'meta' => array( |
1181 | 1181 | 'title' => __('Approved', 'event_espresso'), |
1182 | 1182 | 'target' => '', |
@@ -1186,12 +1186,12 @@ discard block |
||
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | //Registration Overview This Month Pending |
1189 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) { |
|
1189 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) { |
|
1190 | 1190 | $admin_bar->add_menu(array( |
1191 | 1191 | 'id' => 'espresso-toolbar-registrations-month-pending', |
1192 | 1192 | 'parent' => 'espresso-toolbar-registrations-month', |
1193 | - 'title' => __( 'Pending', 'event_espresso'), |
|
1194 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1193 | + 'title' => __('Pending', 'event_espresso'), |
|
1194 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1195 | 1195 | 'meta' => array( |
1196 | 1196 | 'title' => __('Pending', 'event_espresso'), |
1197 | 1197 | 'target' => '', |
@@ -1201,14 +1201,14 @@ discard block |
||
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | //Registration Overview This Month Not Approved |
1204 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) { |
|
1204 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) { |
|
1205 | 1205 | $admin_bar->add_menu(array( |
1206 | 1206 | 'id' => 'espresso-toolbar-registrations-month-not-approved', |
1207 | 1207 | 'parent' => 'espresso-toolbar-registrations-month', |
1208 | - 'title' => __( 'Not Approved', 'event_espresso'), |
|
1209 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1208 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1209 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1210 | 1210 | 'meta' => array( |
1211 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1211 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1212 | 1212 | 'target' => '', |
1213 | 1213 | 'class' => $menu_class |
1214 | 1214 | ), |
@@ -1217,12 +1217,12 @@ discard block |
||
1217 | 1217 | |
1218 | 1218 | |
1219 | 1219 | //Registration Overview This Month Cancelled |
1220 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) { |
|
1220 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) { |
|
1221 | 1221 | $admin_bar->add_menu(array( |
1222 | 1222 | 'id' => 'espresso-toolbar-registrations-month-cancelled', |
1223 | 1223 | 'parent' => 'espresso-toolbar-registrations-month', |
1224 | 1224 | 'title' => __('Cancelled', 'event_espresso'), |
1225 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1225 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1226 | 1226 | 'meta' => array( |
1227 | 1227 | 'title' => __('Cancelled', 'event_espresso'), |
1228 | 1228 | 'target' => '', |
@@ -1232,11 +1232,11 @@ discard block |
||
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | //Extensions & Services |
1235 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) { |
|
1235 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) { |
|
1236 | 1236 | $admin_bar->add_menu(array( |
1237 | 1237 | 'id' => 'espresso-toolbar-extensions-and-services', |
1238 | 1238 | 'parent' => 'espresso-toolbar', |
1239 | - 'title' => __( 'Extensions & Services', 'event_espresso' ), |
|
1239 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1240 | 1240 | 'href' => $extensions_admin_url, |
1241 | 1241 | 'meta' => array( |
1242 | 1242 | 'title' => __('Extensions & Services', 'event_espresso'), |
@@ -1258,8 +1258,8 @@ discard block |
||
1258 | 1258 | * @param array $exclude_array any existing pages being excluded are in this array. |
1259 | 1259 | * @return array |
1260 | 1260 | */ |
1261 | - public function remove_pages_from_wp_list_pages( $exclude_array ) { |
|
1262 | - return array_merge( $exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array() ); |
|
1261 | + public function remove_pages_from_wp_list_pages($exclude_array) { |
|
1262 | + return array_merge($exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array()); |
|
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | |
@@ -1279,12 +1279,12 @@ discard block |
||
1279 | 1279 | */ |
1280 | 1280 | public function wp_enqueue_scripts() { |
1281 | 1281 | // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
1282 | - if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) { |
|
1282 | + if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) { |
|
1283 | 1283 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1284 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
1284 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
1285 | 1285 | // register jQuery Validate and additional methods |
1286 | - wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery' ), '1.15.0', TRUE ); |
|
1287 | - wp_register_script( 'jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', array( 'jquery', 'jquery-validate' ), '1.15.0', TRUE ); |
|
1286 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
1287 | + wp_register_script('jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', array('jquery', 'jquery-validate'), '1.15.0', TRUE); |
|
1288 | 1288 | } |
1289 | 1289 | } |
1290 | 1290 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * |
775 | 775 | * @param mixed $opt_group |
776 | 776 | * @param mixed $QSOs |
777 | - * @param mixed $answer |
|
777 | + * @param string $answer |
|
778 | 778 | * @return string |
779 | 779 | */ |
780 | 780 | private static function _generate_select_option_group( $opt_group, $QSOs, $answer ){ |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | /** |
1123 | 1123 | * prep_required |
1124 | 1124 | * @param string|array $required |
1125 | - * @return array |
|
1125 | + * @return string |
|
1126 | 1126 | */ |
1127 | 1127 | static function prep_required( $required = array() ){ |
1128 | 1128 | // make sure required is an array |
@@ -1173,8 +1173,8 @@ discard block |
||
1173 | 1173 | |
1174 | 1174 | /** |
1175 | 1175 | * _load_system_dropdowns |
1176 | - * @param array $QFI |
|
1177 | - * @return array |
|
1176 | + * @param EE_Question_Form_Input $QFI |
|
1177 | + * @return EE_Question_Form_Input |
|
1178 | 1178 | */ |
1179 | 1179 | private static function _load_system_dropdowns( $QFI ){ |
1180 | 1180 | $QST_system = $QFI->get('QST_system'); |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | * @param string $nonce_action - if using nonces |
1464 | 1464 | * @param bool|string $input_only - whether to print form header and footer. TRUE returns the input without the form |
1465 | 1465 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1466 | - * @return void |
|
1466 | + * @return string |
|
1467 | 1467 | */ |
1468 | 1468 | public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
1469 | 1469 | $btn = ''; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | /** |
395 | 395 | * generate_question_groups_html |
396 | - * |
|
396 | + * |
|
397 | 397 | * @param string $question_groups |
398 | 398 | * @return string HTML |
399 | 399 | */ |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | |
538 | 538 | /** |
539 | 539 | * generate_form_input |
540 | - * |
|
540 | + * |
|
541 | 541 | * @param EE_Question_Form_Input $QFI |
542 | 542 | * @return string HTML |
543 | 543 | */ |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | /** |
614 | 614 | * generates HTML for a form text input |
615 | - * |
|
615 | + * |
|
616 | 616 | * @param string $question label content |
617 | 617 | * @param string $answer form input value attribute |
618 | 618 | * @param string $name form input name attribute |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | |
658 | 658 | /** |
659 | 659 | * generates HTML for a form textarea |
660 | - * |
|
660 | + * |
|
661 | 661 | * @param string $question label content |
662 | 662 | * @param string $answer form input value attribute |
663 | 663 | * @param string $name form input name attribute |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | /** |
710 | 710 | * generates HTML for a form select input |
711 | - * |
|
711 | + * |
|
712 | 712 | * @param string $question label content |
713 | 713 | * @param string $answer form input value attribute |
714 | 714 | * @param array $options array of answer options where array key = option value and array value = option display text |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | |
886 | 886 | /** |
887 | 887 | * generates HTML for form checkbox inputs |
888 | - * |
|
888 | + * |
|
889 | 889 | * @param string $question label content |
890 | 890 | * @param string $answer form input value attribute |
891 | 891 | * @param array $options array of options where array key = option value and array value = option display text |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | |
967 | 967 | /** |
968 | 968 | * generates HTML for a form datepicker input |
969 | - * |
|
969 | + * |
|
970 | 970 | * @param string $question label content |
971 | 971 | * @param string $answer form input value attribute |
972 | 972 | * @param string $name form input name attribute |
@@ -366,14 +366,16 @@ discard block |
||
366 | 366 | $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
367 | 367 | //Debug |
368 | 368 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
369 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
370 | - $field .= ' ' . $parameters; |
|
369 | + if ( EEH_Formatter::ee_tep_not_null($parameters)) { |
|
370 | + $field .= ' ' . $parameters; |
|
371 | + } |
|
371 | 372 | if ($autosize) { |
372 | 373 | $size = 'med'; |
373 | 374 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
374 | 375 | if ($values[$ii]['text']) { |
375 | - if (strlen($values[$ii]['text']) > 5) |
|
376 | - $size = 'wide'; |
|
376 | + if (strlen($values[$ii]['text']) > 5) { |
|
377 | + $size = 'wide'; |
|
378 | + } |
|
377 | 379 | } |
378 | 380 | } |
379 | 381 | } else { |
@@ -382,8 +384,9 @@ discard block |
||
382 | 384 | |
383 | 385 | $field .= ' class="' . $class . ' ' . $size . '">'; |
384 | 386 | |
385 | - if (empty($default) && isset($GLOBALS[$name])) |
|
386 | - $default = stripslashes($GLOBALS[$name]); |
|
387 | + if (empty($default) && isset($GLOBALS[$name])) { |
|
388 | + $default = stripslashes($GLOBALS[$name]); |
|
389 | + } |
|
387 | 390 | |
388 | 391 | |
389 | 392 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @return string |
70 | 70 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
71 | 71 | */ |
72 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
72 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
73 | 73 | |
74 | - if ( empty($input_vars) ) { |
|
75 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
74 | + if (empty($input_vars)) { |
|
75 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
76 | 76 | return FALSE; |
77 | 77 | } |
78 | 78 | |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | 'append_content' => '' |
99 | 99 | ); |
100 | 100 | |
101 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
101 | + $input_value = wp_parse_args($input_value, $defaults); |
|
102 | 102 | |
103 | 103 | // required fields get a * |
104 | 104 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
105 | 105 | // and the css class "required" |
106 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
107 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
106 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
107 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
108 | 108 | |
109 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
110 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
109 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
110 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
111 | 111 | |
112 | 112 | //rows or cols? |
113 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
114 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
113 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
114 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
115 | 115 | |
116 | 116 | //any content? |
117 | 117 | $append_content = $input_value['append_content']; |
118 | 118 | |
119 | - $output .= (!$close) ? '<ul>' : ''; |
|
119 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
120 | 120 | $output .= '<li>'; |
121 | 121 | |
122 | 122 | // what type of input are we dealing with ? |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | |
125 | 125 | // text inputs |
126 | 126 | case 'text' : |
127 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
128 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . $input_value['value'] . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
127 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
128 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.$input_value['value'].'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | // dropdowns |
132 | 132 | case 'select' : |
133 | 133 | |
134 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
135 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
134 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
135 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
136 | 136 | |
137 | 137 | if (is_array($input_value['options'])) { |
138 | 138 | $options = $input_value['options']; |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | foreach ($options as $key => $value) { |
144 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
144 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
145 | 145 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
146 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
146 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
147 | 147 | } |
148 | - $output .= "\n\t\t\t" . '</select>'; |
|
148 | + $output .= "\n\t\t\t".'</select>'; |
|
149 | 149 | |
150 | 150 | break; |
151 | 151 | |
152 | 152 | case 'textarea' : |
153 | 153 | |
154 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
155 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . $input_value['value'] . '</textarea>'; |
|
154 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
155 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.$input_value['value'].'</textarea>'; |
|
156 | 156 | break; |
157 | 157 | |
158 | 158 | case 'hidden' : |
159 | 159 | $close = false; |
160 | 160 | $output .= "</li></ul>"; |
161 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
161 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
162 | 162 | break; |
163 | 163 | |
164 | 164 | case 'checkbox' : |
165 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
166 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
167 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
165 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
166 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
167 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
168 | 168 | break; |
169 | 169 | |
170 | 170 | case 'wp_editor' : |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | ); |
178 | 178 | $output .= '</li>'; |
179 | 179 | $output .= '</ul>'; |
180 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
181 | - if ( $append_content ) { |
|
180 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
181 | + if ($append_content) { |
|
182 | 182 | $output .= $append_content; |
183 | 183 | } |
184 | 184 | ob_start(); |
185 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
185 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
186 | 186 | $editor = ob_get_contents(); |
187 | 187 | ob_end_clean(); |
188 | 188 | $output .= $editor; |
189 | 189 | break; |
190 | 190 | |
191 | 191 | } |
192 | - if ( $append_content && $input_value['input'] !== 'wp_editor' ) { |
|
192 | + if ($append_content && $input_value['input'] !== 'wp_editor') { |
|
193 | 193 | $output .= $append_content; |
194 | 194 | } |
195 | 195 | $output .= ($close) ? '</li>' : ''; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $form_fields = array(); |
231 | 231 | $fields = (array) $fields; |
232 | 232 | |
233 | - foreach ( $fields as $field_name => $field_atts ) { |
|
233 | + foreach ($fields as $field_name => $field_atts) { |
|
234 | 234 | //defaults: |
235 | 235 | $defaults = array( |
236 | 236 | 'label' => '', |
@@ -248,67 +248,67 @@ discard block |
||
248 | 248 | 'wpeditor_args' => array() |
249 | 249 | ); |
250 | 250 | // merge defaults with passed arguments |
251 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
252 | - extract( $_fields ); |
|
251 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
252 | + extract($_fields); |
|
253 | 253 | // generate label |
254 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
254 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
255 | 255 | // generate field name |
256 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
256 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
257 | 257 | |
258 | 258 | //tabindex |
259 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
259 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
260 | 260 | |
261 | 261 | //we determine what we're building based on the type |
262 | - switch ( $type ) { |
|
262 | + switch ($type) { |
|
263 | 263 | |
264 | 264 | case 'textarea' : |
265 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
265 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
266 | 266 | $fld .= $extra_desc; |
267 | 267 | break; |
268 | 268 | |
269 | 269 | case 'checkbox' : |
270 | 270 | $c_input = ''; |
271 | - if ( is_array($value) ) { |
|
272 | - foreach ( $value as $key => $val ) { |
|
273 | - $c_id = $field_name . '_' . $value; |
|
274 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
275 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
276 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
271 | + if (is_array($value)) { |
|
272 | + foreach ($value as $key => $val) { |
|
273 | + $c_id = $field_name.'_'.$value; |
|
274 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
275 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
276 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
278 | 278 | } |
279 | 279 | $fld = $c_input; |
280 | 280 | } else { |
281 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
281 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
283 | 283 | } |
284 | 284 | break; |
285 | 285 | |
286 | 286 | case 'radio' : |
287 | 287 | $c_input = ''; |
288 | - if ( is_array($value) ) { |
|
289 | - foreach ( $value as $key => $val ) { |
|
290 | - $c_id = $field_name . '_' . $value; |
|
291 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
292 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
293 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
288 | + if (is_array($value)) { |
|
289 | + foreach ($value as $key => $val) { |
|
290 | + $c_id = $field_name.'_'.$value; |
|
291 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
292 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
293 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
295 | 295 | } |
296 | 296 | $fld = $c_input; |
297 | 297 | } else { |
298 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
298 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
300 | 300 | } |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case 'hidden' : |
304 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
304 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
305 | 305 | break; |
306 | 306 | |
307 | 307 | case 'select' : |
308 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
309 | - foreach ( $value as $key => $val ) { |
|
310 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
308 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
309 | + foreach ($value as $key => $val) { |
|
310 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
312 | 312 | } |
313 | 313 | $fld .= '</select>'; |
314 | 314 | break; |
@@ -320,21 +320,21 @@ discard block |
||
320 | 320 | 'editor_class' => $class, |
321 | 321 | 'tabindex' => $tabindex |
322 | 322 | ); |
323 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
323 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
324 | 324 | ob_start(); |
325 | - wp_editor( $value, $id, $editor_settings ); |
|
325 | + wp_editor($value, $id, $editor_settings); |
|
326 | 326 | $editor = ob_get_contents(); |
327 | 327 | ob_end_clean(); |
328 | 328 | $fld = $editor; |
329 | 329 | break; |
330 | 330 | |
331 | 331 | default : //'text fields' |
332 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
332 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
333 | 333 | $fld .= $extra_desc; |
334 | 334 | |
335 | 335 | } |
336 | 336 | |
337 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
337 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $form_fields; |
@@ -363,22 +363,22 @@ discard block |
||
363 | 363 | */ |
364 | 364 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
365 | 365 | //if $values was submitted in the wrong format, convert it over |
366 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
367 | - $converted_values=array(); |
|
368 | - foreach($values as $id=>$text){ |
|
369 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
366 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
367 | + $converted_values = array(); |
|
368 | + foreach ($values as $id=>$text) { |
|
369 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
370 | 370 | } |
371 | - $values=$converted_values; |
|
371 | + $values = $converted_values; |
|
372 | 372 | } |
373 | 373 | //load formatter helper |
374 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
374 | + EE_Registry::instance()->load_helper('Formatter'); |
|
375 | 375 | //EE_Registry::instance()->load_helper( 'Formatter' ); |
376 | 376 | |
377 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
377 | + $field = '<select id="'.EEH_Formatter::ee_tep_output_string($name).'" name="'.EEH_Formatter::ee_tep_output_string($name).'"'; |
|
378 | 378 | //Debug |
379 | 379 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
380 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
381 | - $field .= ' ' . $parameters; |
|
380 | + if (EEH_Formatter::ee_tep_not_null($parameters)) |
|
381 | + $field .= ' '.$parameters; |
|
382 | 382 | if ($autosize) { |
383 | 383 | $size = 'med'; |
384 | 384 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -391,21 +391,21 @@ discard block |
||
391 | 391 | $size = ''; |
392 | 392 | } |
393 | 393 | |
394 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
394 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
395 | 395 | |
396 | 396 | if (empty($default) && isset($GLOBALS[$name])) |
397 | 397 | $default = stripslashes($GLOBALS[$name]); |
398 | 398 | |
399 | 399 | |
400 | 400 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
401 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
401 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
402 | 402 | if ($default == $values[$i]['id']) { |
403 | 403 | $field .= ' selected = "selected"'; |
404 | 404 | } |
405 | - if ( isset( $values[$i]['class'] ) ) { |
|
406 | - $field .= ' class="' . $values[$i]['class'] . '"'; |
|
405 | + if (isset($values[$i]['class'])) { |
|
406 | + $field .= ' class="'.$values[$i]['class'].'"'; |
|
407 | 407 | } |
408 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
408 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
409 | 409 | } |
410 | 410 | $field .= '</select>'; |
411 | 411 | |
@@ -423,38 +423,38 @@ discard block |
||
423 | 423 | * @param string $question_groups |
424 | 424 | * @return string HTML |
425 | 425 | */ |
426 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
426 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
427 | 427 | |
428 | 428 | $html = ''; |
429 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
430 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
429 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
430 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
431 | 431 | |
432 | - if ( ! empty( $question_groups )) { |
|
432 | + if ( ! empty($question_groups)) { |
|
433 | 433 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
434 | 434 | // loop thru question groups |
435 | - foreach ( $question_groups as $QSG ) { |
|
435 | + foreach ($question_groups as $QSG) { |
|
436 | 436 | // check that questions exist |
437 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
437 | + if ( ! empty($QSG['QSG_questions'])) { |
|
438 | 438 | // use fieldsets |
439 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
439 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
440 | 440 | // group_name |
441 | - $html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer( $QSG['QSG_name'] ) . '</h5>' : ''; |
|
441 | + $html .= $QSG['QSG_show_group_name'] ? "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.self::prep_answer($QSG['QSG_name']).'</h5>' : ''; |
|
442 | 442 | // group_desc |
443 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
443 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
444 | 444 | |
445 | 445 | $html .= $before_question_group_questions; |
446 | 446 | // loop thru questions |
447 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
447 | + foreach ($QSG['QSG_questions'] as $question) { |
|
448 | 448 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
449 | 449 | $QFI = new EE_Question_Form_Input( |
450 | 450 | $question['qst_obj'], |
451 | 451 | $question['ans_obj'], |
452 | 452 | $question |
453 | 453 | ); |
454 | - $html .= self::generate_form_input( $QFI ); |
|
454 | + $html .= self::generate_form_input($QFI); |
|
455 | 455 | } |
456 | 456 | $html .= $after_question_group_questions; |
457 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
457 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | } |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | * @param string $group_wrapper |
475 | 475 | * @return string HTML |
476 | 476 | */ |
477 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
477 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
478 | 478 | |
479 | 479 | $html = ''; |
480 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
481 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
480 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
481 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
482 | 482 | |
483 | 483 | $default_q_meta = array( |
484 | 484 | 'att_nmbr' => 1, |
@@ -487,55 +487,55 @@ discard block |
||
487 | 487 | 'input_id' => '', |
488 | 488 | 'input_class' => '' |
489 | 489 | ); |
490 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
490 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
491 | 491 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
492 | 492 | |
493 | - if ( ! empty( $question_groups )) { |
|
493 | + if ( ! empty($question_groups)) { |
|
494 | 494 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
495 | 495 | // loop thru question groups |
496 | - foreach ( $question_groups as $QSG ) { |
|
497 | - if ( $QSG instanceof EE_Question_Group ) { |
|
496 | + foreach ($question_groups as $QSG) { |
|
497 | + if ($QSG instanceof EE_Question_Group) { |
|
498 | 498 | // check that questions exist |
499 | 499 | |
500 | - $where = array( 'QST_deleted' => 0 ); |
|
501 | - if ( ! $from_admin ) { |
|
500 | + $where = array('QST_deleted' => 0); |
|
501 | + if ( ! $from_admin) { |
|
502 | 502 | $where['QST_admin_only'] = 0; |
503 | 503 | } |
504 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
505 | - if ( ! empty( $questions )) { |
|
504 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
505 | + if ( ! empty($questions)) { |
|
506 | 506 | // use fieldsets |
507 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
507 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
508 | 508 | // group_name |
509 | - if ( $QSG->show_group_name() ) { |
|
510 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
509 | + if ($QSG->show_group_name()) { |
|
510 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
511 | 511 | } |
512 | 512 | // group_desc |
513 | - if ( $QSG->show_group_desc() ) { |
|
514 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
513 | + if ($QSG->show_group_desc()) { |
|
514 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | $html .= $before_question_group_questions; |
518 | 518 | // loop thru questions |
519 | - foreach ( $questions as $QST ) { |
|
519 | + foreach ($questions as $QST) { |
|
520 | 520 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
521 | 521 | |
522 | 522 | $answer = NULL; |
523 | 523 | |
524 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
524 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
525 | 525 | // check for answer in $_GET in case we are reprocessing a form after an error |
526 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
527 | - $answer = is_array( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ); |
|
526 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
527 | + $answer = is_array($_GET['qstn'][$q_meta['input_id']][$qstn_id]) ? $_GET['qstn'][$q_meta['input_id']][$qstn_id] : sanitize_text_field($_GET['qstn'][$q_meta['input_id']][$qstn_id]); |
|
528 | 528 | } |
529 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
529 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
530 | 530 | //attendee data from the session |
531 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
531 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
535 | 535 | |
536 | 536 | $QFI = new EE_Question_Form_Input( |
537 | 537 | $QST, |
538 | - EE_Answer::new_instance ( array( |
|
538 | + EE_Answer::new_instance(array( |
|
539 | 539 | 'ANS_ID'=> 0, |
540 | 540 | 'QST_ID'=> 0, |
541 | 541 | 'REG_ID'=> 0, |
@@ -544,10 +544,10 @@ discard block |
||
544 | 544 | $q_meta |
545 | 545 | ); |
546 | 546 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
547 | - $html .= self::generate_form_input( $QFI ); |
|
547 | + $html .= self::generate_form_input($QFI); |
|
548 | 548 | } |
549 | 549 | $html .= $after_question_group_questions; |
550 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
550 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
@@ -567,63 +567,63 @@ discard block |
||
567 | 567 | * @param EE_Question_Form_Input $QFI |
568 | 568 | * @return string HTML |
569 | 569 | */ |
570 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
571 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
570 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
571 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
572 | 572 | return ''; |
573 | 573 | } |
574 | 574 | |
575 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
576 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
575 | + $QFI = self::_load_system_dropdowns($QFI); |
|
576 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
577 | 577 | |
578 | 578 | //we also need to verify |
579 | 579 | |
580 | 580 | $display_text = $QFI->get('QST_display_text'); |
581 | 581 | $input_name = $QFI->get('QST_input_name'); |
582 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
582 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
583 | 583 | $input_id = $QFI->get('QST_input_id'); |
584 | 584 | $input_class = $QFI->get('QST_input_class'); |
585 | 585 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
586 | 586 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
587 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
587 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
588 | 588 | $QST_required = $QFI->get('QST_required'); |
589 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
590 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
591 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
592 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
589 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
590 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
591 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
592 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
593 | 593 | $label_class = 'espresso-form-input-lbl'; |
594 | - $QST_options = $QFI->options(true,$answer); |
|
595 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
594 | + $QST_options = $QFI->options(true, $answer); |
|
595 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
596 | 596 | $system_ID = $QFI->get('QST_system'); |
597 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
598 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
597 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
598 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
599 | 599 | |
600 | 600 | |
601 | - switch ( $QFI->get('QST_type') ){ |
|
601 | + switch ($QFI->get('QST_type')) { |
|
602 | 602 | |
603 | 603 | case 'TEXTAREA' : |
604 | - return EEH_Form_Fields::textarea( $display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
604 | + return EEH_Form_Fields::textarea($display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
605 | 605 | break; |
606 | 606 | |
607 | 607 | case 'DROPDOWN' : |
608 | - return EEH_Form_Fields::select( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE ); |
|
608 | + return EEH_Form_Fields::select($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE); |
|
609 | 609 | break; |
610 | 610 | |
611 | 611 | |
612 | 612 | case 'RADIO_BTN' : |
613 | - return EEH_Form_Fields::radio( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label ); |
|
613 | + return EEH_Form_Fields::radio($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label); |
|
614 | 614 | break; |
615 | 615 | |
616 | 616 | case 'CHECKBOX' : |
617 | - return EEH_Form_Fields::checkbox( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities ); |
|
617 | + return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities); |
|
618 | 618 | break; |
619 | 619 | |
620 | 620 | case 'DATE' : |
621 | - return EEH_Form_Fields::datepicker( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
621 | + return EEH_Form_Fields::datepicker($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
622 | 622 | break; |
623 | 623 | |
624 | 624 | case 'TEXT' : |
625 | 625 | default: |
626 | - return EEH_Form_Fields::text( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
626 | + return EEH_Form_Fields::text($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
627 | 627 | break; |
628 | 628 | |
629 | 629 | } |
@@ -649,31 +649,31 @@ discard block |
||
649 | 649 | * @param string $disabled disabled="disabled" or null |
650 | 650 | * @return string HTML |
651 | 651 | */ |
652 | - static function text( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
652 | + static function text($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
653 | 653 | // need these |
654 | - if ( ! $question || ! $name ) { |
|
654 | + if ( ! $question || ! $name) { |
|
655 | 655 | return NULL; |
656 | 656 | } |
657 | 657 | // prep the answer |
658 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
658 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
659 | 659 | // prep the required array |
660 | - $required = self::prep_required( $required ); |
|
660 | + $required = self::prep_required($required); |
|
661 | 661 | // set disabled tag |
662 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
662 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
663 | 663 | // ya gots ta have style man!!! |
664 | 664 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
665 | - $class = empty( $class ) ? $txt_class : $class; |
|
666 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
667 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
665 | + $class = empty($class) ? $txt_class : $class; |
|
666 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
667 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
668 | 668 | |
669 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
669 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
670 | 670 | // filter label but ensure required text comes before it |
671 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
671 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
672 | 672 | |
673 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr( $answer ) . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled .' ' . $extra . '/>'; |
|
673 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.esc_attr($answer).'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
674 | 674 | |
675 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
676 | - return $label_html . $input_html; |
|
675 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
676 | + return $label_html.$input_html; |
|
677 | 677 | |
678 | 678 | } |
679 | 679 | |
@@ -695,35 +695,35 @@ discard block |
||
695 | 695 | * @param string $disabled disabled="disabled" or null |
696 | 696 | * @return string HTML |
697 | 697 | */ |
698 | - static function textarea( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
698 | + static function textarea($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
699 | 699 | // need these |
700 | - if ( ! $question || ! $name ) { |
|
700 | + if ( ! $question || ! $name) { |
|
701 | 701 | return NULL; |
702 | 702 | } |
703 | 703 | // prep the answer |
704 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
704 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
705 | 705 | // prep the required array |
706 | - $required = self::prep_required( $required ); |
|
706 | + $required = self::prep_required($required); |
|
707 | 707 | // make sure $dimensions is an array |
708 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
708 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
709 | 709 | // and set some defaults |
710 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
710 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
711 | 711 | // set disabled tag |
712 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
712 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
713 | 713 | // ya gots ta have style man!!! |
714 | 714 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
715 | - $class = empty( $class ) ? $txt_class : $class; |
|
716 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
717 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
715 | + $class = empty($class) ? $txt_class : $class; |
|
716 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
717 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
718 | 718 | |
719 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
719 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
720 | 720 | // filter label but ensure required text comes before it |
721 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
721 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
722 | 722 | |
723 | - $input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '" title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>'; |
|
723 | + $input_html = "\n\t\t\t".'<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'" title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'.$answer.'</textarea>'; |
|
724 | 724 | |
725 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
726 | - return $label_html . $input_html; |
|
725 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
726 | + return $label_html.$input_html; |
|
727 | 727 | |
728 | 728 | } |
729 | 729 | |
@@ -746,47 +746,47 @@ discard block |
||
746 | 746 | * @param string $disabled disabled="disabled" or null |
747 | 747 | * @return string HTML |
748 | 748 | */ |
749 | - static function select( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE ) { |
|
749 | + static function select($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE) { |
|
750 | 750 | |
751 | 751 | // need these |
752 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
752 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
753 | 753 | return NULL; |
754 | 754 | } |
755 | 755 | // prep the answer |
756 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer ), $use_html_entities) : self::prep_answer( $answer, $use_html_entities ); |
|
756 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer), $use_html_entities) : self::prep_answer($answer, $use_html_entities); |
|
757 | 757 | // prep the required array |
758 | - $required = self::prep_required( $required ); |
|
758 | + $required = self::prep_required($required); |
|
759 | 759 | // set disabled tag |
760 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
760 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
761 | 761 | // ya gots ta have style man!!! |
762 | 762 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
763 | - $class = empty( $class ) ? $txt_class : $class; |
|
764 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
765 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
763 | + $class = empty($class) ? $txt_class : $class; |
|
764 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
765 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
766 | 766 | |
767 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
767 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
768 | 768 | // filter label but ensure required text comes before it |
769 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
769 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
770 | 770 | |
771 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
771 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
772 | 772 | // recursively count array elements, to determine total number of options |
773 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
774 | - if ( ! $only_option ) { |
|
773 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
774 | + if ( ! $only_option) { |
|
775 | 775 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
776 | 776 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
777 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
777 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
778 | 778 | } |
779 | - foreach ( $options as $key => $value ) { |
|
779 | + foreach ($options as $key => $value) { |
|
780 | 780 | // if value is an array, then create option groups, else create regular ol' options |
781 | - $input_html .= is_array( $value ) ? self::_generate_select_option_group( $key, $value, $answer, $use_html_entities ) : self::_generate_select_option( $value->value(), $value->desc(), $answer, $only_option, $use_html_entities ); |
|
781 | + $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer, $use_html_entities) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option, $use_html_entities); |
|
782 | 782 | } |
783 | 783 | |
784 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
784 | + $input_html .= "\n\t\t\t".'</select>'; |
|
785 | 785 | |
786 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
786 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
787 | 787 | |
788 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
789 | - return $label_html . $input_html; |
|
788 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
789 | + return $label_html.$input_html; |
|
790 | 790 | |
791 | 791 | } |
792 | 792 | |
@@ -804,12 +804,12 @@ discard block |
||
804 | 804 | * @param boolean $use_html_entities |
805 | 805 | * @return string |
806 | 806 | */ |
807 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer, $use_html_entities = true ){ |
|
808 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
809 | - foreach ( $QSOs as $QSO ) { |
|
810 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer, false, $use_html_entities ); |
|
807 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true) { |
|
808 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
809 | + foreach ($QSOs as $QSO) { |
|
810 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities); |
|
811 | 811 | } |
812 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
812 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
813 | 813 | return $html; |
814 | 814 | } |
815 | 815 | |
@@ -824,12 +824,12 @@ discard block |
||
824 | 824 | * @param boolean $use_html_entities |
825 | 825 | * @return string |
826 | 826 | */ |
827 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE, $use_html_entities = true ){ |
|
828 | - $key = self::prep_answer( $key, $use_html_entities ); |
|
829 | - $value = self::prep_answer( $value, $use_html_entities ); |
|
830 | - $value = ! empty( $value ) ? $value : $key; |
|
831 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
832 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
827 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE, $use_html_entities = true) { |
|
828 | + $key = self::prep_answer($key, $use_html_entities); |
|
829 | + $value = self::prep_answer($value, $use_html_entities); |
|
830 | + $value = ! empty($value) ? $value : $key; |
|
831 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
832 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | |
@@ -853,56 +853,56 @@ discard block |
||
853 | 853 | * @param bool $use_desc_4_label |
854 | 854 | * @return string HTML |
855 | 855 | */ |
856 | - static function radio( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE ) { |
|
856 | + static function radio($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE) { |
|
857 | 857 | // need these |
858 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
858 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
859 | 859 | return NULL; |
860 | 860 | } |
861 | 861 | // prep the answer |
862 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
862 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
863 | 863 | // prep the required array |
864 | - $required = self::prep_required( $required ); |
|
864 | + $required = self::prep_required($required); |
|
865 | 865 | // set disabled tag |
866 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
866 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
867 | 867 | // ya gots ta have style man!!! |
868 | 868 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
869 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
870 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
869 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
870 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
871 | 871 | |
872 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
872 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
873 | 873 | // filter label but ensure required text comes before it |
874 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
874 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
875 | 875 | |
876 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
876 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
877 | 877 | |
878 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
879 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
878 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
879 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
880 | 880 | |
881 | - foreach ( $options as $OPT ) { |
|
882 | - if ( $OPT instanceof EE_Question_Option ) { |
|
883 | - $value = self::prep_option_value( $OPT->value() ); |
|
881 | + foreach ($options as $OPT) { |
|
882 | + if ($OPT instanceof EE_Question_Option) { |
|
883 | + $value = self::prep_option_value($OPT->value()); |
|
884 | 884 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
885 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
886 | - $desc = $OPT->desc();//no self::prep_answer |
|
887 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
888 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
889 | - $opt = '-' . sanitize_key( $value ); |
|
890 | - |
|
891 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
892 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
893 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
894 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
895 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
896 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
897 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
898 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
885 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
886 | + $desc = $OPT->desc(); //no self::prep_answer |
|
887 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
888 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
889 | + $opt = '-'.sanitize_key($value); |
|
890 | + |
|
891 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
892 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
893 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
894 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="radio" name="'.$name.'" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
895 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
896 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
897 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
898 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
899 | 899 | } |
900 | 900 | } |
901 | 901 | |
902 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
902 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
903 | 903 | |
904 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
905 | - return $label_html . $input_html; |
|
904 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
905 | + return $label_html.$input_html; |
|
906 | 906 | |
907 | 907 | } |
908 | 908 | |
@@ -925,65 +925,65 @@ discard block |
||
925 | 925 | * @param string $disabled disabled="disabled" or null |
926 | 926 | * @return string HTML |
927 | 927 | */ |
928 | - static function checkbox( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
928 | + static function checkbox($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
929 | 929 | // need these |
930 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
930 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
931 | 931 | return NULL; |
932 | 932 | } |
933 | - $answer = maybe_unserialize( $answer ); |
|
933 | + $answer = maybe_unserialize($answer); |
|
934 | 934 | |
935 | 935 | // prep the answer(s) |
936 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
936 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
937 | 937 | |
938 | - foreach ( $answer as $key => $value ) { |
|
939 | - $key = self::prep_option_value( $key ); |
|
940 | - $answer[$key] = self::prep_answer( $value, $use_html_entities ); |
|
938 | + foreach ($answer as $key => $value) { |
|
939 | + $key = self::prep_option_value($key); |
|
940 | + $answer[$key] = self::prep_answer($value, $use_html_entities); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | // prep the required array |
944 | - $required = self::prep_required( $required ); |
|
944 | + $required = self::prep_required($required); |
|
945 | 945 | // set disabled tag |
946 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
946 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
947 | 947 | // ya gots ta have style man!!! |
948 | 948 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
949 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
950 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
949 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
950 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
951 | 951 | |
952 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
952 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
953 | 953 | // filter label but ensure required text comes before it |
954 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
955 | - |
|
956 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
957 | - |
|
958 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
959 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
960 | - |
|
961 | - foreach ( $options as $OPT ) { |
|
962 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
963 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
964 | - $text = self::prep_answer( $OPT->value() ); |
|
965 | - $desc = $OPT->desc() ; |
|
966 | - $opt = '-' . sanitize_key( $value ); |
|
967 | - |
|
968 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
969 | - |
|
970 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
971 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
972 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
973 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
974 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
975 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
976 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
977 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
954 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
955 | + |
|
956 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
957 | + |
|
958 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
959 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
960 | + |
|
961 | + foreach ($options as $OPT) { |
|
962 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
963 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
964 | + $text = self::prep_answer($OPT->value()); |
|
965 | + $desc = $OPT->desc(); |
|
966 | + $opt = '-'.sanitize_key($value); |
|
967 | + |
|
968 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
969 | + |
|
970 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
971 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
972 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
973 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="checkbox" name="'.$name.'['.$OPT->ID().']" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
974 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
975 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
976 | + if ( ! empty($desc) && $desc != $text) { |
|
977 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
978 | 978 | } |
979 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
979 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
980 | 980 | |
981 | 981 | } |
982 | 982 | |
983 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
983 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
984 | 984 | |
985 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
986 | - return $label_html . $input_html; |
|
985 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
986 | + return $label_html.$input_html; |
|
987 | 987 | |
988 | 988 | } |
989 | 989 | |
@@ -1005,36 +1005,36 @@ discard block |
||
1005 | 1005 | * @param string $disabled disabled="disabled" or null |
1006 | 1006 | * @return string HTML |
1007 | 1007 | */ |
1008 | - static function datepicker( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
1008 | + static function datepicker($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
1009 | 1009 | // need these |
1010 | - if ( ! $question || ! $name ) { |
|
1010 | + if ( ! $question || ! $name) { |
|
1011 | 1011 | return NULL; |
1012 | 1012 | } |
1013 | 1013 | // prep the answer |
1014 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
1014 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
1015 | 1015 | // prep the required array |
1016 | - $required = self::prep_required( $required ); |
|
1016 | + $required = self::prep_required($required); |
|
1017 | 1017 | // set disabled tag |
1018 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1018 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1019 | 1019 | // ya gots ta have style man!!! |
1020 | 1020 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
1021 | - $class = empty( $class ) ? $txt_class : $class; |
|
1022 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
1023 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
1021 | + $class = empty($class) ? $txt_class : $class; |
|
1022 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
1023 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
1024 | 1024 | |
1025 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
1025 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
1026 | 1026 | // filter label but ensure required text comes before it |
1027 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
1027 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
1028 | 1028 | |
1029 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . ' ' . $extra . '/>'; |
|
1029 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
1030 | 1030 | |
1031 | 1031 | // enqueue scripts |
1032 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1033 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
1034 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1032 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1033 | + wp_enqueue_style('espresso-ui-theme'); |
|
1034 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1035 | 1035 | |
1036 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
1037 | - return $label_html . $input_html; |
|
1036 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
1037 | + return $label_html.$input_html; |
|
1038 | 1038 | |
1039 | 1039 | } |
1040 | 1040 | |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | * @access public |
1047 | 1047 | * @return string |
1048 | 1048 | */ |
1049 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
1049 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
1050 | 1050 | return $required_text; |
1051 | 1051 | } |
1052 | 1052 | |
@@ -1060,9 +1060,9 @@ discard block |
||
1060 | 1060 | * @param string $value |
1061 | 1061 | * @return string HTML |
1062 | 1062 | */ |
1063 | - static function hidden_input( $name, $value, $id = '' ){ |
|
1064 | - $id = ! empty( $id ) ? $id : $name; |
|
1065 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
1063 | + static function hidden_input($name, $value, $id = '') { |
|
1064 | + $id = ! empty($id) ? $id : $name; |
|
1065 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | * @param string $question |
1075 | 1075 | * @return string |
1076 | 1076 | */ |
1077 | - static function prep_question( $question ){ |
|
1077 | + static function prep_question($question) { |
|
1078 | 1078 | return $question; |
1079 | 1079 | // $link = ''; |
1080 | 1080 | // // does this label have a help link attached ? |
@@ -1097,13 +1097,13 @@ discard block |
||
1097 | 1097 | * @param mixed $answer |
1098 | 1098 | * @return string |
1099 | 1099 | */ |
1100 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
1100 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
1101 | 1101 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
1102 | - if ( is_bool( $answer ) ) { |
|
1102 | + if (is_bool($answer)) { |
|
1103 | 1103 | $answer = $answer ? 1 : 0; |
1104 | 1104 | } |
1105 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
1106 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
1105 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
1106 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | |
@@ -1113,18 +1113,18 @@ discard block |
||
1113 | 1113 | * @param array $QSOs array of EE_Question_Option objects |
1114 | 1114 | * @return array |
1115 | 1115 | */ |
1116 | - public static function prep_answer_options( $QSOs = array() ){ |
|
1116 | + public static function prep_answer_options($QSOs = array()) { |
|
1117 | 1117 | $prepped_answer_options = array(); |
1118 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
1119 | - foreach( $QSOs as $key => $QSO ) { |
|
1120 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
1121 | - $QSO = EE_Question_Option::new_instance( array( |
|
1122 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
1123 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
1118 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
1119 | + foreach ($QSOs as $key => $QSO) { |
|
1120 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
1121 | + $QSO = EE_Question_Option::new_instance(array( |
|
1122 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
1123 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
1124 | 1124 | )); |
1125 | 1125 | } |
1126 | - if ( $QSO->opt_group() ) { |
|
1127 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
1126 | + if ($QSO->opt_group()) { |
|
1127 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
1128 | 1128 | } else { |
1129 | 1129 | $prepped_answer_options[] = $QSO; |
1130 | 1130 | } |
@@ -1140,8 +1140,8 @@ discard block |
||
1140 | 1140 | * @param string $option_value |
1141 | 1141 | * @return string |
1142 | 1142 | */ |
1143 | - static function prep_option_value( $option_value ){ |
|
1144 | - return esc_attr( trim( stripslashes( $option_value ) ) ); |
|
1143 | + static function prep_option_value($option_value) { |
|
1144 | + return esc_attr(trim(stripslashes($option_value))); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | |
@@ -1152,11 +1152,11 @@ discard block |
||
1152 | 1152 | * @param string|array $required |
1153 | 1153 | * @return array |
1154 | 1154 | */ |
1155 | - static function prep_required( $required = array() ){ |
|
1155 | + static function prep_required($required = array()) { |
|
1156 | 1156 | // make sure required is an array |
1157 | - $required = is_array( $required ) ? $required : array(); |
|
1157 | + $required = is_array($required) ? $required : array(); |
|
1158 | 1158 | // and set some defaults |
1159 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
1159 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
1160 | 1160 | return $required; |
1161 | 1161 | } |
1162 | 1162 | |
@@ -1167,30 +1167,30 @@ discard block |
||
1167 | 1167 | * @param string $value |
1168 | 1168 | * @return string |
1169 | 1169 | */ |
1170 | - static function get_label_size_class( $value = FALSE ){ |
|
1171 | - if ( $value === FALSE || $value == '' ) { |
|
1170 | + static function get_label_size_class($value = FALSE) { |
|
1171 | + if ($value === FALSE || $value == '') { |
|
1172 | 1172 | return ' class="medium-lbl"'; |
1173 | 1173 | } |
1174 | 1174 | // determine length of option value |
1175 | - $val_size = strlen( $value ); |
|
1176 | - switch( $val_size ){ |
|
1175 | + $val_size = strlen($value); |
|
1176 | + switch ($val_size) { |
|
1177 | 1177 | case $val_size < 3 : |
1178 | - $size = ' class="nano-lbl"'; |
|
1178 | + $size = ' class="nano-lbl"'; |
|
1179 | 1179 | break; |
1180 | 1180 | case $val_size < 6 : |
1181 | - $size = ' class="micro-lbl"'; |
|
1181 | + $size = ' class="micro-lbl"'; |
|
1182 | 1182 | break; |
1183 | 1183 | case $val_size < 12 : |
1184 | - $size = ' class="tiny-lbl"'; |
|
1184 | + $size = ' class="tiny-lbl"'; |
|
1185 | 1185 | break; |
1186 | 1186 | case $val_size < 25 : |
1187 | - $size = ' class="small-lbl"'; |
|
1187 | + $size = ' class="small-lbl"'; |
|
1188 | 1188 | break; |
1189 | 1189 | case $val_size > 100 : |
1190 | - $size = ' class="big-lbl"'; |
|
1190 | + $size = ' class="big-lbl"'; |
|
1191 | 1191 | break; |
1192 | 1192 | default: |
1193 | - $size = ' class="medium-lbl"'; |
|
1193 | + $size = ' class="medium-lbl"'; |
|
1194 | 1194 | break; |
1195 | 1195 | } |
1196 | 1196 | return $size; |
@@ -1204,20 +1204,20 @@ discard block |
||
1204 | 1204 | * @param array $QFI |
1205 | 1205 | * @return array |
1206 | 1206 | */ |
1207 | - private static function _load_system_dropdowns( $QFI ){ |
|
1207 | + private static function _load_system_dropdowns($QFI) { |
|
1208 | 1208 | $QST_system = $QFI->get('QST_system'); |
1209 | - switch ( $QST_system ) { |
|
1209 | + switch ($QST_system) { |
|
1210 | 1210 | case 'state' : |
1211 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1211 | + $QFI = self::generate_state_dropdown($QFI); |
|
1212 | 1212 | break; |
1213 | 1213 | case 'country' : |
1214 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1214 | + $QFI = self::generate_country_dropdown($QFI); |
|
1215 | 1215 | break; |
1216 | 1216 | case 'admin-state' : |
1217 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
1217 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
1218 | 1218 | break; |
1219 | 1219 | case 'admin-country' : |
1220 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
1220 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
1221 | 1221 | break; |
1222 | 1222 | } |
1223 | 1223 | return $QFI; |
@@ -1234,13 +1234,13 @@ discard block |
||
1234 | 1234 | * |
1235 | 1235 | * @return EE_Question_Form_Input |
1236 | 1236 | */ |
1237 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
1238 | - switch( $QFI->get( 'QST_type' ) ) { |
|
1237 | + protected static function _load_specialized_dropdowns($QFI) { |
|
1238 | + switch ($QFI->get('QST_type')) { |
|
1239 | 1239 | case 'STATE' : |
1240 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1240 | + $QFI = self::generate_state_dropdown($QFI); |
|
1241 | 1241 | break; |
1242 | 1242 | case 'COUNTRY' : |
1243 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1243 | + $QFI = self::generate_country_dropdown($QFI); |
|
1244 | 1244 | break; |
1245 | 1245 | } |
1246 | 1246 | return $QFI; |
@@ -1254,23 +1254,23 @@ discard block |
||
1254 | 1254 | * @param bool $get_all |
1255 | 1255 | * @return array |
1256 | 1256 | */ |
1257 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
1257 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
1258 | 1258 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
1259 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
1260 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1259 | + if ($states && count($states) != count($QST->options())) { |
|
1260 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1261 | 1261 | // if multiple countries, we'll create option groups within the dropdown |
1262 | - foreach ( $states as $state ) { |
|
1263 | - if ( $state instanceof EE_State ) { |
|
1264 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1262 | + foreach ($states as $state) { |
|
1263 | + if ($state instanceof EE_State) { |
|
1264 | + $QSO = EE_Question_Option::new_instance(array( |
|
1265 | 1265 | 'QSO_value' => $state->ID(), |
1266 | 1266 | 'QSO_desc' => $state->name(), |
1267 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1267 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1268 | 1268 | 'QSO_deleted' => FALSE |
1269 | 1269 | )); |
1270 | 1270 | // set option group |
1271 | - $QSO->set_opt_group( $state->country()->name() ); |
|
1271 | + $QSO->set_opt_group($state->country()->name()); |
|
1272 | 1272 | // add option to question |
1273 | - $QST->add_temp_option( $QSO ); |
|
1273 | + $QST->add_temp_option($QSO); |
|
1274 | 1274 | } |
1275 | 1275 | } |
1276 | 1276 | } |
@@ -1286,20 +1286,20 @@ discard block |
||
1286 | 1286 | * @internal param array $question |
1287 | 1287 | * @return array |
1288 | 1288 | */ |
1289 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
1289 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
1290 | 1290 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
1291 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
1292 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1291 | + if ($countries && count($countries) != count($QST->options())) { |
|
1292 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1293 | 1293 | // now add countries |
1294 | - foreach ( $countries as $country ) { |
|
1295 | - if ( $country instanceof EE_Country ) { |
|
1296 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1294 | + foreach ($countries as $country) { |
|
1295 | + if ($country instanceof EE_Country) { |
|
1296 | + $QSO = EE_Question_Option::new_instance(array( |
|
1297 | 1297 | 'QSO_value' => $country->ID(), |
1298 | 1298 | 'QSO_desc' => $country->name(), |
1299 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1299 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1300 | 1300 | 'QSO_deleted' => FALSE |
1301 | 1301 | )); |
1302 | - $QST->add_temp_option( $QSO ); |
|
1302 | + $QST->add_temp_option($QSO); |
|
1303 | 1303 | } |
1304 | 1304 | } |
1305 | 1305 | } |
@@ -1316,11 +1316,11 @@ discard block |
||
1316 | 1316 | */ |
1317 | 1317 | public static function two_digit_months_dropdown_options() { |
1318 | 1318 | $options = array(); |
1319 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
1320 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1321 | - $options[ (string)$mm ] = (string)$mm; |
|
1319 | + for ($x = 1; $x <= 12; $x++) { |
|
1320 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1321 | + $options[(string) $mm] = (string) $mm; |
|
1322 | 1322 | } |
1323 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1323 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | |
@@ -1335,11 +1335,11 @@ discard block |
||
1335 | 1335 | $options = array(); |
1336 | 1336 | $current_year = date('y'); |
1337 | 1337 | $next_decade = $current_year + 10; |
1338 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
1339 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1340 | - $options[ (string)$yy ] = (string)$yy; |
|
1338 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
1339 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1340 | + $options[(string) $yy] = (string) $yy; |
|
1341 | 1341 | } |
1342 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1342 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | 1345 | |
@@ -1353,17 +1353,17 @@ discard block |
||
1353 | 1353 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
1354 | 1354 | * @return string html |
1355 | 1355 | */ |
1356 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
1356 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
1357 | 1357 | $_where = array(); |
1358 | - if ( !empty( $status ) ) { |
|
1358 | + if ( ! empty($status)) { |
|
1359 | 1359 | $_where['STS_ID'] = $status; |
1360 | 1360 | } |
1361 | 1361 | |
1362 | - if ( $evt_category > 0 ) { |
|
1362 | + if ($evt_category > 0) { |
|
1363 | 1363 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1364 | 1364 | } |
1365 | 1365 | |
1366 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
1366 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
1367 | 1367 | |
1368 | 1368 | //setup vals for select input helper |
1369 | 1369 | $options = array( |
@@ -1373,15 +1373,15 @@ discard block |
||
1373 | 1373 | ) |
1374 | 1374 | ); |
1375 | 1375 | |
1376 | - foreach ( $regdtts as $regdtt ) { |
|
1377 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
1376 | + foreach ($regdtts as $regdtt) { |
|
1377 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
1378 | 1378 | $options[] = array( |
1379 | 1379 | 'text' => $date, |
1380 | 1380 | 'id' => $date |
1381 | 1381 | ); |
1382 | 1382 | } |
1383 | 1383 | |
1384 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
1384 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | |
@@ -1395,18 +1395,18 @@ discard block |
||
1395 | 1395 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
1396 | 1396 | * @return string html |
1397 | 1397 | */ |
1398 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
1398 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
1399 | 1399 | //determine what post_status our condition will have for the query. |
1400 | - switch ( $status ) { |
|
1400 | + switch ($status) { |
|
1401 | 1401 | case 'month' : |
1402 | 1402 | case 'today' : |
1403 | 1403 | case NULL : |
1404 | 1404 | case 'all' : |
1405 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
1405 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
1406 | 1406 | break; |
1407 | 1407 | |
1408 | 1408 | case 'draft' : |
1409 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1409 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
1410 | 1410 | |
1411 | 1411 | default : |
1412 | 1412 | $where['Event.status'] = $status; |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | //categories? |
1416 | 1416 | |
1417 | 1417 | |
1418 | - if ( !empty ( $evt_category ) ) { |
|
1418 | + if ( ! empty ($evt_category)) { |
|
1419 | 1419 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1420 | 1420 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1421 | 1421 | } |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | |
1424 | 1424 | // $where['DTT_is_primary'] = 1; |
1425 | 1425 | |
1426 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
1426 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
1427 | 1427 | |
1428 | 1428 | //let's setup vals for select input helper |
1429 | 1429 | $options = array( |
@@ -1438,9 +1438,9 @@ discard block |
||
1438 | 1438 | //translate month and date |
1439 | 1439 | global $wp_locale; |
1440 | 1440 | |
1441 | - foreach ( $DTTS as $DTT ) { |
|
1442 | - $localized_date = $wp_locale->get_month( $DTT->dtt_month_num ) . ' ' . $DTT->dtt_year; |
|
1443 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
1441 | + foreach ($DTTS as $DTT) { |
|
1442 | + $localized_date = $wp_locale->get_month($DTT->dtt_month_num).' '.$DTT->dtt_year; |
|
1443 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
1444 | 1444 | $options[] = array( |
1445 | 1445 | 'text' => $localized_date, |
1446 | 1446 | 'id' => $id |
@@ -1448,7 +1448,7 @@ discard block |
||
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | |
1451 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
1451 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1452 | 1452 | } |
1453 | 1453 | |
1454 | 1454 | |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | * @param integer $current_cat currently selected category |
1460 | 1460 | * @return string html for dropdown |
1461 | 1461 | */ |
1462 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
1462 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
1463 | 1463 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
1464 | 1464 | $options = array( |
1465 | 1465 | '0' => array( |
@@ -1469,14 +1469,14 @@ discard block |
||
1469 | 1469 | ); |
1470 | 1470 | |
1471 | 1471 | //setup categories for dropdown |
1472 | - foreach ( $categories as $category ) { |
|
1472 | + foreach ($categories as $category) { |
|
1473 | 1473 | $options[] = array( |
1474 | 1474 | 'text' => $category->get('name'), |
1475 | 1475 | 'id' => $category->ID() |
1476 | 1476 | ); |
1477 | 1477 | } |
1478 | 1478 | |
1479 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
1479 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | |
@@ -1495,20 +1495,20 @@ discard block |
||
1495 | 1495 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1496 | 1496 | * @return void |
1497 | 1497 | */ |
1498 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
1498 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
1499 | 1499 | $btn = ''; |
1500 | - if ( empty( $url ) || empty( $ID )) { |
|
1500 | + if (empty($url) || empty($ID)) { |
|
1501 | 1501 | return $btn; |
1502 | 1502 | } |
1503 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
1504 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
1505 | - if ( ! $input_only ) { |
|
1506 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
1507 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
1503 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
1504 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
1505 | + if ( ! $input_only) { |
|
1506 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
1507 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
1508 | 1508 | $btn_frm .= $btn; |
1509 | 1509 | $btn_frm .= '</form>'; |
1510 | 1510 | $btn = $btn_frm; |
1511 | - unset ( $btn_frm ); |
|
1511 | + unset ($btn_frm); |
|
1512 | 1512 | } |
1513 | 1513 | return $btn; |
1514 | 1514 | } |
@@ -31,7 +31,6 @@ discard block |
||
31 | 31 | |
32 | 32 | /** |
33 | 33 | * google_map - creates a Google Map Link |
34 | - * @param array $atts aray of attributes required for the map link generation |
|
35 | 34 | * @return string (link to map!) |
36 | 35 | */ |
37 | 36 | public static function google_map( $ee_gmaps_opts ){ |
@@ -116,7 +115,6 @@ discard block |
||
116 | 115 | |
117 | 116 | /** |
118 | 117 | * creates a Google Map Link |
119 | - * @param array $atts aray of attributes required for the map link generation |
|
120 | 118 | * @return string (link to map!) |
121 | 119 | */ |
122 | 120 | public static function espresso_google_map_js() { |
@@ -34,20 +34,20 @@ discard block |
||
34 | 34 | * @param array $atts aray of attributes required for the map link generation |
35 | 35 | * @return string (link to map!) |
36 | 36 | */ |
37 | - public static function google_map( $ee_gmaps_opts ){ |
|
37 | + public static function google_map($ee_gmaps_opts) { |
|
38 | 38 | |
39 | 39 | //d( $ee_gmaps_opts ); |
40 | 40 | |
41 | - $ee_map_width = isset( $ee_gmaps_opts['ee_map_width'] ) && ! empty( $ee_gmaps_opts['ee_map_width'] ) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
42 | - $ee_map_height = isset( $ee_gmaps_opts['ee_map_height'] ) && ! empty( $ee_gmaps_opts['ee_map_height'] ) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
43 | - $ee_map_zoom = isset( $ee_gmaps_opts['ee_map_zoom'] ) && ! empty( $ee_gmaps_opts['ee_map_zoom'] ) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
44 | - $ee_map_nav_display = isset( $ee_gmaps_opts['ee_map_nav_display'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_display'] ) ? 'true' : 'false'; |
|
45 | - $ee_map_nav_size = isset( $ee_gmaps_opts['ee_map_nav_size'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_size'] )? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
46 | - $ee_map_type_control = isset( $ee_gmaps_opts['ee_map_type_control'] ) && ! empty( $ee_gmaps_opts['ee_map_type_control'] )? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
47 | - $static_url = isset( $ee_gmaps_opts['ee_static_url'] ) && ! empty( $ee_gmaps_opts['ee_static_url'] )? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
41 | + $ee_map_width = isset($ee_gmaps_opts['ee_map_width']) && ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
42 | + $ee_map_height = isset($ee_gmaps_opts['ee_map_height']) && ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
43 | + $ee_map_zoom = isset($ee_gmaps_opts['ee_map_zoom']) && ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
44 | + $ee_map_nav_display = isset($ee_gmaps_opts['ee_map_nav_display']) && ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
45 | + $ee_map_nav_size = isset($ee_gmaps_opts['ee_map_nav_size']) && ! empty($ee_gmaps_opts['ee_map_nav_size']) ? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
46 | + $ee_map_type_control = isset($ee_gmaps_opts['ee_map_type_control']) && ! empty($ee_gmaps_opts['ee_map_type_control']) ? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
47 | + $static_url = isset($ee_gmaps_opts['ee_static_url']) && ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
48 | 48 | |
49 | - if( isset( $ee_gmaps_opts['ee_map_align'] ) && ! empty( $ee_gmaps_opts['ee_map_align'] )){ |
|
50 | - switch( $ee_gmaps_opts['ee_map_align'] ){ |
|
49 | + if (isset($ee_gmaps_opts['ee_map_align']) && ! empty($ee_gmaps_opts['ee_map_align'])) { |
|
50 | + switch ($ee_gmaps_opts['ee_map_align']) { |
|
51 | 51 | case "left": |
52 | 52 | $map_align = 'ee-gmap-align-left left'; |
53 | 53 | break; |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | |
69 | 69 | // Determine whether user has set a hardoded url to use and |
70 | 70 | // if so display a Google static iframe map else run V3 api |
71 | - if( $static_url ) { |
|
71 | + if ($static_url) { |
|
72 | 72 | |
73 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
74 | - $html .= '<iframe src="' . $static_url . '&output=embed" style="width: ' . $ee_map_width .'px; height: ' . $ee_map_height . 'px;" frameborder="0" scrolling="no">'; |
|
73 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper '.$map_align.'">'; |
|
74 | + $html .= '<iframe src="'.$static_url.'&output=embed" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;" frameborder="0" scrolling="no">'; |
|
75 | 75 | $html .= '</iframe>'; |
76 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
76 | + $html .= '<a href="'.$static_url.'">View Large map</a>'; |
|
77 | 77 | $html .= '</div>'; |
78 | 78 | return $html; |
79 | 79 | |
80 | 80 | } else { |
81 | 81 | |
82 | - EEH_Maps::$gmap_vars[ $ee_gmaps_opts['map_ID'] ] = array( |
|
82 | + EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
83 | 83 | 'map_ID' => $ee_gmaps_opts['map_ID'], |
84 | 84 | 'ee_map_zoom' => $ee_map_zoom, |
85 | 85 | 'ee_map_nav_display' => $ee_map_nav_display, |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | ); |
90 | 90 | |
91 | 91 | $html = '<div class="ee-gmap-wrapper '.$map_align.';">'; |
92 | - $html .= '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] .'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
92 | + $html .= '<div class="ee-gmap" id="map_canvas_'.$ee_gmaps_opts['map_ID'].'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
93 | 93 | $html .= '</div>'; |
94 | 94 | |
95 | - wp_enqueue_script( 'gmap_api' ); |
|
96 | - wp_enqueue_script( 'ee_gmap' ); |
|
97 | - add_action( 'wp_footer', array( 'EEH_Maps', 'footer_enqueue_script' )); |
|
95 | + wp_enqueue_script('gmap_api'); |
|
96 | + wp_enqueue_script('ee_gmap'); |
|
97 | + add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
98 | 98 | |
99 | 99 | return $html; |
100 | 100 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return void |
110 | 110 | */ |
111 | 111 | public static function footer_enqueue_script() { |
112 | - wp_localize_script( 'ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars ); |
|
112 | + wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function espresso_google_map_js() { |
123 | 123 | $scheme = is_ssl() ? 'https://' : 'http://'; |
124 | - wp_register_script( 'gmap_api', $scheme . 'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE ); |
|
125 | - wp_register_script( 'ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE ); |
|
124 | + wp_register_script('gmap_api', $scheme.'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE); |
|
125 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__).'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @return string (link to map!) |
132 | 132 | */ |
133 | 133 | public static function google_map_link($atts) { |
134 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
134 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
135 | 135 | extract($atts); |
136 | 136 | |
137 | 137 | $address = "{$address}"; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | $id = isset($id) ? $id : 'not_set'; |
147 | 147 | $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
148 | 148 | |
149 | - $address_string = ($address != '' ? $address : '') . ($city != '' ? ',' . $city : '') . ($state != '' ? ',' . $state : '') . ($zip != '' ? ',' . $zip : '') . ($country != '' ? ',' . $country : ''); |
|
149 | + $address_string = ($address != '' ? $address : '').($city != '' ? ','.$city : '').($state != '' ? ','.$state : '').($zip != '' ? ','.$zip : '').($country != '' ? ','.$country : ''); |
|
150 | 150 | |
151 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode( $address_string )); |
|
151 | + $google_map = htmlentities2('http://maps.google.com/maps?q='.urlencode($address_string)); |
|
152 | 152 | |
153 | 153 | switch ($type) { |
154 | 154 | case 'text': |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | |
163 | 163 | case 'map': |
164 | 164 | $scheme = is_ssl() ? 'https://' : 'http://'; |
165 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2( $scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode( $address_string ) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode( $address_string ) . '&sensor=false' ) . '" /></a>'; |
|
165 | + return '<a class="a_map_image_link" href="'.$google_map.'" target="_blank">'.'<img class="map_image_link" id="venue_map_'.$id.'" '.$map_image_class.' src="'.htmlentities2($scheme.'maps.googleapis.com/maps/api/staticmap?center='.urlencode($address_string).'&zoom=14&size='.$map_w.'x'.$map_h.'&markers=color:green|label:|'.urlencode($address_string).'&sensor=false').'" /></a>'; |
|
166 | 166 | } |
167 | 167 | |
168 | - return '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
168 | + return '<a href="'.$google_map.'" target="_blank">'.$text.'</a>'; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 |
@@ -109,7 +109,7 @@ |
||
109 | 109 | * - registers and enqueues the qtip scripts and styles. |
110 | 110 | * |
111 | 111 | * @access public |
112 | - * @param array $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
112 | + * @param string[] $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
113 | 113 | * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
114 | 114 | * @return void |
115 | 115 | */ |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function instance() { |
34 | 34 | // check if class object is instantiated |
35 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) { |
|
35 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EEH_Qtip_Loader)) { |
|
36 | 36 | self::$_instance = new self(); |
37 | 37 | } |
38 | 38 | return self::$_instance; |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | */ |
49 | 49 | private function __construct() { |
50 | 50 | //let's just make sure this is instantiated in the right place. |
51 | - if ( did_action( 'wp_print_styles' ) || did_action( 'admin_head' )) { |
|
52 | - EE_Error::doing_it_wrong( 'EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso' ), '4.1' ); |
|
51 | + if (did_action('wp_print_styles') || did_action('admin_head')) { |
|
52 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1'); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -61,27 +61,27 @@ discard block |
||
61 | 61 | * @return void |
62 | 62 | */ |
63 | 63 | public function register_and_enqueue() { |
64 | - $qtips_js = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js'; |
|
65 | - $qtip_images_loaded = EE_THIRD_PARTY_URL . 'qtip/imagesloaded.pkg.min.js'; |
|
66 | - $qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map'; |
|
67 | - $qtipcss = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css'; |
|
64 | + $qtips_js = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.js'; |
|
65 | + $qtip_images_loaded = EE_THIRD_PARTY_URL.'qtip/imagesloaded.pkg.min.js'; |
|
66 | + $qtip_map = EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.map'; |
|
67 | + $qtipcss = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.css'; |
|
68 | 68 | |
69 | - wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE ); |
|
70 | - wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE ); |
|
71 | - wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE ); |
|
72 | - wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
69 | + wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE); |
|
70 | + wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE); |
|
71 | + wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE); |
|
72 | + wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS.'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE); |
|
73 | 73 | |
74 | - wp_register_style('qtip-css', $qtipcss, array(), '2.2' ); |
|
74 | + wp_register_style('qtip-css', $qtipcss, array(), '2.2'); |
|
75 | 75 | |
76 | 76 | //k now let's see if there are any registered qtips. If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!) |
77 | - if ( !empty( $this->_qtips ) ) { |
|
77 | + if ( ! empty($this->_qtips)) { |
|
78 | 78 | wp_enqueue_script('ee-qtip-helper'); |
79 | 79 | wp_enqueue_style('qtip-css'); |
80 | 80 | $qtips = array(); |
81 | - foreach ( $this->_qtips as $qtip ) { |
|
81 | + foreach ($this->_qtips as $qtip) { |
|
82 | 82 | $qts = $qtip->get_tips(); |
83 | - foreach ( $qts as $qt ) { |
|
84 | - if ( ! $qt instanceof EE_Qtip ) |
|
83 | + foreach ($qts as $qt) { |
|
84 | + if ( ! $qt instanceof EE_Qtip) |
|
85 | 85 | continue; |
86 | 86 | $qtips[] = array( |
87 | 87 | 'content_id' => $qt->content_id, |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | ); |
91 | 91 | } |
92 | 92 | } |
93 | - if ( !empty($qtips) ) |
|
94 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
93 | + if ( ! empty($qtips)) |
|
94 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips)); |
|
95 | 95 | |
96 | 96 | } else { |
97 | 97 | //qtips has been requested without any registration (so assuming its just directly used in the admin). |
@@ -113,24 +113,24 @@ discard block |
||
113 | 113 | * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - public function register( $configname, $paths = array() ) { |
|
116 | + public function register($configname, $paths = array()) { |
|
117 | 117 | |
118 | 118 | //let's just make sure this is instantiated in the right place. |
119 | - if ( did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts') ) { |
|
120 | - EE_Error::doing_it_wrong( 'EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso' ), '4.1' ); |
|
119 | + if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) { |
|
120 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | $configname = (array) $configname; //typecast to array |
124 | - foreach ( $configname as $config ) { |
|
125 | - $this->_register( $config, $paths ); |
|
124 | + foreach ($configname as $config) { |
|
125 | + $this->_register($config, $paths); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | //hook into appropriate footer |
129 | 129 | $footer_action = is_admin() ? 'admin_footer' : 'wp_footer'; |
130 | - add_action($footer_action, array($this, 'setup_qtip'), 10 ); |
|
130 | + add_action($footer_action, array($this, 'setup_qtip'), 10); |
|
131 | 131 | |
132 | 132 | //make sure we "turn on" qtip js. |
133 | - add_filter('FHEE_load_qtip', '__return_true' ); |
|
133 | + add_filter('FHEE_load_qtip', '__return_true'); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | * @throws EE_Error |
145 | 145 | * @return void |
146 | 146 | */ |
147 | - private function _register( $config, $paths ) { |
|
147 | + private function _register($config, $paths) { |
|
148 | 148 | //before doing anything we have to make sure that EE_Qtip_Config parent is required. |
149 | - EE_Registry::instance()->load_lib( 'Qtip_Config', array(), TRUE ); |
|
149 | + EE_Registry::instance()->load_lib('Qtip_Config', array(), TRUE); |
|
150 | 150 | |
151 | - if ( !empty( $paths ) ) { |
|
151 | + if ( ! empty($paths)) { |
|
152 | 152 | $paths = (array) $paths; |
153 | - foreach ( $paths as $path ) { |
|
154 | - $path = $path . $config . '.lib.php'; |
|
155 | - if ( !is_readable($path ) ) { |
|
153 | + foreach ($paths as $path) { |
|
154 | + $path = $path.$config.'.lib.php'; |
|
155 | + if ( ! is_readable($path)) { |
|
156 | 156 | continue; |
157 | 157 | } else { |
158 | 158 | require_once $path; |
@@ -161,26 +161,26 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | //does class exist at this point? If it does then let's instantiate. If it doesn't then let's continue with other paths. |
164 | - if ( !class_exists($config) ) { |
|
165 | - $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php'; |
|
166 | - if ( !is_readable($path ) ) { |
|
167 | - throw new EE_Error( sprintf( __('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config ) ); |
|
164 | + if ( ! class_exists($config)) { |
|
165 | + $path = EE_LIBRARIES.'qtips/'.$config.'.lib.php'; |
|
166 | + if ( ! is_readable($path)) { |
|
167 | + throw new EE_Error(sprintf(__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config)); |
|
168 | 168 | } else { |
169 | 169 | require_once $path; |
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | 173 | //now we attempt a class_exists one more time. |
174 | - if ( !class_exists( $config ) ) |
|
175 | - throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
174 | + if ( ! class_exists($config)) |
|
175 | + throw new EE_Error(sprintf(__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config)); |
|
176 | 176 | |
177 | 177 | //made it HERE? FINALLY, let's get things setup. |
178 | 178 | $a = new ReflectionClass($config); |
179 | 179 | $qtip = $a->newInstance(); |
180 | 180 | |
181 | 181 | //verify that $qtip is a valid object |
182 | - if ( ! $qtip instanceof EE_Qtip_Config ) |
|
183 | - throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
182 | + if ( ! $qtip instanceof EE_Qtip_Config) |
|
183 | + throw new EE_Error(sprintf(__('The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config)); |
|
184 | 184 | |
185 | 185 | $this->_qtips[] = $a->newInstance(); |
186 | 186 | |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | * @return void |
197 | 197 | */ |
198 | 198 | public function setup_qtip() { |
199 | - if ( empty( $this->_qtips ) ) |
|
199 | + if (empty($this->_qtips)) |
|
200 | 200 | return; //no qtips! |
201 | 201 | |
202 | 202 | $content = array(); |
203 | 203 | |
204 | - foreach ( $this->_qtips as $qtip ) { |
|
204 | + foreach ($this->_qtips as $qtip) { |
|
205 | 205 | $content[] = $this->_generate_content_container($qtip); |
206 | 206 | } |
207 | 207 | |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | private function _generate_content_container($qtip) { |
219 | 219 | $qts = $qtip->get_tips(); |
220 | 220 | $content = array(); |
221 | - foreach ( $qts as $qt ) { |
|
222 | - if ( ! $qt instanceof EE_Qtip ) |
|
221 | + foreach ($qts as $qt) { |
|
222 | + if ( ! $qt instanceof EE_Qtip) |
|
223 | 223 | continue; |
224 | - $content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>'; |
|
224 | + $content[] = '<div class="ee-qtip-helper-content hidden" id="'.$qt->content_id.'">'.$qt->content.'</div>'; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return implode('<br />', $content); |
@@ -81,8 +81,9 @@ discard block |
||
81 | 81 | foreach ( $this->_qtips as $qtip ) { |
82 | 82 | $qts = $qtip->get_tips(); |
83 | 83 | foreach ( $qts as $qt ) { |
84 | - if ( ! $qt instanceof EE_Qtip ) |
|
85 | - continue; |
|
84 | + if ( ! $qt instanceof EE_Qtip ) { |
|
85 | + continue; |
|
86 | + } |
|
86 | 87 | $qtips[] = array( |
87 | 88 | 'content_id' => $qt->content_id, |
88 | 89 | 'options' => $qt->options, |
@@ -90,8 +91,9 @@ discard block |
||
90 | 91 | ); |
91 | 92 | } |
92 | 93 | } |
93 | - if ( !empty($qtips) ) |
|
94 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
94 | + if ( !empty($qtips) ) { |
|
95 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
96 | + } |
|
95 | 97 | |
96 | 98 | } else { |
97 | 99 | //qtips has been requested without any registration (so assuming its just directly used in the admin). |
@@ -171,16 +173,18 @@ discard block |
||
171 | 173 | } |
172 | 174 | |
173 | 175 | //now we attempt a class_exists one more time. |
174 | - if ( !class_exists( $config ) ) |
|
175 | - throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
176 | + if ( !class_exists( $config ) ) { |
|
177 | + throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
178 | + } |
|
176 | 179 | |
177 | 180 | //made it HERE? FINALLY, let's get things setup. |
178 | 181 | $a = new ReflectionClass($config); |
179 | 182 | $qtip = $a->newInstance(); |
180 | 183 | |
181 | 184 | //verify that $qtip is a valid object |
182 | - if ( ! $qtip instanceof EE_Qtip_Config ) |
|
183 | - throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
185 | + if ( ! $qtip instanceof EE_Qtip_Config ) { |
|
186 | + throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
187 | + } |
|
184 | 188 | |
185 | 189 | $this->_qtips[] = $a->newInstance(); |
186 | 190 | |
@@ -196,8 +200,10 @@ discard block |
||
196 | 200 | * @return void |
197 | 201 | */ |
198 | 202 | public function setup_qtip() { |
199 | - if ( empty( $this->_qtips ) ) |
|
200 | - return; //no qtips! |
|
203 | + if ( empty( $this->_qtips ) ) { |
|
204 | + return; |
|
205 | + } |
|
206 | + //no qtips! |
|
201 | 207 | |
202 | 208 | $content = array(); |
203 | 209 | |
@@ -219,8 +225,9 @@ discard block |
||
219 | 225 | $qts = $qtip->get_tips(); |
220 | 226 | $content = array(); |
221 | 227 | foreach ( $qts as $qt ) { |
222 | - if ( ! $qt instanceof EE_Qtip ) |
|
223 | - continue; |
|
228 | + if ( ! $qt instanceof EE_Qtip ) { |
|
229 | + continue; |
|
230 | + } |
|
224 | 231 | $content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>'; |
225 | 232 | } |
226 | 233 |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * For verifying that a variable is indeed an array, else throw an EE_Error |
133 | 133 | * @param type $variable_to_test |
134 | - * @param type $variable_name |
|
134 | + * @param string $variable_name |
|
135 | 135 | * @param type $allow_empty one of 'allow_empty' or 'do_not_allow_empty' |
136 | 136 | * @return void |
137 | 137 | * @throws EE_Error |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * for verifying that a variable is one of the string optiosn supplied |
160 | 160 | * @param mixed $variable_to_test |
161 | 161 | * @param mixed $variable_name the name you've given the variable. Eg, '$foo'. THis helps in producing better error messages |
162 | - * @param array $string_options an array of acceptable values |
|
162 | + * @param string[] $string_options an array of acceptable values |
|
163 | 163 | * @return void |
164 | 164 | * @throws EE_Error |
165 | 165 | */ |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | * @return void |
51 | 51 | * @throws EE_Error (indirectly) |
52 | 52 | */ |
53 | - static function verify_is_array_of($variable_to_test,$name_of_variable,$class_name,$allow_null='allow_null'){ |
|
54 | - if(!WP_DEBUG)return; |
|
55 | - self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
|
56 | - if('allow_null' == $allow_null && is_null($variable_to_test)){ |
|
53 | + static function verify_is_array_of($variable_to_test, $name_of_variable, $class_name, $allow_null = 'allow_null') { |
|
54 | + if ( ! WP_DEBUG)return; |
|
55 | + self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null')); |
|
56 | + if ('allow_null' == $allow_null && is_null($variable_to_test)) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | self::verify_is_array($variable_to_test, $name_of_variable); |
60 | - foreach($variable_to_test as $key=>$array_element){ |
|
60 | + foreach ($variable_to_test as $key=>$array_element) { |
|
61 | 61 | self::verify_instanceof($array_element, $key, $class_name); |
62 | 62 | } |
63 | 63 | } |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | * @throws EE_Error |
75 | 75 | */ |
76 | - static function verify_isnt_null($variable_to_test,$name_of_variable){ |
|
77 | - if(!WP_DEBUG)return; |
|
78 | - if($variable_to_test==null && $variable_to_test!=0 && $variable_to_test!=FALSE){ |
|
79 | - $error[]=__('Variable named %s is null.','event_espresso'); |
|
80 | - $error[]=__("Consider looking at the stack trace to see why it wasn't set.",'event_espresso'); |
|
81 | - throw new EE_Error(sprintf(implode(",",$error),$name_of_variable,$name_of_variable)); |
|
76 | + static function verify_isnt_null($variable_to_test, $name_of_variable) { |
|
77 | + if ( ! WP_DEBUG)return; |
|
78 | + if ($variable_to_test == null && $variable_to_test != 0 && $variable_to_test != FALSE) { |
|
79 | + $error[] = __('Variable named %s is null.', 'event_espresso'); |
|
80 | + $error[] = __("Consider looking at the stack trace to see why it wasn't set.", 'event_espresso'); |
|
81 | + throw new EE_Error(sprintf(implode(",", $error), $name_of_variable, $name_of_variable)); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | * @return void |
91 | 91 | * @throws EE_Error |
92 | 92 | */ |
93 | - static function verify_is_true($expression_to_test,$expression_string_representation){ |
|
94 | - if(!WP_DEBUG)return; |
|
95 | - if(!$expression_to_test){ |
|
96 | - $error[]=__('Template error.','event_espresso'); |
|
97 | - $error[]=__("%s evaluated to false, but it must be true!",'event_espresso'); |
|
98 | - throw new EE_Error(sprintf(implode(",",$error),$expression_string_representation)); |
|
93 | + static function verify_is_true($expression_to_test, $expression_string_representation) { |
|
94 | + if ( ! WP_DEBUG)return; |
|
95 | + if ( ! $expression_to_test) { |
|
96 | + $error[] = __('Template error.', 'event_espresso'); |
|
97 | + $error[] = __("%s evaluated to false, but it must be true!", 'event_espresso'); |
|
98 | + throw new EE_Error(sprintf(implode(",", $error), $expression_string_representation)); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -111,16 +111,16 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | * @throws EE_Error |
113 | 113 | */ |
114 | - static function verify_instanceof($variable_to_test,$name_of_variable,$class_name, $allow_null = 'do_not_allow_null'){ |
|
115 | - if(!WP_DEBUG)return; |
|
116 | - self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
|
117 | - if($allow_null == 'allow_null' && is_null($variable_to_test)){ |
|
114 | + static function verify_instanceof($variable_to_test, $name_of_variable, $class_name, $allow_null = 'do_not_allow_null') { |
|
115 | + if ( ! WP_DEBUG)return; |
|
116 | + self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null')); |
|
117 | + if ($allow_null == 'allow_null' && is_null($variable_to_test)) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | - if( $variable_to_test == NULL || ! ( $variable_to_test instanceof $class_name )){ |
|
121 | - $msg[]=__('Variable %s is not of the correct type.','event_espresso'); |
|
122 | - $msg[]=__("It should be of type %s",'event_espresso'); |
|
123 | - throw new EE_Error(sprintf(implode(",",$msg),$name_of_variable,$name_of_variable,$class_name)); |
|
120 | + if ($variable_to_test == NULL || ! ($variable_to_test instanceof $class_name)) { |
|
121 | + $msg[] = __('Variable %s is not of the correct type.', 'event_espresso'); |
|
122 | + $msg[] = __("It should be of type %s", 'event_espresso'); |
|
123 | + throw new EE_Error(sprintf(implode(",", $msg), $name_of_variable, $name_of_variable, $class_name)); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | * @return void |
137 | 137 | * @throws EE_Error |
138 | 138 | */ |
139 | - static function verify_is_array($variable_to_test,$variable_name,$allow_empty='allow_empty'){ |
|
140 | - if(!WP_DEBUG)return; |
|
141 | - self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty')); |
|
142 | - if(empty($variable_to_test) && 'allow_empty'==$allow_empty){ |
|
139 | + static function verify_is_array($variable_to_test, $variable_name, $allow_empty = 'allow_empty') { |
|
140 | + if ( ! WP_DEBUG)return; |
|
141 | + self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty', 'do_not_allow_empty')); |
|
142 | + if (empty($variable_to_test) && 'allow_empty' == $allow_empty) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | - if(!is_array($variable_to_test)){ |
|
146 | - $error[]=__('Variable %s should be an array, but it is not.'); |
|
147 | - $error[]=__("Its value is, instead '%s'",'event_espresso'); |
|
148 | - throw new EE_Error(sprintf(implode(",",$error),$variable_name,$variable_name,$variable_to_test)); |
|
145 | + if ( ! is_array($variable_to_test)) { |
|
146 | + $error[] = __('Variable %s should be an array, but it is not.'); |
|
147 | + $error[] = __("Its value is, instead '%s'", 'event_espresso'); |
|
148 | + throw new EE_Error(sprintf(implode(",", $error), $variable_name, $variable_name, $variable_to_test)); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | * @return void |
164 | 164 | * @throws EE_Error |
165 | 165 | */ |
166 | - static function verify_argument_is_one_of($variable_to_test,$variable_name,$string_options){ |
|
167 | - if(!WP_DEBUG)return; |
|
168 | - if(!in_array($variable_to_test,$string_options)){ |
|
169 | - $msg[0]=__('Malconfigured template.','event_espresso'); |
|
170 | - $msg[1]=__("Variable named '%s' was set to '%s'. It can only be one of '%s'",'event_espresso'); |
|
171 | - throw new EE_Error(sprintf(implode("||",$msg),$variable_name,$variable_to_test, implode("', '",$string_options))); |
|
166 | + static function verify_argument_is_one_of($variable_to_test, $variable_name, $string_options) { |
|
167 | + if ( ! WP_DEBUG)return; |
|
168 | + if ( ! in_array($variable_to_test, $string_options)) { |
|
169 | + $msg[0] = __('Malconfigured template.', 'event_espresso'); |
|
170 | + $msg[1] = __("Variable named '%s' was set to '%s'. It can only be one of '%s'", 'event_espresso'); |
|
171 | + throw new EE_Error(sprintf(implode("||", $msg), $variable_name, $variable_to_test, implode("', '", $string_options))); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | |
3 | 5 | /** |
4 | 6 | * Event Espresso |
@@ -51,7 +53,9 @@ discard block |
||
51 | 53 | * @throws EE_Error (indirectly) |
52 | 54 | */ |
53 | 55 | static function verify_is_array_of($variable_to_test,$name_of_variable,$class_name,$allow_null='allow_null'){ |
54 | - if(!WP_DEBUG)return; |
|
56 | + if(!WP_DEBUG) { |
|
57 | + return; |
|
58 | + } |
|
55 | 59 | self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
56 | 60 | if('allow_null' == $allow_null && is_null($variable_to_test)){ |
57 | 61 | return; |
@@ -74,7 +78,9 @@ discard block |
||
74 | 78 | * @throws EE_Error |
75 | 79 | */ |
76 | 80 | static function verify_isnt_null($variable_to_test,$name_of_variable){ |
77 | - if(!WP_DEBUG)return; |
|
81 | + if(!WP_DEBUG) { |
|
82 | + return; |
|
83 | + } |
|
78 | 84 | if($variable_to_test==null && $variable_to_test!=0 && $variable_to_test!=FALSE){ |
79 | 85 | $error[]=__('Variable named %s is null.','event_espresso'); |
80 | 86 | $error[]=__("Consider looking at the stack trace to see why it wasn't set.",'event_espresso'); |
@@ -91,7 +97,9 @@ discard block |
||
91 | 97 | * @throws EE_Error |
92 | 98 | */ |
93 | 99 | static function verify_is_true($expression_to_test,$expression_string_representation){ |
94 | - if(!WP_DEBUG)return; |
|
100 | + if(!WP_DEBUG) { |
|
101 | + return; |
|
102 | + } |
|
95 | 103 | if(!$expression_to_test){ |
96 | 104 | $error[]=__('Template error.','event_espresso'); |
97 | 105 | $error[]=__("%s evaluated to false, but it must be true!",'event_espresso'); |
@@ -112,7 +120,9 @@ discard block |
||
112 | 120 | * @throws EE_Error |
113 | 121 | */ |
114 | 122 | static function verify_instanceof($variable_to_test,$name_of_variable,$class_name, $allow_null = 'do_not_allow_null'){ |
115 | - if(!WP_DEBUG)return; |
|
123 | + if(!WP_DEBUG) { |
|
124 | + return; |
|
125 | + } |
|
116 | 126 | self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
117 | 127 | if($allow_null == 'allow_null' && is_null($variable_to_test)){ |
118 | 128 | return; |
@@ -137,7 +147,9 @@ discard block |
||
137 | 147 | * @throws EE_Error |
138 | 148 | */ |
139 | 149 | static function verify_is_array($variable_to_test,$variable_name,$allow_empty='allow_empty'){ |
140 | - if(!WP_DEBUG)return; |
|
150 | + if(!WP_DEBUG) { |
|
151 | + return; |
|
152 | + } |
|
141 | 153 | self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty')); |
142 | 154 | if(empty($variable_to_test) && 'allow_empty'==$allow_empty){ |
143 | 155 | return; |
@@ -164,7 +176,9 @@ discard block |
||
164 | 176 | * @throws EE_Error |
165 | 177 | */ |
166 | 178 | static function verify_argument_is_one_of($variable_to_test,$variable_name,$string_options){ |
167 | - if(!WP_DEBUG)return; |
|
179 | + if(!WP_DEBUG) { |
|
180 | + return; |
|
181 | + } |
|
168 | 182 | if(!in_array($variable_to_test,$string_options)){ |
169 | 183 | $msg[0]=__('Malconfigured template.','event_espresso'); |
170 | 184 | $msg[1]=__("Variable named '%s' was set to '%s'. It can only be one of '%s'",'event_espresso'); |
@@ -49,7 +49,6 @@ |
||
49 | 49 | * Returns whether not the remote file exists. |
50 | 50 | * Checking via GET because HEAD requests are blocked on some server configurations. |
51 | 51 | * @param string $url |
52 | - * @param boolean $sslverify whether we care if the SSL certificate for the requested site is setup properly |
|
53 | 52 | * @return boolean |
54 | 53 | */ |
55 | 54 | public static function remote_file_exists( $url, $args = array() ){ |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * EEH_URL helper |
4 | 6 | * Helper class for URL-related PHP functions |
@@ -62,7 +64,7 @@ discard block |
||
62 | 64 | isset($results['response']['code']) && |
63 | 65 | $results['response']['code'] == '200'){ |
64 | 66 | return true; |
65 | - }else{ |
|
67 | + } else{ |
|
66 | 68 | return false; |
67 | 69 | } |
68 | 70 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * ------------------------------------------------------------------------ |
11 | 11 | */ |
12 | -class EEH_URL{ |
|
12 | +class EEH_URL { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * _add_query_arg |
@@ -21,30 +21,30 @@ discard block |
||
21 | 21 | * @param bool $exclude_nonce If true then the nonce will be excluded from the generated url. |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - public static function add_query_args_and_nonce( $args = array(), $url = '', $exclude_nonce = false ) { |
|
25 | - if ( empty( $url ) ) { |
|
26 | - $user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso' ); |
|
27 | - $dev_msg = $user_msg . "\n" . sprintf( |
|
28 | - __('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso' ), |
|
24 | + public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false) { |
|
25 | + if (empty($url)) { |
|
26 | + $user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso'); |
|
27 | + $dev_msg = $user_msg."\n".sprintf( |
|
28 | + __('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso'), |
|
29 | 29 | __CLASS__ |
30 | 30 | ); |
31 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
31 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
32 | 32 | } |
33 | 33 | // check that an action exists and add nonce |
34 | - if ( ! $exclude_nonce ) { |
|
35 | - if ( isset( $args['action'] ) && ! empty( $args['action'] ) ) { |
|
36 | - $args = array_merge( $args, array( $args['action'] . '_nonce' => wp_create_nonce( $args['action'] . '_nonce' ) ) ); |
|
34 | + if ( ! $exclude_nonce) { |
|
35 | + if (isset($args['action']) && ! empty($args['action'])) { |
|
36 | + $args = array_merge($args, array($args['action'].'_nonce' => wp_create_nonce($args['action'].'_nonce'))); |
|
37 | 37 | } else { |
38 | - $args = array_merge( $args, array( 'action' => 'default', 'default_nonce' => wp_create_nonce( 'default_nonce' ) ) ); |
|
38 | + $args = array_merge($args, array('action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce'))); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | 42 | //finally, let's always add a return address (if present) :) |
43 | - $args = ! empty( $_REQUEST['action'] ) && ! isset( $_REQUEST[ 'return' ] ) |
|
44 | - ? array_merge( $args, array( 'return' => $_REQUEST['action'] ) ) |
|
43 | + $args = ! empty($_REQUEST['action']) && ! isset($_REQUEST['return']) |
|
44 | + ? array_merge($args, array('return' => $_REQUEST['action'])) |
|
45 | 45 | : $args; |
46 | 46 | |
47 | - return add_query_arg( $args, $url ); |
|
47 | + return add_query_arg($args, $url); |
|
48 | 48 | |
49 | 49 | } |
50 | 50 | |
@@ -57,17 +57,17 @@ discard block |
||
57 | 57 | * @param boolean $sslverify whether we care if the SSL certificate for the requested site is setup properly |
58 | 58 | * @return boolean |
59 | 59 | */ |
60 | - public static function remote_file_exists( $url, $args = array() ){ |
|
61 | - $results = wp_remote_request($url,array_merge( array( |
|
60 | + public static function remote_file_exists($url, $args = array()) { |
|
61 | + $results = wp_remote_request($url, array_merge(array( |
|
62 | 62 | 'method'=>'GET', |
63 | 63 | 'redirection'=>1 |
64 | - ), $args ) ); |
|
65 | - if( ! $results instanceof WP_Error && |
|
64 | + ), $args)); |
|
65 | + if ( ! $results instanceof WP_Error && |
|
66 | 66 | isset($results['response']) && |
67 | 67 | isset($results['response']['code']) && |
68 | - $results['response']['code'] == '200'){ |
|
68 | + $results['response']['code'] == '200') { |
|
69 | 69 | return true; |
70 | - }else{ |
|
70 | + } else { |
|
71 | 71 | return false; |
72 | 72 | } |
73 | 73 | } |
@@ -83,29 +83,29 @@ discard block |
||
83 | 83 | * @param bool $base_url_only - TRUE will only return the scheme and host with no other parameters |
84 | 84 | * @return string |
85 | 85 | */ |
86 | - public static function refactor_url( $url = '', $remove_query = TRUE, $base_url_only = FALSE ) { |
|
86 | + public static function refactor_url($url = '', $remove_query = TRUE, $base_url_only = FALSE) { |
|
87 | 87 | // break apart incoming URL |
88 | - $url_bits = parse_url( $url ); |
|
88 | + $url_bits = parse_url($url); |
|
89 | 89 | // HTTP or HTTPS ? |
90 | - $scheme = isset( $url_bits[ 'scheme' ] ) ? $url_bits[ 'scheme' ] . '://' : 'http://'; |
|
90 | + $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'].'://' : 'http://'; |
|
91 | 91 | // domain |
92 | - $host = isset( $url_bits[ 'host' ] ) ? $url_bits[ 'host' ] : ''; |
|
92 | + $host = isset($url_bits['host']) ? $url_bits['host'] : ''; |
|
93 | 93 | // if only the base URL is requested, then return that now |
94 | - if ( $base_url_only ) { |
|
95 | - return $scheme . $host; |
|
94 | + if ($base_url_only) { |
|
95 | + return $scheme.$host; |
|
96 | 96 | } |
97 | - $port = isset( $url_bits[ 'port' ] ) ? ':' . $url_bits[ 'port' ] : ''; |
|
98 | - $user = isset( $url_bits[ 'user' ] ) ? $url_bits[ 'user' ] : ''; |
|
99 | - $pass = isset( $url_bits[ 'pass' ] ) ? ':' . $url_bits[ 'pass' ] : ''; |
|
100 | - $pass = ( $user || $pass ) ? $pass . '@' : ''; |
|
101 | - $path = isset( $url_bits[ 'path' ] ) ? $url_bits[ 'path' ] : ''; |
|
97 | + $port = isset($url_bits['port']) ? ':'.$url_bits['port'] : ''; |
|
98 | + $user = isset($url_bits['user']) ? $url_bits['user'] : ''; |
|
99 | + $pass = isset($url_bits['pass']) ? ':'.$url_bits['pass'] : ''; |
|
100 | + $pass = ($user || $pass) ? $pass.'@' : ''; |
|
101 | + $path = isset($url_bits['path']) ? $url_bits['path'] : ''; |
|
102 | 102 | // if the query string is not required, then return what we have so far |
103 | - if ( $remove_query ) { |
|
104 | - return $scheme . $user . $pass . $host . $port . $path; |
|
103 | + if ($remove_query) { |
|
104 | + return $scheme.$user.$pass.$host.$port.$path; |
|
105 | 105 | } |
106 | - $query = isset( $url_bits[ 'query' ] ) ? '?' . $url_bits[ 'query' ] : ''; |
|
107 | - $fragment = isset( $url_bits[ 'fragment' ] ) ? '#' . $url_bits[ 'fragment' ] : ''; |
|
108 | - return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
|
106 | + $query = isset($url_bits['query']) ? '?'.$url_bits['query'] : ''; |
|
107 | + $fragment = isset($url_bits['fragment']) ? '#'.$url_bits['fragment'] : ''; |
|
108 | + return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -118,29 +118,29 @@ discard block |
||
118 | 118 | * @param bool $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will simply return the query string |
119 | 119 | * @return string|array |
120 | 120 | */ |
121 | - public static function get_query_string( $url = '', $as_array = TRUE ) { |
|
121 | + public static function get_query_string($url = '', $as_array = TRUE) { |
|
122 | 122 | // break apart incoming URL |
123 | - $url_bits = parse_url( $url ); |
|
123 | + $url_bits = parse_url($url); |
|
124 | 124 | // grab query string from URL |
125 | - $query = isset( $url_bits[ 'query' ] ) ? $url_bits[ 'query' ] : ''; |
|
125 | + $query = isset($url_bits['query']) ? $url_bits['query'] : ''; |
|
126 | 126 | // if we don't want the query string formatted into an array of key => value pairs, then just return it as is |
127 | - if ( ! $as_array ) { |
|
127 | + if ( ! $as_array) { |
|
128 | 128 | return $query; |
129 | 129 | } |
130 | 130 | // if no query string exists then just return an empty array now |
131 | - if ( empty( $query )) { |
|
131 | + if (empty($query)) { |
|
132 | 132 | return array(); |
133 | 133 | } |
134 | 134 | // empty array to hold results |
135 | 135 | $query_params = array(); |
136 | 136 | // now break apart the query string into separate params |
137 | - $query = explode( '&', $query ); |
|
137 | + $query = explode('&', $query); |
|
138 | 138 | // loop thru our query params |
139 | - foreach ( $query as $query_args ) { |
|
139 | + foreach ($query as $query_args) { |
|
140 | 140 | // break apart the key value pairs |
141 | - $query_args = explode( '=', $query_args ); |
|
141 | + $query_args = explode('=', $query_args); |
|
142 | 142 | // and add to our results array |
143 | - $query_params[ $query_args[0] ] = $query_args[1]; |
|
143 | + $query_params[$query_args[0]] = $query_args[1]; |
|
144 | 144 | } |
145 | 145 | return $query_params; |
146 | 146 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * prevent_prefetching |
152 | 152 | * @return void |
153 | 153 | */ |
154 | - public static function prevent_prefetching(){ |
|
154 | + public static function prevent_prefetching() { |
|
155 | 155 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
156 | 156 | remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
157 | 157 | } |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | * @param string $prefix Use this to prefix the string with something. |
167 | 167 | * @return string |
168 | 168 | */ |
169 | - public static function generate_unique_token( $prefix = '' ) { |
|
170 | - $token = md5( uniqid() . mt_rand() ); |
|
171 | - return $prefix ? $prefix . '_' . $token : $token; |
|
169 | + public static function generate_unique_token($prefix = '') { |
|
170 | + $token = md5(uniqid().mt_rand()); |
|
171 | + return $prefix ? $prefix.'_'.$token : $token; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * add_nocache_headers |
178 | 178 | * @return void |
179 | 179 | */ |
180 | - public static function add_nocache_headers(){ |
|
180 | + public static function add_nocache_headers() { |
|
181 | 181 | // add no cache headers |
182 | 182 | // add_action( 'wp_head' , array( 'EED_Single_Page_Checkout', 'nocache_headers' ), 10 ); |
183 | 183 | // plus a little extra for nginx |
@@ -194,19 +194,19 @@ discard block |
||
194 | 194 | * @param string $server_variable |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - public static function filter_input_server_url( $server_variable = 'REQUEST_URI' ){ |
|
197 | + public static function filter_input_server_url($server_variable = 'REQUEST_URI') { |
|
198 | 198 | $URL = ''; |
199 | 199 | $server_variables = array( |
200 | 200 | 'REQUEST_URI' => 1, |
201 | 201 | 'HTTP_HOST' => 1, |
202 | 202 | 'PHP_SELF' => 1, |
203 | 203 | ); |
204 | - $server_variable = strtoupper( $server_variable ); |
|
204 | + $server_variable = strtoupper($server_variable); |
|
205 | 205 | // whitelist INPUT_SERVER var |
206 | - if ( isset( $server_variables[ $server_variable ] ) ) { |
|
207 | - $URL = filter_input( INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE ); |
|
208 | - if ( empty( $URL ) ) { |
|
209 | - $URL = esc_url( $_SERVER[ $server_variable ] ); |
|
206 | + if (isset($server_variables[$server_variable])) { |
|
207 | + $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE); |
|
208 | + if (empty($URL)) { |
|
209 | + $URL = esc_url($_SERVER[$server_variable]); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | return $URL; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | /** |
187 | 187 | * _prep_name_for_html_id |
188 | - * @param $name |
|
188 | + * @param string $name |
|
189 | 189 | * @return string |
190 | 190 | */ |
191 | 191 | private function _prep_name_for_html_id( $name ) { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | |
233 | 233 | /** |
234 | - * @param mixed $html_class |
|
234 | + * @param string $html_class |
|
235 | 235 | */ |
236 | 236 | public function set_html_class( $html_class ) { |
237 | 237 | $this->_html_class = $html_class; |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * Event Espresso |
@@ -69,7 +70,7 @@ discard block |
||
69 | 70 | $default_address .= $state ? $state->name() . '<br />' : ''; |
70 | 71 | $default_address .= $country ? $country->name(). '<br />' : ''; |
71 | 72 | $default_address .= $organization->zip != '' ? $organization->get_pretty( 'zip' ) : ''; |
72 | - }else{ |
|
73 | + } else{ |
|
73 | 74 | $default_address = 'unknown'; |
74 | 75 | $organization_name = 'unknown'; |
75 | 76 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | * @type $name string the name for this form section, if you want to explicitly define it |
96 | 96 | * } |
97 | 97 | */ |
98 | - function __construct( $options_array = array() ) { |
|
98 | + function __construct($options_array = array()) { |
|
99 | 99 | // used by display strategies |
100 | 100 | EE_Registry::instance()->load_helper('HTML'); |
101 | 101 | // assign incoming values to properties |
102 | - foreach( $options_array as $key => $value ) { |
|
103 | - $key = '_' . $key; |
|
104 | - if ( property_exists( $this, $key ) && empty( $this->{$key} )) { |
|
102 | + foreach ($options_array as $key => $value) { |
|
103 | + $key = '_'.$key; |
|
104 | + if (property_exists($this, $key) && empty($this->{$key} )) { |
|
105 | 105 | $this->{$key} = $value; |
106 | 106 | } |
107 | 107 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param $parent_form_section |
114 | 114 | * @param $name |
115 | 115 | */ |
116 | - protected function _construct_finalize( $parent_form_section, $name ){ |
|
116 | + protected function _construct_finalize($parent_form_section, $name) { |
|
117 | 117 | $this->_construction_finalized = TRUE; |
118 | 118 | $this->_parent_section = $parent_form_section; |
119 | 119 | $this->_name = $name; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | /** |
135 | 135 | * @param string $action |
136 | 136 | */ |
137 | - public function set_action( $action ) { |
|
137 | + public function set_action($action) { |
|
138 | 138 | $this->_action = $action; |
139 | 139 | } |
140 | 140 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return string |
145 | 145 | */ |
146 | 146 | public function method() { |
147 | - return ! empty( $this->_method ) ? $this->_method : 'POST'; |
|
147 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | /** |
153 | 153 | * @param string $method |
154 | 154 | */ |
155 | - public function set_method( $method ) { |
|
156 | - switch ( $method ) { |
|
155 | + public function set_method($method) { |
|
156 | + switch ($method) { |
|
157 | 157 | case 'get' : |
158 | 158 | case 'GET' : |
159 | 159 | $this->_method = 'GET'; |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | * Calculation involves using the name and the parent's html id |
172 | 172 | * return void |
173 | 173 | */ |
174 | - protected function _set_default_html_id_if_empty(){ |
|
175 | - if( ! $this->_html_id ){ |
|
176 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
|
177 | - $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
|
178 | - }else{ |
|
179 | - $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
|
174 | + protected function _set_default_html_id_if_empty() { |
|
175 | + if ( ! $this->_html_id) { |
|
176 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
177 | + $this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name()); |
|
178 | + } else { |
|
179 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | * @param $name |
189 | 189 | * @return string |
190 | 190 | */ |
191 | - private function _prep_name_for_html_id( $name ) { |
|
192 | - return sanitize_key( str_replace( array( ' ', ' ', '_' ), '-', $name )); |
|
191 | + private function _prep_name_for_html_id($name) { |
|
192 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | * @param bool $add_pound_sign |
207 | 207 | * @return string |
208 | 208 | */ |
209 | - public function html_id( $add_pound_sign = FALSE ){ |
|
210 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
209 | + public function html_id($add_pound_sign = FALSE) { |
|
210 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | /** |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public function html_class(){ |
|
218 | + public function html_class() { |
|
219 | 219 | return $this->_html_class; |
220 | 220 | } |
221 | 221 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | /** |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - public function html_style(){ |
|
227 | + public function html_style() { |
|
228 | 228 | return $this->_html_style; |
229 | 229 | } |
230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * @param mixed $html_class |
235 | 235 | */ |
236 | - public function set_html_class( $html_class ) { |
|
236 | + public function set_html_class($html_class) { |
|
237 | 237 | $this->_html_class = $html_class; |
238 | 238 | } |
239 | 239 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | /** |
243 | 243 | * @param mixed $html_id |
244 | 244 | */ |
245 | - public function set_html_id( $html_id ) { |
|
245 | + public function set_html_id($html_id) { |
|
246 | 246 | $this->_html_id = $html_id; |
247 | 247 | } |
248 | 248 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | /** |
252 | 252 | * @param mixed $html_style |
253 | 253 | */ |
254 | - public function set_html_style( $html_style ) { |
|
254 | + public function set_html_style($html_style) { |
|
255 | 255 | $this->_html_style = $html_style; |
256 | 256 | } |
257 | 257 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | /** |
261 | 261 | * @param string $other_html_attributes |
262 | 262 | */ |
263 | - public function set_other_html_attributes( $other_html_attributes ) { |
|
263 | + public function set_other_html_attributes($other_html_attributes) { |
|
264 | 264 | $this->_other_html_attributes = $other_html_attributes; |
265 | 265 | } |
266 | 266 | |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * @throws EE_Error |
281 | 281 | * @return string |
282 | 282 | */ |
283 | - function name(){ |
|
284 | - if( ! $this->_construction_finalized ){ |
|
285 | - 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) ) ); |
|
283 | + function name() { |
|
284 | + if ( ! $this->_construction_finalized) { |
|
285 | + 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))); |
|
286 | 286 | } |
287 | 287 | return $this->_name; |
288 | 288 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * Gets the parent section |
294 | 294 | * @return EE_Form_Section_Proper |
295 | 295 | */ |
296 | - function parent_section(){ |
|
296 | + function parent_section() { |
|
297 | 297 | return $this->_parent_section; |
298 | 298 | } |
299 | 299 | |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
307 | 307 | * @return string |
308 | 308 | */ |
309 | - public function form_open( $action = '', $method = '', $other_attributes = '' ) { |
|
310 | - if ( ! empty( $action )) { |
|
311 | - $this->set_action( $action ); |
|
309 | + public function form_open($action = '', $method = '', $other_attributes = '') { |
|
310 | + if ( ! empty($action)) { |
|
311 | + $this->set_action($action); |
|
312 | 312 | } |
313 | - if ( ! empty( $method )) { |
|
314 | - $this->set_method( $method ); |
|
313 | + if ( ! empty($method)) { |
|
314 | + $this->set_method($method); |
|
315 | 315 | } |
316 | - $html = EEH_HTML::nl( 1, 'form' ) . '<form'; |
|
317 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
318 | - $html .= ' action="' . $this->action() . '"'; |
|
319 | - $html .= ' method="' . $this->method() . '"'; |
|
320 | - $html .= $other_attributes . '>'; |
|
316 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
317 | + $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : ''; |
|
318 | + $html .= ' action="'.$this->action().'"'; |
|
319 | + $html .= ' method="'.$this->method().'"'; |
|
320 | + $html .= $other_attributes.'>'; |
|
321 | 321 | return $html; |
322 | 322 | } |
323 | 323 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return string |
329 | 329 | */ |
330 | 330 | public function form_close() { |
331 | - return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl(); |
|
331 | + return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl(); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 |
@@ -348,6 +348,7 @@ |
||
348 | 348 | * Automatically finds the related model info from the form, if present, and |
349 | 349 | * save the relations indicated |
350 | 350 | * @type string $relation_name |
351 | + * @param integer $relation_name |
|
351 | 352 | * @return bool |
352 | 353 | * @throws EE_Error |
353 | 354 | */ |
@@ -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); |
@@ -244,21 +244,21 @@ discard block |
||
244 | 244 | * @param EE_Base_Class $model_obj |
245 | 245 | * @return void |
246 | 246 | */ |
247 | - public function populate_model_obj($model_obj){ |
|
247 | + public function populate_model_obj($model_obj) { |
|
248 | 248 | $model_obj = $this->_model->ensure_is_obj($model_obj); |
249 | 249 | $this->_model_object = $model_obj; |
250 | 250 | $defaults = $model_obj->model_field_array(); |
251 | - foreach($this->_model->relation_settings() as $relation_name => $relation_obj){ |
|
251 | + foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) { |
|
252 | 252 | $form_inputs = $this->inputs(); |
253 | - if(isset($form_inputs[$relation_name])){ |
|
254 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
253 | + if (isset($form_inputs[$relation_name])) { |
|
254 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
255 | 255 | //then we only expect there to be one |
256 | 256 | $related_item = $this->_model_object->get_first_related($relation_name); |
257 | 257 | $defaults[$relation_name] = $related_item->ID(); |
258 | - }else{ |
|
258 | + } else { |
|
259 | 259 | $related_items = $this->_model_object->get_many_related($relation_name); |
260 | 260 | $ids = array(); |
261 | - foreach($related_items as $related_item){ |
|
261 | + foreach ($related_items as $related_item) { |
|
262 | 262 | $ids[] = $related_item->ID(); |
263 | 263 | } |
264 | 264 | $defaults[$relation_name] = $ids; |
@@ -275,8 +275,8 @@ discard block |
||
275 | 275 | * values are their normalized values |
276 | 276 | * @return array |
277 | 277 | */ |
278 | - public function inputs_values_corresponding_to_model_fields(){ |
|
279 | - return array_intersect_key($this->input_values(),$this->_model->field_settings()); |
|
278 | + public function inputs_values_corresponding_to_model_fields() { |
|
279 | + return array_intersect_key($this->input_values(), $this->_model->field_settings()); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | |
@@ -299,21 +299,21 @@ discard block |
||
299 | 299 | public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
300 | 300 | parent::receive_form_submission($req_data, $validate); |
301 | 301 | //create or set the model object, if it isn't already |
302 | - if( ! $this->_model_object ){ |
|
302 | + if ( ! $this->_model_object) { |
|
303 | 303 | //check to see if the form indicates a PK, in which case we want to only retrieve it and update it |
304 | 304 | $pk_name = $this->_model->primary_key_name(); |
305 | 305 | $model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name)); |
306 | - if($model_obj){ |
|
306 | + if ($model_obj) { |
|
307 | 307 | $this->_model_object = $model_obj; |
308 | - }else{ |
|
309 | - $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name() ); |
|
308 | + } else { |
|
309 | + $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name()); |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | //ok so the model object is set. Just set it with the submitted form data (don't save yet though) |
313 | - foreach($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value){ |
|
313 | + foreach ($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value) { |
|
314 | 314 | //only set the non-primary key |
315 | - if($field_name != $this->_model->primary_key_name()){ |
|
316 | - $this->_model_object->set($field_name,$field_value); |
|
315 | + if ($field_name != $this->_model->primary_key_name()) { |
|
316 | + $this->_model_object->set($field_name, $field_value); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | * @return int, 1 on a successful update, the ID of |
330 | 330 | * the new entry on insert; 0 on failure |
331 | 331 | */ |
332 | - public function save(){ |
|
333 | - if( ! $this->_model_object){ |
|
334 | - 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))); |
|
332 | + public function save() { |
|
333 | + if ( ! $this->_model_object) { |
|
334 | + 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))); |
|
335 | 335 | } |
336 | - $success = $this->_model_object->save(); |
|
337 | - foreach($this->_model->relation_settings() as $relation_name => $relation_obj){ |
|
338 | - if(isset($this->_subsections[$relation_name])){ |
|
336 | + $success = $this->_model_object->save(); |
|
337 | + foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) { |
|
338 | + if (isset($this->_subsections[$relation_name])) { |
|
339 | 339 | $success = $this->_save_related_info($relation_name); |
340 | 340 | } |
341 | 341 | } |
@@ -351,29 +351,29 @@ discard block |
||
351 | 351 | * @return bool |
352 | 352 | * @throws EE_Error |
353 | 353 | */ |
354 | - protected function _save_related_info($relation_name){ |
|
354 | + protected function _save_related_info($relation_name) { |
|
355 | 355 | $relation_obj = $this->_model->related_settings_for($relation_name); |
356 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
356 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
357 | 357 | //there is just a foreign key on this model pointing to that one |
358 | 358 | $this->_model_object->_add_relation_to($this->get_input_value($relation_name), $relation_name); |
359 | - }elseif($relation_obj instanceof EE_Has_Many_Relation){ |
|
359 | + }elseif ($relation_obj instanceof EE_Has_Many_Relation) { |
|
360 | 360 | //then we want to consider all of its currently-related things. |
361 | 361 | //if they're in this list, keep them |
362 | 362 | //if they're not in this list, remove them |
363 | 363 | //and lastly add all the new items |
364 | 364 | throw new EE_Error(sprintf(__('Automatic saving of related info across a "has many" relation is not yet supported', "event_espresso"))); |
365 | - }elseif($relation_obj instanceof EE_HABTM_Relation){ |
|
365 | + }elseif ($relation_obj instanceof EE_HABTM_Relation) { |
|
366 | 366 | //delete everything NOT in this list |
367 | 367 | $normalized_input_value = $this->get_input_value($relation_name); |
368 | - if($normalized_input_value && is_array($normalized_input_value)){ |
|
368 | + if ($normalized_input_value && is_array($normalized_input_value)) { |
|
369 | 369 | $where_query_params = array( |
370 | - $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN',$normalized_input_value)); |
|
371 | - }else{ |
|
370 | + $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN', $normalized_input_value)); |
|
371 | + } else { |
|
372 | 372 | $where_query_params = array(); |
373 | 373 | } |
374 | - $this->_model_object->_remove_relations( $relation_name, $where_query_params ); |
|
375 | - foreach($normalized_input_value as $id){ |
|
376 | - $this->_model_object->_add_relation_to( $id, $relation_name ); |
|
374 | + $this->_model_object->_remove_relations($relation_name, $where_query_params); |
|
375 | + foreach ($normalized_input_value as $id) { |
|
376 | + $this->_model_object->_add_relation_to($id, $relation_name); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | return TRUE; |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | * Gets the model of this model form |
386 | 386 | * @return EEM_Base |
387 | 387 | */ |
388 | - public function get_model(){ |
|
388 | + public function get_model() { |
|
389 | 389 | return $this->_model; |
390 | 390 | } |
391 | 391 | |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * when receive_form_submission($req_data) was called. |
399 | 399 | * @return EE_Base_Class |
400 | 400 | */ |
401 | - public function get_model_object(){ |
|
401 | + public function get_model_object() { |
|
402 | 402 | return $this->_model_object; |
403 | 403 | } |
404 | 404 | |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | * gets teh default name of this form section if none is specified |
409 | 409 | * @return string |
410 | 410 | */ |
411 | - protected function _set_default_name_if_empty(){ |
|
412 | - if( ! $this->_name ){ |
|
413 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
414 | - $this->_name = $default_name; |
|
411 | + protected function _set_default_name_if_empty() { |
|
412 | + if ( ! $this->_name) { |
|
413 | + $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form"; |
|
414 | + $this->_name = $default_name; |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 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 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | if(isset($subsection_args[$relation_name]) && |
102 | 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 | 107 | $input = new EE_Select_Multi_Model_Input($model_objects,$input_constructor_args); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $models_pointed_to = $model_field instanceof EE_Field_With_Model_Name ? $model_field->get_model_class_names_pointed_to() : array(); |
164 | 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); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | //then we only expect there to be one |
256 | 256 | $related_item = $this->_model_object->get_first_related($relation_name); |
257 | 257 | $defaults[$relation_name] = $related_item->ID(); |
258 | - }else{ |
|
258 | + } else{ |
|
259 | 259 | $related_items = $this->_model_object->get_many_related($relation_name); |
260 | 260 | $ids = array(); |
261 | 261 | foreach($related_items as $related_item){ |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name)); |
306 | 306 | if($model_obj){ |
307 | 307 | $this->_model_object = $model_obj; |
308 | - }else{ |
|
308 | + } else{ |
|
309 | 309 | $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name() ); |
310 | 310 | } |
311 | 311 | } |
@@ -356,19 +356,19 @@ discard block |
||
356 | 356 | if($relation_obj instanceof EE_Belongs_To_Relation){ |
357 | 357 | //there is just a foreign key on this model pointing to that one |
358 | 358 | $this->_model_object->_add_relation_to($this->get_input_value($relation_name), $relation_name); |
359 | - }elseif($relation_obj instanceof EE_Has_Many_Relation){ |
|
359 | + } elseif($relation_obj instanceof EE_Has_Many_Relation){ |
|
360 | 360 | //then we want to consider all of its currently-related things. |
361 | 361 | //if they're in this list, keep them |
362 | 362 | //if they're not in this list, remove them |
363 | 363 | //and lastly add all the new items |
364 | 364 | throw new EE_Error(sprintf(__('Automatic saving of related info across a "has many" relation is not yet supported', "event_espresso"))); |
365 | - }elseif($relation_obj instanceof EE_HABTM_Relation){ |
|
365 | + } elseif($relation_obj instanceof EE_HABTM_Relation){ |
|
366 | 366 | //delete everything NOT in this list |
367 | 367 | $normalized_input_value = $this->get_input_value($relation_name); |
368 | 368 | if($normalized_input_value && is_array($normalized_input_value)){ |
369 | 369 | $where_query_params = array( |
370 | 370 | $relation_obj->get_other_model()->primary_key_name() => array('NOT_IN',$normalized_input_value)); |
371 | - }else{ |
|
371 | + } else{ |
|
372 | 372 | $where_query_params = array(); |
373 | 373 | } |
374 | 374 | $this->_model_object->_remove_relations( $relation_name, $where_query_params ); |