@@ -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, |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | * @param \EE_Encryption $encryption |
128 | 128 | * @return EE_Session |
129 | 129 | */ |
130 | - public static function instance( EE_Encryption $encryption = null ) { |
|
130 | + public static function instance(EE_Encryption $encryption = null) { |
|
131 | 131 | // check if class object is instantiated |
132 | 132 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: |
133 | 133 | // add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
134 | - if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
135 | - self::$_instance = new self( $encryption ); |
|
134 | + if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) { |
|
135 | + self::$_instance = new self($encryption); |
|
136 | 136 | } |
137 | 137 | return self::$_instance; |
138 | 138 | } |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | * @access protected |
146 | 146 | * @param \EE_Encryption $encryption |
147 | 147 | */ |
148 | - protected function __construct( EE_Encryption $encryption = null ) { |
|
148 | + protected function __construct(EE_Encryption $encryption = null) { |
|
149 | 149 | |
150 | 150 | // 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' ); |
151 | - if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) { |
|
151 | + if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) { |
|
152 | 152 | return NULL; |
153 | 153 | } |
154 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
155 | - if ( ! defined( 'ESPRESSO_SESSION' ) ) { |
|
156 | - define( 'ESPRESSO_SESSION', true ); |
|
154 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
155 | + if ( ! defined('ESPRESSO_SESSION')) { |
|
156 | + define('ESPRESSO_SESSION', true); |
|
157 | 157 | } |
158 | 158 | // default session lifespan in seconds |
159 | 159 | $this->_lifespan = apply_filters( |
@@ -167,35 +167,35 @@ discard block |
||
167 | 167 | * } |
168 | 168 | */ |
169 | 169 | // retrieve session options from db |
170 | - $session_settings = get_option( 'ee_session_settings' ); |
|
171 | - if ( $session_settings !== FALSE ) { |
|
170 | + $session_settings = get_option('ee_session_settings'); |
|
171 | + if ($session_settings !== FALSE) { |
|
172 | 172 | // cycle though existing session options |
173 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
173 | + foreach ($session_settings as $var_name => $session_setting) { |
|
174 | 174 | // set values for class properties |
175 | - $var_name = '_' . $var_name; |
|
175 | + $var_name = '_'.$var_name; |
|
176 | 176 | $this->{$var_name} = $session_setting; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | // are we using encryption? |
180 | - if ( $this->_use_encryption && $encryption instanceof EE_Encryption ) { |
|
180 | + if ($this->_use_encryption && $encryption instanceof EE_Encryption) { |
|
181 | 181 | // encrypt data via: $this->encryption->encrypt(); |
182 | 182 | $this->encryption = $encryption; |
183 | 183 | } |
184 | 184 | // filter hook allows outside functions/classes/plugins to change default empty cart |
185 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
186 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
185 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
186 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
187 | 187 | // apply default session vars |
188 | 188 | $this->_set_defaults(); |
189 | 189 | // check for existing session and retrieve it from db |
190 | - if ( ! $this->_espresso_session() ) { |
|
190 | + if ( ! $this->_espresso_session()) { |
|
191 | 191 | // or just start a new one |
192 | 192 | $this->_create_espresso_session(); |
193 | 193 | } |
194 | 194 | // check request for 'clear_session' param |
195 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
195 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
196 | 196 | // once everything is all said and done, |
197 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
198 | - add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 ); |
|
197 | + add_action('shutdown', array($this, 'update'), 100); |
|
198 | + add_action('shutdown', array($this, 'garbage_collection'), 999); |
|
199 | 199 | |
200 | 200 | } |
201 | 201 | |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | */ |
228 | 228 | private function _set_defaults() { |
229 | 229 | // set some defaults |
230 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
231 | - if ( is_array( $default_var )) { |
|
232 | - $this->_session_data[ $key ] = array(); |
|
230 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
231 | + if (is_array($default_var)) { |
|
232 | + $this->_session_data[$key] = array(); |
|
233 | 233 | } else { |
234 | - $this->_session_data[ $key ] = ''; |
|
234 | + $this->_session_data[$key] = ''; |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @param \EE_Cart $cart |
254 | 254 | * @return bool |
255 | 255 | */ |
256 | - public function set_cart( EE_Cart $cart ) { |
|
256 | + public function set_cart(EE_Cart $cart) { |
|
257 | 257 | $this->_session_data['cart'] = $cart; |
258 | 258 | return TRUE; |
259 | 259 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return \EE_Cart |
274 | 274 | */ |
275 | 275 | public function cart() { |
276 | - return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL; |
|
276 | + return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param \EE_Checkout $checkout |
283 | 283 | * @return bool |
284 | 284 | */ |
285 | - public function set_checkout( EE_Checkout $checkout ) { |
|
285 | + public function set_checkout(EE_Checkout $checkout) { |
|
286 | 286 | $this->_session_data['checkout'] = $checkout; |
287 | 287 | return TRUE; |
288 | 288 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return \EE_Checkout |
303 | 303 | */ |
304 | 304 | public function checkout() { |
305 | - return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL; |
|
305 | + return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @param \EE_Transaction $transaction |
312 | 312 | * @return bool |
313 | 313 | */ |
314 | - public function set_transaction( EE_Transaction $transaction ) { |
|
314 | + public function set_transaction(EE_Transaction $transaction) { |
|
315 | 315 | // first remove the session from the transaction before we save the transaction in the session |
316 | - $transaction->set_txn_session_data( NULL ); |
|
316 | + $transaction->set_txn_session_data(NULL); |
|
317 | 317 | $this->_session_data['transaction'] = $transaction; |
318 | 318 | return TRUE; |
319 | 319 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @return \EE_Transaction |
334 | 334 | */ |
335 | 335 | public function transaction() { |
336 | - return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL; |
|
336 | + return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
@@ -345,15 +345,15 @@ discard block |
||
345 | 345 | * @param bool $reset_cache |
346 | 346 | * @return array |
347 | 347 | */ |
348 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
349 | - if ( $reset_cache ) { |
|
348 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
349 | + if ($reset_cache) { |
|
350 | 350 | $this->reset_cart(); |
351 | 351 | $this->reset_checkout(); |
352 | 352 | $this->reset_transaction(); |
353 | 353 | } |
354 | - if ( ! empty( $key )) { |
|
355 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
356 | - } else { |
|
354 | + if ( ! empty($key)) { |
|
355 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
356 | + } else { |
|
357 | 357 | return $this->_session_data; |
358 | 358 | } |
359 | 359 | } |
@@ -366,20 +366,20 @@ discard block |
||
366 | 366 | * @param array $data |
367 | 367 | * @return TRUE on success, FALSE on fail |
368 | 368 | */ |
369 | - public function set_session_data( $data ) { |
|
369 | + public function set_session_data($data) { |
|
370 | 370 | |
371 | 371 | // nothing ??? bad data ??? go home! |
372 | - if ( empty( $data ) || ! is_array( $data )) { |
|
373 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
372 | + if (empty($data) || ! is_array($data)) { |
|
373 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
374 | 374 | return FALSE; |
375 | 375 | } |
376 | 376 | |
377 | - foreach ( $data as $key =>$value ) { |
|
378 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
379 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
377 | + foreach ($data as $key =>$value) { |
|
378 | + if (isset($this->_default_session_vars[$key])) { |
|
379 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
380 | 380 | return FALSE; |
381 | 381 | } else { |
382 | - $this->_session_data[ $key ] = $value; |
|
382 | + $this->_session_data[$key] = $value; |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | * @throws \EE_Error |
397 | 397 | */ |
398 | 398 | private function _espresso_session() { |
399 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
399 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
400 | 400 | // check that session has started |
401 | - if ( session_id() === '' ) { |
|
401 | + if (session_id() === '') { |
|
402 | 402 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
403 | 403 | session_start(); |
404 | 404 | } |
@@ -407,57 +407,57 @@ discard block |
||
407 | 407 | // and the visitors IP |
408 | 408 | $this->_ip_address = $this->_visitor_ip(); |
409 | 409 | // set the "user agent" |
410 | - $this->_user_agent = ( isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
410 | + $this->_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
411 | 411 | // now let's retrieve what's in the db |
412 | 412 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
413 | - $session_data = get_transient( EE_Session::session_id_prefix . $this->_sid ); |
|
414 | - if ( $session_data ) { |
|
415 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
416 | - $hash_check = get_transient( EE_Session::hash_check_prefix . $this->_sid ); |
|
417 | - if ( $hash_check && $hash_check !== md5( $session_data ) ) { |
|
413 | + $session_data = get_transient(EE_Session::session_id_prefix.$this->_sid); |
|
414 | + if ($session_data) { |
|
415 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
416 | + $hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid); |
|
417 | + if ($hash_check && $hash_check !== md5($session_data)) { |
|
418 | 418 | EE_Error::add_error( |
419 | 419 | sprintf( |
420 | - __( 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso' ), |
|
421 | - EE_Session::session_id_prefix . $this->_sid |
|
420 | + __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'), |
|
421 | + EE_Session::session_id_prefix.$this->_sid |
|
422 | 422 | ), |
423 | 423 | __FILE__, __FUNCTION__, __LINE__ |
424 | 424 | ); |
425 | 425 | } |
426 | 426 | } |
427 | 427 | // un-encrypt the data |
428 | - $session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data; |
|
428 | + $session_data = $this->_use_encryption ? $this->encryption->decrypt($session_data) : $session_data; |
|
429 | 429 | // unserialize |
430 | - $session_data = maybe_unserialize( $session_data ); |
|
430 | + $session_data = maybe_unserialize($session_data); |
|
431 | 431 | // just a check to make sure the session array is indeed an array |
432 | - if ( ! is_array( $session_data ) ) { |
|
432 | + if ( ! is_array($session_data)) { |
|
433 | 433 | // no?!?! then something is wrong |
434 | 434 | return FALSE; |
435 | 435 | } |
436 | 436 | // get the current time in UTC |
437 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
437 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
438 | 438 | // and reset the session expiration |
439 | - $this->_expiration = isset( $session_data['expiration'] ) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
439 | + $this->_expiration = isset($session_data['expiration']) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
440 | 440 | |
441 | 441 | } else { |
442 | 442 | // set initial site access time and the session expiration |
443 | 443 | $this->_set_init_access_and_expiration(); |
444 | 444 | // set referer |
445 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) ? esc_attr( $_SERVER['HTTP_REFERER'] ) : ''; |
|
445 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) ? esc_attr($_SERVER['HTTP_REFERER']) : ''; |
|
446 | 446 | // no previous session = go back and create one (on top of the data above) |
447 | 447 | return FALSE; |
448 | 448 | } |
449 | 449 | // now the user agent |
450 | - if ( $session_data['user_agent'] != $this->_user_agent ) { |
|
450 | + if ($session_data['user_agent'] != $this->_user_agent) { |
|
451 | 451 | return FALSE; |
452 | 452 | } |
453 | 453 | // wait a minute... how old are you? |
454 | - if ( $this->_time > $this->_expiration ) { |
|
454 | + if ($this->_time > $this->_expiration) { |
|
455 | 455 | // yer too old fer me! |
456 | 456 | // wipe out everything that isn't a default session datum |
457 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
457 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
458 | 458 | } |
459 | 459 | // make event espresso session data available to plugin |
460 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
460 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
461 | 461 | return TRUE; |
462 | 462 | |
463 | 463 | } |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | */ |
476 | 476 | protected function _generate_session_id() { |
477 | 477 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
478 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
479 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
478 | + if (isset($_REQUEST['EESID'])) { |
|
479 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
480 | 480 | } else { |
481 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
481 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
482 | 482 | } |
483 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
483 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | |
@@ -492,20 +492,20 @@ discard block |
||
492 | 492 | */ |
493 | 493 | protected function _get_sid_salt() { |
494 | 494 | // was session id salt already saved to db ? |
495 | - if ( empty( $this->_sid_salt ) ) { |
|
495 | + if (empty($this->_sid_salt)) { |
|
496 | 496 | // no? then maybe use WP defined constant |
497 | - if ( defined( 'AUTH_SALT' ) ) { |
|
497 | + if (defined('AUTH_SALT')) { |
|
498 | 498 | $this->_sid_salt = AUTH_SALT; |
499 | 499 | } |
500 | 500 | // if salt doesn't exist or is too short |
501 | - if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) { |
|
501 | + if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) { |
|
502 | 502 | // create a new one |
503 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
503 | + $this->_sid_salt = wp_generate_password(64); |
|
504 | 504 | } |
505 | 505 | // and save it as a permanent session setting |
506 | - $session_settings = get_option( 'ee_session_settings' ); |
|
507 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
508 | - update_option( 'ee_session_settings', $session_settings ); |
|
506 | + $session_settings = get_option('ee_session_settings'); |
|
507 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
508 | + update_option('ee_session_settings', $session_settings); |
|
509 | 509 | } |
510 | 510 | return $this->_sid_salt; |
511 | 511 | } |
@@ -533,19 +533,19 @@ discard block |
||
533 | 533 | * @param bool $new_session |
534 | 534 | * @return TRUE on success, FALSE on fail |
535 | 535 | */ |
536 | - public function update( $new_session = FALSE ) { |
|
537 | - $this->_session_data = isset( $this->_session_data ) |
|
538 | - && is_array( $this->_session_data ) |
|
539 | - && isset( $this->_session_data['id']) |
|
536 | + public function update($new_session = FALSE) { |
|
537 | + $this->_session_data = isset($this->_session_data) |
|
538 | + && is_array($this->_session_data) |
|
539 | + && isset($this->_session_data['id']) |
|
540 | 540 | ? $this->_session_data |
541 | 541 | : NULL; |
542 | - if ( empty( $this->_session_data )) { |
|
542 | + if (empty($this->_session_data)) { |
|
543 | 543 | $this->_set_defaults(); |
544 | 544 | } |
545 | 545 | $session_data = array(); |
546 | - foreach ( $this->_session_data as $key => $value ) { |
|
546 | + foreach ($this->_session_data as $key => $value) { |
|
547 | 547 | |
548 | - switch( $key ) { |
|
548 | + switch ($key) { |
|
549 | 549 | |
550 | 550 | case 'id' : |
551 | 551 | // session ID |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | break; |
564 | 564 | |
565 | 565 | case 'init_access' : |
566 | - $session_data['init_access'] = absint( $value ); |
|
566 | + $session_data['init_access'] = absint($value); |
|
567 | 567 | break; |
568 | 568 | |
569 | 569 | case 'last_access' : |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | |
574 | 574 | case 'expiration' : |
575 | 575 | // when the session expires |
576 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
576 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
577 | 577 | ? $this->_expiration |
578 | 578 | : $session_data['init_access'] + $this->_lifespan; |
579 | 579 | break; |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | |
586 | 586 | case 'pages_visited' : |
587 | 587 | $page_visit = $this->_get_page_visit(); |
588 | - if ( $page_visit ) { |
|
588 | + if ($page_visit) { |
|
589 | 589 | // set pages visited where the first will be the http referrer |
590 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
590 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
591 | 591 | // we'll only save the last 10 page visits. |
592 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
592 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
593 | 593 | } |
594 | 594 | break; |
595 | 595 | |
@@ -603,9 +603,9 @@ discard block |
||
603 | 603 | |
604 | 604 | $this->_session_data = $session_data; |
605 | 605 | // creating a new session does not require saving to the db just yet |
606 | - if ( ! $new_session ) { |
|
606 | + if ( ! $new_session) { |
|
607 | 607 | // ready? let's save |
608 | - if ( $this->_save_session_to_db() ) { |
|
608 | + if ($this->_save_session_to_db()) { |
|
609 | 609 | return TRUE; |
610 | 610 | } else { |
611 | 611 | return FALSE; |
@@ -626,9 +626,9 @@ discard block |
||
626 | 626 | * @return bool |
627 | 627 | */ |
628 | 628 | private function _create_espresso_session( ) { |
629 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
629 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
630 | 630 | // use the update function for now with $new_session arg set to TRUE |
631 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
631 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | |
@@ -652,15 +652,15 @@ discard block |
||
652 | 652 | return FALSE; |
653 | 653 | } |
654 | 654 | // first serialize all of our session data |
655 | - $session_data = serialize( $this->_session_data ); |
|
655 | + $session_data = serialize($this->_session_data); |
|
656 | 656 | // encrypt it if we are using encryption |
657 | - $session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data; |
|
657 | + $session_data = $this->_use_encryption ? $this->encryption->encrypt($session_data) : $session_data; |
|
658 | 658 | // maybe save hash check |
659 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
660 | - set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan ); |
|
659 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
660 | + set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan); |
|
661 | 661 | } |
662 | 662 | // we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient( transient ID, data, expiry ) |
663 | - return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan ); |
|
663 | + return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | |
@@ -686,10 +686,10 @@ discard block |
||
686 | 686 | 'HTTP_FORWARDED', |
687 | 687 | 'REMOTE_ADDR' |
688 | 688 | ); |
689 | - foreach ( $server_keys as $key ){ |
|
690 | - if ( isset( $_SERVER[ $key ] )) { |
|
691 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
692 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
689 | + foreach ($server_keys as $key) { |
|
690 | + if (isset($_SERVER[$key])) { |
|
691 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
692 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
693 | 693 | $visitor_ip = $ip; |
694 | 694 | } |
695 | 695 | } |
@@ -710,45 +710,45 @@ discard block |
||
710 | 710 | public function _get_page_visit() { |
711 | 711 | |
712 | 712 | // echo '<h3>'. __CLASS__ .'->'.__FUNCTION__.' ( line no: ' . __LINE__ . ' )</h3>'; |
713 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
713 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
714 | 714 | |
715 | 715 | // check for request url |
716 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
716 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
717 | 717 | |
718 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
718 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
719 | 719 | |
720 | - $ru_bits = explode( '?', $request_uri ); |
|
720 | + $ru_bits = explode('?', $request_uri); |
|
721 | 721 | $request_uri = $ru_bits[0]; |
722 | 722 | //echo '<h1>$request_uri ' . $request_uri . '</h1>'; |
723 | 723 | |
724 | 724 | // check for and grab host as well |
725 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
726 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
725 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
726 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
727 | 727 | } else { |
728 | 728 | $http_host = ''; |
729 | 729 | } |
730 | 730 | //echo '<h1>$http_host ' . $http_host . '</h1>'; |
731 | 731 | |
732 | 732 | // check for page_id in SERVER REQUEST |
733 | - if ( isset( $_REQUEST['page_id'] )) { |
|
733 | + if (isset($_REQUEST['page_id'])) { |
|
734 | 734 | // rebuild $e_reg without any of the extra parameters |
735 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
735 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
736 | 736 | } else { |
737 | 737 | $page_id = '?'; |
738 | 738 | } |
739 | 739 | // check for $e_reg in SERVER REQUEST |
740 | - if ( isset( $_REQUEST['ee'] )) { |
|
740 | + if (isset($_REQUEST['ee'])) { |
|
741 | 741 | // rebuild $e_reg without any of the extra parameters |
742 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
742 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
743 | 743 | } else { |
744 | 744 | $e_reg = ''; |
745 | 745 | } |
746 | 746 | |
747 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
747 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
748 | 748 | |
749 | 749 | } |
750 | 750 | |
751 | - return $page_visit != home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
751 | + return $page_visit != home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
752 | 752 | |
753 | 753 | } |
754 | 754 | |
@@ -777,14 +777,14 @@ discard block |
||
777 | 777 | * @param string $function |
778 | 778 | * @return void |
779 | 779 | */ |
780 | - public function clear_session( $class = '', $function = '' ) { |
|
780 | + public function clear_session($class = '', $function = '') { |
|
781 | 781 | //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>'; |
782 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
782 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
783 | 783 | $this->reset_cart(); |
784 | 784 | $this->reset_checkout(); |
785 | 785 | $this->reset_transaction(); |
786 | 786 | // wipe out everything that isn't a default session datum |
787 | - $this->reset_data( array_keys( $this->_session_data )); |
|
787 | + $this->reset_data(array_keys($this->_session_data)); |
|
788 | 788 | // reset initial site access time and the session expiration |
789 | 789 | $this->_set_init_access_and_expiration(); |
790 | 790 | $this->_save_session_to_db(); |
@@ -799,42 +799,42 @@ discard block |
||
799 | 799 | * @param bool $show_all_notices |
800 | 800 | * @return TRUE on success, FALSE on fail |
801 | 801 | */ |
802 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
802 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
803 | 803 | // if $data_to_reset is not in an array, then put it in one |
804 | - if ( ! is_array( $data_to_reset ) ) { |
|
805 | - $data_to_reset = array ( $data_to_reset ); |
|
804 | + if ( ! is_array($data_to_reset)) { |
|
805 | + $data_to_reset = array($data_to_reset); |
|
806 | 806 | } |
807 | 807 | // nothing ??? go home! |
808 | - if ( empty( $data_to_reset )) { |
|
809 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
808 | + if (empty($data_to_reset)) { |
|
809 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
810 | 810 | return FALSE; |
811 | 811 | } |
812 | 812 | $return_value = TRUE; |
813 | 813 | // since $data_to_reset is an array, cycle through the values |
814 | - foreach ( $data_to_reset as $reset ) { |
|
814 | + foreach ($data_to_reset as $reset) { |
|
815 | 815 | |
816 | 816 | // first check to make sure it is a valid session var |
817 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
817 | + if (isset($this->_session_data[$reset])) { |
|
818 | 818 | // then check to make sure it is not a default var |
819 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
819 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
820 | 820 | // remove session var |
821 | - unset( $this->_session_data[ $reset ] ); |
|
822 | - if ( $show_all_notices ) { |
|
823 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
821 | + unset($this->_session_data[$reset]); |
|
822 | + if ($show_all_notices) { |
|
823 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
824 | 824 | } |
825 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
825 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
826 | 826 | |
827 | 827 | } else { |
828 | 828 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
829 | - if ( $show_all_notices ) { |
|
830 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
829 | + if ($show_all_notices) { |
|
830 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
831 | 831 | } |
832 | 832 | $return_value = FALSE; |
833 | 833 | } |
834 | 834 | |
835 | - } else if ( $show_all_notices ) { |
|
835 | + } else if ($show_all_notices) { |
|
836 | 836 | // oops! that session var does not exist! |
837 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
837 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
838 | 838 | $return_value = FALSE; |
839 | 839 | } |
840 | 840 | |
@@ -855,8 +855,8 @@ discard block |
||
855 | 855 | * @return string |
856 | 856 | */ |
857 | 857 | public function wp_loaded() { |
858 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
859 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
858 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
859 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | |
@@ -881,24 +881,24 @@ discard block |
||
881 | 881 | */ |
882 | 882 | public function garbage_collection() { |
883 | 883 | // only perform during regular requests |
884 | - if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) { |
|
884 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
885 | 885 | /** @type WPDB $wpdb */ |
886 | 886 | global $wpdb; |
887 | 887 | // since transient expiration timestamps are set in the future, we can compare against NOW |
888 | 888 | $expiration = time(); |
889 | - $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 ); |
|
889 | + $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2); |
|
890 | 890 | // filter the query limit. Set to 0 to turn off garbage collection |
891 | - $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 )); |
|
891 | + $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50)); |
|
892 | 892 | // non-zero LIMIT means take out the trash |
893 | - if ( $expired_session_transient_delete_query_limit ) { |
|
893 | + if ($expired_session_transient_delete_query_limit) { |
|
894 | 894 | //array of transient keys that require garbage collection |
895 | 895 | $session_keys = array( |
896 | 896 | EE_Session::session_id_prefix, |
897 | 897 | EE_Session::hash_check_prefix, |
898 | 898 | ); |
899 | - foreach ( $session_keys as $session_key ) { |
|
900 | - $session_key = str_replace( '_', '\_', $session_key ); |
|
901 | - $session_key = '\_transient\_timeout\_' . $session_key . '%'; |
|
899 | + foreach ($session_keys as $session_key) { |
|
900 | + $session_key = str_replace('_', '\_', $session_key); |
|
901 | + $session_key = '\_transient\_timeout\_'.$session_key.'%'; |
|
902 | 902 | $SQL = " |
903 | 903 | SELECT option_name |
904 | 904 | FROM {$wpdb->options} |
@@ -908,28 +908,28 @@ discard block |
||
908 | 908 | OR option_value > {$too_far_in_the_the_future} ) |
909 | 909 | LIMIT {$expired_session_transient_delete_query_limit} |
910 | 910 | "; |
911 | - $expired_sessions = $wpdb->get_col( $SQL ); |
|
911 | + $expired_sessions = $wpdb->get_col($SQL); |
|
912 | 912 | // valid results? |
913 | - if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) { |
|
913 | + if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) { |
|
914 | 914 | // format array of results into something usable within the actual DELETE query's IN clause |
915 | 915 | $expired = array(); |
916 | - foreach ( $expired_sessions as $expired_session ) { |
|
917 | - $expired[ ] = "'" . $expired_session . "'"; |
|
918 | - $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'"; |
|
916 | + foreach ($expired_sessions as $expired_session) { |
|
917 | + $expired[] = "'".$expired_session."'"; |
|
918 | + $expired[] = "'".str_replace('timeout_', '', $expired_session)."'"; |
|
919 | 919 | } |
920 | - $expired = implode( ', ', $expired ); |
|
920 | + $expired = implode(', ', $expired); |
|
921 | 921 | $SQL = " |
922 | 922 | DELETE FROM {$wpdb->options} |
923 | 923 | WHERE option_name |
924 | 924 | IN ( $expired ); |
925 | 925 | "; |
926 | - $results = $wpdb->query( $SQL ); |
|
926 | + $results = $wpdb->query($SQL); |
|
927 | 927 | // if something went wrong, then notify the admin |
928 | - if ( $results instanceof WP_Error && is_admin() ) { |
|
929 | - EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
928 | + if ($results instanceof WP_Error && is_admin()) { |
|
929 | + EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
930 | 930 | } |
931 | 931 | } |
932 | - do_action( 'FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit ); |
|
932 | + do_action('FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit); |
|
933 | 933 | } |
934 | 934 | } |
935 | 935 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * |
@@ -21,60 +21,60 @@ discard block |
||
21 | 21 | * Please instead use the EEM_Attendee::system_question_* constants |
22 | 22 | * @deprecated |
23 | 23 | */ |
24 | - const fname_question_id=1; |
|
24 | + const fname_question_id = 1; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @deprecated |
28 | 28 | */ |
29 | - const lname_question_id=2; |
|
29 | + const lname_question_id = 2; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @deprecated |
34 | 34 | */ |
35 | - const email_question_id=3; |
|
35 | + const email_question_id = 3; |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @deprecated |
40 | 40 | */ |
41 | - const address_question_id=4; |
|
41 | + const address_question_id = 4; |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @deprecated |
46 | 46 | */ |
47 | - const address2_question_id=5; |
|
47 | + const address2_question_id = 5; |
|
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @deprecated |
52 | 52 | */ |
53 | - const city_question_id=6; |
|
53 | + const city_question_id = 6; |
|
54 | 54 | |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @deprecated |
58 | 58 | */ |
59 | - const state_question_id=7; |
|
59 | + const state_question_id = 7; |
|
60 | 60 | |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @deprecated |
64 | 64 | */ |
65 | - const country_question_id=8; |
|
65 | + const country_question_id = 8; |
|
66 | 66 | |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @deprecated |
70 | 70 | */ |
71 | - const zip_question_id=9; |
|
71 | + const zip_question_id = 9; |
|
72 | 72 | |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @deprecated |
76 | 76 | */ |
77 | - const phone_question_id=10; |
|
77 | + const phone_question_id = 10; |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * When looking for questions that correspond to attendee fields, |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * @access protected |
120 | 120 | * @param null $timezone |
121 | 121 | */ |
122 | - protected function __construct( $timezone = NULL ) { |
|
123 | - $this->singular_item = __('Attendee','event_espresso'); |
|
124 | - $this->plural_item = __('Attendees','event_espresso'); |
|
122 | + protected function __construct($timezone = NULL) { |
|
123 | + $this->singular_item = __('Attendee', 'event_espresso'); |
|
124 | + $this->plural_item = __('Attendees', 'event_espresso'); |
|
125 | 125 | $this->_tables = array( |
126 | 126 | 'Attendee_CPT'=> new EE_Primary_Table('posts', 'ID'), |
127 | 127 | 'Attendee_Meta'=>new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID') |
@@ -135,37 +135,37 @@ discard block |
||
135 | 135 | 'ATT_created'=>new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"), false, time()), |
136 | 136 | 'ATT_short_bio'=>new EE_Simple_HTML_Field('post_excerpt', __("Attendee Short Biography", "event_espresso"), true, __("No Biography Provided", "event_espresso")), |
137 | 137 | 'ATT_modified'=>new EE_Datetime_Field('post_modified', __("Time Attendee Last Modified", "event_espresso"), FALSE, time()), |
138 | - 'ATT_author'=>new EE_WP_User_Field('post_author', __("Creator ID of the first Event attended", "event_espresso"), false ), |
|
138 | + 'ATT_author'=>new EE_WP_User_Field('post_author', __("Creator ID of the first Event attended", "event_espresso"), false), |
|
139 | 139 | 'ATT_parent'=>new EE_DB_Only_Int_Field('post_parent', __("Parent Attendee (unused)", "event_espresso"), false, 0), |
140 | - 'post_type'=>new EE_WP_Post_Type_Field('espresso_attendees'),// EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'), |
|
140 | + 'post_type'=>new EE_WP_Post_Type_Field('espresso_attendees'), // EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'), |
|
141 | 141 | 'status' => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'), false, 'publish') |
142 | 142 | ), |
143 | 143 | 'Attendee_Meta'=>array( |
144 | - 'ATTM_ID'=> new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID','event_espresso'), false), |
|
144 | + 'ATTM_ID'=> new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'), false), |
|
145 | 145 | 'ATT_ID_fk'=>new EE_DB_Only_Int_Field('ATT_ID', __("Foreign Key to Attendee in Post Table", "event_espresso"), false), |
146 | - 'ATT_fname'=>new EE_Plain_Text_Field('ATT_fname', __('First Name','event_espresso'), true, ''), |
|
147 | - 'ATT_lname'=>new EE_Plain_Text_Field('ATT_lname', __('Last Name','event_espresso'), true, ''), |
|
148 | - 'ATT_address'=>new EE_Plain_Text_Field('ATT_address', __('Address Part 1','event_espresso'), true, ''), |
|
149 | - 'ATT_address2'=>new EE_Plain_Text_Field('ATT_address2', __('Address Part 2','event_espresso'), true, ''), |
|
150 | - 'ATT_city'=>new EE_Plain_Text_Field('ATT_city', __('City','event_espresso'), true, ''), |
|
151 | - 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __('State','event_espresso'), true,0,'State'), |
|
152 | - 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __('Country','event_espresso'), true,'','Country'), |
|
153 | - 'ATT_zip'=>new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code','event_espresso'), true, ''), |
|
154 | - 'ATT_email'=>new EE_Email_Field('ATT_email', __('Email Address','event_espresso'), true, ''), |
|
155 | - 'ATT_phone'=>new EE_Plain_Text_Field('ATT_phone', __('Phone','event_espresso'), true, '') |
|
146 | + 'ATT_fname'=>new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''), |
|
147 | + 'ATT_lname'=>new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''), |
|
148 | + 'ATT_address'=>new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true, ''), |
|
149 | + 'ATT_address2'=>new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true, ''), |
|
150 | + 'ATT_city'=>new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''), |
|
151 | + 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0, 'State'), |
|
152 | + 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '', 'Country'), |
|
153 | + 'ATT_zip'=>new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''), |
|
154 | + 'ATT_email'=>new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''), |
|
155 | + 'ATT_phone'=>new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, '') |
|
156 | 156 | )); |
157 | 157 | $this->_model_relations = array( |
158 | 158 | 'Registration'=>new EE_Has_Many_Relation(), |
159 | 159 | 'State'=>new EE_Belongs_To_Relation(), |
160 | 160 | 'Country'=>new EE_Belongs_To_Relation(), |
161 | - 'Event'=>new EE_HABTM_Relation('Registration', FALSE ), |
|
161 | + 'Event'=>new EE_HABTM_Relation('Registration', FALSE), |
|
162 | 162 | 'WP_User' => new EE_Belongs_To_Relation(), |
163 | - 'Message' => new EE_Has_Many_Any_Relation( false ) //allow deletion of attendees even if they have messages in the queue for them. |
|
163 | + 'Message' => new EE_Has_Many_Any_Relation(false) //allow deletion of attendees even if they have messages in the queue for them. |
|
164 | 164 | ); |
165 | 165 | require_once('strategies/EE_CPT_Where_Conditions.strategy.php'); |
166 | 166 | $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_attendees', 'ATTM_ID'); |
167 | 167 | $this->_caps_slug = 'contacts'; |
168 | - parent::__construct( $timezone ); |
|
168 | + parent::__construct($timezone); |
|
169 | 169 | |
170 | 170 | } |
171 | 171 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * @param string $system_question_string |
176 | 176 | * @return string|null if not found |
177 | 177 | */ |
178 | - public function get_attendee_field_for_system_question( $system_question_string ) { |
|
179 | - return isset( $this->_system_question_to_attendee_field_name[ $system_question_string ] ) ? $this->_system_question_to_attendee_field_name[ $system_question_string ] : null; |
|
178 | + public function get_attendee_field_for_system_question($system_question_string) { |
|
179 | + return isset($this->_system_question_to_attendee_field_name[$system_question_string]) ? $this->_system_question_to_attendee_field_name[$system_question_string] : null; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | * @param EE_Transaction/int $transaction_id_or_obj EE_Transaction or its ID |
188 | 188 | * @return EE_Attendee[] |
189 | 189 | */ |
190 | - public function get_attendees_for_transaction( $transaction_id_or_obj ){ |
|
191 | - return $this->get_all( array( array( |
|
190 | + public function get_attendees_for_transaction($transaction_id_or_obj) { |
|
191 | + return $this->get_all(array(array( |
|
192 | 192 | 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction ? $transaction_id_or_obj->ID() : $transaction_id_or_obj |
193 | 193 | ))); |
194 | 194 | } |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | * @return mixed array on success, FALSE on fail |
204 | 204 | * @deprecated |
205 | 205 | */ |
206 | - public function get_attendee_by_ID( $ATT_ID = FALSE ) { |
|
206 | + public function get_attendee_by_ID($ATT_ID = FALSE) { |
|
207 | 207 | // retrieve a particular EE_Attendee |
208 | - return $this->get_one_by_ID( $ATT_ID ); |
|
208 | + return $this->get_one_by_ID($ATT_ID); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @param array $where_cols_n_values |
219 | 219 | * @return mixed array on success, FALSE on fail |
220 | 220 | */ |
221 | - public function get_attendee( $where_cols_n_values = array() ) { |
|
221 | + public function get_attendee($where_cols_n_values = array()) { |
|
222 | 222 | |
223 | - if ( empty( $where_cols_n_values )) { |
|
223 | + if (empty($where_cols_n_values)) { |
|
224 | 224 | return FALSE; |
225 | 225 | } |
226 | - $attendee = $this->get_all( array($where_cols_n_values )); |
|
227 | - if ( ! empty( $attendee )) { |
|
228 | - return array_shift( $attendee ); |
|
226 | + $attendee = $this->get_all(array($where_cols_n_values)); |
|
227 | + if ( ! empty($attendee)) { |
|
228 | + return array_shift($attendee); |
|
229 | 229 | } else { |
230 | 230 | return FALSE; |
231 | 231 | } |
@@ -241,20 +241,20 @@ discard block |
||
241 | 241 | * @param array $where_cols_n_values |
242 | 242 | * @return bool|mixed |
243 | 243 | */ |
244 | - public function find_existing_attendee( $where_cols_n_values = NULL ) { |
|
244 | + public function find_existing_attendee($where_cols_n_values = NULL) { |
|
245 | 245 | // search by combo of first and last names plus the email address |
246 | - $attendee_data_keys = array( 'ATT_fname' => $this->_ATT_fname, 'ATT_lname' => $this->_ATT_lname, 'ATT_email' => $this->_ATT_email ); |
|
246 | + $attendee_data_keys = array('ATT_fname' => $this->_ATT_fname, 'ATT_lname' => $this->_ATT_lname, 'ATT_email' => $this->_ATT_email); |
|
247 | 247 | // no search params means attendee object already exists. |
248 | - $where_cols_n_values = is_array( $where_cols_n_values ) && ! empty( $where_cols_n_values ) ? $where_cols_n_values : $attendee_data_keys; |
|
248 | + $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) ? $where_cols_n_values : $attendee_data_keys; |
|
249 | 249 | $valid_data = TRUE; |
250 | 250 | // check for required values |
251 | - $valid_data = isset( $where_cols_n_values['ATT_fname'] ) && ! empty( $where_cols_n_values['ATT_fname'] ) ? $valid_data : FALSE; |
|
252 | - $valid_data = isset( $where_cols_n_values['ATT_lname'] ) && ! empty( $where_cols_n_values['ATT_lname'] ) ? $valid_data : FALSE; |
|
253 | - $valid_data = isset( $where_cols_n_values['ATT_email'] ) && ! empty( $where_cols_n_values['ATT_email'] ) ? $valid_data : FALSE; |
|
251 | + $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) ? $valid_data : FALSE; |
|
252 | + $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) ? $valid_data : FALSE; |
|
253 | + $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) ? $valid_data : FALSE; |
|
254 | 254 | |
255 | - if ( $valid_data ) { |
|
256 | - $attendee = $this->get_attendee( $where_cols_n_values ); |
|
257 | - if ( $attendee instanceof EE_Attendee ) { |
|
255 | + if ($valid_data) { |
|
256 | + $attendee = $this->get_attendee($where_cols_n_values); |
|
257 | + if ($attendee instanceof EE_Attendee) { |
|
258 | 258 | return $attendee; |
259 | 259 | } |
260 | 260 | } |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | * @param array $ids array of EE_Registration ids |
273 | 273 | * @return EE_Attendee[] |
274 | 274 | */ |
275 | - public function get_array_of_contacts_from_reg_ids( $ids ) { |
|
275 | + public function get_array_of_contacts_from_reg_ids($ids) { |
|
276 | 276 | $ids = (array) $ids; |
277 | 277 | $_where = array( |
278 | - 'Registration.REG_ID' => array( 'in', $ids ) |
|
278 | + 'Registration.REG_ID' => array('in', $ids) |
|
279 | 279 | ); |
280 | - return $this->get_all( array( $_where ) ); |
|
280 | + return $this->get_all(array($_where)); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 |
@@ -95,7 +95,7 @@ |
||
95 | 95 | * |
96 | 96 | * @param EE_Event $event EE event object |
97 | 97 | * @param array $data The request data from the form |
98 | - * @return bool success or fail |
|
98 | + * @return integer success or fail |
|
99 | 99 | */ |
100 | 100 | public function attach_evt_message_templates( $event, $data ) { |
101 | 101 | //first we remove all existing relations on the Event for message types. |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -22,21 +22,21 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param \EE_Admin_Page $admin_page |
24 | 24 | */ |
25 | - public function __construct( EE_Admin_Page $admin_page ) { |
|
25 | + public function __construct(EE_Admin_Page $admin_page) { |
|
26 | 26 | /** |
27 | 27 | * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages |
28 | 28 | */ |
29 | 29 | if ( |
30 | - ! EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'messages_events_editor_metabox' ) |
|
30 | + ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'messages_events_editor_metabox') |
|
31 | 31 | ) { |
32 | 32 | return; |
33 | 33 | } |
34 | 34 | add_filter( |
35 | 35 | 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
36 | - array( $this, 'caf_updates' ), |
|
36 | + array($this, 'caf_updates'), |
|
37 | 37 | 10 |
38 | 38 | ); |
39 | - parent::__construct( $admin_page ); |
|
39 | + parent::__construct($admin_page); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | */ |
50 | 50 | protected function _extend_properties() { |
51 | 51 | |
52 | - define( 'EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/' ); |
|
52 | + define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'messages/assets/'); |
|
53 | 53 | $this->_ajax_func = array( |
54 | 54 | 'ee_msgs_create_new_custom' => 'create_new_custom' |
55 | 55 | ); |
56 | 56 | $this->_metaboxes = array( |
57 | 57 | 0 => array( |
58 | - 'page_route' => array('edit','create_new'), |
|
58 | + 'page_route' => array('edit', 'create_new'), |
|
59 | 59 | 'func' => 'messages_metabox', |
60 | 60 | 'label' => __('Notifications', 'event_espresso'), |
61 | 61 | 'priority' => 'high' |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | $this->_scripts_styles = array( |
67 | 67 | 'registers' => array( |
68 | 68 | 'events_msg_admin' => array( |
69 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js', |
|
69 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL.'events_messages_admin.js', |
|
70 | 70 | 'depends' => array('ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array') |
71 | 71 | ), |
72 | 72 | 'events_msg_admin_css' => array( |
73 | - 'url' => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css', |
|
73 | + 'url' => EE_MSGS_EXTEND_ASSETS_URL.'ee_msg_events_admin.css', |
|
74 | 74 | 'type' => 'css' |
75 | 75 | ) |
76 | 76 | ), |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | - public function caf_updates( $update_callbacks ) { |
|
86 | - $update_callbacks[] = array( $this, 'attach_evt_message_templates' ); |
|
85 | + public function caf_updates($update_callbacks) { |
|
86 | + $update_callbacks[] = array($this, 'attach_evt_message_templates'); |
|
87 | 87 | return $update_callbacks; |
88 | 88 | } |
89 | 89 | |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | * @param array $data The request data from the form |
98 | 98 | * @return bool success or fail |
99 | 99 | */ |
100 | - public function attach_evt_message_templates( $event, $data ) { |
|
100 | + public function attach_evt_message_templates($event, $data) { |
|
101 | 101 | //first we remove all existing relations on the Event for message types. |
102 | 102 | $event->_remove_relations('Message_Template_Group'); |
103 | 103 | //now let's just loop through the selected templates and add relations! |
104 | - if ( isset( $data[ 'event_message_templates_relation' ] ) ) { |
|
105 | - foreach ( $data[ 'event_message_templates_relation' ] as $grp_ID ) { |
|
106 | - $event->_add_relation_to( $grp_ID, 'Message_Template_Group' ); |
|
104 | + if (isset($data['event_message_templates_relation'])) { |
|
105 | + foreach ($data['event_message_templates_relation'] as $grp_ID) { |
|
106 | + $event->_add_relation_to($grp_ID, 'Message_Template_Group'); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | //now save |
@@ -118,25 +118,25 @@ discard block |
||
118 | 118 | * @return string |
119 | 119 | * @throws \EE_Error |
120 | 120 | */ |
121 | - public function messages_metabox( $event, $callback_args ) { |
|
121 | + public function messages_metabox($event, $callback_args) { |
|
122 | 122 | //let's get the active messengers (b/c messenger objects have the active message templates) |
123 | 123 | //convert 'evt_id' to 'EVT_ID' |
124 | - $this->_req_data['EVT_ID'] = isset( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : NULL; |
|
125 | - $this->_req_data['EVT_ID'] = isset( $this->_req_data['post'] ) && empty( $this->_req_data['EVT_ID'] ) |
|
124 | + $this->_req_data['EVT_ID'] = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL; |
|
125 | + $this->_req_data['EVT_ID'] = isset($this->_req_data['post']) && empty($this->_req_data['EVT_ID']) |
|
126 | 126 | ? $this->_req_data['post'] |
127 | 127 | : $this->_req_data['EVT_ID']; |
128 | 128 | |
129 | - $this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID'] ) && isset($this->_req_data['evt_id'] ) |
|
129 | + $this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID']) && isset($this->_req_data['evt_id']) |
|
130 | 130 | ? $this->_req_data['evt_id'] |
131 | 131 | : $this->_req_data['EVT_ID']; |
132 | 132 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
133 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
133 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
134 | 134 | $active_messengers = $message_resource_manager->active_messengers(); |
135 | 135 | $tabs = array(); |
136 | 136 | |
137 | 137 | //empty messengers? |
138 | 138 | //Note message types will always have at least one available because every messenger has a default message type associated with it (payment) if no other message types are selected. |
139 | - if ( empty( $active_messengers ) ) { |
|
139 | + if (empty($active_messengers)) { |
|
140 | 140 | $msg_activate_url = EE_Admin_Page::add_query_args_and_nonce( |
141 | 141 | array('action' => 'settings'), |
142 | 142 | EE_MSG_ADMIN_URL |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | __('There are no active messengers. So no notifications will go out for %1$sany%2$s events. You will want to %3$sActivate a Messenger%4$s.', 'event_espresso'), |
146 | 146 | '<strong>', |
147 | 147 | '</strong>', |
148 | - '<a href="' . $msg_activate_url . '">', |
|
148 | + '<a href="'.$msg_activate_url.'">', |
|
149 | 149 | '</a>' |
150 | 150 | ); |
151 | - $error_content = '<div class="error"><p>' . $error_msg . '</p></div>'; |
|
152 | - $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>'; |
|
151 | + $error_content = '<div class="error"><p>'.$error_msg.'</p></div>'; |
|
152 | + $internal_content = '<div id="messages-error"><p>'.$error_msg.'</p></div>'; |
|
153 | 153 | |
154 | 154 | echo $error_content; |
155 | 155 | echo $internal_content; |
@@ -158,20 +158,20 @@ discard block |
||
158 | 158 | |
159 | 159 | $event_id = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL; |
160 | 160 | //get content for active messengers |
161 | - foreach ( $active_messengers as $name => $messenger ) { |
|
161 | + foreach ($active_messengers as $name => $messenger) { |
|
162 | 162 | //first check if there are any active message types for this messenger. |
163 | - $active_mts = $message_resource_manager->get_active_message_types_for_messenger( $name ); |
|
164 | - if ( empty( $active_mts ) ) { |
|
163 | + $active_mts = $message_resource_manager->get_active_message_types_for_messenger($name); |
|
164 | + if (empty($active_mts)) { |
|
165 | 165 | continue; |
166 | 166 | } |
167 | 167 | |
168 | 168 | $tab_content = $messenger->get_messenger_admin_page_content( |
169 | 169 | 'events', |
170 | 170 | 'edit', |
171 | - array( 'event' => $event_id ) |
|
171 | + array('event' => $event_id) |
|
172 | 172 | ); |
173 | 173 | |
174 | - if ( ! empty( $tab_content ) ) { |
|
174 | + if ( ! empty($tab_content)) { |
|
175 | 175 | $tabs[$name] = $tab_content; |
176 | 176 | } |
177 | 177 | } |
@@ -179,23 +179,23 @@ discard block |
||
179 | 179 | |
180 | 180 | //we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper. |
181 | 181 | $tabbed_content = EEH_Tabbed_Content::display($tabs); |
182 | - if ( $tabbed_content instanceof WP_Error ) { |
|
182 | + if ($tabbed_content instanceof WP_Error) { |
|
183 | 183 | $tabbed_content = $tabbed_content->get_error_message(); |
184 | 184 | } |
185 | 185 | |
186 | 186 | $notices = ' |
187 | 187 | <div id="espresso-ajax-loading" class="ajax-loader-grey"> |
188 | - <span class="ee-spinner ee-spin"></span><span class="hidden">' . __('loading...', 'event_espresso') . '</span> |
|
188 | + <span class="ee-spinner ee-spin"></span><span class="hidden">' . __('loading...', 'event_espresso').'</span> |
|
189 | 189 | </div> |
190 | 190 | <div class="ee-notices"></div>'; |
191 | 191 | |
192 | - if ( defined('DOING_AJAX' ) ) { |
|
192 | + if (defined('DOING_AJAX')) { |
|
193 | 193 | return $tabbed_content; |
194 | 194 | } |
195 | 195 | |
196 | - do_action( 'AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content' ); |
|
197 | - echo $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>'; |
|
198 | - do_action( 'AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content' ); |
|
196 | + do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content'); |
|
197 | + echo $notices.'<div class="messages-tabs-content">'.$tabbed_content.'</div>'; |
|
198 | + do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content'); |
|
199 | 199 | |
200 | 200 | } |
201 | 201 | |
@@ -210,15 +210,15 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function create_new_custom() { |
212 | 212 | |
213 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'create_new_custom_ajax' ) ) { |
|
214 | - wp_die( __('You don\'t have privileges to do this action', 'event_espresso' ) ); |
|
213 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) { |
|
214 | + wp_die(__('You don\'t have privileges to do this action', 'event_espresso')); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | //let's clean up the _POST global a bit for downstream usage of name and description. |
218 | - $_POST['templateName'] = !empty( $this->_req_data['custom_template_args']['MTP_name'] ) |
|
218 | + $_POST['templateName'] = ! empty($this->_req_data['custom_template_args']['MTP_name']) |
|
219 | 219 | ? $this->_req_data['custom_template_args']['MTP_name'] |
220 | 220 | : ''; |
221 | - $_POST['templateDescription'] = !empty( $this->_req_data['custom_template_args']['MTP_description'] ) |
|
221 | + $_POST['templateDescription'] = ! empty($this->_req_data['custom_template_args']['MTP_description']) |
|
222 | 222 | ? $this->_req_data['custom_template_args']['MTP_description'] |
223 | 223 | : ''; |
224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $this->_set_page_object(); |
228 | 228 | |
229 | 229 | // is this a template switch if so EE_Admin_Page child needs this object |
230 | - $this->_page_object->set_hook_object( $this ); |
|
230 | + $this->_page_object->set_hook_object($this); |
|
231 | 231 | |
232 | 232 | $this->_page_object->add_message_template( |
233 | 233 | $this->_req_data['messageType'], |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function edit_admin_footer() { |
253 | 253 | EEH_Template::display_template( |
254 | - EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php' |
|
254 | + EE_CORE_CAF_ADMIN_EXTEND.'messages/templates/create_custom_template_form.template.php' |
|
255 | 255 | ); |
256 | 256 | } |
257 | 257 |
@@ -594,7 +594,7 @@ |
||
594 | 594 | * @since 4.1 |
595 | 595 | * @access public |
596 | 596 | * |
597 | - * @param object $item The current item |
|
597 | + * @param EE_Message_Template_Group $item The current item |
|
598 | 598 | */ |
599 | 599 | public function single_row( $item ) { |
600 | 600 | $row_class = $this->_get_row_class( $item ); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param $messenger |
85 | 85 | * @param string $orderby |
86 | 86 | * @param string $order |
87 | - * @return array all (including trashed or inactive) message template group objects for the given messenger |
|
87 | + * @return EE_Base_Class[] all (including trashed or inactive) message template group objects for the given messenger |
|
88 | 88 | */ |
89 | 89 | public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC' ) { |
90 | 90 | return $this->get_all_deleted_and_undeleted( |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | /** |
344 | 344 | * This sends things to the validator for the given messenger and message type. |
345 | 345 | * |
346 | - * @param array $fields the incoming fields to check. |
|
346 | + * @param string $fields the incoming fields to check. |
|
347 | 347 | * Note this array is in the formatted fields from the form fields setup. |
348 | 348 | * So we need to reformat this into an array of expected field refs by the validator. |
349 | 349 | * Note also that this is not only the fields for the Message Template Group |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php if (!defined('EVENT_ESPRESSO_VERSION') ) |
2 | 2 | exit('NO direct script access allowed'); |
3 | 3 | /** |
4 | - * EEM_Message_Template_Group |
|
5 | - * |
|
6 | - * @package Event Espresso |
|
7 | - * @subpackage includes/models/EEM_Message_Template_Group.model.php |
|
8 | - * @author Darren Ethier |
|
9 | - * |
|
10 | - * |
|
11 | - */ |
|
4 | + * EEM_Message_Template_Group |
|
5 | + * |
|
6 | + * @package Event Espresso |
|
7 | + * @subpackage includes/models/EEM_Message_Template_Group.model.php |
|
8 | + * @author Darren Ethier |
|
9 | + * |
|
10 | + * |
|
11 | + */ |
|
12 | 12 | require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
13 | 13 | class EEM_Message_Template_Group extends EEM_Soft_Delete_Base { |
14 | 14 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
2 | 2 | exit('NO direct script access allowed'); |
3 | 3 | /** |
4 | 4 | * EEM_Message_Template_Group |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * |
11 | 11 | */ |
12 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
12 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
13 | 13 | class EEM_Message_Template_Group extends EEM_Soft_Delete_Base { |
14 | 14 | |
15 | 15 | // private instance of the EEM_Message_Template_Group object |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | |
19 | 19 | |
20 | - protected function __construct( $timezone = NULL ) { |
|
20 | + protected function __construct($timezone = NULL) { |
|
21 | 21 | $this->singular_item = __('Message Template Group', 'event_espresso'); |
22 | 22 | $this->plural_item = __('Message Template Groups', 'event_espresso'); |
23 | 23 | $this->_tables = array( |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | $this->_fields = array( |
27 | 27 | 'Message_Template_Group' => array( |
28 | 28 | 'GRP_ID' => new EE_Primary_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso')), |
29 | - 'MTP_name' => new EE_Plain_Text_Field( 'MTP_name', __('The name of the template group', 'event_espresso'), FALSE, '' ), |
|
30 | - 'MTP_description' => new EE_Simple_HTML_Field( 'MTP_description', __('A brief description about this template.', 'event_espresso' ), FALSE, '' ), |
|
31 | - 'MTP_user_id'=> new EE_WP_User_Field('MTP_user_id', __('Template Creator ID', 'event_espresso'), FALSE, get_current_user_id() ), |
|
32 | - 'MTP_messenger'=>new EE_Plain_Text_Field('MTP_messenger', __('Messenger Used for Template', 'event_espresso'), FALSE, 'email' ), |
|
33 | - 'MTP_message_type'=>new EE_Plain_Text_Field('MTP_message_type', __('Message Type', 'event_espresso'),false,'registration'), |
|
29 | + 'MTP_name' => new EE_Plain_Text_Field('MTP_name', __('The name of the template group', 'event_espresso'), FALSE, ''), |
|
30 | + 'MTP_description' => new EE_Simple_HTML_Field('MTP_description', __('A brief description about this template.', 'event_espresso'), FALSE, ''), |
|
31 | + 'MTP_user_id'=> new EE_WP_User_Field('MTP_user_id', __('Template Creator ID', 'event_espresso'), FALSE, get_current_user_id()), |
|
32 | + 'MTP_messenger'=>new EE_Plain_Text_Field('MTP_messenger', __('Messenger Used for Template', 'event_espresso'), FALSE, 'email'), |
|
33 | + 'MTP_message_type'=>new EE_Plain_Text_Field('MTP_message_type', __('Message Type', 'event_espresso'), false, 'registration'), |
|
34 | 34 | 'MTP_is_global'=>new EE_Boolean_Field('MTP_is_global', __('Flag indicating if Template Group is Global', 'event_espresso'), false, true), |
35 | 35 | 'MTP_is_override'=>new EE_Boolean_Field('MTP_is_override', __('Flag indicating if Template Group overrides any other Templates for the messenger/messagetype combination', 'event_espresso'), false, false), |
36 | 36 | 'MTP_deleted'=>new EE_Trashed_Flag_Field('MTP_deleted', __('Flag indicating whether this has been trashed', 'event_espresso'), false, false), |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | 'Event' => new EE_HABTM_Relation('Event_Message_Template'), |
44 | 44 | 'WP_User' => new EE_Belongs_To_Relation() |
45 | 45 | ); |
46 | - foreach( $this->_cap_contexts_to_cap_action_map as $context => $action ){ |
|
47 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global( 'MTP_is_global'); |
|
46 | + foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
47 | + $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_Global('MTP_is_global'); |
|
48 | 48 | } |
49 | 49 | $this->_caps_slug = 'messages'; |
50 | 50 | |
51 | - parent::__construct( $timezone ); |
|
51 | + parent::__construct($timezone); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | $limit = null, |
72 | 72 | $count = false |
73 | 73 | ) { |
74 | - $query_params = array( array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
75 | - return $count ? $this->count_deleted( $query_params, 'GRP_ID', TRUE ) : $this->get_all_deleted( $query_params ); |
|
74 | + $query_params = array(array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
75 | + return $count ? $this->count_deleted($query_params, 'GRP_ID', TRUE) : $this->get_all_deleted($query_params); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | * @param string $order |
87 | 87 | * @return array all (including trashed or inactive) message template group objects for the given messenger |
88 | 88 | */ |
89 | - public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC' ) { |
|
89 | + public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC') { |
|
90 | 90 | return $this->get_all_deleted_and_undeleted( |
91 | - array( array( 'MTP_messenger' => $messenger ), 'order_by' => array( $orderby => $order ) ) |
|
91 | + array(array('MTP_messenger' => $messenger), 'order_by' => array($orderby => $order)) |
|
92 | 92 | ); |
93 | 93 | } |
94 | 94 | |
@@ -99,18 +99,18 @@ discard block |
||
99 | 99 | * @param array $_where any existing where conditions to append these to. |
100 | 100 | * @return array original where conditions or original with additional filters. |
101 | 101 | */ |
102 | - protected function _maybe_mtp_filters( $_where = array() ) { |
|
102 | + protected function _maybe_mtp_filters($_where = array()) { |
|
103 | 103 | //account for messenger or message type filters |
104 | 104 | if ( |
105 | - isset( $_REQUEST[ 'ee_messenger_filter_by' ] ) |
|
106 | - && $_REQUEST[ 'ee_messenger_filter_by' ] != 'none_selected' |
|
107 | - && $_REQUEST[ 'ee_messenger_filter_by' ] != 'all' |
|
105 | + isset($_REQUEST['ee_messenger_filter_by']) |
|
106 | + && $_REQUEST['ee_messenger_filter_by'] != 'none_selected' |
|
107 | + && $_REQUEST['ee_messenger_filter_by'] != 'all' |
|
108 | 108 | ) { |
109 | - $_where['MTP_messenger'] = $_REQUEST['ee_messenger_filter_by'] ; |
|
109 | + $_where['MTP_messenger'] = $_REQUEST['ee_messenger_filter_by']; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | if ( |
113 | - isset( $_REQUEST['ee_message_type_filter_by']) |
|
113 | + isset($_REQUEST['ee_message_type_filter_by']) |
|
114 | 114 | && $_REQUEST['ee_message_type_filter_by'] != 'none_selected' |
115 | 115 | ) { |
116 | 116 | $_where['MTP_message_type'] = $_REQUEST['ee_message_type_filter_by']; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $global = true, |
142 | 142 | $user_check = false |
143 | 143 | ) { |
144 | - $_where = $global ? array('MTP_is_global' => TRUE ) : array('MTP_is_global' => FALSE ); |
|
144 | + $_where = $global ? array('MTP_is_global' => TRUE) : array('MTP_is_global' => FALSE); |
|
145 | 145 | $_where['MTP_is_active'] = TRUE; |
146 | 146 | $_where = $this->_maybe_mtp_filters($_where); |
147 | 147 | |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | $_where['MTP_user_id'] = get_current_user_id(); |
157 | 157 | } |
158 | 158 | |
159 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
159 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
160 | 160 | |
161 | - return $count ? $this->count($query_params, 'GRP_ID', TRUE ) : $this->get_all($query_params); |
|
161 | + return $count ? $this->count($query_params, 'GRP_ID', TRUE) : $this->get_all($query_params); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | * @param bool $count |
174 | 174 | * @return mixed array on success, FALSE on fail |
175 | 175 | */ |
176 | - public function get_all_message_templates( $orderby = 'GRP_ID', $order = 'ASC', $limit = null, $count = false ) { |
|
176 | + public function get_all_message_templates($orderby = 'GRP_ID', $order = 'ASC', $limit = null, $count = false) { |
|
177 | 177 | $_where = $this->_maybe_mtp_filters(); |
178 | 178 | |
179 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
179 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
180 | 180 | |
181 | 181 | $r_templates = $count |
182 | - ? $this->count_deleted_and_undeleted($query_params, 'GRP_ID', TRUE ) |
|
183 | - : $this->get_all_deleted_and_undeleted( $query_params ); |
|
182 | + ? $this->count_deleted_and_undeleted($query_params, 'GRP_ID', TRUE) |
|
183 | + : $this->get_all_deleted_and_undeleted($query_params); |
|
184 | 184 | |
185 | 185 | return $r_templates; |
186 | 186 | } |
@@ -194,10 +194,10 @@ discard block |
||
194 | 194 | * @param array $query_params same as EEM_Base::get_all() |
195 | 195 | * @return EE_Message_Template_Group[] |
196 | 196 | */ |
197 | - public function get_all_custom_templates_by_event( $EVT_ID, $query_params = array() ) { |
|
198 | - $where = array_merge( $query_params, array( 'Event.EVT_ID' => $EVT_ID ) ); |
|
197 | + public function get_all_custom_templates_by_event($EVT_ID, $query_params = array()) { |
|
198 | + $where = array_merge($query_params, array('Event.EVT_ID' => $EVT_ID)); |
|
199 | 199 | return $this->get_all( |
200 | - array( $where ) |
|
200 | + array($where) |
|
201 | 201 | ); |
202 | 202 | } |
203 | 203 | |
@@ -222,13 +222,13 @@ discard block |
||
222 | 222 | $count = false, |
223 | 223 | $global = true |
224 | 224 | ) { |
225 | - $_where = $global ? array('MTP_is_global' => TRUE ) : array('MTP_is_global' => FALSE ); |
|
225 | + $_where = $global ? array('MTP_is_global' => TRUE) : array('MTP_is_global' => FALSE); |
|
226 | 226 | $_where['MTP_is_active'] = TRUE; |
227 | 227 | $_where = $this->_maybe_mtp_filters($_where); |
228 | 228 | |
229 | - $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit ); |
|
229 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
230 | 230 | |
231 | - return $count ? $this->count_deleted($query_params, 'GRP_ID', TRUE ) : $this->get_all_deleted( $query_params ); |
|
231 | + return $count ? $this->count_deleted($query_params, 'GRP_ID', TRUE) : $this->get_all_deleted($query_params); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -264,9 +264,9 @@ discard block |
||
264 | 264 | 'MTP_is_active' => $active |
265 | 265 | ); |
266 | 266 | |
267 | - $query_params = array( $_where, 'order_by' => array($orderby=>$order), 'limit' => $limit ); |
|
267 | + $query_params = array($_where, 'order_by' => array($orderby=>$order), 'limit' => $limit); |
|
268 | 268 | |
269 | - return $count ? $this->count($query_params, 'GRP_ID', TRUE ) : $this->get_all( $query_params ); |
|
269 | + return $count ? $this->count($query_params, 'GRP_ID', TRUE) : $this->get_all($query_params); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | 'MTP_is_global' => TRUE, |
301 | 301 | ); |
302 | 302 | |
303 | - if ( $active != 'all' ) { |
|
303 | + if ($active != 'all') { |
|
304 | 304 | $_where['MTP_is_active'] = $active; |
305 | 305 | } |
306 | 306 | |
307 | - $query_params = array( $_where, 'order_by' => array( $orderby => $order ), 'limit' => $limit ); |
|
307 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
308 | 308 | |
309 | - return $count ? $this->count( $query_params, 'GRP_ID', TRUE ) : $this->get_all( $query_params ); |
|
309 | + return $count ? $this->count($query_params, 'GRP_ID', TRUE) : $this->get_all($query_params); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param array $query_params same as EEM_Base->get_all() |
320 | 320 | * @return EE_Message_Template_Group[] |
321 | 321 | */ |
322 | - public function get_custom_message_template_by_m_and_mt( $messenger, $message_type, $query_params = array() ) { |
|
322 | + public function get_custom_message_template_by_m_and_mt($messenger, $message_type, $query_params = array()) { |
|
323 | 323 | return $this->get_all( |
324 | 324 | array_merge( |
325 | 325 | $query_params, |
@@ -356,14 +356,14 @@ discard block |
||
356 | 356 | $assembled_fields = array(); |
357 | 357 | |
358 | 358 | //let's loop through all the fields and set them up in the right format |
359 | - foreach ( $fields as $index => $value ) { |
|
359 | + foreach ($fields as $index => $value) { |
|
360 | 360 | // first let's figure out if the value['content'] in the current index is an array. |
361 | 361 | // If it is then this is special fields that are used in parsing special shortcodes (i.e. 'attendee_list'). |
362 | - if ( is_array($value['content']) ) { |
|
362 | + if (is_array($value['content'])) { |
|
363 | 363 | $assembled_fields[$value['name']] = $value['content']['main']; |
364 | 364 | //loop through the content and get the other fields. |
365 | - foreach ( $value['content'] as $name => $val ) { |
|
366 | - if ( $name == 'main' ) continue; |
|
365 | + foreach ($value['content'] as $name => $val) { |
|
366 | + if ($name == 'main') continue; |
|
367 | 367 | $assembled_fields[$name] = $val; |
368 | 368 | } |
369 | 369 | continue; |
@@ -375,15 +375,15 @@ discard block |
||
375 | 375 | |
376 | 376 | // now we've got the assembled_fields. |
377 | 377 | // We need to setup the string for the appropriate validator class and call that. |
378 | - $m_ref = ucwords( str_replace('_',' ', $messenger ) ); |
|
379 | - $m_ref = str_replace( ' ', '_', $m_ref ); |
|
380 | - $mt_ref = ucwords( str_replace('_', ' ', $message_type ) ); |
|
381 | - $mt_ref = str_replace( ' ', '_', $mt_ref ); |
|
378 | + $m_ref = ucwords(str_replace('_', ' ', $messenger)); |
|
379 | + $m_ref = str_replace(' ', '_', $m_ref); |
|
380 | + $mt_ref = ucwords(str_replace('_', ' ', $message_type)); |
|
381 | + $mt_ref = str_replace(' ', '_', $mt_ref); |
|
382 | 382 | |
383 | - $classname = 'EE_Messages_' . $m_ref . '_' . $mt_ref . '_Validator'; |
|
383 | + $classname = 'EE_Messages_'.$m_ref.'_'.$mt_ref.'_Validator'; |
|
384 | 384 | |
385 | - if ( !class_exists( $classname ) ) { |
|
386 | - $msg[] = __( 'The Validator class was unable to load', 'event_espresso'); |
|
385 | + if ( ! class_exists($classname)) { |
|
386 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
387 | 387 | $msg[] = sprintf( |
388 | 388 | __( |
389 | 389 | 'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | ), |
392 | 392 | $classname |
393 | 393 | ); |
394 | - throw new EE_Error( implode( '||', $msg ) ); |
|
394 | + throw new EE_Error(implode('||', $msg)); |
|
395 | 395 | } |
396 | 396 | |
397 | - $a = new ReflectionClass( $classname ); |
|
398 | - $_VLD = $a->newInstance( $assembled_fields, $context ); |
|
397 | + $a = new ReflectionClass($classname); |
|
398 | + $_VLD = $a->newInstance($assembled_fields, $context); |
|
399 | 399 | $result = $_VLD->validate(); |
400 | 400 | return $result; |
401 | 401 | } |
@@ -414,18 +414,18 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @return int count of updated records. |
416 | 416 | */ |
417 | - public function deactivate_message_template_groups_for( $messenger_names = array(), $message_type_names = array() ) { |
|
417 | + public function deactivate_message_template_groups_for($messenger_names = array(), $message_type_names = array()) { |
|
418 | 418 | $query_args = array(); |
419 | - if ( empty( $messenger_names ) && empty( $message_type_names ) ) { |
|
419 | + if (empty($messenger_names) && empty($message_type_names)) { |
|
420 | 420 | return 0; |
421 | 421 | } |
422 | - if ( ! empty( $messenger_names ) ) { |
|
423 | - $query_args[ 0 ][ 'MTP_messenger' ] = array( 'IN', (array) $messenger_names ); |
|
422 | + if ( ! empty($messenger_names)) { |
|
423 | + $query_args[0]['MTP_messenger'] = array('IN', (array) $messenger_names); |
|
424 | 424 | } |
425 | - if ( ! empty( $message_type_names ) ) { |
|
426 | - $query_args[ 0 ][ 'MTP_message_type' ] = array( 'IN', (array) $message_type_names ); |
|
425 | + if ( ! empty($message_type_names)) { |
|
426 | + $query_args[0]['MTP_message_type'] = array('IN', (array) $message_type_names); |
|
427 | 427 | } |
428 | - return $this->update( array( 'MTP_is_active' => false ), $query_args ); |
|
428 | + return $this->update(array('MTP_is_active' => false), $query_args); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 |
@@ -534,7 +534,7 @@ |
||
534 | 534 | *@param EE_Message $message |
535 | 535 | * @param EE_Messenger $messenger |
536 | 536 | * @param EE_message_type $message_type |
537 | - * @param $test_send |
|
537 | + * @param boolean $test_send |
|
538 | 538 | * @return bool true means all went well, false means, not so much. |
539 | 539 | */ |
540 | 540 | protected function _do_preview( EE_Message $message, EE_Messenger $messenger, EE_message_type $message_type, $test_send ) { |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param \EE_Message_Repository $message_repository |
73 | 73 | */ |
74 | - public function __construct( EE_Message_Repository $message_repository ) { |
|
75 | - $this->_batch_count = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 ); |
|
74 | + public function __construct(EE_Message_Repository $message_repository) { |
|
75 | + $this->_batch_count = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50); |
|
76 | 76 | $this->_rate_limit = $this->get_rate_limit(); |
77 | 77 | $this->_queue = $message_repository; |
78 | 78 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * use the messenger send method but typically is based on preview data. |
92 | 92 | * @return bool Whether the message was successfully added to the repository or not. |
93 | 93 | */ |
94 | - public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) { |
|
94 | + public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) { |
|
95 | 95 | $data['preview'] = $preview; |
96 | 96 | $data['test_send'] = $test_send; |
97 | - return $this->_queue->add( $message, $data ); |
|
97 | + return $this->_queue->add($message, $data); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param bool $persist This flag indicates whether to attempt to delete the object from the db as well. |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function remove( EE_Message $message, $persist = false ) { |
|
110 | - if ( $persist && $this->_queue->current() !== $message ) { |
|
109 | + public function remove(EE_Message $message, $persist = false) { |
|
110 | + if ($persist && $this->_queue->current() !== $message) { |
|
111 | 111 | //get pointer on right message |
112 | - if ( $this->_queue->has( $message ) ) { |
|
112 | + if ($this->_queue->has($message)) { |
|
113 | 113 | $this->_queue->rewind(); |
114 | - while( $this->_queue->valid() ) { |
|
115 | - if ( $this->_queue->current() === $message ) { |
|
114 | + while ($this->_queue->valid()) { |
|
115 | + if ($this->_queue->current() === $message) { |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | $this->_queue->next(); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | } |
124 | - return $persist ? $this->_queue->delete() : $this->_queue->remove( $message ); |
|
124 | + return $persist ? $this->_queue->delete() : $this->_queue->remove($message); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | * @return bool true if successfully retrieved batch, false no batch ready. |
162 | 162 | */ |
163 | 163 | public function get_batch_to_generate() { |
164 | - if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) { |
|
164 | + if ($this->is_locked(EE_Messages_Queue::action_generating)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | //lock batch generation to prevent race conditions. |
169 | - $this->lock_queue( EE_Messages_Queue::action_generating ); |
|
169 | + $this->lock_queue(EE_Messages_Queue::action_generating); |
|
170 | 170 | |
171 | 171 | $query_args = array( |
172 | 172 | // key 0 = where conditions |
173 | - 0 => array( 'STS_ID' => EEM_Message::status_incomplete ), |
|
173 | + 0 => array('STS_ID' => EEM_Message::status_incomplete), |
|
174 | 174 | 'order_by' => $this->_get_priority_orderby(), |
175 | 175 | 'limit' => $this->_batch_count |
176 | 176 | ); |
177 | - $messages = EEM_Message::instance()->get_all( $query_args ); |
|
177 | + $messages = EEM_Message::instance()->get_all($query_args); |
|
178 | 178 | |
179 | - if ( ! $messages ) { |
|
179 | + if ( ! $messages) { |
|
180 | 180 | return false; //nothing to generate |
181 | 181 | } |
182 | 182 | |
183 | - foreach ( $messages as $message ) { |
|
184 | - if ( $message instanceof EE_Message ) { |
|
183 | + foreach ($messages as $message) { |
|
184 | + if ($message instanceof EE_Message) { |
|
185 | 185 | $data = $message->all_extra_meta_array(); |
186 | - $this->add( $message, $data ); |
|
186 | + $this->add($message, $data); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | return true; |
@@ -206,34 +206,34 @@ discard block |
||
206 | 206 | * to assist with notifying user. |
207 | 207 | */ |
208 | 208 | public function get_to_send_batch_and_send() { |
209 | - if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) { |
|
209 | + if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | |
213 | - $this->lock_queue( EE_Messages_Queue::action_sending ); |
|
213 | + $this->lock_queue(EE_Messages_Queue::action_sending); |
|
214 | 214 | |
215 | 215 | $batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit; |
216 | 216 | |
217 | 217 | $query_args = array( |
218 | 218 | // key 0 = where conditions |
219 | - 0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ), |
|
219 | + 0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())), |
|
220 | 220 | 'order_by' => $this->_get_priority_orderby(), |
221 | 221 | 'limit' => $batch |
222 | 222 | ); |
223 | 223 | |
224 | - $messages_to_send = EEM_Message::instance()->get_all( $query_args ); |
|
224 | + $messages_to_send = EEM_Message::instance()->get_all($query_args); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | //any to send? |
228 | - if ( ! $messages_to_send ) { |
|
229 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
228 | + if ( ! $messages_to_send) { |
|
229 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
230 | 230 | return false; |
231 | 231 | } |
232 | 232 | |
233 | 233 | //add to queue. |
234 | - foreach ( $messages_to_send as $message ) { |
|
235 | - if ( $message instanceof EE_Message ) { |
|
236 | - $this->add( $message ); |
|
234 | + foreach ($messages_to_send as $message) { |
|
235 | + if ($message instanceof EE_Message) { |
|
236 | + $this->add($message); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $this->execute(); |
242 | 242 | |
243 | 243 | //release lock |
244 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
244 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param string $type The type of queue being locked. |
255 | 255 | */ |
256 | - public function lock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
257 | - set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) ); |
|
256 | + public function lock_queue($type = EE_Messages_Queue::action_generating) { |
|
257 | + set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param string $type The type of queue being unlocked. |
267 | 267 | */ |
268 | - public function unlock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
269 | - delete_transient( $this->_get_lock_key( $type ) ); |
|
268 | + public function unlock_queue($type = EE_Messages_Queue::action_generating) { |
|
269 | + delete_transient($this->_get_lock_key($type)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $type The type of lock. |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) { |
|
281 | - return '_ee_lock_' . $type; |
|
280 | + protected function _get_lock_key($type = EE_Messages_Queue::action_generating) { |
|
281 | + return '_ee_lock_'.$type; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param string $type The type of lock |
290 | 290 | * @return int time to expiry in seconds. |
291 | 291 | */ |
292 | - protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) { |
|
293 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type ); |
|
292 | + protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) { |
|
293 | + return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return int |
309 | 309 | */ |
310 | 310 | protected function _get_rate_limit_expiry() { |
311 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS ); |
|
311 | + return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return int |
320 | 320 | */ |
321 | 321 | protected function _default_rate_limit() { |
322 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 ); |
|
322 | + return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param string $type The type of lock being checked for. |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | - public function is_locked( $type = EE_Messages_Queue::action_generating ) { |
|
349 | - return (bool) get_transient( $this->_get_lock_key( $type ) ); |
|
348 | + public function is_locked($type = EE_Messages_Queue::action_generating) { |
|
349 | + return (bool) get_transient($this->_get_lock_key($type)); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | |
@@ -361,9 +361,9 @@ discard block |
||
361 | 361 | * @return int |
362 | 362 | */ |
363 | 363 | public function get_rate_limit() { |
364 | - if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) { |
|
364 | + if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) { |
|
365 | 365 | $rate_limit = $this->_default_rate_limit(); |
366 | - set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() ); |
|
366 | + set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key()); |
|
367 | 367 | } |
368 | 368 | return $rate_limit; |
369 | 369 | } |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | * This updates existing rate limit with the new limit which is the old minus the batch. |
376 | 376 | * @param int $batch_completed This sets the new rate limit based on the given batch that was completed. |
377 | 377 | */ |
378 | - public function set_rate_limit( $batch_completed ) { |
|
378 | + public function set_rate_limit($batch_completed) { |
|
379 | 379 | //first get the most up to date rate limit (in case its expired and reset) |
380 | 380 | $rate_limit = $this->get_rate_limit(); |
381 | 381 | $new_limit = $rate_limit - $batch_completed; |
382 | 382 | //updating the transient option directly to avoid resetting the expiry. |
383 | - update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit ); |
|
383 | + update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param string $task This indicates what type of request is going to be initiated. |
394 | 394 | * @param int $priority This indicates the priority that triggers initiating the request. |
395 | 395 | */ |
396 | - public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) { |
|
396 | + public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { |
|
397 | 397 | //determine what status is matched with the priority as part of the trigger conditions. |
398 | 398 | $status = $task == 'generate' |
399 | 399 | ? EEM_Message::status_incomplete |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | // always make sure we save because either this will get executed immediately on a separate request |
402 | 402 | // or remains in the queue for the regularly scheduled queue batch. |
403 | 403 | $this->save(); |
404 | - if ( $this->_queue->count_by_priority_and_status( $priority, $status ) ) { |
|
405 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task ); |
|
404 | + if ($this->_queue->count_by_priority_and_status($priority, $status)) { |
|
405 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -427,50 +427,50 @@ discard block |
||
427 | 427 | * Also, if the messenger is an request type messenger (or a preview), |
428 | 428 | * its entirely possible that the messenger will exit before |
429 | 429 | */ |
430 | - public function execute( $save = true, $sending_messenger = null, $by_priority = false ) { |
|
430 | + public function execute($save = true, $sending_messenger = null, $by_priority = false) { |
|
431 | 431 | $messages_sent = 0; |
432 | 432 | $this->_did_hook = array(); |
433 | 433 | $this->_queue->rewind(); |
434 | - while ( $this->_queue->valid() ) { |
|
434 | + while ($this->_queue->valid()) { |
|
435 | 435 | $error_messages = array(); |
436 | 436 | /** @type EE_Message $message */ |
437 | 437 | $message = $this->_queue->current(); |
438 | 438 | //if the message in the queue has a sent status, then skip |
439 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_sent() ) ) { |
|
439 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_sent())) { |
|
440 | 440 | continue; |
441 | 441 | } |
442 | 442 | //if $by_priority is set and does not match then continue; |
443 | - if ( $by_priority && $by_priority != $message->priority() ) { |
|
443 | + if ($by_priority && $by_priority != $message->priority()) { |
|
444 | 444 | continue; |
445 | 445 | } |
446 | 446 | //error checking |
447 | - if ( ! $message->valid_messenger() ) { |
|
447 | + if ( ! $message->valid_messenger()) { |
|
448 | 448 | $error_messages[] = sprintf( |
449 | - __( 'The %s messenger is not active at time of sending.', 'event_espresso' ), |
|
449 | + __('The %s messenger is not active at time of sending.', 'event_espresso'), |
|
450 | 450 | $message->messenger() |
451 | 451 | ); |
452 | 452 | } |
453 | - if ( ! $message->valid_message_type() ) { |
|
453 | + if ( ! $message->valid_message_type()) { |
|
454 | 454 | $error_messages[] = sprintf( |
455 | - __( 'The %s message type is not active at the time of sending.', 'event_espresso' ), |
|
455 | + __('The %s message type is not active at the time of sending.', 'event_espresso'), |
|
456 | 456 | $message->message_type() |
457 | 457 | ); |
458 | 458 | } |
459 | 459 | // if there was supposed to be a sending messenger for this message, but it was invalid/inactive, |
460 | 460 | // then it will instead be an EE_Error object, so let's check for that |
461 | - if ( $sending_messenger instanceof EE_Error ) { |
|
461 | + if ($sending_messenger instanceof EE_Error) { |
|
462 | 462 | $error_messages[] = $sending_messenger->getMessage(); |
463 | 463 | } |
464 | 464 | // if there are no errors, then let's process the message |
465 | - if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) { |
|
465 | + if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) { |
|
466 | 466 | $messages_sent++; |
467 | 467 | } |
468 | - $this->_set_error_message( $message, $error_messages ); |
|
468 | + $this->_set_error_message($message, $error_messages); |
|
469 | 469 | //add modified time |
470 | - $message->set_modified( time() ); |
|
470 | + $message->set_modified(time()); |
|
471 | 471 | $this->_queue->next(); |
472 | 472 | } |
473 | - if ( $save ) { |
|
473 | + if ($save) { |
|
474 | 474 | $this->save(); |
475 | 475 | } |
476 | 476 | return $messages_sent; |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * @param mixed $sending_messenger (optional) |
486 | 486 | * @return bool |
487 | 487 | */ |
488 | - protected function _process_message( EE_Message $message, $sending_messenger = null ) { |
|
488 | + protected function _process_message(EE_Message $message, $sending_messenger = null) { |
|
489 | 489 | // these *should* have been validated in the execute() method above |
490 | 490 | $messenger = $message->messenger_object(); |
491 | 491 | $message_type = $message->message_type_object(); |
@@ -495,20 +495,20 @@ discard block |
||
495 | 495 | && $messenger instanceof EE_messenger |
496 | 496 | && $sending_messenger->name != $messenger->name |
497 | 497 | ) { |
498 | - $messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
498 | + $messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
499 | 499 | $messenger = $sending_messenger; |
500 | 500 | } |
501 | 501 | // send using messenger, but double check objects |
502 | - if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) { |
|
502 | + if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) { |
|
503 | 503 | //set hook for message type (but only if not using another messenger to send). |
504 | - if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) { |
|
505 | - $message_type->do_messenger_hooks( $messenger ); |
|
506 | - $this->_did_hook[ $message_type->name ] = 1; |
|
504 | + if ( ! isset($this->_did_hook[$message_type->name])) { |
|
505 | + $message_type->do_messenger_hooks($messenger); |
|
506 | + $this->_did_hook[$message_type->name] = 1; |
|
507 | 507 | } |
508 | 508 | //if preview then use preview method |
509 | 509 | return $this->_queue->is_preview() |
510 | - ? $this->_do_preview( $message, $messenger, $message_type, $this->_queue->is_test_send() ) |
|
511 | - : $this->_do_send( $message, $messenger, $message_type ); |
|
510 | + ? $this->_do_preview($message, $messenger, $message_type, $this->_queue->is_test_send()) |
|
511 | + : $this->_do_send($message, $messenger, $message_type); |
|
512 | 512 | } |
513 | 513 | return false; |
514 | 514 | } |
@@ -526,12 +526,12 @@ discard block |
||
526 | 526 | * @param array $status Stati to check for in queue |
527 | 527 | * @return int Count of EE_Message's matching the given status. |
528 | 528 | */ |
529 | - public function count_STS_in_queue( $status ) { |
|
529 | + public function count_STS_in_queue($status) { |
|
530 | 530 | $count = 0; |
531 | - $status = is_array( $status ) ? $status : array( $status ); |
|
531 | + $status = is_array($status) ? $status : array($status); |
|
532 | 532 | $this->_queue->rewind(); |
533 | - foreach( $this->_queue as $message ) { |
|
534 | - if ( in_array( $message->STS_ID(), $status ) ) { |
|
533 | + foreach ($this->_queue as $message) { |
|
534 | + if (in_array($message->STS_ID(), $status)) { |
|
535 | 535 | $count++; |
536 | 536 | } |
537 | 537 | } |
@@ -548,15 +548,15 @@ discard block |
||
548 | 548 | * @param $test_send |
549 | 549 | * @return bool true means all went well, false means, not so much. |
550 | 550 | */ |
551 | - protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
|
552 | - if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) { |
|
553 | - if ( ! $test_send ) { |
|
554 | - $message->set_content( $preview ); |
|
551 | + protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) { |
|
552 | + if ($preview = $messenger->get_preview($message, $message_type, $test_send)) { |
|
553 | + if ( ! $test_send) { |
|
554 | + $message->set_content($preview); |
|
555 | 555 | } |
556 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
556 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
557 | 557 | return true; |
558 | 558 | } else { |
559 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
559 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
560 | 560 | return false; |
561 | 561 | } |
562 | 562 | } |
@@ -572,12 +572,12 @@ discard block |
||
572 | 572 | * @param EE_message_type $message_type |
573 | 573 | * @return bool true means all went well, false means, not so much. |
574 | 574 | */ |
575 | - protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) { |
|
576 | - if ( $messenger->send_message( $message, $message_type ) ) { |
|
577 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
575 | + protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) { |
|
576 | + if ($messenger->send_message($message, $message_type)) { |
|
577 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
578 | 578 | return true; |
579 | 579 | } else { |
580 | - $message->set_STS_ID( EEM_Message::status_retry ); |
|
580 | + $message->set_STS_ID(EEM_Message::status_retry); |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | } |
@@ -591,21 +591,21 @@ discard block |
||
591 | 591 | * @param EE_Message $message |
592 | 592 | * @param array $error_messages the response from the messenger. |
593 | 593 | */ |
594 | - protected function _set_error_message( EE_Message $message, $error_messages ) { |
|
594 | + protected function _set_error_message(EE_Message $message, $error_messages) { |
|
595 | 595 | $error_messages = (array) $error_messages; |
596 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending() ) ) { |
|
596 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) { |
|
597 | 597 | $notices = EE_Error::has_notices(); |
598 | - $error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' ); |
|
599 | - if ( $notices === 1 ) { |
|
598 | + $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); |
|
599 | + if ($notices === 1) { |
|
600 | 600 | $notices = EE_Error::get_vanilla_notices(); |
601 | - $notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array(); |
|
602 | - $error_messages[] = implode( "\n", $notices['errors'] ); |
|
601 | + $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); |
|
602 | + $error_messages[] = implode("\n", $notices['errors']); |
|
603 | 603 | } |
604 | 604 | } |
605 | - if ( count( $error_messages ) > 0 ) { |
|
606 | - $msg = __( 'Message was not executed successfully.', 'event_espresso' ); |
|
607 | - $msg = $msg . "\n" . implode( "\n", $error_messages ); |
|
608 | - $message->set_error_message( $msg ); |
|
605 | + if (count($error_messages) > 0) { |
|
606 | + $msg = __('Message was not executed successfully.', 'event_espresso'); |
|
607 | + $msg = $msg."\n".implode("\n", $error_messages); |
|
608 | + $message->set_error_message($msg); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 |
@@ -66,7 +66,7 @@ |
||
66 | 66 | /** |
67 | 67 | * @access public |
68 | 68 | * @param array $props_n_values |
69 | - * @return mixed |
|
69 | + * @return EE_Message |
|
70 | 70 | */ |
71 | 71 | public static function create( $props_n_values = array() ) { |
72 | 72 | /** @type EE_Message_Factory $Message_Factory */ |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @param \EE_Message_Resource_Manager $Message_Resource_Manager |
54 | 54 | * @return \EE_Message_Factory instance |
55 | 55 | */ |
56 | - public static function instance( EE_Message_Resource_Manager $Message_Resource_Manager ) { |
|
56 | + public static function instance(EE_Message_Resource_Manager $Message_Resource_Manager) { |
|
57 | 57 | // check if class object is instantiated, and instantiated properly |
58 | - if ( ! self::$_instance instanceof EE_Message_Factory ) { |
|
59 | - self::$_instance = new EE_Message_Factory( $Message_Resource_Manager ); |
|
58 | + if ( ! self::$_instance instanceof EE_Message_Factory) { |
|
59 | + self::$_instance = new EE_Message_Factory($Message_Resource_Manager); |
|
60 | 60 | } |
61 | 61 | return self::$_instance; |
62 | 62 | } |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | * @param array $props_n_values |
69 | 69 | * @return mixed |
70 | 70 | */ |
71 | - public static function create( $props_n_values = array() ) { |
|
71 | + public static function create($props_n_values = array()) { |
|
72 | 72 | /** @type EE_Message_Factory $Message_Factory */ |
73 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
74 | - return $Message_Factory->_create( $props_n_values ); |
|
73 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
74 | + return $Message_Factory->_create($props_n_values); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * @return \EE_Message |
83 | 83 | * @throws \EE_Error |
84 | 84 | */ |
85 | - public static function set_messenger_and_message_type( EE_Message $message ) { |
|
85 | + public static function set_messenger_and_message_type(EE_Message $message) { |
|
86 | 86 | /** @type EE_Message_Factory $Message_Factory */ |
87 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
88 | - return $Message_Factory->_set_messenger_and_message_type( $message ); |
|
87 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
88 | + return $Message_Factory->_set_messenger_and_message_type($message); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * @return \EE_Message |
97 | 97 | * @throws \EE_Error |
98 | 98 | */ |
99 | - public static function set_messenger( EE_Message $message ) { |
|
99 | + public static function set_messenger(EE_Message $message) { |
|
100 | 100 | /** @type EE_Message_Factory $Message_Factory */ |
101 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
102 | - return $Message_Factory->_set_messenger( $message ); |
|
101 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
102 | + return $Message_Factory->_set_messenger($message); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * @return \EE_Message |
111 | 111 | * @throws \EE_Error |
112 | 112 | */ |
113 | - public static function set_message_type( EE_Message $message ) { |
|
113 | + public static function set_message_type(EE_Message $message) { |
|
114 | 114 | /** @type EE_Message_Factory $Message_Factory */ |
115 | - $Message_Factory = EE_Registry::instance()->load_lib( 'Message_Factory' ); |
|
116 | - return $Message_Factory->_set_message_type( $message ); |
|
115 | + $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory'); |
|
116 | + return $Message_Factory->_set_message_type($message); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | * @return \EE_Message |
125 | 125 | * @throws \EE_Error |
126 | 126 | */ |
127 | - protected function _create( $props_n_values = array() ) { |
|
127 | + protected function _create($props_n_values = array()) { |
|
128 | 128 | $new_instance = false; |
129 | - if ( ! empty( $props_n_values['MSG_ID'] ) ) { |
|
130 | - $message = EE_Message::new_instance_from_db( $props_n_values ); |
|
129 | + if ( ! empty($props_n_values['MSG_ID'])) { |
|
130 | + $message = EE_Message::new_instance_from_db($props_n_values); |
|
131 | 131 | } else { |
132 | - $message = EE_Message::new_instance( $props_n_values ); |
|
132 | + $message = EE_Message::new_instance($props_n_values); |
|
133 | 133 | $new_instance = true; |
134 | 134 | } |
135 | - return $this->_set_messenger_and_message_type( $message, $new_instance ); |
|
135 | + return $this->_set_messenger_and_message_type($message, $new_instance); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | * @return \EE_Message |
145 | 145 | * @throws \EE_Error |
146 | 146 | */ |
147 | - protected function _set_messenger_and_message_type( EE_Message $message, $new_instance = false ) { |
|
148 | - $message = $this->_set_messenger( $message ); |
|
149 | - $message = $this->_set_message_type( $message, $new_instance ); |
|
147 | + protected function _set_messenger_and_message_type(EE_Message $message, $new_instance = false) { |
|
148 | + $message = $this->_set_messenger($message); |
|
149 | + $message = $this->_set_message_type($message, $new_instance); |
|
150 | 150 | return $message; |
151 | 151 | } |
152 | 152 | |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | * @return \EE_Message |
159 | 159 | * @throws \EE_Error |
160 | 160 | */ |
161 | - protected function _set_messenger( EE_Message $message ) { |
|
162 | - $messenger = $this->_message_resource_manager->get_messenger( $message->messenger() ); |
|
163 | - if ( $messenger instanceof EE_messenger ) { |
|
164 | - $message->set_messenger_object( $messenger ); |
|
161 | + protected function _set_messenger(EE_Message $message) { |
|
162 | + $messenger = $this->_message_resource_manager->get_messenger($message->messenger()); |
|
163 | + if ($messenger instanceof EE_messenger) { |
|
164 | + $message->set_messenger_object($messenger); |
|
165 | 165 | } |
166 | 166 | return $message; |
167 | 167 | } |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | * @return \EE_Message |
176 | 176 | * @throws \EE_Error |
177 | 177 | */ |
178 | - protected function _set_message_type( EE_Message $message, $new_instance = false ) { |
|
179 | - $message_type = $this->_message_resource_manager->get_message_type( $message->message_type() ); |
|
180 | - if ( $message_type instanceof EE_message_type ) { |
|
181 | - $message->set_message_type_object( $message_type, $new_instance ); |
|
178 | + protected function _set_message_type(EE_Message $message, $new_instance = false) { |
|
179 | + $message_type = $this->_message_resource_manager->get_message_type($message->message_type()); |
|
180 | + if ($message_type instanceof EE_message_type) { |
|
181 | + $message->set_message_type_object($message_type, $new_instance); |
|
182 | 182 | } |
183 | 183 | return $message; |
184 | 184 | } |
@@ -200,7 +200,7 @@ |
||
200 | 200 | * generates an EE_Message using the supplied arguments and some defaults |
201 | 201 | * |
202 | 202 | * @param array $properties |
203 | - * @return string |
|
203 | + * @return EE_Message |
|
204 | 204 | */ |
205 | 205 | protected function _generate_message( $properties = array() ) { |
206 | 206 | $message = EE_Message_Factory::create( |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | public function __construct( |
106 | 106 | $messenger_name, |
107 | 107 | $message_type_name, |
108 | - $data = array(), |
|
108 | + $data = array(), |
|
109 | 109 | $context = '', |
110 | 110 | $preview = false, |
111 | 111 | $status = EEM_Message::status_incomplete |
112 | 112 | ) { |
113 | - $this->_messenger_name = $messenger_name; |
|
114 | - $this->_message_type_name = $message_type_name; |
|
115 | - $this->_data = is_array( $data ) ? $data : array( $data ); |
|
113 | + $this->_messenger_name = $messenger_name; |
|
114 | + $this->_message_type_name = $message_type_name; |
|
115 | + $this->_data = is_array($data) ? $data : array($data); |
|
116 | 116 | $this->_context = $context; |
117 | 117 | $this->_preview = $preview; |
118 | 118 | $this->_status = $status; |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | /** |
171 | 171 | * @param boolean $preview |
172 | 172 | */ |
173 | - public function set_preview( $preview ) { |
|
174 | - $this->_preview = filter_var( $preview, FILTER_VALIDATE_BOOLEAN ); |
|
173 | + public function set_preview($preview) { |
|
174 | + $this->_preview = filter_var($preview, FILTER_VALIDATE_BOOLEAN); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param array $properties |
203 | 203 | * @return string |
204 | 204 | */ |
205 | - protected function _generate_message( $properties = array() ) { |
|
205 | + protected function _generate_message($properties = array()) { |
|
206 | 206 | $message = EE_Message_Factory::create( |
207 | 207 | array_merge( |
208 | 208 | array( |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | ); |
217 | 217 | // validate the message, and if it's good, set some properties |
218 | 218 | try { |
219 | - $message->is_valid_for_sending_or_generation( true ); |
|
219 | + $message->is_valid_for_sending_or_generation(true); |
|
220 | 220 | $this->_valid = true; |
221 | 221 | $this->_messenger = $message->messenger_object(); |
222 | 222 | $this->_message_type = $message->message_type_object(); |
223 | 223 | $this->_send_now = $message->send_now(); |
224 | - } catch ( Exception $e ) { |
|
224 | + } catch (Exception $e) { |
|
225 | 225 | $this->_valid = false; |
226 | 226 | $this->_error_msg[] = $e->getMessage(); |
227 | 227 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function get_EE_Message() { |
239 | 239 | // already set ? |
240 | - if ( $this->_message instanceof EE_Message ) { |
|
240 | + if ($this->_message instanceof EE_Message) { |
|
241 | 241 | return $this->_message; |
242 | 242 | } |
243 | 243 | // no? then let's create one |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | * @param bool $preview Used to indicate that the preview data handler is to be returned. |
256 | 256 | * @return string |
257 | 257 | */ |
258 | - public function get_data_handler_class_name( $preview = false ) { |
|
259 | - if ( $this->_data_handler_class_name === '' && $this->valid() ) { |
|
260 | - $ref = $preview ? 'Preview' : $this->_message_type->get_data_handler( $this->_data ); |
|
258 | + public function get_data_handler_class_name($preview = false) { |
|
259 | + if ($this->_data_handler_class_name === '' && $this->valid()) { |
|
260 | + $ref = $preview ? 'Preview' : $this->_message_type->get_data_handler($this->_data); |
|
261 | 261 | //make sure internal data is updated. |
262 | 262 | $this->_data = $this->_message_type->get_data(); |
263 | 263 | |
264 | 264 | //verify |
265 | - $this->_data_handler_class_name = EE_Message_To_Generate::verify_and_retrieve_class_name_for_data_handler_reference( $ref ); |
|
266 | - if ( $this->_data_handler_class_name === '' ) { |
|
265 | + $this->_data_handler_class_name = EE_Message_To_Generate::verify_and_retrieve_class_name_for_data_handler_reference($ref); |
|
266 | + if ($this->_data_handler_class_name === '') { |
|
267 | 267 | $this->_valid = false; |
268 | 268 | } |
269 | 269 | } |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | * @param string $data_handler_reference |
280 | 280 | * @return string |
281 | 281 | */ |
282 | - public static function verify_and_retrieve_class_name_for_data_handler_reference( $data_handler_reference ) { |
|
283 | - $class_name = 'EE_Messages_' . $data_handler_reference . '_incoming_data'; |
|
284 | - if ( ! class_exists( $class_name ) ) { |
|
282 | + public static function verify_and_retrieve_class_name_for_data_handler_reference($data_handler_reference) { |
|
283 | + $class_name = 'EE_Messages_'.$data_handler_reference.'_incoming_data'; |
|
284 | + if ( ! class_exists($class_name)) { |
|
285 | 285 | EE_Error::add_error( |
286 | 286 | sprintf( |
287 | 287 | __( |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | |
197 | 197 | |
198 | 198 | /** |
199 | - * detect_if_activation_or_upgrade |
|
200 | - * |
|
201 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
202 | - * and either setting up the DB or setting up maintenance mode etc. |
|
203 | - * |
|
204 | - * @access public |
|
205 | - * @return void |
|
206 | - */ |
|
199 | + * detect_if_activation_or_upgrade |
|
200 | + * |
|
201 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
202 | + * and either setting up the DB or setting up maintenance mode etc. |
|
203 | + * |
|
204 | + * @access public |
|
205 | + * @return void |
|
206 | + */ |
|
207 | 207 | public function detect_if_activation_or_upgrade() { |
208 | 208 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
209 | 209 | |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | $query_params = array( 'page' => 'espresso_about' ); |
513 | 513 | |
514 | 514 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
515 | - $query_params['new_activation'] = TRUE; |
|
515 | + $query_params['new_activation'] = TRUE; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
519 | - $query_params['reactivation'] = TRUE; |
|
519 | + $query_params['reactivation'] = TRUE; |
|
520 | 520 | } |
521 | 521 | $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
522 | 522 | wp_safe_redirect( $url ); |
@@ -619,11 +619,11 @@ discard block |
||
619 | 619 | |
620 | 620 | |
621 | 621 | /** |
622 | - * _incompatible_addon_error |
|
623 | - * |
|
624 | - * @access public |
|
625 | - * @return void |
|
626 | - */ |
|
622 | + * _incompatible_addon_error |
|
623 | + * |
|
624 | + * @access public |
|
625 | + * @return void |
|
626 | + */ |
|
627 | 627 | private function _incompatible_addon_error() { |
628 | 628 | // get array of classes hooking into here |
629 | 629 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
@@ -745,14 +745,14 @@ discard block |
||
745 | 745 | |
746 | 746 | |
747 | 747 | /** |
748 | - * load_controllers |
|
749 | - * |
|
750 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
751 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
752 | - * |
|
753 | - * @access public |
|
754 | - * @return void |
|
755 | - */ |
|
748 | + * load_controllers |
|
749 | + * |
|
750 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
751 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
752 | + * |
|
753 | + * @access public |
|
754 | + * @return void |
|
755 | + */ |
|
756 | 756 | public function load_controllers() { |
757 | 757 | do_action( 'AHEE__EE_System__load_controllers__start' ); |
758 | 758 | // let's get it started |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | |
770 | 770 | |
771 | 771 | /** |
772 | - * core_loaded_and_ready |
|
773 | - * |
|
774 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
775 | - * |
|
776 | - * @access public |
|
777 | - * @return void |
|
778 | - */ |
|
772 | + * core_loaded_and_ready |
|
773 | + * |
|
774 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
775 | + * |
|
776 | + * @access public |
|
777 | + * @return void |
|
778 | + */ |
|
779 | 779 | public function core_loaded_and_ready() { |
780 | 780 | do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
781 | 781 | do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | |
787 | 787 | |
788 | 788 | /** |
789 | - * initialize |
|
790 | - * |
|
791 | - * this is the best place to begin initializing client code |
|
792 | - * |
|
793 | - * @access public |
|
794 | - * @return void |
|
795 | - */ |
|
789 | + * initialize |
|
790 | + * |
|
791 | + * this is the best place to begin initializing client code |
|
792 | + * |
|
793 | + * @access public |
|
794 | + * @return void |
|
795 | + */ |
|
796 | 796 | public function initialize() { |
797 | 797 | do_action( 'AHEE__EE_System__initialize' ); |
798 | 798 | } |
@@ -800,13 +800,13 @@ discard block |
||
800 | 800 | |
801 | 801 | |
802 | 802 | /** |
803 | - * initialize_last |
|
804 | - * |
|
805 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
806 | - * |
|
807 | - * @access public |
|
808 | - * @return void |
|
809 | - */ |
|
803 | + * initialize_last |
|
804 | + * |
|
805 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
806 | + * |
|
807 | + * @access public |
|
808 | + * @return void |
|
809 | + */ |
|
810 | 810 | public function initialize_last() { |
811 | 811 | do_action( 'AHEE__EE_System__initialize_last' ); |
812 | 812 | } |
@@ -815,14 +815,14 @@ discard block |
||
815 | 815 | |
816 | 816 | |
817 | 817 | /** |
818 | - * set_hooks_for_shortcodes_modules_and_addons |
|
819 | - * |
|
820 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
821 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
822 | - * |
|
823 | - * @access public |
|
824 | - * @return void |
|
825 | - */ |
|
818 | + * set_hooks_for_shortcodes_modules_and_addons |
|
819 | + * |
|
820 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
821 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
822 | + * |
|
823 | + * @access public |
|
824 | + * @return void |
|
825 | + */ |
|
826 | 826 | public function set_hooks_for_shortcodes_modules_and_addons() { |
827 | 827 | // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
828 | 828 | } |
@@ -831,13 +831,13 @@ discard block |
||
831 | 831 | |
832 | 832 | |
833 | 833 | /** |
834 | - * do_not_cache |
|
835 | - * |
|
836 | - * sets no cache headers and defines no cache constants for WP plugins |
|
837 | - * |
|
838 | - * @access public |
|
839 | - * @return void |
|
840 | - */ |
|
834 | + * do_not_cache |
|
835 | + * |
|
836 | + * sets no cache headers and defines no cache constants for WP plugins |
|
837 | + * |
|
838 | + * @access public |
|
839 | + * @return void |
|
840 | + */ |
|
841 | 841 | public static function do_not_cache() { |
842 | 842 | // set no cache constants |
843 | 843 | if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | //Current post |
957 | 957 | global $post; |
958 | 958 | |
959 | - if ( $this->registry->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
959 | + if ( $this->registry->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
960 | 960 | //Events Edit Current Event |
961 | 961 | $admin_bar->add_menu(array( |
962 | 962 | 'id' => 'espresso-toolbar-events-edit', |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | * @param \EE_Registry $Registry |
89 | 89 | * @return \EE_System |
90 | 90 | */ |
91 | - public static function instance( EE_Registry $Registry = null ) { |
|
91 | + public static function instance(EE_Registry $Registry = null) { |
|
92 | 92 | // check if class object is instantiated |
93 | - if ( ! self::$_instance instanceof EE_System ) { |
|
94 | - self::$_instance = new self( $Registry ); |
|
93 | + if ( ! self::$_instance instanceof EE_System) { |
|
94 | + self::$_instance = new self($Registry); |
|
95 | 95 | } |
96 | 96 | return self::$_instance; |
97 | 97 | } |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | * resets the instance and returns it |
102 | 102 | * @return EE_System |
103 | 103 | */ |
104 | - public static function reset(){ |
|
104 | + public static function reset() { |
|
105 | 105 | self::$_instance->_req_type = NULL; |
106 | 106 | //we need to reset the migration manager in order for it to detect DMSs properly |
107 | 107 | EE_Data_Migration_Manager::reset(); |
108 | 108 | //make sure none of the old hooks are left hanging around |
109 | - remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
109 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
110 | 110 | self::instance()->detect_activations_or_upgrades(); |
111 | 111 | self::instance()->perform_activations_upgrades_and_migrations(); |
112 | 112 | return self::instance(); |
@@ -122,28 +122,28 @@ discard block |
||
122 | 122 | * @access private |
123 | 123 | * @param \EE_Registry $Registry |
124 | 124 | */ |
125 | - private function __construct( EE_Registry $Registry ) { |
|
125 | + private function __construct(EE_Registry $Registry) { |
|
126 | 126 | $this->registry = $Registry; |
127 | - do_action( 'AHEE__EE_System__construct__begin', $this ); |
|
127 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
128 | 128 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
129 | - add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'load_espresso_addons' ) ); |
|
129 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
130 | 130 | // when an ee addon is activated, we want to call the core hook(s) again |
131 | 131 | // because the newly-activated addon didn't get a chance to run at all |
132 | - add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 ); |
|
132 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
133 | 133 | // detect whether install or upgrade |
134 | - add_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array( $this, 'detect_activations_or_upgrades' ), 3 ); |
|
134 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), 3); |
|
135 | 135 | // load EE_Config, EE_Textdomain, etc |
136 | - add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 5 ); |
|
136 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
137 | 137 | // load EE_Config, EE_Textdomain, etc |
138 | - add_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
138 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
139 | 139 | // you wanna get going? I wanna get going... let's get going! |
140 | - add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 9 ); |
|
140 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
141 | 141 | //other housekeeping |
142 | 142 | //exclude EE critical pages from wp_list_pages |
143 | - add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 ); |
|
143 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
144 | 144 | // ALL EE Addons should use the following hook point to attach their initial setup too |
145 | 145 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
146 | - do_action( 'AHEE__EE_System__construct__complete', $this ); |
|
146 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -163,30 +163,30 @@ discard block |
||
163 | 163 | public function load_espresso_addons() { |
164 | 164 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
165 | 165 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
166 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' ); |
|
166 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
167 | 167 | //load and setup EE_Capabilities |
168 | - $this->registry->load_core( 'Capabilities' ); |
|
168 | + $this->registry->load_core('Capabilities'); |
|
169 | 169 | //caps need to be initialized on every request so that capability maps are set. |
170 | 170 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
171 | 171 | $this->registry->CAP->init_caps(); |
172 | - do_action( 'AHEE__EE_System__load_espresso_addons' ); |
|
172 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
173 | 173 | //if the WP API basic auth plugin isn't already loaded, load it now. |
174 | 174 | //We want it for mobile apps. Just include the entire plugin |
175 | 175 | //also, don't load the basic auth when a plugin is getting activated, because |
176 | 176 | //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
177 | 177 | //and causes a fatal error |
178 | - if( !function_exists( 'json_basic_auth_handler' ) |
|
179 | - && ! function_exists( 'json_basic_auth_error' ) |
|
178 | + if ( ! function_exists('json_basic_auth_handler') |
|
179 | + && ! function_exists('json_basic_auth_error') |
|
180 | 180 | && ! ( |
181 | - isset( $_GET[ 'action'] ) |
|
182 | - && in_array( $_GET[ 'action' ], array( 'activate', 'activate-selected' ) ) |
|
181 | + isset($_GET['action']) |
|
182 | + && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
183 | 183 | ) |
184 | 184 | && ! ( |
185 | - isset( $_GET['activate' ] ) |
|
186 | - && $_GET['activate' ] === 'true' |
|
185 | + isset($_GET['activate']) |
|
186 | + && $_GET['activate'] === 'true' |
|
187 | 187 | ) |
188 | 188 | ) { |
189 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
189 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | * @access public |
203 | 203 | * @return void |
204 | 204 | */ |
205 | - public function detect_activations_or_upgrades(){ |
|
205 | + public function detect_activations_or_upgrades() { |
|
206 | 206 | //first off: let's make sure to handle core |
207 | 207 | $this->detect_if_activation_or_upgrade(); |
208 | - foreach($this->registry->addons as $addon){ |
|
208 | + foreach ($this->registry->addons as $addon) { |
|
209 | 209 | //detect teh request type for that addon |
210 | 210 | $addon->detect_activation_or_upgrade(); |
211 | 211 | } |
@@ -226,41 +226,41 @@ discard block |
||
226 | 226 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
227 | 227 | |
228 | 228 | // load M-Mode class |
229 | - $this->registry->load_core( 'Maintenance_Mode' ); |
|
229 | + $this->registry->load_core('Maintenance_Mode'); |
|
230 | 230 | // check if db has been updated, or if its a brand-new installation |
231 | 231 | |
232 | 232 | $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
233 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
233 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
234 | 234 | //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
235 | 235 | |
236 | - switch($request_type){ |
|
236 | + switch ($request_type) { |
|
237 | 237 | case EE_System::req_type_new_activation: |
238 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' ); |
|
239 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
238 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
239 | + $this->_handle_core_version_change($espresso_db_update); |
|
240 | 240 | break; |
241 | 241 | case EE_System::req_type_reactivation: |
242 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' ); |
|
243 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
242 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
243 | + $this->_handle_core_version_change($espresso_db_update); |
|
244 | 244 | break; |
245 | 245 | case EE_System::req_type_upgrade: |
246 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' ); |
|
246 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
247 | 247 | //migrations may be required now that we've upgraded |
248 | 248 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
249 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
249 | + $this->_handle_core_version_change($espresso_db_update); |
|
250 | 250 | // echo "done upgrade";die; |
251 | 251 | break; |
252 | 252 | case EE_System::req_type_downgrade: |
253 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' ); |
|
253 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
254 | 254 | //its possible migrations are no longer required |
255 | 255 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
256 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
256 | + $this->_handle_core_version_change($espresso_db_update); |
|
257 | 257 | break; |
258 | 258 | case EE_System::req_type_normal: |
259 | 259 | default: |
260 | 260 | // $this->_maybe_redirect_to_ee_about(); |
261 | 261 | break; |
262 | 262 | } |
263 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' ); |
|
263 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | * initializing the database later during the request |
269 | 269 | * @param array $espresso_db_update |
270 | 270 | */ |
271 | - protected function _handle_core_version_change( $espresso_db_update ){ |
|
272 | - $this->update_list_of_installed_versions( $espresso_db_update ); |
|
271 | + protected function _handle_core_version_change($espresso_db_update) { |
|
272 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
273 | 273 | //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
274 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )); |
|
274 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -286,44 +286,44 @@ discard block |
||
286 | 286 | * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table |
287 | 287 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
288 | 288 | */ |
289 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null){ |
|
290 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update ); |
|
291 | - if( ! $espresso_db_update){ |
|
292 | - $espresso_db_update = get_option( 'espresso_db_update' ); |
|
289 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) { |
|
290 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
291 | + if ( ! $espresso_db_update) { |
|
292 | + $espresso_db_update = get_option('espresso_db_update'); |
|
293 | 293 | } |
294 | 294 | // check that option is an array |
295 | - if( ! is_array( $espresso_db_update )) { |
|
295 | + if ( ! is_array($espresso_db_update)) { |
|
296 | 296 | // if option is FALSE, then it never existed |
297 | - if ( $espresso_db_update === FALSE ) { |
|
297 | + if ($espresso_db_update === FALSE) { |
|
298 | 298 | // make $espresso_db_update an array and save option with autoload OFF |
299 | - $espresso_db_update = array(); |
|
300 | - add_option( 'espresso_db_update', $espresso_db_update, '', 'no' ); |
|
299 | + $espresso_db_update = array(); |
|
300 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
301 | 301 | } else { |
302 | 302 | // option is NOT FALSE but also is NOT an array, so make it an array and save it |
303 | - $espresso_db_update = array( $espresso_db_update=>array() ); |
|
304 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
303 | + $espresso_db_update = array($espresso_db_update=>array()); |
|
304 | + update_option('espresso_db_update', $espresso_db_update); |
|
305 | 305 | } |
306 | - }else{ |
|
306 | + } else { |
|
307 | 307 | $corrected_db_update = array(); |
308 | 308 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
309 | - foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
|
310 | - if(is_int($should_be_version_string) && ! is_array($should_be_array)){ |
|
309 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
310 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
311 | 311 | //the key is an int, and the value IS NOT an array |
312 | 312 | //so it must be numerically-indexed, where values are versions installed... |
313 | 313 | //fix it! |
314 | 314 | $version_string = $should_be_array; |
315 | 315 | $corrected_db_update[$version_string] = array('unknown-date'); |
316 | - }else{ |
|
316 | + } else { |
|
317 | 317 | //ok it checks out |
318 | 318 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
319 | 319 | } |
320 | 320 | } |
321 | 321 | $espresso_db_update = $corrected_db_update; |
322 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
322 | + update_option('espresso_db_update', $espresso_db_update); |
|
323 | 323 | |
324 | 324 | } |
325 | 325 | |
326 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update ); |
|
326 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
327 | 327 | return $espresso_db_update; |
328 | 328 | } |
329 | 329 | |
@@ -343,34 +343,34 @@ discard block |
||
343 | 343 | * so we prefer to only do it when necessary |
344 | 344 | * @return void |
345 | 345 | */ |
346 | - public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){ |
|
346 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) { |
|
347 | 347 | $request_type = $this->detect_req_type(); |
348 | 348 | //only initialize system if we're not in maintenance mode. |
349 | - if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
350 | - update_option( 'ee_flush_rewrite_rules', TRUE ); |
|
349 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
350 | + update_option('ee_flush_rewrite_rules', TRUE); |
|
351 | 351 | |
352 | - if( $verify_schema ) { |
|
352 | + if ($verify_schema) { |
|
353 | 353 | EEH_Activation::initialize_db_and_folders(); |
354 | 354 | } |
355 | 355 | EEH_Activation::initialize_db_content(); |
356 | 356 | EEH_Activation::system_initialization(); |
357 | - if( $initialize_addons_too ) { |
|
357 | + if ($initialize_addons_too) { |
|
358 | 358 | $this->initialize_addons(); |
359 | 359 | } |
360 | - }else{ |
|
361 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
|
360 | + } else { |
|
361 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
362 | 362 | } |
363 | - if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
|
364 | - add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 ); |
|
363 | + if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) { |
|
364 | + add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9); |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
369 | 369 | * Initializes the db for all registered addons |
370 | 370 | */ |
371 | - public function initialize_addons(){ |
|
371 | + public function initialize_addons() { |
|
372 | 372 | //foreach registered addon, make sure its db is up-to-date too |
373 | - foreach($this->registry->addons as $addon){ |
|
373 | + foreach ($this->registry->addons as $addon) { |
|
374 | 374 | $addon->initialize_db_if_no_migrations_required(); |
375 | 375 | } |
376 | 376 | } |
@@ -382,16 +382,16 @@ discard block |
||
382 | 382 | * @param string $current_version_to_add version to be added to the version history |
383 | 383 | * @return boolean success as to whether or not this option was changed |
384 | 384 | */ |
385 | - public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
|
386 | - if( ! $version_history ) { |
|
385 | + public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) { |
|
386 | + if ( ! $version_history) { |
|
387 | 387 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
388 | 388 | } |
389 | - if( $current_version_to_add == NULL){ |
|
389 | + if ($current_version_to_add == NULL) { |
|
390 | 390 | $current_version_to_add = espresso_version(); |
391 | 391 | } |
392 | - $version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() ); |
|
392 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
393 | 393 | // re-save |
394 | - return update_option( 'espresso_db_update', $version_history ); |
|
394 | + return update_option('espresso_db_update', $version_history); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | * but still know if this is a new install or not |
409 | 409 | * @return int one of the constants on EE_System::req_type_ |
410 | 410 | */ |
411 | - public function detect_req_type( $espresso_db_update = NULL ){ |
|
412 | - if ( $this->_req_type === NULL ){ |
|
413 | - $espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
414 | - $this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() ); |
|
411 | + public function detect_req_type($espresso_db_update = NULL) { |
|
412 | + if ($this->_req_type === NULL) { |
|
413 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
414 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version()); |
|
415 | 415 | } |
416 | 416 | return $this->_req_type; |
417 | 417 | } |
@@ -427,39 +427,39 @@ discard block |
||
427 | 427 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version()) |
428 | 428 | * @return int one of the constants on EE_System::req_type_* |
429 | 429 | */ |
430 | - public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){ |
|
431 | - $version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ); |
|
432 | - if( $activation_history_for_addon ){ |
|
430 | + public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) { |
|
431 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
432 | + if ($activation_history_for_addon) { |
|
433 | 433 | //it exists, so this isn't a completely new install |
434 | 434 | //check if this version already in that list of previously installed versions |
435 | - if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) { |
|
435 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
436 | 436 | //it a version we haven't seen before |
437 | - if( $version_is_higher === 1 ){ |
|
437 | + if ($version_is_higher === 1) { |
|
438 | 438 | $req_type = EE_System::req_type_upgrade; |
439 | - }else{ |
|
439 | + } else { |
|
440 | 440 | $req_type = EE_System::req_type_downgrade; |
441 | 441 | } |
442 | - delete_option( $activation_indicator_option_name ); |
|
442 | + delete_option($activation_indicator_option_name); |
|
443 | 443 | } else { |
444 | 444 | // its not an update. maybe a reactivation? |
445 | - if( get_option( $activation_indicator_option_name, FALSE ) ){ |
|
446 | - if ( $version_is_higher === -1 ){ |
|
445 | + if (get_option($activation_indicator_option_name, FALSE)) { |
|
446 | + if ($version_is_higher === -1) { |
|
447 | 447 | $req_type = EE_System::req_type_downgrade; |
448 | - }elseif( $version_is_higher === 0 ){ |
|
448 | + }elseif ($version_is_higher === 0) { |
|
449 | 449 | //we've seen this version before, but it's an activation. must be a reactivation |
450 | 450 | $req_type = EE_System::req_type_reactivation; |
451 | - }else{//$version_is_higher === 1 |
|
451 | + } else {//$version_is_higher === 1 |
|
452 | 452 | $req_type = EE_System::req_type_upgrade; |
453 | 453 | } |
454 | - delete_option( $activation_indicator_option_name ); |
|
454 | + delete_option($activation_indicator_option_name); |
|
455 | 455 | } else { |
456 | 456 | //we've seen this version before and the activation indicate doesn't show it was just activated |
457 | - if ( $version_is_higher === -1 ){ |
|
457 | + if ($version_is_higher === -1) { |
|
458 | 458 | $req_type = EE_System::req_type_downgrade; |
459 | - }elseif( $version_is_higher === 0 ){ |
|
459 | + }elseif ($version_is_higher === 0) { |
|
460 | 460 | //we've seen this version before and it's not an activation. its normal request |
461 | 461 | $req_type = EE_System::req_type_normal; |
462 | - }else{//$version_is_higher === 1 |
|
462 | + } else {//$version_is_higher === 1 |
|
463 | 463 | $req_type = EE_System::req_type_upgrade; |
464 | 464 | } |
465 | 465 | } |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | } else { |
468 | 468 | //brand new install |
469 | 469 | $req_type = EE_System::req_type_new_activation; |
470 | - delete_option( $activation_indicator_option_name ); |
|
470 | + delete_option($activation_indicator_option_name); |
|
471 | 471 | } |
472 | 472 | return $req_type; |
473 | 473 | } |
@@ -485,30 +485,30 @@ discard block |
||
485 | 485 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
486 | 486 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
487 | 487 | */ |
488 | - protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){ |
|
488 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) { |
|
489 | 489 | //find the most recently-activated version |
490 | 490 | $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
491 | 491 | $most_recently_active_version = '0.0.0.dev.000'; |
492 | - if( is_array( $activation_history_for_addon ) ){ |
|
493 | - foreach( $activation_history_for_addon as $version => $times_activated ){ |
|
492 | + if (is_array($activation_history_for_addon)) { |
|
493 | + foreach ($activation_history_for_addon as $version => $times_activated) { |
|
494 | 494 | //check there is a record of when this version was activated. Otherwise, |
495 | 495 | //mark it as unknown |
496 | - if( ! $times_activated ){ |
|
497 | - $times_activated = array( 'unknown-date'); |
|
496 | + if ( ! $times_activated) { |
|
497 | + $times_activated = array('unknown-date'); |
|
498 | 498 | } |
499 | - if( is_string( $times_activated ) ){ |
|
500 | - $times_activated = array( $times_activated ); |
|
499 | + if (is_string($times_activated)) { |
|
500 | + $times_activated = array($times_activated); |
|
501 | 501 | } |
502 | - foreach( $times_activated as $an_activation ){ |
|
503 | - if( $an_activation != 'unknown-date' && |
|
504 | - $an_activation > $most_recently_active_version_activation ){ |
|
502 | + foreach ($times_activated as $an_activation) { |
|
503 | + if ($an_activation != 'unknown-date' && |
|
504 | + $an_activation > $most_recently_active_version_activation) { |
|
505 | 505 | $most_recently_active_version = $version; |
506 | 506 | $most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation; |
507 | 507 | } |
508 | 508 | } |
509 | 509 | } |
510 | 510 | } |
511 | - return version_compare( $version_to_upgrade_to, $most_recently_active_version ); |
|
511 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
@@ -518,24 +518,24 @@ discard block |
||
518 | 518 | * @return void |
519 | 519 | */ |
520 | 520 | public function redirect_to_about_ee() { |
521 | - $notices = EE_Error::get_notices( FALSE ); |
|
521 | + $notices = EE_Error::get_notices(FALSE); |
|
522 | 522 | //if current user is an admin and it's not an ajax request |
523 | 523 | if ( |
524 | - $this->registry->CAP->current_user_can( 'manage_options', 'espresso_about_default' ) |
|
525 | - && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
526 | - && ! isset( $notices[ 'errors' ] ) |
|
524 | + $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
525 | + && ! (defined('DOING_AJAX') && DOING_AJAX) |
|
526 | + && ! isset($notices['errors']) |
|
527 | 527 | ) { |
528 | - $query_params = array( 'page' => 'espresso_about' ); |
|
528 | + $query_params = array('page' => 'espresso_about'); |
|
529 | 529 | |
530 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
|
530 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
531 | 531 | $query_params['new_activation'] = TRUE; |
532 | 532 | } |
533 | 533 | |
534 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
|
534 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
535 | 535 | $query_params['reactivation'] = TRUE; |
536 | 536 | } |
537 | - $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
|
538 | - wp_safe_redirect( $url ); |
|
537 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
538 | + wp_safe_redirect($url); |
|
539 | 539 | exit(); |
540 | 540 | } |
541 | 541 | } |
@@ -549,31 +549,31 @@ discard block |
||
549 | 549 | * |
550 | 550 | * @return void |
551 | 551 | */ |
552 | - public function load_core_configuration(){ |
|
553 | - do_action( 'AHEE__EE_System__load_core_configuration__begin', $this ); |
|
554 | - $this->registry->load_core( 'EE_Load_Textdomain' ); |
|
552 | + public function load_core_configuration() { |
|
553 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
554 | + $this->registry->load_core('EE_Load_Textdomain'); |
|
555 | 555 | //load textdomain |
556 | 556 | EE_Load_Textdomain::load_textdomain(); |
557 | 557 | // load and setup EE_Config and EE_Network_Config |
558 | - $this->registry->load_core( 'Config' ); |
|
559 | - $this->registry->load_core( 'Network_Config' ); |
|
558 | + $this->registry->load_core('Config'); |
|
559 | + $this->registry->load_core('Network_Config'); |
|
560 | 560 | // setup autoloaders |
561 | 561 | // enable logging? |
562 | - if ( $this->registry->CFG->admin->use_full_logging ) { |
|
563 | - $this->registry->load_core( 'Log' ); |
|
562 | + if ($this->registry->CFG->admin->use_full_logging) { |
|
563 | + $this->registry->load_core('Log'); |
|
564 | 564 | } |
565 | 565 | // check for activation errors |
566 | - $activation_errors = get_option( 'ee_plugin_activation_errors', FALSE ); |
|
567 | - if ( $activation_errors ) { |
|
568 | - EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
569 | - update_option( 'ee_plugin_activation_errors', FALSE ); |
|
566 | + $activation_errors = get_option('ee_plugin_activation_errors', FALSE); |
|
567 | + if ($activation_errors) { |
|
568 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
569 | + update_option('ee_plugin_activation_errors', FALSE); |
|
570 | 570 | } |
571 | 571 | // get model names |
572 | 572 | $this->_parse_model_names(); |
573 | 573 | |
574 | 574 | //load caf stuff a chance to play during the activation process too. |
575 | 575 | $this->_maybe_brew_regular(); |
576 | - do_action( 'AHEE__EE_System__load_core_configuration__complete', $this ); |
|
576 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
@@ -582,23 +582,23 @@ discard block |
||
582 | 582 | * |
583 | 583 | * @return void |
584 | 584 | */ |
585 | - private function _parse_model_names(){ |
|
585 | + private function _parse_model_names() { |
|
586 | 586 | //get all the files in the EE_MODELS folder that end in .model.php |
587 | - $models = glob( EE_MODELS.'*.model.php'); |
|
587 | + $models = glob(EE_MODELS.'*.model.php'); |
|
588 | 588 | $model_names = array(); |
589 | 589 | $non_abstract_db_models = array(); |
590 | - foreach( $models as $model ){ |
|
590 | + foreach ($models as $model) { |
|
591 | 591 | // get model classname |
592 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model ); |
|
593 | - $short_name = str_replace( 'EEM_', '', $classname ); |
|
592 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
593 | + $short_name = str_replace('EEM_', '', $classname); |
|
594 | 594 | $reflectionClass = new ReflectionClass($classname); |
595 | - if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){ |
|
596 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
595 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
596 | + $non_abstract_db_models[$short_name] = $classname; |
|
597 | 597 | } |
598 | - $model_names[ $short_name ] = $classname; |
|
598 | + $model_names[$short_name] = $classname; |
|
599 | 599 | } |
600 | - $this->registry->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names ); |
|
601 | - $this->registry->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models ); |
|
600 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
601 | + $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | |
@@ -608,8 +608,8 @@ discard block |
||
608 | 608 | * @return void |
609 | 609 | */ |
610 | 610 | private function _maybe_brew_regular() { |
611 | - if (( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) { |
|
612 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
611 | + if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
612 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | |
@@ -626,9 +626,9 @@ discard block |
||
626 | 626 | * @return void |
627 | 627 | */ |
628 | 628 | public function register_shortcodes_modules_and_widgets() { |
629 | - do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
|
629 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
630 | 630 | // check for addons using old hookpoint |
631 | - if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) { |
|
631 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
632 | 632 | $this->_incompatible_addon_error(); |
633 | 633 | } |
634 | 634 | } |
@@ -642,19 +642,19 @@ discard block |
||
642 | 642 | */ |
643 | 643 | private function _incompatible_addon_error() { |
644 | 644 | // get array of classes hooking into here |
645 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
|
646 | - if ( ! empty( $class_names )) { |
|
647 | - $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' ); |
|
645 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
646 | + if ( ! empty($class_names)) { |
|
647 | + $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'); |
|
648 | 648 | $msg .= '<ul>'; |
649 | - foreach ( $class_names as $class_name ) { |
|
650 | - $msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>'; |
|
649 | + foreach ($class_names as $class_name) { |
|
650 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>'; |
|
651 | 651 | } |
652 | 652 | $msg .= '</ul>'; |
653 | - $msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' ); |
|
653 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso'); |
|
654 | 654 | // save list of incompatible addons to wp-options for later use |
655 | - add_option( 'ee_incompatible_addons', $class_names, '', 'no' ); |
|
656 | - if ( is_admin() ) { |
|
657 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
655 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
656 | + if (is_admin()) { |
|
657 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
658 | 658 | } |
659 | 659 | } |
660 | 660 | } |
@@ -671,25 +671,25 @@ discard block |
||
671 | 671 | * |
672 | 672 | * @return void |
673 | 673 | */ |
674 | - public function brew_espresso(){ |
|
675 | - do_action( 'AHEE__EE_System__brew_espresso__begin', $this ); |
|
674 | + public function brew_espresso() { |
|
675 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
676 | 676 | // load some final core systems |
677 | - add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 ); |
|
678 | - add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 ); |
|
679 | - add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 ); |
|
680 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
681 | - add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 ); |
|
682 | - add_action( 'init', array( $this, 'initialize' ), 10 ); |
|
683 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
684 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
685 | - add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 ); |
|
686 | - |
|
687 | - if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE ) ) { |
|
677 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
678 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
679 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
680 | + add_action('init', array($this, 'load_controllers'), 7); |
|
681 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
682 | + add_action('init', array($this, 'initialize'), 10); |
|
683 | + add_action('init', array($this, 'initialize_last'), 100); |
|
684 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
685 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
686 | + |
|
687 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) { |
|
688 | 688 | // pew pew pew |
689 | - $this->registry->load_core( 'PUE' ); |
|
690 | - do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' ); |
|
689 | + $this->registry->load_core('PUE'); |
|
690 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
691 | 691 | } |
692 | - do_action( 'AHEE__EE_System__brew_espresso__complete', $this ); |
|
692 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | */ |
704 | 704 | public function set_hooks_for_core() { |
705 | 705 | $this->_deactivate_incompatible_addons(); |
706 | - do_action( 'AHEE__EE_System__set_hooks_for_core' ); |
|
706 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | |
@@ -712,15 +712,15 @@ discard block |
||
712 | 712 | * Using the information gathered in EE_System::_incompatible_addon_error, |
713 | 713 | * deactivates any addons considered incompatible with the current version of EE |
714 | 714 | */ |
715 | - private function _deactivate_incompatible_addons(){ |
|
716 | - $incompatible_addons = get_option( 'ee_incompatible_addons', array() ); |
|
717 | - if ( ! empty( $incompatible_addons )) { |
|
718 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
719 | - foreach ( $active_plugins as $active_plugin ) { |
|
720 | - foreach ( $incompatible_addons as $incompatible_addon ) { |
|
721 | - if ( strpos( $active_plugin, $incompatible_addon ) !== FALSE ) { |
|
722 | - unset( $_GET['activate'] ); |
|
723 | - espresso_deactivate_plugin( $active_plugin ); |
|
715 | + private function _deactivate_incompatible_addons() { |
|
716 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
717 | + if ( ! empty($incompatible_addons)) { |
|
718 | + $active_plugins = get_option('active_plugins', array()); |
|
719 | + foreach ($active_plugins as $active_plugin) { |
|
720 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
721 | + if (strpos($active_plugin, $incompatible_addon) !== FALSE) { |
|
722 | + unset($_GET['activate']); |
|
723 | + espresso_deactivate_plugin($active_plugin); |
|
724 | 724 | } |
725 | 725 | } |
726 | 726 | } |
@@ -737,10 +737,10 @@ discard block |
||
737 | 737 | */ |
738 | 738 | public function perform_activations_upgrades_and_migrations() { |
739 | 739 | //first check if we had previously attempted to setup EE's directories but failed |
740 | - if( EEH_Activation::upload_directories_incomplete() ) { |
|
740 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
741 | 741 | EEH_Activation::create_upload_directories(); |
742 | 742 | } |
743 | - do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
743 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | |
@@ -752,10 +752,10 @@ discard block |
||
752 | 752 | * @return void |
753 | 753 | */ |
754 | 754 | public function load_CPTs_and_session() { |
755 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__start' ); |
|
755 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
756 | 756 | // register Custom Post Types |
757 | - $this->registry->load_core( 'Register_CPTs' ); |
|
758 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ); |
|
757 | + $this->registry->load_core('Register_CPTs'); |
|
758 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | |
@@ -770,16 +770,16 @@ discard block |
||
770 | 770 | * @return void |
771 | 771 | */ |
772 | 772 | public function load_controllers() { |
773 | - do_action( 'AHEE__EE_System__load_controllers__start' ); |
|
773 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
774 | 774 | // let's get it started |
775 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
776 | - do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' ); |
|
777 | - $this->registry->load_core( 'Front_Controller', array(), false, true ); |
|
778 | - } else if ( ! EE_FRONT_AJAX ) { |
|
779 | - do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' ); |
|
780 | - EE_Registry::instance()->load_core( 'Admin' ); |
|
775 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
776 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
777 | + $this->registry->load_core('Front_Controller', array(), false, true); |
|
778 | + } else if ( ! EE_FRONT_AJAX) { |
|
779 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
780 | + EE_Registry::instance()->load_core('Admin'); |
|
781 | 781 | } |
782 | - do_action( 'AHEE__EE_System__load_controllers__complete' ); |
|
782 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | |
@@ -793,9 +793,9 @@ discard block |
||
793 | 793 | * @return void |
794 | 794 | */ |
795 | 795 | public function core_loaded_and_ready() { |
796 | - do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
|
797 | - do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
798 | - $this->registry->load_core( 'Session' ); |
|
796 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
797 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
798 | + $this->registry->load_core('Session'); |
|
799 | 799 | // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
800 | 800 | } |
801 | 801 | |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | * @return void |
811 | 811 | */ |
812 | 812 | public function initialize() { |
813 | - do_action( 'AHEE__EE_System__initialize' ); |
|
813 | + do_action('AHEE__EE_System__initialize'); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | * @return void |
825 | 825 | */ |
826 | 826 | public function initialize_last() { |
827 | - do_action( 'AHEE__EE_System__initialize_last' ); |
|
827 | + do_action('AHEE__EE_System__initialize_last'); |
|
828 | 828 | } |
829 | 829 | |
830 | 830 | |
@@ -856,21 +856,21 @@ discard block |
||
856 | 856 | */ |
857 | 857 | public static function do_not_cache() { |
858 | 858 | // set no cache constants |
859 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
860 | - define( 'DONOTCACHEPAGE', true ); |
|
859 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
860 | + define('DONOTCACHEPAGE', true); |
|
861 | 861 | } |
862 | - if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { |
|
863 | - define( 'DONOTCACHCEOBJECT', true ); |
|
862 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
863 | + define('DONOTCACHCEOBJECT', true); |
|
864 | 864 | } |
865 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
866 | - define( 'DONOTCACHEDB', true ); |
|
865 | + if ( ! defined('DONOTCACHEDB')) { |
|
866 | + define('DONOTCACHEDB', true); |
|
867 | 867 | } |
868 | 868 | // add no cache headers |
869 | - add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 ); |
|
869 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
870 | 870 | // plus a little extra for nginx and Google Chrome |
871 | - add_filter( 'nocache_headers', array( 'EE_System', 'extra_nocache_headers' ), 10, 1 ); |
|
871 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
872 | 872 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
873 | - remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); |
|
873 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | * @param $headers |
883 | 883 | * @return array |
884 | 884 | */ |
885 | - public static function extra_nocache_headers ( $headers ) { |
|
885 | + public static function extra_nocache_headers($headers) { |
|
886 | 886 | // for NGINX |
887 | 887 | $headers['X-Accel-Expires'] = 0; |
888 | 888 | // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
@@ -911,14 +911,14 @@ discard block |
||
911 | 911 | * @param WP_Admin_Bar $admin_bar |
912 | 912 | * @return void |
913 | 913 | */ |
914 | - public function espresso_toolbar_items( WP_Admin_Bar $admin_bar ) { |
|
914 | + public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) { |
|
915 | 915 | |
916 | 916 | // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
917 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! $this->registry->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) { |
|
917 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) { |
|
918 | 918 | return; |
919 | 919 | } |
920 | 920 | |
921 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
921 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
922 | 922 | $menu_class = 'espresso_menu_item_class'; |
923 | 923 | //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
924 | 924 | //because they're only defined in each of their respective constructors |
@@ -930,20 +930,20 @@ discard block |
||
930 | 930 | //Top Level |
931 | 931 | $admin_bar->add_menu(array( |
932 | 932 | 'id' => 'espresso-toolbar', |
933 | - '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>', |
|
933 | + '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>', |
|
934 | 934 | 'href' => $events_admin_url, |
935 | 935 | 'meta' => array( |
936 | 936 | 'title' => __('Event Espresso', 'event_espresso'), |
937 | - 'class' => $menu_class . 'first' |
|
937 | + 'class' => $menu_class.'first' |
|
938 | 938 | ), |
939 | 939 | )); |
940 | 940 | |
941 | 941 | //Events |
942 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) { |
|
942 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
943 | 943 | $admin_bar->add_menu(array( |
944 | 944 | 'id' => 'espresso-toolbar-events', |
945 | 945 | 'parent' => 'espresso-toolbar', |
946 | - 'title' => __( 'Events', 'event_espresso' ), |
|
946 | + 'title' => __('Events', 'event_espresso'), |
|
947 | 947 | 'href' => $events_admin_url, |
948 | 948 | 'meta' => array( |
949 | 949 | 'title' => __('Events', 'event_espresso'), |
@@ -954,13 +954,13 @@ discard block |
||
954 | 954 | } |
955 | 955 | |
956 | 956 | |
957 | - if ( $this->registry->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) { |
|
957 | + if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
958 | 958 | //Events Add New |
959 | 959 | $admin_bar->add_menu(array( |
960 | 960 | 'id' => 'espresso-toolbar-events-new', |
961 | 961 | 'parent' => 'espresso-toolbar-events', |
962 | 962 | 'title' => __('Add New', 'event_espresso'), |
963 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ), |
|
963 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url), |
|
964 | 964 | 'meta' => array( |
965 | 965 | 'title' => __('Add New', 'event_espresso'), |
966 | 966 | 'target' => '', |
@@ -969,18 +969,18 @@ discard block |
||
969 | 969 | )); |
970 | 970 | } |
971 | 971 | |
972 | - if ( is_single() && ( get_post_type() == 'espresso_events' ) ) { |
|
972 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
973 | 973 | |
974 | 974 | //Current post |
975 | 975 | global $post; |
976 | 976 | |
977 | - if ( $this->registry->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
977 | + if ($this->registry->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) { |
|
978 | 978 | //Events Edit Current Event |
979 | 979 | $admin_bar->add_menu(array( |
980 | 980 | 'id' => 'espresso-toolbar-events-edit', |
981 | 981 | 'parent' => 'espresso-toolbar-events', |
982 | 982 | 'title' => __('Edit Event', 'event_espresso'), |
983 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ), |
|
983 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$post->ID), $events_admin_url), |
|
984 | 984 | 'meta' => array( |
985 | 985 | 'title' => __('Edit Event', 'event_espresso'), |
986 | 986 | 'target' => '', |
@@ -992,11 +992,11 @@ discard block |
||
992 | 992 | } |
993 | 993 | |
994 | 994 | //Events View |
995 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) { |
|
995 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) { |
|
996 | 996 | $admin_bar->add_menu(array( |
997 | 997 | 'id' => 'espresso-toolbar-events-view', |
998 | 998 | 'parent' => 'espresso-toolbar-events', |
999 | - 'title' => __( 'View', 'event_espresso' ), |
|
999 | + 'title' => __('View', 'event_espresso'), |
|
1000 | 1000 | 'href' => $events_admin_url, |
1001 | 1001 | 'meta' => array( |
1002 | 1002 | 'title' => __('View', 'event_espresso'), |
@@ -1006,12 +1006,12 @@ discard block |
||
1006 | 1006 | )); |
1007 | 1007 | } |
1008 | 1008 | |
1009 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) { |
|
1009 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1010 | 1010 | //Events View All |
1011 | 1011 | $admin_bar->add_menu(array( |
1012 | 1012 | 'id' => 'espresso-toolbar-events-all', |
1013 | 1013 | 'parent' => 'espresso-toolbar-events-view', |
1014 | - 'title' => __( 'All', 'event_espresso' ), |
|
1014 | + 'title' => __('All', 'event_espresso'), |
|
1015 | 1015 | 'href' => $events_admin_url, |
1016 | 1016 | 'meta' => array( |
1017 | 1017 | 'title' => __('All', 'event_espresso'), |
@@ -1022,13 +1022,13 @@ discard block |
||
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | |
1025 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) { |
|
1025 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) { |
|
1026 | 1026 | //Events View Today |
1027 | 1027 | $admin_bar->add_menu(array( |
1028 | 1028 | 'id' => 'espresso-toolbar-events-today', |
1029 | 1029 | 'parent' => 'espresso-toolbar-events-view', |
1030 | 1030 | 'title' => __('Today', 'event_espresso'), |
1031 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ), |
|
1031 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url), |
|
1032 | 1032 | 'meta' => array( |
1033 | 1033 | 'title' => __('Today', 'event_espresso'), |
1034 | 1034 | 'target' => '', |
@@ -1038,13 +1038,13 @@ discard block |
||
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | |
1041 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) { |
|
1041 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) { |
|
1042 | 1042 | //Events View This Month |
1043 | 1043 | $admin_bar->add_menu(array( |
1044 | 1044 | 'id' => 'espresso-toolbar-events-month', |
1045 | 1045 | 'parent' => 'espresso-toolbar-events-view', |
1046 | - 'title' => __( 'This Month', 'event_espresso'), |
|
1047 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ), |
|
1046 | + 'title' => __('This Month', 'event_espresso'), |
|
1047 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url), |
|
1048 | 1048 | 'meta' => array( |
1049 | 1049 | 'title' => __('This Month', 'event_espresso'), |
1050 | 1050 | 'target' => '', |
@@ -1054,11 +1054,11 @@ discard block |
||
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | //Registration Overview |
1057 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) { |
|
1057 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) { |
|
1058 | 1058 | $admin_bar->add_menu(array( |
1059 | 1059 | 'id' => 'espresso-toolbar-registrations', |
1060 | 1060 | 'parent' => 'espresso-toolbar', |
1061 | - 'title' => __( 'Registrations', 'event_espresso' ), |
|
1061 | + 'title' => __('Registrations', 'event_espresso'), |
|
1062 | 1062 | 'href' => $reg_admin_url, |
1063 | 1063 | 'meta' => array( |
1064 | 1064 | 'title' => __('Registrations', 'event_espresso'), |
@@ -1069,12 +1069,12 @@ discard block |
||
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | //Registration Overview Today |
1072 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) { |
|
1072 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) { |
|
1073 | 1073 | $admin_bar->add_menu(array( |
1074 | 1074 | 'id' => 'espresso-toolbar-registrations-today', |
1075 | 1075 | 'parent' => 'espresso-toolbar-registrations', |
1076 | - 'title' => __( 'Today', 'event_espresso'), |
|
1077 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ), |
|
1076 | + 'title' => __('Today', 'event_espresso'), |
|
1077 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url), |
|
1078 | 1078 | 'meta' => array( |
1079 | 1079 | 'title' => __('Today', 'event_espresso'), |
1080 | 1080 | 'target' => '', |
@@ -1084,14 +1084,14 @@ discard block |
||
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | //Registration Overview Today Completed |
1087 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) { |
|
1087 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) { |
|
1088 | 1088 | $admin_bar->add_menu(array( |
1089 | 1089 | 'id' => 'espresso-toolbar-registrations-today-approved', |
1090 | 1090 | 'parent' => 'espresso-toolbar-registrations-today', |
1091 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1092 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1091 | + 'title' => __('Approved', 'event_espresso'), |
|
1092 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1093 | 1093 | 'meta' => array( |
1094 | - 'title' => __('Approved', 'event_espresso' ), |
|
1094 | + 'title' => __('Approved', 'event_espresso'), |
|
1095 | 1095 | 'target' => '', |
1096 | 1096 | 'class' => $menu_class |
1097 | 1097 | ), |
@@ -1099,14 +1099,14 @@ discard block |
||
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | //Registration Overview Today Pending\ |
1102 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) { |
|
1102 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) { |
|
1103 | 1103 | $admin_bar->add_menu(array( |
1104 | 1104 | 'id' => 'espresso-toolbar-registrations-today-pending', |
1105 | 1105 | 'parent' => 'espresso-toolbar-registrations-today', |
1106 | - 'title' => __( 'Pending', 'event_espresso' ), |
|
1107 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1106 | + 'title' => __('Pending', 'event_espresso'), |
|
1107 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1108 | 1108 | 'meta' => array( |
1109 | - 'title' => __('Pending Payment', 'event_espresso' ), |
|
1109 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1110 | 1110 | 'target' => '', |
1111 | 1111 | 'class' => $menu_class |
1112 | 1112 | ), |
@@ -1114,14 +1114,14 @@ discard block |
||
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | //Registration Overview Today Incomplete |
1117 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) { |
|
1117 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) { |
|
1118 | 1118 | $admin_bar->add_menu(array( |
1119 | 1119 | 'id' => 'espresso-toolbar-registrations-today-not-approved', |
1120 | 1120 | 'parent' => 'espresso-toolbar-registrations-today', |
1121 | - 'title' => __( 'Not Approved', 'event_espresso' ), |
|
1122 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1121 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1122 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1123 | 1123 | 'meta' => array( |
1124 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1124 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1125 | 1125 | 'target' => '', |
1126 | 1126 | 'class' => $menu_class |
1127 | 1127 | ), |
@@ -1129,12 +1129,12 @@ discard block |
||
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | //Registration Overview Today Incomplete |
1132 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) { |
|
1132 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) { |
|
1133 | 1133 | $admin_bar->add_menu(array( |
1134 | 1134 | 'id' => 'espresso-toolbar-registrations-today-cancelled', |
1135 | 1135 | 'parent' => 'espresso-toolbar-registrations-today', |
1136 | - 'title' => __( 'Cancelled', 'event_espresso'), |
|
1137 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1136 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1137 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1138 | 1138 | 'meta' => array( |
1139 | 1139 | 'title' => __('Cancelled', 'event_espresso'), |
1140 | 1140 | 'target' => '', |
@@ -1144,12 +1144,12 @@ discard block |
||
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | //Registration Overview This Month |
1147 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) { |
|
1147 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) { |
|
1148 | 1148 | $admin_bar->add_menu(array( |
1149 | 1149 | 'id' => 'espresso-toolbar-registrations-month', |
1150 | 1150 | 'parent' => 'espresso-toolbar-registrations', |
1151 | - 'title' => __( 'This Month', 'event_espresso' ), |
|
1152 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ), |
|
1151 | + 'title' => __('This Month', 'event_espresso'), |
|
1152 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url), |
|
1153 | 1153 | 'meta' => array( |
1154 | 1154 | 'title' => __('This Month', 'event_espresso'), |
1155 | 1155 | 'target' => '', |
@@ -1159,12 +1159,12 @@ discard block |
||
1159 | 1159 | } |
1160 | 1160 | |
1161 | 1161 | //Registration Overview This Month Approved |
1162 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) { |
|
1162 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) { |
|
1163 | 1163 | $admin_bar->add_menu(array( |
1164 | 1164 | 'id' => 'espresso-toolbar-registrations-month-approved', |
1165 | 1165 | 'parent' => 'espresso-toolbar-registrations-month', |
1166 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1167 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1166 | + 'title' => __('Approved', 'event_espresso'), |
|
1167 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1168 | 1168 | 'meta' => array( |
1169 | 1169 | 'title' => __('Approved', 'event_espresso'), |
1170 | 1170 | 'target' => '', |
@@ -1174,12 +1174,12 @@ discard block |
||
1174 | 1174 | } |
1175 | 1175 | |
1176 | 1176 | //Registration Overview This Month Pending |
1177 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) { |
|
1177 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) { |
|
1178 | 1178 | $admin_bar->add_menu(array( |
1179 | 1179 | 'id' => 'espresso-toolbar-registrations-month-pending', |
1180 | 1180 | 'parent' => 'espresso-toolbar-registrations-month', |
1181 | - 'title' => __( 'Pending', 'event_espresso'), |
|
1182 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1181 | + 'title' => __('Pending', 'event_espresso'), |
|
1182 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1183 | 1183 | 'meta' => array( |
1184 | 1184 | 'title' => __('Pending', 'event_espresso'), |
1185 | 1185 | 'target' => '', |
@@ -1189,14 +1189,14 @@ discard block |
||
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | //Registration Overview This Month Not Approved |
1192 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) { |
|
1192 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) { |
|
1193 | 1193 | $admin_bar->add_menu(array( |
1194 | 1194 | 'id' => 'espresso-toolbar-registrations-month-not-approved', |
1195 | 1195 | 'parent' => 'espresso-toolbar-registrations-month', |
1196 | - 'title' => __( 'Not Approved', 'event_espresso'), |
|
1197 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1196 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1197 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1198 | 1198 | 'meta' => array( |
1199 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1199 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1200 | 1200 | 'target' => '', |
1201 | 1201 | 'class' => $menu_class |
1202 | 1202 | ), |
@@ -1205,12 +1205,12 @@ discard block |
||
1205 | 1205 | |
1206 | 1206 | |
1207 | 1207 | //Registration Overview This Month Cancelled |
1208 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) { |
|
1208 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) { |
|
1209 | 1209 | $admin_bar->add_menu(array( |
1210 | 1210 | 'id' => 'espresso-toolbar-registrations-month-cancelled', |
1211 | 1211 | 'parent' => 'espresso-toolbar-registrations-month', |
1212 | 1212 | 'title' => __('Cancelled', 'event_espresso'), |
1213 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1213 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1214 | 1214 | 'meta' => array( |
1215 | 1215 | 'title' => __('Cancelled', 'event_espresso'), |
1216 | 1216 | 'target' => '', |
@@ -1220,11 +1220,11 @@ discard block |
||
1220 | 1220 | } |
1221 | 1221 | |
1222 | 1222 | //Extensions & Services |
1223 | - if ( $this->registry->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) { |
|
1223 | + if ($this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) { |
|
1224 | 1224 | $admin_bar->add_menu(array( |
1225 | 1225 | 'id' => 'espresso-toolbar-extensions-and-services', |
1226 | 1226 | 'parent' => 'espresso-toolbar', |
1227 | - 'title' => __( 'Extensions & Services', 'event_espresso' ), |
|
1227 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1228 | 1228 | 'href' => $extensions_admin_url, |
1229 | 1229 | 'meta' => array( |
1230 | 1230 | 'title' => __('Extensions & Services', 'event_espresso'), |
@@ -1246,8 +1246,8 @@ discard block |
||
1246 | 1246 | * @param array $exclude_array any existing pages being excluded are in this array. |
1247 | 1247 | * @return array |
1248 | 1248 | */ |
1249 | - public function remove_pages_from_wp_list_pages( $exclude_array ) { |
|
1250 | - return array_merge( $exclude_array, $this->registry->CFG->core->get_critical_pages_array() ); |
|
1249 | + public function remove_pages_from_wp_list_pages($exclude_array) { |
|
1250 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1251 | 1251 | } |
1252 | 1252 | |
1253 | 1253 | |
@@ -1267,12 +1267,12 @@ discard block |
||
1267 | 1267 | */ |
1268 | 1268 | public function wp_enqueue_scripts() { |
1269 | 1269 | // 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' ); |
1270 | - if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) { |
|
1270 | + if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) { |
|
1271 | 1271 | // 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' ); |
1272 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
1272 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
1273 | 1273 | // register jQuery Validate and additional methods |
1274 | - wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery' ), '1.15.0', TRUE ); |
|
1275 | - 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 ); |
|
1274 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
1275 | + 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); |
|
1276 | 1276 | } |
1277 | 1277 | } |
1278 | 1278 | } |